Repository navigation
fix(agent-status): status follows a terminal re-homed into a new tab after a restart - #33601
Conversation
…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.
…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.
|
No actionable comments were generated in the recent review.
|
Keep both methods main (stablyai#33601) and this change add to pty-worktree-record.ts, and import rekeyMigrationUnsupportedEntries from agent-status/, where main moved the module (stablyai#33665).
Keep both methods main (stablyai#33601) and this change add to pty-worktree-record.ts, and import rekeyMigrationUnsupportedEntries from agent-status/, where main moved the module (stablyai#33665).
Keep both methods main (stablyai#33601) and this change add to pty-worktree-record.ts, and import rekeyMigrationUnsupportedEntries from agent-status/, where main moved the module (stablyai#33665).
ELI5
An agent's hook knows which Orca pane it belongs to only through the
ORCA_PANE_KEYits shell was started with, and a running process's environment can't change. If Orca restarts while the terminal keeps running and the terminal comes back in a tab with a new id, the agent keeps reporting to the old, dead pane key. The status row with the prompt and session was filed under a tab that no longer exists, and the live tab only had the weaker terminal-title (OSC) status with no prompt or session. Now that status follows the terminal to the pane it is actually in.This is #31841 by @AmoabaKelvin, rebased onto current main. Their two fix commits are kept as-is. Their daemon commit is dropped because #33380 already makes the daemon list each session's spawn
paneKey. One small commit on top switches to that field.Root cause
ORCA_PANE_KEYand lists it aspaneKey(src/main/daemon/terminal-host-session-listing.ts, from fix(terminal): don't resume an agent whose spawned PTY is still live #33380), but nothing in main compared it with the pane the terminal is now shown in.placeUnshownLiveTerminals/ the renderer adoption gate put a surviving terminal whose tab is gone into a new tab (tabId: randomUUID()), so its pane key changes.ORCA_PANE_KEYfrom the env. Main had no alias from the old key to the new pane, unlike a pane move, which callstransferPaneAuthority(src/main/runtime/moved-pane-owner-rekey.ts).What changed
spawnPaneKey) from each inventory.followExportedPaneKeysmoves that key's status to the pane the terminal is now shown in, using the existingtransferPaneAuthority. This is the same persisted alias a pane move uses, and it is cleared when the PTY exits.returnPaneAuthority).Mixed versions: older daemons and orcad don't list
paneKey, so they keep today's behavior. The legacy SSH relay doesn't report it either, so it is unchanged. Mobile and paired clients read the host's per-pane status, so they follow without client changes.How verified
A real repro in an isolated dev Electron (separate userData and HOME), with a real Claude Code 2.1.310 and the PTY daemon kept alive across the restart:
1b248014…), startedclaudeand sent a prompt. The hook row landed on1b248014…:5657a812….d484763d…. Sent "reply with just the word hello". Inlast-status.jsonthe hook row (prompt "hello") was filed under the dead key1b248014…. The live paned484763d…had only anorigin: oscrow withprompt: "". The renderer store andorca worktree psshowed only that OSC row.d484763d…. A new prompt ("live") from the same Claude process, which still hasORCA_PANE_KEY=1b248014…(checked withps eww), landed ond484763d…as anorigin: hookrow with the prompt, inlast-status.json, the renderer store andorca worktree ps.Tests:
src/main/runtime/exported-pane-key-follow.test.ts(from #31841) drives the real runtime and hook server.pnpm test src/main/runtime src/main/providers src/main/agent-hooks src/main/daemon/terminal-host.test.tspasses, andpnpm tc:nodeandcheck:code-quality:changedare clean.Risk
Fixes #23753
Supersedes #31841
Co-authored-by: Kelvin Amoaba 97001695+AmoabaKelvin@users.noreply.github.com