Repository navigation
Conversation
📝 WalkthroughWalkthroughWindows Codex managed hooks now use a shared raw PowerShell command builder for non-safe script paths, while safe paths remain unchanged. The encoded wrapper still handles CMD launcher commands. Tests cover Unicode paths, PowerShell reuse, event delivery, fallback behavior, command contracts, and idempotent hook upgrades. The Windows package workflow now runs the new tests. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Windows hooks can fail for UNC profiles or after the managed script is removed; route those cases through the guarded launcher before merging. 🚥 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 |
There was a problem hiding this comment.
Important
The new command shape is correct for Codex's default Windows hook shell but is now PowerShell-only, where the previous encoded launcher also ran under Codex's cmd.exe /C fallback. One inline note; everything else looks solid.
Reviewed changes
buildWindowsHookPowerShellCommandextracted (installer-utils.ts) — the guarded PowerShell body is now exported and reused;wrapWindowsHookCommandstill encodes it for its other callers, so Antigravity/Devin/Grok/Kimi shapes are unchanged.- Codex Windows command switched (
codex-hook-definition.ts) —getManagedCommandreturns the bare.cmdfor cmd-safe paths and the unencoded body otherwise, dropping the nestedpowershell.exe -NoProfile -EncodedCommandon every CJK/spaced-profile event. - Command-shape + delivery tests (
windows-hook-command.test.ts) — asserts nopowershell.exe/EncodedCommand/Set-ExecutionPolicy, pins-LiteralPath '…' -PathType Leafquoting, and drives all eight events through real PowerShell with large Unicode payloads plus missing-script and unreachable-receiver paths. - Upgrade test (
windows-hook-upgrade.test.ts) — reinstall twice, asserts exactly one new managed command per event, no old encoded command survives, user hooks and the userhooks.jsonare untouched, and trust TOML changes. - Existing assertions retargeted —
hook-service-managed-install.test.tsand the Grok dollar-byte scanner contract now account for the new shape.
ℹ️ Nitpicks
src/main/agent-hooks/installer-utils.test.ts:710and:724still describe Codex as awrapWindowsCmdHookCommandargv[0] consumer ("Codex/Antigravity/Devin launch the command as a program"). This PR establishes Codex is not one — the surviving callers are Antigravity, Devin, and Grok — so those comments are now misleading.src/main/codex/windows-hook-upgrade.test.ts:80assertsexpect(readFileSync(tomlPath, 'utf8')).not.toBe(oldTrust), which passes on any byte change. Asserting the new computed trusted hash (ornot.toContain(oldHash)) would actually pin the trust refresh.- The load-bearing assumption (PowerShell
-Commandhost) is exercised only bydescribe.skipIf(process.platform !== 'win32'), so Linux CI never runs it. Fine given the manual Windows verification, just noting the coverage boundary.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in the follow-up commit. (Not an approval — the prior
codex-hook-definition.ts:80note remains open.)
Reviewed changes
- CI registration for the new suites (
5eb6ac9df1) —src/main/codex/windows-hook-command.test.tsandwindows-hook-upgrade.test.tsare now listed in bothWINDOWS_PACKAGE_TESTS(config/scripts/pr-code-change-scope.mjs:226-227) and theTest Windows-specific boundariesvitest argv (.github/workflows/pr.yml:891-892). Both are required byconfig/scripts/win32-test-lane-registration.test.mjs, the relative placement matches the existing classifier list, and the files carrydescribe.skipIf(process.platform !== 'win32'), so they would otherwise have run on no machine.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed only the delta since the prior pullfrog review (5eb6ac9 → b6da1d3): comment and test-assertion tightening on the already-reviewed command change.
- Comment accuracy fixed (
installer-utils.test.ts,codex-hook-definition.ts) —wrapWindowsCmdHookCommand's comments no longer name Codex as an argv[0] consumer, and thegetManagedCommandcomment now reads "Codex's default native Windows hook host is PowerShell", scoping the shell assumption instead of asserting it unconditionally. - Trust refresh assertion strengthened (
windows-hook-upgrade.test.ts) — the setup entry now usestimeoutSec: 10(wastimeout), and the loosenot.toBe(oldTrust)byte-diff check is replaced with exactcomputeTrustedHashassertions: the new command's hash is present and the old command's hash is absent after reinstall.
The remaining prior nitpick (the real-PowerShell delivery test is skipIf non-win32) is an informational coverage boundary, not actionable — the new suites are registered in both Windows CI lanes, so they do run somewhere.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
🟠 Major · Keep UNC and missing paths on the guarded launcher.
src/main/codex/codex-hook-definition.ts:73-80
🩺 Stability & Availability | 🟠 Major | ⚡ Quick winKeep UNC and missing paths on the guarded launcher.
getManagedCommandreturns a bare path whenWINDOWS_CMD_SAFE_PATHmatches. That predicate accepts UNC paths. Codex runs the command throughcmd.exe /C, which does not reliably launch UNC script paths. If the managed script is removed after installation,cmd.exe /Creports a command-not-found failure instead of using the PowerShell wrapper’s missing-file fallback and stdin drain. Restrict the bare branch to drive-letter paths, and route UNC and other paths throughbuildWindowsHookPowerShellCommand.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 448692d8-e27e-4b96-b63f-41932b7198c3
📒 Files selected for processing (1)
src/main/codex/windows-hook-command.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…es (stablyai#20952) * fix(codex): reuse the Windows hook shell for Unicode profile paths * test(codex): register Unicode hook tests in Windows CI * test(codex): pin trust hash replacement during Windows upgrade * test(codex): retry transient Windows teardown locks

ELI5
Windows Codex hooks under a CJK or spaced profile started a second PowerShell process for every event. Reuse the PowerShell host Codex already provides, keeping the quoted script invocation, missing-file check, environment guard, and stdin drain.
What Changed
Extract the existing PowerShell command body from its encoded launcher and use that body for native Windows Codex paths that previously required the launcher. ASCII fast paths, other agents' launchers, POSIX/SSH/WSL commands, hook payloads, and the 10-second timeout retain their existing behavior. Reinstallation replaces the old commands and refreshes trust without duplicating hooks or removing user hooks.
Why
The native Windows hook engine passes commands to its selected PowerShell with
-NoProfile -Command; it has done so since the hook engine was introduced. The shared helper's historical argv[0] assumption does not describe this consumer. A bare Unicode path loses quoting and missing-script handling; executing the existing guarded body inside the host preserves both while removing the extra interpreter and its execution-policy setup.Reviewed the reports and discussions in #11496, #18875, and #19187, and cross-referenced #11497, #13442, #18905, and the open #19255. The latter changes Claude's bash/cmd launcher and cannot be applied directly to Codex's PowerShell host.
Linked Issue
Resolves STA-7381.
Visual Proof
N/A — generated hook commands change; no rendered UI or interaction changes. Windows execution and timing evidence follows.
Testing
Write-Outputtool call against a local model-response fixture. SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, and Stop reached the receiver; tool and session exited 0 with empty stderr. No hook-trust bypass was used.src/main/codex,installer-utils, and managed-command contracts).pnpm tc,pnpm build, changed-code quality gate, targeted oxlint, formatting, andgit diff --checkpassed.Paired win-lowspec benchmark: 12 measured runs per shape per host after two warmup rounds, alternating order, the same generated
.cmd, and the same 259,044-byte Unicode payload:All 56/56 deliveries, including warmups, were byte-exact. No claim is made that this resolves every historical 10-second timeout or unrelated orphan-process report.
Review
Upstream shell boundary checked in local Codex source:
build_hooks_for_configalways supplies the selected program, so the hooks library's empty-programcmd.exe /Cfallback is not used by native sessions. Native shell discovery selects PowerShell; its ultimate cmd fallback requires PowerShell to be absent, which also breaks the oldpowershell.exelauncher. Shell overrides are test-only apart from disabled, under-developmentshell_zsh_fork; that experimental native Windows configuration is outside this verification. Orca terminal-shell selection does not configure the Codex hook host.The shared wrapper still builds the same encoded command for its other callers. Native Windows Codex alone selects the unwrapped body; its ASCII path remains byte-identical. No new process, dependency, runtime detection, polling, wire field, or timeout extension is introduced. Existing sessions may retain their startup hook snapshot; use a fresh Codex session after hook regeneration.
An independently reproduced, pre-existing cmd percent-expansion problem affects literal
%VAR%profile segments with both launchers. It is tracked separately as STA-7655.Agent skill upstream boundary
Checklist