Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(ui): honor color settings in prompt themes#10009

Draft
risu729 wants to merge 2 commits into
jdx:mainfrom
risu729:codex-20260521-054207-b99590
Draft

fix(ui): honor color settings in prompt themes#10009
risu729 wants to merge 2 commits into
jdx:mainfrom
risu729:codex-20260521-054207-b99590

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented May 20, 2026

Summary

  • make demand prompt themes fall back to an unstyled theme when stderr colors are disabled
  • clear the remaining color specs from demand's nominal no-color theme so filter cursors/buttons do not emit ANSI styling
  • add a regression test for color=false with color_theme=base16

Discussion

Addresses #9999.

Tests

  • mise run format
  • cargo fmt --all -- --check
  • cargo test --all-features ui::theme::tests::get_theme_returns_no_color_theme_when_color_is_disabled -- --exact

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR fixes demand prompt themes ignoring the color=false / NO_COLOR settings by adding an early-return to get_theme() that falls back to a fully unstyled theme whenever console::colors_enabled_stderr() is false. A new no_color_theme() helper explicitly clears every color-bearing field on Theme::new() to work around residual ANSI specs in demand's nominal no-color constructor.

  • get_theme() now gates colored-theme selection behind console::colors_enabled_stderr(), which is already driven by Settings::get() applying color, NO_COLOR, and CLICOLOR to the console state.
  • no_color_theme() exhaustively resets all 20 style fields (including focused_button, blurred_button, cursor_style, and the breadcrumb slots) plus force_style = false on Theme::new().
  • A regression test asserts that every cleared field reports no fg/bg color after the call.

Confidence Score: 5/5

The change is narrowly scoped to theme selection; the worst outcome of a regression is unstyled or over-styled prompt output, not data loss or a crash.

Settings::get() already calls console::set_colors_enabled_stderr() before get_theme() checks that flag, so the color state is always up to date when the guard runs. no_color_theme() clears every style field the PR description identifies as problematic, and the test asserts all of them.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/theme.rs Adds console::colors_enabled_stderr() guard in get_theme() and a new no_color_theme() helper that explicitly clears every color-bearing field on Theme::new(); includes a test asserting all cleared fields have no fg/bg.

Reviews (2): Last reviewed commit: "test(ui): cover unstyled prompt theme fi..." | Re-trigger Greptile

Comment thread src/ui/theme.rs
Comment thread src/ui/theme.rs Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a no-color theme mode in src/ui/theme.rs by checking if colors are enabled for stderr and returning a theme with default styles if they are not. It also adds a unit test to verify that key theme components have no foreground or background colors when disabled. The review feedback suggests expanding the no_color_theme function to reset additional fields such as error_indicator, help_style, and spinner_style, and updating the regression tests to include assertions for these fields.

Comment thread src/ui/theme.rs
Comment thread src/ui/theme.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant