Skip to content

feat(cli): add worktree wake and sleep commands - #30832

Open
Thxzzzzz wants to merge 1 commit into
stablyai:mainfrom
Thxzzzzz:feat/cli-worktree-wake-sleep
Open

Thxzzzzz wants to merge 1 commit into
stablyai:mainfrom
Thxzzzzz:feat/cli-worktree-wake-sleep

Conversation

@Thxzzzzz

@Thxzzzzz Thxzzzzz commented Oct 19, 2026 •

Copy link
Copy Markdown

ELI5

When Agent sleep puts an idle agent to sleep, a script can only bring it back by making Orca show that workspace, which yanks you away from whatever you were looking at. Orca can already wake sleeping agents quietly in the background, but only when a phone asks. This PR lets the CLI ask too: orca worktree wake wakes them without touching your screen, and orca worktree sleep is the matching Sleep action.

What Changed

  • Before: to give work to a slept agent from the CLI, you ran orca file open … --focus or orca terminal switch, and the desktop jumped to that workspace. There was no CLI for Sleep either, although a worktree.sleep RPC existed.
  • After:
    • orca worktree wake --worktree <selector> [--json] resumes the workspace's slept agents in hidden panes: those a workspace sleep left running, and those Agent sleep hibernated. The desktop keeps showing what it showed. The command returns once the wake is queued, behind any sleep still running. The result's sleepingAgentWake is requested, not-applicable, or unsupported-headless (the slept agents only a desktop window can wake, and headless orca serve has none).
    • orca worktree sleep --worktree <selector> [--json] runs the workspace Sleep action through the existing worktree.sleep RPC. It returns once the sleep finished, fails when a terminal stop cannot be proven, and prints a warning when a chat stop or the VM suspend could not be confirmed.
  • Mechanism:
    • Mobile activation's wake (queueSleepingAgentWake + phoneWakeReport, which main now runs since feat(sidebar): main runs workspace sleep; the window follows (P3b) #31564) moves into a small runtime layer, OrcaRuntimeWithWakeManagedWorktree in workspaces/workspace-wake.ts, as wakeSleepingAgents(repo, worktreeId). Mobile activation calls it exactly as before.
    • A new worktree.wake RPC (permission: 'workspace', WorktreeSelector params) calls the same helper for any caller through wakeManagedWorktree. It reads the sleeping records of the repo's execution host, so SSH-host workspaces are covered.
    • worktree.sleep is upstream's method, unchanged. It is grouped with worktree.wake in worktree-sleep-wake-methods.ts (and the CLI handlers in handlers/worktree-sleep-wake.ts), which keeps rpc/methods/worktree.ts and cli/handlers/worktree.ts under the line limit.
    • The 'requested' | 'unsupported-headless' | 'not-applicable' union is named SleepingAgentWakeReport in shared/workspace-sleep.ts next to phoneWakeReport.
    • As with a phone's open, finished agents in a workspace the user explicitly slept (restoreOnTabOpenOnly) still resume only when their tab is opened ([Bug]: Interrupted agent sessions are never auto-hibernated, and manual workspace sleep silently discards them on wake #11598). The help text and docs say so.

Why

I drive agents in Orca workspaces from a chat bot. Each task gets a workspace, and follow-ups are sent with orca terminal send. Every follow-up to a slept agent stole my Orca window.

Alternatives I tried or considered:

  • --focus / terminal switch: these work, but steal the user's view.
  • Close the slept tab and relaunch the agent: close it with terminal close --tab (which drops its sleep record), then start claude --resume <id> with terminal create. This also works without focus, but the caller must know the provider and session id, it replaces the user's tab, and it cannot handle an agent that shares a split tab.
  • Add a "no navigation" flag to worktree.activate: activation also hydrates mobile session surfaces and has mobile-specific semantics. A dedicated wake call is smaller and clearer.

Reusing the existing background wake means no new wake logic. The only new surface is who may call it.

Linked Issue

Fixes #30831

Visual Proof

