Skip to content

Terminal title changes update the app once instead of twice - #46507

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/parked-title-one-notification
Nov 21, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/parked-title-one-notification

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When a terminal changes its title, the app used to tell the rest of the app about it twice in a row: once for the pane's own title and once for the tab's title. Every part of the app that watches for changes woke up both times. Now both titles change together, so everything wakes up once. Two of those watchers also used to look through every workspace on each title change; now they only look at the one that changed. Nothing looks different.

What Changed

Before: a terminal title change made two separate store updates: one for the pane title and one for the tab title when that pane is the tab's active split. This happened for parked (hidden) terminals and for visible ones. Every store subscriber ran twice per title change.

After: a single store update writes both. Subscribers run once. If neither title actually changed, there's no update and no notification, as before.

Mechanism: setRuntimePaneTitle takes an optional { alsoTabTitle } flag. With it set, one set() call computes the pane-title patch and then runs the existing applyTerminalTabTitleUpdates against the post-pane sortEpoch. This keeps the result identical to the old back-to-back calls, including the double sort bump when both changes reclassify an inactive workspace. The parked terminal watcher's title callback now uses this flag instead of making two calls. So do the three visible-terminal call sites: title observation, the inferred-interrupt title reset and the confirmed-shell title reset. In title observation the tab title is now written together with the pane title, a few lines earlier than before. Nothing in between reads the tab title. The pane-title logic moved unchanged into a runtimePaneTitlePatch function.

Two store subscribers that every title change reaches also stop scanning all workspaces:

  • terminalTabNamesChanged (tab-name sync) used to call Object.keys on the whole tab map and walk every workspace key. It now reads the changed workspace ids from the store's existing write provenance (readTabMapChanges). It falls back to the old full walk only when a write wasn't annotated.
  • countLiveWorktrees (sidebar sort settling) used to walk every worktree on each sort bump. Title churn bumps the sort counter without changing worktree rows, so the count is now reused until the rows object changes.

Why

Store notifications from background terminal title changes showed up in 28 of 74 sampled long tasks on a large profile. Each title change paid the full subscriber fan-out twice. Combining the two writes halves that cost without changing any title behavior.

Linked Issue

N/A (internal performance report)

Visual Proof

N/A: no visual or interaction change. Titles end up exactly as before; only how many store updates it takes changed.

Testing

  • I manually tested these changes locally (timing harness below, macOS)
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

The existing fanout perf contract in terminal-title-fanout.performance.test.ts now also includes the tab-name sync subscriber; it fails (2 scans instead of 0) if that subscriber goes back to scanning all workspaces. Also added a contract there: a title change that drives its tab notifies store subscribers exactly once, writes both titles, and notifies zero times when repeated with the same title.

Timing, measured with a throwaway harness (not committed) on head 500bc14: 1,900 workspaces, the real title-change store subscribers attached (including tab-name sync), 1,000 unique title changes per mode, macOS. Both modes run on the same head, so this isolates the one-write change; the scan fixes help both modes equally.

  • Two calls (old shape): median 355 µs, p90 583 µs, 200 store notifications per 100 changes.
  • One call (new): median 319 µs, p90 468 µs, 100 store notifications per 100 changes.

Platforms: macOS (unit + timing). The change is platform-independent renderer store code; CI covers Linux and Windows.

Performance

Improves: half the store notifications per terminal title change (parked and visible) when the pane drives its tab. Measured at 1,900 workspaces: about 10% lower median and 20% lower p90 per change. Visible terminals use the same store action. No new work for anyone: the combined path calls the same two existing reducers. Per title change, tab-name sync goes from O(workspaces) to O(changed workspaces), and the live-worktree count goes from O(worktrees) to O(1). It still recounts all worktrees when the worktree rows themselves change.

Risk

Low. The riskiest part is ordering inside the combined update: the tab-title step has to see the pane step's sortEpoch bump. It does, so the result matches the old two calls. If it went wrong, a background workspace could sort one step differently. The second risk is the visible-terminal title observation, where the tab title is now written slightly earlier, before agent completion tracking sees the title. Completion tracking reads only agent status, not the tab title, and sends its notifications later from timers. The remaining setRuntimePaneTitle callers (parked-watcher restarts) pass no options and behave exactly as before. The scan fixes keep a full-walk fallback for unannotated writes, and the live-worktree count recomputes whenever the worktree rows change. Back out with a plain revert.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Does not overlap #46016 (main-process mailbox writes) or #45731 (session persistence keys); neither touches this renderer call site.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: #46507 at e1fc16fb8e6 (base f2be6077d05)

Result: pass. No findings. The change strictly lowers work. Each parked-terminal title change that drives its tab title now makes one store set() and one subscriber notification pass, down from two. The work done inside the updater matches base call for call. It adds no timers, IPC, subscriptions, or scans.

Work the diff adds or changes

Work Trigger Population Bound
onTitleChange → setRuntimePaneTitle(tabId, paneId, title, { alsoTabTitle }) (parked-terminal-byte-watcher.ts:144-148) Every OSC title the parked byte watcher observes (pty-output-title-observer.ts:76-78). This includes agent spinner frames, up to ~10/s per working agent. One call per parked pane with title output. At the reference fleet: a few hundred terminals and 100+ agents. One store set() per observed title. Base made two: setRuntimePaneTitle, then updateTabTitle.
runtimePaneTitlePatch (terminal-tab-presentation.ts:204-233) Same One pane Same code as base, moved: O(1) equality check, decorative-frame gate, and a classification compare. Owner lookup goes through the cached shared owner index. One replaceRecordEntries runs only on a real change.
applyTerminalTabTitleUpdates called inside the same updater (terminal-tab-presentation.ts:157-168) Same, when drivesTabTitle The owner worktree's tabs only Same function and inputs as base updateTabTitle. Its owner stage is O(tabs in one worktree), and the existing N/10N contract in this file pins it at 0 rows scanned in other workspaces. sortEpoch composes in the same order as before: the pane bump is applied first, then the tab bump.
scheduleRuntimeGraphSync() Tab title actually changed Global Unchanged count. Already called inside the updater at base, and coalesced to one pending timer (graph-sync-scheduler.ts:28-43).
withStatusTransaction wrapper per set() (status-transaction-boundary.ts:28-63) Every call Global Halved. A changed write pays one {...get(), ...requested} copy of the full state plus agent-status staging. A no-op write (equal title or decorative frame) returns early at requested === current, and it now hits that early return once instead of twice.

