Repository navigation
Preserve desktop startup input in host agent launches - #26364
brennanb2025 wants to merge 15 commits into
Conversation
# Conflicts: # src/main/agent-launch/agent-launch-executor.ts # src/main/agent-launch/agent-launch-surface-factories.ts # src/main/runtime/agent-launch-follow-up-record.test.ts # src/main/runtime/rpc/methods/agent-launch-replay.ts # src/main/runtime/rpc/methods/agent-launch-surfaces.ts # src/main/runtime/rpc/methods/agent-launch-terminal-prompt.ts
No desktop new-tab caller sends session options, since main keeps remembered model and effort off terminal launches. The launch contract goes back to string-only options, the startup planner stops reading a desktop options field, and a follow-up test that repeated the base's own case is removed.
zod keeps running refinements after the agent check fails, so the desktop prompt check looked up the unknown agent's config and threw. The caller got internal_error instead of the validation issue.
Only the desktop window's own connection may send a desktop new-tab prompt, so publishing agent.launch.desktop-new-tab.v1 to every paired, mobile and remote client advertised something each of them is refused. The desktop renderer already names it on its own IPC connection, which is what the host checks. Renamed the constant to the client-capability form; the wire string is unchanged. Also drops the check of the host's own constant list, which was always true.
agent_launch_desktop_new_tab_unsupported was not on the runtime error pass-through list, so a refused caller saw a generic runtime_error.
The desktop writer pastes the prompt itself, so the full bracketed-paste copy built beforehand (up to 16 MiB, on the main process) was only used for the byte count. The writer now counts the bytes it actually wrote. The bytes sent to the terminal are unchanged.
Review, readiness and QA summary (head
|
Restack onto the final #26173 (head
|
|
Closing this as superseded. Brennan asked for strict parity first ("just parity for the migration to agent.launch please and then we can do bug fixes after"), and #26168/#26173, which this was stacked on, are being closed for the same reason. At strict parity this PR isn't needed. It taught the host to type the first prompt the way the window does. In the rebuilt #26489, the window keeps delivering prompts exactly as main does, and only plain no-prompt new tabs start through the host's existing The old head is kept on this branch ( Author: @BrennanKB5 |
ELI5
When you start an agent from the "+" menu or Quick Launch, the window itself types the startup command and your prompt into the new terminal. The AI buttons already work differently: they ask the computer that runs the workspace (the "host", which may be this Mac or an SSH server) to start the agent. We want every launch to go through the host. But the host types prompts a little differently than the window does, so moving the menus over as-is would change what reaches the agent. This PR teaches the host to start a new-tab agent exactly the way the window does today. Nothing you see changes in this PR; the next PR (#26489) moves the menus onto it.
What Changed
Problem. The window and the host each had their own way to start an agent and deliver the first prompt: different startup command rules, different handling of drafts that must not be submitted, different timing for Enter, and no protection against typing a prompt into an agent's startup trust/security dialog in some cases. Moving the "+" menus to the host without closing those gaps would have changed prompt bytes, editable drafts and Enter behaviour for users.
User-facing change. None in this PR. It adds a capability the next PR uses. Existing callers keep their current behaviour.
Mechanism.
src/shared, unchanged), so agent arguments, environment and quoting (including Windows shells) match.agent_launch_desktop_new_tab_unsupported) that now passes through to the caller.Base. Stacked on #26173. That base removed restart re-delivery of prompts and made desktop launches wait the same per-agent time as the window's paste. Like every launch prompt on that base, this one is never re-sent after a restart; replay never sends it twice.
Why
One owner (the host) should start agents for every caller, local and SSH, so the "+" menus can stop running their own startup queue. Reusing the window's existing planner and byte rules, instead of writing new ones, is what keeps the move invisible to users. The common pattern is a single host-side launch path with the client only placing the tab; this PR gets the host to parity before any caller moves.
Alternatives considered: moving the menus first and fixing differences after (would ship changed prompt bytes and Enter timing); a second, desktop-only launch RPC (two launch paths to keep in sync). A second prompt writer next to the host's existing one is accepted for parity now; merging the two writers is the planned follow-up.
Linked Issue
Launch unification, after #26168 and #26173. Targets #26173's branch until it merges. Next: #26489.
Visual Proof
N/A: no UI or behaviour change in this PR (no caller uses the new capability until #26489). Runtime evidence for the migrated menus, which exercise this code, is on #26489.
Testing
Automated: 843 tests across 50 named files (this PR's own plus the neighbouring launch tests) cover startup commands and environment, per-write bytes and the separate Enter, empty/native/pasted drafts, the original-terminal fence, SSH transport backpressure (real async multiplexer), replay, follow-ups, capability negotiation over local IPC, and the validation/refusal fixes. Each fix from review was checked by removing it and seeing its test fail, then restoring it.
tc-gate pnpm tc:node,tc:webandtc:clipass; all 22orca-ci-checkspass; CI green atfac392b7af3(one Windows packaging test in a file this PR doesn't touch timed out once and passed on rerun).Not verified: a real Windows or WSL machine, and a real (non-stand-in) agent consuming the prompt.
Review
Adversarial review rounds plus a full readiness checklist (SSH/network, crash and retry, security, performance, functional, compatibility, cross-platform, code organisation). Fixed during review: follow-up settlement ownership, SSH write backpressure, a write-reservation race, a validation crash on an unknown agent, the capability being advertised to remote clients that are always refused, the refusal code being hidden, and an unused full copy of large prompts. No open P0/P1/P2. Deferred (P3): the per-chunk "agent still in front" check costs one terminal round trip per 16 KiB chunk for prompts over 64 KiB (most noticeable on Windows); it goes away when the two prompt writers merge.
Agent skill upstream boundary
Notes
Author: @BrennanKB5.
Checklist
N/Avisual proof with reason