Skip to content

Fix Windows shell escaping for CLI arguments containing double quotes - #1608

Closed
arajooj wants to merge 23 commits into
pingdotgg:mainfrom
arajooj:t3code/pr-windows-shell-arg-escaping
Closed

arajooj wants to merge 23 commits into
pingdotgg:mainfrom
arajooj:t3code/pr-windows-shell-arg-escaping

Conversation

@arajooj

@arajooj arajooj commented Mar 31, 2026 •

Copy link
Copy Markdown

What Changed

Added a centralized escapeArgForWindowsShell utility in packages/shared/src/shell.ts that escapes double-quote characters (" → \") in command-line arguments when spawning processes with shell: true on Windows.

Applied it to two affected call sites:

  • ClaudeTextGeneration.ts — --settings and --json-schema arguments (JSON strings)
  • CodexTextGeneration.ts — --config arguments (key="value" pairs)

Why

On Windows, every ChildProcess.make / spawn call uses shell: true so that cmd.exe can resolve .cmd shims in PATH. The child process's C runtime (MSVCRT) parses the raw command-line string into argv and treats unescaped " as argument-quoting delimiters — consuming them instead of passing them through.

This means a JSON argument like {"fastMode":true} arrives at the CLI as {fastMode:true} (quotes stripped), producing:

TextGenerationError: Claude CLI command failed: Error: Invalid JSON provided to --settings

The same class of issue affects the Codex --config arguments where values are wrapped in quotes (e.g. model_reasoning_effort="high" → model_reasoning_effort=high).

Escaping each " as \" makes MSVCRT treat them as literal quote characters, preserving the original value.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Medium risk because it changes how CLI command arguments are constructed for text generation, which could affect request formatting across platforms, though the change is narrow and covered by new unit tests.

Overview
Prevents Windows shell: true spawning from stripping double quotes in CLI args by introducing escapeArgForWindowsShell in packages/shared/src/shell.ts.

Applies the escaping to Claude --json-schema/--settings and Codex --config arguments, and adds unit tests validating Windows vs non-Windows behavior.

Written by Cursor Bugbot for commit ac4bbd0. Configure here.

Note

Fix Windows shell escaping for CLI arguments containing double quotes

  • Adds escapeArgForWindowsShell in packages/shared/src/shell.ts that replaces " with \" on win32 and is a no-op on other platforms.
  • Applies this escaping to --json-schema and --settings args in the Claude CLI runner and to --config values in the Codex CLI runner on Windows.
  • Adds Trae as a supported editor (id: "trae") in the EDITORS constant, the Open In picker, and the server-side editor resolution and tests.
  • Most other changes are mechanical refactors wrapping Effect.gen functions with named Effect.fn("...") for better tracing; no logic changes.

Macroscope summarized 5d04c90.

arajooj added 2 commits March 31, 2026 09:52
…s to use it

- Introduced escapeArgForWindowsShell function to handle argument escaping for Windows shell.
- Updated ClaudeTextGeneration and CodexTextGeneration layers to utilize the new utility for escaping JSON strings and configuration arguments.
- Added unit tests for escapeArgForWindowsShell to ensure correct functionality across platforms.
@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 207c1f8b-224b-4bda-9281-5ad0738a1c77

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 31, 2026
arajooj and others added 21 commits March 31, 2026 20:30
…ckpointDiffQuery.ts (pingdotgg#1622)

Co-authored-by: codex <codex@users.noreply.github.com>
…ckpointStore.ts (pingdotgg#1623)

Co-authored-by: codex <codex@users.noreply.github.com>
…eration.ts (pingdotgg#1625)

Co-authored-by: codex <codex@users.noreply.github.com>
…ration.ts (pingdotgg#1624)

Co-authored-by: codex <codex@users.noreply.github.com>
…csService.ts (pingdotgg#1642)

Co-authored-by: codex <codex@users.noreply.github.com>
…vider.ts (pingdotgg#1635)

Co-authored-by: codex <codex@users.noreply.github.com>
…ovider.ts (pingdotgg#1634)

Co-authored-by: codex <codex@users.noreply.github.com>
…AdapterRegistry.ts (pingdotgg#1637)

Co-authored-by: codex <codex@users.noreply.github.com>
…erProvider.ts (pingdotgg#1640)

Co-authored-by: codex <codex@users.noreply.github.com>
…e.ts (pingdotgg#1631)

Co-authored-by: codex <codex@users.noreply.github.com>
…sonLogger.ts (pingdotgg#1636)

Co-authored-by: codex <codex@users.noreply.github.com>
…Registry.ts (pingdotgg#1638)

Co-authored-by: codex <codex@users.noreply.github.com>
…Service.ts (pingdotgg#1639)

Co-authored-by: codex <codex@users.noreply.github.com>
…viderCommandReactor.ts (pingdotgg#1629)

Co-authored-by: codex <codex@users.noreply.github.com>
…ient.ts (pingdotgg#1633)

Co-authored-by: codex <codex@users.noreply.github.com>
…s to use it

- Introduced escapeArgForWindowsShell function to handle argument escaping for Windows shell.
- Updated ClaudeTextGeneration and CodexTextGeneration layers to utilize the new utility for escaping JSON strings and configuration arguments.
- Added unit tests for escapeArgForWindowsShell to ensure correct functionality across platforms.
Resolve conflicts keeping Effect.fn structure from upstream
with escapeArgForWindowsShell applied to CLI arguments.
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Apr 1, 2026
@arajooj

arajooj commented Apr 1, 2026

Copy link
Copy Markdown
Author

Closing — this has already been addressed upstream.

@arajooj arajooj closed this Apr 1, 2026
@macroscopeapp

macroscopeapp Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR mixes three concerns: a small Windows shell escaping bug fix, a large mechanical refactor (Effect.gen → Effect.fn pattern migration) touching 15+ files including critical provider and persistence layers, and a new 'Trae' editor feature. While the refactor appears behavioral-no-op (adds tracing span names), the breadth of changes across unfamiliar code by a newer contributor warrants human verification.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants