codex-multi-auth icon indicating copy to clipboard operation
codex-multi-auth copied to clipboard

[bug] Login dashboard text is nearly invisible on light terminal themes

Open quanganhdo opened this issue 2 months ago β€’ 1 comments

Summary

Running codex-multi-auth login in Ghostty with a light theme makes the dashboard title and some saved-account rows nearly invisible. The dashboard uses pale foreground colors on the terminal's light background, even though the terminal's default foreground is dark and readable. Disabling colors or switching to the 16-color profile does not provide a satisfactory colored UI on this theme.

Reproduction

  1. Use Ghostty with Catppuccin Latte, or a comparable light terminal theme. For Latte, the background is #eff1f5 and the default foreground is #4c4f69.
  2. Have saved accounts available so the dashboard includes account rows.
  3. Run codex-multi-auth login with the default truecolor profile and no color-related environment overrides.
  4. Inspect the β€œAccounts Dashboard” title and the saved-account rows that use the ordinary pale text color.

Expected Behavior

The dashboard title, account labels, section labels, and help text should remain readable on light terminal backgrounds while retaining useful action colors, status badges, and selection highlights.

A light palette or a way to respect/configure the terminal's default text foreground would address this. Foreground text drawn directly on the terminal background should be handled separately from pale text drawn on the dashboard's dark selection and badge backgrounds.

Actual Behavior

  • The dashboard title and some saved-account labels blend into the light background and are difficult to read.
  • Section labels and help text also have weak contrast.
  • Green action text and status badges with their own dark backgrounds are more readable, so the problem does not affect all elements equally.

Workarounds tried:

FORCE_COLOR=0 codex-multi-auth login
CODEX_TUI_COLOR_PROFILE=ansi16 codex-multi-auth login

Neither produces a satisfactory result: disabling colors loses useful styling, and the ANSI16 profile still looks poor with this light theme.

Environment

  • codex --version: codex-cli 0.160.0
  • codex-multi-auth status output summary: Not collected; the affected screen is the interactive login dashboard.
  • codex-multi-auth rotation status output summary: Not applicable to this rendering issue.
  • npm ls -g codex-multi-auth: [email protected] in the active mise-managed Node installation, verified with its installation prefix.
  • OS: macOS 27.2, build 26B5091g
  • Node.js: v25.9.0
  • Terminal: Ghostty 1.3.2-main-+4ff699343 (tip)
  • Terminal theme: Catppuccin Latte, light mode
  • Dashboard color profile: Default truecolor
  • Dashboard palette: Green

Diagnostic Outputs

