Repository navigation
fix(agent-status): let a pane's owner reclaim it from a nested agent's hooks - #33572
Conversation
…s hooks A nested agent (e.g. a background `claude -p` or Pi runtime started by the pane's agent) inherits ORCA_PANE_KEY. If it posts while the owner is idle it is admitted, and its fresh row then made the owner's own next hooks look inherited, so they were dropped until the child went done or stale (#30589). The hook server already records the pane's owner in agentPresence and keeps it through nested hooks; resolveAgentStatusIdentity now admits a hook from that owner over a fresh row of another agent. Main forwards the owner to the renderer as paneOwnerAgent so its guards agree; the IPC applicator's guard moves into agent-status-routing to stay under the file-size limit.
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f5c01a22-de59-4064-8d21-4f2852ec81d9
Files selected for processing: 10-
src/main/agent-hooks/server-nested-agent-roster.test.tssrc/main/startup/main-window-agent-status.tssrc/renderer/src/hooks/ipc-events/agent-status-event-applicator.tssrc/renderer/src/hooks/ipc-events/agent-status-routing.tssrc/renderer/src/hooks/ipc-events/normalize-agent-status-event.tssrc/renderer/src/store/slices/agent-status-contract.tssrc/renderer/src/store/slices/agent-status-live-entry-builder.tssrc/renderer/src/store/slices/agent-status-pane-owner-reclaim.test.tssrc/shared/agent-status-identity.tssrc/shared/agent-status-ipc-payload.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
-
A recorded owner type can outlive the owner (relay re-sends presence; local exits can be missed), so a nested codex exec matching only the type could take the row. Record the claiming provider session in agentPresence and allow the reclaim only for that session; without a recorded session keep prior behavior.
…ion on same-process hooks
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Minor · Align the session length limits before storing… · agent-hook-presence-transition.ts:53-60
src/shared/agent-hook-presence-transition.ts:53-60
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winAlign the session length limits before storing
agentPresence.session.Provider session IDs allow up to 512 characters, but presence deserialization accepts only 256 characters. A valid 257–512-character session stored here is dropped at the relay/main boundary. The owner’s later hook then cannot match the recorded session and cannot reclaim the pane. Use one shared validation limit for both fields. (raw.githubusercontent.com)

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ad0bad83-bd11-4a7b-b76a-b937106ec23c
Files selected for processing: 2-
src/renderer/src/store/slices/agent-status-pane-owner-reclaim.test.tssrc/shared/agent-hook-presence-transition.ts
Files skipped from review as they are similar to previous changes: 1-
- src/renderer/src/store/slices/agent-status-pane-owner-reclaim.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
ELI5
If the agent in a pane starts another agent that keeps running in the background (a
claude -pjob, or a Pi-based runtime), the child gets the pane's Orca environment, so its hooks report as that pane. When the child posted while the pane's own agent was idle, Orca relabeled the pane to the child. The real bug came after that: the owner's own next hooks were treated as "nested" and dropped, so the pane stayed on the wrong agent until the child finished or its row went stale (up to 30 minutes). With this change the pane's owner takes the pane back on its next hook.Root cause
agentPresencecomes from the first hook and is kept unchanged through nested hooks (transitionHookPresence,src/shared/agent-hook-presence-transition.ts: "nested agents' hooks update status, never ownership").resolveAgentStatusIdentity(src/shared/agent-status-identity.ts) suppresses a hook from a different agent while the existing row is fresh and not done (isActiveExistingIdentity). If the existing row was the child's, that check suppressed the owner itself. [Bug]: A nested Pi-compatible runtime that inherits ORCA_PANE_KEY can claim a Claude Code pane and then suppress the legitimate Claude hook #30589 shows this exact record:source: "pi",agentPresence: { agent: "claude" }.hasOtherAgentProcessOwner, Keep idle Claude sessions selected during nested Codex work #29386) only exists for Claude on macOS/Linux. Codex, Pi, OpenCode, and Windows Claude owners have presence without a process, so nothing protected them.What changed
transitionHookPresencenow also records the provider session that claimed the pane (agentPresence.session). The relay forwards it, and main reads it back throughreadAgentProcessPresence.resolveAgentStatusIdentity: a hook from the pane's recorded owner session (same agent and same session id, not ended, no conflicting process owner) is accepted over a fresh row from another agent. Matching the agent type alone is not enough, because a recorded owner can outlive the real one (the relay re-sends presence, and local exits can be missed); a nestedcodex execor Pi child always has a new session id. If no session was recorded (older hosts/relays), main's existing behavior applies.paneOwner: {agent, session}onagentStatus:set. The renderer's two copies of the guard (IPC applicator and live-entry builder) pass it through so they reach the same verdict as main. The applicator's guard moves intoagent-status-routing.tsbecause the applicator is at the 300-line limit.Reproduction (real CLIs, isolated HOME/CLAUDE_CONFIG_DIR/CODEX_HOME, fake Anthropic and OpenAI servers, no spend)
Real
claude2.1.310 andcodex0.164.0 ran Orca's generatedclaude-hook.sh/codex-hook.sh(plus Codex hook trust) and posted to a realAgentHookServer:codex exec: the nested Codex posted SessionStart/UserPromptSubmit/Stop, and all of them were rejected. The pane stayed Claude. Already fixed on main (Keep idle Claude sessions selected during nested Codex work #29386 process owner).claude -p: the nested Claude posted SessionStart/UserPromptSubmit/Stop/SessionEnd, and all of them were rejected. The pane stayed Codex. Already fixed on main (fix(agent-status): stop nested reviews from collapsing Claude children #29264).claude -pjob runs in the background in the same pane, then Codex runs another turn:claude working "nested slow", and Codex's whole second turn (SessionStart/UserPromptSubmit/Stop) was dropped. The row heldagentType: claudewithagentPresence: {agent: codex}, the same shape as [Bug]: A nested Pi-compatible runtime that inherits ORCA_PANE_KEY can claim a Claude Code pane and then suppress the legitimate Claude hook #30589.codex exec resume <id>, matching a TUI's next turn) comes through (codex done "second turn").session_id: sess.session_id()on every turn of a session (codex-rs/core/src/hook_runtime.rs:157and other call sites). Pi and OpenCode report their session id, which stays the same across turns until/new. Known gap: a brand-new Pi session only reports its id after the first message (Pi creates the session file then), so a Pi owner recorded before that has no session and keeps main's behavior; resumed Pi sessions and OMP are covered.Verification
codex exec) failed on the previous head. Both pass now. New renderer store test covers the builder guard with and withoutpaneOwnerAgent.pnpm tc,check:code-quality:changed, and the agent-hooks/shared/renderer agent-status/sidebar/runtime suites (~45k tests) pass.Risk / trade-offs
lets a new agent claim the pane with its model once the parent turn is done). The pane is now corrected on the owner's next hook instead of staying wrong./new,/clear) and a child then holds the row, the owner's hooks are dropped until the child finishes, same as on main.Fixes #30589
Refs #13341 #22011
Credit: Emaj77 for the root-cause analysis in #30589. phillipLoacker, xxuxinn and pobbye-star for the nested
codex exechook traces in #13341. mmarabel (#22800), OrcaWin (#14012) and mrcha033 (#13385) for earlier nested-identity work that this supersedes.