-
Notifications
You must be signed in to change notification settings - Fork 3
feat(tui): implement live theme preview system #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Greptile OverviewGreptile SummaryThis PR successfully implements a live theme preview system for the TUI, allowing users to see theme changes in real-time before committing to them. Key Changes
Implementation QualityThe implementation is clean and well-structured:
The code follows existing patterns in the codebase and integrates seamlessly with the modal stack system. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/cortex-tui/src/app/state.rs | Added preview_theme field and helper methods for theme preview state management - clean implementation |
| src/cortex-tui/src/modal/mod.rs | Added ActionContinue variant and new theme action types to enable live preview without closing modal |
| src/cortex-tui/src/modal/theme.rs | Implemented live preview with color swatches, updated tests to verify preview behavior - comprehensive implementation |
| src/cortex-tui/src/runner/event_loop/modal.rs | Implemented handlers for PreviewTheme, RevertTheme, and ConfirmTheme actions with proper state management |
Sequence Diagram
sequenceDiagram
participant User
participant ThemeSelectorModal
participant ModalStack
participant EventLoop
participant AppState
participant ThemeColors
User->>ThemeSelectorModal: Open /themes
Note over ThemeSelectorModal: Stores original_theme<br/>for potential revert
User->>ThemeSelectorModal: Press Down Arrow
ThemeSelectorModal->>ThemeSelectorModal: navigate_down()
ThemeSelectorModal->>ModalStack: ModalResult::ActionContinue(<br/>PreviewTheme("light"))
ModalStack->>EventLoop: process_modal_action(<br/>PreviewTheme("light"))
EventLoop->>AppState: start_theme_preview("light")
AppState->>AppState: set_preview_theme(Some("light"))
AppState->>ThemeColors: ThemeColors::from_name("light")
ThemeColors-->>AppState: Updated colors
Note over AppState: preview_theme = Some("light")<br/>theme_colors updated
AppState-->>User: TUI updates with<br/>light theme colors
User->>ThemeSelectorModal: Press Up Arrow
ThemeSelectorModal->>ThemeSelectorModal: navigate_up()
ThemeSelectorModal->>ModalStack: ModalResult::ActionContinue(<br/>PreviewTheme("dark"))
ModalStack->>EventLoop: process_modal_action(<br/>PreviewTheme("dark"))
EventLoop->>AppState: start_theme_preview("dark")
AppState->>ThemeColors: ThemeColors::from_name("dark")
ThemeColors-->>AppState: Updated colors
AppState-->>User: TUI updates with<br/>dark theme colors
alt User confirms selection
User->>ThemeSelectorModal: Press Enter
ThemeSelectorModal->>ModalStack: ModalResult::Action(<br/>ConfirmTheme("dark"))
ModalStack->>ModalStack: pop() - closes modal
ModalStack->>EventLoop: process_modal_action(<br/>ConfirmTheme("dark"))
EventLoop->>AppState: set_theme("dark")
Note over AppState: active_theme = "dark"<br/>preview_theme = None
EventLoop->>EventLoop: Persist to config
EventLoop-->>User: Toast: "Theme changed to: dark"
else User cancels
User->>ThemeSelectorModal: Press Esc
ThemeSelectorModal->>ModalStack: ModalResult::Action(<br/>RevertTheme)
ModalStack->>ModalStack: pop() - closes modal
ModalStack->>EventLoop: process_modal_action(<br/>RevertTheme)
EventLoop->>AppState: cancel_theme_preview()
AppState->>AppState: set_preview_theme(None)
AppState->>ThemeColors: ThemeColors::from_name(<br/>original active_theme)
ThemeColors-->>AppState: Restored colors
Note over AppState: preview_theme = None<br/>Colors reverted to original
AppState-->>User: TUI reverts to<br/>original theme
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, no comments
- Add preview_theme field to AppState for temporary theme previews - Add set_preview_theme, get_effective_theme_colors, start_theme_preview, cancel_theme_preview, and confirm_theme_preview methods - Add ModalResult::ActionContinue for live preview without closing modal - Add ModalAction variants: PreviewTheme, RevertTheme, ConfirmTheme - Update ThemeSelectorModal to emit preview actions on navigation - Add color swatch display in theme selector rows - Handle new theme actions in event loop - Update ThemePicker to use ThemeSelectorModal instead of interactive builder - Add comprehensive tests for new preview functionality
aa6f3a5 to
abe702a
Compare
Summary
Adds a live theme preview system to the TUI, allowing users to preview theme colors in real-time before confirming their selection.
Changes
preview_themefield to AppState for temporary theme previewsset_preview_theme,get_effective_theme_colors,start_theme_preview,cancel_theme_preview,confirm_theme_previewModalResult::ActionContinuevariant for live preview without closing modalModalActionvariants:PreviewTheme,RevertTheme,ConfirmThemeThemeSelectorModalto emit preview actions on navigation (Up/Down keys)ThemeSelectorModalinstead of interactive builderHow it works
/themescommandTesting