Repository navigation
fix(settings): keep copied skill commands bare for POSIX-family Windows shells - #11599
Conversation
📝 WalkthroughWalkthroughWindows skill command generation now detects whether the configured Windows terminal shell is POSIX-family and avoids wrapping commands with 🚥 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx (1)
254-261: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover every supported POSIX shell alias.
resolveWindowsShellStartupFamilyalso classifieswsl.exe,wsl, and barebash.exeas POSIX-family, but this test covers onlygit-bashand onebash.exepath. Add the remaining aliases so regressions for those configurations cannot reintroduce thecmd.exewrapper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fa407dd4-5437-4dfd-9df2-4eefc6e0c0c7
📒 Files selected for processing (2)
src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsxsrc/renderer/src/components/settings/CliSkillRuntimeSetup.tsx
Greptile SummaryThis PR fixes a regression from #10453 where the cmd.exe-wrapped skill install/update commands placed on the clipboard would break in POSIX-family Windows shells (Git Bash,
Confidence Score: 5/5Safe to merge. The change is narrowly scoped to one cohort (POSIX-family Windows shells) and removes a wrapper that was actively breaking clipboard output for those users, restoring the pre-regression baseline. The fix is a small, well-reasoned guard that delegates to an existing, already-tested classification helper. Null settings are handled safely via optional chaining, defaulting to the PowerShell family (wrapper retained). The update-to-add normalization still runs before the guard fires. PowerShell, pwsh, and cmd.exe users are byte-identical to before the PR. New tests were written red-first and cover the positive POSIX case, a full bash.exe path, and the cmd.exe pin. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx | Adds isPosixFamilyWindowsShellConfigured() helper and inserts it as an early-return guard in wrapWindowsSkillCommandWithNpxPrerequisite; the null-safe settings?.terminalWindowsShell lookup correctly defaults to powershell family (wrapper retained) when settings are not yet hydrated. |
| src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx | Two new red-first tests added: one verifies bare output for git-bash and bash.exe-path shells (plus a cmd.exe pin that the wrapper is retained), another confirms the update to add normalization still applies before the wrapper is skipped for POSIX-family shells. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[buildSkillCommandForRuntime] --> B[normalizeWindowsSkillUpdateCommand\nupdate to add on win32]
B --> C{runtime is wsl?}
C -- Yes --> D[Build wsl.exe PowerShell wrapper]
C -- No --> E[wrapWindowsSkillCommandWithNpxPrerequisite]
E --> F{not win32?}
F -- Yes --> G[Return bare command]
F -- No --> H{isRemoteRuntimeEnvironmentFocused?}
H -- Yes --> G
H -- No --> I{isPosixFamilyWindowsShellConfigured?\ngit-bash or bash.exe or wsl.exe}
I -- Yes --> G[Return bare npx command]
I -- No --> J{matches npx skills add or update?}
J -- No --> G
J -- Yes --> K[Return cmd.exe /d /s /c wrapper\nwith where.exe npx preflight]
Reviews (3): Last reviewed commit: "fix(settings): keep copied skill command..." | Re-trigger Greptile
…ws shells The cmd.exe npx preflight added in #10453 silently no-ops when pasted into Git Bash: MSYS rewrites the leading /d /s /c switches into drive paths, so cmd.exe starts an interactive session and never runs the payload. Skip the wrapper when the configured Windows shell resolves to the posix family, matching the shell the copied command actually lands in.
cc1a972 to
381cb84
Compare
…ws shells (stablyai#11599) The cmd.exe npx preflight added in stablyai#10453 silently no-ops when pasted into Git Bash: MSYS rewrites the leading /d /s /c switches into drive paths, so cmd.exe starts an interactive session and never runs the payload. Skip the wrapper when the configured Windows shell resolves to the posix family, matching the shell the copied command actually lands in.
Summary
Addresses the regression reported in #11431 (introduced by #10453).
#10453 wraps Windows-native skill install/update commands in
cmd.exe /d /s /c "…"to preflightnpx. The spawned-terminal path is guarded (getProjectAgentSkillTerminalShellOverrideforcespowershell.exefor POSIX-family shells), but the same wrapped string is also placed on the clipboard by four call sites — and a paste target can't be overridden. In Git Bash, MSYS rewrites the leading/d /s /cswitches intoD:/ S:/ C:/drive paths, so cmd.exe never receives/c, starts an interactive session, and exits 0 without ever running the payload (measured matrix in #11431).This PR skips the cmd.exe wrapper in
wrapWindowsSkillCommandWithNpxPrerequisitewhenresolveWindowsShellStartupFamily(settings.terminalWindowsShell) === 'posix'(Git Bash,bash.exe,wsl.exe), returning the barenpx skills add … --globalcommand exactly asmaindid before #10453. The store-read mirrors the existingisRemoteRuntimeEnvironmentFocused()pattern in the same function.Behavior after the fix, for a POSIX-family-configured Windows user:
npx …— works when pasted into Git Bash (and still works in PowerShell/cmd if pasted there instead).powershell.exeby the existing fix(settings): guide Windows skill setup when npx is missing #10453 guard, now running the bare command — the same pre-fix(settings): guide Windows skill setup when npx is missing #10453 behavior. The npx-missing guidance is intentionally given up for this cohort; a silent no-op is strictly worse than the pre-fix(settings): guide Windows skill setup when npx is missing #10453 baseline of a shell "command not found" error.cmd.exe //cwas deliberately not used: MSYS collapses//cto/c, but cmd.exe itself rejects//c, which would break the three shells that currently work.Screenshots
No visual change on macOS/Linux. On Windows with a POSIX-family shell configured, the displayed/copied setup command reverts from the cmd.exe wrapper to the bare
npxform.Real-app validation on this branch (macOS dev build of this worktree, CDP-driven through the real UI): the Orchestration settings pane's skill setup surface — the exact
AgentSkillSetupPanel+copyActiveCommandpath from #11431 — with the Copy command button clicked and the "Copied command." toast showing. The system clipboard afterward contained exactlynpx skills update orchestration --global(verified viapbpaste), confirming the copied-command surface works and is unchanged on macOS. The Windows-only wrapper path cannot be produced on a darwin build (platform is reported by the frozenwindow.api), so that path is pinned by the red-first unit tests plus the real-Windows measurement in #11431.Testing
npx oxlinton changed files (also via pre-commit hooks, including the react-doctor oxlint config)pnpm typecheck(all three tsconfigs,.tsbuildinfocache cleared first)npx vitest run --config config/vitest.config.tsonCliSkillRuntimeSetup.test.tsx(20 passed) plus the 8 related suites that exercisebuildSkillCommandForRuntime/ the Linear CTA / skill-runtime hooks (60 passed)node config/scripts/check-react-doctor-changed.mjs— 0 issuesterminalWindowsShell: 'git-bash'(and abash.exepath) the copied command was the cmd.exe wrapper; after the fix they assert the bare install command, and acmd.exe-configured case pins that the preflight wrapper is retained for cmd-family shells.AI Review Report
Reviewed the wrapper skip for scope (only the POSIX-family case changes; remote-runtime, WSL-runtime, non-Windows, and non-skill-command paths untouched), for regressions against the #11431 measured matrix (pwsh 7 / PowerShell 5.1 / cmd.exe keep the identical wrapper string, byte-for-byte, per unchanged existing tests), and for cross-platform behavior on macOS/Linux/Windows/WSL (non-win32 platforms return early before the new check; the WSL runtime branch never reaches the wrapper). The store read happens outside render subscription, same trade-off as the existing remote-environment check and explicitly documented there.
Two independent same-model subagent review rounds both returned clean with zero actionable findings, so no review-fix commits were needed. Round 1 verified every clipboard producer routes through
buildSkillCommandForRuntime(including ruling outSkillFreshnessUpdateDialog, which copies a never-wrapped bare command) and confirmed red-on-revert for the new tests first-hand. Round 2 ran seven adversarial attack angles — pre-hydration store reads (settingsnull→powershellfamily → byte-identical pre-PR output), WSL-branch reachability, shell-neutrality of the update→reinstall rewrite under MSYS path conversion (---prefixed and://-containing args are exempt from rewriting), i18n gate impact, test store-state leaks, import cycles/formatting drift, and a repo-wide grep for otherwhere.exe npx//d /s /cproducers (the only other hits are a programmatic PTY agent-launch wrapper and an SSH WMI line, neither user-pasted) — all failed to find a defect.Security Audit
No new command execution paths: the change only removes a cmd.exe wrapper for one cohort, and the command strings remain fixed constants from
buildAgentFeatureSkillInstallCommand— no user input is interpolated into the copied command. The new code performs a read-only store lookup (settings.terminalWindowsShell) and string classification; no IPC, path handling, or secrets are touched.Notes
currentPlatform === 'win32'plus the configured-shell family; macOS/Linux/SSH-remote paths are unchanged.where.exe npxlists the extensionlessC:\Program Files\nodejs\npx(a bash script) first on a normal Node install, so a passing preflight does not strictly prove cmd.exe can execute npx — harmless in practice becausenpx.cmdsits beside it.win32platform report from the frozenwindow.api), so the repro is the red-first unit test plus the real-Windows measurement recorded in Copied skill install command silently no-ops in Git Bash after the cmd.exe npx preflight (#10453) #11431.Real Windows Electron QA
On this exact branch in a real Windows dev build, Settings → Terminal was configured for Git Bash. The Orchestration setup surface displayed the bare command and the real Copy command action produced the Copied command toast:
That exact clipboard value was then pasted into a standalone Git Bash window with no cmd.exe wrapper or MSYS-rewritten switches:
After running the clean bare command, Git Bash reached the real interactive skills CLI agent selector. QA stopped at the prompt before any installation:
Final owner verification (2026-07-30)
381cb84cebd059437af6bc252852901bdbfd019d.pnpm typecheck, fullpnpm lint, React Doctor (0 issues), andgit diff --check.main@a906f98baf1d57102731eeb481444928f8826ff9: the changed test plus a 43-file / 427-test related sweep passed, followed by the same typecheck, lint, React Doctor, and diff gates.run_ff79c37f9c32, final clean tasktask_cf10103418ab). No review-fix commit was required.%an/%ae: Brennan Benson<[email protected]>.