From e323ee49ab1a2c3132f2da51142f884f6edff441 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Sun, 31 May 2026 22:04:17 +0800 Subject: [PATCH] fix(git): scope Enter swallow to a visible ready Git popover The Enter guard keyed off branch_picker_open/overflow_open alone, so a stale flag while the panel was closed / loading / merging / showing a diff would wrongly eat the global Enter. Add git_ready_popover_open() (panel open + ready view + a popover flag) and guard on it instead. --- crates/op-host-native/src/widget_host/input.rs | 15 +++++++++++++++ crates/op-host-native/src/widget_host/keyboard.rs | 12 ++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/op-host-native/src/widget_host/input.rs b/crates/op-host-native/src/widget_host/input.rs index 547ea9fa9..eb9a50a8b 100644 --- a/crates/op-host-native/src/widget_host/input.rs +++ b/crates/op-host-native/src/widget_host/input.rs @@ -61,6 +61,21 @@ impl WidgetHostNative { panel.open && panel.branch_create_focused && !panel.loading } + /// Whether a ready-state Git popover (branch picker / overflow menu) is + /// actually visible — the panel is open, in the ready view, and a popover + /// flag is set. Scopes the Enter swallow so a stale flag while the panel + /// is closed / loading / merging / showing a diff can't eat global Enter. + pub fn git_ready_popover_open(&self) -> bool { + let p = &self.editor_state.editor_ui.git_panel; + p.open + && p.in_repo + && !p.loading + && !p.merging + && p.diff.is_none() + && p.merge_resolve.is_none() + && (p.branch_picker_open || p.overflow_open) + } + /// Whether the inline Git clone wizard is up. While it is, the /// wizard owns the keyboard: a focused URL / destination field takes /// text, and every other key is swallowed so no canvas shortcut diff --git a/crates/op-host-native/src/widget_host/keyboard.rs b/crates/op-host-native/src/widget_host/keyboard.rs index 6dd57400a..d5e880210 100644 --- a/crates/op-host-native/src/widget_host/keyboard.rs +++ b/crates/op-host-native/src/widget_host/keyboard.rs @@ -646,12 +646,12 @@ impl WidgetHostNative { self.mark_dirty(); return true; } - // While a ready-state popover (branch picker / overflow menu) is open - // with no focused input, swallow Enter so it can't fall through to the - // global chat send below. (Focused inputs already submitted above.) - if self.editor_state.editor_ui.git_panel.branch_picker_open - || self.editor_state.editor_ui.git_panel.overflow_open - { + // While a ready-state popover (branch picker / overflow menu) is + // actually visible with no focused input, swallow Enter so it can't + // fall through to the global chat send below. (Focused inputs already + // submitted above; the helper requires the ready view so a stale flag + // on a closed / merging / diff panel can't eat global Enter.) + if self.git_ready_popover_open() { return true; } if self.editor_state.ui.layer_rename.is_some() {