-
Notifications
You must be signed in to change notification settings - Fork 33
Reagan/windows fixes #391
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
Merged
Reagan/windows fixes #391
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0decce
Feed codex prompts via stdin to fix Windows newline mangling
Cheggin 02d9cd7
Add windows-latest CI smoke test for cmd.exe shim spawn
Cheggin 35f0f9d
Restore Windows caption controls on the main shell window (#388)
Cheggin 3d851a6
Inset hub toolbar right side under Windows caption buttons
Cheggin 5276060
Listen for EPIPE on engine child stdin to avoid main-process crash
Cheggin 1290414
Merge branch 'main' into reagan/windows-fixes
Cheggin c4610a3
Merge branch 'main' into reagan/windows-fixes
Cheggin a2c7553
Merge branch 'main' into reagan/windows-fixes
Cheggin beb8700
Use `more` instead of `findstr` to capture stdin in windows-spawn smoke
Cheggin b50d8e7
Resolve 8.3 short paths and surface diagnostics in windows-spawn smoke
Cheggin a130ac0
Set windowsVerbatimArguments on all cmd.exe spawns to fix #394 regres…
Cheggin 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
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,73 @@ | ||
| import { spawn } from 'node:child_process'; | ||
| import fs from 'node:fs'; | ||
| import os from 'node:os'; | ||
| import path from 'node:path'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { resolveCliSpawn } from '../../../src/main/hl/engines/pathEnrich'; | ||
|
|
||
| const onWindows = process.platform === 'win32'; | ||
|
|
||
| const MULTILINE_PROMPT = [ | ||
| 'You are driving a specific Chromium browser view on this machine.', | ||
| 'Your target is CDP target_id=abc123 on port 9222.', | ||
| 'Read `./AGENTS.md` for how to drive the browser in this harness.', | ||
| '', | ||
| 'Task: start google', | ||
| ].join('\n'); | ||
|
|
||
| describe.skipIf(!onWindows)('codex stdin path on Windows', () => { | ||
| it('round-trips a multi-line prompt through a .cmd shim without word-splitting', async () => { | ||
| // realpathSync.native expands 8.3 short names like C:\Users\RUNNER~1 | ||
| // (which os.tmpdir returns on GitHub Actions Windows runners) to the | ||
| // canonical long form. Short names work in most APIs but `~` can confuse | ||
| // batch-file redirect parsing in some shells/locales. | ||
| const tmpRaw = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-stdin-')); | ||
| const tmp = fs.realpathSync.native(tmpRaw); | ||
| const argvOut = path.join(tmp, 'argv.txt'); | ||
| const stdinOut = path.join(tmp, 'stdin.txt'); | ||
|
|
||
| // The shim uses `more` (not `findstr`) to capture stdin: findstr returns | ||
| // exit code 1 when the input lacks a trailing newline. `more` always | ||
| // exits 0. Trailing `exit /b 0` is belt-and-suspenders. | ||
| const shim = path.join(tmp, 'codex.cmd'); | ||
| fs.writeFileSync( | ||
| shim, | ||
| [ | ||
| '@echo off', | ||
| `(for %%A in (%*) do @echo %%A) > "${argvOut}"`, | ||
| `more > "${stdinOut}"`, | ||
| 'exit /b 0', | ||
| ].join('\r\n'), | ||
| 'utf-8', | ||
| ); | ||
|
|
||
| const env = { ...process.env, Path: `${tmp};${process.env.Path ?? ''}` }; | ||
| const resolved = resolveCliSpawn('codex', ['exec', '--json', '--yolo', '-'], { env, platform: 'win32' }); | ||
| expect(resolved.viaCmdShell).toBe(true); | ||
|
|
||
| let stdoutBuf = ''; | ||
| let stderrBuf = ''; | ||
| const exitCode = await new Promise<number | null>((resolveSpawn, rejectSpawn) => { | ||
| const child = spawn(resolved.command, resolved.args, { env, cwd: tmp, stdio: ['pipe', 'pipe', 'pipe'], ...resolved.spawnOptions }); | ||
| child.stdout.on('data', (c: Buffer) => { stdoutBuf += c.toString('utf-8'); }); | ||
| child.stderr.on('data', (c: Buffer) => { stderrBuf += c.toString('utf-8'); }); | ||
| child.on('error', rejectSpawn); | ||
| child.on('close', (code) => resolveSpawn(code)); | ||
| child.stdin.end(MULTILINE_PROMPT, 'utf-8'); | ||
| }); | ||
|
|
||
| // Surface diagnostics in the failure message so future regressions | ||
| // (cmd.exe quoting, path-with-spaces, missing `more`) are debuggable | ||
| // without re-running the job. | ||
| const diag = `\nspawn: ${resolved.command} ${JSON.stringify(resolved.args)}\nexit: ${exitCode}\nstdout: ${stdoutBuf}\nstderr: ${stderrBuf}\ntmp: ${tmp}`; | ||
| expect(fs.existsSync(argvOut), `argv file not created${diag}`).toBe(true); | ||
| expect(fs.existsSync(stdinOut), `stdin file not created${diag}`).toBe(true); | ||
|
|
||
| const argv = fs.readFileSync(argvOut, 'utf-8').trim().split(/\r?\n/); | ||
| expect(argv).toEqual(['exec', '--json', '--yolo', '-']); | ||
|
|
||
| const stdinSeen = fs.readFileSync(stdinOut, 'utf-8').replace(/\r\n/g, '\n').replace(/\n$/, ''); | ||
| expect(stdinSeen).toBe(MULTILINE_PROMPT); | ||
| expect(stdinSeen.split('\n').length).toBeGreaterThan(1); | ||
| }); | ||
| }); |
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.