From c8ab8fddd3dba5122996d7afc27986170d881348 Mon Sep 17 00:00:00 2001 From: Narrator Date: Thu, 29 Oct 2026 19:28:59 +0100 Subject: [PATCH] Background checks get their own copy of the answers The dashboard, mirror, review, users, rooms, tokens and update checks copied the config with *s.cfg, which still shares the Components, Values and Overrides maps. They read those maps (VarsYAML, DNSRecords) while the UI writes them: leaving Settings or saving a Fine-tune value during a check could abort the app with "concurrent map iteration and map write". config.Clone copies the maps and slices too, and the deploy runner and history snapshot use it as well. Co-Authored-By: Claude Opus 5.5 --- internal/config/config.go | 13 +++++++++++++ internal/config/tuning_test.go | 10 ++++++++++ internal/deploy/deploy.go | 7 ++----- internal/deploy/history.go | 2 +- internal/ui/dashboard.go | 2 +- internal/ui/mirrors.go | 2 +- internal/ui/rooms.go | 4 ++-- internal/ui/screens_deploy.go | 4 ++-- internal/ui/screens_manage.go | 2 +- internal/ui/screens_tools.go | 2 +- internal/ui/screens_tuning.go | 2 +- internal/ui/tokens.go | 4 ++-- internal/ui/users.go | 4 ++-- 13 files changed, 39 insertions(+), 19 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 841fab4..301f3a6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -177,6 +177,19 @@ func Fresh() *Config { return c } +// Clone is a copy that shares no maps or slices with c, for work in the +// background while c is still being edited. +func (c *Config) Clone() *Config { + cp := *c + cp.Components, cp.Values, cp.Overrides = maps.Clone(c.Components), maps.Clone(c.Values), maps.Clone(c.Overrides) + cp.FederateOnly, cp.FederateNever = slices.Clone(c.FederateOnly), slices.Clone(c.FederateNever) + if c.Deployed != nil { + d := *c.Deployed + cp.Deployed = &d + } + return &cp +} + // Load returns the saved configuration, or fresh answers on first run. // A file that can't be parsed is moved aside to .broken-