Skip to content

fix(tabs): trust native OpenCode titles without hook signals - #11382

Merged
Jinwoo-H merged 4 commits into
stablyai:mainfrom
bbingz:fix/opencode-tab-icon
Jul 30, 2026
Merged

Jinwoo-H merged 4 commits into
stablyai:mainfrom
bbingz:fix/opencode-tab-icon

Conversation

@bbingz

@bbingz bbingz commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Treat the exact native OpenCode OC | title as direct runtime identity evidence.
  • Let it replace stale Claude launch metadata when hooks and foreground-process signals are unavailable.
  • Preserve launch-intent precedence for ordinary conflicting titles.

This closes the remaining integration gap after #9102.

Fixes #11329

Screenshots

No visual layout change. The visible result is that the existing OpenCode icon replaces the incorrect Claude icon for affected tabs.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

Focused checks:

  • 96 tests passed across tab identity, process signals, sleeping sessions, Pi/OMP identity, native OpenCode titles, and pane ownership.
  • pnpm run check:code-quality:changed
  • pnpm run check:max-lines-ratchet
  • git diff --check

AI Review Report

Reviewed the title, launch metadata, hook, process, sleeping-session, split-pane, and remote precedence chain. Greptile rated the change 5/5 and CodeRabbit generated no actionable code comments. Cross-platform review confirmed the change is title-classification only and does not alter shortcuts, paths, shells, or Electron platform branches on macOS, Linux, or Windows.

Security Audit

No command execution, path handling, IPC, auth, secrets, dependencies, or persisted data changed. The native title matcher already existed; this PR only uses its exact high-confidence result in the identity resolver.

Notes

The exact native OpenCode marker is the only new no-hook override. Ordinary conflicting titles still wait for observed activity, preserving the existing launch-window anti-flicker behavior.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR closes the remaining integration gap for native OpenCode tab identity. When a tab carries a stale Claude launchAgent but its terminal title matches the exact OC | <task> native OpenCode pattern, the resolver now promotes OpenCode identity immediately — without waiting for an observed hook signal. Sleeping session records are simultaneously promoted to suppress title-based reclaims entirely, preventing an in-flight title from displacing durable provider-session ownership.

  • use-tab-agent.ts: Adds nativeOpenCodeTitle flag, gates titleReclaimsReusedPane on it, and adds sleepingSessionAgent as an early-exit condition that nulls titleAgent before the reclaim logic runs.
  • Precedence behavior shift: sleepingSessionAgent now suppresses titleAgent in all cases; the sleeping-session test expectation is updated from 'claude' to 'gemini' to match.
  • New test file: 8 scenarios covering live-local, inactive-split, SSH/tmux, persisted-tab reclaim, sleeping-session guard, completed-hook guard, lookalike rejection, and a mounted-component integration test.

Confidence Score: 5/5

Safe to merge — the change is limited to title-classification logic in a pure function and is thoroughly covered by 96 tests, including a new dedicated test file for every edge case introduced.

The two functional changes are tightly scoped: the nativeOpenCodeTitle short-circuit fires only for the exact OC | … format via an already-tested regex, and the sleepingSessionAgent suppression of titleAgent is deliberately consistent with the upgraded durable ownership semantics. No hook lifecycle, PTY management, shell detection, or IPC paths are touched. The one test whose expectation flipped correctly tracks the intentional behavior change.

Files Needing Attention: No files require special attention. The sleeping-session test expectation flip is the most semantically significant change and is already well-documented by the renamed test description.

Important Files Changed

Filename Overview
src/renderer/src/lib/use-tab-agent.ts Core logic change: adds nativeOpenCodeTitle flag that lets native OC
src/renderer/src/lib/use-tab-agent-opencode-native-title.test.ts New test file with 8 focused scenarios covering the native OpenCode title path: live local, inactive split, SSH/tmux, stale persisted tab, sleeping-session durable ownership, completed-hook precedence, and lookalike rejection.
src/renderer/src/lib/use-tab-agent-sleeping-session.test.ts One test expectation flipped from 'claude' to 'gemini' to reflect the new behavior where a sleeping session suppresses title-based identity reclaims.
src/renderer/src/lib/use-tab-agent.test.ts One fixture changed from hasObservedAgentSignal: true to false to correctly validate the new no-signal reclaim path for native OpenCode titles.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[resolveTabAgentFromSignals] --> B{liveFocusedIdentity?}
    B -- yes --> Z[return liveFocusedIdentity]
    B -- no --> C{processAgent?}
    C -- yes --> Z2[return processAgent]
    C -- no --> D[Compute titleAgent]
    D --> D1{processProvesShell OR sleepingSessionAgent OR nativeOCTitle AND idleFocusedIdentity?}
    D1 -- yes --> D2[titleAgent = null]
    D1 -- no --> D3{titleReclaimsReusedPane?}
    D3 -- yes --> D4[titleAgent = explicitTitleAgent]
    D3 -- no --> D5{priorIdentity?}
    D5 -- yes --> D6[titleAgent = null]
    D5 -- no --> D7[titleAgent = explicitTitleAgent]
    D2 & D4 & D6 & D7 --> E{titleAgent?}
    E -- yes --> Z3[return titleAgent]
    E -- no --> F{idleFocusedIdentity?}
    F -- yes --> Z4[return idleFocusedIdentity]
    F -- no --> G{sleepingSessionAgent?}
    G -- yes --> Z5[return sleepingSessionAgent]
    G -- no --> H{activeLaunchAgent?}
    H -- yes --> Z6[return activeLaunchAgent]
    H -- no --> I[return sibling identity]
Loading

Reviews (2): Last reviewed commit: "fix(tabs): preserve completed hook autho..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OpenCode-native title detection is now included in tab-agent identity resolution. The resolver can identify opencode when no agent signal has been observed, including tabs with stale Claude launch metadata, without clearing that metadata. Tests cover both direct signal resolution and the useTabAgent behavior.

🚥 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 code change matches #11329 by using native OpenCode titles to correct the tab icon when stale Claude metadata exists.
Out of Scope Changes check ✅ Passed The diff stays focused on tab-agent identity logic and its tests, with no unrelated code changes visible.
Title check ✅ Passed The title clearly and concisely summarizes the main change: trusting native OpenCode titles when hook signals are absent.
Description check ✅ Passed The description follows the required template with Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes sections.

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.

@Jinwoo-H
Jinwoo-H force-pushed the fix/opencode-tab-icon branch from 05393a0 to 76c8e64 Compare July 30, 2026 02:15
@Jinwoo-H
Jinwoo-H merged commit bd9653c into stablyai:main Jul 30, 2026
41 checks passed
@bbingz
bbingz deleted the fix/opencode-tab-icon branch August 1, 2026 00:47
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…i#11382)

* fix(tabs): trust native OpenCode titles

* test(tabs): cover native OpenCode identity authority

* fix(tabs): preserve sleeping provider identity

* fix(tabs): preserve completed hook authority

---------

Co-authored-by: OrcaWin <[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]: Bug]: Wrong tab icon — OpenCode tab shows Claude icon instead of OpenCode icon

4 participants