You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agents): keep OpenCode identity through Claude hooks - #13385
Keep an OpenCode pane identified as OpenCode when its exact live local foreground process and explicit native OC | ... title agree, even if Claude-compatible tooling posts an inherited Claude hook for the same pane.
Resolve the identity before main-process retention so renderer replay, sidebar/tab status, worktree.ps, headless, and mobile consumers receive the same corrected agent, while incompatible Claude session/model/tool metadata is removed.
Preserve hook precedence for shell foreground, missing or mismatched process evidence, launch-only hints, SSH panes, and remote-runtime PTYs; preserve launch-owner normalization for Pi/oh-my-pi and similar wrappers.
Suppress inherited child completion/provider-only events so a nested Claude-compatible hook cannot complete or attach a Claude session to the active OpenCode turn.
Related context: #8940, #12466, and the nested-hook precedence established in #3990. This fixes the residual inherited Claude-compatible hook path rather than the already-fixed generic title path.
Screenshots
No visual layout change. A fresh headed Electron run on the rebased commit verified that the tab and sidebar remain OpenCode after a real Claude-form hook reaches a renderer-created OpenCode PTY.
Testing
pnpm lint
pnpm typecheck (node, CLI, and web typechecks run through pnpm run build:desktop)
pnpm test (the pre-rebase identical patch ran 48,668 passing and 155 skipped tests with 6 unrelated baseline/environment failures; focused affected tests were rerun after rebase and GitHub CI owns the new full-suite run)
pnpm build (pnpm run build:desktop)
Added or updated high-quality tests that would catch regressions, or explained why tests were not needed
Exact-SHA validation on rebased commit f54840c939998f38437e4d7aaa0e3980352ee43c:
independent QA matrix: 1,452 passed, 1 skipped across 17 files
core identity/runtime selection: 1,100 passed, 1 skipped across 4 files under Node 24
rebase-adjacent Prime Agent/process-recognition and canonical PTY hydration suites: 35/35 passed
lint, reliability, type-aware, max-lines, skill, and localization gates: passed
desktop build and node/CLI/web typechecks: passed
git diff --check: clean
fresh headed Electron QA: renderer store, main worktree.ps, tab, and sidebar all stayed OpenCode; Claude model/provider metadata was absent
The regression matrix covers local positive identity correction, exact launch-token/live-PTY binding, stale launch hints, shell return, process/title mismatch, first inherited Stop, inactive split-pane titles, SSH, remote-runtime PTYs, replay/remote ingestion, metadata filtering, Pi/oh-my-pi owner normalization, Prime Agent coexistence, and canonical PTY hydration.
AI Review Report
Five independent review lanes plus a debugging runtime audit reviewed exact rebased SHA f54840c939998f38437e4d7aaa0e3980352ee43c: goal verification, code quality, security, history/context, and QA all passed with no blockers. An earlier review found that connection IDs alone did not identify remote-runtime PTYs; the final patch adds an addressed-PTY remote-runtime guard and negative regression. Every lane was rerun after the main rebase.
The review explicitly checked macOS, Linux, and Windows compatibility. This PR changes no shortcuts, labels, filesystem paths, shell commands, or platform-specific process APIs; it uses the existing cross-platform PTY controller and shared agent/title normalization. It also checked local, SSH, and remote-runtime routing; supported-agent wrapper ownership; Prime Agent coexistence; canonical PTY hydration; split-pane behavior; main/renderer/headless/mobile consistency; performance; and UI quality. The only new process query is bounded and occurs only for a conflicting non-replay local hook without an already-protected parent identity.
Security Audit
The correction is classification, not authorization. Main-process corroboration requires the runtime-owned local hook endpoint, exact nonempty launch token, exact pane/leaf/tab/worktree binding, a connected local PTY, the current controller, and a bounded foreground-process result; those bindings are rechecked after the async probe. Replay and remote ingestion bypass the resolver, and renderer fallback excludes SSH and remote-runtime PTYs.
No dependency, wire contract, IPC surface, command execution, filesystem path, credential, or secret-handling change was introduced. Conflicting Claude provider-session/transcript/model/tool/subagent metadata is stripped before persistence and publication. Residual low risk: a process and title are controlled by the same local user and can spoof presentation classification, but no reviewed authorization consumer trusts this identity.
Notes
Rebasing onto upstream bf406720a059029cadaaeb56c79e6b8cc49d5dec preserved the stable patch ID exactly. Six later upstream commits contain four IME/key-remap changes, a release marker, and manual artifact sharing. The artifact commit adds unrelated imports and service methods in orca-runtime.ts, far from the PTY identity resolver; git merge-tree confirms the current PR and live main integrate without conflict.
Linux hosted manual QA was completed; platform-neutral controller behavior and macOS/Linux/Windows non-regression were reviewed statically and through mocked controller tests.
Repro data from 1.4.182 (stable), in case it helps validate this: the mismatch also occurs on panes that were started with OpenCode from the beginning, not only after switching a workspace's agent.
On one machine, same moment in time:
Source
Reports
orca worktree ps --json → agents[].agentType
claude=17, opencode=1
orca-data.json → worktreeMeta[].createdWithAgent
opencode=9, claude=1
actual running processes
opencode=9, claude=2
session-parse-cache.json → session.agent
opencode for those same panes
So worktree ps reported claude for 7 of 9 live panes whose transcript, recorded resumeCommand (cd '<path>' && opencode --session 'ses_...'), and OS process were all OpenCode.
User-visible consequence is resume: the pane is labelled claude, so an OpenCode session id gets resumed with the Claude CLI and is not found. Matches #8940, and #12466 did not cover this path (no stray literal "claude" in the title — these are native OC | ... titles with an inherited Claude hook, exactly as this PR describes).
Thanks for the investigation! Nested-agent identity is now handled on main by the nested-hook guards in #29264 and #29386 plus #33572 (the pane's owner reclaims the pane by session). Closing as superseded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OC | ...title agree, even if Claude-compatible tooling posts an inherited Claude hook for the same pane.worktree.ps, headless, and mobile consumers receive the same corrected agent, while incompatible Claude session/model/tool metadata is removed.Related context: #8940, #12466, and the nested-hook precedence established in #3990. This fixes the residual inherited Claude-compatible hook path rather than the already-fixed generic title path.
Screenshots
No visual layout change. A fresh headed Electron run on the rebased commit verified that the tab and sidebar remain OpenCode after a real Claude-form hook reaches a renderer-created OpenCode PTY.
Testing
pnpm lintpnpm typecheck(node, CLI, and web typechecks run throughpnpm run build:desktop)pnpm test(the pre-rebase identical patch ran 48,668 passing and 155 skipped tests with 6 unrelated baseline/environment failures; focused affected tests were rerun after rebase and GitHub CI owns the new full-suite run)pnpm build(pnpm run build:desktop)Exact-SHA validation on rebased commit
f54840c939998f38437e4d7aaa0e3980352ee43c:git diff --check: cleanworktree.ps, tab, and sidebar all stayed OpenCode; Claude model/provider metadata was absentThe regression matrix covers local positive identity correction, exact launch-token/live-PTY binding, stale launch hints, shell return, process/title mismatch, first inherited
Stop, inactive split-pane titles, SSH, remote-runtime PTYs, replay/remote ingestion, metadata filtering, Pi/oh-my-pi owner normalization, Prime Agent coexistence, and canonical PTY hydration.AI Review Report
Five independent review lanes plus a debugging runtime audit reviewed exact rebased SHA
f54840c939998f38437e4d7aaa0e3980352ee43c: goal verification, code quality, security, history/context, and QA all passed with no blockers. An earlier review found that connection IDs alone did not identify remote-runtime PTYs; the final patch adds an addressed-PTY remote-runtime guard and negative regression. Every lane was rerun after the main rebase.The review explicitly checked macOS, Linux, and Windows compatibility. This PR changes no shortcuts, labels, filesystem paths, shell commands, or platform-specific process APIs; it uses the existing cross-platform PTY controller and shared agent/title normalization. It also checked local, SSH, and remote-runtime routing; supported-agent wrapper ownership; Prime Agent coexistence; canonical PTY hydration; split-pane behavior; main/renderer/headless/mobile consistency; performance; and UI quality. The only new process query is bounded and occurs only for a conflicting non-replay local hook without an already-protected parent identity.
Security Audit
The correction is classification, not authorization. Main-process corroboration requires the runtime-owned local hook endpoint, exact nonempty launch token, exact pane/leaf/tab/worktree binding, a connected local PTY, the current controller, and a bounded foreground-process result; those bindings are rechecked after the async probe. Replay and remote ingestion bypass the resolver, and renderer fallback excludes SSH and remote-runtime PTYs.
No dependency, wire contract, IPC surface, command execution, filesystem path, credential, or secret-handling change was introduced. Conflicting Claude provider-session/transcript/model/tool/subagent metadata is stripped before persistence and publication. Residual low risk: a process and title are controlled by the same local user and can spoof presentation classification, but no reviewed authorization consumer trusts this identity.
Notes
bf406720a059029cadaaeb56c79e6b8cc49d5decpreserved the stable patch ID exactly. Six later upstream commits contain four IME/key-remap changes, a release marker, and manual artifact sharing. The artifact commit adds unrelated imports and service methods inorca-runtime.ts, far from the PTY identity resolver;git merge-treeconfirms the current PR and livemainintegrate without conflict.