Repository navigation
Preserve Codex [tui] settings across managed CODEX_HOME remirrors - #9475
Conversation
…emirror
Codex TUI preferences (/statusline, theme, terminal title) are written into
the [tui] table of the managed runtime config.toml, but the write-back
promotion allowlist only covered four top-level scalars — so the next mirror
pass rewrote the runtime config from ~/.codex and silently discarded them.
Extend promotion to the [tui] keys the Codex TUI persists (status_line,
status_line_use_colors, terminal_title, theme), keyed as structured tui.*
paths so the same three-way merge (runtime vs baseline vs ~/.codex) applies:
in-Codex changes promote into ~/.codex before the mirror, and outside edits
to ~/.codex still win over stale runtime values.
The byte-preserving upsert moves to codex-config-settings-upsert.ts (max-lines)
and learns [tui] placement: replace an existing bare or dotted key in place,
insert into the first [tui] body, insert dotted beside existing dotted tui.*
keys, or create one [tui] table at EOF — never defining tui twice, including
when the system config holds an inline tui = {...} table.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds structured TOML upsert utilities for top-level and 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)config/tsconfig.cli.jsonTraceback (most recent call last): 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 627d1d87-cabe-4d1c-bbbc-b693ea364680
📒 Files selected for processing (4)
src/main/codex/codex-config-settings-upsert.tssrc/main/codex/config-settings-promotion.test.tssrc/main/codex/config-settings-promotion.tssrc/main/codex/config-toml-line-scan.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/codex/codex-config-settings-upsert.ts (1)
173-205: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAppending
[tui]after[tui.*]sub-tables creates invalid TOML.If the file already contains a sub-table like
[tui.something], appending a[tui]super-table at the end of the file will result in an unparseable configuration. The TOML specification prohibits defining a super-table after one of its sub-tables.To prevent creating an invalid config,
blocksNewTuiTableshould also be set totrueif a[tui.*]table header is encountered.🛠️ Proposed fix to block new `[tui]` table on sub-tables
const tableName = getTomlTableName(header) if (tableName === 'tui' && !tuiTableSeen) { tuiTableSeen = true tuiBodyActive = true tuiBodyHeaderIndex = index + } else if (tableName && tableName.startsWith('tui.')) { + blocksNewTuiTable = true } // Why: a root [[tui]] is already an array, so appending [tui] would // redefine it and make an otherwise valid config unparseable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 68021262-30e4-41c7-aa93-dd38b7a39a04
📒 Files selected for processing (2)
src/main/codex/codex-config-settings-upsert.tssrc/main/codex/config-settings-promotion.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/codex/config-settings-promotion.test.ts
…-codex-tui-settings-remirror # Conflicts: # src/main/codex/config-settings-promotion.ts # src/main/codex/config-toml-line-scan.ts
…-codex-tui-settings-remirror
…-codex-tui-settings-remirror
…rors (stablyai#9475)" (stablyai#10085) This reverts commit c8381f3.
…ablyai#9475) * fix(codex): promote [tui] settings so they survive the managed-home remirror Codex TUI preferences (/statusline, theme, terminal title) are written into the [tui] table of the managed runtime config.toml, but the write-back promotion allowlist only covered four top-level scalars — so the next mirror pass rewrote the runtime config from ~/.codex and silently discarded them. Extend promotion to the [tui] keys the Codex TUI persists (status_line, status_line_use_colors, terminal_title, theme), keyed as structured tui.* paths so the same three-way merge (runtime vs baseline vs ~/.codex) applies: in-Codex changes promote into ~/.codex before the mirror, and outside edits to ~/.codex still win over stale runtime values. The byte-preserving upsert moves to codex-config-settings-upsert.ts (max-lines) and learns [tui] placement: replace an existing bare or dotted key in place, insert into the first [tui] body, insert dotted beside existing dotted tui.* keys, or create one [tui] table at EOF — never defining tui twice, including when the system config holds an inline tui = {...} table. * Add codex-config-settings-upsert to the CLI tsconfig file list * fix(codex): keep tui upserts out of array tables * fix(codex): handle quoted tui config paths during promotion * fix(codex): harden tui promotion writes
…rors (stablyai#9475)" (stablyai#10085) This reverts commit 254ee71.
…ablyai#10213) * Reapply "Preserve Codex [tui] settings across managed CODEX_HOME remirrors (stablyai#9475)" (stablyai#10085) This reverts commit f86e28f. * fix(codex): anchor settings baseline migration
Fixes #9168
Problem
Codex TUI preferences changed inside an Orca-launched session (
/statusline, theme, terminal title) are written by Codex into the[tui]table of the managed runtimeconfig.toml— but Orca's write-back promotion allowlist only covered four top-level scalars (model,model_reasoning_effort,approval_policy,sandbox_mode). On the next mirror pass the runtime config is rewritten from~/.codex, silently discarding the[tui]changes: a custom status line works in the current session and is gone in the next one.Fix
[tui]keys the Codex TUI persists:status_line,status_line_use_colors,terminal_title,theme. They flow through the same three-way merge (runtime vs baseline vs~/.codex): in-Codex changes are promoted into~/.codexbefore the mirror so the very pass that used to erase them now preserves them, while an outside edit to~/.codexstill wins over a stale runtime value.tui.<key>) so[tui]entries can never collide with a top-level key of the same name. Old baseline files stay valid — a missingtui.*baseline entry degrades safely (analyzed for both upgrade and downgrade).codex-config-settings-upsert.ts(max-lines) and learns[tui]placement with a total rule: replace an existing bare or dotted key in place (keeping its form), else insert bare into the first[tui]body (before any[tui.*]subtable), else insert dotted beside existing dottedtui.*preamble keys, else create exactly one[tui]table at EOF. It never definestuitwice — including the corner where~/.codexholds an inlinetui = {...}table, where the update is dropped instead of corrupting the config.[tui]table body and hand-authored dottedtui.<key>preamble form. Keys under[tui.*]subtables and multiline values are excluded (line-wise editing can't handle them safely), matching the existing top-level behavior.Testing
[tui]block (the shape codex 0.144.6 writes viaconfig/batchWrite) survives a system→managed remirror and reaches a steady state.[tui]neighbors, dotted-form preservation, mixed top-level + tui batches, single[tui]table creation (incl. after a[tui.*]subtable), outside-edit-wins conflicts, deletion non-promotion, CRLF preservation, subtable exclusion, and the inline-table guard.src/main/codexsuite: 11 files, 282 passed / 5 skipped.typecheck:nodeandoxlintclean.Trade-offs / user-visible changes
None beyond the fix itself. Non-allowlisted
[tui]keys,[tui.*]subtable keys, and inline-table configs keep today's behavior (not promoted, fail-safe).Review validation
tui.*key under an array-of-tables is never mistaken for a root key, and a root[[tui]]can never gain an invalid duplicate[tui]table.src/main/codexsuite: 463 passed / 5 skipped. Node + CLI typechecks, changed-file lint/format, and max-lines ratchet passed.Live Electron smoke
The dev Electron build launched with a ready runtime graph; Settings navigation rendered normally and Codex was detected and enabled. A fresh Codex terminal could not be included because this host had exhausted its OS PTY pool (
posix_openptfailed); no existing user terminal sessions were closed. The filesystem end-to-end test above exercises the exact remirror behavior.Agents settings loaded
Codex detected and enabled