Skip to content

[P2] fix(skills): keep the npx preflight in the forced-PowerShell setup terminal on Windows - #11814

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-skill-setup-terminal-npx-preflight
Jul 31, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-skill-setup-terminal-npx-preflight

Conversation

@nwparker

@nwparker nwparker commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-on to #11599, found by the v1.4.163-rc.1..v1.4.163-rc.3 production 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):

// Why: generated skill commands are PowerShell/cmd syntax, so a POSIX-family
// Windows shell (wsl.exe, Git Bash) would mangle the wrapper we hand it.
return resolveWindowsShellStartupFamily(settings?.terminalWindowsShell) === 'posix'
  ? 'powershell.exe'
  : undefined

So: user's shell is POSIX-family → force the setup terminal onto PowerShell.

Guard 2 — #11599 drops the npx preflight (CliSkillRuntimeSetup.tsx:143):

// Why: the copied command lands in the user's configured shell, and MSYS
// shells rewrite cmd.exe's leading /d /s /c switches into drive paths,
// starting an interactive cmd session instead of running the payload.
isPosixFamilyWindowsShellConfigured() ||

So: user's shell is POSIX-family → strip the cmd.exe npx 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 on PATH, the user sees PowerShell's raw

The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program.

instead 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 — new SkillCommandTarget = 'copied-command' | 'orca-setup-terminal'.
  • CliSkillRuntimeSetup.tsx:181 — the POSIX bypass is narrowed to target === '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 exported buildSkillSetupTerminalCommand(copiedCommand, terminalShellOverride, currentPlatform?). It re-applies the preflight only when resolveWindowsShellStartupFamily(terminalShellOverride) === 'powershell' — that is, only when the override actually resolved to a PowerShell-family shell. It does not assume; it checks.
  • AgentSkillSetupPanel.tsx:393 and feature-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 wrapWindowsSkillCommandWithNpxPrerequisite are untouched: non-Windows, a focused remote runtime environment, and a non-npx skills add|update command still bypass the wrapper exactly as before.

Left alone deliberately: FeatureSetupInlineTerminal passes no shell override, so isSetupTerminalForcedToPowerShell returns false and it correctly keeps the bare command. WSL runtimes take an earlier return in buildSkillCommandForRuntime and 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 cmd syntax, which Git Bash mangles — so Orca has two separate protections for those users:

  1. When Orca opens its own setup terminal, it quietly switches to PowerShell so the syntax works.
  2. When Orca gives you the command to copy and paste, it removes the wrapper so it doesn't break in your Git Bash window.

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 npx command 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:364 and copyActiveCommand at :186 still read openTerminalCommand, and only the command prop handed to OnboardingInlineCommandTerminal at :394 is wrapped. What changed is the string executed inside the spawned PTY.

Proof of fix

With CliSkillRuntimeSetup.tsx, AgentSkillSetupPanel.tsx and CliSkillSetupTerminal.tsx reverted to origin/main and the tests kept:

 × keeps the npx preflight in the PowerShell-forced setup terminal
 × does not re-wrap the setup terminal command when no shell override applies
 × leaves WSL and non-Windows setup terminal commands untouched
 × routes the combined feature-tip install through runtime command setup

TypeError: buildSkillSetupTerminalCommand is not a function
AssertionError: expected 'import { Copy } from \'lucide-react\'…' to contain 'buildSkillSetupTerminalCommand('

 Test Files  2 failed (2)
      Tests  4 failed | 24 passed (28)

With the fix restored: 3 files / 30 tests passed.

New coverage in CliSkillRuntimeSetup.test.tsx:

  • Windows + PowerShell-resolved override → the setup-terminal command is wrapped with the where.exe npx preflight.
  • No shell override → command passes through untouched (the non-POSIX Windows user already got the wrapper from buildSkillCommandForRuntime; re-wrapping would double it).
  • WSL and non-Windows → untouched.
  • The copied command on a POSIX-family Windows shell is still bare, i.e. fix(settings): keep copied skill commands bare for POSIX-family Windows shells #11599 is not regressed.

agent-skill-installed-command-callers.test.ts is 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

  • Targeted suite at branch tip: 3 files / 30 tests passed.
  • Full desktop suite on the merged tree containing all eight scan fixes: 359 files / 3830 tests passed.
  • npx oxfmt --check and npx oxlint clean.
  • FloatingTerminalOrchestrationDialog.freshness.test.tsx changed by exactly one line: its vi.mock factory for CliSkillRuntimeSetup needed the newly-exported symbol. No assertion changed.
  • fix(settings): keep copied skill commands bare for POSIX-family Windows shells #11599's own scenario is explicitly re-asserted rather than assumed: the copied command on a POSIX-family Windows shell is still unwrapped.

