Repository navigation
fix(agents): stop a foreign agent name in task text from taking a pane - #19309
Conversation
Pure move, no behaviour change. The name tokens, display labels and the bare-name/whole-title resolvers come out of agent-title-evidence.ts into agent-title-name-anchoring.ts so more than one predicate can resolve a name to an agent through the same implementation rather than by convention. Nothing is added or reworded on the way out; the extracted functions are unchanged and simply exported. Verified by the existing suites: the title, identity and sidebar tests all pass untouched. The identity ratchet moves with it — titleHasAgentName's two parser-implementation callsites now live in the new module — so this commit is green on its own rather than leaving the ratchet red until the next one.
A Claude pane's WORKING title is a bare braille spinner plus task text, so any agent name inside that text resolved the title to a committed foreign identity. The guard that fixed the mirror-image bug was written for the Claude label only, so every other name short-circuited above it and took the pane from its owner — the tab icon in use-tab-agent.ts, and the sidebar/dashboard row in worktree-title-derived-agent-rows.ts, which never consulted the owner at all. Make the rule agent-neutral in both directions: a title may only take a pane from a known owner when it PRESENTS that agent, never when the name merely occurs in free-form task text. titlePresentsAgent sits beside collectAgentTitleEvidence and resolves names through the vocabulary they now share. It differs from the parser in one respect: the parser asks who a title names given no owner, so it must refuse anything a task sentence could forge; this predicate is told which agent to check, so it also accepts that one name in an identity POSITION — the whole undecorated remainder, or the head of a `Name:` frame. The colon is what separates `Codex: fix cursor offsets` from `Claude Code compare Opencode`. resolveTabAgentFromSignals exists twice, already drifted in owner handling. useTabAgent calls the copy in use-tab-agent.ts, which is what paints the tab icon; every existing test imports the copy in tab-agent-from-signals.ts. Both are fixed, and the new suite runs its whole contract through both so a future divergence fails instead of hiding.
Narrowing the map's value type to TuiAgent surfaced an inaccuracy that was always there: noUncheckedIndexedAccess is off, so indexing Record<string, _> types every lookup as a hit, and `label` is arbitrary text parsed off a terminal title. The compiler concluded the `?? 'unknown'` fallback was unreachable and the unknown-label comparison impossible. The runtime disagrees — the map carries a fixed set of ~10 labels and misses everything else. Deleting the branch would return undefined where the function returns 'unknown' today, so the type is what is wrong. Partial<Record<...>> makes absence expressible and leaves behaviour unchanged. Pinned by a test, since nothing else forced the map to be honest about this.
|
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:
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
ℹ️ No critical issues — one minor performance nit inline.
Reviewed changes
Makes the "title presents agent" owner guard agent-neutral in both directions — fixing the foreign-agent-name pane theft behind STA-4554/4555 — and extracts the shared name-anchoring vocabulary so the evidence parser and the new predicate resolve names through one implementation.
titlePresentsAgentpredicate (src/shared/agent-title-evidence.ts) — decides whether a title presents a named agent (identity position) versus merely mentions it; the one intentional divergence fromcollectAgentTitleEvidence(admits bare⠋ Codex) is test-pinned.- Three consumers re-pointed to the agent-neutral rule — both
resolveTabAgentFromSignalscopies (use-tab-agent.ts,tab-agent-from-signals.ts) and the sidebar'sresolveTitleDerivedAgentType. Partial<Record<string, TuiAgent>>map type — makes the sidebar label map's?? 'unknown'fallback honest rather than dead-looking.- Vocabulary extraction —
agent-title-name-anchoring.tsplus thepane-agent-identity-inventoryratchet declaration the move requires. - Tests — a
describe.eachsuite running the contract through both resolver copies, with non-discriminating cases labeled inline and an ablation result documented.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
titlePresentsAgent read only anchoredNames, so it missed the evidence class the parser ranks highest: a vendor marker, the sigil an agent emits itself and task text cannot forge. Gemini's four glyphs and Cursor's native literal are markers, not anchored names, so every Gemini working, idle and permission title — and Cursor's literal — failed the gate and the pane stayed on its previous owner. Run Claude, let it finish, run gemini in the same pane: tab and sidebar both stayed Claude. The bug this change exists to fix, mirrored. Admitting the whole vendor class would have reintroduced #8940 the other way, because Claude's '. ', '* ' and idle sigil are generic — OpenCode emits them too — so they prove activity, not identity. hasGenericClaudeStatusPrefix already modelled that distinction inside terminal-title-agent-type.ts; it moves to agent-title-core.ts so both callers share the one definition. Not isGenericClaudeStatusClaim, which is that model plus a clause for a different question: it treats a 'claude' token as upgrading a generic prefix into a real claim, which is right when asking whether a title may MINT Claude identity and wrong when asking whether it PRESENTS Claude. Applied here it would have let ". port the claude prompt" reclaim an OpenCode pane. The predicate is now one memoized set per title rather than a memoized first line and an uncached scan, so the common path — a title presenting nobody — no longer re-runs the name matchers over every wrapper segment on each render.
…e corpus Two review rounds found the same class of defect: the gate was a second model of "does this title present an agent", poorer than the model its callers use. Round 1 missed an evidence class, round 2 missed four whole ROUTES in a different function. A third patch would have bought the fifth route. getAgentLabel mints identity through routes the evidence parser cannot express, because titleHasAgentName asks whether a name occurs ANYWHERE and never where. One Codex branch therefore serves both 'codex working' and the mid-sentence mention this change exists to reject. Route identity cannot separate them; the gate genuinely needs position information the resolver discards. So the models cannot be collapsed. What they can be is one GRAMMAR plus an enforced agreement: agentForIdentityFrame generalizes what isClaudeIdentityFrameSegment has always described — a name, an optional status word, an optional '- action required' — which was agent-neutral in shape and applied only to Claude. That was the same one-way-guard mistake as the original bug, one level down. Generalized, it covers every minting route: bare names, 'Codex: ...', em-dash frames, name plus status, Windows launcher forms, '|'-headed titles and Pi's native format. The positional and vendor-marker rules fold into it rather than stacking beside it. terminal-title-pane-claim-corpus.test.ts is the enforcement. It sweeps the whole classification corpus, and any title getAgentLabel still mints an identity from must remain able to claim a pane. Shared code cannot enforce this because the two models legitimately differ; the corpus can, and it names the offending title when a future route is added. Corpus: 14 lost claims before this commit, 0 after. One intended gain, 'claude.bat working', listed and explained in the ratchet: the old gate accepted 'aider.ps1 ready' for aider and refused the identical form for Claude purely because the guard was Claude-only.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 4e08e769-9942-4289-b9b0-2f82b6eb84bf
📒 Files selected for processing (9)
src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.tssrc/renderer/src/lib/tab-agent-foreign-name-title-guard.test.tssrc/renderer/src/lib/tab-agent-pane-claim-corpus.test.tssrc/shared/agent-title-core.tssrc/shared/agent-title-evidence.test.tssrc/shared/agent-title-evidence.tssrc/shared/agent-title-name-anchoring.tssrc/shared/terminal-title-agent-type.tssrc/shared/terminal-title-pane-claim-corpus.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Revisited the two fixes pushed since the prior review — vendor-marker reclamation and the single identity-frame grammar — plus the corpus ratchets that pin them.
- Memoized
titlePresentedAgentsset replaces the per-agent position scan —titlePresentsAgentnow delegates to onememoizeTitleClassification-cachedReadonlySet<TuiAgent>, resolving the prior uncached regex-ladder nit (per-render cost is now a.has()). - Vendor-marker admission — an agent's own sigil (Gemini glyphs, Cursor's native literal) still reclaims a pane from a prior owner, while Claude's generic
./*/spinner status decorations are excluded (hasGenericClaudeStatusPrefix) since OpenCode emits the same markers (#8940). agentForIdentityFramegeneralizes the Claude frame grammar — name plus optional status word /- action required, plus pi/OMP native forms, so every route the resolver mints identity from remains claimable.- Two corpus-ratchet suites —
terminal-title-pane-claim-corpus.test.tsandtab-agent-pane-claim-corpus.test.tsforce the gate to agree with the resolver across the whole corpus and pin the sole intended new claim (claude.bat working), so a future grammar drift in either direction fails concretely.
Focused suites pass: agent-title-evidence (117), terminal-title-pane-claim-corpus (4), tab-agent-pane-claim-corpus (4), tab-agent-foreign-name-title-guard (32).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The head grammar treated '|' as a separator an agent puts after its own name. Wrappers PREFIX the pane's title and the innermost title comes LAST (terminal-title-wrapper-segments.ts), so a name before a '|' is a tmux window or an ssh host, never the pane. `claude | zsh` on a Codex-owned pane therefore handed it to Claude through all three consumers — this change's own bug, inverted. Wrapper-joined titles already reach the real pane title through getEvidenceTitleSegments' suffix splitting, which is what actually resolves `ssh host | opencode ready`; the separator was not carrying that case. '>' goes too. Pi's native `π > session` is matched before the head grammar runs, so the only titles it affected were `name > text` breadcrumbs, which are closer to task text than to an identity frame. That narrows `⠋ gemini > next steps` and `⠋ codex > plan` relative to the previous gate; both are pinned as intended rejections, since refusing leaves the pane with its known owner, which is the safe direction on ambiguous evidence. The corpus gain assertion is renamed to say it is corpus-scoped. Over every string literal in the repo the change gains more than the one title this 67-title corpus can see, mostly the same Claude symmetry, and the test should not read as a global guarantee. Near-misses the grammar deliberately accepts are pinned too, so the boundary is visible and moving it requires editing a list.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the single commit pushed since the prior review (8b65244ffc), which narrows the identity-frame grammar so a wrapper prefix (tmux window |, ssh host |) or a > breadcrumb can no longer pass as an agent identity frame.
IDENTITY_FRAME_HEAD_REdrops|and>as separators (src/shared/agent-title-name-anchoring.ts) — a name before|is a wrapper prefix, never the pane, and>was only ever Pi's nativeπ > sessionform, which the legacy-Pi branch already matches before the head grammar runs.- Wrapper/breadcrumb titles moved into the must-reject list (
src/shared/terminal-title-pane-claim-corpus.test.ts) —claude | zsh,codex | main | Fix the parser,⠋ gemini > next steps, and⠋ codex > plannow pin the narrowing, and a new near-miss boundary test pins the accepted edge adjacent to them.
Verified the narrowing is a real ablation (the new must-reject cases fail on the prior grammar), that ssh host | opencode ready still resolves through getEvidenceTitleSegments suffix splitting, and that π > session still resolves through isLegacyPiCompatibleTitle. Focused suites pass: terminal-title-pane-claim-corpus (5), agent-title-evidence (117), tab-agent-foreign-name-title-guard (32), tab-agent-pane-claim-corpus (4).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1

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:
143bd5b2-4b9f-4c7a-8ff1-f4f397081d45
Files selected for processing: 28-
mobile/src/session/mobile-terminal-tab-agent.test.tssrc/main/runtime/orchestration-mailbox-cold-park-idle.spec.tssrc/main/runtime/orchestration-mailbox-notification-test-harness.tssrc/main/runtime/terminal-wait-name-only-idle.test.tssrc/main/runtime/tui-idle-evidence.tssrc/renderer/src/components/sidebar/title-derived-pane-agent-identity.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.test.tssrc/renderer/src/components/terminal-pane/terminal-ctrl-enter.test.tssrc/renderer/src/components/terminal-pane/terminal-title-evidence.test.tssrc/renderer/src/components/terminal-pane/terminal-title-evidence.tssrc/renderer/src/components/terminal-pane/terminal-windows-shift-enter.test.tssrc/shared/agent-detection.test.tssrc/shared/agent-title-core.tssrc/shared/agent-title-evidence.test.tssrc/shared/agent-title-evidence.tssrc/shared/agent-title-name-anchoring.tssrc/shared/agent-title-status.tssrc/shared/dsb-terminal-title.tssrc/shared/opencode-terminal-title.tssrc/shared/qoder-terminal-title.tssrc/shared/terminal-pane-title-reset.test.tssrc/shared/terminal-pane-title-reset.tssrc/shared/terminal-title-agent-type.test.tssrc/shared/terminal-title-agent-type.tssrc/shared/terminal-title-classification-corpus.test.tssrc/shared/terminal-title-classification-memo.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
|
A Claude pane could acquire another agent's tab icon, sidebar/dashboard identity or keyboard encoding when its task title mentioned that agent. Title normalization could discard the task text and leave a false provider label. The fix keeps producer-backed title identity separate from task text, preserves provenance through normalization and uses the same answer for desktop/mobile identity and committed-title input routing. A user who exits an agent and starts another in the same ordinary pane can still change its identity. User-typed commands are unchanged. An unowned task-only title stays Active without inventing an agent row/Working ring, and task text alone cannot override a fresh other-agent hook to announce completion. Independent owner evidence and captured native frames retain their positive paths. The final reviewed shipped code is 89597b9; main merge 7480c27 preserved its PR patch byte-for-byte. Test-only CI repairs c99ccd6, 5f080dc and 7193757 retain the regression assertions, move the renderer performance contract into its existing TypeScript project and add negative/positive controls for the settled strict identity policy. Review: round 4 correctness and architecture challenge passed; all confirmed prior findings independently verified fixed. Final whole-mechanism comparison, readiness and performance passes completed. Intended difference from the common pattern: structural title fallback supports manual, hookless, SSH and mixed-version panes without requiring a binding event. Existing unsupported-agent rows keep their generic Agent identity and historical label fallback; that fallback can still display provider-like task text under the retained unknown-row policy. Historical normalized-only Gemini/Qoder/Qoder CN/Grok status labels cannot recover task text an older producer already discarded; raw evidence can correct the manufactured label. No new saved field or minimum peer version is required. Validation: targeted source/consumer tests and the 14-scenario production-trigger operation contract passed, with unchanged counters after both CI test repairs. All CI checks passed on 7193757 (full gh watch exit 0). Native Windows Claude/Codex foreign-title Ctrl+Enter and Shift+Enter, two branch replies each, graceful saved-pane upgrade and genuine same-pane replacement passed. Desktop tab/sidebar/dashboard and native-leaf fixture screenshots passed. Baseline Codex raw-title evidence and normal default-tab setup were completed with targeted corrections; no passed flow was repeated. Actual modified-key bytes were unavailable; trusted process/hook signals mask the title-only fallback, separately covered by regression tests. Initial reply stalls and a recovered right-click clipboard-paste incident are retained in the report. Windows copies stopped gracefully, no recorded survivors/listeners remain and Windows real-config hashes are unchanged. Native iOS terminal-tab screenshot passed on a dedicated iPhone 16 Pro simulator with the completed-Claude fixture and the exact branch JavaScript/page bundle in the shipping native shell. Its compatible native container was reused; no mobile agent run is claimed. All 22 recorded mobile target/keeper identities have no survivors; the simulator is shut down and configured ports are released. One real-config hash changed on that machine; contents were not inspected and attribution is unknown. Deferred: unsupported no-pipe decoration spellings without a supported producer expectation (P3). The new fresh-hook tests cover the two diagnosed completion inputs; a full matrix of direct turn-end and Windows-focus callback substitutions was not added. No concrete failure has been demonstrated. Inherited presentation costs remain disclosed; no whole-pipeline linearity or zero warm-JavaScript claim is made. For Brennan's review: producer-envelope ownership, normalization provenance and row identity precedence. Windows captures use genuine hidden whole-window pixels. The baseline Codex supplement reused the saved conversation, so earlier branch turns remain in its scrollback. Build identity and immediate pre-key raw title were independently recorded. Live process/hooks mask title fallback in these runs; display fixtures and regression tests cover that boundary.
Genuine same-pane Claude → Codex replacement: Completed-Claude owner with foreign task text — terminal tab/sidebar and workspace dashboard: Native-leaf positive admission and the negative Droid fixture beside the completed-Claude tab (fixtures, no Grok agent run): Normal baseline setup/default-tab confirmation after selecting Blank Terminal: Native iOS terminal tab, branch-only display fixture: completed Claude ownership with task title “⠋ fix the grok launcher”. The shipping native shell loads this branch’s JavaScript and mobile page bundle; its compatible native container was reused. No mobile agent run. |
Keeps both favicon entries where upstream added Codebuddy, and teaches the explicit title evidence about Codewhale: stablyai#19309 stopped treating a loose name as identity, so its whole-segment title now anchors the agent the way DSH's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>














A Claude terminal could switch its tab icon and sidebar/dashboard row to another agent when its task title mentioned that agent, such as “⠋ fix the grok launcher”. Title-only keyboard readers could then select the other agent's input encoding. Normalization could also replace the task text with a false provider label before those readers saw it.
Pane identity now comes from an unambiguous producer-backed title frame when stronger owner/process evidence is absent. A native frame owns its session/task payload, and display normalization preserves its identity. The same answer reaches desktop/mobile tabs, sidebar/dashboard rows and committed-title input readers. Genuine user-started and hookless reuse remains supported. Readiness and confirmed-shell cleanup retain their existing title policy. A task-only title without independent agent identity no longer invents an agent row or Working ring; it remains Active. Task text alone also cannot override a fresh other-agent hook to announce completion. Native frames and independent owner evidence retain their existing positive behavior.
Intended difference from the common pattern: Orca keeps structural title fallback for manual, hookless, SSH and mixed-version panes where no binding event is guaranteed. Existing stronger ownership and canonical-host policy remain intact. Existing unsupported-agent rows keep their generic Agent identity and historical label fallback; that fallback can still display provider-like task text under the retained unknown-row policy.
Intended historical limit: an older producer or saved snapshot may contain only a normalized Gemini, Qoder, Qoder CN or Grok label after discarding the original task title. This applies to all ten exact status labels emitted by the normalizer. That label alone cannot reveal the lost text. Supplied raw evidence can correct a manufactured label; normalized-only history retains the existing title-only behavior without a new saved field or peer-version requirement.
Code review, the reference comparison, targeted regression/performance tests and all CI checks passed on
7193757ff863f6bbbb7cc5813ff585fd166055b4. Native Windows Claude and Codex passed Ctrl+Enter and Shift+Enter with genuine committed titles mentioning other agents, two branch replies each, graceful saved-pane upgrade and manual same-pane Claude → Codex replacement. Branch desktop tab/sidebar/dashboard and native-leaf fixture captures passed. Baseline Codex title evidence and ordinary default-tab setup were completed with targeted corrections; passed flows were preserved. Actual wire bytes were unavailable, and trusted process/hook ownership masks title-only fallback in these real runs; regression tests cover that fallback. Reply delays and a recovered clipboard-paste incident remain disclosed in the QA report. Windows copies stopped gracefully, no recorded survivors or slot listeners remain, and Windows real-config hashes are unchanged. The shipping native iOS terminal-tab screenshot passed with completed-Claude ownership and the foreign Grok task title on a dedicated iPhone 16 Pro simulator. The native shell loaded this exact branch’s JavaScript and production mobile page bundle; its compatible native container was reused, and the fixture screenshot does not claim a mobile agent run. All 22 recorded mobile process identities have no survivors, the simulator is shut down and configured ports are released. One real-config hash changed on that machine; contents were not inspected and attribution is unknown. The loop status comment includes the screenshots and evidence bounds.Tracked in STA-4554
Tracked in STA-4555