From 95c7394b01d61a1b175ef4b71eef15a550e474c5 Mon Sep 17 00:00:00 2001 From: "Brandon McGinty (chatgpt)" Date: Mon, 10 Aug 2026 07:31:18 -0400 Subject: [PATCH] Snapshot context actions under client lock --- admin.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/admin.go b/admin.go index e8e5f1a..00a178f 100644 --- a/admin.go +++ b/admin.go @@ -490,11 +490,21 @@ func (b *Barnard) adminACLItems() []uiterm.TreeItem { } func (b *Barnard) adminContextActionItems() []uiterm.TreeItem { - if b.Client == nil || len(b.Client.ContextActions) == 0 { + if b.Client == nil { + return []uiterm.TreeItem{adminItem{label: "No context actions available"}} + } + var actions []*gumble.ContextAction + b.Client.Do(func() { + actions = make([]*gumble.ContextAction, 0, len(b.Client.ContextActions)) + for _, action := range b.Client.ContextActions { + actions = append(actions, action) + } + }) + if len(actions) == 0 { return []uiterm.TreeItem{adminItem{label: "No context actions available"}} } items := []uiterm.TreeItem{} - for _, action := range b.Client.ContextActions { + for _, action := range actions { ca := action label := ca.Label if label == "" { @@ -830,7 +840,8 @@ func (b *Barnard) executeContextCommand(fields []string) { b.AddOutputLine("Admin: usage /admin context [server|user|channel] [target]") return } - action := b.Client.ContextActions[fields[1]] + var action *gumble.ContextAction + b.Client.Do(func() { action = b.Client.ContextActions[fields[1]] }) if action == nil { b.AddOutputLine("Admin: context action not found") return