Store write: listener census at this head

Zustand runs every listener on every notification, whichever field changed. A driving title change touches runtimePaneTitlesByTabId, plus tabsByWorktree/unifiedTabsByWorktree and possibly sortEpoch. These are all the subscribers it reaches, including in unchanged files.

Always installed, non-React

  • Store-internal listeners: installSettledSortEpoch (settled-sort-epoch.ts:45), with an identity check on sortEpoch/worktree rows. Also installStoreListenerCensus (counts at subscribe time only) and the withStatusTransaction error-wrapper around each listener.
  • installTerminalParkingInputs (terminal-parking-input-transitions.ts:20). Its body runs on every write. It then diffs only the changed buckets and the title keys of changed tabs.
  • Runtime graph sync key (use-runtime-graph-sync.ts:30). About 22 identity checks. A title change always rebuilds the key and schedules one coalesced sync. A tabsByWorktree change rebuilds the mobile tabs projection over all tabs.
  • wsl-host-ipc-bridge.ts:135. Identity-gated. Only when WSL is serving does it run selectWslHostsWithVisibleWork twice, and it sends IPC only when the result differs.
  • legacy-chat-rename-migration.ts:80: O(chat tabs) on a unifiedTabsByWorktree change.
  • StructuredAgentSessionStatusBridge.tsx:355: addressed diffs per changed workspace.
  • agent-status-ipc-bridge.ts:271: retry gate, then keyedListsMatch over changed buckets only.
  • installPRAutoRefreshCadenceObserver, runtime-file-position.ts:110, sleeping-records-to-layout-owner.ts:15, web-session-visible-tab-pick-report.ts:76, worktree-operation-store.ts:131, connector-connect-state.ts:322, connector-host-state.ts:228, ipynb-kernel-session.ts:310. Each is gated on an unrelated field and does no work on a title write.

Refcounted or open-surface, non-React

  • activity-thread-projection.ts:128. No gate: notifies every reader, and each runs a shallow compare over ~20 fields.
  • structured-chat-name-observation.ts:116 and bot-background-sessions.ts:225, gated on unifiedTabsByWorktree.
  • terminal-pane-attention-subscriptions.ts:73, no work on a title write.
  • SpaceWindowStatePublisher.tsx:46, only while that window is open. It runs two Object.values passes of ~35 fields per write and queues a 100 ms IPC publish when titles or tabs change.

Transient, one flow each

  • web-runtime-browser-creation-context.ts:170, native-chat-side-chat-placement.ts:151, browser-request-ipc-bridge.ts:31, mobile-terminal-close-ipc-bridge.ts:67 (ungated check), worktree-agent-activation-gate.ts:73, wake-sleeping-agents-in-background.ts:33.
  • agent-terminal-presence.ts:64: until its agent appears, a tabs change scans all worktrees.

React useAppStore hooks: one listener per mounted hook

  • Sidebar worktree cards. use-worktree-activity-status.ts:65-75 is mounted once per visible card. Its per-worktree title selector caches by source identity, so each title write starts a new generation and every mounted card rebuilds its own record. That is O(all tabs across mounted cards) per notification.
  • Tab bar and panes. use-terminal-tab-activity.ts:71 (one per tab) and use-terminal-pane-tab-state.ts:19-31 (one per pane) compare one tab's slot.
  • Dashboard drawer, while mounted. useLiveDashboardSnapshot.ts:18-28 subscribes to the whole tabsByWorktree, unifiedTabsByWorktree and runtimePaneTitlesByTabId maps. Every title write re-runs buildDashboardSnapshot over all worktrees.
  • Ungated whole-map selectors: StatusBarAccountControls.tsx:11, use-workspace-space-manager-bindings.ts:27,31, use-worktree-jump-palette-store-state.ts:102.
  • Gated whole-map selectors: the resources status segment (on viewActive), the palette live status (on active), the send-target popover and the context menu.
  • No React selector reads sortEpoch.

Rate under load. Take the reference fleet: a few hundred parked terminals and 100+ agents. Assume ~1–5 real title changes/s fleet-wide (status transitions and title text), which is the same order as hook status traffic.

  • Real changes: base ran the census above twice per change (2–10 passes/s). This head runs it once (1–5 passes/s). Each removed pass saves one full-state copy, one parking-input diff, one sync-key build, one generation rebuild for every mounted sidebar card, and one dashboard snapshot rebuild when the drawer is open.
  • Spinner frames: up to ~10/s per working agent, so hundreds/s fleet-wide. These notify nobody at either base or head, because both actions return the same state. Head calls the middleware wrapper once per frame instead of twice.
  • Commits: both base writes ran in one task, so React likely already batched them into one commit. The saving is selector and listener evaluation, not commits. This is a count from source, not measured timing. I did not read the live listener count (readStoreListenerCount) from a running app.

Regression classes touched

  • No-op store write returns new identities: checked and ruled out. An equal title, or a decorative frame with no label change, returns s (terminal-tab-presentation.ts:162-164). The new contract asserts 0 notifications on a repeat.
  • Update published when nothing changed: checked and ruled out, same evidence.
  • One change published as N notices: this is what the PR fixes. 2 → 1, asserted by terminal-title-fanout.performance.test.ts:167-181. On revert, that test fails because alsoTabTitle is ignored and the tab title assertion breaks.
  • Per-row derivation over the whole collection per write: the sidebar-card generation rebuild and the dashboard snapshot are pre-existing. This PR halves how often they run.
  • New idle wakeups / fixed-cadence poll: none. No timer or subscription added. scheduleRuntimeGraphSync keeps the same call count.
  • Per-entity state outlives the entity: no new per-entity state is kept.

Six questions

  1. Unused work before the skip gate: reviewed. The equality and decorative-frame gates still run before any allocation. The combined path still calls applyTerminalTabTitleUpdates when the pane slot is unchanged, exactly as base updateTabTitle did.
  2. Ownership multiplying work: reviewed. One watcher per parked pane, unchanged. Listener fanout per change is halved (census above).
  3. Thread paying: renderer main thread only, as before. No sync fs, SQLite or IPC added.
  4. Growth: constant per event. Owner-stage work is O(tabs in one worktree), and the existing contract covers N=200 and 2,000 workspaces.
  5. Execution host: not applicable. This is renderer store logic and behaves the same for local, SSH, WSL and mobile-mirrored terminals.
  6. Obsolete work stops: not applicable. No new resource, timer or retained closure.

