Skip to content

feat(codex): opt-in setting to use your default ~/.codex config directory - #5594

Closed
eilon-onyx wants to merge 1 commit into
stablyai:mainfrom
eilon-onyx:feat/codex-use-default-config-dir
Closed

eilon-onyx wants to merge 1 commit into
stablyai:mainfrom
eilon-onyx:feat/codex-use-default-config-dir

Conversation

@eilon-onyx

@eilon-onyx eilon-onyx commented Jun 17, 2026 •

Copy link
Copy Markdown

What & why

Codex launched inside Orca always runs against a managed runtime home — Orca injects CODEX_HOME → ~/Library/Application Support/orca/codex-runtime-home/home, a materialized copy of your config with its own auth/sessions/history. This means Codex doesn't read your real ~/.codex/config.toml; edits to your system config aren't picked up, and history/sessions live somewhere else.

This adds an opt-in setting (default off) — Settings → Accounts → "Use default Codex config directory" — that makes Codex use its native ~/.codex by injecting no CODEX_HOME at all.

Behavior

  • Off (default): byte-identical to today's behavior — managed runtime home is injected. Guarded by a test.
  • On: skipCodexHomeEnv is forced at all three PTY spawn sites, so buildPtyHostEnv deletes CODEX_HOME/ORCA_CODEX_HOME and strips any ambient values, leaving Codex to resolve its own ~/.codex.

Design decisions

  • Codex-only by design. opencode/pi already fall back to the user's real config dir when agentStatusHooksEnabled is off; Codex is the one agent whose home is always managed (even with zero managed accounts), so this setting is scoped to Codex alone.
  • OR, never replace. The new condition ORs into the existing WSL/Windows-shell skip logic at each spawn site — it never weakens those paths; they still fire when the setting is off.
  • Stated trade-off. The setting's description makes clear that using the default home disables Orca's Codex account hot-swap and auth-sync, which depend on the materialized overlay home.
  • Belt-and-suspenders strip. On the local spawn path, enabling the setting also scrubs ambient CODEX_HOME/ORCA_CODEX_HOME inherited from the parent process, so a stale value can't leak into the child PTY (the test asserts this).
  • Opt-in, default false → fully backward compatible.

Tests

Two unit tests in src/main/ipc/pty.test.ts (spawn-env):

  • With the setting on, the built env has no CODEX_HOME/ORCA_CODEX_HOME even when a managed home is selected and ambient values are present — this only holds because of the new OR, so it catches a regression.
  • With the setting off, the managed home is still injected (guards the off-path).

Cross-platform / SSH / agent notes

  • Wired through the shared buildPtyHostEnv, so local, daemon-backed, and SSH/remote Codex spawns all honor the setting identically — no separate wiring.
  • WSL/Windows-incompatible-home skips are preserved when the setting is off.
  • No new dependencies; renderer/main TypeScript only. User-facing strings go through translate() with catalog parity via pnpm sync:localization-catalog.

Checks

  • pnpm exec oxlint — clean on changed files
  • pnpm typecheck — clean
  • pnpm test — full suite passes (17,479 passed / 15 skipped)
  • (Did not run the full pnpm build locally; change is renderer/main TS + localized strings only.)

AI code-review summary

Reviewed for: cross-platform (single shared env path; no platform-specific assumptions added) ✓ · SSH/remote/local (all route through buildPtyHostEnv) ✓ · agent compatibility (scoped to Codex; opencode/pi/claude untouched) ✓ · performance (one boolean settings read at spawn time; no hot-path work) ✓ · UI quality (reuses SettingsSwitchRow inside SearchableSetting, matching MobileEmulatorSettingsPane) ✓ · security (no new surface; the on-path only removes an env injection) ✓.

Screenshots

No screenshot attached yet — it's a standard SettingsSwitchRow in the existing Accounts pane (same primitive as its neighbours). Happy to add one on request.


Open in Stage

ELI5

Codex in Orca usually uses a managed copy of config, so your real ~/.codex is ignored. An opt-in setting lets Codex use your default ~/.codex directory instead, so your real config and history apply.

@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 5 individual chapters for you:

Title
1 Define the Codex home directory setting
2 Implement setting check and PTY environment logic
3 Test PTY environment variable injection
4 Add UI for Codex home directory setting
5 Localize setting labels and descriptions
Open in Stage

Chapters generated by Stage for commit e581a8d on Jun 17, 2026 1:58pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new optional boolean field codexUseDefaultConfigDir is added to GlobalSettings (defaulting to false). A helper function isCodexDefaultHomeEnabled reads this flag. In pty.ts, three PTY spawn paths now include this helper in the skipCodexHomeEnv boolean condition, causing CODEX_HOME and ORCA_CODEX_HOME to be omitted from spawn environments when the flag is true. The Accounts settings pane gains a SettingsSwitchRow toggle wired to the new flag, along with a search catalog entry in accounts-search.ts. Locale files for English, Spanish, Japanese, Korean, and Chinese receive new Codex config directory label/description strings and expanded PR-creation preflight status messages.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately and concisely summarizes the main change—adding an opt-in setting for Codex to use the default ~/.codex config directory instead of Orca's managed home.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description is mostly complete and covers the main template sections, though it does not include an explicit Security Audit section.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0642931d-3ba1-4e6f-b2d6-b6084a30f861

