Repository navigation
Unify tab agent identity with the agent-status pipeline - #7059
Conversation
|
Ready to review this PR? Stage has broken it down into 8 individual chapters for you: Chapters generated by Stage for commit f6c2cb8 on Jul 2, 2026 2:38am UTC. |
16987e9 to
31c5e6a
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughChangesThis change adds pane-scoped foreground agent state to the terminal store and updates cleanup paths to remove it. It introduces foreground signal extraction and resolution helpers, a worktree foreground sync hook, and tab-agent foreground caching. Sidebar row building now consumes foreground identity through new selector and row-builder helpers, and the review notes menu now disables foreground syncing when reading worktree rows. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/store/slices/terminals.ts (1)
1847-2051: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
shutdownCompletedAgentPaneForHibernationnever clearsforegroundAgentByPaneKey[opts.paneKey].This function hibernates a single completed-agent pane and explicitly clears the pane's other per-pane ephemeral state —
unreadTerminalPanes,unreadAgentCompletionPanes, andlastTerminalInputAtByPaneKey(Lines 2013–2018, 2035–2037) — but omitsforegroundAgentByPaneKey, even though the underlying PTY for this pane is being killed/stopped here just like incloseTabandshutdownWorktreeTerminals, both of which do sweep this map. This leaves a stale foreground-agent entry for a dead pane in the "ephemeral, non-persistent" cache the PR describes, contradicting the stated design goal of clearing foreground entries through all lifecycle/cleanup paths.🐛 Proposed fix
const nextUnreadTerminalPanes = { ...s.unreadTerminalPanes } const nextUnreadAgentCompletionPanes = { ...s.unreadAgentCompletionPanes } const nextLastTerminalInputAtByPaneKey = { ...s.lastTerminalInputAtByPaneKey } + const nextForegroundAgentByPaneKey = { ...s.foregroundAgentByPaneKey } delete nextUnreadTerminalPanes[opts.paneKey] delete nextUnreadAgentCompletionPanes[opts.paneKey] delete nextLastTerminalInputAtByPaneKey[opts.paneKey] + delete nextForegroundAgentByPaneKey[opts.paneKey] return { tabsByWorktree: nextTabsByWorktree, ptyIdsByTabId: { ...s.ptyIdsByTabId, [opts.tabId]: remainingPtyIds }, lastKnownRelayPtyIdByTabId: nextLastKnownRelay, suppressedPtyExitIds: { ...s.suppressedPtyExitIds, ...Object.fromEntries(shutdownPtyIds.map((ptyId) => [ptyId, true] as const)) }, codexRestartNoticeByPtyId: nextCodexRestartNoticeByPtyId, ...(nextRuntimePaneTitlesByTabId !== s.runtimePaneTitlesByTabId ? { runtimePaneTitlesByTabId: nextRuntimePaneTitlesByTabId } : {}), unreadTerminalPanes: nextUnreadTerminalPanes, unreadAgentCompletionPanes: nextUnreadAgentCompletionPanes, - lastTerminalInputAtByPaneKey: nextLastTerminalInputAtByPaneKey + lastTerminalInputAtByPaneKey: nextLastTerminalInputAtByPaneKey, + foregroundAgentByPaneKey: nextForegroundAgentByPaneKey } })
🧹 Nitpick comments (8)
src/renderer/src/components/sidebar/worktree-foreground-agent-row-selectors.ts (1)
22-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a short "why" comment for the caching design.
The module-level single-slot caches (
tabWorktreeIndexCache,foregroundAgentsByWorktreeCache) and thereuseForegroundRecordIfEqualreference-reuse trick are non-obvious: a reader unfamiliar with the render-amplification concern (avoiding new object identities per worktree souseShallow/memo consumers don't re-render) could easily "simplify" this into a plain.map()/.filter()and reintroduce churn. A one- or two-line comment stating the rationale (why per-worktree reference stability matters here) would match the "Why:" comment convention used elsewhere in this codebase (e.g.useWorktreeAgentRows.ts,use-worktree-foreground-agent-sync.ts).As per path instructions, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."
Source: Path instructions
src/renderer/src/components/sidebar/worktree-foreground-agent-row-type.ts (2)
37-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short "why" comment for the single-PTY fallback heuristic.
When the layout hasn't recorded a
ptyIdfor the leaf, this falls back to assuming the sole live PTY belongs to the pane wheneverleafCount <= 1. That's a non-obvious assumption (it can be wrong the instant a tab gains a second pane before layout catches up) and currently has no explanation.📝 Suggested comment
const leafCount = countTerminalLayoutLeaves(layout?.root) + // Why: layout metadata can lag a freshly-spawned pane. If there's exactly + // one live PTY and at most one tracked leaf, assume it's this pane's PTY. if (livePtyIds.length === 1 && leafCount <= 1) {As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
10-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract
countTerminalLayoutLeavesinto a shared helper
src/renderer/src/components/sidebar/worktree-foreground-agent-row-type.tsandsrc/renderer/src/components/sidebar/worktree-agent-rows.tsboth define the same leaf-count recursion. Moving it to a shared layout utility keeps the pane/PTy fallback and retained-alias logic from drifting.src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts (1)
155-181: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract shared title→status/label/agentType derivation to avoid drift.
buildTitleDerivedAgentRow(status/label/agentType computation) andtitleCanBuildTitleDerivedAgentRowduplicate the sameisClaudeManagementTitle→detectAgentStatusFromTitle/getAgentLabel→resolveTitleDerivedAgentTypechain.titleCanBuildTitleDerivedAgentRowis consumed by the foreground-sync-targets logic to decide which panes get probed; if this copy diverges from the row-building copy, the sync hook could skip probing a pane that would actually get a title-derived row (or the reverse).Consider factoring the shared
{status, label, agentType}derivation into one helper used by both.Also applies to: 208-222
src/renderer/src/store/slices/terminals.ts (1)
1028-1036: 📐 Maintainability & Code Quality | 🔵 TrivialConsider extracting the repeated paneKey-prefix deletion loop into a helper.
The
for (const paneKey of Object.keys(...)) { if (paneKey.startsWith(${tabId}:)) ... }pattern is now duplicated acrosscloseTab,shutdownWorktreeTerminals, andbuildOrphanTerminalCleanupPatchforforegroundAgentByPaneKey(on top of the pre-existing duplication forunreadTerminalPanes/cacheTimerByKey). A smalldeletePaneKeysWithPrefix(record, prefix)helper would reduce this to one call site per map.Also applies to: 2280-2287
src/renderer/src/store/slices/worktrees.ts (2)
1903-1914: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a "why" comment for the composite pane-key parsing.
Unlike the sibling
omitByTabId/omitByWorktreehelpers that check plain membership (id in out),omitPaneKeysByTabIdparses a composite key (tabId:leafId) to recover the tab id. This is a non-obvious constraint (pane keys are the only tab-scoped map here keyed by a composite string) and deserves a short inline note, consistent with other maps in this function that already carry "Why:" comments explaining non-obvious cleanup requirements.As per coding guidelines,
**/*.{ts,tsx,js,jsx}: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."📝 Proposed comment
+ // Why: foregroundAgentByPaneKey is keyed by composite `tabId:leafId` pane + // keys (see makePaneKey), unlike the other tab-scoped maps above that are + // keyed directly by tabId. const omitPaneKeysByTabId = <T>(obj: Record<string, T>): Record<string, T> => {Source: Coding guidelines
3068-3080: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate pane-key cleanup logic diverges from the bulk-purge helper.
This inline cleanup re-implements the same "drop
foregroundAgentByPaneKeyentries whose tabId prefix is doomed" logic already added asomitPaneKeysByTabIdinbuildWorktreePurgeState(Lines 1903-1914), but as a nested loop (for tabId → for Object.keys(nextForegroundAgentByPaneKey)) instead of a single set-lookup pass. Two independent implementations of the same rule increase the risk that a future edit to one is missed in the other, and this variant is less efficient (O(tabIds × paneKeys) vs. O(paneKeys)).Consider factoring both into one shared helper (e.g. taking a
Set<string>of doomed tab ids and returning the filtered pane-key map) and reusing it from bothbuildWorktreePurgeStateandremoveWorktree.src/renderer/src/components/sidebar/worktree-foreground-sync-targets.ts (1)
133-145: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueIdentical branch bodies — simplify the condition.
The
if (titleCanBuildTitleDerivedAgentRow(...))andelse if (targetByPaneKey.has(paneKey))branches execute the exact sametargetByPaneKey.set(...)call. This can be collapsed into a single condition, which also makes the intent (re-read on title-derived-row-eligible OR already-tracked pane) explicit at a glance.♻️ Suggested simplification
- if (titleCanBuildTitleDerivedAgentRow(title, args.tab.launchAgent)) { - targetByPaneKey.set(paneKey, { - lifecycleKey: targetByPaneKey.get(paneKey)?.lifecycleKey ?? 'title', - titleForegroundKey: getTitleForegroundKey(title, args.tab.launchAgent) - }) - } else if (targetByPaneKey.has(paneKey)) { - // Why: a live row whose pane title changes back to shell/unknown - // needs one re-read so stale foreground identity can be cleared. - targetByPaneKey.set(paneKey, { - lifecycleKey: targetByPaneKey.get(paneKey)?.lifecycleKey ?? 'title', - titleForegroundKey: getTitleForegroundKey(title, args.tab.launchAgent) - }) - } + // Why: track this pane if the title can build a title-derived row, or + // if it was already tracked (a live row whose title changed back to + // shell/unknown needs one re-read so stale identity can be cleared). + if ( + titleCanBuildTitleDerivedAgentRow(title, args.tab.launchAgent) || + targetByPaneKey.has(paneKey) + ) { + targetByPaneKey.set(paneKey, { + lifecycleKey: targetByPaneKey.get(paneKey)?.lifecycleKey ?? 'title', + titleForegroundKey: getTitleForegroundKey(title, args.tab.launchAgent) + }) + }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cd40957f-cab7-450a-aa08-65e125a3d1c7
📥 Commits
Reviewing files that changed from the base of the PR and between d7322ec and 16987e946ebbca1bbe7449be6c57357fb80e166c.
📒 Files selected for processing (22)
src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsxsrc/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.test.tsxsrc/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.test.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.tssrc/renderer/src/components/sidebar/worktree-agent-row-agent-type.tssrc/renderer/src/components/sidebar/worktree-agent-row-selectors.test.tssrc/renderer/src/components/sidebar/worktree-agent-rows.tssrc/renderer/src/components/sidebar/worktree-foreground-agent-row-selectors.tssrc/renderer/src/components/sidebar/worktree-foreground-agent-row-type.tssrc/renderer/src/components/sidebar/worktree-foreground-agent-rows.test.tssrc/renderer/src/components/sidebar/worktree-foreground-derived-agent-rows.tssrc/renderer/src/components/sidebar/worktree-foreground-sync-targets.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/lib/use-tab-agent-foreground-cache.test.tssrc/renderer/src/lib/use-tab-agent.test.tssrc/renderer/src/lib/use-tab-agent.tssrc/renderer/src/store/slices/store-cascades.test.tssrc/renderer/src/store/slices/terminal-orphan-helpers.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.ts
31c5e6a to
f6c2cb8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/worktree-foreground-sync-targets.ts (1)
26-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a short comment on why epochs are part of the identity key.
Folding
commandFinishedEpoch/interruptInputEpochintotargetKey()is a non-obvious race-hardening mechanism (per the PR's "harden agent tab foreground races" intent) — a one-line comment would help future readers understand why these counters bump the key.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9802555b-2d91-4ff7-bdac-8a7aa9b33f72
📥 Commits
Reviewing files that changed from the base of the PR and between 7234d44 and 56c76b6bab2ce6e825e020d5ebe0d97752d3f684.
📒 Files selected for processing (10)
src/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.test.tsxsrc/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.tssrc/renderer/src/components/sidebar/worktree-foreground-sync-targets.tssrc/renderer/src/lib/tab-agent-hook-signals.tssrc/renderer/src/lib/use-tab-agent-launch-lifecycle.test.tssrc/renderer/src/lib/use-tab-agent.tssrc/renderer/src/store/slices/store-cascades.test.tssrc/renderer/src/store/slices/terminal-orphan-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/renderer/src/store/slices/worktrees.test.ts
- src/renderer/src/store/slices/worktrees.ts
- src/renderer/src/store/slices/store-cascades.test.ts
- src/renderer/src/store/slices/terminal-orphan-helpers.ts
- src/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.test.tsx
- src/renderer/src/lib/use-tab-agent-launch-lifecycle.test.ts
- src/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.ts
- src/renderer/src/lib/use-tab-agent.ts
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/renderer/src/components/sidebar/worktree-foreground-sync-targets.ts (1)
16-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a short "why" comment for
inputEpoch.The rationale for including
inputEpochin the identity key (busting a stale-suppression window so a legitimate relaunch isn't hidden) is documented downstream inuse-worktree-foreground-agent-sync.ts, but not here where the field/key is defined. A future edit totargetKey()could drop this field without realizing it breaks that downstream invalidation contract.As per coding guidelines: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
📝 Suggested comment
export type ForegroundSyncTarget = { commandFinishedEpoch: number + // Included so a fresh terminal input can invalidate a stale post-finish + // suppression in the sync hook and trigger a foreground re-read. inputEpoch: numberSource: Coding guidelines
src/renderer/src/components/sidebar/worktree-foreground-epoch-selectors.ts (1)
40-106: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short comment on why manual identity-preserving memoization is used here.
The module-level caches plus
reuseNumberRecordIfEqual/reuseEpochsIfEqualare a deliberate, non-obvious technique: preserving object identity per worktree so unrelated worktrees don't get spuriously re-synced (each foreground re-sync triggers an IPC call viagetForegroundProcess). Worth a one-line note so a future refactor doesn't "simplify" this into a plain rebuild and silently cause excessive foreground re-reads.As per coding guidelines: "add a comment explaining why the code behaves the way it does... capturing only the non-obvious reason."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 73decc8f-1238-49bc-9ff0-3e87eab3c3db
📥 Commits
Reviewing files that changed from the base of the PR and between 56c76b6bab2ce6e825e020d5ebe0d97752d3f684 and 137e7541895160155094dafc615f0dc1312a573a.
📒 Files selected for processing (5)
src/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.test.tsxsrc/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.tssrc/renderer/src/components/sidebar/worktree-agent-row-selectors.test.tssrc/renderer/src/components/sidebar/worktree-foreground-epoch-selectors.tssrc/renderer/src/components/sidebar/worktree-foreground-sync-targets.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/components/sidebar/worktree-agent-row-selectors.test.ts
- src/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.ts
- src/renderer/src/components/sidebar/use-worktree-foreground-agent-sync.test.tsx
Per Brennan's direction on this PR: tab icons must not run their own foreground-process probe. Identity now flows through the same already-computed state as the sidebar agent rows — hook entries (kept live by the OSC 133 command-finished drop machinery), explicit titles, and launch bootstrap. The probe's one unique local job, clearing stale launch identity after the launched agent exits, is replaced with probe-free evidence: a completed hook at a shell title, or a previously observed live hook row that was dropped (crash/kill path) while the title reads as a shell. Behavior trades, accepted with this direction: agents that never emit hooks resolve from title evidence or show no icon, and a done-but-open agent whose title reads as a shell shows no icon (matches the existing remote-pane behavior). Co-authored-by: Orca <help@stably.ai>
a9b74f3 to
d58772e
Compare
Review fixes: gate the vanished-activity clear to local panes (remote rows drop on transport blips), require no live hook row anywhere in the tab, make the observed-signal generation reset race-safe and self-re-seeding, accept the neutral default title as exit evidence (inferred-interrupt reset target), count a title naming the launched agent as its activity so hookless launched agents can clear, scope layout-less completed rows to single-pane tabs, share one exit-evidence predicate between the resolver and the clear effect, and drop the dead tab-agent wrappers. Co-authored-by: Orca <help@stably.ai>
… reads (#7189) Co-authored-by: Orca <help@stably.ai>
…per retry ladder Live verification on PR #7059 found two gaps: a TUI that dies leaving a stuck agent title kept painting the tab through the title-fallback layer (shell-foreground proof now suppresses title-derived identity and the local completed-hook fallback), and the daemon's wrapper→agent ancestry resolution can take >1.5s for real node-wrapped CLIs (the read ladder gets a second bounded re-read at 3.5s). Co-authored-by: Orca <help@stably.ai>
…on-running-agent # Conflicts: # src/renderer/src/components/terminal-pane/pty-connection.ts
Wholesale teardowns (tab close, worktree sleep/remove) retire pane keys without per-pane close events, stranding unreachable foreground entries for the renderer's lifetime. Mirror the agent-status prefix sweeps at both chokepoints; no-op sweeps bail without a state change. Co-authored-by: Orca <help@stably.ai>
A settle-read that still runs means 133;D has not fired (D cancels pending reads), so a shell seen there is a nested sh/bash without integration. Publishing shell-foreground from reads let a stale mark suppress live title identity for agents started inside nested shells; 133;D is now the only shell-foreground source. Also gate the shell-foreground exit-evidence branch on !isRemote (defense in depth; unreachable via production wiring) and document the worktree sweep's must-run-before-tab-prune ordering assumption. Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Summary
Tab-bar agent icons now resolve identity through the same already-computed state as the sidebar agent rows — hook status entries, explicit titles, and launch bootstrap — instead of running their own foreground-process probe. One pipeline drives both surfaces, so the tab icon and the WorktreeCard rows can no longer disagree about which agent a pane is running.
This replaces the earlier foreground-probe approach on this branch per review direction: the agent-status state is already kept correct (live hook rows are dropped by the OSC 133 command-finished machinery on crash/kill/Ctrl+C exits), so identity should reuse it rather than maintain a parallel probing pipeline.
What changed
useTabAgentno longer callsgetForegroundProcess(no reads, no retry timers). Identity resolution is now: focused-pane hook agent → explicit title (with the existing stale-launch override) → launch bootstrap → sibling/completed hook fallback — the same evidence the sidebar rows derive from.launchAgentidentity after the launched agent exits — is replaced with probe-free evidence, expressed as a single shared predicate (resolveLaunchedAgentExitEvidence) used by both the resolver and the clear effect: the title shows no agent (a shell name, or the tab's neutral default title — the inferred-interrupt reset target), no live hook row remains anywhere in the tab, and either the hook completed or previously observed activity vanished (the crash/kill path, where OSC 133;D removes the entry without a completed hook).tab-agent.ts,SortableTab.tsx), and the never-consumed composed wrappers (resolveTabAgent,hasCompletedTabAgent,resolveCompletedTabAgent) were removed —useTabAgentcomposes the focused/sibling resolvers directly.Hardening (review round)
A review pass on the first cut of this rework found races and scope bugs in the clear rule; all fixed in
1f8219c:launchAgent).launchAgentwhile an agent is still running — clears require no live hook row anywhere in the tab, and a layout-less multi-pane tab no longer treats a sibling's done row as focused-pane exit evidence.defaultTitle("Terminal N") counts as exit evidence alongside shell names — Orca's inferred-interrupt flow parks titles there, and previously the stale agent icon survived indefinitely on that path.Live verification (dev instance, this branch @
3b925bd)Exercised end-to-end in a real Electron dev build with the store instrumented and the tab bar inspected (
data-agent-icon):aider(no hooks, no titles) run by hand → tab icon flipped to aider via the process tracker; Ctrl+C → OSC 133;D published shell-foreground with no RPC → icon reverted.launchAgent: 'aider'showed the icon instantly pre-start; after the process ran and was interrupted,clearTabLaunchAgentfired via process-grade evidence and the clear persisted across an app reload.working→donehook states observed live with correct pane attribution; tab icon, sidebar WorktreeCard indicator (orange Claude dot), and Agent Session History all agreed; clean/exitpublished shell-foreground and cleared the icon.3b925bd: (1) a TUI dying with a stuck agent title kept its icon through the title-fallback layer even though the pane was provably at the shell — shell-foreground proof now suppresses title-derived identity and the local completed-hook fallback (remote panes unaffected); (2) the daemon's wrapper→agent ancestry resolution took >1.5s for the real node-wrappedclaude, so the tracker's bounded ladder gets a second re-read at 3.5s.Behavior trades (accepted with this direction)
doneis turn-scoped, so title-less hook agents idle at a shell-reading title blank between turns; this matches the existing remote-pane behavior and is inherent to probe-free evidence.Checks
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/use-tab-agent.test.ts src/renderer/src/lib/tab-agent.test.ts src/renderer/src/components/sidebar/useWorktreeAgentRows.test.ts src/renderer/src/components/sidebar/WorktreeCardAgents.test.tsx— 107 tests passeduseTabAgentnever callsgetForegroundProcess; row-drop clears at a shell title (local only — remote pinned to not clear); live focused or sibling rows block clearing; neutral-default-title exit; hookless same-agent-title exit; layout-less multi-pane completed rows don't clear; the one-commit generation switch doesn't clear.pnpm run typecheck— passedpnpm run lint— passedgit diff --check— passedNotes
The previous foreground-probe implementation (including its review fixes) is preserved on the local branch
backup/7059-foreground-probe-approach. One orthogonal piece of it may be worth its own PR later: the terminal protocol auto-reply filter that stops xterm.js query replies (DA/DSR/CPR/OSC color/DCS) from counting as user input for hibernation idle tracking.Known follow-ups (pre-existing, out of scope here): the tab and sidebar title→agent maps have drifted (
MiMo Codeexists only inshared/terminal-title-agent-type.ts) andtab-agent.tsmapsentry.agentTypewithout the sidebar's compatible-owner normalization, so the two surfaces can still disagree for Pi-compatible harnesses;SHELL_NAMESinshared/shell-process-detection.tsaccidentally contains the empty string (leading-|split) — neutralized here by the blank-title guard, but worth fixing at the source.