Pre-existing (not regressions of this PR, do not block it)

  • The mounted (non-parked) title path still writes twice per driving title change: pane-title-observation.ts:27 then :38. So do shell-command-inference.ts:135/137 and confirmed-shell-agent-title.ts:19/21. The same alsoTabTitle option would halve those too.
  • Whole-map or ungated subscribers that do fleet-scaled work on every title write:
    • useLiveDashboardSnapshot (all worktrees, while the drawer is mounted)
    • sidebar card title-record generation (all mounted cards' tabs)
    • activity-thread-projection (no gate)
    • use-worktree-jump-palette-store-state.ts:102 (no gate)

Evidence

  • Ran: pnpm test src/renderer/src/store/terminal-title-fanout.performance.test.ts, 2/2 passed. That covers the new 1-notification / 0-on-repeat contract and the existing 0-rows-scanned at N=200 and 2,000.
  • Read in full: the diff, terminal-tab-title-batch.ts, the withStatusTransaction middleware, settled-sort-epoch.ts, graph-sync-scheduler.ts, the title observer, and the subscriber sites listed above.
  • Not run: no app-level timing, CPU or listener-count capture. No typecheck or full suite.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: #46507 at 9e5d5d1d78c7

Verdict: PASS. No findings (no P0 or P1). The PR adds no new work. When a pane title also drives its tab, the change goes from two store notifications to one. Each listener does the same work or less per notification.

Findings

None.

Work added or changed by the diff

# Work Trigger Population Bound
1 setRuntimePaneTitle(…, { alsoTabTitle }) runs runtimePaneTitlePatch and applyTerminalTabTitleUpdates inside one set() (terminal-tab-presentation.ts:150-175) A non-decorative OSC title change on the active pane of a visible terminal (pane-title-observation.ts:28), or on a parked terminal whose pane drives the tab (parked-terminal-byte-watcher.ts:148) One tab. The owner lookup goes through the shared identity-cached getTerminalTabOwners. getOwnerStage indexes only the owning worktree's tab and unified-tab buckets Same calls as before (updateTabTitle already ran applyTerminalTabTitleUpdates on every such change). Notifications drop from 2 to 1. If both patches are null the setter returns s, so zustand's Object.is check skips the notify. The contract asserts 0 notifications on a repeat
2 Same batching for the neutral-title reset after an inferred interrupt (shell-command-inference.ts:135) Title-only interrupt timer fires, one per interrupt 1 pane Notifications drop from 2 to 1
3 Same batching for clearing a stale agent title on a confirmed shell (confirmed-shell-agent-title.ts:19) Shell confirmed after agent exit, one per transition 1 pane Notifications drop from 2 to 1
4 alsoTabTitle: false, or no option (inactive split panes, parked tabs that don't drive the tab, and the restart path at terminal-parked-tab-watchers.ts:79) Same as before 1 pane Same single runtimePaneTitlePatch write as base
5 sortEpoch: the tab step reads panePatch.sortEpoch ?? s.sortEpoch A non-active worktree's title changes classification or text — Same total increment as base (pane +1 and tab +1), now published once instead of across two notifications
6 scheduleRuntimeGraphSync() when the tab title changes Same as base 1 timer Already coalesced (syncScheduled latch, RUNTIME_GRAPH_SYNC_COALESCE_MS). Same as base

Decorative spinner frames: the pane step returns null (isDecorativeAgentTitleFrameChange). The tab step at most rewrites the unified label to the current tab.title, which is a no-op. Result: 0 notifications, same as base.

No new timers, intervals, IPC, subprocesses, filesystem or SQLite work, imports, or retained state. Steady-idle wakeups per second are unchanged on renderer, main and daemon (0 added).

Listener census for the store write

Each zustand notification reaches every raw subscribe listener plus every mounted useAppStore(selector) hook. At this head the renderer has 101 raw subscribe sites (non-test; many are conditional or one-shot waiters) and 3,126 useAppStore( call sites. The selectors that run depend on what is mounted. The PR does not change who subscribes. It halves how often all of them run for a tab-driving title change.

These listeners read the fields a title change writes (runtimePaneTitlesByTabId, tabsByWorktree, unifiedTabsByWorktree, sortEpoch). Most are unchanged files:

  • use-runtime-graph-sync.ts:30: does an identity skip gate, then builds an incremental sync key and calls the coalesced scheduleRuntimeGraphSync. Before: 2 key builds per change (pane field, then tab field). After: 1.
  • use-runtime-graph-sync.ts:60: compares 5 catalog fields by identity and returns.
  • settled-sort-epoch.ts:45: on an epoch bump it runs countLiveWorktrees, an O(worktrees) walk over the indexed list. Before: up to 2 walks per non-active classification and title change. After: 1.
  • session-write-subscriber.ts:273: filters SESSION_RELEVANT_FIELDS and arms a debounce. Once per notification, and an armed timer isn't reset.
  • terminal-session-name-sync.ts:148: terminalTabNamesChanged runs Object.keys over all worktree buckets whenever tabsByWorktree changes. 1 per tab-title change in both base and head (pre-existing, see below).
  • ai-vault-tab-title-sync.ts:271: gated on runtimePaneTitlesByTabId identity. Visits only the changed owning-pane requests.
  • bot-background-sessions.ts:225: calls recompute() when unifiedTabsByWorktree changes. 1 per tab-label change in both base and head.
  • workspace-layout-frame-drawn-workspaces.ts:27: identity check on groupsByWorktree and unifiedTabsByWorktree.
  • agent-terminal-presence.ts:64, structured-chat-name-observation.ts:116, legacy-chat-rename-migration.ts:80, StructuredAgentSessionStatusBridge.tsx:355, bot-home-tab-placement.ts:146, runtime-status-subscriptions.ts:61/313, wsl-host-ipc-bridge.ts:135, and the remaining raw listeners: identity or field gates that return early on a title write.
  • subscribeTabTransitions (tab-transition-subscription.ts) has no production caller at this head.
  • Mounted hook readers of titles (tab bar activity, sidebar card activity/status inputs, the dashboard snapshot, the cmd-j live status, worktree-jump status inputs) each run their selector once per notification instead of twice.

Rate under load (reference fleet): assume 100+ agents, each emitting at most ~1 non-decorative title change per second. Spinner frames are filtered upstream.

  • Base: up to ~200 notifications/s from active-pane and tab-driving parked titles.
  • Head: ~100/s.
  • Each notification fans out to the ~101 raw listeners plus every mounted selector.
  • At 10× fleet: ~2,000/s → ~1,000/s. Per-notification work is unchanged, so the PR halves the total.

Regression classes touched

  • One change published as N notices. This is the class the PR fixes. Verified by terminal-title-fanout.performance.test.ts ("notifies store subscribers once"), which I ran: 2/2 passed. The new test fails if reverted, because without the option the tab title isn't written.
  • No-op store write returns new identities. Matched and disproved: the setter returns s when both patches are null, and the contract asserts 0 notifications on a repeat apply.
  • Per-row derivation over the whole collection per write. Matched and disproved: the existing contract asserts 0 other-workspace rows scanned per title change at 200 and 2,000 workspaces (passes).
  • Hidden owners keep working. Matched (parked terminals write titles). The behavior is unchanged and the output is required (sidebar and tab title). The PR only reduces notifications.
  • New idle wakeups and fixed-cadence poll. No matching code.

Six questions

  1. Unused work before the skip gate. Reviewed. Pane and tab equality and decorative-frame gates run before any patch is allocated. When both are no-ops, the result is a no-op return.
  2. Ownership multiplies work. Reviewed. One write per title event per pane. No new owners or subscriptions.
  3. Thread and storage. Renderer main thread only, with no sync I/O. Persistence goes through the existing debounced session writer.
  4. Growth. Reviewed. Per-write cost is O(tabs in one worktree) through the cached owner index, held at 0 cross-workspace rows at 10N by the existing contract.
  5. Execution host. Not applicable. This is renderer store logic, identical for local, SSH, WSL and paired hosts.
  6. Obsolete work. Not applicable. No timers or resources are added. Parked watcher teardown is unchanged.

Pre-existing (not introduced or amplified by this PR)

  • terminal-session-name-sync.ts:20 terminalTabNamesChanged calls Object.keys on all worktree buckets twice per tabsByWorktree change. That is ~1,500 key visits per tab-title change at 750 worktrees, or ~150k/s at 100 changes/s. The count is the same in base and head.
  • settled-sort-epoch.ts:13 countLiveWorktrees walks all worktrees on every sortEpoch bump, which happens on non-active title changes. This PR lowers it from ≤2 to 1 walk per change.

Evidence and gaps

  • Source-traced on renderer store paths at merge 43ddaa91b60 (PR head on main 3b8cbe221f2).
  • Ran terminal-title-fanout.performance.test.ts: 2/2 passed.
  • No runtime timing or CPU profile was captured, so no millisecond claims. The impact is stated as notification counts.
  • Behavior note, not perf: in pane-title-observation.ts the tab title is now written before agentCompletionCoordinator.observeTitle. The coordinator reads hook status and the raw title, not tabsByWorktree, so the ordering change has no observable effect.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: #46507 @ 500bc1496fe (merged onto main be7d52a87c0)

Result: PASS. No P0/P1 findings. The PR adds no new work per event, no timers or idle wakeups, no new subscriber, no subprocess, no IPC and no growing state. Every changed path now does the same work as before or less.

Work the diff adds or changes

# Work Trigger Population per event Bound / invalidation Before → after
1 setRuntimePaneTitle(..., { alsoTabTitle }) (terminal-tab-presentation.ts:150): pane-title patch plus applyTerminalTabTitleUpdates in one set Every terminal title change, from three places: a parked terminal's byte watcher; a visible pane's title observation (pane-title-observation.ts:28); and two neutral-title resets (shell-command-inference.ts:135, confirmed-shell-agent-title.ts:19) 1 tab: owner lookup from the shared owner index (O(1) after adoptTerminalTabOwnerMetadataOnlyBuckets), owner-stage maps over one worktree's tabs, one replaced bucket in tabsByWorktree / unifiedTabsByWorktree Pane-level skips (same title, decorative spinner frame) run before any allocation; returns s when neither patch exists, so unchanged input notifies 0 times 2 store notifications → 1 per title change on the active pane or the tab-driving pane. The patch is the same; a sortEpoch change is still +1 or +2 overall, now in a single write
2 countLiveWorktrees cached on worktreesByRepo identity (settled-sort-epoch.ts:16) Every store write that changes sortEpoch or the rows; title writes for a non-active worktree bump sortEpoch Base: full getIndexedAllWorktrees walk (750 rows, 7,500 at 10×) per sortEpoch bump. Head: one identity compare; the walk runs only when rows change Invalidated by worktreesByRepo identity, which every row write replaces. Retains one reference to the last counted worktreesByRepo, and only one O(worktrees) per title-driven bump → O(1)
3 terminalTabNamesChanged reads readTabMapChanges (terminal-session-name-sync.ts:21) Every write that replaces tabsByWorktree (all tab-driving title writes) Base: Object.keys of both maps plus an identity walk over every worktree key. Head: only the addressed bucket(s) Falls back to the full walk when the change chain can't be addressed (unlinked write, >64-step gap, reorder); same as base in that case O(worktrees) per tab-driving title write → O(changed bucket)
4 Contract test (terminal-title-fanout.performance.test.ts) test only — Fails if the change is reverted: two sets give 2 notifications, not 1. The unchanged case asserts 0 pnpm test on this file: 2/2 pass at head

Parked terminals that don't drive their tab (drivesTabTitle=false) and pane-only titles (inactive split) still notify once, as on base. Nothing else calls the old two-step sequence on a per-title path. The remaining updateTabTitle callers run on focus change, pane close, restart and agent-status routing, not per title.

Listener census: what one title write reaches at this head

A title write is one set. A pane-only write replaces runtimePaneTitlesByTabId and maybe bumps sortEpoch. A tab-driving write also replaces one bucket in tabsByWorktree and one in unifiedTabsByWorktree, linked through replaceTabBuckets. Every useAppStore.subscribe listener in the renderer runs on every notify, so I read all 100 direct subscribe sites, plus the wrapped subscriptions (subscribeStore / subscribeStoreWithStatuses passthroughs, the session-name sync and AI-vault title sync gates, and the status-transaction wrapper), and every mounted selector hook. This includes files the PR doesn't touch.

Listeners that get past their gate on a title write and do more than O(changed bucket):

Listener Owner × count Work per title write Changed by this PR?
use-runtime-graph-sync.ts:30 1, app-wide Its gate includes runtimePaneTitlesByTabId, so every title write rebuilds the mobile sync key (O(changed bucket)) and arms the 16 ms coalesced scheduleRuntimeGraphSync. The sync rebuilds tab indexes cached on tabsByWorktree identity: O(all terminal tabs) after a tab-driving write Base ran the key build on both writes; head runs it once. Graph syncs coalesce to ≤ ~60/s either way
session-write-subscriber.ts:273 1, app-wide Pane-only writes stop at the field-identity gate. On a tab-driving write that isn't a spinner frame it projects the changed bucket and re-arms a 150 ms trailing debounce. The flush builds a session patch over all worktrees/tabs and sends it over IPC Unchanged: base made the same tab-driving write once
settled-sort-epoch.ts:54 1, per store Per sortEpoch bump: re-arms a 3 s trailing deadline, or in Manual sort a synchronous nested setState. The live-worktree count is now O(1) (row 2 above) Improved: one bump-carrying write per title change instead of up to two; full scan removed
activity-thread-projection.ts:128 1 while Activity readers are mounted Tab-driving write → readers re-render → buildActivityEvents full pass over agent panes Unchanged (same tab-driving write count)
legacy-chat-rename-migration.ts:80, structured-chat-name-observation.ts:116 1 each Tab-driving write passes the unifiedTabsByWorktree gate → walk over all structured-chat tabs (snapshot cached, result equal → no publish) Unchanged
workspace-layout-frame-drawn-workspaces.ts:27 (+ server-layout-frames.ts:148, one per paired stream) 1 + paired streams Tab-driving write → Object.keys(cache).filter(unshown); local path may call the unmemoized buildHostSessionRouting when an unshown key is present Unchanged
agent-terminal-presence.ts:64 ≤3, live until that agent type appears Tab-driving write → walk over agentStatusByPaneKey and paneForegroundAgentByPaneKey Unchanged
SpaceWindowStatePublisher.tsx:46 1, only while the Space window is open Gate includes titles and tabs → 100 ms coalesced full-state IPC Gate now runs once per title change instead of twice; publishes stay coalesced
useDashboardPopoutBridge.ts:84 1, only while the dashboard pop-out is open Gate includes titles and tabs → snapshot build over all worktrees, throttled to 250 ms, plus IPC Same as above
ai-vault-tab-title-sync.ts:271 1 gate Every title write: O(changed tab). For an AI-vault refresh agent whose title key changed: microtask reconcile over requests, resolveSessionTitles IPC, timer re-arm Base saw the pane change on write 1 and the tab change on write 2; head sees both in one notify
agent-status-ipc-bridge.ts:271 1, app-wide O(changed bucket); if status events are queued, a tab-driving write flushes them (routing index over all tabs) Unchanged
Conditional / transient: wsl-host-ipc-bridge.ts:135 (WSL serving), bot-background-sessions.ts:225 (bots exist), automation-run-workspace-action.ts:69 (during a run reveal), mobile-terminal-close-ipc-bridge.ts:67 (held mirrored workspace), use-terminal-editor-close-queue.ts:52 (pending close), native-windows-pane-policy.ts:42 (one per Windows ConPTY pane, O(1) each) — O(worktrees, sessions or Windows panes) per notify while active Unchanged or halved: they don't gate on the title fields, so base ran them on both writes

Gated at O(1) or O(changed bucket): the other ~80 direct sites. Their gates read fields a title write leaves alone (openFiles, settings, repos, worktreesByRepo, activeWorktreeId, groupsByWorktree, status maps, …), or they are short waits that check one key. This includes terminal-session-name-sync (now O(changed bucket), row 3), terminal-parking-input-transitions (addressed diff; it publishes only when a pane-title slot is added or removed), StructuredAgentSessionStatusBridge (addressed reconcile; title isn't a semantic field), and runtime-status-subscriptions:61 (returns on runtimeStatusByEnvironmentId identity).

Selector hooks: useAppStore(...) is used in ~908 renderer files, and there are 67 useAppStoreWithHostStatuses call sites. Every mounted selector re-runs once per notify. Halving notifications per title change halves this selector work. Renders are unchanged: the tab-driving output is the same, and readers that select the whole tabsByWorktree or runtimePaneTitlesByTabId re-render once per title change, as they did once per write.

Rate under load (reference fleet): spinner frames are filtered before any write (isDecorativeAgentTitleFrameChange at both pane and tab level). Assume 100+ agents emitting real title changes at ~1–2/s each, with most of them driving their tab. That is ~100–200 title writes/s fleet-wide, ~1,000–2,000/s at 10×.

  • Base: up to 2 notifications per title change → ~200–400 full listener + selector passes/s (2,000–4,000 at 10×).
  • Head: ~100–200/s (1,000–2,000 at 10×).
  • Each bump-carrying write also loses an O(750) live-worktree walk (O(7,500) at 10×). Each tab-driving write loses an O(750) worktree-key walk in the session-name sync.
  • These rates are derived from source, not from a profile. No timing is claimed.

Regression classes touched

Class Disposition
No-op store write returns new identities Disproved: returns s when neither patch exists. The contract test asserts 0 notifications for an unchanged title
One change published as N notices This is what the PR fixes; the test asserts 1 notification
Per-row derivation over the whole collection per write Removed for countLiveWorktrees and terminalTabNamesChanged. Fallback paths stay O(N) only for unaddressable changes, same as base
Update published when nothing changed Disproved (as above)
Per-entity state outlives the entity Disproved: the module cache holds one worktreesByRepo reference and is replaced on the next recount; no per-entity keys
New wakeups in steady idle No matching code: no timer, poll, rAF or IPC added. Idle wakeups/s per process are the same as base (none added on main, renderer or daemon)
Hot-path rescans Reduced (rows 2 and 3)

Six questions

  1. Unused work before the skip gate: reviewed. Pane-level checks (equality, decorative frame) run before allocation. Tab title work is shared with the existing applyTerminalTabTitleUpdates, so nothing is reimplemented.
  2. Ownership multiplying work: reviewed. No new owners or subscribers. Callers per pane are unchanged; deps pass setRuntimePaneTitle through by reference, so options reaches the store.
  3. Thread/storage: renderer only. No sync I/O or SQLite; no main-process change.
  4. Growth / progress: reviewed. Both new caches are keyed on identity and invalidate correctly. No retries or cursors.
  5. Execution host: not applicable. The change is a renderer store action and runs the same on local, SSH, WSL and remote hosts. The title source differs per host; the write does not.
  6. Obsolete work: not applicable. No async work, timers or retained handles added.

Pre-existing (not introduced by this PR, not blocking)

Found while taking the census. Each is reached once per tab-driving title write on both base and head:

  • activity-thread-projection re-renders its readers and runs a full buildActivityEvents pass.
  • The chat-name observers walk every structured-chat tab.
  • session-write-subscriber and settled-sort-epoch use trailing debounces with no max wait (150 ms / 3 s), so sustained fleet-wide title churn can keep pushing the flush or settle back. I did not check whether another path forces a flush (e.g. on quit).

These are worth a separate look but are outside this PR's change.

Evidence

  • Reproduced: the targeted contract test passes at head. The notification counts in rows 1–3 are proven from source.
  • Not run: typecheck, full suite, benchmarks, profiles. No timing, CPU or heap numbers are claimed.

@brennanb2025
brennanb2025 marked this pull request as ready for review November 21, 2026 21:19
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Runtime pane-title updates can now update the tab title in the same store operation. Title-update callers pass whether the pane drives the tab title. Subscriber checks inspect addressed workspace changes, and live-worktree counts are cached by worktree-map reference. Tests check subscriber notifications for combined and unchanged title updates.

Merge Risk: Minimal · up to 500bc

Background terminal title changes now update the store once instead of twice, and titles come out the same. No concrete defect was found, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template closely. It has all required sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk (with level), Agent skill upstrea…
Title check Passed The title "Terminal title changes update the app once instead of twice" matches the main change. When a pane drives its tab title, the pane-title and tab-title updates now run as one store update, so …
Full details: Description check

Explanation

The description follows the repository template closely. It has all required sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk (with level), Agent skill upstream boundary, Notes, and Checklist. The What Changed section gives a clear before and after, plus the mechanism. Testing lists the performance contract test, a new notification test, and timing numbers from a macOS harness. Performance is answered with a concrete explanation and measurements. Risk names the riskiest ordering change, the earlier tab-title write in visible title observation, and gives a revert path. Gaps: the Linked Issue section says 'N/A (internal performance report)' rather than linking an issue, which the template asks for on outside-contributor PRs. The AI Disclosure section is empty. The Review section is empty. The author's checklist items are checked, but the lint, typecheck, test, and build results are not reported separately. These gaps are minor for a maintainer-authored change, so the check passes.

Full details: Title check

Explanation

The title "Terminal title changes update the app once instead of twice" matches the main change. When a pane drives its tab title, the pane-title and tab-title updates now run as one store update, so subscribers are notified once instead of twice. The changeset adds an optional alsoTabTitle option to setRuntimePaneTitle and updates the callers and the performance test to match. The title is specific and does not use vague terms. It omits the other included changes, such as the tab-name sync scan reduction and the worktree count cache, but the task does not require full coverage.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a726cfb9-5aff-40b2-ab3c-c404cb3bc777
Commits

Reviewing files that changed from the base of the PR and between f2be607 and 500bc14.

Files selected for processing: 11

  • src/renderer/src/components/terminal-pane/mounting/terminal-pane-lifecycle-types.ts
  • src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-byte-watcher.ts
  • src/renderer/src/components/terminal-pane/pty-connection/agent-identity/confirmed-shell-agent-title.ts
  • src/renderer/src/components/terminal-pane/pty-connection/agent-identity/pane-title-observation.ts
  • src/renderer/src/components/terminal-pane/pty-connection/agent-identity/shell-command-inference.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pty-connection-deps.ts
  • src/renderer/src/lib/agent-session/history/session-names/terminal-session-name-sync.ts
  • src/renderer/src/store/slices/ui/settled-sort-epoch.ts
  • src/renderer/src/store/terminal-title-fanout.performance.test.ts
  • src/renderer/src/store/terminals/tabs/presentation/terminal-tab-presentation.ts
  • src/renderer/src/store/terminals/terminal-actions.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready

Problem. Each terminal title change wrote the pane title and the tab title as two separate store updates, so every store subscriber ran twice. On a large profile these notifications showed up in 28 of 74 sampled long tasks.

User-facing change. None visible. Titles and sidebar order end up exactly as before; each title change now reaches subscribers once, and an unchanged title reaches them zero times.

What changed, by review pass

  1. e1fc16fb8e6: parked terminals write pane and tab title in one store update.
  2. 9e5d5d1d78c: the perf reviewer noted the visible-terminal path still wrote twice. Fixed: the three visible-terminal call sites use the same single write.
  3. 500bc1496fe: the perf reviewer noted two subscribers every title change reaches still scanned all workspaces (on main before this PR). Fixed: tab-name sync reads only changed workspaces, and the live-worktree count is reused until the worktree rows change. The fanout perf contract now covers tab-name sync and fails without the fix (2 scans instead of 0).
  4. f5b3b83f9df: merge of main (picks up the max-lines fix from fix(settings): split usage-limit settings types to keep global-settings-types under max-lines #46509 that turned this PR's static analysis red).

Every finding, and what happened to it

  • Pass 1, Claude P2: Linked Issue says N/A. No change needed: the template allows it for maintainers, and the reviewer said the same.
  • Pass 1, Claude P2: lint/typecheck/test box unchecked. Checked once CI went green.
  • Pass 1, perf: visible terminals still wrote twice. Fixed in pass 2.
  • Pass 2, Claude P1: PR body still described only parked terminals. Fixed (body rewritten for both paths).
  • Pass 2, perf: terminalTabNamesChanged and countLiveWorktrees scanned all workspaces per title change. Fixed in pass 3.
  • Pass 3, Claude: one sentence about the live-worktree count was imprecise. Fixed.
  • Pass 3, perf, labelled by that reviewer as not caused by this PR and not blocking, all on main already: the activity-thread projection rebuilds on tab-title writes; two chat-name observers walk every chat tab per write; the session-save and sort-settle debounces have no maximum wait. Not fixed here: they are separate subscribers outside this change, and session saving is owned by perf(session): save only the workspace keys a terminal title change touched #45731. Reported as follow-ups.

Verified

  • Codex regression audit (blinded, PR merged onto current main): SAFE on 500bc1496fe, no must-fix, should-fix or nit findings. Earlier heads were also SAFE.
  • Claude review: READY on 500bc1496fe, no P0/P1/P2.
  • Perf-scan (fresh reviewer, full scan): PASS, 0 findings on 500bc1496fe (report above).
  • check:changed gate: 32/32 passed on 500bc1496fe.
  • terminal-title-fanout.performance.test.ts: one notification per title change that drives its tab, zero when unchanged, zero reads of other workspaces at 200 and 2,000 workspaces.
  • QA: tests only (renderer store behavior; no layout, OS, process or cross-process behavior involved).

Benchmark: head=500bc1496fe47fd781719d50859090dca768a69c gate=PASS 1,900 workspaces, 1,000 unique title changes per mode, listeners mounted: agent hook completion sync, AI-vault title freshness and sync inputs, tab-name sync, mobile session sync key, visible agent orchestration, agent terminal presence. Two calls: median 355 µs, p90 583 µs, 200 notifications per 100 changes. One call: median 319 µs, p90 468 µs, 100 notifications per 100 changes.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: #46507 at f5b3b83f9df

Findings: none. I found no P0 or P1 regression. Each piece of work the diff touches stays the same or gets smaller, at the reference fleet and at 10×.

Evidence used: source-proven work counts and terminal-title-fanout.performance.test.ts at this head (2/2 pass). There is no runtime timing or CPU evidence, so every cost below is a count tied to its trigger.

Work the diff adds or changes

Work Trigger Population Bound / disposition
setRuntimePaneTitle(…, { alsoTabTitle }) merges the pane-title write and the tab-title write into one set() (terminal-tab-presentation.ts:150) A non-decorative OSC title change on the active pane of a visible pane, a parked terminal (drivesTabTitle), a confirmed-shell neutral title, or an inferred interrupt One tab bucket, owner looked up through the shared owner index (already warm, same as base) Store notifications per title: 2 → 1. Middleware passes (withStatusTransaction, withEditorBufferRecords, retention, cascade probe): 2 → 1. Each subscriber now sees the union of the two old patches once. The fields that change, and their identities, match base.
runtimePaneTitlePatch extracted from the old inline body Same Same Same code. Decorative spinner frames and unchanged titles return null. The new contract confirms 0 notifications for an unchanged title.
applyTerminalTabTitleUpdates now always runs when alsoTabTitle is set, including when the pane patch is a no-op Same 1 owner bucket: O(tabs in that workspace) index build Base did the same: updateTabTitle ran unconditionally after the pane write. No new work.
sortEpoch composition (version-bump surface) A classification change on a pane outside the active workspace (+1), plus a tab title change outside the active workspace (+1) — The tab update reads panePatch?.sortEpoch ?? s.sortEpoch, so the final value is base +2, the same as base's two sequential writes. It publishes once instead of twice. alsoTabTitle: false is unchanged. There is no publish when nothing changed: both bump conditions require a real classification or title change.
countLiveWorktrees identity cache (hot-path surface: settled-sort-epoch.ts:12-29) Every store notification where sortEpoch was bumped or worktreesByRepo changed All worktrees (750 at the reference fleet, 7,500 at 10×) Before: one O(W) walk per epoch bump. Every non-active-workspace title change bumps, so about 100 titles/s × 750 ≈ 75k row visits/s at the reference fleet, and about 7.5M/s at 10× fleet and title rate. After: O(1) while the row map identity is unchanged, and a recount only when rows change. Retention: one module-level reference to the current worktreesByRepo, replaced on every recount. This is bounded to one snapshot and does not grow. The identity key relies on the same immutability that getWorktreeSnapshot already assumes. A module singleton shared across store instances (tests) stays correct because it is keyed on identity.
terminalTabNamesChanged reads addressed readTabMapChanges (terminal-session-name-sync.ts:21) Every notification where the tabsByWorktree identity changed (every tab-title write) Changed buckets. The fallback for unannotated writes is the old full scan. Before: Object.keys over every workspace plus an identity loop over all W buckets per title. After: a link walk (depth ≤ 64, normally 1) plus only the changed buckets. A workspace add or delete returns true, as the old length check did. The contract now counts 0 unrelated-bucket reads at 200 and 2,000 workspaces.
Call-site refactors (parked byte watcher, pane-title observation, confirmed-shell title, shell-command inference) and type widening in the two deps types and terminal-actions.ts — — They take no extra store reads (the parked watcher drops one getState() local). The active-pane check runs once per title, as before.

Listener census for the title write (this head, unchanged files included)

Zustand notifies every listener once for each set() that changes state, so a title write reaches all of them. Populations:

  • 100 direct subscribe( sites in 95 renderer files, plus indirect subscribers wired through dependencies: TerminalSessionNameSyncGate, AI-vault title sync through runtimeStatusSubscriptionsFor, parking inputs and PR cadence through STORE_OBSERVER_INSTALLERS, the structured-selection catalog, and the HTTP-link accessor.
  • React hooks: about 3,100 useAppStore( call sites. Each mounted one is a listener that re-runs its selector on every notification. This population grows with mounted sidebar rows and panes, so at 750 rows it is in the thousands.

Listeners that read fields a title write changes (tabsByWorktree, unifiedTabsByWorktree, runtimePaneTitlesByTabId, sortEpoch):

Listener Work per title notification at this head
installSettledSortEpoch Identity checks, then O(1) count (was O(W) on a bump; fixed here)
startTerminalSessionNameSync → terminalTabNamesChanged Changed buckets only (was O(W); fixed here)
whenAgentTerminalAppears, hook-completion sync, AI-vault title freshness and sync inputs, mobile session sync key (use-runtime-graph-sync), visible agent orchestration Own bucket only. The fanout contract enforces 0 unrelated reads at N=200 and 10N=2,000.
installTerminalParkingInputs Addressed diff of the changed bucket (diffUnknownParkingRecordKeys)
tab-transition-subscription readTabMapChanges walk, depth about 1
session-write-subscriber Identity gate, then projection of the changed buckets plus a debounced flush
workspace-layout-frame-drawn-workspaces, server-layout-frames Identity gate on unifiedTabsByWorktree, then the unshown set
wsl-host-ipc-bridge report Windows/WSL only. Identity gate, then O(workspaces focused this session). This is pre-existing, has the same count per title as base, and is not fleet-wide.
activity-thread-projection (subscribe(notify)) Runs on every write and fans out to observed activity listeners. Pre-existing; halved by this PR.
The remaining ~85 direct sites (bots, native chat, editor, GitHub, connectors, browser, …) Identity compares on unrelated slices, O(1) per notification. Halved by this PR.

Rate:

  • Idle: with no title changes there are 0 writes. The PR adds no timer, poll, subscriber or IPC, so idle wakeups per second (renderer, main, daemon) are unchanged from base.
  • Under load: at the reference fleet, assume about 100 non-decorative titles/s across 100+ agents. Base produced about 200 notifications/s for tab-driving titles, each running every listener and mounted selector. This head produces about 100/s. Pane-only titles (an inactive split pane, or a parked pane with drivesTabTitle false) stay at 1. At 10× (about 1,000 titles/s) it is 2,000/s → 1,000/s. The per-listener work per notification is unchanged or lower, as shown above.

Regression classes touched

  • No-op store write returns new identities: matched and disproved. An unchanged or decorative title returns s, and the new contract asserts 0 notifications.
  • Per-row derivation over the whole collection per write: matched. This PR fixes two instances (terminalTabNamesChanged and countLiveWorktrees), and the contract now covers the first.
  • One change published as N notices: this PR fixes it (2 → 1).
  • Update published when nothing changed (sortEpoch): matched and disproved. A bump needs a real change, and the value equals base.
  • Per-entity state outlives the entity: matched and disproved. The module cache holds one current snapshot and no per-entity keys.
  • New idle wakeups: no matching code.

Six questions

  1. Unused work before the gate: reviewed. The decorative and unchanged gates still run before allocation, and the tab path does the same work as base.
  2. Ownership multiplication: reviewed. No new owners. Each parked watcher and pane session still makes one call per title.
  3. Thread: renderer only, synchronous within set(). No new main, SQLite or IPC work. scheduleRuntimeGraphSync still fires once per tab-title change, as in base.
  4. Growth: reviewed. Two O(W) per-title paths become O(changed) or O(1). Nothing new grows with history.
  5. Execution host: not host-dependent. SSH, WSL and remote workspaces use the same renderer store path, and the WSL bridge cost is unchanged.
  6. Obsolete work and release: not applicable. No new resources, timers or subscriptions. The cache is replaced, not accumulated.

Coverage and residual gaps: I did not take a live listener count (readStoreListenerCount) or a renderer profile, and I did not run base and head on the same workload. The notification reduction is source-proven and asserted by the new test. The ~85 identity-gated listeners were classified with a field-reference screen plus a read of each title-relevant body, not a line-by-line read of every listener.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready (supersedes the previous status comment: adds the reference comparison and the perf-scan on the merged head)

Problem. Each terminal title change wrote the pane title and the tab title as two separate store updates, so every store subscriber ran twice. On a large profile these notifications showed up in 28 of 74 sampled long tasks.

User-facing change. None visible. Titles and sidebar order end up exactly as before; each title change now reaches subscribers once, and an unchanged title reaches them zero times.

What changed, by review pass

  1. e1fc16fb8e6: parked terminals write pane and tab title in one store update.
  2. 9e5d5d1d78c: the perf reviewer noted the visible-terminal path still wrote twice. Fixed: the three visible-terminal call sites use the same single write.
  3. 500bc1496fe: the perf reviewer noted two subscribers every title change reaches still scanned all workspaces (on main before this PR). Fixed: tab-name sync reads only changed workspaces, and the live-worktree count is reused until the worktree rows change. The fanout perf contract now covers tab-name sync and fails without the fix (2 scans instead of 0).
  4. f5b3b83f9df: merge of main (picks up the max-lines fix from fix(settings): split usage-limit settings types to keep global-settings-types under max-lines #46509 that turned this PR's static analysis red).

Every finding, and what happened to it

  • Pass 1, Claude P2: Linked Issue says N/A. No change needed: the template allows it for maintainers, and the reviewer said the same.
  • Pass 1, Claude P2: lint/typecheck/test box unchecked. Checked once CI went green.
  • Pass 1, perf: visible terminals still wrote twice. Fixed in pass 2.
  • Pass 2, Claude P1: PR body still described only parked terminals. Fixed (body rewritten for both paths).
  • Pass 2, perf: terminalTabNamesChanged and countLiveWorktrees scanned all workspaces per title change. Fixed in pass 3.
  • Pass 3, Claude: one sentence about the live-worktree count was imprecise. Fixed.
  • Pass 3, perf, labelled by that reviewer as not caused by this PR and not blocking, all on main already: the activity-thread projection rebuilds on tab-title writes; two chat-name observers walk every chat tab per write; the session-save and sort-settle debounces have no maximum wait. Not fixed here: they are separate subscribers outside this change, and session saving is owned by perf(session): save only the workspace keys a terminal title change touched #45731. Reported as follow-ups. The final perf-scan on f5b3b83f9df also lists, as existing before this PR, the Windows/WSL host bridge and the activity projection notifying on every write; unchanged by this PR, also reported as follow-ups.

Verified

  • Codex regression audit (blinded, PR merged onto current main): SAFE on 500bc1496fe, no must-fix, should-fix or nit findings. Earlier heads were also SAFE.
  • Claude review: READY on 500bc1496fe, no P0/P1/P2.
  • Perf-scan (fresh reviewer, full scan): PASS, 0 findings on 500bc1496fe; a second fresh full scan on the merged head f5b3b83f9df covering both detected surfaces (sort-settle hot path, sort-epoch bump) is clean (reports above).
  • Reference comparison (fresh reviewer, t3code, bb and vscode): no blocker. The one-write title update matches the references' single write; the change detection for tab names and the cached live-worktree count have no reference equivalent, and Orca keeps a full-scan fallback. Nothing outside Orca's own data changes.
  • check:changed gate: 32/32 passed on 500bc1496fe.
  • terminal-title-fanout.performance.test.ts: one notification per title change that drives its tab, zero when unchanged, zero reads of other workspaces at 200 and 2,000 workspaces.
  • QA: tests only (renderer store behavior; no layout, OS, process or cross-process behavior involved).

Benchmark: head=500bc1496fe47fd781719d50859090dca768a69c gate=PASS 1,900 workspaces, 1,000 unique title changes per mode, listeners mounted: agent hook completion sync, AI-vault title freshness and sync inputs, tab-name sync, mobile session sync key, visible agent orchestration, agent terminal presence. Two calls: median 355 µs, p90 583 µs, 200 notifications per 100 changes. One call: median 319 µs, p90 468 µs, 100 notifications per 100 changes.

@brennanb2025 brennanb2025 changed the title Background terminal title changes update the app once instead of twice Terminal title changes update the app once instead of twice Nov 21, 2026
@brennanb2025
brennanb2025 merged commit 4491884 into main Nov 21, 2026
106 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant