Repository navigation
fix(prompts): stop spawning PowerShell for the OS name on Windows - #2449
Conversation
The system prompt's SYSTEM INFORMATION section called os-name on every request. On Windows its windows-release dependency runs wmic, then `powershell (Get-CimInstance Win32_OperatingSystem).caption`, through execaSync with no timeout, on the extension host's only JavaScript thread. Where wmic has been removed (recent Windows 11 builds), PowerShell starts on every request. I measured 3 to 4.5 s per call, during which the extension host is blocked. In one observed freeze, the PowerShell process did not exit, and the extension host stayed blocked: the request was never sent, Stop did nothing, and only reloading the window recovered. On Windows, read the product name from os.version(), which spawns nothing and costs well under a microsecond. Other platforms keep os-name, which does not spawn a process there, with the existing fallback. Fixes Zoo-Code-Org#2448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: The required review sequence passed. Remaining merge requirements apply. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
edelauna
left a comment
There was a problem hiding this comment.
Nice! Thanks for this contribution, just had 1 nit.
| const fallback = `${os.platform()} ${os.release()}` | ||
|
|
||
| if (os.platform() === "win32") { | ||
| return os.version() || fallback |
There was a problem hiding this comment.
On win32 os.version() runs outside any try/catch, unlike the old osName() call. Can it throw here (I believe Node wraps it so a failed uv_os_uname raises ERR_SYSTEM_ERROR)? If so, every prompt build on Windows would fail instead of using the platform release fallback. Would it make sense to put both branches inside the same try?
There was a problem hiding this comment.
Thanks for the comment. In current Node, os.version() cannot throw: os computes the value once when the module loads. But it costs nothing to put it in the try block, so I did it in d06a98c.
6089bdb to
c7ad873
Compare
Move the Windows os.version() branch inside the same try as the os-name call, so both platforms use the platform and release fallback if the lookup throws. Cover a throwing os.version() on win32 next to the existing os-name case, with it.each. Refs Zoo-Code-Org#2448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c7ad873 to
d06a98c
Compare
Related GitHub Issue
Closes: #2448
Description
On Windows,
getSystemInfoSection()now usesos.version()instead ofos-name.os.version()is a Node.js built-in and does not start a process. Other platforms still useos-name, which does not start a process there.Points to check:
Windows 11to the full product name, for exampleWindows 11 Pro.os.version()returns an empty string, the section useswin32 <release>, as the old fallback did.Test Procedure
cd src && npx vitest run core/prompts/sections/__tests__/system-info.spec.ts: 7 tests pass. Two new Windows tests check thatos-nameis not called. They fail on the old code.cd src && npx vitest run core/prompts core/webview/__tests__/generateSystemPrompt.spec.ts: 435 tests pass.tsc --noEmitand ESLint pass. I removed two unnecessaryas anycasts from the spec, and its entry ineslint-suppressions.json.Pre-Submission Checklist
src/test-utils/,@/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible.Visual Snapshots
No UI change.
Videos (interaction / animation only)
No UI change.
Documentation Updates
Additional Notes
I used Claude Code to find the cause and write the fix and the tests.
🤖 Generated with Claude Code