Skip to content

Commit 8dc8e70

Browse files
authored
Merge pull request #243 from run-vibes/m45-feat-03-runtime-theme-switching
feat(tui): add runtime theme switching command
2 parents 1d291cc + 9bb289b commit 8dc8e70

File tree

11 files changed

+1564
-13
lines changed

11 files changed

+1564
-13
lines changed

docs/board/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
| [feat-0013-windows-daemon-support](stages/backlog/stories/feat-0013-windows-daemon-support.md) | feat | low | cli,cross-platform |
2121
| [feat-0101-header-identity-display](stages/backlog/stories/feat-0101-header-identity-display.md) | feat | low | web-ui,design-system |
2222
| [m39-feat-06-eval-web-ui](stages/backlog/stories/m39-feat-06-eval-web-ui.md) | feat | medium | evals |
23-
| [m45-feat-03-runtime-theme-switching](stages/backlog/stories/m45-feat-03-runtime-theme-switching.md) | feat | medium | tui |
2423
| [m45-feat-04-theme-preview-settings](stages/backlog/stories/m45-feat-04-theme-preview-settings.md) | feat | medium | tui |
2524
| [m46-feat-01-pty-server-core](stages/backlog/stories/m46-feat-01-pty-server-core.md) | feat | medium | tui |
2625
| [m46-feat-02-session-management](stages/backlog/stories/m46-feat-02-session-management.md) | feat | medium | tui |
@@ -291,6 +290,7 @@
291290
- [m44-feat-03-result-merge-interface](stages/done/stories/m44-feat-03-result-merge-interface.md)
292291
- [m44-feat-04-swarm-coordination-status](stages/done/stories/m44-feat-04-swarm-coordination-status.md)
293292
- [m45-feat-02-builtin-theme-variants](stages/done/stories/m45-feat-02-builtin-theme-variants.md)
293+
- [m45-feat-03-runtime-theme-switching](stages/done/stories/m45-feat-03-runtime-theme-switching.md)
294294
- [refactor-0008-consolidate-assessment-types-module](stages/done/stories/refactor-0008-consolidate-assessment-types-module.md)
295295
- [refactor-0069-dashboard-visual-consistency](stages/done/stories/refactor-0069-dashboard-visual-consistency.md)
296296
- [refactor-0070-design-system-extraction](stages/done/stories/refactor-0070-design-system-extraction.md)
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# TUI Theme System Design
2+
3+
## Overview
4+
5+
Design for runtime theme switching and the command infrastructure that supports it.
6+
7+
## Command System Architecture
8+
9+
### Command Trait
10+
11+
```rust
12+
pub enum CommandResult {
13+
Ok(Option<String>),
14+
Err(String),
15+
Quit,
16+
}
17+
18+
pub trait Command: Send + Sync {
19+
fn name(&self) -> &str;
20+
fn execute(&mut self, args: &[&str], app: &mut App) -> CommandResult;
21+
fn completions(&self, args: &[&str], app: &App) -> Vec<String> { vec![] }
22+
fn help(&self) -> &str { "" }
23+
}
24+
```
25+
26+
### Command Registry
27+
28+
```rust
29+
pub struct CommandRegistry {
30+
commands: Vec<Box<dyn Command>>,
31+
}
32+
33+
impl CommandRegistry {
34+
pub fn register(&mut self, cmd: Box<dyn Command>);
35+
pub fn execute(&mut self, input: &str, app: &mut App) -> CommandResult;
36+
pub fn completions(&self, input: &str, app: &App) -> Vec<String>;
37+
}
38+
```
39+
40+
### Command Input State
41+
42+
```rust
43+
pub struct CommandInput {
44+
pub buffer: String,
45+
pub cursor: usize,
46+
pub completions: Vec<String>,
47+
pub completion_idx: Option<usize>,
48+
pub message: Option<(String, bool)>,
49+
}
50+
```
51+
52+
## ThemeCommand
53+
54+
Handles `:theme`, `:theme <name>`, and `:theme save`.
55+
56+
```rust
57+
pub struct ThemeCommand {
58+
loader: ThemeLoader,
59+
}
60+
61+
impl Command for ThemeCommand {
62+
fn name(&self) -> &str { "theme" }
63+
64+
fn execute(&mut self, args: &[&str], app: &mut App) -> CommandResult {
65+
match args {
66+
[] => list_themes(),
67+
["save"] => save_to_config(),
68+
[name] => switch_theme(name),
69+
_ => usage_error(),
70+
}
71+
}
72+
73+
fn completions(&self, args: &[&str], _app: &App) -> Vec<String> {
74+
// Theme names + "save"
75+
}
76+
}
77+
```
78+
79+
## Config Persistence
80+
81+
`:theme save` writes to `~/.config/vibes/config.toml`:
82+
83+
- Creates file if missing
84+
- Preserves existing content
85+
- Updates `[theme].active` field
86+
87+
## UI Integration
88+
89+
### Command Bar Widget
90+
91+
Renders at bottom of screen during Command mode:
92+
- Shows `:` prompt with input buffer
93+
- Displays cursor at correct position
94+
- Shows completion dropdown when available
95+
- Displays success/error messages after execution
96+
97+
### App Integration
98+
99+
```rust
100+
pub struct App {
101+
pub command_input: CommandInput,
102+
pub command_registry: CommandRegistry,
103+
// ... existing fields
104+
}
105+
```
106+
107+
Mode::Command handling:
108+
- `:` key enters Command mode
109+
- Keys route to CommandInput methods
110+
- Enter executes via CommandRegistry
111+
- Escape clears and returns to Normal
112+
113+
## Files
114+
115+
### New Files
116+
117+
| File | Purpose |
118+
|------|---------|
119+
| `commands/mod.rs` | Command trait, CommandResult |
120+
| `commands/registry.rs` | CommandRegistry |
121+
| `commands/input.rs` | CommandInput state |
122+
| `commands/theme.rs` | ThemeCommand |
123+
| `widgets/command_bar.rs` | Command bar widget |
124+
125+
### Modified Files
126+
127+
| File | Changes |
128+
|------|---------|
129+
| `app.rs` | Add command fields, wire Mode::Command |
130+
| `lib.rs` | Export commands module |
131+
| `widgets/mod.rs` | Export CommandBarWidget |

docs/board/stages/backlog/stories/m45-feat-03-runtime-theme-switching.md renamed to docs/board/stages/done/stories/m45-feat-03-runtime-theme-switching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
id: m45-feat-03
33
title: Runtime theme switching
44
type: feat
5-
status: backlog
5+
status: done
66
priority: medium
77
epics: [tui]
88
depends: [m45-feat-01, m45-feat-02]

0 commit comments

Comments
 (0)