Skip to content

fix(settings): make WSL skill commands pasteable (#7795) - #7881

Merged
AmethystLiang merged 4 commits into
stablyai:mainfrom
rodboev:pr/wsl-skill-update-command-escaping
Jul 12, 2026
Merged

AmethystLiang merged 4 commits into
stablyai:mainfrom
rodboev:pr/wsl-skill-update-command-escaping

Conversation

@rodboev

@rodboev rodboev commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Generate WSL skill install/update commands as a direct selected-distro Bash login command instead of embedding a shell-detection script inside a PowerShell-quoted sh -c string.
  • Keep Windows-host update behavior on the existing reinstall path, so this only changes WSL runtime command text.

Closes #7795.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx - passed, Test Files 1 passed (1), Tests 8 passed (8).
  • pnpm run typecheck:web - passed.
  • pnpm exec oxlint src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx - passed.
  • pnpm exec oxfmt --check src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx - passed, All matched files use the correct format.

AI Review Report

  • Review focus: Windows + WSL quoting, selected distro preservation, update/install command routing, and web settings helper consumers.
  • The generated WSL command now has one Windows quoting layer and one Bash -ilc payload, avoiding escaped shell substitutions and nested doubled quotes in copied command text.
  • Host Windows skill updates still normalize through the existing add/install command path, and non-Windows host updates remain unchanged.

Security Audit

  • The change does not add subprocess execution. It changes the command string shown to users for WSL skill setup.
  • Distro names and command payloads still pass through PowerShell single-quote escaping before display.
  • No auth, network, IPC, filesystem, SSH, or browser permissions change.

Notes

No visual change. The command now assumes Bash inside WSL for this settings setup path, matching the direct runnable form users can paste into the selected distro.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change updates the WSL command execution path in CliSkillRuntimeSetup.tsx. The previous WSL login-shell helper imports are removed, and buildSkillCommandForRuntime now uses wsl.exe with bash -ilc and the quoted normalized command. The test suite updates the install and update cases to expect the new wsl.exe -d ... -- bash -ilc form and to verify the npx subcommands while rejecting shell-substitution and doubled-quote patterns.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests address #7795 by switching WSL commands to a direct bash -ilc form and removing the broken escaping.
Out of Scope Changes check ✅ Passed The changes are limited to the WSL command implementation and its tests, with no obvious unrelated scope creep.
Title check ✅ Passed The title is concise and accurately describes the WSL skill command pasteability fix.
Description check ✅ Passed All required sections are present and mostly complete, with testing, AI review, security, and notes filled in.

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.tsx (1)

82-85: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a brief comment explaining the bash -ilc choice.

The switch from the removed shell-detection helpers to a hardcoded bash -ilc wrapper is a non-obvious constraint (interactive login shell to pick up the user's PATH, and a directly pasteable form for the selected distro). A short "why" comment here would preserve that intent, mirroring the existing rationale comment in normalizeWindowsSkillUpdateCommand.

📝 Suggested comment
   const distroArg = resolvedRuntime.wslDistro?.trim()
     ? ` -d ${quotePowerShellSingle(resolvedRuntime.wslDistro.trim())}`
     : ''
+  // Why: run through an interactive login bash so the user's PATH (nvm, etc.)
+  // is available, and emit a directly pasteable command instead of the prior
+  // sh -c login-shell-detection wrapper that broke argv quoting on Windows→WSL.
   return `wsl.exe${distroArg} -- bash -ilc ${quotePowerShellSingle(normalizedCommand)}`

As per coding guidelines: "When writing or modifying code driven by a design doc or another non-obvious constraint, add a brief comment explaining why the code behaves that way."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7bf302d8-fbe2-4195-ac14-2aec4c6e5adc

📥 Commits

Reviewing files that changed from the base of the PR and between 7e1a777 and d4a41de15bf48e89774fa4e7d12a43061834907b.

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

@rodboev
rodboev force-pushed the pr/wsl-skill-update-command-escaping branch from d4a41de to e485c50 Compare July 9, 2026 03:38
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 9, 2026 16:50
rodboev and others added 2 commits July 11, 2026 22:15
- Encode the WSL login-shell script as base64 and decode/eval it inside
  the sh -c invocation, avoiding raw nested quotes at the paste boundary
- Scope $PSNativeCommandArgumentPassing = 'Legacy' to the invocation so
  PS 5.1 and PS 7 both hand wsl.exe the same escaped argv
- Extract powershell-native-argument.ts as the shared quoting module and
  reuse it from ssh-remote-powershell.ts
@AmethystLiang
AmethystLiang force-pushed the pr/wsl-skill-update-command-escaping branch from e485c50 to cb77169 Compare July 12, 2026 05:51
@AmethystLiang

Copy link
Copy Markdown
Contributor

Review: WSL skill command escaping ✅

Traced the generated command through every layer and it holds up. For the WSL paste path it now emits:

& { $PSNativeCommandArgumentPassing = 'Legacy'; wsl.exe -d 'Ubuntu' -- sh -c 'eval \"`printf %s <BASE64> | base64 -d`\"' } # Runs: npx skills add orchestration --global

Why it's correct:

  • PowerShell → Win32 argv: quotePowerShellNativeArgument pre-escapes "→\"; the scoped $PSNativeCommandArgumentPassing = 'Legacy' (no-op on 5.1, corrective on pwsh 7) makes both hosts produce identical argv. Backticks/| sit inside a PS single-quoted literal, so they pass through untouched.
  • WSL $ hazard sidestepped: dropping escapeWslShCommandForWindows is safe here because the outer command has no $ at all — every $/quote lives inside the base64 blob, so WSL's Windows-argv $ preprocessing never fires. This is the elegant part.
  • Single-line paste: base64 collapses the multi-line login-shell detector to one line (fixes bracketed-paste/partial-exec risk) while still honoring the user's real login shell + PATH — which the interim bash -ilc approach had lost.
  • Scope is correct: only the paste-into-powershell.exe-terminal path is changed; the argv-spawn callers (git runner, codex, preflight) rightly keep escapeWslShCommandForWindows.
  • The powerShellLiteral/powerShellNativeArg extraction into shared/powershell-native-argument.ts is byte-identical to the old logic.

Gates run locally: affected unit tests + full settings suite (570) + shell/ssh suites (652) pass; web+node typecheck clean; oxlint clean; max-lines ratchet OK. The it.skipIf(win32) end-to-end test actually executes the decode→login-shell→npx chain against a real /bin/sh and passes.

Optional nit (non-blocking): the -d distro arg uses quotePowerShellLiteral rather than quotePowerShellNativeArgument. Under the Legacy scope they're byte-identical for any real distro name (names can't contain "), so it only differs for inputs that can't occur — fine to leave as-is.

No defects found. LGTM.

AmethystLiang and others added 2 commits July 11, 2026 23:33
Main's stablyai#7892 made listMobileSessionTabs validate selectors via
this.store?.getRepo; the mock store here only defined
getWorkspaceSession, so the merged CI build threw 'getRepo is not a
function'. Return null (wt-1 is a worktree id, not a repo).

Co-authored-by: Orca <help@stably.ai>
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

1 similar comment
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#7881)

* fix(settings): make WSL skill commands pasteable (stablyai#7795)

* Fix WSL skill commands so PowerShell 7 pastes match PowerShell 5.1 argv

- Encode the WSL login-shell script as base64 and decode/eval it inside
  the sh -c invocation, avoiding raw nested quotes at the paste boundary
- Scope $PSNativeCommandArgumentPassing = 'Legacy' to the invocation so
  PS 5.1 and PS 7 both hand wsl.exe the same escaped argv
- Extract powershell-native-argument.ts as the shared quoting module and
  reuse it from ssh-remote-powershell.ts

* test(runtime): stub getRepo in mobile-tab startup cwd test

Main's stablyai#7892 made listMobileSessionTabs validate selectors via
this.store?.getRepo; the mock store here only defined
getWorkspaceSession, so the merged CI build threw 'getRepo is not a
function'. Return null (wt-1 is a worktree id, not a repo).

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Co-authored-by: Orca <help@stably.ai>
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.

[Bug]: Generated WSL skills update command has broken escaping and drops into quote prompt

3 participants