Skip to content

Commit 30bcf53

Browse files
committed
Docs n tests for custom TUI themes
Signed-off-by: krissetto <chrisjpetito@gmail.com>
1 parent ad38082 commit 30bcf53

4 files changed

Lines changed: 746 additions & 2 deletions

File tree

docs/USAGE.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ During TUI sessions, you can use special slash commands. Type `/` to see all ava
170170
| `/sessions` | Browse and load past sessions |
171171
| `/shell` | Start a shell |
172172
| `/star` | Toggle star on current session |
173+
| `/theme` | Change the color theme (see [Theming](#theming)) |
173174
| `/think` | Toggle thinking/reasoning mode |
174175
| `/yolo` | Toggle automatic approval of tool calls |
175176

@@ -195,6 +196,89 @@ The `/model` command (or `ctrl+m`) allows you to change the AI model used by the
195196

196197
To revert to the agent's default model, select the model marked with "(default)" in the picker.
197198

199+
#### Theming
200+
201+
The TUI supports customizable color themes. You can create and use custom themes to personalize the appearance of the terminal interface.
202+
203+
**Theme Configuration:**
204+
205+
Your theme preference is saved globally in `~/.config/cagent/config.yaml` under `settings.theme`. If not set, the built-in default theme is used.
206+
207+
**Creating Custom Themes:**
208+
209+
Create theme files in `~/.cagent/themes/` as YAML files (`.yaml` or `.yml`). Theme files are **partial overrides** — you only need to specify the colors you want to change. Any omitted keys fall back to the built-in default theme values.
210+
211+
```yaml
212+
# ~/.cagent/themes/my-theme.yaml
213+
name: "My Custom Theme"
214+
215+
colors:
216+
# Backgrounds
217+
background: "#1a1a2e"
218+
background_alt: "#16213e"
219+
220+
# Text colors
221+
text_bright: "#ffffff"
222+
text_primary: "#e8e8e8"
223+
text_secondary: "#b0b0b0"
224+
text_muted: "#707070"
225+
226+
# Accent colors
227+
accent: "#4fc3f7"
228+
brand: "#1d96f3"
229+
230+
# Status colors
231+
success: "#4caf50"
232+
error: "#f44336"
233+
warning: "#ff9800"
234+
info: "#00bcd4"
235+
236+
# Optional: Customize syntax highlighting colors
237+
chroma:
238+
comment: "#6a9955"
239+
keyword: "#569cd6"
240+
literal_string: "#ce9178"
241+
242+
# Optional: Customize markdown rendering colors
243+
markdown:
244+
heading: "#4fc3f7"
245+
link: "#569cd6"
246+
code: "#ce9178"
247+
```
248+
249+
**Applying Themes:**
250+
251+
- **In user config** (`~/.config/cagent/config.yaml`):
252+
```yaml
253+
settings:
254+
theme: my-theme # References ~/.cagent/themes/my-theme.yaml
255+
```
256+
257+
- **At runtime**: Use the `/theme` command to open the theme picker and select from available themes. Your selection is automatically saved to user config and persists across sessions.
258+
259+
**Hot Reload:** Custom theme files are automatically watched for changes. When you edit a user theme file (in `~/.cagent/themes/`), the changes are applied immediately without needing to restart cagent or re-select the theme. This makes it easy to customize themes while seeing changes in real-time.
260+
261+
262+
> **Note:** All user themes are partial overrides applied on top of the `default` theme. If you want to customize a built-in theme, copy the full YAML from the [built-in themes on GitHub](https://github.com/docker/cagent/tree/main/pkg/tui/styles/themes) into `~/.cagent/themes/` and edit the copy. Otherwise, omitted values will use `default` colors, not the original theme's colors.
263+
264+
**Built-in Themes:**
265+
266+
The following themes are included:
267+
- `default` — The built-in default theme with a dark color scheme
268+
- `catppuccin-latte`, `catppuccin-mocha` — Catppuccin themes (light and dark)
269+
- `dracula` — Dracula dark theme
270+
- `gruvbox-dark`, `gruvbox-light` — Gruvbox themes
271+
- `nord` — Nord dark theme
272+
- `one-dark` — One Dark theme
273+
- `solarized-dark` — Solarized dark theme
274+
- `tokyo-night` — Tokyo Night dark theme
275+
276+
**Available Color Keys:**
277+
278+
Themes can customize colors in three sections: `colors`, `chroma` (syntax highlighting), and `markdown` (markdown rendering).
279+
280+
See the [built-in themes on GitHub](https://github.com/docker/cagent/tree/main/pkg/tui/styles/themes) for complete examples.
281+
198282
## 🔧 Configuration Reference
199283

200284
### Agent Properties

pkg/tui/components/markdown/fast_renderer_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,11 @@ func TestInlineCodeRestoresBaseStyle(t *testing.T) {
10611061
// - Resets between styled segments
10621062
require.GreaterOrEqual(t, len(seqs), 3, "Should have at least 3 ANSI sequences")
10631063

1064-
// Verify that the base document style (color 252) appears somewhere (for text styling)
1064+
// Verify that text styling is applied (either ANSI 256 color or RGB)
10651065
allSeqs := strings.Join(seqs, "")
1066-
assert.Contains(t, allSeqs, "38;5;252", "Should have document text color applied")
1066+
// Text color can be either "38;5;N" (256 color) or "38;2;R;G;B" (RGB) depending on theme
1067+
hasTextColor := strings.Contains(allSeqs, "38;5;") || strings.Contains(allSeqs, "38;2;")
1068+
assert.True(t, hasTextColor, "Should have text color applied (38;5; or 38;2;)")
10671069

10681070
// Verify code style appears (RGB foreground and background)
10691071
assert.Contains(t, allSeqs, "38;2;", "Code style should have RGB foreground")

0 commit comments

Comments
 (0)