Skip to content

Add light palette for the terminal UI#6

Open
ildunari wants to merge 1 commit into
browser-use:mainfrom
ildunari:codex/light-tui-theme
Open

Add light palette for the terminal UI#6
ildunari wants to merge 1 commit into
browser-use:mainfrom
ildunari:codex/light-tui-theme

Conversation

@ildunari
Copy link
Copy Markdown

@ildunari ildunari commented May 25, 2026

Summary

  • refactor the TUI color tokens into dark and light palettes while keeping the existing dark colors as the default
  • add BUT_THEME=light for light terminal backgrounds and BUT_THEME=auto support via CLITHEME=light
  • document the new theme override and add contrast coverage for the light foreground tokens

Why

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 --check
  • cargo test -p browser-use-tui
  • scripts/verify-terminal-ui.sh

The 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

    • Light color palette with accessible contrast.
    • Theme switch via BUT_THEME=light; BUT_THEME=auto honors CLITHEME=light.
  • Refactors

    • Centralized colors into ThemeMode and Palette; default remains dark.
    • Added contrast tests for light foreground tokens.
    • Updated README and .env.example with theme overrides.

Written for commit 08d2126. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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 {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 25, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +95 to +97
fn active_theme_mode() -> ThemeMode {
match std::env::var("BUT_THEME") {
Ok(value) => theme_mode_from_str(&value),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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