Skip to content

Commit 763ad70

Browse files
johnsideserfclaude
andauthored
Expose notification preview level in /settings UI (#169)
Add a cycle toggle for notification_preview ("full", "sender", "minimal") in the settings overlay, between the boolean toggles and the Theme selector. Press Space/Enter to cycle through values. Setting is persisted to config.toml. Closes #162 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ecb35b0 commit 763ad70

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

src/app.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ impl App {
818818
config.account = self.account.clone();
819819
config.theme = self.theme.name.clone();
820820
config.keybinding_profile = self.keybindings.profile_name.clone();
821+
config.notification_preview = self.notification_preview.clone();
821822
for def in SETTINGS {
822823
if let Some(save_fn) = def.save {
823824
save_fn(&mut config, (def.get)(self));
@@ -880,8 +881,9 @@ impl App {
880881
/// Handle a key press while the settings overlay is open.
881882
/// After toggles: Theme at SETTINGS.len(), Keybindings at SETTINGS.len()+1.
882883
pub fn handle_settings_key(&mut self, code: KeyCode) {
883-
let theme_index = SETTINGS.len();
884-
let kb_index = SETTINGS.len() + 1;
884+
let preview_index = SETTINGS.len();
885+
let theme_index = SETTINGS.len() + 1;
886+
let kb_index = SETTINGS.len() + 2;
885887
let max_index = kb_index;
886888
match code {
887889
KeyCode::Char('j') | KeyCode::Down => {
@@ -893,7 +895,13 @@ impl App {
893895
self.settings_index = self.settings_index.saturating_sub(1);
894896
}
895897
KeyCode::Char(' ') | KeyCode::Enter | KeyCode::Tab => {
896-
if self.settings_index == theme_index {
898+
if self.settings_index == preview_index {
899+
self.notification_preview = match self.notification_preview.as_str() {
900+
"full" => "sender".to_string(),
901+
"sender" => "minimal".to_string(),
902+
_ => "full".to_string(),
903+
};
904+
} else if self.settings_index == theme_index {
897905
self.show_settings = false;
898906
self.save_settings();
899907
self.show_theme_picker = true;

src/ui.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ fn draw_autocomplete(frame: &mut Frame, app: &App, input_area: Rect) {
21472147

21482148
fn draw_settings(frame: &mut Frame, app: &App, area: Rect) {
21492149
let theme = &app.theme;
2150-
let height = SETTINGS_POPUP_HEIGHT + 2; // extra lines for theme + keybindings entries
2150+
let height = SETTINGS_POPUP_HEIGHT + 3; // extra lines for preview + theme + keybindings entries
21512151
let (popup_area, block) = centered_popup(
21522152
frame, area, SETTINGS_POPUP_WIDTH, height, " Settings ", theme,
21532153
);
@@ -2176,8 +2176,26 @@ fn draw_settings(frame: &mut Frame, app: &App, area: Rect) {
21762176
]));
21772177
}
21782178

2179-
// Theme selector entry (index == SETTINGS.len())
2180-
let is_theme_selected = app.settings_index == SETTINGS.len();
2179+
// Notification preview cycle entry (index == SETTINGS.len())
2180+
let preview_index = SETTINGS.len();
2181+
let is_preview_selected = app.settings_index == preview_index;
2182+
let preview_style = if is_preview_selected {
2183+
Style::default().bg(theme.bg_selected).fg(theme.fg).add_modifier(Modifier::BOLD)
2184+
} else {
2185+
Style::default().fg(theme.fg_secondary)
2186+
};
2187+
let preview_value_style = if is_preview_selected {
2188+
Style::default().bg(theme.bg_selected).fg(theme.accent)
2189+
} else {
2190+
Style::default().fg(theme.accent)
2191+
};
2192+
lines.push(Line::from(vec![
2193+
Span::styled(" Notification preview: ", preview_style),
2194+
Span::styled(app.notification_preview.clone(), preview_value_style),
2195+
]));
2196+
2197+
// Theme selector entry (index == SETTINGS.len() + 1)
2198+
let is_theme_selected = app.settings_index == SETTINGS.len() + 1;
21812199
let theme_style = if is_theme_selected {
21822200
Style::default().bg(theme.bg_selected).fg(theme.fg).add_modifier(Modifier::BOLD)
21832201
} else {
@@ -2193,8 +2211,8 @@ fn draw_settings(frame: &mut Frame, app: &App, area: Rect) {
21932211
Span::styled(app.theme.name.clone(), theme_value_style),
21942212
]));
21952213

2196-
// Keybindings selector entry (index == SETTINGS.len() + 1)
2197-
let is_kb_selected = app.settings_index == SETTINGS.len() + 1;
2214+
// Keybindings selector entry (index == SETTINGS.len() + 2)
2215+
let is_kb_selected = app.settings_index == SETTINGS.len() + 2;
21982216
let kb_style = if is_kb_selected {
21992217
Style::default().bg(theme.bg_selected).fg(theme.fg).add_modifier(Modifier::BOLD)
22002218
} else {

0 commit comments

Comments
 (0)