Skip to content

fix(settings): keep copied skill commands bare for POSIX-family Windows shells - #11599

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-11431-gitbash-clipboard
Jul 31, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-11431-gitbash-clipboard

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

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 preflight npx. The spawned-terminal path is guarded (getProjectAgentSkillTerminalShellOverride forces powershell.exe for 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 /c switches into D:/ 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 wrapWindowsSkillCommandWithNpxPrerequisite when resolveWindowsShellStartupFamily(settings.terminalWindowsShell) === 'posix' (Git Bash, bash.exe, wsl.exe), returning the bare npx skills add … --global command exactly as main did before #10453. The store-read mirrors the existing isRemoteRuntimeEnvironmentFocused() pattern in the same function.

Behavior after the fix, for a POSIX-family-configured Windows user:

cmd.exe //c was deliberately not used: MSYS collapses //c to /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 npx form.

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 + copyActiveCommand path from #11431 — with the Copy command button clicked and the "Copied command." toast showing. The system clipboard afterward contained exactly npx skills update orchestration --global (verified via pbpaste), 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 frozen window.api), so that path is pinned by the red-first unit tests plus the real-Windows measurement in #11431.

pr11599-orchestration-copy-surface.png

Testing

  • npx oxlint on changed files (also via pre-commit hooks, including the react-doctor oxlint config)
  • pnpm typecheck (all three tsconfigs, .tsbuildinfo cache cleared first)
  • npx vitest run --config config/vitest.config.ts on CliSkillRuntimeSetup.test.tsx (20 passed) plus the 8 related suites that exercise buildSkillCommandForRuntime / the Linear CTA / skill-runtime hooks (60 passed)
  • node config/scripts/check-react-doctor-changed.mjs — 0 issues
  • Added or updated high-quality tests that would catch regressions: two new tests were written first and confirmed red on the parent commit — with terminalWindowsShell: 'git-bash' (and a bash.exe path) the copied command was the cmd.exe wrapper; after the fix they assert the bare install command, and a cmd.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 out SkillFreshnessUpdateDialog, 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 (settings null → powershell family → 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 other where.exe npx / /d /s /c producers (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

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:

Windows Orchestration setup with bare command and copy toast

That exact clipboard value was then pasted into a standalone Git Bash window with no cmd.exe wrapper or MSYS-rewritten switches:

Bare skill command pasted into standalone Git Bash

After running the clean bare command, Git Bash reached the real interactive skills CLI agent selector. QA stopped at the prompt before any installation:

Skills CLI interactive agent selector running in Git Bash

Final owner verification (2026-07-30)

  • Final head: 381cb84cebd059437af6bc252852901bdbfd019d.
  • Exact-head validation: 9 focused files / 85 tests, cache-cleared pnpm typecheck, full pnpm lint, React Doctor (0 issues), and git diff --check.
  • Conflict-free synthetic merge with pinned 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.
  • The mandated same-model/xhigh review loop completed with zero actionable findings (run_ff79c37f9c32, final clean task task_cf10103418ab). No review-fix commit was required.
  • Commit authorship was verified from %an/%ae: Brennan Benson <[email protected]>.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Windows skill command generation now detects whether the configured Windows terminal shell is POSIX-family and avoids wrapping commands with cmd.exe /d /s /c in that case. Tests cover bare install commands for POSIX-family shells, restored preflight wrapping for cmd.exe, and bare reinstall behavior during Windows skill updates.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary fix for copied skill commands in POSIX-family Windows shells.
Description check ✅ Passed The description covers every required template section with detailed change, testing, review, security, screenshot, and platform notes.
✨ 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.

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

🧹 Nitpick comments (1)
src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx (1)

254-261: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover every supported POSIX shell alias.

resolveWindowsShellStartupFamily also classifies wsl.exe, wsl, and bare bash.exe as POSIX-family, but this test covers only git-bash and one bash.exe path. Add the remaining aliases so regressions for those configurations cannot reintroduce the cmd.exe wrapper.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fa407dd4-5437-4dfd-9df2-4eefc6e0c0c7

📥 Commits

Reviewing files that changed from the base of the PR and between 89a9d4f and 9aee966.

📒 Files selected for processing (2)
  • src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx
  • src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This 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, bash.exe) because MSYS rewrites the leading /d /s /c flags into drive-letter paths. The fix adds an isPosixFamilyWindowsShellConfigured() guard inside wrapWindowsSkillCommandWithNpxPrerequisite that returns the bare npx command when the configured shell family is posix, restoring pre-#10453 behavior for that cohort.

  • Adds isPosixFamilyWindowsShellConfigured() using the existing resolveWindowsShellStartupFamily helper, mirroring the isRemoteRuntimeEnvironmentFocused() pattern for store reads outside React subscriptions.
  • Leaves the cmd.exe preflight wrapper unchanged for PowerShell, pwsh, and cmd.exe users; the spawned-terminal override (getProjectAgentSkillTerminalShellOverride) is also untouched.
  • Adds two new tests: one confirming bare output for git-bash and a full bash.exe path, and a negative pin for cmd.exe retaining the wrapper.

Confidence Score: 5/5

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

Important Files Changed

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]
Loading

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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-11431-gitbash-clipboard branch from cc1a972 to 381cb84 Compare July 31, 2026 00:23
@brennanb2025
brennanb2025 merged commit e109229 into main Jul 31, 2026
41 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
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