Repository navigation
Conversation
When an agent Orca launched exits, the pane's command-finished retirement wiped every row on the pane: the row of an agent the launch had already handed the pane to (a detached Codex promoted after Claude crashed), and the launch's own resume remnant. endLaunchAuthority keeps a row whose owner is a different agent than the launch, without fencing its later events, and keeps the resume remnant; the launch's own live row is wiped and fenced as before.
endLaunchAuthority no longer wipes and re-admits rows. When the launch still owns the pane, its command ending ends that ownership through the owner rule's exit path (ended resume remnant, then the guest held behind it takes the pane), so the handover works whichever of the exit check and the command-finished signal arrives first. A remnant or an owner the launch already handed the pane to is left in place; only the launch's token and restored authority are revoked. A pane with no owner record is reset as before.
An ended owner record now admits a same-type event only when it starts a new turn (the isNewTurnEvent set the retirement fence used); a matching process stays blocked. This keeps base's suppression of a launched agent's late hooks without a pane fence, including for agents that report no process.
…split launch end from PTY exit The ended-owner rule now drops only the ended process's hooks, or a same-type process-less hook that does not start a new run (the retired-pane gate's own predicate, startsNewAgentRun). Command finish ends the launch; PTY exit keeps retirement. Relayed rows and an unknown launch agent only lose launch authority. An owner with no session to resume is fenced as before.
… launch command finishes Main and the relay now apply one rule, ownerEndedByLaunch, to the panes each executes: a launched agent command finishing ends its owner when that owner is the launched agent, whether or not its process can be checked. The relay tracks the launch per PTY and clears it on the first command finish, as main's receipt does; its presence check and launch end share one owner-exit write.
…esets as before WSL rows are this machine's (isLocalHookConnectionId, shared with worktree cleanup), so their launch ends here. A launch maps to the agent its hooks name (claude-agent-teams and OpenClaude report claude). A restored PTY whose launch agent is unknown resets the pane as before. One main owner-exit helper, endPaneOwner; opencode2 prompt MessageParts start a new run.
hookAgent is an optional catalog field (claude-agent-teams and OpenClaude name claude), read through getTuiAgentHookAgent; the separate map is gone.
Ending a launch drops its current authority and records its token hash for the pane; a later event carrying that token (a late hook, or a new run in the same shell) is applied without it, as the old retirement's restart did. The hook agent map moves back out of the catalog into tui-agent-hook-agent.ts.
8 of 9 tasks
…ce is minted toAuthorityEvidence refuses a pane's ended launch token, so no path records or persists it; the tmux path now publishes the event recordCurrentAuthorityObservation returns, and pane-authority transfer moves the fence with the other maps.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ELI5
When an agent that Orca started in a terminal exits, Orca resets that terminal's status. Until now the reset deleted everything on the pane: the status of an agent that had just taken the pane over, and the record Orca uses to resume the exited agent. Now Orca treats the command ending as that agent's exit, the same way it treats a confirmed process exit. The pane keeps the exited agent's resume record and passes to the agent waiting behind it.
What Changed
Before:
/exit). Orca briefly keeps a resume record for that Claude session, then deletes it about 2 seconds later when the process ends.After:
Mechanism: the machine that runs the pane decides: the desktop for local panes, the relay for SSH panes. Both use one shared rule,
ownerEndedByLaunch: when the launched command finishes, the pane's owner ends if it is the launched agent, whether or not its process can be checked.On the desktop: when a launched agent's command finishes, the runtime now calls
endLaunchAuthority(paneKey, launchAgent)instead ofretirePaneAuthority. PTY exit keepsretirePaneAuthority; the two have separate runtime entry points.endLaunchAuthorityreads the pane's current owner (theagentPresencerecord from #26408):PaneOwnerProbes.ownerEnded, also used by the process check).claude(getTuiAgentHookAgent).isLocalHookConnectionId, now shared with worktree cleanup.RelayAgentHookServer.endLaunch. It ends the owner through the same exit write the relay's process check uses (now one function,endRelayPaneOwner), then replays the guest held behind it. The process check still runs on every command finish.startsNewAgentRun, one function now shared with the old reset's fence (including the promptMessagePartof OpenCode, OpenCode 2 and mimo-code). Any other type, or a different process, is admitted.retirePaneAuthority, which is unchanged for pane, tab and worktree close.Why
The command ending is evidence that the launched agent is gone, which is exactly what the owner rule's exit path handles. Routing it there makes the order of signals irrelevant and removes the delete-then-re-add of the resume record from the first version of this PR.
Alternatives considered:
Why only launched commands, and not any command that finishes: a pane where the user typed an agent was never reset before. Ending on any command finish would be worse than before in two cases. After Ctrl-Z, the agent's events would be dropped once
fgresumes it. An agent started with&would be ended by the next unrelated command. Scoping to the launch matches the old reset in every case: the user quitting a typed agent, Ctrl-Z,&, and panes Orca did not launch an agent in.Why the relay and not the desktop for SSH panes: only the relay knows the remote rows' owners. The SSH relay always runs the desktop's exact build (its handshake compares build hashes), so there is no mixed-version gap.
Known limits:
Linked Issue
STA-9582 (follow-up to #26408).
Visual Proof
N/A. No UI change; this only changes which status rows survive the pane reset.
Testing
New
server-launch-retirement.test.ts:claudeowner. Without the mapping, these tests fail.Swapping the old reset back in fails the first-order handover test and both resume-record tests.
New relay tests:
claudeowner.Ended token: neither a late hook nor a new run attests the ended launch's token. The STA-4557 suite
opencode-finished-session-authority.test.tsis now wired to the launch end, and all 5 pass. Without the recorded token, its "later OpenCode session" test fails.Owner rule unit tests: after an ended row, a mimo-code or OpenCode prompt
MessagePart, a droid prompt and a Codex SessionStart are admitted; other types and other processes are admitted; a same-type process-less Stop is dropped.Updated the runtime specs: command finish calls
endLaunchAuthority, PTY exit callsretirePaneAuthority.Ran:
src/main/agent-hooks,src/shared/agent-hook*andsrc/shared/agent-pane-owner*: plus the relay, parity and SSH hook suites: 185 files, 1949 passed; relay PTY suites: 33 files, 419 passed;src/main/runtime/orca-runtime.test.tsunder node: 1336 passed;pnpm tc, oxlint, and the changed-code quality gate.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)