Repository navigation
feat(desktop): let the renderer reach agent.launch on its own main process - #21132
Conversation
…ocess The desktop renderer aimed at a remote host was admitted to `agent.launch`; the same renderer aimed at its own main process was refused `agent_launch_unsupported`. Main sends `ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES` on the remote path, which carries the capability, while `runtime:call` built its own hardcoded list that did not. Collapse the two hand-maintained copies in `runtime.ts` — the unary and the streaming path held separate literals — into one constant, add the capability to it, and pin its divergence from the remote Electron list so the next capability cannot drift the same way. No caller is migrated: this makes the call possible and changes no behaviour.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change adds one readonly capability list for desktop renderer runtime calls. Both unary and streaming IPC handlers use this list. The list includes Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The desktop renderer can advertise agent-launch support consistently for local runtime calls, with no actionable merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the implementation, rationale, scope, and verification in detail, but it omits required template content, including the Linked Issue, Visual Proof or an explicit N/A statement, the Testing section and checkboxes, and the remaining checklist sections. Resolution Add the required template sections. Include a linked issue after “Fixes #”, provide visual proof or write “N/A” with a reason, document testing under the Testing heading, complete the AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, and mark applicable checkboxes.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full diff (9ff87074..7053745e, 5 files) and verified the new tests pass, the adjacent capability/launch suites still pass, and oxlint is clean on the changed files.
- One capability constant for both dispatch paths —
runtime:callandruntime:subscribenow readDESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIESinstead of two identical inline arrays; the new list is the previous six plusAGENT_LAUNCH_RUNTIME_CAPABILITY, with nothing dropped. agent.launchadmitted on the local main process —supportsAgentLaunchnow accepts the desktop renderer (clientKind: 'runtime') against its own main process, closing the asymmetry with the remote path. The one consumer of the capability is that predicate, so advertising it locally has no other effect.- Divergence ledger test — pins the symmetric difference between the local constant and
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES, so a capability added to either list fails until a decision is recorded for the other side. I hand-verified bothtoEqualassertions against the current lists (12 remote / 7 local; 10 remote-only / 5 local-only) and they hold. - Wiring test — drives the real registered
runtime:call/runtime:subscribehandlers, then feeds what they actually advertise into the real host gate, with a negative control proving the gate discriminates. Not vacuous. - Comment correction —
supportsAgentLaunch's docstring now names the realclientKind === undefinedpopulation (theorcaCLI over the runtime socket and the SSH-remote CLI bridges, which dispatch with noclientKind/capability list), rather than "the same build as the host".
One note I checked but am not asking you to change: the renderer sends no operationId, so it takes runLegacyAgentLaunch and never reaches agentLaunchOperationCallerKey, which would throw agent_session_identity_required for a clientKind caller with no pairedDeviceId. That matches the PR description and keeps this change free of any ledger-identity decision.
ℹ️ The ledger makes omissions visible but not decisions mandatory
The divergence test is a real improvement over the two silently-maintained arrays, but its stated goal — "adding a capability to either list now reddens the test until someone writes down a decision for the other side" — is only partly enforced. LOCAL_ONLY_BY_DECISION has no per-entry reason ("Why it is one is not recorded here"), and half of REMOTE_ONLY_BY_DECISION shares one grouped "mixed-version wire terms" rationale. A future author hitting a red ledger can still satisfy it by pasting a capability into the by-decision list without recording why — the same silent-omission failure mode, just relocated. Requiring a one-line reason per entry (or a linked follow-up issue for the grouped ones) would close that loop. Not blocking: the entries are all pre-existing omissions, and the second commit explicitly marks which rationales are grouped rather than audited.
Technical details
# Divergence ledger records grouping, not decisions
## Affected sites
- `src/main/ipc/desktop-renderer-runtime-capabilities.test.ts:34-51` — `REMOTE_ONLY_BY_DECISION`; five entries (`AGENT_SESSION_BOUNDARY`, `WORKTREE_VISIBILITY_DEFAULTS`, `WORKTREE_VISIBILITY_SOURCE_DEFAULTS`, `WORKTREE_GITHUB_PR_SUPPRESSION`, `AUTOMATION_OWNER_FENCING`, `AUTOMATION_CREATE_IDEMPOTENCY`) share one "not audited one by one" comment.
- `src/main/ipc/desktop-renderer-runtime-capabilities.test.ts:53-62` — `LOCAL_ONLY_BY_DECISION`; all five entries carry a single "Why it is one is not recorded here" comment.
## Required outcome
- Each capability that is deliberately absent from one of the two lists has, in the ledger, either a one-line reason or a pointer (issue/PR) to where the reason is recorded, so the test's failure message forces a real decision rather than a list edit.
## Open questions for the human
- Are the five `LOCAL_ONLY_BY_DECISION` entries (structured-session capabilities the renderer advertises locally but not to a remote Electron host) a known Electron-remote gap with a tracking issue, or intentionally Electron-local? The comment says the gap is real but unrecorded; a pointer would let the next reader stop re-deriving it.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Visual proof — local renderer
|
Review status: PASS — landNo P0, P1, or P2 findings remain. The same-model review loop returned clean on its first pass, and both the opening and closing readiness audits passed. No corrective code changes were necessary; the reviewed and pushed head remains The failure mechanism is addressed at its source: local desktop IPC identified the renderer as a capability-negotiated runtime client but omitted Architecture and performance review found no regression. Launch ownership stays on the execution host, the renderer continues through the existing RPC boundary, and transport-specific local/remote capability differences remain explicit and tested. The production change adds no polling, timers, listeners, scans, subprocess fanout, caches, or persistent state; it removes the prior per-call capability-array allocations. Validation completed:
Electron validation used a hidden isolated app launched from this exact worktree. A renderer call to local Residual validation gaps: the structured-session outcome was not separately exercised through this newly admitted local route, and no additional live Windows/Linux Electron run was performed. The launch implementation, result contract, remote path, and platform-specific code are unchanged, so these are coverage gaps rather than proven risks. |
…ocess (stablyai#21132) * feat(desktop): let the renderer reach agent.launch on its own main process The desktop renderer aimed at a remote host was admitted to `agent.launch`; the same renderer aimed at its own main process was refused `agent_launch_unsupported`. Main sends `ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES` on the remote path, which carries the capability, while `runtime:call` built its own hardcoded list that did not. Collapse the two hand-maintained copies in `runtime.ts` — the unary and the streaming path held separate literals — into one constant, add the capability to it, and pin its divergence from the remote Electron list so the next capability cannot drift the same way. No caller is migrated: this makes the call possible and changes no behaviour. * docs(test): mark which ledger rationales are grouped rather than audited




The asymmetry
agent.launchis the one host-side method that decides structured-chat vs terminal. The desktop renderer already had a transport to it —runtime:callbuilds anRpcDispatcheroverALL_RPC_METHODS, registered on every main window. What it did not have was permission.supportsAgentLaunchadmits a caller whoseclientKindisundefined, or one that advertisesagent.launch.v2. The renderer arrives asclientKind: 'runtime', so it needs the capability — and the hardcoded list inruntime:calldid not carry it. Meanwhile, when that same renderer targets a remote host, main sendsELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES, which does carry it viaNATIVE_REMOTE_RUNTIME_CLIENT_CAPABILITIES.So: renderer to a remote host, admitted; renderer to its own main process, refused
agent_launch_unsupported. One client, one build, two hand-maintained capability lists that had already drifted.What this does about the drift
Two changes, both deliberately small:
One constant instead of two literals.
runtime.tsheld separate capability arrays for the unary (runtime:call) and streaming (runtime:subscribe) paths. Both now readDESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES. That drift class is now structurally impossible rather than merely tested.A pinned divergence ledger against the remote list. The local and remote lists cannot simply be unified, and I checked rather than assumed: several remote-only entries would change local behaviour if adopted —
SESSION_TAB_CLOSE_INTENTflipsrequiresIntenton, so an unattributed desktop tab close would start being refused;BROWSER_CLIENT_HOSTis about hosting pages for a remote runtime;SESSION_TABS_RETIREMENT_PROOF_DELTAswaps the full tab list for a delta feed. Unifying them is a real refactor and does not belong here.So instead the test pins both difference sets explicitly, with specific reasons where audited and grouped transport rationales for the remaining pre-existing differences. Adding a capability to either list now reddens the test until someone writes down a decision for the other side. The decision can no longer be skipped silently — which is the failure that produced this bug.
The shape I chose over the alternatives: a blanket equality guard cannot pass today, and deriving the local list by union from the remote one would change behaviour. The ledger is the smallest thing that makes the omission impossible.
Why desktop deliberately sends no
operationIdagent.launchsupports a durable operation ledger: name the launch withoperationIdand a retry replays the recorded answer instead of starting a second agent. Desktop does not use it, on purpose.The renderer's local path is a single
ipcRenderer.invokeinruntime-bridge.tswith no retry logic anywhere above it, and main and the renderer die together — there is no window in which a desktop caller retries a launch whose reply it lost. A durable obligation with nothing to discharge it is a defect, not a safety net.There is also a concrete blocker:
agentLaunchOperationCallerKeythrowsagent_session_identity_requiredfor any caller with aclientKindand nopairedDeviceId, which is exactly the desktop renderer. Supplying anoperationIdfrom desktop would need a caller-identity decision this PR does not make.Scope
No caller is migrated and no behaviour changes.
launchAgentInNewTab(11 production call sites) andlaunchWorkItemDirect(4) are untouched; their migration carries real risk around tab placement, focus, navigation and work-item provenance, and belongs in a later PR. This PR only makes the call possible.One comment correction in
supportsAgentLaunch, because it is the docstring of the predicate this PR is about and it is what makes the bug look correct: it described theclientKind === undefinedbranch as in-process callers that are "the same build as the host". That population is theorcaCLI over the runtime socket (runtime-rpc-request-admission.tsdispatches with noclientKind) plus the SSH-remote CLI bridges. The desktop renderer is the same build as the host and is still not in that branch.Verification
pnpm tcexit 0;oxlintclean;pnpm run check:code-quality:changedpasses (0 findings across 5 changed files).runtime.test.ts,runtime-subscribe-lifecycle.test.ts,agent-launch{,-replay}.test.ts, the sixruntime-environment*capability suites,session-tab-browser-placement-projection,github-pr-suppression,remote-runtime-client).supportsAgentLaunchactually refuses the same caller without the capability, so neither is vacuous.mainin the committed tree.