Skip to content

fix(agents): recognize OpenCode native OC | tab titles - #9102

Merged
nwparker merged 3 commits into
mainfrom
nwparker/fix-8478-wave3
Jul 17, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/fix-8478-wave3

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Summary

OpenCode sets OSC titles as OC | <task> without the token opencode. Title classifiers only treated OpenCode as identity when that token appeared, so tabs painted the Claude (or unknown) glyph instead of OpenCode.

This wires the existing OpenCode native-title predicate into both agent-label paths so OC | … (optional single-token mux prefix) resolves to OpenCode before Claude prefixes, Gemini glyphs, or task-text name matches. isClaudeAgent also rejects native OpenCode titles so braille inside the session text cannot rebrand the pane as Claude.

Credit: Takes over / builds on #8590 by @gatsby74 (same core idea: start-anchored OC | identity + early classifier priority + stale Claude launch reclaim). Improvements on main: consolidate with existing opencode-terminal-title.ts (avoid a parallel regex in agent-title-core), keep flexible OC|session spacing already used for display preservation, exclude native OC from both isClaudeAgent copies, and add adversarial multi-agent coverage + flipped #8478 repro regression.

Fixes #8478.
Supersedes #8590.

Description

  • Extend isOpenCodeNativeTitle / isMeaningfulOpenCodeTerminalTitle to share one start-anchored matcher: optional mux | prefix + case-sensitive OC + non-empty session text.
  • Early-return OpenCode from getAgentLabel in both agent-title-identity.ts and terminal-title-agent-type.ts.
  • Gate isClaudeAgent so OC | ⠋ … is not Claude.
  • Re-export from agent-detection.
  • Regression + adversarial tests; [Bug]: OpenCode logo is not coming up well #8478 repro kit flipped to assert the fixed behavior.

Evidence

  • Repro kit (docs/bug-reproductions/8478.md / src/shared/repro-8478-opencode-native-title-icon.test.ts on nwparker/bug-repro-handoffs) proved pre-fix: resolveTerminalTitleAgentType('OC | Understand about the plugin') !== 'opencode'.
  • After fix (this PR):
pnpm exec vitest run --config config/vitest.config.ts \
  src/shared/repro-8478-opencode-native-title-icon.test.ts \
  src/shared/opencode-terminal-title.test.ts \
  src/shared/terminal-title-agent-type.test.ts \
  src/shared/tab-title-resolution.test.ts \
  src/renderer/src/lib/use-tab-agent.test.ts \
  src/renderer/src/lib/agent-status-terminal-title.test.ts
# 6 files / 79 tests passed

ELI5

OpenCode shortens its terminal title to something like OC | fix the bug. Orca only looked for the word “opencode”, so it thought the tab was Claude and showed the wrong logo. Now Orca understands the short OC | … form and shows the OpenCode logo.

