Repository navigation
feat(runtime): accept a declared spawn intent from paired clients - #27452
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No specific spawn-intent or deferral failure is established. The change is mergeable subject to normal checks. Pre-merge checks |
|
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.
8edc6ad to
4683c55
Compare
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.createandterminal.ensureAgentSessionaccept an optionalspawnIntent(user-resumefor the visible pane,automatic-restorefor hidden ones). The host passes it to the terminal daemon's fork gate, which already knows how to use it.terminal.spawn-intent.v1.terminal.ensureAgentSessionrejects unknown fields, so an app must only send the field to a host that advertises it.terminal_spawn_deferred, with the reason (paused,live_cap,pressure,deadline), instead of a genericruntime_error.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:
terminal_spawn_deferred.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:
ensureAgentSessionforwards 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
interactivebut 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 codeterminal_spawn_deferredwith{ reason }.pnpm tc,pnpm lint,pnpm run check:code-quality:changedand 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)