📥 Commits

Reviewing files that changed from the base of the PR and between 6cea158 and e581a8d.

📒 Files selected for processing (12)
  • src/main/agent-hooks/managed-agent-hook-controls.ts
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/renderer/src/components/settings/AccountsPane.tsx
  • src/renderer/src/components/settings/accounts-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/constants.ts
  • src/shared/types.ts

"d8a4c0e369": "Authenticate before creating a {{value0}}.",
"e9b5d1f470": "Check out a branch before creating a {{value0}}.",
"f0c6e2a581": "This branch is not ready for a {{value0}} yet.",
"h3i4j5k607": "Checking whether this branch can create a {{value0}}…"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Malformed localization key breaks catalog consistency

Line 8730 uses h3i4j5k607, which is not a valid SHA1-style hex key and is likely to miss lookups/parity against other locale catalogs. Replace it with the exact generated key from the source catalog sync output.

Based on learnings, locale keys here are auto-keyed from SHA1(file path + source text) and should stay catalog-parity aligned across locales.

Source: Learnings

"d8a4c0e369": "Authenticate before creating a {{value0}}.",
"e9b5d1f470": "Check out a branch before creating a {{value0}}.",
"f0c6e2a581": "This branch is not ready for a {{value0}} yet.",
"h3i4j5k607": "Checking whether this branch can create a {{value0}}…"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix non-catalog key format for the new i18n entry.

"h3i4j5k607" does not match your catalog key convention and can break locale parity/sync for this string. Regenerate this key via the localization sync flow so it uses the standard SHA1-derived format.

Based on learnings, locale entries under src/renderer/src/i18n/locales/ should be auto-keyed using SHA1(file path + source text) and synced via pnpm run sync:localization-catalog.

Source: Learnings

"d8a4c0e369": "Authenticate before creating a {{value0}}.",
"e9b5d1f470": "Check out a branch before creating a {{value0}}.",
"f0c6e2a581": "This branch is not ready for a {{value0}} yet.",
"h3i4j5k607": "Checking whether this branch can create a {{value0}}…"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Malformed localization key breaks catalog-key convention

Line 8730 uses "h3i4j5k607", which is not a valid SHA1-style hex key pattern used by this repo’s localization catalog. Please regenerate/sync this entry so the key matches the auto-key format and stays in parity with other locale files.

Based on learnings: “new strings should be auto-keyed using SHA1(file path + source text)… and catalog parity is maintained via pnpm run sync:localization-catalog.”

Source: Learnings

Comment on lines +8718 to +8730
"c72e5e65d1": "准备此分支并创建 {{value0}}",
"b8e4f2a901": "Wait for the remote operation to finish.",
"c9f3a1b802": "Resolve conflicts before creating a {{value0}}.",
"d2a8c4e703": "No changes on this branch to include in a {{value0}}.",
"e3b9d5f814": "Cannot create a {{value0}} from the default branch.",
"f4c0e6a925": "Commit changes before creating a {{value0}}.",
"a5d1f7b036": "Publish commits before creating a {{value0}}.",
"b6e2a8c147": "Push commits before creating a {{value0}}.",
"c7f3b9d258": "Sync this branch before creating a {{value0}}.",
"d8a4c0e369": "Authenticate before creating a {{value0}}.",
"e9b5d1f470": "Check out a branch before creating a {{value0}}.",
"f0c6e2a581": "This branch is not ready for a {{value0}} yet.",
"h3i4j5k607": "Checking whether this branch can create a {{value0}}…"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check if the file exists and read the relevant section
head -n 8730 src/renderer/src/i18n/locales/zh.json | tail -n 50

Repository: stablyai/orca

Length of output: 2717


🏁 Script executed:

# Let's check the overall structure of keys in the file
head -n 100 src/renderer/src/i18n/locales/zh.json | tail -n 30

Repository: stablyai/orca

Length of output: 1146


🏁 Script executed:

# Search for the specific key mentioned
rg "h3i4j5k607" src/renderer/src/i18n/locales/zh.json -A 2 -B 2

Repository: stablyai/orca

Length of output: 345


🏁 Script executed:

# Search for localization sync tooling or documentation
find . -type f \( -name "*.json" -o -name "*.md" -o -name "*.ts" -o -name "*.js" \) | xargs rg -l "SHA1|sha1|localization.*sync|i18n.*sync" --max-count=20

Repository: stablyai/orca

Length of output: 227


🏁 Script executed:

# Check if there's any script or tooling related to i18n/locale generation
find . -type f \( -name "*i18n*" -o -name "*locale*" -o -name "*translation*" \) | grep -E "\.(js|ts|py|sh)$" | head -20

