Skip to content

fix(windows): stop the service wrapper killer using the argv Bun rejects - #1944

Open
lidge-jun wants to merge 1 commit into
devfrom
codex/win-010-powershell-argv
Open

fix(windows): stop the service wrapper killer using the argv Bun rejects#1944
lidge-jun wants to merge 1 commit into
devfrom
codex/win-010-powershell-argv

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • src/service.ts spawned PowerShell with "-WindowStyle", "Hidden" as argv elements. src/codex/user-identity.ts:222-224 already forbids exactly that: Bun 1.3.14 can fail the direct CLI pair before the command runs ([Bug] Windows PowerShell -WindowStyle Hidden causes EACLIDENTITY under Bun #1589), and the process-level windowsHide flag is what actually suppresses the window.
  • The call is not decorative. stopServiceIfInstalled() uses it because schtasks /end can leave the wscript.exe/cmd.exe wrapper alive to respawn the proxy, and it ignores spawnSync's exit status. Under [Bug] Windows PowerShell -WindowStyle Hidden causes EACLIDENTITY under Bun #1589 wrapper termination silently does nothing, so ocx stop, restart and update report success without sticking.
  • The invariant survived as prose plus a single-file assertion. tests/windows-deploy-close-regressions.test.ts:43 pins the argv only for src/update/job.ts (the variable is bound at line 13), so service.ts was never covered. Replaced with a sweep over every src/**/*.ts, which found exactly one offender.
  • The sweep matches the argv form only. Six call sites legitimately pass -WindowStyle Hidden inside a PowerShell script string handed to Start-Process (windows-elevation.ts 622/660/687/736, tray/windows.ts:489, update/job.ts:574); Bun never parses those. A second test pins that discrimination in both directions so the sweep cannot quietly become vacuous or start failing correct code.

First of a stacked chain implementing devlog/_plan/260817_windows_stability_program/ (phase 010). This one targets dev.

Verification

  • Driven red first: the sweep reported ["service.ts"] before the fix.
  • bun test tests/windows-popup-fix.test.ts — 7 pass
  • bun test tests/service.test.ts tests/windows-deploy-close-regressions.test.ts — 131 pass
  • bun run typecheck — clean

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Windows service cleanup to prevent unwanted PowerShell compatibility issues.
    • Console windows remain hidden during background cleanup operations.
  • Tests

    • Added regression coverage to ensure incompatible PowerShell arguments are not used directly.

src/service.ts spawned PowerShell with "-WindowStyle", "Hidden" as argv
elements. src/codex/user-identity.ts:222-224 already forbids exactly that:
Bun 1.3.14 can fail the direct CLI pair before the command runs (#1589), and
the process-level windowsHide flag is what actually suppresses the window.

The call is not decorative. stopServiceIfInstalled() uses it because
schtasks /end can leave the wscript.exe/cmd.exe wrapper alive to respawn the
proxy, and it ignores spawnSync's exit status. Under #1589 wrapper termination
silently does nothing, so ocx stop, restart and update report success without
sticking.

The invariant survived as prose plus a single-file assertion:
tests/windows-deploy-close-regressions.test.ts:43 pins the argv only for
src/update/job.ts (the variable is bound at line 13), so service.ts was never
covered. Replaced with a sweep over every src/**/*.ts, which found exactly one
offender.

The sweep matches the argv form only. Six call sites legitimately pass
-WindowStyle Hidden inside a PowerShell script string handed to Start-Process
(windows-elevation.ts 622/660/687/736, tray/windows.ts:489, update/job.ts:574);
Bun never parses those. A second test pins that discrimination in both
directions so the sweep cannot quietly become vacuous or start failing correct
code.

Driven red first: the sweep reported ["service.ts"] before the fix.

Verification: bun test tests/windows-popup-fix.test.ts (7 pass), bun test
tests/service.test.ts tests/windows-deploy-close-regressions.test.ts
(131 pass), bun run typecheck clean.
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 69dfff6c-547b-48fe-930f-92bc1f092697

📥 Commits

Reviewing files that changed from the base of the PR and between bc11a6e and 393d72a.

📒 Files selected for processing (2)
  • src/service.ts
  • tests/windows-popup-fix.test.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The Windows service-wrapper cleanup command removes the Bun-incompatible -WindowStyle Hidden arguments while retaining windowsHide: true. A regression suite scans runtime TypeScript files and accepts valid script-string usage.

Changes

Windows PowerShell cleanup

Layer / File(s) Summary
Remove forbidden PowerShell arguments and add regression coverage
src/service.ts, tests/windows-popup-fix.test.ts
The cleanup command removes the direct -WindowStyle Hidden argument pair and keeps windowsHide: true. The regression tests recursively scan runtime TypeScript files, reject forbidden argument-list usage, accept script-string usage, and validate the detection regex.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 393d7

This localized Windows fix prevents the service wrapper from being invoked with rejected arguments and adds coverage for the affected behavior; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

  • lidge-jun/opencodex#1674: Both changes remove direct PowerShell -WindowStyle Hidden arguments while retaining windowsHide: true.

Suggested reviewers: wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Windows service-wrapper fix and the rejected Bun argv as the cause.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/win-010-powershell-argv

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.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant