Repository navigation
fix(startup): restore Windows PATH before shell changes - #13792
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe change adds Windows PATH ownership management. It tracks baseline and application-applied PATH values, preserves externally added segments, and restores PATH state across shell probes and configuration changes. Shell hydration now supports both 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
(cherry picked from commit c96ded8)
Summary
cmd.exeresolution across PowerShell/Git Bash-style A→B transitionsLinear: STA-3889
Supersedes the PATH cleanup behavior introduced by #13418.
Root cause
mergePathSegmentspromoted every shell segment, including inherited entries, but cleanup tracked only segments absent from the premerge PATH. Shell A could therefore reorder inherited directories without owning that reorder. Shell B then inherited A's reordered process PATH and resolved an overlapping executable from A.The fix records the full baseline and exact applied PATH for one hydration application. Restore reestablishes the baseline before the next probe/merge and carries forward only case-insensitively new entries. That exception matches the existing Windows preflight behavior, which appends newly installed registry PATH entries to the live process.
Reproduction and oracle
The byte-identical oracle test blob (
2bbf094fb9b00540ce70bb32ea677c33882e97dd) was exercised against:56b6d84/ latest main3713dd7376: same hydration source blobs; red with[B-profile, A, B], and realcmd.exeselected shell A[B-profile, B, A], and realcmd.exeselected shell BThe suite also covers concurrent generation fencing, PATH/Path casing, case-insensitive duplicates, drive roots, UNC shares, cmd, WSL, and external registry-style additions. Existing focused tests cover PowerShell and Git Bash probe behavior.
Testing
pnpm run typecheckoxlint --deny-warningspnpm run check:reliability-gatespnpm run check:max-lines-ratchetpnpm test— repository-wide Windows run completed with broad pre-existing platform failures unrelated to this diff, including/bin/shassumptions, POSIX path expectations, symlink cases, and unrelated source/snapshot assertions; the affected matrix above is greenpnpm run check:code-quality:changed— wrapper fails on this host withspawnSync pnpm.cmd EINVAL; its exact underlying oxlint scan passes directlyElectron UI automation was intentionally skipped: this is main-process executable resolution with no visual change, and a visible proof would require modifying real user shell profiles while providing weaker evidence than the deterministic real-process oracle.
Compatibility and policy
Performance and review
A delegated performance audit measured restoration at 0.066 ms for 100 PATH segments and 0.793 ms for 1,000 (0.834 ms max). The change retains one generation (two PATH strings plus one key), adds no subprocess, listener, timer, polling, IPC, or network work.
Three fresh adversarial review rounds ran. Round 1 added the CLI TypeScript project entry; Round 2 gated the real Windows oracle off non-Windows CI; both independent Round 3 lanes returned clean. The final internal review found no in-scope issue or future-PR suggestion.