Skip to content

feat: configurable semantic role colors in themes and config - #235

Open
wowi42 wants to merge 1 commit into
gi-dellav:mainfrom
wowi42:feat/theme-role-colors
Open

feat: configurable semantic role colors in themes and config#235
wowi42 wants to merge 1 commit into
gi-dellav:mainfrom
wowi42:feat/theme-role-colors

Conversation

@wowi42

@wowi42 wowi42 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements item 3 of the "Input and pickers" section of #186: "Extend the theme/config system to map semantic roles (agent, error, tool, permission) to configurable colors."

Semantic conversation roles are now recolorable from both theme files and the [colors] config section, via a new roles map:

{
  "colors": {
    "chat_background": "#1e1e2e",
    "roles": {
      "agent": "#cdd6f4",
      "error": "#f38ba8",
      "tool": "#f9e2af",
      "permission": "#cba6f7"
    }
  }
}

Changes

  • New src/ui/roles.rs: global registry of role color overrides with the historical palette as defaults. BlockStyle::color() resolves through it, so all feed blocks — and legacy write_line(color) call sites that map to roles via style_from_color — pick up themed colors automatically.
  • All 10 roles supported: user, agent, reasoning, tool, tool_result, error, system, welcome, permission, plain. Colors are parsed with the existing parse_color (named colors + #rrggbb).
  • Robust application: unknown role names and unparsable colors are skipped with a tracing warning, never breaking rendering. Applying a theme or config without a roles map resets to the default palette, so switching themes doesn't leak the previous theme's roles.
  • Docs: docs/CONFIG.md colors section documents roles with an example.
  • No changes to bundled themes; default behavior is pixel-identical to before.

Verification

  • cargo test (717 passed), cargo test --no-default-features (602 passed), cargo clippy --all-features -- -D warnings and cargo clippy --no-default-features -- -D warnings — all clean.
  • New unit tests for the registry (override/fallback/reset, role-name parsing, bad input handling).
  • Smoke-tested on a pty with a roles theme: themed colors render in the actual TUI output.

Refs #186

Extend the theme/config color system (item from gi-dellav#186) so semantic
conversation roles can be recolored instead of using the hardcoded
palette. Both theme files and the [colors] config section accept a
roles map:

    "roles": { "agent": "#cdd6f4", "error": "#f38ba8",
               "tool": "#f9e2af", "permission": "#cba6f7" }

- New ui::roles registry holding the overrides; BlockStyle::color()
  resolves through it and falls back to the historical palette.
- Known roles: user, agent, reasoning, tool, tool_result, error,
  system, welcome, permission, plain. Unknown role names and
  unparsable colors are skipped with a warning.
- Applying a theme/config without a roles map resets to defaults,
  so switching themes drops the previous theme roles.
- Documented in docs/CONFIG.md with an example.
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