Skip to content

fix(sidebar): show Cursor rows and stop a stray "claude" title hijacking OpenCode - #12466

Merged
nwparker merged 6 commits into
mainfrom
fix/sidebar-agent-row-identity
Aug 9, 2026
Merged

nwparker merged 6 commits into
mainfrom
fix/sidebar-agent-row-identity

Conversation

@nwparker

@nwparker nwparker commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

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.

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.

These two are in one PR because they share the ownerAgentType plumbing through buildTitleDerivedAgentRow — split apart, neither half compiles on its own.

Verification

  • pnpm typecheck clean on this branch
  • This branch's own tests pass; the new cases fail before the change and pass after
  • Split out of the original combined branch; the union of all 12 split branches was diffed back against it to prove nothing was lost

Fixes #10258
Fixes #8940

Made with Orca 🐋

…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]>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change updates Cursor native-title handling across shared utilities, renderer transport, and main runtime state. The first bare Cursor Agent title is retained, repeated native redraws are suppressed, and synthesized Cursor titles remain available for working-state detection. Native titles do not seed or represent agent liveness. Sidebar attribution now uses pane ownership and explicit Claude identity frames. Tests cover title parity, runtime behavior, sidebar resolution, and PTY-based end-to-end identity rendering.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defects, fixes, issues, and verification, but omits the required Screenshots, AI Review Report, Security Audit, Notes, and testing checklist sections. Add all template sections, mark each testing item, state whether visual proof is included, and document AI review, cross-platform checks, security audit, and follow-up notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes both primary fixes: preserving Cursor sidebar rows and preventing stray Claude title ownership.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands.

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]>
@nwparker

nwparker commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Visual proof

Recorded with --repeat-each=3; the harness refuses to emit a video for a failing run, so this is three consecutive passes.

12466-sidebar-agent-row-identity.spec.ts.webm

What you are looking at

Left 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 bug

Same spec on origin/main:

Ran on origin/main (5f9a5b80b37), --repeat-each=3, all 3 failed:

Running 3 tests using 1 worker

  ✘  1 [electron-headless] › tests/e2e/sidebar-agent-row-identity.spec.ts:150:5 › sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands (9.2s)
  ✘  2 [electron-headless] › tests/e2e/sidebar-agent-row-identity.spec.ts:150:5 › sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands (7.9s)
  ✘  3 [electron-headless] › tests/e2e/sidebar-agent-row-identity.spec.ts:150:5 › sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands (8.9s)

  1) [electron-headless] › tests/e2e/sidebar-agent-row-identity.spec.ts:150:5 › sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands 

    Error: expect(received).toEqual(expected) // deep equality

    - Expected  - 2
    + Received  + 1

      Array [
…

Test: sidebar keeps a Cursor pane visible and an OpenCode pane out of Claude Code hands
Spec: tests/e2e/sidebar-agent-row-identity.spec.ts (committed to this branch)

Caveats and setup notes from building this proof

Spec 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):
SKIP_BUILD=1 npx playwright test tests/e2e/sidebar-agent-row-identity.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1 --repeat-each=3
Use npx playwright, not pnpm exec playwright (pnpm resolves a different playwright binary that has no test subcommand).

…

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

10319-10322: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated isLiveCursorNativeTitle check into one helper.

The onTitle callback computes isLiveCursorNativeTitle (lines 10320-10321) with the exact expression applyTrackedPtyTitle computes internally (lines 10412-10413):

isCursorNativeAgentTitle(rawTitle) && meta?.staleWorkingTitleClear !== true

This predicate decides whether Cursor-identity evidence is cleared from the live records. Issues #10258 and #8940 both 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

📥 Commits

Reviewing files that changed from the base of the PR and between e172a51 and 246ceae.

📒 Files selected for processing (16)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts
  • src/renderer/src/lib/use-tab-agent.test.ts
  • src/renderer/src/lib/use-tab-agent.ts
  • src/shared/agent-detection.ts
  • src/shared/agent-title-core.ts
  • src/shared/terminal-output-side-effects.ts
  • src/shared/terminal-title-agent-type.test.ts
  • src/shared/terminal-title-agent-type.ts
  • tests/e2e/sidebar-agent-row-identity.spec.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 246ceae and 3b0b230.

📒 Files selected for processing (5)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts
  • src/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

nwparker and others added 2 commits August 9, 2026 00:55
… 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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts (1)

227-229: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the emitted title values.

The length assertion does not verify that the re-emitted event is the native Cursor Agent title. Assert the three title events, including normalized and raw, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e848da and 68d668c.

📒 Files selected for processing (8)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts
  • src/shared/agent-title-owner.ts
  • src/shared/terminal-title-agent-type.test.ts
  • src/shared/terminal-title-agent-type.ts
  • src/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

@nwparker
nwparker merged commit 970696a into main Aug 9, 2026
47 checks passed
@nwparker
nwparker deleted the fix/sidebar-agent-row-identity branch August 9, 2026 08:32
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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.

[Bug]: Cursor Agent session are not shown in the left sidebar [Bug] opencode is displayed as Claude Code

1 participant