Testing

  • pnpm lint — clean (oxlint, type-aware audit, reliability gates, max-lines ratchet, localization catalog/extraction/coverage); oxfmt --check clean via lint-staged
  • pnpm 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 change
  • Added or updated high-quality tests that would catch regressions

AI Review Report

Reviewed by Claude Opus 5 as part of a 45-agent release scan with adversarial refutation. Risks checked:

  • Cross-platform — the core of this PR. The change is Windows-only by construction: buildSkillSetupTerminalCommand returns early unless the shell override resolves to a PowerShell family, and getProjectAgentSkillTerminalShellOverride returns undefined for every non-win32 platform. 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.
  • Double-wrapping. The main risk of the fix. A non-POSIX Windows user already receives a wrapped command from buildSkillCommandForRuntime; isSetupTerminalForcedToPowerShell returns false for them (no override is set), so no second wrap occurs. Pinned by a test.
  • SSH / remote runtime. isRemoteRuntimeEnvironmentFocused() is unchanged and still short-circuits the wrapper, so a Windows client never hands a cmd.exe command to a remote host.
  • Provider neutrality: not applicable; no git or provider code touched.

Security Audit

  • No new dependencies, no lockfile change, no install hooks.
  • Command construction is the relevant surface. No new command text is introduced by this PR — wrapWindowsSkillCommandWithNpxPrerequisite and its cmd.exe /d /s /c "…" payload are byte-for-byte unchanged from origin/main. The change is purely which of two existing strings a given call site receives.
  • The regex gate /^npx\s+skills\s+(?:add|update)\b/i still runs before any wrapping, so only Orca's own generated skill-install commands are ever wrapped.
  • The command being wrapped is built by buildAgentFeatureSkillInstallCommand from Orca's own constants, not from user free-text.
  • No auth, secrets, path handling, or IPC changes.

Notes

  • The bug is invisible on macOS and Linux, and invisible on Windows unless the user has explicitly configured Git Bash or WSL as their terminal shell and npx is missing from PATH — which is why it shipped.
  • buildSkillSetupTerminalCommand checks the resolved shell family rather than trusting that the override is always powershell.exe. Today getProjectAgentSkillTerminalShellOverride only 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 🐋

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 71a0592f-7c70-4d4a-b852-7bdf84636309

📥 Commits

Reviewing files that changed from the base of the PR and between e698241 and 0cd12e1.

📒 Files selected for processing (6)
  • src/renderer/src/components/feature-tips/CliSkillSetupTerminal.tsx
  • src/renderer/src/components/floating-terminal/FloatingTerminalOrchestrationDialog.freshness.test.tsx
  • src/renderer/src/components/settings/AgentSkillSetupPanel.tsx
  • src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx
  • src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx
  • src/renderer/src/components/settings/agent-skill-installed-command-callers.test.ts

📝 Walkthrough

Walkthrough

The change adds buildSkillSetupTerminalCommand to adapt commands for setup-terminal execution. Windows commands receive the npx prerequisite when the terminal uses PowerShell, without duplicate wrapping. Displayed and copied commands remain unchanged. Feature-tip and settings terminals now execute the adapted command. Tests cover shell overrides, WSL, non-Windows platforms, and existing wrappers.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the Windows forced-PowerShell npx preflight fix.
Description check ✅ Passed The description covers the required sections, explains the change, documents testing, and includes cross-platform AI review and security audit details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 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.

@nwparker
nwparker merged commit ea40c87 into main Jul 31, 2026
42 checks passed
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

This 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 where.exe npx error-guidance wrapper in the very terminal that was already safe to use it.

  • Introduces SkillCommandTarget = 'copied-command' | 'orca-setup-terminal' and threads it through wrapWindowsSkillCommandWithNpxPrerequisite, so the POSIX bypass fires only on the clipboard path.
  • Adds buildSkillSetupTerminalCommand(copiedCommand, terminalShellOverride) which re-applies the preflight when resolveWindowsShellStartupFamily(terminalShellOverride) === 'powershell', and updates both PTY call sites while leaving the display code block and copy button on the bare command.
  • Double-wrapping for cmd.exe users is prevented naturally by the existing regex guard, and the test suite explicitly pins the no-override and WSL pass-through cases.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "[P2] fix(skills): keep the npx preflight..." | Re-trigger Greptile

@nwparker
nwparker deleted the nwparker/fix-skill-setup-terminal-npx-preflight branch July 31, 2026 21:05
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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