-
Notifications
You must be signed in to change notification settings - Fork 642
Fix Codex chat startup for WSL UNC workspaces on Windows #724
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
Open
MansGullberg
wants to merge
4
commits into
pingdotgg:main
Choose a base branch
from
MansGullberg:codex/fix-windows-unc-cwd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+227
−27
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cfff6c2
Handle Windows UNC working directories across shell-based server proc…
MansGullberg 8b59ce9
Fix ProviderHealth windowsShell import after broad UNC shell launch c…
MansGullberg 1068084
Fix Windows UNC Codex app-server launches and Codex collaboration mod…
MansGullberg 0952c5f
Address review follow-ups for UNC wrapper env merging and verbatim pa…
MansGullberg 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
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
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,83 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { isWindowsUncPath, resolveShellCommand } from "./windowsShell"; | ||
|
|
||
| describe("isWindowsUncPath", () => { | ||
| it("detects UNC paths on Windows", () => { | ||
| expect(isWindowsUncPath("\\\\wsl.localhost\\Ubuntu\\home\\user\\repo", "win32")).toBe(true); | ||
| }); | ||
|
|
||
| it("ignores drive-letter paths on Windows", () => { | ||
| expect(isWindowsUncPath("C:\\Users\\user\\repo", "win32")).toBe(false); | ||
| }); | ||
|
|
||
| it("ignores UNC-looking paths on non-Windows platforms", () => { | ||
| expect(isWindowsUncPath("\\\\wsl.localhost\\Ubuntu\\home\\user\\repo", "linux")).toBe(false); | ||
| }); | ||
|
|
||
| it("ignores Windows verbatim paths on Windows", () => { | ||
| expect(isWindowsUncPath("\\\\?\\C:\\Users\\user\\repo", "win32")).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("resolveShellCommand", () => { | ||
| it("keeps the normal Windows shell path for drive-letter cwd values", () => { | ||
| expect( | ||
| resolveShellCommand("codex", ["app-server"], { | ||
| cwd: "C:\\Users\\user\\repo", | ||
| platform: "win32", | ||
| }), | ||
| ).toEqual({ | ||
| command: "codex", | ||
| args: ["app-server"], | ||
| cwd: "C:\\Users\\user\\repo", | ||
| shell: true, | ||
| }); | ||
| }); | ||
|
|
||
| it("wraps UNC cwd values through cmd pushd on Windows", () => { | ||
| expect( | ||
| resolveShellCommand("codex", ["app-server"], { | ||
| cwd: "\\\\wsl.localhost\\Ubuntu\\home\\user\\repo", | ||
| platform: "win32", | ||
| }), | ||
| ).toEqual({ | ||
| command: "cmd.exe", | ||
| args: [ | ||
| "/d", | ||
| "/c", | ||
| 'pushd %__T3CODE_WINDOWS_UNC_CWD% && %__T3CODE_WINDOWS_UNC_COMMAND% %__T3CODE_WINDOWS_UNC_ARG_0%', | ||
| ], | ||
| cwd: undefined, | ||
| env: { | ||
| __T3CODE_WINDOWS_UNC_COMMAND: '"codex"', | ||
| __T3CODE_WINDOWS_UNC_CWD: '"\\\\wsl.localhost\\Ubuntu\\home\\user\\repo"', | ||
| __T3CODE_WINDOWS_UNC_ARG_0: '"app-server"', | ||
| }, | ||
| shell: false, | ||
| }); | ||
| }); | ||
|
|
||
| it("quotes command paths with spaces for UNC cwd values", () => { | ||
| expect( | ||
| resolveShellCommand("C:\\Users\\user\\AppData\\Roaming\\npm\\codex.cmd", ["--version"], { | ||
| cwd: "\\\\wsl.localhost\\Ubuntu\\home\\user\\repo", | ||
| platform: "win32", | ||
| }), | ||
| ).toEqual({ | ||
| command: "cmd.exe", | ||
| args: [ | ||
| "/d", | ||
| "/c", | ||
| "pushd %__T3CODE_WINDOWS_UNC_CWD% && call %__T3CODE_WINDOWS_UNC_COMMAND% %__T3CODE_WINDOWS_UNC_ARG_0%", | ||
| ], | ||
| cwd: undefined, | ||
| env: { | ||
| __T3CODE_WINDOWS_UNC_COMMAND: '"C:\\Users\\user\\AppData\\Roaming\\npm\\codex.cmd"', | ||
| __T3CODE_WINDOWS_UNC_CWD: '"\\\\wsl.localhost\\Ubuntu\\home\\user\\repo"', | ||
| __T3CODE_WINDOWS_UNC_ARG_0: '"--version"', | ||
| }, | ||
| shell: false, | ||
| }); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
Layers/CodexTextGeneration.ts:227When
cwdis a Windows UNC path,resolveShellCommandreturns anenvobject containing only the UNC wrapper variables. Passing this directly toChildProcess.makereplaces the entire process environment, strippingPATHandSystemRoot, which causes thecodexcommand to fail with "Command not found" because executables cannot be located.Also found in 1 other location(s)
apps/server/scripts/cli.ts:228🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 0952c5f. UNC wrapper env vars are now merged with process.env in CodexTextGeneration, and the same merge was added to the CLI build/publish subprocess paths so PATH/SystemRoot are preserved for UNC working directories.