User-regression-tradeoffs

  • Positive: Correct OpenCode tab icons for native titles; reused panes with a stale Claude launch reclaim OpenCode once the native title is observed.
  • Tradeoff / residual: Braille-only OpenCode frames without OC | or the opencode token still follow the Claude spinner heuristic ([Bug] opencode is displayed as Claude Code #8940 family) — not solved here.
  • False-positive risk: Only uppercase start-anchored OC | … (optional single-token mux prefix) matches. Lowercase oc |, mid-title … | OC | …, multi-word prefixes, and bare OC | are rejected. Claude/Codex/Gemini/Cursor/Pi explicit titles unchanged in adversarial tests.
  • No UI token/layout change — reuses existing OpenCode glyph.

Screenshots

Before: issue screenshot — Claude glyph on an OpenCode tab.

After: No new assets in this PR; icon path is unit-tested via resolveTerminalTitleAgentType → agentTypeToIconAgent → opencode. Manual UI probe documented in #8590.

Testing

  • Targeted vitest (79 passed) listed under Evidence
  • oxlint on changed files (0 issues; pre-commit hook)
  • Full pnpm lint / pnpm typecheck / pnpm test / pnpm build (not run end-to-end in this session; CI should cover)
  • Added regression coverage: native + mux titles, compact OC|session, lowercase/embedded rejection, Gemini-glyph-inside-OC, other-agent identity, stale Claude launch reclaim, [Bug]: OpenCode logo is not coming up well #8478 repro flip

AI Review Report

Compared #8590 vs main and the #8478 repro kit.

Risks checked

  • Unanchored / mid-title false positives (⠋ Fix foo | OC | bar) — rejected by start anchor.
  • Task text naming other agents (OC | Compare Codex and Claude, OC | ✦ Gemini CLI) — native marker wins before Gemini glyphs and Claude prefixes.
  • Dual getAgentLabel / isClaudeAgent copies drifting — both updated.
  • Parallel regex vs existing opencode-terminal-title.ts — consolidated so display preservation and identity share one matcher (also keeps flexible OC|session spacing fix(agents): recognize OpenCode native tab titles #8590’s rigid OC | would miss).
  • Multiplexer / SSH titles — optional single-token prefix.
  • Tab-agent precedence — explicit OpenCode title reclaims stale Claude launch after activity (same case as fix(agents): recognize OpenCode native tab titles #8590).
  • Cross-platform: platform-neutral string match; no shortcuts, labels, paths, shell quoting, or Electron platform branches. Title path works where local process probing is disabled (SSH).
  • Other agents (Claude, Codex, Gemini, Cursor, Pi, OpenCode ready) keep prior classification in adversarial tests.

Not fixed here: #8940 braille OpenCode frames without native marker.

Security Audit

OSC titles are untrusted input. Handling is a fixed non-backtracking regex → existing enum/label. No HTML render of title content, no command execution, path resolve, IPC/auth boundary, credentials, new deps, or secrets. No follow-up security work needed.

Notes

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c1ab948e-1c06-4017-add1-bbdf3a2d4617

📥 Commits

Reviewing files that changed from the base of the PR and between 7af82a5b387ff2a1b745b8ef8b8ce25bc5cb16be and f220479.

📒 Files selected for processing (11)
  • src/renderer/src/lib/use-tab-agent.test.ts
  • src/renderer/src/runtime/sync-runtime-graph-terminal-layout.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/shared/agent-detection.ts
  • src/shared/agent-title-identity.ts
  • src/shared/opencode-terminal-title.test.ts
  • src/shared/opencode-terminal-title.ts
  • src/shared/repro-8478-opencode-native-title-icon.test.ts
  • src/shared/terminal-title-agent-type.test.ts
  • src/shared/terminal-title-agent-type.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/shared/agent-detection.ts
  • src/shared/agent-title-identity.ts
  • src/shared/repro-8478-opencode-native-title-icon.test.ts
  • src/shared/terminal-title-agent-type.ts
  • src/shared/opencode-terminal-title.test.ts
  • src/shared/opencode-terminal-title.ts
  • src/shared/terminal-title-agent-type.test.ts

📝 Walkthrough

Walkthrough

Adds native OpenCode terminal-title detection for OC | ... titles with an optional single-token prefix. Agent-label and terminal-title resolution classify these titles as OpenCode before other heuristics. Tests cover accepted and rejected formats, agent resolution, icon mapping, stale Claude signals, and preservation of other classifications. Mobile browser certificate-failure lookup now tolerates missing state, with corresponding test fixtures updated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The browserCertificateFailuresByPageId runtime graph changes appear unrelated to the OpenCode title-detection fix. Remove the unrelated runtime graph/test changes or explain why they are required for #8478.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 is concise and accurately summarizes the main change: recognizing native OpenCode OC | tab titles.
Description check ✅ Passed The description covers the required template sections and includes summary, testing, review, security, screenshots, and notes.
Linked Issues check ✅ Passed The PR addresses #8478 by making native OpenCode OC | titles resolve to the OpenCode icon instead of Claude.
✨ Finishing Touches
📝 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.

@nwparker

Copy link
Copy Markdown
Contributor Author

OpenCode source review

Cloned anomalyco/opencode and checked how titles are actually set.

Source of truth: packages/tui/src/app.tsx (~452–475):

// home
renderer.setTerminalTitle("OpenCode")

// session with default auto title
renderer.setTerminalTitle("OpenCode")

// named session (truncated to 40 chars)
renderer.setTerminalTitle(`OC | ${title}`)

// plugin route
renderer.setTerminalTitle(`OC | ${route.data.id}`)

That’s the full terminal-title surface — no other OSC brand formats, no alternate agent-id sequence. Bare "OpenCode" was already classified via the opencode token; the bug was only the abbreviated OC | … form (no token).

Conclusion: No better approach in their codebase than recognizing start-anchored OC | … (this PR). Upstream could rename to OpenCode | …, but we shouldn’t depend on that. Flexible spacing in the matcher is fine; OpenCode always emits OC | with spaces.

CI fix: dropped the renderer agentTypeToIconAgent import from the shared repro (node typecheck).

nwparker added 3 commits July 16, 2026 19:37
OpenCode's native OSC titles use `OC | <task>` without an `opencode`
token, so title classifiers left tabs as Claude/unknown. Map the native
marker (optional mux prefix) to OpenCode identity in both title
classifiers, exclude it from isClaudeAgent, and cover lookalikes plus
stale Claude launch reclaim.

Builds on and supersedes #8590 (credit @gatsby74). Fixes #8478.
tsconfig.node includes src/shared tests; importing agent-status pulled
renderer modules outside the node project and failed typecheck. Assert
opencode identity via shared title classifiers only (OpenCode TUI sets
"OpenCode" and `OC | ${title}`).
Main's #9104 reads browserCertificateFailuresByPageId in buildMobileBrowserTab
but left partial AppState test helpers without the field, breaking PR Checks
merge commits. Default the map in fixtures and use optional chaining so partial
state cannot throw.
@nwparker
nwparker force-pushed the nwparker/fix-8478-wave3 branch from 7af82a5 to f220479 Compare July 17, 2026 02:37
@nwparker
nwparker merged commit 5ee90c8 into main Jul 17, 2026
1 check passed
@nwparker
nwparker deleted the nwparker/fix-8478-wave3 branch July 17, 2026 02:53
@Indosaram

Copy link
Copy Markdown

This is still not working. My opencode sessions still displayed as Claude Code

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(agents): recognize OpenCode native OC | tab titles

OpenCode's native OSC titles use `OC | <task>` without an `opencode`
token, so title classifiers left tabs as Claude/unknown. Map the native
marker (optional mux prefix) to OpenCode identity in both title
classifiers, exclude it from isClaudeAgent, and cover lookalikes plus
stale Claude launch reclaim.

Builds on and supersedes stablyai#8590 (credit @gatsby74). Fixes stablyai#8478.

* fix(agents): drop renderer import from stablyai#8478 shared repro

tsconfig.node includes src/shared tests; importing agent-status pulled
renderer modules outside the node project and failed typecheck. Assert
opencode identity via shared title classifiers only (OpenCode TUI sets
"OpenCode" and `OC | ${title}`).

* fix(runtime): fill browser cert failure map in mobile snapshot fixtures

Main's stablyai#9104 reads browserCertificateFailuresByPageId in buildMobileBrowserTab
but left partial AppState test helpers without the field, breaking PR Checks
merge commits. Default the map in fixtures and use optional chaining so partial
state cannot throw.
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]: OpenCode logo is not coming up well

2 participants