Repository navigation
[P2] fix(skills): keep the npx preflight in the forced-PowerShell setup terminal on Windows - #11814
Conversation
…up terminal on Windows Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe change adds 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
Greptile SummaryThis PR fixes a guard collision on Windows where two independently-correct conditions were mutually cancelling: the setup terminal's shell being forced to PowerShell (guard 1) and the npx preflight being stripped for POSIX-family shells (guard 2) were both reading the same setting, so Git Bash / WSL users lost the
Confidence Score: 5/5Safe to merge — the change is Windows-only by construction, the two affected PTY call sites are updated symmetrically, and the copy/display path is untouched. The fix is narrowly scoped: one new exported function, two updated call sites, and a one-character guard change in an existing private function. All four Windows shell families are covered by tests, double-wrapping is provably prevented by the regex guard and pinned by a test, WSL and non-Windows code paths are verified to pass through unchanged, and the source-guard test encodes the copy/execute split at CI so a future caller cannot silently reintroduce the bug. Files Needing Attention: No files require special attention — the logic is self-contained in CliSkillRuntimeSetup.tsx and both call sites apply it identically.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx | Core fix: introduces SkillCommandTarget discriminant and buildSkillSetupTerminalCommand to re-apply the cmd.exe npx preflight only when the setup terminal is force-switched to PowerShell; the POSIX bypass in wrapWindowsSkillCommandWithNpxPrerequisite is correctly narrowed to the copied-command path. |
| src/renderer/src/components/settings/AgentSkillSetupPanel.tsx | Call site updated to pass the wrapped command to OnboardingInlineCommandTerminal while keeping the bare openTerminalCommand for the copy button and on-screen display; the split is correct. |
| src/renderer/src/components/feature-tips/CliSkillSetupTerminal.tsx | Analogous call-site fix: setupTerminalCommand is computed once and passed to the PTY; skillCommand continues to drive the display code block and clipboard write. |
| src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx | Three new tests cover the exact bug scenario (POSIX shell + PowerShell override yields preflight preserved), no-override pass-through, double-wrap prevention, and WSL/non-Windows unchanged; all use try/finally for store isolation. |
| src/renderer/src/components/settings/agent-skill-installed-command-callers.test.ts | Source-guard test updated to pin that CliSkillSetupTerminal uses writeClipboardText(skillCommand) for the copy path and buildSkillSetupTerminalCommand + command={setupTerminalCommand} for the PTY path; encodes the copy/execute split at CI. |
| src/renderer/src/components/floating-terminal/FloatingTerminalOrchestrationDialog.freshness.test.tsx | Minimal one-line change to add buildSkillSetupTerminalCommand to the vi.mock factory; no assertion changed. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Skill install needed] --> B[buildSkillCommandForRuntime]
B --> C{WSL runtime?}
C -- Yes --> D["wsl.exe sh -c (PowerShell-safe)"]
C -- No --> E{POSIX shell + copied-command?}
E -- Yes --> F[Bare npx command]
E -- No --> G[cmd.exe npx preflight wrapper]
F --> H[Display / Clipboard]
G --> H
F --> I[buildSkillSetupTerminalCommand]
G --> I
I --> J{terminalShellOverride resolves to powershell?}
J -- No --> K[Pass through unchanged]
J -- Yes --> L{Command already wrapped?}
L -- Yes --> M[Return unchanged]
L -- No --> N[Re-apply cmd.exe npx preflight]
N --> O[PTY]
K --> O
M --> O
D --> O
Reviews (1): Last reviewed commit: "[P2] fix(skills): keep the npx preflight..." | Re-trigger Greptile
…up terminal on Windows (stablyai#11814) Co-authored-by: Orca <[email protected]>
Summary
Follow-on to #11599, found by the
v1.4.163-rc.1..v1.4.163-rc.3production release scan.Two guards fire on the same condition and cancel each other out, so Windows users with Git Bash or WSL configured as their terminal shell lose the npx preflight in Orca's own skill-setup terminal.
The collision
Guard 1 — Orca overrides the setup terminal's shell (
src/renderer/src/lib/project-skill-runtime.ts:41):So: user's shell is POSIX-family → force the setup terminal onto PowerShell.
Guard 2 — #11599 drops the npx preflight (
CliSkillRuntimeSetup.tsx:143):So: user's shell is POSIX-family → strip the
cmd.exenpx preflight wrapper.Both read the same setting. On a Windows box configured for Git Bash, guard 1 says "this command will run in PowerShell, not their shell" and guard 2 says "this command will run in their shell, so don't wrap it". Guard 2's stated premise — "the copied command lands in the user's configured shell" — is true for the clipboard, and false for the terminal Orca spawns itself, precisely because guard 1 just redirected it.
Result: clicking "Set up in terminal" runs a bare
npx skills add …in PowerShell. If Node/npx is not onPATH, the user sees PowerShell's rawinstead of #11599's guidance ("Install Node.js LTS from https://nodejs.org/ … then close this terminal and start skill setup again — a new terminal picks up the updated PATH"). The users who hit this are exactly the ones most likely to have a PATH that differs between shells.
Fix
The wrapper now knows where the command is going, instead of assuming.
CliSkillRuntimeSetup.tsx:134— newSkillCommandTarget = 'copied-command' | 'orca-setup-terminal'.CliSkillRuntimeSetup.tsx:181— the POSIX bypass is narrowed totarget === 'copied-command' && isPosixFamilyWindowsShellConfigured(). fix(settings): keep copied skill commands bare for POSIX-family Windows shells #11599's actual fix is fully preserved for the clipboard path, which is what it was about.CliSkillRuntimeSetup.tsx:141— new exportedbuildSkillSetupTerminalCommand(copiedCommand, terminalShellOverride, currentPlatform?). It re-applies the preflight only whenresolveWindowsShellStartupFamily(terminalShellOverride) === 'powershell'— that is, only when the override actually resolved to a PowerShell-family shell. It does not assume; it checks.AgentSkillSetupPanel.tsx:393andfeature-tips/CliSkillSetupTerminal.tsx:25— the spawned terminal gets the wrapped command. The<code>block shown on screen and the "Copy" button both keep the bare command.All the other conditions in
wrapWindowsSkillCommandWithNpxPrerequisiteare untouched: non-Windows, a focused remote runtime environment, and a non-npx skills add|updatecommand still bypass the wrapper exactly as before.Left alone deliberately:
FeatureSetupInlineTerminalpasses no shell override, soisSetupTerminalForcedToPowerShellreturns false and it correctly keeps the bare command. WSL runtimes take an earlier return inbuildSkillCommandForRuntimeand are unaffected.ELI5
Orca can install a "skill" for you by running one command. On Windows there is a wrinkle: if that command can't find
npx, the error you get is cryptic, so Orca wraps the command in a little check that says "npx is missing — here's how to install Node.js" instead.Some Windows users run Git Bash or WSL as their terminal. That wrapper is written in Windows
cmdsyntax, which Git Bash mangles — so Orca has two separate protections for those users:The bug is that protection 2 was also being applied to the terminal from protection 1. Orca switched to PowerShell to make the wrapper safe to use, and then removed the wrapper anyway. So Git Bash users got the raw
npxcommand in PowerShell with no safety net, and if npx wasn't installed they saw PowerShell's unhelpful "'npx' is not recognized" instead of the install instructions.Now Orca tells the two paths apart: the thing you copy stays plain, and the thing Orca runs itself keeps the safety net.
Screenshots
No visual change. The
<code>block rendered on screen and the "Copy" button both continue to show and copy the bare command — verified in the diff:AgentSkillSetupPanel.tsx:364andcopyActiveCommandat:186still readopenTerminalCommand, and only thecommandprop handed toOnboardingInlineCommandTerminalat:394is wrapped. What changed is the string executed inside the spawned PTY.Proof of fix
With
CliSkillRuntimeSetup.tsx,AgentSkillSetupPanel.tsxandCliSkillSetupTerminal.tsxreverted toorigin/mainand the tests kept:With the fix restored: 3 files / 30 tests passed.
New coverage in
CliSkillRuntimeSetup.test.tsx:where.exe npxpreflight.buildSkillCommandForRuntime; re-wrapping would double it).agent-skill-installed-command-callers.test.tsis a source-guard test that pins which call sites use which builder; it now encodes the copy/execute split, so a future caller that runs the bare command in a forced-PowerShell terminal fails CI.Proof of no regression
npx oxfmt --checkandnpx oxlintclean.FloatingTerminalOrchestrationDialog.freshness.test.tsxchanged by exactly one line: itsvi.mockfactory forCliSkillRuntimeSetupneeded the newly-exported symbol. No assertion changed.Testing
pnpm lint— clean (oxlint, type-aware audit, reliability gates, max-lines ratchet, localization catalog/extraction/coverage);oxfmt --checkclean via lint-stagedpnpm typecheck— clean (tsc: node + cli + web)pnpm test(targeted at tip + full desktop suite on the combined tree)pnpm build— not run; no build-graph, packaging, or dependency changeAI Review Report
Reviewed by Claude Opus 5 as part of a 45-agent release scan with adversarial refutation. Risks checked:
buildSkillSetupTerminalCommandreturns early unless the shell override resolves to a PowerShell family, andgetProjectAgentSkillTerminalShellOverridereturnsundefinedfor every non-win32platform. macOS and Linux take the identical code path they did before. Verified all four Windows shell families (PowerShell, cmd, Git Bash/MSYS, wsl.exe) plus the WSL-runtime and remote-runtime branches.buildSkillCommandForRuntime;isSetupTerminalForcedToPowerShellreturns false for them (no override is set), so no second wrap occurs. Pinned by a test.isRemoteRuntimeEnvironmentFocused()is unchanged and still short-circuits the wrapper, so a Windows client never hands acmd.execommand to a remote host.Security Audit
wrapWindowsSkillCommandWithNpxPrerequisiteand itscmd.exe /d /s /c "…"payload are byte-for-byte unchanged fromorigin/main. The change is purely which of two existing strings a given call site receives./^npx\s+skills\s+(?:add|update)\b/istill runs before any wrapping, so only Orca's own generated skill-install commands are ever wrapped.buildAgentFeatureSkillInstallCommandfrom Orca's own constants, not from user free-text.Notes
buildSkillSetupTerminalCommandchecks the resolved shell family rather than trusting that the override is alwayspowershell.exe. TodaygetProjectAgentSkillTerminalShellOverrideonly ever returns'powershell.exe', but tying the behaviour to the resolved family means a future override value cannot silently reintroduce this bug.Made with Orca 🐋