Skip to content

Commit 60094dc

Browse files
committed
Implement multiple code changes to enhance functionality and improve performance
1 parent 8f7f594 commit 60094dc

File tree

3 files changed

+1580
-70
lines changed

3 files changed

+1580
-70
lines changed

src/events.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,28 @@ pub enum AppEvent {
1414
OpenSettings,
1515
/// User requested to close settings modal
1616
CloseSettings,
17+
/// User requested to show about information
18+
ShowAbout,
19+
/// User requested to show menu modal
20+
ShowMenu,
1721
/// Navigate up in settings modal
1822
NavigateUp,
1923
/// Navigate down in settings modal
2024
NavigateDown,
25+
/// Navigate left (for theme switching)
26+
NavigateLeft,
27+
/// Navigate right (for theme switching)
28+
NavigateRight,
2129
/// Select current item in settings modal
2230
Select,
2331
/// Start the AI orchestration application (Enter key)
2432
StartApplication,
2533
/// Toggle theme between Dark/Light
2634
ToggleTheme,
35+
/// Text input character
36+
Input(char),
37+
/// Backspace key pressed
38+
Backspace,
2739
/// Settings action to be applied
2840
SettingsAction(crate::settings::SettingsAction),
2941
/// Terminal was resized to new dimensions
@@ -58,22 +70,27 @@ impl EventHandler {
5870
KeyCode::Char('q') => Ok(AppEvent::Quit),
5971
KeyCode::Esc => Ok(AppEvent::CloseSettings),
6072
KeyCode::Char(',') | KeyCode::Char('s') | KeyCode::Char('S') => {
61-
Ok(AppEvent::OpenSettings)
73+
Ok(AppEvent::ShowMenu)
6274
}
75+
KeyCode::Char('a') | KeyCode::Char('A') => Ok(AppEvent::ShowAbout),
6376
KeyCode::Char('t') | KeyCode::Char('T') => Ok(AppEvent::ToggleTheme),
6477
KeyCode::Up | KeyCode::Char('k') => Ok(AppEvent::NavigateUp),
6578
KeyCode::Down | KeyCode::Char('j') => Ok(AppEvent::NavigateDown),
79+
KeyCode::Left | KeyCode::Char('h') => Ok(AppEvent::NavigateLeft),
80+
KeyCode::Right | KeyCode::Char('l') => Ok(AppEvent::NavigateRight),
6681
KeyCode::Enter => {
6782
// Enter can be either StartApplication or Select depending on context
6883
// We'll let the App decide which one to use based on state
6984
Ok(AppEvent::StartApplication)
7085
}
7186
KeyCode::Char(' ') => Ok(AppEvent::Select),
87+
KeyCode::Backspace => Ok(AppEvent::Backspace),
7288
KeyCode::Char('c')
7389
if key_event.modifiers.contains(KeyModifiers::CONTROL) =>
7490
{
7591
Ok(AppEvent::ForceQuit)
7692
}
93+
KeyCode::Char(c) => Ok(AppEvent::Input(c)),
7794
_ => Ok(AppEvent::None),
7895
}
7996
}
@@ -97,6 +114,10 @@ impl Default for EventHandler {
97114
pub enum AppState {
98115
/// Primary TUI interface
99116
Main,
117+
/// Menu modal active
118+
Menu,
119+
/// Model selection modal active for OpenRouter
120+
ModelSelection,
100121
/// Settings modal active
101122
Settings,
102123
/// Waiting for provider configuration - no valid providers available

src/theme.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub struct ColorPalette {
3232
pub border: Color,
3333
pub selection: Color,
3434
pub cursor: Color,
35+
pub warning: Color, // Yellow/orange for settings
3536
}
3637

3738
/// UI element types for styling
@@ -57,6 +58,8 @@ pub enum Element {
5758
Active,
5859
/// Inactive/disabled elements
5960
Inactive,
61+
/// Warning/settings elements (yellow/orange)
62+
Warning,
6063
}
6164

6265
/// Main theme structure managing all UI styling
@@ -85,6 +88,7 @@ impl Theme {
8588
border: Color::Rgb(116, 125, 135), // #747d87 (gray)
8689
selection: Color::Rgb(64, 72, 78), // #40484e (darker bg)
8790
cursor: Color::Rgb(211, 198, 170), // #d3c6aa (same as fg)
91+
warning: Color::Rgb(219, 188, 127), // #dbbc7f (yellow/orange)
8892
},
8993
ThemeVariant::EverforestLight => ColorPalette {
9094
background: Color::Rgb(253, 246, 227), // #fdf6e3
@@ -95,6 +99,7 @@ impl Theme {
9599
border: Color::Rgb(150, 160, 170), // #96a0aa (gray)
96100
selection: Color::Rgb(243, 236, 217), // #f3ecd9 (darker bg)
97101
cursor: Color::Rgb(92, 106, 114), // #5c6a72 (same as fg)
102+
warning: Color::Rgb(207, 131, 44), // #cf832c (yellow/orange)
98103
},
99104
};
100105

@@ -174,6 +179,10 @@ impl Theme {
174179
Element::Inactive => Style::default()
175180
.fg(self.colors.border)
176181
.bg(self.colors.background),
182+
183+
Element::Warning => Style::default()
184+
.fg(self.colors.warning)
185+
.bg(self.colors.background),
177186
}
178187
}
179188

@@ -186,6 +195,7 @@ impl Theme {
186195
Element::Highlight => self.colors.foreground,
187196
Element::Secondary => self.colors.secondary,
188197
Element::Info => self.colors.info,
198+
Element::Warning => self.colors.warning,
189199
}
190200
}
191201

@@ -231,4 +241,9 @@ impl Theme {
231241
pub fn info_style(&self) -> Style {
232242
self.ratatui_style(Element::Info)
233243
}
244+
245+
/// Get style for warning/settings elements
246+
pub fn warning_style(&self) -> Style {
247+
self.ratatui_style(Element::Warning)
248+
}
234249
}

0 commit comments

Comments
 (0)