Repository navigation
fix(terminal): a phone wake no longer resumes an agent whose terminal is still running - #29431
Merged
Merged
Conversation
…ng an agent The background wake a phone triggers on the desktop host resumed slept agent records with no host PTY inventory check. In a worktree the desktop is not looking at, a pane whose PTY the daemon still runs (e.g. after a renderer restart) reads as unowned, so the wake forked a second claude --resume onto the live transcript. Route it through the activation gate, which resumes only records whose PTY the host inventory shows exited and declines when the inventory cannot be read. (STA-3859)
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nwparker
added a commit
that referenced
this pull request
Oct 25, 2026
The terminal daemon now lists the ORCA_PANE_KEY each PTY was spawned with, and the activation gate (also used by the phone wake) claims a sleeping record through that key when this renderer's layout no longer links the record's pane to the live PTY. Covers a host that re-keyed the live PTY onto a new tab and an agent a paired client launched for its own pane; both previously forked a second `claude --resume` onto the live transcript. Rewritten on current main from #24386 (the phone wake already routes through the gate since #29431; the SSH relay it also touched is gone). Co-authored-by: Minidoracat <[email protected]>
This was referenced Oct 25, 2026
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 a phone opens a workspace on a desktop that runs Orca, the desktop wakes that workspace's sleeping agents. It could also "wake" an agent that was never asleep, starting a second
claude --resumeon a conversation that was still running in another tab. You ended up with two copies of one conversation writing to the same transcript. Now the desktop asks its terminal service which terminals are still running before it resumes anything.What Changed
Before: a phone opened a workspace the desktop wasn't showing. If one of its agent tabs hadn't been re-attached since the desktop app restarted (the terminal service kept the agent running across the restart), the wake treated the tab as empty and opened a new tab running
claude --resume <same id>. Two live processes, one transcript.After: the wake resumes a record only when the host's own terminal list shows that pane's terminal has exited. If the terminal is still running, the record is left alone and nothing new is launched. If the list can't be read, the wake declines and keeps the record, so a later activation can still resume it.
Mechanism:
wakeSleepingAgentsForWorktreeInBackgroundcalledresumeSleepingAgentSessionsForWorktreedirectly. That sweep decides ownership from renderer-local state only: the live PTY map, plus "this pane will reconnect because its worktree is active". For a background worktree after a restart, both are empty or false, so a live pane reads as unowned. The wake now goes throughgateWorktreeAgentActivation, the gate that user worktree activation already uses. The gate reads the execution host's PTY inventory (pty.listSessions), skips records whose persisted PTY is still listed, refuses when an unattributed agent PTY is live, and returnsblockedif the inventory is unreadable. The gate gained an optionalresumeOptionsargument, so the wake keeps its no-navigation, already-woken-claims and background-mount behavior.Workspaces owned by a paired Remote Orca Server have no host inventory on this renderer, so they keep the existing per-pane mirror park unchanged.
Why
The rule is to never resume unless the current holder is proven exited. The activation gate already enforces that rule against the host's terminal inventory, and the background wake was the one sweep caller that skipped it. Reusing the gate keeps one ownership check instead of adding a second inventory read. The other option was to make
recordPaneIsOwnedByPreservedPanetreat a persisted PTY binding as ownership. But that binding goes stale across sleep and restart and can't tell live from exited, so it would either block legitimate resumes or still fork.The two paired-client paths were closed by #29272 and #29389 (open). #29289 (open) covers the paired-desktop renderer's mirrored-record sweep. This PR touches neither.
Linked Issue
STA-3859 (Linear)
Visual Proof
N/A. This changes which resume a background sweep is allowed to launch. It has no UI change, and the runtime test covers it.
Testing
New
src/renderer/src/lib/wake-sleeping-agents-live-unmounted-pane.test.ts, run against the real store and sweep. The worktree is a background one, and its pane is unmounted but its persisted PTY is live.--resumegets queued).blocked, no resume, record kept. Fails on main.The existing wake, live-done, activation-gate and host-mirror frame-ordering suites pass.
pnpm tc:webandpnpm run check:code-quality:changedpass.AI Disclosure
Review
Agent skill upstream boundary
Notes
unverifiable, and the wake declines instead of resuming.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)