From 45d68bccc21621f9ec0c4caf74737c1aaf398e2b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 25 Aug 2026 09:18:38 +0200 Subject: [PATCH] Treat the views of a popup panel as a group when clicking The check was a single set of view names, so it also let a click move between two different panels, e.g. from the prompt to the commit message. List the panels instead, and require both views to be in the same one. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gui/gui.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1a3a1273e..e10705748 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -922,6 +922,20 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView { return result } +// The views that each popup panel is made up of. A panel's views share the +// keyboard focus, so clicking from one of them to another stays within the +// panel. +var popupPanelViewGroups = [][]string{ + {"commitMessage", "commitDescription"}, + {"prompt", "suggestions"}, +} + +func viewsBelongToSamePopupPanel(viewName string, otherViewName string) bool { + return lo.SomeBy(popupPanelViewGroups, func(group []string) bool { + return lo.Contains(group, viewName) && lo.Contains(group, otherViewName) + }) +} + // Run: setup the gui with keybindings and start the mainloop func (gui *Gui) Run(startArgs appTypes.StartArgs) error { g, err := gui.initGocui(Headless(), startArgs.IntegrationTest) @@ -937,15 +951,11 @@ func (gui *Gui) Run(startArgs appTypes.StartArgs) error { gui.g.ShouldHandleMouseEvent = func(view *gocui.View, key gocui.KeyName) bool { if gui.helpers.Confirmation.IsPopupPanelFocused() && gui.currentViewName() != view.Name() && !gocui.IsMouseScrollKey(key) { - // we ignore click events on views that aren't popup panels, when a popup panel is focused. - // Unless both the current view and the clicked-on view are either commit message or commit - // description, or a prompt and the suggestions view, because we want to allow switching - // between those two views by clicking. - isCommitMessageOrSuggestionsView := func(viewName string) bool { - return viewName == "commitMessage" || viewName == "commitDescription" || - viewName == "prompt" || viewName == "suggestions" - } - if !isCommitMessageOrSuggestionsView(gui.currentViewName()) || !isCommitMessageOrSuggestionsView(view.Name()) { + // we ignore click events on views that aren't popup panels, when a popup + // panel is focused. Unless the clicked-on view is part of the same popup + // panel as the current one, because we want to allow switching between the + // views of a panel by clicking. + if !viewsBelongToSamePopupPanel(gui.currentViewName(), view.Name()) { return false } }