N/A — CLI and RPC only. The desktop view is deliberately left unchanged, and no UI was modified.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Added:

  • src/main/runtime/orca-runtime-tests/worktree-wake.spec.ts (run through orca-runtime.test.ts):
    • with a window: requested, the queued wake reaches resumeSleepingAgents, activateWorktree not called
    • headless with a hibernation record only a window wakes: unsupported-headless
    • headless with a running agent's workspace-sleep record, which main resumes: requested
    • an SSH-host worktree: its ssh: session partition is read
  • src/main/runtime/rpc/methods/worktree-sleep-wake-methods.test.ts:
    • a local CLI call (no clientKind) reaches wakeManagedWorktree, not activation
    • a missing selector is rejected
  • src/cli/index.test.ts: worktree sleep / worktree wake call worktree.sleep / worktree.wake with the resolved selector.

Ran locally on macOS (arm64), Node 24.22, pnpm 12.14, Bun 1.4.3, rebased on main at d667e54:

  • oxlint on the changed files, audit:anti-slop, audit:code-quality:native, check:max-lines-ratchet, check:dead-classes, verify:rpc-params-catalog and verify:bundled-skill-guides pass.
  • pnpm typecheck:node and pnpm typecheck:cli pass.
  • vitest run src/main/runtime/orca-runtime.test.ts src/main/runtime/rpc src/cli: 7560 passed, 2 failed.
    • The 2 failures (sets up an existing folder on a fresh runtime after importing the repo project, keeps existing-folder imports split by runtime host on the same normalized path) fail identically on unmodified main.
    • The cause is local: macOS /var → /private/var realpath in repository-project-operations.spec.ts.

Not run locally: the full pnpm lint and pnpm test, pnpm build, and a manual run of a built app.

AI Disclosure

Implemented with Claude Code using Claude Opus 5.5 (claude-opus-5-5): investigation, code, tests and this description, with human direction and review.

Review

AI review summary:

  • Cross-platform: no platform-specific code. Path, shell and keyboard handling are untouched.
  • SSH/remote:
    • Same as the mobile path. The report reads the repo's execution-host session partition (getRepoExecutionHostId), so SSH-host worktrees are covered.
    • A paired CLI reaches the method like any other workspace method. It is not added to the phone allowlist, since the mobile app keeps using activation.
  • Mobile: behavior is identical. worktree.activate still gates the wake on clientKind === 'mobile' and returns the same sleepingAgentWake values.
  • Agents/integrations: provider-neutral. It resumes whatever records the host keeps.
  • Performance: one queued wake per call, not awaited by the request.
  • Security: standard workspace permission, the same as worktree.sleep / worktree.activate. No new data is exposed.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — changed-file lint, the related audits and typecheck pass locally; targeted tests pass apart from the two pre-existing macOS path failures above; full pnpm lint, pnpm test and pnpm build left to CI

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1f7cfa6b-efc5-4b52-92af-ce1415af8b6f
📥 Commits

Reviewing files that changed from the base of the PR and between ca72504984b32ab47b686f7559054a32d6afa455 and de5dfe8.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 14
  • docs/site/content/docs/cli/reference.mdx
  • skill-guides/orca-cli.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/worktree-sleep-wake.ts
  • src/cli/handlers/worktree.ts
  • src/cli/index.test.ts
  • src/cli/specs/core.ts
  • src/main/runtime/orca-runtime-tests/worktree-wake.spec.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/rpc/methods/worktree-sleep-wake-methods.ts
  • src/main/runtime/rpc/methods/worktree.ts
  • src/main/runtime/workspaces/workspace-activation.ts
  • src/main/runtime/workspaces/workspace-wake.ts
  • src/shared/workspace-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.

📝 Walkthrough

The change adds orca worktree sleep and orca worktree wake to the CLI. It registers the wake RPC method and adds runtime handling that queues agent wake requests and reports their outcome. Mobile worktree activation also uses the shared wake helper. The change updates command help and guides, and adds CLI, RPC, and runtime tests.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to de5df

