From 0402fb1233de717c020d3efa8362287faefd8bb2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 09:55:59 +0000 Subject: [PATCH] Fix channel dialog freeze when pressing Enter Fixed a deadlock issue where the application would freeze when pressing Enter to create or edit a channel. The problem was caused by creating the dialog action inside the ui.input() closure, which held a lock on the input state while executing action handler code. The fix moves the action creation outside the closure, following the same pattern used in other input handlers throughout the codebase. Now we only check if the key was pressed inside the closure and handle the action creation afterwards. This resolves the freeze while maintaining the same functionality when clicking the button, as button clicks don't hold input state locks. --- .../notedeck_columns/src/ui/channel_dialog.rs | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/crates/notedeck_columns/src/ui/channel_dialog.rs b/crates/notedeck_columns/src/ui/channel_dialog.rs index 3008765..f60281e 100644 --- a/crates/notedeck_columns/src/ui/channel_dialog.rs +++ b/crates/notedeck_columns/src/ui/channel_dialog.rs @@ -129,35 +129,37 @@ impl ChannelDialog { ); // Handle Escape key to close dialog - ui.input(|i| { - if i.key_pressed(egui::Key::Escape) { - action = Some(ChannelDialogAction::Cancel); - } - // Handle Enter key when name is focused - if i.key_pressed(egui::Key::Enter) && !hashtags_response.has_focus() { - if !self.name.trim().is_empty() { - let hashtags: Vec = self - .hashtags - .split(',') - .map(|s| s.trim().to_string()) - .filter(|s| !s.is_empty()) - .collect(); + let escape_pressed = ui.input(|i| i.key_pressed(egui::Key::Escape)); + let enter_pressed = ui.input(|i| i.key_pressed(egui::Key::Enter)); - action = if let Some(index) = self.editing_index { - Some(ChannelDialogAction::Edit { - index, - name: self.name.trim().to_string(), - hashtags, - }) - } else { - Some(ChannelDialogAction::Create { - name: self.name.trim().to_string(), - hashtags, - }) - }; - } + if escape_pressed { + action = Some(ChannelDialogAction::Cancel); + } + + // Handle Enter key when name is focused (not hashtags multiline field) + if enter_pressed && !hashtags_response.has_focus() { + if !self.name.trim().is_empty() { + let hashtags: Vec = self + .hashtags + .split(',') + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()) + .collect(); + + action = if let Some(index) = self.editing_index { + Some(ChannelDialogAction::Edit { + index, + name: self.name.trim().to_string(), + hashtags, + }) + } else { + Some(ChannelDialogAction::Create { + name: self.name.trim().to_string(), + hashtags, + }) + }; } - }); + } ui.add_space(24.0);