Repository navigation
fix(agents): direct work-item and checks-fix launches quote for the execution host - #29716
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1debe28f-1804-4ebc-9c37-8ac552a33e6e
📒 Files selected for processing: 25
src/renderer/src/components/editor/check-run-details-fix-with-ai.tssrc/renderer/src/components/pull-request-page/checks/fix-dialog.tsxsrc/renderer/src/components/pull-request-page/checks/tab.tsxsrc/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsxsrc/renderer/src/components/right-sidebar/source-control/ai/controller-types.tssrc/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.tssrc/renderer/src/components/right-sidebar/source-control/ai/use-recovery-ai.tssrc/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.tssrc/renderer/src/lib/execution-host-facts.test.tssrc/renderer/src/lib/execution-host-facts.tssrc/renderer/src/lib/fix-checks-agent-launch.test.tssrc/renderer/src/lib/fix-checks-agent-launch.tssrc/renderer/src/lib/launch-agent-execution-context.tssrc/renderer/src/lib/launch-work-item-direct-agent-routing.tssrc/renderer/src/lib/launch-work-item-direct-agent.tssrc/renderer/src/lib/launch-work-item-direct-host-platform.test.tssrc/renderer/src/lib/launch-work-item-direct-owner-row.test.tssrc/renderer/src/lib/launch-work-item-direct-route-preparation.tssrc/renderer/src/lib/launch-work-item-direct.test.tssrc/renderer/src/lib/launch-work-item-direct.tssrc/renderer/src/lib/source-control-launch-platform.test.tssrc/renderer/src/lib/source-control-launch-platform.tssrc/shared/tui-agent-startup-shell.spec.tssrc/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.
| // 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' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C5 'export function planAgentCliArgsSuffix' srcRepository: 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.tsRepository: 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 -240Repository: 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.tsRepository: 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.
baf3ef6 to
8d63025
Compare
|
Update (8d63025): unit shard 5 found that 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. |
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.tsis 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.resolveRepoWorktreeLaunchPlatform, which prefers the worktree's ownhostIdand keeps the owning server for SSH workspaces that server projects. The launch itself still resolves the worktree's host inresolveAgentLaunchExecutionContext.buildAgentDraftLaunchPlan: undercmd.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.tscovers 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 localcmd.exeshell, 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 localcmd.exeshell, and the server that hasn't reported its OS).execution-host-facts.test.tscovers 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
/tmpand%TEMP%dirs that were removed afterwards: I took the exact startup commands the code produces and ran them with a stubclaudethat prints its arguments.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 atPS2>, swallowed the next input line, and ended withunexpected EOF while looking for matching'``. That matches the report.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/sharedandsrc/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:
cmd.exedrafts.wsl.exebut the project uses awindows-hostruntime).C:\path.Agent skill upstream boundary
Notes
remotePlatform, and nested SSH is read through the owning server.hostPlatformnow stops a direct start with "Update the server", the same as the composer.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)