Skip to content

fix(agents): recognize OpenCode native tab titles - #8590

Closed
mmarabel wants to merge 2 commits into
stablyai:mainfrom
mmarabel:gatsby74/bug-opencode-logo-is-not-coming-up-well
Closed

mmarabel wants to merge 2 commits into
stablyai:mainfrom
mmarabel:gatsby74/bug-opencode-logo-is-not-coming-up-well

Conversation

@mmarabel

@mmarabel mmarabel commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • recognize OpenCode's native OC | … terminal-title format as OpenCode identity
  • preserve recognition when a multiplexer prefixes the native title
  • let current OpenCode title evidence replace stale Claude launch identity in a reused tab

Fixes #8478.

Screenshots

Before: issue screenshot shows the Claude glyph on an OpenCode tab.

After: manually verified in the macOS dev build by emitting OpenCode's native OC | Understand about the plugin OSC title into a terminal with no launch or process identity; the tab rendered the existing OpenCode glyph.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test (29,168 passed, 40 skipped)
  • pnpm build
  • Added regression coverage for native and multiplexer-prefixed OpenCode titles, lookalike rejection, and replacement of stale Claude launch identity

AI Review Report

Reviewed the title-classification and tab-agent precedence paths. CodeRabbit flagged an unanchored false-positive case and native-title precedence when task text names another agent; both were fixed with a start-anchored matcher, negative coverage, and early native-marker resolution in both title classifiers. The matcher is limited to OpenCode's exact uppercase OC | … native marker with an optional single-token multiplexer prefix, so ordinary task text and other agents retain their existing classification. The change performs one bounded regex check per terminal-title classification and does not add polling or hot-path allocation beyond the existing title parse.

Cross-platform review covered macOS, Linux, and Windows. The change is platform-neutral and does not touch shortcuts, shortcut labels, paths, shell quoting, or Electron platform branches. SSH/remote behavior was checked explicitly: multiplexer-prefixed titles are covered, and title evidence remains available where local foreground-process probing is intentionally disabled. Existing Claude, Codex, Pi/OMP, Cursor, Gemini, and custom-agent precedence is unchanged. UI review confirmed that this reuses the existing OpenCode glyph without layout, color, spacing, or theme changes.

Security Audit

Terminal OSC titles are untrusted input. The new handling only applies a fixed, non-backtracking regular expression and maps a match to an existing enum value. It does not render title content as HTML, execute commands, resolve paths, cross IPC/auth boundaries, access credentials, add dependencies, or expose secrets. No follow-up security work is needed.

Notes

Validated on macOS with OpenCode 1.17.19 and a direct native-title probe. The parsing fix is shared by local, SSH, WSL, and mirrored title consumers.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added isOpenCodeNativeTitle to detect uppercase OC | ... session titles, including titles with a pipe-delimited prefix. Re-exported the helper through the shared agent-detection barrel and integrated it into shared and terminal agent-label resolution. Added tests covering OpenCode title variants, lowercase rejection, embedded markers, and replacement of a stale Claude launch identity during tab-agent resolution.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #8478 by detecting OpenCode native titles and restoring the correct OpenCode tab icon on macOS.
Out of Scope Changes check ✅ Passed The diff stays focused on OpenCode title detection and regression tests, with no clear unrelated changes.
Title check ✅ Passed The title is concise and accurately summarizes the main change: recognizing OpenCode native tab titles.
Description check ✅ Passed The description matches the required template and includes summary, screenshots, testing, AI review, security audit, and notes.

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.

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9b1020ce-9bf8-48be-9a61-2b2c2513e144

📥 Commits

Reviewing files that changed from the base of the PR and between 7b3103f and aaeab3e.

📒 Files selected for processing (6)
  • src/renderer/src/lib/use-tab-agent.test.ts
  • src/shared/agent-detection.ts
  • src/shared/agent-title-core.ts
  • src/shared/agent-title-identity.ts
  • src/shared/terminal-title-agent-type.test.ts
  • src/shared/terminal-title-agent-type.ts

Comment thread src/shared/agent-title-core.ts Resolved
Comment thread src/shared/agent-title-identity.ts Resolved
@nwparker

Copy link
Copy Markdown
Contributor

Taking over / superseding this PR with #9102 (same fix direction, rebased on current main).

Credit @gatsby74 — core approach kept: start-anchored native OC | … identity, early classifier priority so task text / other-agent glyphs don’t rebrand the tab, mux prefix, and stale Claude launch reclaim in resolveTabAgentFromSignals.

Deltas on top of this PR:

  • Consolidate matcher into existing src/shared/opencode-terminal-title.ts (display preservation + identity share one predicate; keeps flexible OC|session spacing already covered there)
  • Gate both isClaudeAgent copies so OC | ⠋ … cannot claim Claude
  • Adversarial multi-agent tests + flipped [Bug]: OpenCode logo is not coming up well #8478 repro regression

Please close this PR if you’re good with the takeover — happy to adjust if you prefer co-authoring on #9102 instead.

nwparker added a commit that referenced this pull request Jul 17, 2026
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.
nwparker added a commit that referenced this pull request Jul 17, 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 #8590 (credit @gatsby74). Fixes #8478.

* fix(agents): drop renderer import from #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 #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.
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for this! A maintainer picked up the same fix and rebased it onto main as #9102, crediting you as the original author. Closing this in favor of #9102 so we don't double up — thank you for getting it started 🙏

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

3 participants