Repository: stablyai/orca

Length of output: 175


🏁 Script executed:

# Look for pattern validation or hash generation in the codebase
rg "h3i4j5k607|auto.*key|generate.*key" --type ts --type js

Repository: stablyai/orca

Length of output: 22441


🏁 Script executed:

# Check the TypeScript file that references h3i4j5k607
cat -n src/renderer/src/components/right-sidebar/source-control-primary-create-pr-intent-action.ts | grep -A 5 -B 5 "h3i4j5k607"

Repository: stablyai/orca

Length of output: 489


🏁 Script executed:

# Look for localization key generation or validation logic
rg "SHA1|sha1|hash|keygen" src/main/i18n/ src/shared/ui-locale.ts --type ts -A 3 -B 3

Repository: stablyai/orca

Length of output: 39


🏁 Script executed:

# Check if there's documentation about i18n keys or patterns
find . -type f \( -name "*.md" \) -exec rg -l "i18n|locale|SHA1.*key|auto.*key" {} \; | head -10

Repository: stablyai/orca

Length of output: 121


🏁 Script executed:

# Check the localization audit documentation
cat ./config/localization-audit.md

Repository: stablyai/orca

Length of output: 4075


🏁 Script executed:

# Search for how the localization keys are supposed to be generated
rg "auto\." src/renderer/src/i18n/locales/zh.json | head -5

Repository: stablyai/orca

Length of output: 39


🏁 Script executed:

# Look for the pattern of how keys are structured in actual code
rg "translate\(" src/renderer/src/components/right-sidebar/source-control-primary-create-pr-intent-action.ts -B 1 -A 2 | head -30

Repository: stablyai/orca

Length of output: 1204


🏁 Script executed:

# Verify the SHA1 pattern by checking what a properly generated key might be
# Let's examine the localization sync script to understand key generation
find . -type f -name "*audit*" -o -name "*sync*" -o -name "*localization*" | grep -E "\.(js|mjs|ts)$" | head -10

Repository: stablyai/orca

Length of output: 576


🏁 Script executed:

# Check the actual sync script to understand key generation
cat config/scripts/audit-localization-coverage.mjs 2>/dev/null | head -100

Repository: stablyai/orca

Length of output: 2305


🏁 Script executed:

# Look at the verify-localization-catalog script to understand key generation
head -150 config/scripts/verify-localization-catalog.mjs

Repository: stablyai/orca

Length of output: 4349


🏁 Script executed:

# Search for references to crypto/hash generation in localization scripts
rg "crypto|hash|SHA|md5|createHash" config/scripts/ --type js --type mjs -A 2 -B 2

Repository: stablyai/orca

Length of output: 85


🏁 Script executed:

# Check if h3i4j5k607 appears anywhere else in the codebase
rg "h3i4j5k607" --type ts --type tsx --type js --type json

Repository: stablyai/orca

Length of output: 85


🏁 Script executed:

# Search for the key generation logic more broadly
rg "createHash|crypto" config/scripts/ -A 5

Repository: stablyai/orca

Length of output: 3118


🏁 Script executed:

# Look for SHA1 or hash patterns in the verify script with simpler approach
cat config/scripts/verify-localization-catalog.mjs | grep -A 10 -B 10 "hash\|crypto\|sha" | head -50

Repository: stablyai/orca

Length of output: 39


🏁 Script executed:

# Check if there's a catalog sync script that might regenerate keys
cat config/scripts/sync-localization-catalog.mjs 2>/dev/null || echo "File not found, searching for similar..."

Repository: stablyai/orca

Length of output: 98


🏁 Script executed:

# List all scripts in config/scripts
ls -la config/scripts/

Repository: stablyai/orca

Length of output: 7588


🏁 Script executed:

# Perfect! Let's examine the localize-renderer-strings.mjs to confirm the exact pattern
cat config/scripts/localize-renderer-strings.mjs | head -100

Repository: stablyai/orca

Length of output: 3076


🏁 Script executed:

# Now let's generate what the correct key should be for that source text
node -e "const crypto = require('crypto'); const source = 'Checking whether this branch can create a {{value0}}…'; const hash = crypto.createHash('sha1').update(source).digest('hex').slice(0, 10); console.log('Correct key would be: auto.components.right.sidebar.source.control.primary.action.' + hash);"

Repository: stablyai/orca

Length of output: 150


Regenerate the localization key with correct SHA1 hash.

The key h3i4j5k607 contains non-hexadecimal characters (h, i, j, k) and doesn't match the SHA1 pattern used throughout the catalog. The correct key should be auto.components.right.sidebar.source.control.primary.action.77a3a268f7. Update this in both the locale file and the reference in src/renderer/src/components/right-sidebar/source-control-primary-create-pr-intent-action.ts, then rerun the localization catalog sync to ensure consistency.

Source: Learnings

@AmethystLiang

Copy link
Copy Markdown
Contributor

Thanks for the contribution — the underlying change is already implemented in main, so we’re closing this PR as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants