Repository navigation
fix(sidebar): show Cursor rows and stop a stray "claude" title hijacking OpenCode - #12466
Conversation
…ing OpenCode Two defects in the same title-resolution path. **#10258** — Cursor's only native OSC title is the literal `cursor agent`, which both title trackers dropped unconditionally. A hookless Cursor pane therefore had neither a status entry nor any title carrying Cursor identity, so the worktree card showed nothing at all. **#8940** — two owner-blind paths let an incidental `claude` token anywhere in an OpenCode session or task title outrank the pane's known owner, so the tab icon and sidebar row flipped to Claude Code. #10258: let the literal through exactly once as identity, so a restored or mobile tab keeps its Cursor row instead of vanishing. #8940: require an *identity frame* — after stripping status decoration the title must PRESENT Claude, not merely mention it — before a Claude title may reclaim a pane from its prior identity, and make the sidebar row builder owner-aware. > These two are in one PR because they share the `ownerAgentType` plumbing through `buildTitleDerivedAgentRow` — split apart, neither half compiles on its own. Fixes #10258 Fixes #8940 Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThe change updates Cursor native-title handling across shared utilities, renderer transport, and main runtime state. The first bare 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
Fails on origin/main, passes on this branch. Test: sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands Co-authored-by: Orca <[email protected]>
Visual proofRecorded with 12466-sidebar-agent-row-identity.spec.ts.webmWhat you are looking atLeft half of the window is the worktree sidebar; right of it the terminal tab bar and pane. The test opens two real agent-launched terminal tabs in the active worktree and lets each pane emit one real OSC title over its PTY (a node emitter that prints "agent pane holding" and then holds the pane forever, so no shell prompt repaints the title). ON THE FIX (verified screenshot /tmp/proof-specs/fix-pass.png): the "master" worktree card grows TWO agent rows — "use Claude Sonnet — Running" carrying the OpenCode identity glyph, and directly under it "Cursor — idle" carrying the Cursor glyph. The third tab in the tab bar is titled "Cursor Agent". ON MAIN (verified screenshot test-results/.../test-failed-1.png): the same card shows only ONE row — "use Claude Sonnet — Running" wearing the orange Claude asterisk icon (the OpenCode pane hijacked by an incidental "claude" token, #8940) — and no Cursor row exists at all; the Cursor tab is titled with the repo path because the "cursor agent" literal was dropped (#10258). So in the recording the reviewer literally sees the sidebar card go from one mislabelled Claude row to two correctly-identified rows (OpenCode + Cursor). The assertion reads the rendered rows' identity-icon tooltips, so the failure diff (Received ["Claude"] vs Expected ["Cursor","OpenCode"]) names exactly what is on screen. It actually captures the bugSame spec on Test: Caveats and setup notes from building this proofSpec path in the worktree: /Users/nwparker/projects/orca/.claude/worktrees/wf_7377b4a2-62e-3/tests/e2e/sidebar-agent-row-identity.spec.ts (untracked, nothing committed). Copy at /tmp/proof-specs/sidebar-agent-row-identity.spec.ts. Also in /tmp/proof-specs: fix-run.txt, main-run.txt, fix-pass.png. Run command (worktree is already on fix/sidebar-agent-row-identity with a fresh e2e build): … |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
10319-10322: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the duplicated
isLiveCursorNativeTitlecheck into one helper.The
onTitlecallback computesisLiveCursorNativeTitle(lines 10320-10321) with the exact expressionapplyTrackedPtyTitlecomputes internally (lines 10412-10413):isCursorNativeAgentTitle(rawTitle) && meta?.staleWorkingTitleClear !== trueThis predicate decides whether Cursor-identity evidence is cleared from the live records. Issues
#10258and#8940both hinge on this exact condition. A future change to one copy without the other reintroduces the bug this PR fixes.Extract a small private method, for example
isLiveCursorNativeTitle(rawTitle, meta), and call it from both places.Also applies to: 10402-10439
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9688acaf-25a0-46e9-8bec-9a7a07ebc29e
📒 Files selected for processing (16)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.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/parked-terminal-byte-watcher.test.tssrc/renderer/src/components/terminal-pane/pty-transport.test.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.tssrc/renderer/src/lib/use-tab-agent.test.tssrc/renderer/src/lib/use-tab-agent.tssrc/shared/agent-detection.tssrc/shared/agent-title-core.tssrc/shared/terminal-output-side-effects.tssrc/shared/terminal-title-agent-type.test.tssrc/shared/terminal-title-agent-type.tstests/e2e/sidebar-agent-row-identity.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fe393abc-ac40-4402-a253-81ae09e0e354
📒 Files selected for processing (5)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.tssrc/shared/terminal-output-side-effects.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/renderer/src/components/terminal-pane/pty-transport.ts
- src/shared/terminal-output-side-effects.ts
- src/main/runtime/orca-runtime.test.ts
- src/main/runtime/orca-runtime.ts
… matching Review follow-ups on the title-resolution path: - pty-transport dropped a native Cursor literal that main emits whenever a non-Cursor title preceded it, re-introducing the #10258 blank row in the renderer path. The pre-filter now projects the predecessor the drain will actually see, and defers to the drain gate while facts are still queued. - applyTrackedPtyTitle threaded the cursor flag through 12 sites, including ptyRecordChanged bookkeeping the sole caller ignores. Force the status null once, and the activity-gated effects fall out unchanged. - isClaudeIdentityFrameTitle missed a multiplexer-wrapped Claude title ("zsh | Claude Code"), costing a genuine Claude pane its identity. Reuse the ' | ' segment split that agent-title-owner already had inline. - Keep title normalization on launchAgent: it only rewrites within an identity group (OMP wraps Pi), so a split does not make it wrong, and the hook-row path normalizes the same way. - Drop the tab.ptyId tracker fallback, which read a pty that the pane identity check had just rejected. Co-authored-by: Orca <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts (1)
227-229: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the emitted title values.
The length assertion does not verify that the re-emitted event is the native
Cursor Agenttitle. Assert the three title events, includingnormalizedandraw, as in the preceding test.Proposed test assertion
expect(deferred.main.events).toEqual(deferred.renderer.events) - expect(deferred.main.events.filter((event) => event.kind === 'title')).toHaveLength(3) + expect(deferred.main.events.filter((event) => event.kind === 'title')).toEqual([ + { kind: 'title', normalized: 'Cursor Agent', raw: 'Cursor Agent' }, + { kind: 'title', normalized: 'zsh', raw: 'zsh' }, + { kind: 'title', normalized: 'Cursor Agent', raw: 'Cursor Agent' } + ])
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 97384145-7e7e-424c-afbf-3455fc589559
📒 Files selected for processing (8)
src/main/runtime/orca-runtime.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.tssrc/shared/agent-title-owner.tssrc/shared/terminal-title-agent-type.test.tssrc/shared/terminal-title-agent-type.tssrc/shared/terminal-title-wrapper-segments.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/shared/terminal-title-agent-type.ts
- src/renderer/src/components/terminal-pane/pty-transport.ts
- src/main/runtime/orca-runtime.ts
- src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
- src/shared/terminal-title-agent-type.test.ts
…ing OpenCode (stablyai#12466) * fix(sidebar): show Cursor rows and stop a stray "claude" title hijacking OpenCode Two defects in the same title-resolution path. **stablyai#10258** — Cursor's only native OSC title is the literal `cursor agent`, which both title trackers dropped unconditionally. A hookless Cursor pane therefore had neither a status entry nor any title carrying Cursor identity, so the worktree card showed nothing at all. **stablyai#8940** — two owner-blind paths let an incidental `claude` token anywhere in an OpenCode session or task title outrank the pane's known owner, so the tab icon and sidebar row flipped to Claude Code. stablyai#10258: let the literal through exactly once as identity, so a restored or mobile tab keeps its Cursor row instead of vanishing. stablyai#8940: require an *identity frame* — after stripping status decoration the title must PRESENT Claude, not merely mention it — before a Claude title may reclaim a pane from its prior identity, and make the sidebar row builder owner-aware. > These two are in one PR because they share the `ownerAgentType` plumbing through `buildTitleDerivedAgentRow` — split apart, neither half compiles on its own. Fixes stablyai#10258 Fixes stablyai#8940 Co-authored-by: Orca <[email protected]> * test(e2e): add recordable proof for sidebar-agent-row-identity Fails on origin/main, passes on this branch. Test: sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands Co-authored-by: Orca <[email protected]> * fix(terminal): preserve restored Cursor identity * test(terminal): cover restored Cursor redraw suppression * refactor(terminal): tighten Cursor identity handling and Claude frame matching Review follow-ups on the title-resolution path: - pty-transport dropped a native Cursor literal that main emits whenever a non-Cursor title preceded it, re-introducing the stablyai#10258 blank row in the renderer path. The pre-filter now projects the predecessor the drain will actually see, and defers to the drain gate while facts are still queued. - applyTrackedPtyTitle threaded the cursor flag through 12 sites, including ptyRecordChanged bookkeeping the sole caller ignores. Force the status null once, and the activity-gated effects fall out unchanged. - isClaudeIdentityFrameTitle missed a multiplexer-wrapped Claude title ("zsh | Claude Code"), costing a genuine Claude pane its identity. Reuse the ' | ' segment split that agent-title-owner already had inline. - Keep title normalization on launchAgent: it only rewrites within an identity group (OMP wraps Pi), so a split does not make it wrong, and the hook-row path normalizes the same way. - Drop the tab.ptyId tracker fallback, which read a pty that the pane identity check had just rejected. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Two defects in the same title-resolution path.
#10258 — Cursor's only native OSC title is the literal
cursor agent, which both title trackers dropped unconditionally. A hookless Cursor pane therefore had neither a status entry nor any title carrying Cursor identity, so the worktree card showed nothing at all.#8940 — two owner-blind paths let an incidental
claudetoken anywhere in an OpenCode session or task title outrank the pane's known owner, so the tab icon and sidebar row flipped to Claude Code.Fix
#10258: let the literal through exactly once as identity, so a restored or mobile tab keeps its Cursor row instead of vanishing. #8940: require an identity frame — after stripping status decoration the title must PRESENT Claude, not merely mention it — before a Claude title may reclaim a pane from its prior identity, and make the sidebar row builder owner-aware.
Verification
pnpm typecheckclean on this branchFixes #10258
Fixes #8940
Made with Orca 🐋