Skip to content

fix(agents): direct work-item and checks-fix launches quote for the execution host - #29716

Merged
nwparker merged 6 commits into
mainfrom
nwparker/fix-27971-start-prefill-quoting
Oct 16, 2026
Merged

nwparker merged 6 commits into
mainfrom
nwparker/fix-27971-start-prefill-quoting

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​446 $\color{#cf222e}{\Huge{\mathbf{−}}}$​160 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​286
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​222 $\color{#cf222e}{\Huge{\mathbf{−}}}$​134 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88

ELI5

When you start work from a task card, Orca types a command like claude --prefill "<issue link>" into the terminal of the machine that will run the agent. Some of those start buttons wrote that command for the computer you're sitting at rather than for the machine that runs it. So on a Windows laptop driving a Linux Orca server, bash got a PowerShell-style command ("…`n…") and sat waiting at its > continuation prompt. This PR makes those buttons ask the machine that actually runs the agent which OS it is, the same way the new-workspace composer already does.

What Changed

Before: GitHub Project rows' Start, the PR checks Fix flow, and the source-control and checks-panel "fix with AI" checks picked the OS with resolveSourceControlLaunchPlatform. That guessed from the path shape when the repo had an SSH connection, and otherwise used the client's own OS. A workspace on a paired Orca server has no SSH connection, so a Windows client always quoted for PowerShell, even when the server runs bash.

After: those paths read the OS from #27259's execution-host facts: the OS the paired server reports, the OS an SSH host reports (nested SSH is read through its server), or Linux for WSL. If the host hasn't reported its OS yet, a direct start stops before it creates a workspace and says why, the same as the composer does. source-control-launch-platform.ts is deleted, so one resolver now makes this choice.

  • launch-work-item-direct*: the preflight and the startup plan resolve from the repo's owner host (the host the worktree is created on), refined by the new worktree's own path and runtime, so a WSL worktree on a Windows server still gets Linux quoting. A local launch also passes this client's Windows shell setting, as the composer does.
  • Source-control and checks preflights use resolveRepoWorktreeLaunchPlatform, which prefers the worktree's own hostId and keeps the owning server for SSH workspaces that server projects. The launch itself still resolves the worktree's host in resolveAgentLaunchExecutionContext.
  • buildAgentDraftLaunchPlan: under cmd.exe, a multi-line draft now falls back to pasting the draft after the agent starts. cmd.exe can't quote a newline, so each one would submit the line early.

Why

#27259 fixed the composer, the new-tab launcher, and background launches, but the other callers were left as follow-ups. Reusing the same facts keeps one answer to "which OS runs this agent". The other options were patching the path-shape guess or adding another client-side heuristic, and either would drift from the host's own report again.

I read the platform from the repo or worktree owner rather than the worktree routing resolver. That resolver falls back to the focused "Active Server" for rows with no owner, and the focus-read ratchet forbids new uses of that fallback.

Linked Issue

Follow-up to #27971. Current main already fixes the Linear Start path the reporter hit: it opens the composer, which #27259 fixed. Their v1.4.227 is on the 1.4.224 release line, which doesn't contain #27259. This PR fixes the remaining direct-start paths their bundle trace pointed at.

Visual Proof

N/A. This changes the text of the terminal startup command, not the UI. The before and after commands are under Testing.

Testing

  • Unit tests: launch-work-item-direct-host-platform.test.ts covers a Windows client with a paired Linux server, a Windows client with a Linux SSH host, a Linux client with a paired Windows server, a macOS client with a Windows SSH host, Linux to Linux, Windows to Windows, local Linux, local Windows, local WSL, a WSL worktree on a Windows server, an un-hydrated new worktree, the local cmd.exe shell, and a server that hasn't reported its OS. Before the fix, 5 of them fail (Windows client with a paired Linux server, Linux client with a paired Windows server, macOS client with a Windows SSH host, the local cmd.exe shell, and the server that hasn't reported its OS). execution-host-facts.test.ts covers the preflight resolver, including the worktree host override and nested SSH. I also updated the fix-checks, owner-row, direct-launch and shared startup specs.

  • Live, isolated in throwaway /tmp and %TEMP% dirs that were removed afterwards: I took the exact startup commands the code produces and ran them with a stub claude that prints its arguments.

    • omarchy (Linux, bash 5.3, interactive): the fixed command claude '--dangerously-skip-permissions' --prefill 'Linked Linear issue: ENG-1⏎https://…' ran and passed the two-line draft as one argument. The old command (--prefill "…`n…") stopped at PS2>, swallowed the next input line, and ended with unexpected EOF while looking for matching '``. That matches the report.
    • awin-lan (Windows PowerShell 5.1): the Windows-host command (Linux client to Windows host) ran and passed the same two-line draft as one argument.
    • Not verified live: the full GUI flow of a Windows desktop client clicking Start against a paired Linux server.
  • Full local static-analysis job (lint, anti-slop, code-quality gates, typecheck, all ratchets including focus-read, localization, and generated-file checks) passed. Unit shards for src/renderer/src/lib, components/{editor,pull-request-page,right-sidebar,github-project}, hooks/composer-state, src/shared and src/main/{runtime,agent-launch} passed.

  • I manually tested these changes locally

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

Review

Codex review (gpt-6.1-sol, high), 5 rounds:

  • Fixed: WSL worktree on a Windows server, owner-row test fixture, mistyped test mock (P1), per-worktree host override, nested-SSH server owner, and multi-line cmd.exe drafts.
  • Deferred to a follow-up issue (both P2s, and both already present in fix(hosts): agent launch platform and shell come from the execution host #27259's composer path):
    • A local project's runtime-aware Windows shell (setting is wsl.exe but the project uses a windows-host runtime).
    • A paired Windows server whose project selects WSL while the worktree keeps a C:\ path.

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: SSH hosts use their reported remotePlatform, and nested SSH is read through the owning server.
  • Mixed versions: no wire change. An older server that doesn't report hostPlatform now stops a direct start with "Update the server", the same as the composer.
  • Folder workspaces: unaffected, because their composer path was already host-aware.

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 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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: 08b0ef70-2b93-4c84-9a00-24a940c463bd
📥 Commits

Reviewing files that changed from the base of the PR and between baf3ef6 and 8d63025.

📒 Files selected for processing: 2
  • src/renderer/src/lib/launch-work-item-direct-route-preparation.ts
  • src/shared/launch-parity-workspace-start-cases.test-fixture.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

Launch-platform selection now uses repository and worktree execution-host facts instead of connection and path heuristics. Direct work-item launches pass host and shell context into startup planning. Check-fix and source-control consumers accept an unknown platform. Draft prompts with multiple lines are rejected for the cmd shell.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 8d630

Direct launches to a local cmd.exe tab can reject valid cmd-style agent arguments before creating a workspace. The issue is narrow, but it remains open and should be fixed or explicitly accepted before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 27.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 24 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: direct work-item and checks-fix launches now quote commands for the execution host.
Description check Passed The description is directly related to the changeset and explains the execution-host platform resolution, shell selection, tests, and behavior for unreported host platforms.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1debe28f-1804-4ebc-9c37-8ac552a33e6e
📥 Commits

Reviewing files that changed from the base of the PR and between 40f56eb and baf3ef6.

📒 Files selected for processing: 25
  • src/renderer/src/components/editor/check-run-details-fix-with-ai.ts
  • src/renderer/src/components/pull-request-page/checks/fix-dialog.tsx
  • src/renderer/src/components/pull-request-page/checks/tab.tsx
  • src/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsx
  • src/renderer/src/components/right-sidebar/source-control/ai/controller-types.ts
  • src/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.ts
  • src/renderer/src/components/right-sidebar/source-control/ai/use-recovery-ai.ts
  • src/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.ts
  • src/renderer/src/lib/execution-host-facts.test.ts
  • src/renderer/src/lib/execution-host-facts.ts
  • src/renderer/src/lib/fix-checks-agent-launch.test.ts
  • src/renderer/src/lib/fix-checks-agent-launch.ts
  • src/renderer/src/lib/launch-agent-execution-context.ts
  • src/renderer/src/lib/launch-work-item-direct-agent-routing.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct-host-platform.test.ts
  • src/renderer/src/lib/launch-work-item-direct-owner-row.test.ts
  • src/renderer/src/lib/launch-work-item-direct-route-preparation.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/renderer/src/lib/launch-work-item-direct.ts
  • src/renderer/src/lib/source-control-launch-platform.test.ts
  • src/renderer/src/lib/source-control-launch-platform.ts
  • src/shared/tui-agent-startup-shell.spec.ts
  • src/shared/tui-agent-startup.ts
💤 Files with no reviewable changes: 2
  • src/renderer/src/lib/source-control-launch-platform.test.ts
  • src/renderer/src/lib/source-control-launch-platform.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.

Comment on lines +96 to +103
// Why: the agent runs on the repo's execution host, so its OS decides quoting, not this client's (#27971).
const repoLaunchFact = resolveRepoExecutionHostPlatform(store, repo, () => repoProjectRuntime)
if (repoLaunchFact.kind === 'withheld') {
toast.error(repoLaunchFact.reason)
return false
}
const repoLaunchHost = refineLocalLaunchPlatform(repoLaunchFact, args.launchPlatform)
const shell = repoLaunchHost.platform === 'win32' ? 'powershell' : 'posix'

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP -C5 'export function planAgentCliArgsSuffix' src

Repository: stablyai/orca

Length of output: 931


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- direct launch references ---'
rg -n -C8 -F -- 'planAgentCliArgsSuffix' src/renderer/src/lib/launch-work-item-direct.ts src || test "$?" -eq 1
printf '%s\n' '--- startup shell resolver references ---'
rg -n -C8 -F -- 'resolveExecutionHostAgentStartupShell' src || test "$?" -eq 1
printf '%s\n' '--- direct startup builder references ---'
rg -n -C8 -F -- 'buildDirectWorkItemStartup' src || test "$?" -eq 1
printf '%s\n' '--- target direct-launch block ---'
sed -n '1,220p' src/renderer/src/lib/launch-work-item-direct.ts
printf '%s\n' '--- shared suffix planner ---'
sed -n '340,430p' src/shared/tui-agent-startup-shell.ts

Repository: stablyai/orca

Length of output: 40398


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- resolver declaration and uses ---'
rg -n -C12 -F -- 'resolveExecutionHostAgentStartupShell' src || test "$?" -eq 1
printf '%s\n' '--- Windows shell resolver declaration and uses ---'
rg -n -C12 -F -- 'resolveLocalWindowsAgentStartupShell' src/shared src/renderer/src/lib || test "$?" -eq 1
printf '%s\n' '--- direct startup plan and shell inputs ---'
rg -n -C15 -F -- 'buildDirectWorkItemAgentStartupPlan' src/renderer/src/lib/launch-work-item-direct-agent.ts src/renderer/src/lib/launch-work-item-direct-route-preparation.ts src/renderer/src/lib/launch-work-item-direct.ts || test "$?" -eq 1
printf '%s\n' '--- direct startup command construction ---'
rg -n -C15 -F -- 'buildDirectWorkItemStartup' src/renderer/src/lib src/shared || test "$?" -eq 1
printf '%s\n' '--- terminalWindowsShell settings declarations ---'
rg -n -C8 -F -- 'terminalWindowsShell' src/shared src/renderer/src/lib | head -240

Repository: stablyai/orca

Length of output: 42351


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- direct startup routing block ---'
sed -n '1,95p' src/renderer/src/lib/launch-work-item-direct-agent-routing.ts
printf '%s\n' '--- direct launch preparation call ---'
rg -n -C18 -F -- 'buildDirectWorkItemStartup({' src/renderer/src/lib/launch-work-item-direct.ts src/renderer/src/lib/launch-work-item-direct-route-preparation.ts src/renderer/src/lib/launch-work-item-direct-agent-routing.ts || test "$?" -eq 1
printf '%s\n' '--- resolver implementation ---'
sed -n '180,225p' src/renderer/src/lib/execution-host-facts.ts
printf '%s\n' '--- worktree creation and preparation ordering ---'
sed -n '95,145p' src/renderer/src/lib/launch-work-item-direct.ts
sed -n '200,260p' src/renderer/src/lib/launch-work-item-direct.ts

Repository: stablyai/orca

Length of output: 13946


Validate saved agent args with the resolved startup shell.

For a local Windows launch with terminalWindowsShell: 'cmd.exe', the preflight currently validates agentArgs with PowerShell quoting. The later startup plan uses cmd quoting, so incompatible arguments can pass preflight, create the worktree, and fail during startup.

🐛 Suggested fix
 import {
   refineLocalLaunchPlatform,
+  resolveExecutionHostAgentStartupShell,
   resolveRepoExecutionHostPlatform
 } from '@/lib/execution-host-facts'
@@
-  const shell = repoLaunchHost.platform === 'win32' ? 'powershell' : 'posix'
+  const shell =
+    resolveExecutionHostAgentStartupShell(repoLaunchHost, settings?.terminalWindowsShell) ??
+    (repoLaunchHost.platform === 'win32' ? 'powershell' : 'posix')

…xecution host

GitHub Project Start, PR checks Fix and the source-control/checks preflights
resolved their launch platform from the client OS whenever the repo had no SSH
connection, so a Windows client starting work on a paired Linux Orca server sent
a PowerShell-quoted --prefill to bash. They now read the execution-host facts
#27259 introduced (server-reported OS, SSH-reported OS, WSL), and the
path-shape resolver is removed so one helper decides.
…epo owner

Review follow-up: a WSL worktree on a paired Windows server quotes for Linux,
the owner-row fixture reports its server OS, and the source-control preflights
read the repo owner rather than the focus-defaulted worktree route.
Review follow-up: a per-worktree host outranks the repo owner, the host-platform
test's mutable client platform is typed, and the source-control panel fixture
carries the host slices.
…tate

Review follow-up: the preflight resolver keeps the runtime owner for nested SSH
worktrees instead of reading this client's own SSH connections.
Review follow-up: now that direct launches pass the local Windows shell, a
multi-line --prefill under cmd.exe would submit at its first newline.
A project's Windows runtime can override the terminal setting (WSL setting,
Windows runtime spawns PowerShell), so resolve the tab's effective shell before
quoting. The cmd.exe parity row now expects cmd quoting.
@nwparker
nwparker force-pushed the nwparker/fix-27971-start-prefill-quoting branch from baf3ef6 to 8d63025 Compare October 16, 2026 15:23
@nwparker

Copy link
Copy Markdown
Contributor Author

Update (8d63025): unit shard 5 found that launch-parity-window-tab pins the shell a direct start's tab really spawns. Direct launches now quote for that shell (resolveLocalWindowsTerminalShellOverrideForTab), so the first deferred P2 (terminal setting wsl.exe with a windows-host runtime) is fixed for direct starts. The parity row for cmd.exe now expects cmd quoting; that is the intended behaviour change. #29718 still tracks the composer and the Windows-server WSL case.

I rebased onto main and re-ran full static analysis plus the renderer lib, components, hooks, shared and main ipc/runtime/agent-launch shards; all pass.

@nwparker
nwparker merged commit 8fad958 into main Oct 16, 2026
54 of 56 checks passed
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