Skip to content

feat(runtime): accept a declared spawn intent from paired clients - #27452

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/d1b-c2-spawn-intent
Oct 11, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/d1b-c2-spawn-intent

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​285 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​279
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​85 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73

ELI5

When a remote Orca host restarts, every connected app asks it to bring back all of its agent terminals at once. The host now has a gate that can pace those restores and keep some asleep, but it cannot tell which terminal the user is actually looking at. This PR lets an app say so: "this one is on screen" or "this one is hidden". Nothing sends that yet; the next PR teaches the app to send it and to show a sleeping terminal when the host asks it to wait.

What Changed

  • terminal.create and terminal.ensureAgentSession accept an optional spawnIntent (user-resume for the visible pane, automatic-restore for hidden ones). The host passes it to the terminal daemon's fork gate, which already knows how to use it.
  • The host advertises a new capability, terminal.spawn-intent.v1. terminal.ensureAgentSession rejects unknown fields, so an app must only send the field to a host that advertises it.
  • When the gate keeps a declared restore asleep, the app now gets a distinct error code, terminal_spawn_deferred, with the reason (paused, live_cap, pressure, deadline), instead of a generic runtime_error.
  • The desktop app's own terminal spawn (local, no network) accepts the same field. Desktop stays in observe mode, so this only improves the gate's counts there.

Before: the host guessed: any agent resume counted as background work. After: an app that declares intent gets the pane the user is looking at started first, within a small per-app budget.

Why

The gate (#27424, #27428, #27433, #27437) only affects requests that carry an intent, and no app sent one, so today it changes nothing for anyone. The host side lands first so that it is already in place when apps start sending the field. A new capability is needed rather than a plain new field because the resume call's parameters are strict, and an older host would reject the whole request.

Version skew:

  • New app, old host: the host does not advertise the capability, so the app does not send the field (next PR). An old host never answers terminal_spawn_deferred.
  • Old app, new host: no field, so the host keeps inferring from the facts it holds and only paces, never defers. This is unchanged.
  • New host, old terminal daemon kept running across an update: the daemon ignores the field. Protection starts at its next restart.

Linked Issue

Part of the headless-serve robustness work for #10493.

Visual Proof

N/A. No user-visible change yet; no app sends the field until the next PR.

Testing

  • Param schemas: an explicit resume accepts and keeps spawnIntent, still accepts a request without it, and rejects an unknown value.

  • Runtime: ensureAgentSession forwards the intent to the PTY controller, and omits it when it was not declared. A deferral passes back unchanged.

  • Both main-process spawn paths (the runtime's and the renderer's) hand the intent to the provider, and drop unknown values.

  • Daemon adapter: a deferral comes back as-is after one request. It is not treated as a dead daemon and not retried.

  • Gate: a request that declares interactive but carries an agent claim is still charged as automatic, so a client cannot declare its way past pacing. Interactive forks skip the gate entirely, and before this PR no client could declare anything.

  • RPC error mapping: terminal_spawn_deferred:<reason> maps to code terminal_spawn_deferred with { reason }.

  • pnpm tc, pnpm lint, pnpm run check:code-quality:changed and the focused tests pass locally (macOS).

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

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

SSH: current apps reach SSH hosts through managed orcad, which uses the same RPCs, so the field reaches those hosts the same way. Mobile does not send the field and keeps today's behavior.

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)

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85b956c5-1904-49cd-acae-289879bf2e1a

📥 Commits

Reviewing files that changed from the base of the PR and between 8edc6ad and 4683c55.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95ee62bb-0eb2-4734-b39c-2d397e80e371


📥 Commits

Reviewing files that changed from the base of the PR and between 4b78a0e and 8edc6ad.



📒 Files selected for processing (8)
  • src/main/daemon/daemon-pty-adapter-spawn-intent.test.ts
  • src/main/daemon/daemon-pty-spawn-request.ts
  • src/main/ipc/pty/ipc/spawn-options-spawn-intent.test.ts
  • src/main/ipc/pty/ipc/spawn-options.ts
  • src/main/ipc/pty/ipc/spawn-types.ts
  • src/shared/host-spawn-admission.ts
  • src/shared/rpc-contract/agent-session-params.ts
  • src/shared/rpc-contract/agent-session-spawn-intent-params.test.ts


🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/ipc/pty/ipc/spawn-types.ts


Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds optional spawn-intent values to RPC schemas and runtime contracts, and advertises the related runtime capability. Host spawn-charge resolution prevents requests with an agent-session claim from selecting the interactive charge. Terminal and PTY spawn paths forward declared intents. Runtime error mapping returns a dedicated code and reason for recognized terminal-spawn deferrals.



Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 8edc6

No specific spawn-intent or deferral failure is established. The change is mergeable subject to normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 26 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: accepting a declared spawn intent from paired clients.
Description check Passed The description covers the user impact, implementation, rationale, linked issue, compatibility behavior, testing, platform considerations, and checklist. It correctly marks visual proof as not applica…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.



✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

  • 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.

m4air added 3 commits October 11, 2026 05:17
Paired clients can now say whether a terminal restore is the pane the
user is looking at (user-resume) or a hidden one (automatic-restore).
The host forwards the intent to its fork gate, advertises
terminal.spawn-intent.v1 so clients only send it to hosts that accept
it (terminal.ensureAgentSession params are strict), and reports a
deferred fork as terminal_spawn_deferred with its reason.

No client sends the field yet; that lands next with the sleeping-pane
handling.
Interactive forks skip the gate, and paired clients can now declare
intent, so the host keeps inferring from the claim when a request
says interactive.
A daemon kept running across an update still lets a declared
interactive request skip its gate, even for a claimed resume. The RPC
and local IPC now accept only user-resume and automatic-restore, and
the daemon request boundary turns a claimed interactive into an
automatic restore.
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.

1 participant