Repository navigation
fix(runtime): automatic tab activation no longer wakes a worktree the host put to sleep - #27081
Conversation
… host put to sleep
|
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 3 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (7)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughTerminal spawning now accepts a Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Automatic activation leaves a sleeping worktree stopped, while explicit activation can still wake it. No actionable merge-blocking risk remains after normal checks. Pre-merge checks |
|
ELI5
When you put a workspace on a paired Orca server to sleep, its terminal stopped and then started again about a second later. The server now remembers that it put the workspace to sleep and refuses to restart it on its own. Opening the tab yourself still wakes it.
What Changed
Before: Sleeping a remote workspace with a plain shell tab (no agent) stopped the terminal, then the desktop's background reconnect asked the server to "activate" the tab, and the server started a fresh shell under the same session id. The workspace never stayed asleep until the desktop was reloaded.
After: The background reconnect gets the tab back without a terminal, the workspace stays asleep, and a click on the tab (an explicit user activation) still wakes it as before.
Mechanism:
terminalSleepStateByWorktreeId). Automatic tab activation only checked for an agent's sleep record, which a plain shell never has. It now also refuses when the host's own sleep record exists.refuseSleptWorktree, andacquireWorktreeTerminalSpawnre-checks under the lock: it releases the lock and refuses instead of clearing the sleep record and publishingwoken. The activation turns that refusal into the same "navigate without spawning" result the agent-record path already returns, so the client's recovery stops instead of looping.Why
The host is the only side that knows it put the worktree to sleep, so the fix belongs on the host and also protects older clients. Alternatives considered: making the client stop sending automatic activations after a sleep only covers new clients and still races with the stream recovery; writing a durable sleep record would also survive a host restart, but that is part of a parked decision about pausing automatic restore after a crash, so this PR deliberately does not add one. Known limitation: the sleep record is in memory, so a host restart forgets it.
Takes over the approach from #24410 (@mmarabel) and #24416 (@innocarpe), with credit.
Linked Issue
Fixes #24399
Visual Proof
N/A: host-side runtime behavior; covered by the runtime tests below.
Testing
src/main/runtime/automatic-activation-host-sleep.test.ts(new; fails onorigin/main): a slept worktree with no agent record refuses an automatic activation (no spawn, nowoken), a user activation still spawns, an automatic spawn carriesrefuseSleptWorktree, and a sleep that commits while an automatic spawn waits for the lock makes that spawn refuse without waking the worktree.orca-runtime.test.ts,folder-workspace-pty-identity.test.ts,terminal-list-pending-pty-registration.test.tspass.pnpm tc:node,oxlint,pnpm run check:code-quality:changed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
SSH and
orca serverun the same runtime code. Folder workspaces use the same worktree identity key. No wire change: the refusal is the existing navigation result, so old clients benefit too. No platform-specific code.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)