Skip to content

Commit 20ad944

Browse files
johnsideserfclaude
andcommitted
Fix settings persistence, input scrolling, and image preview refresh
- Settings now persist to config file when closing /settings overlay - Load existing config before saving to preserve signal_cli_path etc - Input box scrolls horizontally when text exceeds width (fixes #39) - Toggling inline image previews re-renders existing messages immediately - Tab key toggles settings items in /settings overlay Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f06e75e commit 20ad944

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/app.rs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ impl App {
173173
0 => self.notify_direct = !self.notify_direct,
174174
1 => self.notify_group = !self.notify_group,
175175
2 => self.sidebar_visible = !self.sidebar_visible,
176-
3 => self.inline_images = !self.inline_images,
176+
3 => {
177+
self.inline_images = !self.inline_images;
178+
self.refresh_image_previews();
179+
}
177180
4 => self.native_images = !self.native_images,
178181
5 => self.show_receipts = !self.show_receipts,
179182
6 => self.color_receipts = !self.color_receipts,
@@ -196,6 +199,41 @@ impl App {
196199
}
197200
}
198201

202+
/// Persist current settings to the config file.
203+
fn save_settings(&self) {
204+
// Load existing config to preserve non-settings fields (signal_cli_path, download_dir)
205+
let mut config = crate::config::Config::load(None).unwrap_or_default();
206+
config.account = self.account.clone();
207+
config.notify_direct = self.notify_direct;
208+
config.notify_group = self.notify_group;
209+
config.inline_images = self.inline_images;
210+
config.native_images = self.native_images;
211+
config.show_receipts = self.show_receipts;
212+
config.color_receipts = self.color_receipts;
213+
config.nerd_fonts = self.nerd_fonts;
214+
if let Err(e) = config.save() {
215+
crate::debug_log::logf(format_args!("settings save error: {e}"));
216+
}
217+
}
218+
219+
/// Re-render or clear image previews on all messages (after toggling inline_images).
220+
fn refresh_image_previews(&mut self) {
221+
for conv in self.conversations.values_mut() {
222+
for msg in &mut conv.messages {
223+
if msg.body.starts_with("[image:") {
224+
if self.inline_images {
225+
// Re-render from stored path
226+
if let Some(ref p) = msg.image_path {
227+
msg.image_lines = image_render::render_image(Path::new(p), 40);
228+
}
229+
} else {
230+
msg.image_lines = None;
231+
}
232+
}
233+
}
234+
}
235+
}
236+
199237
/// Handle a key press while the settings overlay is open.
200238
pub fn handle_settings_key(&mut self, code: KeyCode) {
201239
match code {
@@ -207,11 +245,12 @@ impl App {
207245
KeyCode::Char('k') | KeyCode::Up => {
208246
self.settings_index = self.settings_index.saturating_sub(1);
209247
}
210-
KeyCode::Char(' ') | KeyCode::Enter => {
248+
KeyCode::Char(' ') | KeyCode::Enter | KeyCode::Tab => {
211249
self.toggle_setting(self.settings_index);
212250
}
213251
KeyCode::Esc | KeyCode::Char('q') => {
214252
self.show_settings = false;
253+
self.save_settings();
215254
}
216255
_ => {}
217256
}

0 commit comments

Comments
 (0)