Repository navigation
fix(codex): Codex 0.157+ starts in Orca-managed homes instead of failing with SUN_LEN #22878
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3e08106
fix(codex): turn off Codex daemon auto-start in homes whose socket pa…
8625d5a
fix(codex): address review of the daemon socket guard
e2c8dd9
fix(codex): apply the daemon socket guard even when the settings mirr…
brennanb2025 36fd3d1
fix(codex): guard managed account homes when ~/.codex/config.toml is …
brennanb2025 c7a0395
test(codex): keep reset-credit ownership checks scoped to the retry, …
brennanb2025 20d7d59
test(codex): build the account mirror test without a type cast
brennanb2025 2e505eb
fix(codex): keep blocking WSL ownership checks off the no-config guar…
brennanb2025 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | ||
| import type * as NodeOs from 'node:os' | ||
| import { tmpdir } from 'node:os' | ||
| import { join } from 'node:path' | ||
| import { getDefaultSettings } from '../../shared/constants' | ||
|
|
||
| const testState = vi.hoisted(() => ({ fakeHomeDir: '' })) | ||
|
|
||
| vi.mock('electron', () => ({ | ||
| app: { | ||
| getPath: () => { | ||
| throw new Error('tests pass explicit homes') | ||
| } | ||
| } | ||
| })) | ||
|
|
||
| vi.mock('node:os', async () => { | ||
| const actual = await vi.importActual<typeof NodeOs>('node:os') | ||
| return { ...actual, homedir: () => testState.fakeHomeDir } | ||
| }) | ||
|
|
||
| import { CodexConfigMirror } from './codex-config-mirror' | ||
|
|
||
| const OVERRIDE_LINE = 'daemon_auto_start = false # orca: CODEX_HOME too long for the daemon socket' | ||
|
|
||
| describe('CodexConfigMirror without ~/.codex/config.toml', () => { | ||
| let root: string | ||
| let managedHomePath: string | ||
| let mirror: CodexConfigMirror | ||
|
|
||
| beforeEach(() => { | ||
| root = mkdtempSync(join(tmpdir(), 'orca-codex-accounts-mirror-')) | ||
| testState.fakeHomeDir = join(root, 'user-home') | ||
| mkdirSync(testState.fakeHomeDir) | ||
| // Long enough to exceed sun_path on every platform, like a real account home. | ||
| managedHomePath = join(root, 'a'.repeat(80), 'home') | ||
| mkdirSync(managedHomePath, { recursive: true }) | ||
| const settings = { | ||
| ...getDefaultSettings(testState.fakeHomeDir), | ||
| codexManagedAccounts: [ | ||
| { | ||
| id: 'acct', | ||
| email: 'user@example.com', | ||
| managedHomePath, | ||
| createdAt: 1, | ||
| updatedAt: 1, | ||
| lastAuthenticatedAt: 1 | ||
| } | ||
| ] | ||
| } | ||
| mirror = new CodexConfigMirror({ getSettings: () => settings }, (path) => path) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| rmSync(root, { recursive: true, force: true }) | ||
| }) | ||
|
|
||
| it('still guards every managed home against the daemon socket limit', () => { | ||
| mirror.safeSyncToManagedHomes() | ||
|
|
||
| expect(readFileSync(join(managedHomePath, 'config.toml'), 'utf-8')).toBe( | ||
| `[features]\n${OVERRIDE_LINE}\n` | ||
| ) | ||
| expect(existsSync(join(testState.fakeHomeDir, '.codex'))).toBe(false) | ||
| }) | ||
|
|
||
| it('leaves a WSL home to launch prep instead of running its blocking ownership check', () => { | ||
| const assertManagedHomePath = vi.fn((path: string) => path) | ||
| const wslMirror = new CodexConfigMirror( | ||
| { getSettings: () => getDefaultSettings(testState.fakeHomeDir) }, | ||
| assertManagedHomePath | ||
| ) | ||
|
|
||
| wslMirror.safeSyncIntoManagedHome( | ||
| '\\\\wsl.localhost\\Ubuntu\\home\\u\\.local\\share\\orca\\codex-accounts\\acct\\home', | ||
| undefined, | ||
| 'acct' | ||
| ) | ||
|
|
||
| expect(assertManagedHomePath).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('adds the guard without touching settings already in the managed home', () => { | ||
| writeFileSync(join(managedHomePath, 'config.toml'), 'model = "gpt-5"\n') | ||
|
|
||
| mirror.safeSyncIntoManagedHome(managedHomePath, undefined, 'acct') | ||
|
|
||
| expect(readFileSync(join(managedHomePath, 'config.toml'), 'utf-8')).toBe( | ||
| `model = "gpt-5"\n\n[features]\n${OVERRIDE_LINE}\n` | ||
| ) | ||
| }) | ||
| }) |
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
Oops, something went wrong.
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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: stablyai/orca
Length of output: 7862
🏁 Script executed:
Repository: stablyai/orca
Length of output: 45654
🏁 Script executed:
Repository: stablyai/orca
Length of output: 42374
🏁 Script executed:
Repository: stablyai/orca
Length of output: 42800
🏁 Script executed:
Repository: stablyai/orca
Length of output: 41905
🏁 Script executed:
Repository: stablyai/orca
Length of output: 41953
🏁 Script executed:
Repository: stablyai/orca
Length of output: 16968
Guard the selected WSL home when system-home discovery fails.
When
getWslHome()returnsnull, WSL launch preparation returns before callingsyncSystemConfigIntoManagedCodexHome. The no-canonical-config branch also skips the guard. An overlong managed WSL home with no runtime config can then start Codex withoutdaemon_auto_start = false, which can cause theSUN_LENsocket-path startup failure.Apply the guard in WSL launch preparation when the selected managed home has no resolvable system home.
Suggested fix