feat: implement interactive TUI dashboard with ratatui#5
Conversation
Implements the core TUI runtime: App holds engine, config, snapshot state, and selected tab index. run_tui() sets up crossterm alternate screen, runs a draw+poll loop at the configured refresh rate, and handles q/Esc to quit plus Tab/arrows/h/l for tab switching. Cleans up terminal state on exit. draw_ui is stubbed for the next commit.
draw_ui splits the terminal into header, content area, and footer. Header shows module names as tabs with the selected one bolded and underlined in its theme color. Footer shows keybinding hints. Both respect the border style and chrome colors from config.
Each module gets a column panel with its themed border and title. Modules with a percentage metric (cpu, memory, disk) show a colored gauge bar at the top. Below it, all metrics are listed as key-value pairs sorted alphabetically. Selected tab highlights its panel border in the module's theme color. Large integer values auto-format as KB/MB/GB.
dev-dami
left a comment
There was a problem hiding this comment.
Looking good. Event loop handles KeyEventKind::Press correctly for Windows compat. Gauge bar only renders for modules with a percentage metric — right behavior. Theme integration via module_theme() is clean and will scale when new modules land. Terminal cleanup path is correct. One thing to note: the 200ms CPU sleep in CpuCollector will add latency to the first TUI refresh, but that's a collector-layer concern not a TUI one.
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughA complete terminal user interface (TUI) implementation has been added to Changes
Sequence DiagramsequenceDiagram
participant User
participant App
participant Engine
participant Terminal
User->>App: Start TUI (run_tui)
App->>App: Initialize App state
loop Event Loop
User->>Terminal: Input events (tab, arrows, quit)
Terminal->>App: Poll events
alt Tab/Arrow Navigation
App->>App: Update active tab/focus
else Refresh Tick
App->>Engine: Fetch current metrics/data
Engine-->>App: Return data
App->>App: Update App state (refresh)
else Quit
App->>Terminal: Cleanup & restore terminal
Terminal-->>User: Exit TUI
end
App->>Terminal: Render layout (header/modules/footer)
Terminal->>Terminal: Compose widgets (blocks, gauges, text)
Terminal-->>User: Display frame
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Replaces the empty TUI placeholder with a full interactive dashboard built on ratatui and crossterm.
Commits
feat(tui): add App struct, event loop, and keyboard navigationfeat(tui): implement header tabs and footer help barfeat(tui): add module panels with gauge bars and metric detailsSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.