fix: keep spinner titles animating without waking the app on every frame
Status: rebased onto main (623e5bcbb80) as a linear 6-commit stack, no merge commits. Conflicts resolved: upstream's AutomaticTerminalTitle bounding (a9547067ddb-era #13009) now runs first, the PR's position-independent spinner removal operates on the bounded title; Workspace.updatePanelTitle keeps upstream's cloud-title projection and adds the stableTitle parameter; the upstream Bool-returning TabManager.updatePanelTitle(tabId:panelId:title:) overload is preserved alongside the PR's stable-title variant. Local focused tests: all 12 TerminalTitleChurnFilterTests pass (swift test --filter TerminalTitleChurnFilterTests), including upstream's new bounding tests. App-host build locally is blocked by an Xcode 27 issue that reproduces on pristine main; CI is the arbiter.
Reviewer's guide
- Read
TerminalTitleChurnFilter(frame classification) first, thenGhosttyTitleUpdateIngressandWorkspace+TitleOwnership.updatePanelTitle. - Tests:
TerminalTitleChurnFilterTests.swift,cmuxTests/GhosttyTitleUpdateIngressTests.swift. - The point of the change: a frame that only advances a spinner refreshes the tab label and stops. Everything else keys off the stable title, so it never writes
@Publishedstate and never reaches the sidebar or titlebar.
A spinner frame is cheap to draw and expensive to announce. cmux currently announces it: every tick of ✳ Working or π ⠋ safety-rating is a new title string, so it flows through the workspace title, the sidebar's observation stream, the titlebar, and the toolbar. On a window running several agents that is the app re-laying itself out to move one glyph.
This keeps the animation and cuts the announcement.
Why the earlier approach was wrong
The first version of this PR removed the frame from the title, which is what TerminalTitleChurnFilter already did for Braille spinners on main. It works, and dogfooding showed why it should not ship: the tab stops animating. Widening the frame set to the glyphs agents actually use just made the existing behavior visible. Losing the animation to save CPU is paying with the feature.
Change
GhosttyTitleUpdate and GhosttyTitleChange carry two strings:
titlestays the frame the terminal emitted, spinner included.stableTitleis that frame with a standalone spinner glyph removed, so consecutive ticks share one.isSpinnerFrameOnlyistitle != stableTitle.
The ingress forwards every frame again instead of collapsing them, so the label still has something to animate with. The saving comes from what each consumer does with it:
| consumer | on a spinner-only frame |
|---|---|
Workspace.updatePanelTitle | refreshes the AppKit tab label, then returns before touching @Published panelTitles or applyFocusedPanelTitle |
TabManager.updatePanelTitle | skips the window title and the display-title comparison |
ContentView.onReceive | skips scheduleTitlebarTextRefresh |
WindowToolbarController | skips scheduleFocusedCommandTextUpdate |
panelTitles doubles as the memo, since it already holds the last stable label, so the change adds no new state.
The tab label path is bonsplitController.updateTab. BonsplitController is a plain final class with no @Published and no ObservableObject conformance, so that call is an AppKit label redraw rather than a SwiftUI invalidation. That is what makes it safe to run on every frame.
Also extends the frame set past Braille to U+2731...U+273D (asterisks, which is what Claude Code animates) and U+25D0...U+25D3 / U+25F4...U+25F7 (circles), and drops the leading-position requirement so a branded title like π ⠋ label is recognized. Sampling a live 20-surface window, every animated title used a glyph or a position the old filter missed, so it collapsed nothing there.
Deleted test, deliberately
spinnerFramesCollapseBeforeAsyncStreamEnqueue asserted submitted == (index == 0), i.e. that frames are dropped at the ingress. That assertion is the animation bug, so it is replaced by:
spinnerFramesAreForwardedSoTheTabLabelKeepsAnimatingrepeatedIdenticalFrameIsStillRejected, so the plain duplicate guard is still covered- three tests over the
stableTitle/isSpinnerFrameOnlycontract, including the legacy-payload fallback
Verification
xcodebuild -scheme cmux -configuration Debug: BUILD SUCCEEDED.
I cannot run cmuxTests locally, so CI is the gate there. The churn filter itself I exercised through a standalone harness compiling the real source file alongside every pre-existing assertion plus the new ones: 23 pass, and against unmodified main the new cases fail.
Both new fields default to nil and fall back to the raw title, so the other GhosttyTitleChange(...) and updatePanelTitle(...) call sites compile unchanged and treat their input as a real change, which is the safe direction.
Running it: the tab animates as before, and the sidebar's own ✦ Running indicator is unaffected since it comes from agent status rather than the title.
Not in this PR
The per-frame NotificationCenter post stays. Removing it needs a display-only sink from the ingress to the tab bar, which is a bigger change; this cuts the cascade behind the post, which is the expensive half.
Related: #10348, #6599. Supersedes #9094.
Summary by CodeRabbit
-
Bug Fixes
- Terminal titles now remain stable while spinner animations update, reducing unnecessary tab, sidebar, and workspace refreshes.
- Spinner-only titles are ignored, while meaningful title changes continue to appear immediately.
- Title normalization now supports additional spinner styles without altering ordinary symbols or branded titles.
-
Tests
- Expanded coverage for spinner frames, embedded titles, stable-title handling, deduplication, and legacy notification behavior.