Add light palette for the terminal UI#6
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/browser-use-tui/src/theme.rs">
<violation number="1" location="crates/browser-use-tui/src/theme.rs:91">
P2: Theme selection recomputes environment variables on every style access, causing avoidable overhead in hot TUI render paths</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| selection: Color::Rgb(221, 230, 243), | ||
| }; | ||
|
|
||
| fn active_palette() -> Palette { |
There was a problem hiding this comment.
P2: Theme selection recomputes environment variables on every style access, causing avoidable overhead in hot TUI render paths
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/browser-use-tui/src/theme.rs, line 91:
<comment>Theme selection recomputes environment variables on every style access, causing avoidable overhead in hot TUI render paths</comment>
<file context>
@@ -1,63 +1,187 @@
+ selection: Color::Rgb(221, 230, 243),
+};
+
+fn active_palette() -> Palette {
+ palette_for_mode(active_theme_mode())
+}
</file context>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08d21268b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fn active_theme_mode() -> ThemeMode { | ||
| match std::env::var("BUT_THEME") { | ||
| Ok(value) => theme_mode_from_str(&value), |
There was a problem hiding this comment.
Cache resolved theme instead of re-reading env per style call
active_theme_mode() reads BUT_THEME (and, for auto, CLITHEME) on every style lookup, because all token helpers call active_palette() repeatedly. In the render path these helpers are invoked for many spans each frame, so this change adds repeated environment lookups plus string normalization/allocation in hot UI code, which can noticeably degrade responsiveness on large transcripts. Resolving the mode once (for example via OnceLock or app startup config) and reusing the palette would avoid the per-frame overhead.
Useful? React with 👍 / 👎.
Summary
BUT_THEME=lightfor light terminal backgrounds andBUT_THEME=autosupport viaCLITHEME=lightWhy
The current TUI emits truecolor RGB values tuned for dark terminal backgrounds. On light terminal themes, especially near-white backgrounds, the default text/accent/muted tokens have very low contrast and become difficult to read. This keeps the current dark behavior unchanged unless users opt into the light palette.
Verification
cargo fmt --checkcargo test -p browser-use-tuiscripts/verify-terminal-ui.shThe full TUI verification passed, including deterministic dumps and the tmux terminal smoke test. Artifacts inspected under
/tmp/but-design-loop.Summary by cubic
Adds a light theme for the terminal UI with a simple switcher. Improves readability on light terminals while keeping dark as the default.
New Features
BUT_THEME=light;BUT_THEME=autohonorsCLITHEME=light.Refactors
ThemeModeandPalette; default remains dark..env.examplewith theme overrides.Written for commit 08d2126. Summary will update on new commits. Review in cubic