From c23bcd6d9423f3fd51bd8b8d39a5b01dbc52ca65 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 15 Jul 2026 15:19:55 +0200 Subject: [PATCH] Store the UI thread ID earlier --- pkg/gocui/gui.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/gocui/gui.go b/pkg/gocui/gui.go index dbef57b59..20beb2af7 100644 --- a/pkg/gocui/gui.go +++ b/pkg/gocui/gui.go @@ -293,6 +293,12 @@ func NewGui(opts NewGuiOpts) (*Gui, error) { g.playRecording = opts.PlayRecording + // Record the UI thread here, at construction. This assumes NewGui is called + // on the same goroutine that will run MainLoop, which holds for all our + // callers -- and it means IsUIThread is already correct for the UI work that + // runs during startup, before we reach MainLoop. + g.uiThreadID.Store(goid.Get()) + return g, nil } @@ -977,8 +983,6 @@ func (g *Gui) SetManagerFunc(manager func(*Gui) error) { func (g *Gui) MainLoop() error { defer close(g.loopExited) - g.uiThreadID.Store(goid.Get()) - go func() { for { select {