The following source observations may help locate the cause:

  • In lib/ui/theme.ts, getColors() assigns heading: truecolor(240, 253, 244) (#f0fdf4) and muted: truecolor(148, 163, 184) (#94a3b8). These same values are present in the installed 2.3.3 package.
  • In lib/ui/select.ts, the dashboard title uses the heading color, and the default branch of codexColorCode() also returns that color for ordinary menu text.
  • #f0fdf4 is very close to Latte's background, #eff1f5. Because this is an explicit RGB escape sequence, changing the terminal's ANSI white palette entry does not change it.
  • The green and blue dashboard palettes share the same heading and muted colors. The current theme options do not provide a light-background variant.

codex-multi-auth check, report --json, and doctor --json outputs have not been collected; this report concerns interactive text rendering.

Logs (Optional)

No request logs collected for this UI issue.

Compliance Confirmation

  • [x] I am using this project for personal development workflows.
  • [x] This report does not request policy bypasses or prohibited usage.
  • [x] I removed any secrets/tokens from this report.

quanganhdo avatar Oct 02 '26 17:10 quanganhdo

Coding Plan

Summary

  • add a dashboard preference uiBackgroundMode with default dark and alternative light. follow the uiThemePreset/uiAccentColor pattern at lib/dashboard-settings.ts:131-151,293-390. keep background appearance separate from color depth.
  • in light mode, use terminal default fg (\x1b[39m) for heading at lib/ui/theme.ts:147-195. use darker shades for muted, action colors, status colors, and accent colors. keep paired focus and badge fg/bg unchanged at lib/ui/theme.ts:163-164,178-179,193-194 and lib/ui/format.ts:43-111.
  • add the field to every explicit inventory: normalization, clone, equality, THEME_PANEL_KEYS, runtime setter, and reset helper. otherwise, load, save, or plugin-side runtime updates can drop the preference. key integration points are lib/codex-manager/dashboard-settings-data.ts:41-42,103-104, lib/codex-manager/settings-hub/dashboard.ts:160-175, and lib/ui/runtime.ts:51-67,88.
  • add exact token and selector-rendering regression tests. explicitly cover the currently untested default branch at lib/ui/select.ts:275 with the tty mock at test/select.test.ts:3-38.
  • cover concurrent saves and windows cleanup at test/unified-settings.test.ts:699-862. cover cancel and scoped reset at test/codex-manager-cli.test.ts:11539-11583.
Design Choices
Design Choice 1: expose light-background readability through a dashboard preference

Options Considered:

  1. globally change heading/muted defaults to values that work on both backgrounds, with no new setting.
  2. add a persisted dashboard preference uiBackgroundMode: "dark" | "light" (default dark). forward the preference to a new background theme option. use that option to select appearance-aware foreground tokens.
  3. auto-detect the terminal background through COLORFGBG or an osc 11 query.

Chosen Option: 2

Rationale: option 2. it is backward compatible for dark-terminal users. it follows the existing uiThemePreset/uiAccentColor pattern. option 3 is unreliable: ghostty does not set COLORFGBG, and an osc query needs raw stdin reads that are risky on windows consoles.

Design Choice 2: use the terminal default foreground for light-mode title and ordinary text

Options Considered:

  1. use a fixed dark rgb, for example slate-800, for heading in light mode.
  2. use the terminal default foreground sgr \x1b[39m for heading in light mode in all profiles. use darker explicit values for muted, primary/success/border, accent, warning, and danger.

Chosen Option: 2

Rationale: option 2. latte defines its default fg as #4c4f69, and option 2 honors that value exactly in every depth. action colors stay saturated but dark enough for light backgrounds.

Design Choice 3: keep the current token set instead of adding a separate text token

Options Considered:

  1. add a new text token to UiThemeColors and reroute the default branch.
  2. keep the current token set and make heading appearance-aware.

Chosen Option: 2

Rationale: option 2. in light mode, the title and ordinary text both need the default fg. a new token adds churn in many consumers (lib/codex-manager/commands/status.ts, lib/codex-manager/health-check.ts, index.ts) and fixes no additional symptom.

Design Choice 4: ship only the dashboard preference without an env override

Options Considered:

  1. add an env override, for example CODEX_TUI_BACKGROUND, and a plugin-config field.
  2. ship only the dashboard preference.

Chosen Option: 2

Rationale: option 2. codex-multi-auth login already loads dashboard settings at lib/codex-manager.ts:656-657, so the dashboard preference covers the reported screen. an env override can follow later without schema changes.

πŸ’‘ User Tips

Regenerate the plan with different choices with @coderabbitai <feedback>.

Implementation Steps

Phase 1: appearance-aware theme tokens

add a background dimension to theme construction and runtime state. change only foregrounds drawn directly on the terminal background. these tasks share the lib/ui/ layer and one test surface.

no light or dark concept exists today. palette and profile are separate from background brightness. the ticket asks to respect the terminal default foreground or provide a light palette. codexColorCode() falls back to heading for ordinary labels at lib/ui/select.ts:275.

Task 1: add the background option to createUiTheme()

give the theme a light variant. keep focus and badge pairs unchanged.

  • at lib/ui/theme.ts:5-8, add the exported type UiBackground = "dark" | "light".
  • at lib/ui/theme.ts:245-265, add an optional background field to the inline options type of createUiTheme(). default to dark. pass background into getColors() and accent resolution at lib/ui/theme.ts:99-134.
  • dark must produce byte-identical output to the current tokens. this prevents a regression for existing users.
  • for light, override only background-relative foregrounds in each profile:
    • heading β†’ \x1b[39m (terminal default fg) in all depths.
    • muted β†’ a mid-dark slate. examples are truecolor (71,85,105), ansi256 240, and ansi16 90. the value must remain readable when lib/codex-manager/formatters/text-style.ts:8-16 adds dim.
    • primary/success/border β†’ darker palette shades. for green, use truecolor green-700, ansi256 28, and ansi16 32. for blue, use blue-700, ansi256 26, and ansi16 34.
    • each accent value β†’ its darker variant, for example cyan-700 and amber-700.
    • warning and danger β†’ amber-700 and red-700. use matching ansi256 and ansi16 non-bright codes.
  • keep focusBg and focusText unchanged across backgrounds. they form an explicit fg/bg pair at lib/ui/theme.ts:163-164,178-179,193-194.
  • keep reset and dim unchanged. keep the disableColor blanking of all tokens at lib/ui/theme.ts:209-226. blanking must also cover the new light values.
  • export UiBackground from the internal barrel at lib/ui/index.ts:30-38. this is not a public package export (package.json:7-38). do not change test/public-api-contract.test.ts:19-52.
Task 2: carry background through process-global runtime state

make the preference survive every setUiRuntimeOptions() call.

  • at lib/ui/runtime.ts:10-30, add background to the runtime options interface and defaults. default to dark.
  • at lib/ui/runtime.ts:51-67, resolve an omitted background from current state. retain the value in the rebuilt object. forward it to createUiTheme().
  • this preservation is required because lib/runtime/ui-runtime.ts:8-20 and plugin-host paths (index.ts:745,771,3118,3628) call the setter without dashboard fields.
  • at lib/ui/runtime.ts:88, make resetUiRuntimeOptions() restore dark.
  • without this reset, process-global state can leak between vitest files under the single-worker run (test/AGENTS.md:170-188).
Task 3: add theme and selector regression tests

current tests assert only that an escape is present. add exact-value assertions so the bug cannot return silently.

  • at test/ui-theme.test.ts:8-41, add table-driven exact assertions for dark heading and muted in all three profiles. pin today's values.
  • in test/ui-theme.test.ts, add a light-mode matrix: 3 profiles Γ— 2 palettes Γ— 4 accents. assert exact sgr strings. include heading === "\x1b[39m". use disableColor: false, as existing tests do.
  • assert that focusBg/focusText are equal between dark and light for every profile and palette.
  • extend test/ui-theme.test.ts:78-84. with disableColor: true and background: "light", every token must be "".
  • in test/select.test.ts, use the existing tty mock and stdout.write spy at test/select.test.ts:3-38. render a menu with a light theme. include a title, heading item, disabled item, ordinary unselected item, hint, and help text.
  • assert that the title and ordinary label start with \x1b[39m. assert that the section heading and help text use light muted. assert that the selected row still uses focusBg + focusText.
  • flag the missing regression test: no current test covers the codexColorCode() default branch at lib/ui/select.ts:275. the light-theme render test must cover this branch.
  • in test/ui-runtime.test.ts, test that a profile-only update preserves an omitted background. test that resetUiRuntimeOptions() restores dark.
  • test/ui-format.test.ts:56-63 must still pass without changes. badges are intentionally out of scope.
πŸ€– Prompt for AI agents
implement appearance-aware foreground tokens and preserve the background choice
in process-global runtime state. keep dark output byte-identical and keep paired
focus and badge colors unchanged.

- theme construction:
- add `UiBackground = "dark" | "light"` at `lib/ui/theme.ts:5-8` and export it
through `lib/ui/index.ts:30-38` only. leave the public-api contract at
`test/public-api-contract.test.ts:19-52` unchanged.
- add optional `background`, default `dark`, to `createUiTheme()` at
`lib/ui/theme.ts:245-265`. pass it to `getColors()` and accent resolution at
`lib/ui/theme.ts:99-134`.
- for light mode, use terminal default fg `\x1b[39m` for `heading` in all
profiles. use the specified mid-dark slate for `muted`, darker green/blue
palette shades for `primary`/`success`/`border`, darker accent variants,
amber-700 for `warning`, and red-700 for `danger`. use the specified ansi codes
and matching non-bright action/status codes.
- preserve `focusBg`, `focusText`, `reset`, and `dim`. retain all-token
`disableColor` blanking at `lib/ui/theme.ts:209-226`.
- runtime propagation:
  - add `background` with default `dark` at `lib/ui/runtime.ts:10-30`.
- at `lib/ui/runtime.ts:51-67`, preserve an omitted value from current state and
forward it into each rebuilt theme.
- reset to `dark` at `lib/ui/runtime.ts:88` to prevent single-worker test-state
leaks.
- regression coverage:
- pin exact dark `heading`/`muted` values in all profiles at
`test/ui-theme.test.ts:8-41`.
- add the 3-profile Γ— 2-palette Γ— 4-accent light matrix with exact sgr
assertions and `disableColor: false`. compare focus pairs across backgrounds.
extend `test/ui-theme.test.ts:78-84` to verify light-mode blanking.
- use the tty mock and write spy at `test/select.test.ts:3-38` to cover the
title, heading item, disabled item, ordinary unselected item, hint, help text,
and selected focus pair. explicitly cover the previously untested default branch
at `lib/ui/select.ts:275`.
- test background preservation and reset in `test/ui-runtime.test.ts`. keep
`test/ui-format.test.ts:56-63` passing unchanged.
- edit source only. do not edit `dist/`, use `as any`, or add ts suppression
comments. do not change badge tables at `lib/ui/format.ts:43-111`,
`lib/ui/auth-menu-builder.ts:128`, or focus-pair values. flag the latte
muted-plus-dim and windows ansi16 manual checks in the pr.

Phase 2: dashboard preference persistence and propagation

add uiBackgroundMode to every explicit settings inventory. prevent normalization, cloning, equality checks, and keyed persistence from dropping the field. use the existing dashboard preference pattern at lib/dashboard-settings.ts:131-151,293-390.

Task 1: add the persisted field, default, and normalization
  • at lib/dashboard-settings.ts:12-32,49-76, add uiBackgroundMode: "dark" | "light" to DashboardDisplaySettings and defaults. default to dark.
  • at lib/dashboard-settings.ts:131-151, add a normalizer. exactly "light" β†’ light. any other value β†’ dark. keep this case-sensitive, like uiThemePreset.
  • at lib/dashboard-settings.ts:348-352, add the field to explicit reconstruction. without this change, load, legacy migration at lib/dashboard-settings.ts:410-439, and save at lib/dashboard-settings.ts:454-458 strip the field.
  • legacy dashboard-settings.json files do not contain the field. normalize them to dark. existing users must see no change.
Task 2: update clone, equality, ownership, and the runtime adapter
  • at lib/codex-manager/dashboard-settings-data.ts:41-42, add the field to the clone. at lib/codex-manager/dashboard-settings-data.ts:103-104, add it to the equality comparison.
  • without the equality change, a background-only edit compares as unchanged at lib/codex-manager/unified-settings-controller.ts:97-106 and never persists.
  • at lib/codex-manager/settings-hub/dashboard.ts:160-163, add uiBackgroundMode to THEME_PANEL_KEYS. this list controls scoped reset and the keyed merge at lib/codex-manager/settings-hub/shared.ts:73-107.
  • at lib/codex-manager/settings-hub/dashboard.ts:165-175, map uiBackgroundMode to runtime background, with default dark. preserve profile, glyph mode, and v2 enablement.
  • at lib/codex-manager/settings-hub/dashboard.ts:126-159, add a background option inventory next to the palette and accent inventories.
  • concurrency risk: the save path reloads settings, merges only theme-owned keys, and writes through the unified-settings queue with a stale-record retry at lib/unified-settings.ts:564-609. the new key must be in THEME_PANEL_KEYS. otherwise, a concurrent save from another panel or process can overwrite the new key with a stale value.
  • windows edge case: keep the queued retry for EBUSY/EPERM (lib/AGENTS.md:281-283). do not add a direct fs.writeFile path.
  • keep layering intact. do not make lib/ui/ import dashboard settings (lib/AGENTS.md:268-272). only the manager adapter maps the preference.
Task 3: add persistence regression tests
  • at test/dashboard-settings.test.ts:316-401, test default dark; preservation of "light"; and normalization of "Light", "auto", and 42 to dark.
  • at test/dashboard-settings.test.ts:35-112, add a round-trip case. at test/dashboard-settings.test.ts:174, add a legacy migration case with no field. expect dark.
  • at test/dashboard-settings-data.test.ts:56-57,131-132, add the field to clone and equality inventories. add a background-only difference case.
  • at test/settings-hub-utils.test.ts:715-722, assert that the adapter forwards background and preserves the env-selected profile.
  • at test/unified-settings-controller.test.ts:82-125, assert that a background-only change persists and reapplies the runtime.
  • at test/unified-settings.test.ts:699-862, add a concurrency case. interleave a theme save containing uiBackgroundMode with an unrelated-section write. assert that both values survive.
  • windows cleanup: use removeWithRetry for the concurrency case at test/unified-settings.test.ts:699-862.
πŸ€– Prompt for AI agents
persist `uiBackgroundMode` and propagate it through every explicit settings
inventory. preserve existing appearance by default and prevent background-only
edits or concurrent saves from losing the preference.

- settings schema and normalization:
- add `uiBackgroundMode: "dark" | "light"`, default `dark`, at
`lib/dashboard-settings.ts:12-32,49-76`.
- at `lib/dashboard-settings.ts:131-151`, normalize exactly `"light"` to `light`
and all other values to `dark`. keep normalization case-sensitive.
- include the field in reconstruction at `lib/dashboard-settings.ts:348-352` so
load, legacy migration, and save retain it. legacy files without the field must
resolve to `dark`.
- inventories and adapter:
- include the field in clone and equality at
`lib/codex-manager/dashboard-settings-data.ts:41-42,103-104`. background-only
edits must no longer compare as unchanged.
- add a background option inventory at
`lib/codex-manager/settings-hub/dashboard.ts:126-159`. add `uiBackgroundMode` to
`THEME_PANEL_KEYS` at `lib/codex-manager/settings-hub/dashboard.ts:160-163`.
- map the field to runtime `background`, default `dark`, at
`lib/codex-manager/settings-hub/dashboard.ts:165-175`. preserve profile, glyph
mode, and v2 enablement.
- keep dashboard imports out of `lib/ui/`. map the preference only in the
manager adapter.
- concurrency and windows safeguards:
- retain the reload, theme-owned keyed merge, unified-settings queue, and
stale-record retry at `lib/unified-settings.ts:564-609` and
`lib/codex-manager/settings-hub/shared.ts:73-107`.
- explicitly prevent stale concurrent writes by including the field in
`THEME_PANEL_KEYS`.
- retain queued `EBUSY`/`EPERM` retries. do not add direct `fs.writeFile`
writes.
- tests:
- add normalization, round-trip, and missing-field legacy migration cases at
`test/dashboard-settings.test.ts:35-112,174,316-401`.
- update clone/equality inventories and test a background-only difference at
`test/dashboard-settings-data.test.ts:56-57,131-132`.
- test background forwarding with the env-selected profile preserved at
`test/settings-hub-utils.test.ts:715-722`.
- test persistence and runtime reapplication for background-only edits at
`test/unified-settings-controller.test.ts:82-125`.
- interleave a theme save and unrelated-section write at
`test/unified-settings.test.ts:699-862`. verify both values survive. use
`removeWithRetry` for windows cleanup.
- edit source only. do not edit `dist/`, use `as any`, or add ts suppression
comments.

Phase 3: theme editor, copy, and docs

make the preference discoverable in the theme editor at lib/codex-manager/theme-settings-panel.ts:39-164. retain the live-preview, cancel, and reset contracts (AGENTS.md:155). the reporter tried env workarounds first, but this plan ships only the dashboard preference.

Task 1: add the background selector to the theme panel
  • at lib/codex-manager/theme-settings-panel.ts:11-32, extend the action and options interfaces with background choices.
  • at lib/codex-manager/theme-settings-panel.ts:49-106, add "Dark background" and "Light background" rows. mark the current selection with the same marker as palette and accent.
  • at lib/codex-manager/theme-settings-panel.ts:156-164, apply the selection to the draft and preview it immediately. the panel renders itself, so this gives a live light preview.
  • cancel and q reapply the cloned baseline at lib/codex-manager/theme-settings-panel.ts:134-147. the clone now includes the field, so a light preview must revert correctly.
  • reset at lib/codex-manager/theme-settings-panel.ts:150-154 restores dark through THEME_PANEL_KEYS.
  • forward the new option inventory through lib/codex-manager/settings-panels.ts:125-146 and lib/codex-manager/settings-hub/dashboard.ts:276-289.
  • save-failure edge case: lib/codex-manager/settings-hub/shared.ts:73-107 warns and returns a fallback, but the preview stays applied. keep this existing behavior. document it only in the pr.
Task 2: update copy and documentation
  • at lib/ui/ui-copy.ts:144-146,161 and lib/codex-manager/settings-hub-menu.ts:37, update theme menu descriptions to mention background mode.
  • at docs/reference/settings.md:93-95, add a uiBackgroundMode row (dark | light, default dark). state that codexTuiColorProfile at docs/reference/settings.md:224 controls only color depth, as implemented at lib/config.ts:850-873.
  • at docs/configuration.md:99, add a short note: on light terminals, set background to light in settings β†’ theme. CODEX_TUI_COLOR_PROFILE does not change appearance.
Task 3: add panel regression tests and run validation
  • at test/settings-panels.test.ts:149-172, assert that the adapter forwards background options.
  • at test/codex-manager-cli.test.ts:11539-11583, extend the panel-scoped reset case. after selecting light, reset must restore dark. reset must not change other panels.
  • add a theme-panel case: select light, then cancel with q. the runtime must return to dark. nothing may persist.
  • run npm run typecheck, npm run lint, and npm test.
  • keep the 80% coverage thresholds (test/AGENTS.md:170-188).
πŸ€– Prompt for AI agents
add a discoverable background selector with immediate live preview. preserve
cancel, scoped reset, and existing save-failure behavior while updating copy,
documentation, and regression tests.

- theme panel:
- extend action and options interfaces at
`lib/codex-manager/theme-settings-panel.ts:11-32` with background choices.
- add "Dark background" and "Light background" rows at
`lib/codex-manager/theme-settings-panel.ts:49-106`. use the existing
palette/accent selection marker.
- apply background changes to the draft and preview immediately at
`lib/codex-manager/theme-settings-panel.ts:156-164`.
- keep cancel and `q` restoring the cloned baseline at
`lib/codex-manager/theme-settings-panel.ts:134-147`. use the updated clone to
restore background correctly.
- keep reset restoring `dark` through `THEME_PANEL_KEYS` at
`lib/codex-manager/theme-settings-panel.ts:150-154`.
- forward background options through
`lib/codex-manager/settings-panels.ts:125-146` and
`lib/codex-manager/settings-hub/dashboard.ts:276-289`.
- if save fails, retain the warning, fallback, and applied preview behavior at
`lib/codex-manager/settings-hub/shared.ts:73-107`. document this behavior only
in the pr.
- copy and docs:
- mention background mode in theme descriptions at
`lib/ui/ui-copy.ts:144-146,161` and `lib/codex-manager/settings-hub-menu.ts:37`.
- add the `uiBackgroundMode` row with `dark` | `light` and default `dark` at
`docs/reference/settings.md:93-95`. clarify that `codexTuiColorProfile` controls
only color depth at `docs/reference/settings.md:224`, consistent with
`lib/config.ts:850-873`.
- at `docs/configuration.md:99`, explain that light-terminal users must choose
light background in settings β†’ theme. state that `CODEX_TUI_COLOR_PROFILE` does
not change appearance.
- tests and validation:
  - test option forwarding at `test/settings-panels.test.ts:149-172`.
- extend scoped reset at `test/codex-manager-cli.test.ts:11539-11583` to restore
`dark` after selecting light without changing other panels.
- add a light-then-`q` regression case. verify runtime restoration to `dark` and
no persistence.
- run `npm run typecheck`, `npm run lint`, and `npm test`. retain the 80%
coverage thresholds in `test/AGENTS.md:170-188`.
- follow-up constraints:
- edit source only. do not edit `dist/`, use `as any`, or add ts suppression
comments.
- do not add auto-detection, an env override, plugin-host appearance loading, a
fix for the no-color badge escape leak at `lib/ui/format.ts:199-207`, or changes
to the unused `selectedEmphasis` option.
- flag the latte check for muted plus dim at
`lib/codex-manager/formatters/text-style.ts:8-16`. flag manual windows terminal
and conhost checks for palette-dependent ansi16 light values.
Research

ticket summary

the login dashboard uses fixed pale rgb foregrounds for its title, ordinary account rows, section labels, and help text. examples include heading #f0fdf4 and muted #94a3b8 at lib/ui/theme.ts:155-156. these colors are nearly invisible on light terminal themes such as catppuccin latte. this plan adds a persisted dashboard background preference with dark and light values. light selects readable foreground tokens. the existing paired focus and badge backgrounds stay unchanged.

codebase summary

  • theme tokens come from getColors() in lib/ui/theme.ts:147-195. the function uses color profile (truecolor, ansi256, ansi16), palette (green, blue), and accent.
  • heading and muted are fixed in all three depth branches at lib/ui/theme.ts:155-156,170-171,185-186.
  • select() uses heading for the title and ordinary unselected labels through the default branch of codexColorCode() at lib/ui/select.ts:262-277.
  • select() uses muted for section headings and help text at lib/ui/select.ts:318-408.
  • selected rows use paired focusBg/focusText at lib/ui/select.ts:364-373.
  • badges use their own hard-coded fg/bg tables at lib/ui/format.ts:43-111.
  • process-global runtime state lives in lib/ui/runtime.ts:10-31,51-67,88. each update rebuilds the theme and preserves omitted options.
  • dashboard preferences (uiThemePreset, uiAccentColor) persist in the unified settings.json dashboardDisplaySettings section. normalization is explicit at lib/dashboard-settings.ts:131-151,293-390.
  • explicit clone and equality functions are at lib/codex-manager/dashboard-settings-data.ts:18-57,72-127.
  • THEME_PANEL_KEYS and the dashboard-to-runtime adapter are at lib/codex-manager/settings-hub/dashboard.ts:160-175.
  • the live-preview theme editor is at lib/codex-manager/theme-settings-panel.ts:39-164.
  • the color profile (codexTuiColorProfile / CODEX_TUI_COLOR_PROFILE) controls only ansi encoding depth at lib/config.ts:850-873. the color profile does not control light or dark appearance.

file-level change summary

file change
lib/ui/theme.ts:5-8,99-134,147-195,245-265 add UiBackground and the background option. add light foreground values. keep focus pairs and disableColor behavior.
lib/ui/runtime.ts:10-30,51-67,88 carry and preserve background. reset it to dark.
lib/ui/index.ts:30-38 export UiBackground from the internal barrel.
lib/dashboard-settings.ts:12-32,49-76,131-151,348-352 add the uiBackgroundMode type, default, normalizer, and reconstruction.
lib/codex-manager/dashboard-settings-data.ts:41-42,103-104 add the field to clone and equality.
lib/codex-manager/settings-hub/dashboard.ts:126-175,276-289 add the option inventory, THEME_PANEL_KEYS, runtime mapping, and di forwarding.
lib/codex-manager/theme-settings-panel.ts:11-164 add selector rows, live preview, cancel, and reset.
lib/codex-manager/settings-panels.ts:125-146 forward the new inventory.
lib/ui/ui-copy.ts:144-146,161, lib/codex-manager/settings-hub-menu.ts:37 update copy.
docs/reference/settings.md:93-95,224, docs/configuration.md:99 update docs.
tests listed in tasks 1.3, 2.3, and 3.3 add exact-value, propagation, concurrency, and cancel/reset regressions.

follow-up instructions

  • edit source only. do not edit dist/. do not use as any or ts suppression comments (AGENTS.md:137-174).
  • do not change lib/ui/format.ts:43-111 badge tables, lib/ui/auth-menu-builder.ts:128, or focusBg/focusText values at lib/ui/theme.ts:163-164,178-179,193-194. these items draw pale text on their own dark backgrounds. they remain readable on light terminals.
  • deliberately exclude terminal background auto-detection and an env override.
  • deliberately exclude plugin-host loading of dashboard appearance. index.ts output stays dark unless the user sets the preference. the setter preserves the value only within a manager process.
  • deliberately exclude the no-color badge escape leak at lib/ui/format.ts:199-207 and the unused selectedEmphasis option.
  • flag this manual check in the pr: light-mode muted, combined with dim from lib/codex-manager/formatters/text-style.ts:8-16, needs a check on latte.
  • flag this windows edge case in the pr: ansi16 light values depend on the terminal palette. check them manually in windows terminal and conhost.
  • flag the missing selector regression test: no current test covers the codexColorCode() default branch at lib/ui/select.ts:275.
  • flag the concurrency risk: omission from THEME_PANEL_KEYS at lib/codex-manager/settings-hub/dashboard.ts:160-163 can let another panel or process overwrite the new key with a stale value.

πŸš€ Next Steps

πŸ€– All AI agent prompts combined
Task: 1

implement appearance-aware foreground tokens and preserve the background choice
in process-global runtime state. keep dark output byte-identical and keep paired
focus and badge colors unchanged.

- theme construction:
- add `UiBackground = "dark" | "light"` at `lib/ui/theme.ts:5-8` and export it
through `lib/ui/index.ts:30-38` only. leave the public-api contract at
`test/public-api-contract.test.ts:19-52` unchanged.
- add optional `background`, default `dark`, to `createUiTheme()` at
`lib/ui/theme.ts:245-265`. pass it to `getColors()` and accent resolution at
`lib/ui/theme.ts:99-134`.
- for light mode, use terminal default fg `\x1b[39m` for `heading` in all
profiles. use the specified mid-dark slate for `muted`, darker green/blue
palette shades for `primary`/`success`/`border`, darker accent variants,
amber-700 for `warning`, and red-700 for `danger`. use the specified ansi codes
and matching non-bright action/status codes.
- preserve `focusBg`, `focusText`, `reset`, and `dim`. retain all-token
`disableColor` blanking at `lib/ui/theme.ts:209-226`.
- runtime propagation:
  - add `background` with default `dark` at `lib/ui/runtime.ts:10-30`.
- at `lib/ui/runtime.ts:51-67`, preserve an omitted value from current state and
forward it into each rebuilt theme.
- reset to `dark` at `lib/ui/runtime.ts:88` to prevent single-worker test-state
leaks.
- regression coverage:
- pin exact dark `heading`/`muted` values in all profiles at
`test/ui-theme.test.ts:8-41`.
- add the 3-profile Γ— 2-palette Γ— 4-accent light matrix with exact sgr
assertions and `disableColor: false`. compare focus pairs across backgrounds.
extend `test/ui-theme.test.ts:78-84` to verify light-mode blanking.
- use the tty mock and write spy at `test/select.test.ts:3-38` to cover the
title, heading item, disabled item, ordinary unselected item, hint, help text,
and selected focus pair. explicitly cover the previously untested default branch
at `lib/ui/select.ts:275`.
- test background preservation and reset in `test/ui-runtime.test.ts`. keep
`test/ui-format.test.ts:56-63` passing unchanged.
- edit source only. do not edit `dist/`, use `as any`, or add ts suppression
comments. do not change badge tables at `lib/ui/format.ts:43-111`,
`lib/ui/auth-menu-builder.ts:128`, or focus-pair values. flag the latte
muted-plus-dim and windows ansi16 manual checks in the pr.
===============================================================================

Task: 2

persist `uiBackgroundMode` and propagate it through every explicit settings
inventory. preserve existing appearance by default and prevent background-only
edits or concurrent saves from losing the preference.

- settings schema and normalization:
- add `uiBackgroundMode: "dark" | "light"`, default `dark`, at
`lib/dashboard-settings.ts:12-32,49-76`.
- at `lib/dashboard-settings.ts:131-151`, normalize exactly `"light"` to `light`
and all other values to `dark`. keep normalization case-sensitive.
- include the field in reconstruction at `lib/dashboard-settings.ts:348-352` so
load, legacy migration, and save retain it. legacy files without the field must
resolve to `dark`.
- inventories and adapter:
- include the field in clone and equality at
`lib/codex-manager/dashboard-settings-data.ts:41-42,103-104`. background-only
edits must no longer compare as unchanged.
- add a background option inventory at
`lib/codex-manager/settings-hub/dashboard.ts:126-159`. add `uiBackgroundMode` to
`THEME_PANEL_KEYS` at `lib/codex-manager/settings-hub/dashboard.ts:160-163`.
- map the field to runtime `background`, default `dark`, at
`lib/codex-manager/settings-hub/dashboard.ts:165-175`. preserve profile, glyph
mode, and v2 enablement.
- keep dashboard imports out of `lib/ui/`. map the preference only in the
manager adapter.
- concurrency and windows safeguards:
- retain the reload, theme-owned keyed merge, unified-settings queue, and
stale-record retry at `lib/unified-settings.ts:564-609` and
`lib/codex-manager/settings-hub/shared.ts:73-107`.
- explicitly prevent stale concurrent writes by including the field in
`THEME_PANEL_KEYS`.
- retain queued `EBUSY`/`EPERM` retries. do not add direct `fs.writeFile`
writes.
- tests:
- add normalization, round-trip, and missing-field legacy migration cases at
`test/dashboard-settings.test.ts:35-112,174,316-401`.
- update clone/equality inventories and test a background-only difference at
`test/dashboard-settings-data.test.ts:56-57,131-132`.
- test background forwarding with the env-selected profile preserved at
`test/settings-hub-utils.test.ts:715-722`.
- test persistence and runtime reapplication for background-only edits at
`test/unified-settings-controller.test.ts:82-125`.
- interleave a theme save and unrelated-section write at
`test/unified-settings.test.ts:699-862`. verify both values survive. use
`removeWithRetry` for windows cleanup.
- edit source only. do not edit `dist/`, use `as any`, or add ts suppression
comments.
===============================================================================

Task: 3

add a discoverable background selector with immediate live preview. preserve
cancel, scoped reset, and existing save-failure behavior while updating copy,
documentation, and regression tests.

- theme panel:
- extend action and options interfaces at
`lib/codex-manager/theme-settings-panel.ts:11-32` with background choices.
- add "Dark background" and "Light background" rows at
`lib/codex-manager/theme-settings-panel.ts:49-106`. use the existing
palette/accent selection marker.
- apply background changes to the draft and preview immediately at
`lib/codex-manager/theme-settings-panel.ts:156-164`.
- keep cancel and `q` restoring the cloned baseline at
`lib/codex-manager/theme-settings-panel.ts:134-147`. use the updated clone to
restore background correctly.
- keep reset restoring `dark` through `THEME_PANEL_KEYS` at
`lib/codex-manager/theme-settings-panel.ts:150-154`.
- forward background options through
`lib/codex-manager/settings-panels.ts:125-146` and
`lib/codex-manager/settings-hub/dashboard.ts:276-289`.
- if save fails, retain the warning, fallback, and applied preview behavior at
`lib/codex-manager/settings-hub/shared.ts:73-107`. document this behavior only
in the pr.
- copy and docs:
- mention background mode in theme descriptions at
`lib/ui/ui-copy.ts:144-146,161` and `lib/codex-manager/settings-hub-menu.ts:37`.
- add the `uiBackgroundMode` row with `dark` | `light` and default `dark` at
`docs/reference/settings.md:93-95`. clarify that `codexTuiColorProfile` controls
only color depth at `docs/reference/settings.md:224`, consistent with
`lib/config.ts:850-873`.
- at `docs/configuration.md:99`, explain that light-terminal users must choose
light background in settings β†’ theme. state that `CODEX_TUI_COLOR_PROFILE` does
not change appearance.
- tests and validation:
  - test option forwarding at `test/settings-panels.test.ts:149-172`.
- extend scoped reset at `test/codex-manager-cli.test.ts:11539-11583` to restore
`dark` after selecting light without changing other panels.
- add a light-then-`q` regression case. verify runtime restoration to `dark` and
no persistence.
- run `npm run typecheck`, `npm run lint`, and `npm test`. retain the 80%
coverage thresholds in `test/AGENTS.md:170-188`.
- follow-up constraints:
- edit source only. do not edit `dist/`, use `as any`, or add ts suppression
comments.
- do not add auto-detection, an env override, plugin-host appearance loading, a
fix for the no-color badge escape leak at `lib/ui/format.ts:199-207`, or changes
to the unused `selectedEmphasis` option.
- flag the latte check for muted plus dim at
`lib/codex-manager/formatters/text-style.ts:8-16`. flag manual windows terminal
and conhost checks for palette-dependent ansi16 light values.
πŸ’‘ Iterate on the plan with: @coderabbitai <feedback>
Example Feedback
- @coderabbitai You can skip phase 3. Add a simple unit test case for phase 2.
- @coderabbitai For design choice 1 go ahead with option 3 and replan.

coderabbitai[bot] avatar Oct 02 '26 17:10 coderabbitai[bot]