-
Notifications
You must be signed in to change notification settings - Fork 670
fix(windows): stop console popups from proxy-internal PowerShell lookups (#1278) #1347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Wibias
merged 3 commits into
lidge-jun:dev
from
wade19990814-hue:fix/windows-popup-hidden-spawn
Aug 9, 2026
+148
−16
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /** | ||
| * Regression coverage for the Windows console-popup fix (#1278). | ||
| * | ||
| * The desktop proxy parent runs without a console. Every console-subsystem | ||
| * child it spawns without CREATE_NO_WINDOW (`windowsHide`) gets a fresh | ||
| * visible console window — observed at startup, on config writes, and on | ||
| * shutdown. The proxy-internal identity and process lookups must therefore | ||
| * spawn PowerShell hidden, from the trusted System32 directory (never PATH), | ||
| * and under a bounded timeout so a hung child cannot wedge those paths. | ||
| */ | ||
| import { afterEach, describe, expect, test } from "bun:test"; | ||
|
|
||
| import { readProcessStartMsBatch } from "../src/codex/app-server-processes"; | ||
| import { | ||
| resolveEffectiveUserIdentity, | ||
| windowsIdentityPowerShellCommandForTests, | ||
| windowsIdentityPowerShellSpawnOptionsForTests, | ||
| } from "../src/codex/user-identity"; | ||
| import { setTrustedWindowsElevationExecutablesForTests } from "../src/lib/windows-elevation"; | ||
|
|
||
| const TRUSTED_POWERSHELL = "C:\\trusted-system32\\WindowsPowerShell\\v1.0\\powershell.exe"; | ||
|
|
||
| afterEach(() => { | ||
| setTrustedWindowsElevationExecutablesForTests(null); | ||
| }); | ||
|
|
||
| describe("Windows identity lookup popup fix (#1278)", () => { | ||
| test("builds a hidden non-interactive command from the trusted PowerShell path", () => { | ||
| setTrustedWindowsElevationExecutablesForTests({ powershell: TRUSTED_POWERSHELL }); | ||
| const command = windowsIdentityPowerShellCommandForTests( | ||
| "[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value", | ||
| ); | ||
| expect(command[0]).toBe(TRUSTED_POWERSHELL); | ||
| expect(command).toContain("-NoProfile"); | ||
| expect(command).toContain("-NonInteractive"); | ||
| const windowStyle = command.indexOf("-WindowStyle"); | ||
| expect(windowStyle).toBeGreaterThan(0); | ||
| expect(command[windowStyle + 1]).toBe("Hidden"); | ||
| expect(command[command.length - 2]).toBe("-Command"); | ||
| expect(command[command.length - 1]) | ||
| .toBe("[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value"); | ||
| }); | ||
|
|
||
| test("spawn options are hidden and bounded", () => { | ||
| const options = windowsIdentityPowerShellSpawnOptionsForTests(); | ||
| expect(options.windowsHide).toBe(true); | ||
| expect(options.stdin).toBe("ignore"); | ||
| // Assert the exact budget: the identity lookup contract is an 8-second | ||
| // bound, and a looser assertion would let a silent re-tune through. | ||
| expect(options.timeout).toBe(8_000); | ||
| }); | ||
|
|
||
| test("the hidden trusted lookup resolves the real token on Windows", () => { | ||
| if (process.platform !== "win32") return; | ||
| const identity = resolveEffectiveUserIdentity(); | ||
| expect(identity.platform).toBe("win32"); | ||
| if (identity.platform === "win32") { | ||
| expect(identity.sid).toMatch(/^S-1-(?:\d+-)+\d+$/i); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("Windows process-lookup popup fix (#1278)", () => { | ||
| test("batch start-time lookup is trusted, bounded, and never throws cross-platform", () => { | ||
| // On POSIX hosts the trusted System32 resolver throws inside the win32 | ||
| // branch's catch — the batch must degrade to nulls, exactly like a | ||
| // missing/failed PowerShell, instead of propagating. | ||
| const batch = readProcessStartMsBatch([process.pid], "win32"); | ||
| const startedAtMs = batch.get(process.pid) ?? null; | ||
| if (process.platform === "win32") { | ||
| expect(startedAtMs).not.toBeNull(); | ||
| expect(Number.isFinite(startedAtMs)).toBe(true); | ||
| expect(startedAtMs!).toBeGreaterThan(0); | ||
| } else { | ||
| expect(startedAtMs).toBeNull(); | ||
| } | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.