Skip to content

feat(desktop): let the renderer reach agent.launch on its own main process - #21132

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/desktop-launch-capability
Sep 17, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/desktop-launch-capability

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​240 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​240
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​43 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17

The asymmetry

agent.launch is the one host-side method that decides structured-chat vs terminal. The desktop renderer already had a transport to it — runtime:call builds an RpcDispatcher over ALL_RPC_METHODS, registered on every main window. What it did not have was permission.

supportsAgentLaunch admits a caller whose clientKind is undefined, or one that advertises agent.launch.v2. The renderer arrives as clientKind: 'runtime', so it needs the capability — and the hardcoded list in runtime:call did not carry it. Meanwhile, when that same renderer targets a remote host, main sends ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES, which does carry it via NATIVE_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.ts held separate capability arrays for the unary (runtime:call) and streaming (runtime:subscribe) paths. Both now read DESKTOP_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_INTENT flips requiresIntent on, so an unattributed desktop tab close would start being refused; BROWSER_CLIENT_HOST is about hosting pages for a remote runtime; SESSION_TABS_RETIREMENT_PROOF_DELTA swaps 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 operationId

agent.launch supports a durable operation ledger: name the launch with operationId and 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.invoke in runtime-bridge.ts with 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: agentLaunchOperationCallerKey throws agent_session_identity_required for any caller with a clientKind and no pairedDeviceId, which is exactly the desktop renderer. Supplying an operationId from 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) and launchWorkItemDirect (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 the clientKind === undefined branch as in-process callers that are "the same build as the host". That population is the orca CLI over the runtime socket (runtime-rpc-request-admission.ts dispatches with no clientKind) 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 tc exit 0; oxlint clean; pnpm run check:code-quality:changed passes (0 findings across 5 changed files).
  • New tests green; adjacent suites re-run with no ripple (runtime.test.ts, runtime-subscribe-lifecycle.test.ts, agent-launch{,-replay}.test.ts, the six runtime-environment* capability suites, session-tab-browser-placement-projection, github-pr-suppression, remote-runtime-client).
  • RED arm 1 — removed the capability from the constant: 4 of 5 tests fail, including both the unary and streaming gate proofs. Re-proved at the final commit, not just mid-work.
  • RED arm 2 — added a capability to the remote Electron list only (simulating the original drift): the ledger fails and names the drifted capability in the diff.
  • Both gate assertions carry a negative control proving supportsAgentLaunch actually refuses the same caller without the capability, so neither is vacuous.
  • Both lockfiles byte-identical to main in the committed tree.

…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.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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: 026f2ae2-1d5c-4abb-9e39-f93e87af7750

📥 Commits

Reviewing files that changed from the base of the PR and between 77cd61d and 7053745.

📒 Files selected for processing (5)
  • src/main/ipc/desktop-renderer-runtime-capabilities.test.ts
  • src/main/ipc/desktop-renderer-runtime-capabilities.ts
  • src/main/ipc/runtime-agent-launch-capability.test.ts
  • src/main/ipc/runtime.ts
  • src/main/runtime/rpc/methods/agent-launch.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change adds one readonly capability list for desktop renderer runtime calls. Both unary and streaming IPC handlers use this list. The list includes agent.launch and the existing renderer capabilities. New tests verify agent-launch negotiation, duplicate-free entries, parity between dispatch paths, and exact differences from Electron remote capabilities. Documentation now distinguishes capability-less CLI callers from runtime clients.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 70537

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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… 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, No…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: enabling the desktop renderer to call agent.launch on its own main process.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog 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.

✅ 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:call and runtime:subscribe now read DESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES instead of two identical inline arrays; the new list is the previous six plus AGENT_LAUNCH_RUNTIME_CAPABILITY, with nothing dropped.
  • agent.launch admitted on the local main process — supportsAgentLaunch now 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 both toEqual assertions 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:subscribe handlers, 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 real clientKind === undefined population (the orca CLI over the runtime socket and the SSH-remote CLI bridges, which dispatch with no clientKind/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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof — local renderer agent.launch (Electron)

Scenario. Isolated hidden renderer on this worktree (window.api.app.getIdentity() → devBranch: brennanb2025/desktop-launch-capability, devRepoRoot: …/desktop-launch-capability). Direct window.api.runtime.call({ method: 'agent.launch' }) against the local main process, targeting a disposable existing workspace (disposable-repo / main) with agent grok and a draft prompt. No UI caller was used; this PR does not migrate one.

Visible result. Before launch the workspace is selected with an empty center pane and 0 terminal sessions. After the RPC, a grok tab is open, the Grok Build TUI is painted in the pane, the sidebar shows Grok - Idle, and Resource Manager reports 1 terminal session.

Backing evidence. The RPC returned ok: true in 348ms with outcome.kind: terminal, handle term_212a550a-98d6-4ed3-b0ec-2363fc7deda1, receipt user_default / terminal. It did not return agent_launch_unsupported. session.tabs.listAll then showed an active grok tab (launchAgent: grok, status: ready, same terminal handle). Renderer store activeTabId matched that tab.

Remaining gap. Remote-host admission was not re-run here (the bug was local-only refusal). Prompt was draft so Grok stayed on its welcome screen. A collapsed Playwright CDP toolbar pill is visible at the bottom of the shots; it is not product UI.

Before (empty isolated profile):

01-before-empty-profile.png

Before launch (workspace selected, no agent):

02-before-agent-launch.png

After local agent.launch:

03-after-agent-launch.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: PASS — land

No 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 7053745e79f3dec280b8d1328de2aa94e8c66d9b.

The failure mechanism is addressed at its source: local desktop IPC identified the renderer as a capability-negotiated runtime client but omitted agent.launch.v2, so the host rejected the local call while accepting the equivalent remote path. This branch gives unary and streaming local dispatch one capability declaration and adds the missing capability without weakening the host gate or changing caller, launch, persistence, remote, mobile, SSH, or platform behavior.

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:

  • 17 focused and adjacent test files, 149 tests passed
  • pnpm tc and pnpm tc:node passed
  • pnpm run check:code-quality:changed passed with zero findings
  • git diff --check passed
  • Current PR checks are green, including Windows packaging and cross-version wire compatibility
  • Merge state is clean and the worktree matches the pushed PR head

Electron validation used a hidden isolated app launched from this exact worktree. A renderer call to local agent.launch returned ok: true in 348 ms with a terminal outcome, did not return agent_launch_unsupported, rendered a real Grok tab/TUI, and produced exactly one terminal session. The app processes, disposable repo, and isolated profile were cleaned up. Screenshots and backing evidence

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.

@brennanb2025
brennanb2025 merged commit c2962a7 into main Sep 17, 2026
27 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
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