Wake reports that the request was queued, not that background resumption succeeded. No merge-blocking issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 19 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding CLI commands for worktree wake and sleep.
Description check Passed The description is complete and covers the required sections, including user impact, implementation details, rationale, linked issue, testing, AI disclosure, compatibility considerations, and checklis…
Linked Issues check Passed Issue #30831 requires CLI wake without desktop navigation and CLI access to the existing workspace Sleep action. The PR adds worktree wake and worktree sleep, registers worktree.wake, routes wak…
Out of Scope Changes check Passed The changes stay within issue #30831. The documentation, help text, CLI tests, RPC tests, and shared wake layer support the two requested commands. The mobile activation refactor preserves existing be…
Full details: Description check

Explanation

The description is complete and covers the required sections, including user impact, implementation details, rationale, linked issue, testing, AI disclosure, compatibility considerations, and checklist status. It also transparently documents unrun full checks and two pre-existing targeted-test failures.

Full details: Linked Issues check

Explanation

Issue #30831 requires CLI wake without desktop navigation and CLI access to the existing workspace Sleep action. The PR adds worktree wake and worktree sleep, registers worktree.wake, routes wake through wakeManagedWorktree, and preserves the existing mobile wake path. The runtime uses the repository execution host and reports requested, unsupported-headless, or not-applicable. Tests cover CLI routing, selector validation, windowed wake, headless behavior, and host-specific records.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #30831. The documentation, help text, CLI tests, RPC tests, and shared wake layer support the two requested commands. The mobile activation refactor preserves existing behavior while sharing the requested wake logic. No unrelated UI or product behavior is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 19 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2316069f-7c08-4416-b0e3-0a7a77763112
📥 Commits

Reviewing files that changed from the base of the PR and between 40e7bd1 and d3f2c01.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 18
  • docs/site/content/docs/cli/overview.mdx
  • docs/site/content/docs/cli/reference.mdx
  • skill-guides/orca-cli.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/handler-group-manifest.ts
  • src/cli/handlers/worktree.ts
  • src/cli/index.test.ts
  • src/cli/root-help-text-primary.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/specs/core.ts
  • src/cli/specs/terminal-close.ts
  • src/main/runtime/orca-runtime-tests/worktree-wake.spec.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/rpc/methods/worktree-sleep-wake-methods.test.ts
  • src/main/runtime/rpc/methods/worktree-sleep-wake-methods.ts
  • src/main/runtime/rpc/methods/worktree.ts
  • src/main/runtime/workspaces/managed-workspace-operations.ts
  • src/main/runtime/workspaces/workspace-activation.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.

Comment thread src/cli/handlers/worktree.ts Outdated
Comment thread src/main/runtime/workspaces/managed-workspace-operations.ts Outdated
Comment thread src/main/runtime/workspaces/managed-workspace-operations.ts Outdated
@Thxzzzzz

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Thxzzzzz

Copy link
Copy Markdown
Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai review --preview-config to test the unmerged CodeRabbit configuration on a draft PR. The requester must have repository write access; preview results are non-authoritative.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai track in a human-authored review thread to track the original finding until CodeRabbit verifies it is fixed.
  • @coderabbitai fixed in a tracked review thread to verify the current code against the original finding.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai generate project vocabulary to list vocabulary that is specific to this repository (requires an Essentials plan or above with an active subscription).
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai fix comments to automatically fix issues in the current review thread, or all unresolved review comments when used in the PR conversation.
  • @coderabbitai autofix (alias: @coderabbitai autopilot) to enable Autofix to fix CodeRabbit findings and required CI, and resolve merge conflicts.
  • @coderabbitai autofix resume to resume Autofix for this PR.
  • @coderabbitai autofix stop to stop Autofix for this PR.
  • @coderabbitai fix-ci to automatically fix failing CI checks in a stacked pull request.
  • @coderabbitai fix-ci commit to automatically fix failing CI checks by committing fixes to the current branch.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai approve as a new top-level PR comment to resolve CodeRabbit review threads; also requests approval when reviews.request_changes_workflow is enabled.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@odmrs odmrs mentioned this pull request Oct 21, 2026
9 tasks done
@Thxzzzzz
Thxzzzzz force-pushed the feat/cli-worktree-wake-sleep branch from ca72504 to de5dfe8 Compare October 23, 2026 02:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Resume slept agents from the CLI without switching the desktop view

1 participant