From 3d324ed7fbfec2fb15f107c34dc975221db290aa Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 7 May 2026 08:31:03 +0200 Subject: [PATCH] Bounce SuggestionsContext.SetSuggestions to UI thread SetSuggestions has two callers: prepareConfirmationPanel calls it directly on the UI thread, while editors.promptEditor and SuggestionsContext.RefreshSuggestions call it via AsyncHandler, which runs the result closure on a worker goroutine. The worker path currently relies on HandleRender's self.c.Render() to flush the view update. Wrap the body in OnUIThread so the worker path stays correct when Render() is removed; for the UI-thread caller the extra bounce is harmless. --- pkg/gui/context/suggestions_context.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/gui/context/suggestions_context.go b/pkg/gui/context/suggestions_context.go index eafe7fb7c..fb69b34d9 100644 --- a/pkg/gui/context/suggestions_context.go +++ b/pkg/gui/context/suggestions_context.go @@ -67,10 +67,17 @@ func NewSuggestionsContext( } func (self *SuggestionsContext) SetSuggestions(suggestions []*types.Suggestion) { - self.State.Suggestions = suggestions - self.SetSelection(0) - self.c.ResetViewOrigin(self.GetView()) - self.HandleRender() + // SetSuggestions is invoked from AsyncHandler (a worker goroutine) when + // the prompt input changes, as well as from prepareConfirmationPanel on + // the UI thread. Bounce to the UI thread either way so the worker path + // keeps flushing once HandleRender stops calling Render() itself. + self.c.OnUIThread(func() error { + self.State.Suggestions = suggestions + self.SetSelection(0) + self.c.ResetViewOrigin(self.GetView()) + self.HandleRender() + return nil + }) } func (self *SuggestionsContext) RefreshSuggestions() {