Repository navigation
fix(tui): keep shaded panels without palette queries - #3
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdded terminal default color fallbacks (COLORFGBG parsing and fixed dark RGBs), introduced helpers to choose explicit RGB when stdout color level is Unknown, updated style functions to use them, and added tests including a UI snapshot asserting fallback background rendering for an empty ChatComposer. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Term as Terminal Palette
participant Style as Style System
participant UI as UI Renderer
rect rgba(100,150,200,0.5)
Note over App,UI: Color determination and rendering flow
App->>Term: query default colors
alt Term returns defaults
Term-->>Style: DefaultColors
else Term missing defaults
Term->>Term: parse COLORFGBG
alt COLORFGBG yields numeric codes
Term-->>Style: fallback fg/bg from COLORFGBG
else
Term-->>Style: fixed dark RGB defaults
end
end
Style->>Style: subtle_surface_bg_with_level(target, level)
alt level == Unknown
Style-->>Style: return explicit Color::Rgb
else
Style-->>Style: return best_color(target)
end
Style-->>UI: styled widget (bg set)
UI->>UI: render widget with background
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
codex-rs/tui/src/style.rs (1)
49-57: Extract a shared helper to avoid test/production logic drift.
subtle_surface_bg_forre-implements the branch logic instead of reusing the production path. Consider extracting a singlesubtle_surface_bg_with_level(target, level)helper and calling it from bothsubtle_surface_bgand tests.♻️ Suggested refactor
fn subtle_surface_bg(target: (u8, u8, u8)) -> Color { - match stdout_color_level() { - // Some transports and test backends fail capability detection even though RGB colors still - // render correctly. Prefer a visible shaded surface over silently resetting to the - // terminal default. - StdoutColorLevel::Unknown => rgb_color(target), - _ => best_color(target), - } + subtle_surface_bg_with_level(target, stdout_color_level()) +} + +fn subtle_surface_bg_with_level(target: (u8, u8, u8), level: StdoutColorLevel) -> Color { + match level { + // Some transports and test backends fail capability detection even though RGB colors still + // render correctly. Prefer a visible shaded surface over silently resetting to the + // terminal default. + StdoutColorLevel::Unknown => rgb_color(target), + _ => best_color(target), + } } @@ - fn subtle_surface_bg_for(target: (u8, u8, u8), color_level: StdoutColorLevel) -> Color { - match color_level { - StdoutColorLevel::Unknown => rgb_color(target), - _ => best_color(target), - } + fn subtle_surface_bg_for(target: (u8, u8, u8), color_level: StdoutColorLevel) -> Color { + subtle_surface_bg_with_level(target, color_level) } }Also applies to: 84-89
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@codex-rs/tui/src/style.rs` around lines 49 - 57, The test reimplements production branching logic; extract a shared helper subtle_surface_bg_with_level(target: (u8,u8,u8), level: StdoutColorLevel) that contains the match/branch (using rgb_color or best_color) and then update subtle_surface_bg to call subtle_surface_bg_with_level(target, stdout_color_level()) and update the test helper (subtle_surface_bg_for or similar) to call subtle_surface_bg_with_level with the desired level; also apply the same extraction for the other duplicated block (the code around the other subtle_surface_* helper).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@codex-rs/tui/src/style.rs`:
- Around line 49-57: The test reimplements production branching logic; extract a
shared helper subtle_surface_bg_with_level(target: (u8,u8,u8), level:
StdoutColorLevel) that contains the match/branch (using rgb_color or best_color)
and then update subtle_surface_bg to call subtle_surface_bg_with_level(target,
stdout_color_level()) and update the test helper (subtle_surface_bg_for or
similar) to call subtle_surface_bg_with_level with the desired level; also apply
the same extraction for the other duplicated block (the code around the other
subtle_surface_* helper).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bc37faa3-8344-4301-aa3d-d0f8a3f03b99
⛔ Files ignored due to path filters (15)
codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__approval_overlay__tests__network_exec_prompt.snapis excluded by!**/*.snapcodex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__empty_with_fallback_background_debug.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__app_server_guardian_review_denied_renders_denied_request.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__app_server_mcp_startup_failure_renders_warning_history.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec_multiline_prefix_no_execpolicy.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec_no_reason.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_patch.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__chatwidget_exec_and_status_layout_vt100_snapshot.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__chatwidget_tall.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__compact_queues_user_messages_snapshot.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__exec_approval_modal_exec.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__guardian_approved_exec_renders_approved_request.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__guardian_denied_exec_renders_warning_and_denied_request.snapis excluded by!**/*.snapcodex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__review_queues_user_messages_snapshot.snapis excluded by!**/*.snap
📒 Files selected for processing (3)
codex-rs/tui/src/bottom_pane/chat_composer.rscodex-rs/tui/src/style.rscodex-rs/tui/src/terminal_palette.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@codex-rs/tui/src/style.rs`:
- Around line 68-70: The test
user_message_style_uses_fallback_background_when_default_palette_is_unavailable
is currently brittle because assert_ne!(user_message_style().bg,
Some(Color::Reset)) still passes if bg is None; update the test to first assert
that user_message_style().bg is Some(...) (e.g.,
assert!(user_message_style().bg.is_some())) and only then assert_ne! against
Some(Color::Reset) to ensure a fallback background was actually applied; locate
the user_message_style function and its bg field and adjust the assertions
accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Summary
COLORFGBGand stable dark defaults when OSC default-color queries failVerification
cargo test -p codex-tuicr review --agent --type committed --base-commit HEAD~1Summary by CodeRabbit