Skip to content

fix: route Windows .cmd shims through PowerShell to fix Ctrl+C terminal corruption#1414

Merged
fengmk2 merged 11 commits intomainfrom
exec-ps1-script-first
Apr 21, 2026
Merged

fix: route Windows .cmd shims through PowerShell to fix Ctrl+C terminal corruption#1414
fengmk2 merged 11 commits intomainfrom
exec-ps1-script-first

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Apr 18, 2026

Summary

Running a node_modules/.bin/*.cmd shim on Windows — what vp run <script> does when resolving vite, tsc, etc. — triggers cmd.exe's "Terminate batch job (Y/N)?" prompt on Ctrl+C. That prompt leaves the terminal in a corrupt state: backspace prints ^H, Ctrl+C prints ^C, input becomes sluggish.

Pulls in voidzero-dev/vite-task#345 (merged as c45e5e72), which teaches the plan layer to rewrite the invocation at plan time:

program_path: <abs path to pwsh.exe or powershell.exe>
args:         [-NoProfile, -NoLogo, -ExecutionPolicy, Bypass, -File,
               <.ps1 path relative to task cwd>, ...original_args]

PowerShell resolves -File <relative> against its own working directory (= the task's cwd) and lands on the correct .ps1, so Ctrl+C propagates cleanly without the cmd.exe hop. The .ps1 path is cwd-relative so SpawnFingerprint.args stays portable — no absolute paths leak into cache keys.

The rewrite only fires when all of these hold: extension is .cmd, path lives inside the workspace root, the two last path components are .bin / node_modules (case-insensitive), a sibling .ps1 exists, and pwsh.exe / powershell.exe is on PATH. Any miss keeps the original .cmd path — behavior matches pre-merge.

Also includes a previously-pushed CI fix: the musl test job disables crt-static so fspy_preload_unix's cdylib build doesn't fail after voidzero-dev/vite-task#344 made that crate an unconditional build-dep.

Closes #1176

Test plan

  • cargo check --workspace clean on macOS
  • vite-task CI green on the merged PR (includes new Windows-only plan snapshot verifying the rewrite end-to-end across cwd and --filter invocations)
  • vite-plus CI green
  • Manual on Windows: reproduce with https://github.com/Curtion/report-vite-plus-1; Ctrl+C during vp run dev should leave the terminal clean
  • Manual: confirm .cmd fallback on a Windows box with PATH stripped of PowerShell
  • Manual: confirm a globally installed .cmd outside the workspace is not rewritten

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 18, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit da5f147
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69e6ef4283398a000894b6c2

@fengmk2 fengmk2 self-assigned this Apr 18, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 18, 2026


How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 force-pushed the exec-ps1-script-first branch 4 times, most recently from 754ad9f to ad0a26f Compare April 18, 2026 13:26
@fengmk2 fengmk2 added test: install-e2e run vite install e2e test test: e2e Auto run e2e tests labels Apr 18, 2026 — with Graphite App
@fengmk2 fengmk2 force-pushed the exec-ps1-script-first branch from 4ac205f to f84a026 Compare April 20, 2026 06:44
@fengmk2 fengmk2 changed the title chore: bump vite-task to e0229ffb fix: route Windows .cmd shims through PowerShell to fix Ctrl+C terminal corruption Apr 21, 2026
@fengmk2 fengmk2 force-pushed the exec-ps1-script-first branch from 232e34b to fb9e642 Compare April 21, 2026 02:26
@fengmk2 fengmk2 requested a review from branchseer April 21, 2026 02:27
@fengmk2 fengmk2 marked this pull request as ready for review April 21, 2026 02:27
@fengmk2 fengmk2 force-pushed the exec-ps1-script-first branch from fb9e642 to 86ee43c Compare April 21, 2026 02:38
fengmk2 added 11 commits April 21, 2026 11:29
Pulls in voidzero-dev/vite-task#345 which prefers .ps1 shims over .cmd
on Windows to avoid the "Terminate batch job (Y/N)?" prompt and terminal
corruption on Ctrl+C during `vp run dev`.

Closes #1176
Picks up the cache-portability fix for voidzero-dev/vite-task#345
(PowerShell rewrite moved from plan layer to spawn layer).
Picks up voidzero-dev/vite-task#345 fix for missing `which` dep on
Windows after the module move.
vite-task PR voidzero-dev/vite-task#344 made `fspy_preload_unix`
(a cdylib) an unconditional build-dep so cargo's artifact resolver
doesn't panic during cross-compile. On musl, building a cdylib
requires dynamically-linked libc; the default is static, so the
build fails with:

    error: cannot produce cdylib for `fspy_preload_unix` as the
    target `x86_64-unknown-linux-musl` does not support these crate
    types

Mirror vite-task's own musl CI: set `-C target-feature=-crt-static`
in `RUSTFLAGS`. vite+ ships as a NAPI module that links musl libc
dynamically, so this matches production.
@fengmk2 fengmk2 force-pushed the exec-ps1-script-first branch from 86ee43c to da5f147 Compare April 21, 2026 03:30
@fengmk2 fengmk2 merged commit c5e09e7 into main Apr 21, 2026
84 of 85 checks passed
@fengmk2 fengmk2 deleted the exec-ps1-script-first branch April 21, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: e2e Auto run e2e tests test: install-e2e run vite install e2e test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pressing Ctrl+C after vp run dev, pnpm run dev, or npm run dev leaves the terminal in a broken state on Windows

2 participants