Repository navigation
fix(agent-status): show agent status on a terminal that comes back in a new tab after a restart - #31841
fix(agent-status): show agent status on a terminal that comes back in a new tab after a restart#31841AmoabaKelvin wants to merge 3 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e0e2f8c4-20f4-47d8-968b-7892935182c2
📒 Files selected for processing: 35
config/main-layout-writer-baseline.txtsrc/main/agent-hooks/server/server-authority-aliases.tssrc/main/daemon/daemon-pty-session-inventory.tssrc/main/daemon/session-options.tssrc/main/daemon/session.tssrc/main/daemon/terminal-host-env-pane-key-listing.test.tssrc/main/daemon/terminal-host-session-create.tssrc/main/daemon/terminal-host-session-listing.tssrc/main/daemon/types.tssrc/main/ipc/pty/delivery/attached-pty-size.tssrc/main/ipc/pty/ipc/spawn-commit-persist.tssrc/main/ipc/pty/ipc/spawn-commit.tssrc/main/ipc/pty/ipc/spawn-options.tssrc/main/ipc/pty/pane/key-state.tssrc/main/ipc/pty/pane/stable-owner.tssrc/main/ipc/pty/runtime/spawn-commit-pty-size.tssrc/main/ipc/pty/runtime/spawn-commit-response.tssrc/main/ipc/pty/runtime/spawn-commit.tssrc/main/ipc/pty/spawn-commit-assembly.tssrc/main/ipc/pty/spawn-commit-binding.tssrc/main/ipc/pty/spawn-commit-publication.tssrc/main/ipc/pty/spawn-host-env.tssrc/main/ipc/pty/spawn-options-assembly.tssrc/main/providers/pty-process-info.tssrc/main/providers/pty-process-list-admission.tssrc/main/runtime/exported-pane-key-follow.test.tssrc/main/runtime/rpc/methods/agent-launch-instant-tab.test.tssrc/main/runtime/runtime-terminal-state-records.tssrc/main/runtime/session-graph/session-graph-promotion.tssrc/main/runtime/session-graph/session-window-graph.tssrc/main/runtime/terminal/adoption/adopt-terminal-orphans-from-inventory.tssrc/main/runtime/terminal/identity/exported-pane-key-follow.tssrc/main/runtime/terminal/identity/pty-worktree-record.tssrc/main/runtime/terminal/lifecycle/pty-controller-inventory-refresh.tssrc/main/runtime/workspaces/persisted-surfaces/restored-terminal-placement.ts
💤 Files with no reviewable changes: 2
- src/main/ipc/pty/runtime/spawn-commit-pty-size.ts
- src/main/ipc/pty/ipc/spawn-commit-persist.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
964f955 to
41f84ce
Compare
…after a restart A surviving terminal's hooks keep posting the ORCA_PANE_KEY its env exported, but after a relaunch nothing in main knew that key once the terminal came back in a newly minted tab. The terminal host now reports the key it exported, and when main records the terminal in a different pane it moves that key's status with the existing transferPaneAuthority, as a pane move does.
41f84ce to
4acba1d
Compare
There was a problem hiding this comment.
Actionable comments posted: 2

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:
81a9d0c2-cf62-435b-9c8a-3d9904f67cc7
Files selected for processing: 16-
src/main/agent-hooks/server/server-authority-aliases.tssrc/main/daemon/daemon-pty-session-inventory.tssrc/main/daemon/session.tssrc/main/daemon/terminal-host-session-create.tssrc/main/daemon/terminal-host-session-listing.tssrc/main/daemon/types.tssrc/main/providers/pty-process-info.tssrc/main/providers/pty-process-list-admission.tssrc/main/runtime/runtime-terminal-state-records.tssrc/main/runtime/session-graph/session-graph-promotion.tssrc/main/runtime/session-graph/session-window-graph.tssrc/main/runtime/terminal/adoption/adopt-terminal-orphans-from-inventory.tssrc/main/runtime/terminal/identity/exported-pane-key-follow.tssrc/main/runtime/terminal/identity/pty-worktree-record.tssrc/main/runtime/terminal/lifecycle/pty-controller-inventory-refresh.tssrc/main/runtime/workspaces/persisted-surfaces/restored-terminal-placement.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
…biguous Status moved off a terminal's exported pane key now goes back under that key when another live terminal also exported or shows either key, or when the terminal is shown in its exported pane again. A move also needs its destination to be unambiguous.
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 · Clear aliases when pruning a certified PTY. · exported-pane-key-follow.ts:35-39
src/main/runtime/terminal/identity/exported-pane-key-follow.ts:35-39
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winClear aliases when pruning a certified PTY.
dropDisconnectedPtyRecordcan remove a certified PTY without clearing its pane-key alias. If PTY1 leavesA → B, a later PTY2 can exportAwhile appearing atC.followExportedPaneKeysthen callstransferPaneAuthority(A, C, PTY2). The PTY mismatch makesgetPhysicalPaneKeyForAuthorityfall back toA, butresolvePaneKeyAlias(A)still returnsB.transferPaneAuthoritytherefore moves the cached status fromBtoC, and PTY2 inherits PTY1’s status.Clear the certified PTY’s pane-key aliases before deleting its runtime record. The existing
canTransferPaneAuthoritycheck does not protect this path becausefollowExportedPaneKeyscallstransferPaneAuthoritydirectly, andtransferPaneAuthoritydoes not invoke that check.

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:
a31c7450-1c69-4d08-b795-8c3505e4f215
Files selected for processing: 3-
src/main/agent-hooks/server/server-authority-aliases.tssrc/main/runtime/exported-pane-key-follow.test.tssrc/main/runtime/terminal/identity/exported-pane-key-follow.ts
Files skipped from review as they are similar to previous changes: 3-
- src/main/runtime/terminal/identity/exported-pane-key-follow.ts
- src/main/agent-hooks/server/server-authority-aliases.ts
- src/main/runtime/exported-pane-key-follow.test.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.
-
…after a restart (#33601) After an Orca restart with the PTY daemon alive, a surviving terminal placed in a different pane than its spawn ORCA_PANE_KEY now carries that key's agent status (prompt, session) to the live pane, using the daemon-reported spawn key and the manual pane-move mechanism; ambiguous keys (claimed by more than one live terminal) are left alone. Fixes #23753 Supersedes #31841 Co-authored-by: Kelvin Amoaba <[email protected]>
What users saw
A terminal that survives an Orca quit and relaunch can come back in a tab with a new id (the renderer no longer had its recorded tab). Agent hooks from that shell still post the old
ORCA_PANE_KEY, so Orca filed their status under a tab that no longer exists:orca worktree pslisted the agent under the dead pane key;claude --resumein the same tab did not help, because the new process inherits the same env.Now the status shows on the tab the terminal is in, and later hooks from that shell (including a
claude --resumethere) land on it too.Root cause
Hooks identify themselves only by the pane key their env exported at spawn, and a running shell's env can't change. After a relaunch, nothing in main knew which key a surviving terminal had exported: main's only per-terminal record of it was in memory, and the terminal host's session list didn't carry it. So when the terminal was shown in a newly minted tab, nothing told the hook server to move that key's status, the way a pane move or detach does with
transferPaneAuthority.Fix
ORCA_PANE_KEYfrom its spawn env (a reattach never re-exports it) and lists it as an optionalenvPaneKey, next to theterminalHandleit already lists. The same host code runs for the desktop, headlessorca serve, WSL and orcad on SSH hosts.transferPaneAuthority. That is the same move a pane detach does, and the same persisted alias, cleared when the terminal exits.Desktop, the sidebar,
orca worktree psand mobile all read the host's per-pane status, so they follow without client changes.Mixed versions: the field is optional. A daemon or orcad that predates it (an old daemon keeps running after an app update) lists nothing, and status stays where it lands today. An older app ignores the field. Not covered: the legacy SSH relay (the released
relay.jscan't be changed) and the in-process fallback provider used when the daemon fails to start (its terminals die with the app, so they can't survive a restart).Verification
src/main/runtime/exported-pane-key-follow.test.tsdrives the real runtime and hook server through inventory and graph sync: the row filed under the old key moves to the new tab and later posts land there; an older host without the field keeps today's behaviour; a key another live terminal shows or also exported is left alone; a move made before a second terminal was known is undone with its status; a destination another terminal exported is refused; and a terminal shown in its exported pane again gets its status back. With the move removed the first case fails; with the guard removed the third fails; the last three each failed before the follow-up commit.src/main/daemon/terminal-host-env-pane-key-listing.test.ts: the daemon lists the spawn-time key after a reattach from another pane, and fails without the change.check:code-quality:changed,check:react-doctor:changedandpnpm tc:nodeare clean.Visual Proof
N/A: I couldn't reach the bug's trigger in a real app without hand-editing saved state. The trigger is a surviving terminal whose tab the renderer no longer has after a relaunch. In a hidden dev build I opened a tab, started a delayed hook from its shell and force-quit Orca within a second. The tab was already saved, so it came back under its own id, and the hook landed on it as usual (no change from main). #24458 also found no natural path that loses the tab. The runtime test above drives the restart sequence through the real runtime and hook server instead.
Fixes #23753