Repository navigation
Conversation
Expose the existing worktree.sleep runtime method as `orca worktree sleep --worktree <selector> [--force] [--json]`, the CLI equivalent of Sleep in the sidebar. The command refuses to sleep the worktree whose terminal runs it unless --force is passed, and maps method_not_found from older hosts to incompatible_runtime.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a721b25b-6fec-4abf-be4d-74570cd2c3df
📒 Files selected for processing: 13
docs/site/content/docs/cli/overview.mdxdocs/site/content/docs/cli/reference.mdxskill-guides/orca-cli.mdsrc/cli/bundled-skill-guides.tssrc/cli/flag-help-text.tssrc/cli/handler-group-manifest.tssrc/cli/handlers/worktree-sleep.tssrc/cli/handlers/worktree.tssrc/cli/index-worktree-sleep.test.tssrc/cli/root-help-text-primary.tssrc/cli/root-help-text-secondary.tssrc/cli/specs/core.tssrc/cli/specs/worktree-sleep.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
ELI5
The sidebar has a Sleep action that closes a workspace's terminals, browser tabs and agents to free memory and CPU. Scripts and agents had no way to do the same from the terminal. This adds
orca worktree sleep.What Changed
worktree.sleepRPC, but no CLI command called it.orca worktree sleep --worktree <selector> [--force] [--json]calls that RPC and takes the same selectors asworktree show.Mechanism. This is CLI-only. There is no new RPC and no runtime change.
specs/worktree-sleep.ts. It lives in its own file socore.tsstays under the max-lines budget.handlers/worktree-sleep.ts, wired intoWORKTREE_HANDLERSand the handler manifest.ORCA_WORKTREE_ID) against the local runtime, it resolves the target withworktree.show. If the target is the caller's own worktree, it refuses withinvalid_argument, because sleeping it would kill the terminal running the command.--forceskips the check, and remote targets skip it too.method_not_foundmaps toincompatible_runtime, the same wayterminal close --alldoes.--forcehelp text. The shared line used to read "Force worktree removal…", which was also wrong forproject,serveandmanaged-server. It is now generic and points at each command's notes.skill-guides/orca-cli.md(and regeneratedbundled-skill-guides.ts) and the CLI docs. The notes say plainly that with a desktop window, success means the sleep was accepted. The renderer finishes it right after. Headless runtimes only succeed once every PTY is confirmed stopped.Why
It lets automations and agents free a finished workspace's resources without touching the UI. #22571 asks for exactly this command shape.
I reused the existing RPC instead of adding a new one. That keeps the change small and leaves the server-side sleep path to the ongoing main-process sleep work (#31564).
#30832 also proposes sleep plus a new
worktree.wakeRPC. This PR is narrower: sleep only, no runtime change, plus the self-sleep guard. If maintainers prefer #30832, I'm happy to close this or port the guard there.Linked Issue
Fixes #22571
Visual Proof
N/A — CLI-only change with no UI change. The terminal output is under Testing.
Testing
I tested on macOS against Orca 1.4.237 (desktop window open), using the CLI built from this branch (
pnpm build:cli,node out/cli/index.js). I made a throwaway worktree and ransleep 3000in a terminal there.worktree sleep --worktree id:<…> --jsonfrom another worktreeok: true,{ worktreeId }; thesleep 3000process is gone a few seconds latersleep requested: <id>, exit 0 (no-op)ORCA_WORKTREE_ID=<target>(caller inside the target)invalid_argument, exit 1; the process keeps running--force--worktree name:does-not-existselector_not_foundwith next stepsAutomated:
src/cli/index-worktree-sleep.test.tscovers the sleep call and output, another worktree from an Orca terminal, the self-sleep refusal,--force, and themethod_not_found→incompatible_runtimemapping. Removing the guard makes the refusal test fail.Local checks:
pnpm lint,pnpm typecheck, the fullsrc/clisuite (179 files),pnpm build:cli,generate-rpc-params-catalog --check,generate-bundled-skill-guides --check,oxfmt --checkand the max-lines ratchet all pass. In the fullpnpm testrun, the only failures are daemon, shell-startup and native-chat tests outsidesrc/cli, which fail the same way on a cleanmaincheckout on this machine.pnpm buildbuilds main, preload and renderer; only the mobile web step fails here, because I don't have the mobile workspace dependencies installed. CI should cover both.Not tested by hand: Linux, Windows, SSH and paired remote hosts. The command only forwards a selector to an existing RPC, and the guard is skipped for remote clients.
AI Disclosure
Implemented with Claude (Opus 5.5) via Claude Code. I directed the change, and I reviewed and tested it myself.
Review
AI review summary:
worktree.sleepkeeps itsworkspacepermission. The guard only readsORCA_WORKTREE_ID, and only makes one read-onlyworktree.showcall.ORCA_WORKTREE_ID, so the format is identical on every platform.--environment/--pairing-codebehave as inworktree show. The guard is skipped for remote clients, because a local terminal can't belong to a remote host's worktree. Older hosts getincompatible_runtime.worktree.showcall, only when the command runs inside an Orca terminal without--force.--forcehelp string.Agent skill upstream boundary
Notes
I checked security, cross-platform, remote SSH, mobile, backwards compatibility and performance; details are in the Review section above.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — see Testing for the environment-only failures