Skip to content

feat(tui): themes (#463) - #569

Merged
ajianaz merged 3 commits into
developfrom
feat/463-themes
Nov 11, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/463-themes

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 3 of #463 (themes). Part of #463; the keybinding config remains.

The TUI gets a Theme (semantic role -> ratatui Style) with three built-in themes (default, light, mono), NO_COLOR support, and optional per-role color overrides in the user config.

Why

Hardcoded colors were unreadable on light terminals (yellow, white, cyan) and ignored NO_COLOR. A theme also decides how the approval prompt looks, so the design is built so a theme can never hide text and a cloned repository can never control it.

Changes

  • tole-tui: new theme.rs (20 roles, built-ins, color/spec parser, safety rules). render.rs reads every style from App's theme (no Color::/Modifier:: left there). TuiHost gets two defaulted methods, theme() and startup_note(); App::with_theme. tole-tui still reads no file or env.
  • default reproduces today's look exactly (pinned by a test). light: no yellow/white/cyan text, blue tools/code, dark amber notes and approval. mono: no colors, only bold/dim/italic/underline.
  • Config (user layer and env only): TOLE_THEME > [tui] theme in the user config > non-empty NO_COLOR (-> mono) > default. Overrides: [tui.colors] role = "<color> [bold] [italic] [underline] [dim]", with a color name, 0-255, or #rrggbb. An override replaces the role's whole style. No theme file format (it would add a loader and a second schema for no gain).
  • Safety: no background colors and no hidden/reversed/blink in the vocabulary; approval and note are critical (never dim, custom styles forced bold); a color is rejected only if it can never be valid; any invalid value falls back to default with one startup note naming the key and the problem.
  • Project boundary: config::layered drops a project config's [tui] table; startup prints one warning: ignoring tui in project config ... and tole config check marks the project keys IGNORED and shows the effective theme with its source (and INVALID for a bad value).
  • Bare profile (no tui feature): theme validation needs tole-tui, so a build without it cannot know whether a theme is valid. tole config check there prints (not validated: this build has no TUI ...) for tui.theme and tui.colors instead of an effective value or a verdict; the tests that need the TUI are gated on the feature (the project-boundary and precedence tests do not need it and run in every profile).
  • Unrelated flake fixed in its own commit (test(tui): wait for idle before /quit in the escape-sequence e2e): tui_never_passes_escape_sequences_from_provider_text sent /quit right after the provider text appeared. Slash commands are ignored while a turn runs, so a /quit sent before the turn settled was dropped, the process never exited, and the Test job failed (None instead of Some(0)). The test now waits for the idle footer first, like the other e2e tests. The test is on develop unchanged by this PR, so the commit can be taken out on its own.
  • Docs in the same PR: docs/tui.md (themes section, no /theme because a live switch cannot restyle the append-only scrollback), README status/key/env rows, docs/epics.md, docs/threat-model.md.

Deviations from the design, with reasons:

  • The default theme's approval and note are NOT bold (today they are yellow, not bold); making them bold would change the default look. The "critical = bold" rule is enforced for light, mono and every custom override; "never dim" holds in every theme, default included.
  • With NO_COLOR set, an explicit colored theme still prints without color: crossterm 0.29 itself drops color escapes when NO_COLOR is set and non-empty. Explicit theme still wins in selection and in config check; bold/dim/underline stay.
  • no-color.org was unreachable from this environment (host not allowlisted), so its text is not quoted. The rule implemented (set and non-empty) is the one crossterm implements and cites that page for; the code comment says so. Please check against the page.
  • Picker rows had no highlight style (selection is the marker character), so the picker role is plain in default. The brief's "picker highlight" maps to that role.
  • Only TOML type errors in [tui] (wrong type, unknown key) are hard config errors like any key; bad values are soft.

Testing

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings: clean. cargo test --workspace: 1298 passed, 0 failed.
  • Bare profile, the exact no-mcp CI commands: cargo check -p tole-cli --no-default-features, cargo test -p tole-cli --no-default-features (397 passed, 0 failed), cargo check ... --features shell-tools, cargo clippy ... --features shell-tools -- -D warnings, cargo test ... --features shell-tools (505 passed, 0 failed), cargo check -p tole-core --no-default-features --tests: all green. The first push failed no-mcp profile because a config-check test asserted INVALID in a build that cannot validate; fixed as described under Changes.
  • After the flake fix: cargo fmt --all -- --check and cargo clippy -p tole-cli --all-targets -- -D warnings clean, and the whole tui_e2e file (13 tests) passed 5 runs in a row. The flake depends on timing, so five green runs make it likely, not certain, that it is gone.
  • tole-tui unit: default pinned to the pre-theme styles, every role defined, mono has no fg/bg, light differs where it matters, parsing (names, indexed, #rrggbb), errors name the role, no background/conceal producible, critical roles never dim and bold in custom styles.
  • tole-cli: precedence matrix (env > user config > NO_COLOR > default, empty NO_COLOR ignored), project theme ignored in layered and in resolution, invalid values fall back with the note, config check output, e2e with the real binary for the project warning, INVALID, and a bad user theme not aborting a command.
  • pty e2e (tui_e2e.rs, tui feature only): TOLE_THEME=mono and NO_COLOR=1 produce no SGR color sequence (ESC[3Xm, ESC[9Xm, ESC[38;...), the default and light themes still do, an unknown theme shows one note; tui_never_passes_escape_sequences_from_provider_text still passes.
  • Mutation checks (each made a test fail, then restored): project config sets theme (3 tests), allow background (1), allow conceal (1), critical role dim (1), invalid value aborts (1).
  • cora is not installed here; I reviewed the staged diff by hand (precedence, project-config boundary, parsing, error paths). The CI Cora Review is the gate.

Add a Theme (role -> style) to tole-tui with built-in default, light and mono themes, per-role color overrides from the user config, TOLE_THEME and NO_COLOR. Themes cannot set backgrounds or conceal text, critical roles stay non-dim and bold, a project config cannot set the theme, and an invalid value falls back to default with a startup note.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…UI (#463)

A build without the tui feature cannot validate a theme, so config check now says the theme is not validated instead of reporting an effective value or a verdict. The tests that assume the TUI are gated on the feature.
Slash commands are ignored while a turn runs, so a /quit sent right after the
provider text appeared, before the turn settled, was dropped and the process
never exited: wait_exit timed out and returned None. This failed the Test job
of the themes PR although the change is unrelated. Wait for the idle footer
first, like the other e2e tests do.
@ajianaz
ajianaz merged commit b90b822 into develop Nov 11, 2026
19 of 20 checks passed
ajianaz added a commit that referenced this pull request Nov 11, 2026
[tui.keys] in the user config rebinds ten convenience actions (tool output, reasoning, model picker, cycle model, cycle thinking, newline, queue follow-up, pop queue, history) to a key spec or a list; the default keymap is the keys the TUI always had. y, n, Esc, Ctrl+C, Enter, Backspace, Tab and every bare character are never rebindable, and at an approval prompt only y, n, Esc and Ctrl+C act whatever the keymap says. A project config cannot set keys (ignored with a warning), and an invalid keymap falls back to the default with one startup note. Closes #463 with #567, #568 and #569.
@ajianaz
ajianaz deleted the feat/463-themes branch November 20, 2026 08:35
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.

2 participants