From 436f3a8a0c725ecc6fc945ae145459ddfe015a3e Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 7 Oct 2026 23:29:03 +1100 Subject: [PATCH] fix(archieui): the Versions card compares against the running daemon, so an available update can be installed --- .../app/archiemessaging/telegram_features.go | 34 +---------------- internal/app/archieui/compose.go | 4 +- internal/app/archieui/run.go | 2 +- internal/app/servicekit/versions.go | 38 +++++++++++++++++++ 4 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 internal/app/servicekit/versions.go diff --git a/internal/app/archiemessaging/telegram_features.go b/internal/app/archiemessaging/telegram_features.go index 21b4ac244..690c51f9a 100644 --- a/internal/app/archiemessaging/telegram_features.go +++ b/internal/app/archiemessaging/telegram_features.go @@ -9,13 +9,11 @@ import ( "time" configtemplate "github.com/samcharles93/archie-core" + "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/buildinfo" "github.com/samcharles93/archie-core/internal/channels/telegram" "github.com/samcharles93/archie-core/internal/domain/messaging" - "github.com/samcharles93/archie-core/internal/domain/presence" - "github.com/samcharles93/archie-core/internal/domain/storecontract" "github.com/samcharles93/archie-core/internal/releaseannounce" - "github.com/samcharles93/archie-core/internal/releaseupdate" "github.com/samcharles93/archie-core/internal/secret" ) @@ -25,7 +23,7 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon g.Version = gatewayVersionReporter(ctx, d.Chat, cfg.Options.DependencyTimeout) g.SetShowToolCalls(cfg.ShowToolCalls) g.Reload = telegramReloader(cfg.Options, d.Secrets, d.Log) - g.RunningVersions = runningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout) + g.RunningVersions = servicekit.RunningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout) if d.Updates != nil { g.Updates = d.Updates @@ -41,34 +39,6 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon } } -// runningVersions reports the daemon version archied's own presence record -// carries, so an update report is checked against what archied compiled in -// rather than this process's build. A down or unreachable daemon, or a -// missing store, leaves the daemon unverified. The agent stays unverified: -// only archied observes it. -func runningVersions(ctx context.Context, store storecontract.PresenceStore, timeout time.Duration) func() map[string]string { - return func() map[string]string { - if store == nil { - return nil - } - if timeout <= 0 { - timeout = 5 * time.Second - } - callCtx, cancel := context.WithTimeout(ctx, timeout) - defer cancel() - records, err := store.ListPresence(callCtx) - if err != nil { - return nil - } - for _, service := range presence.Mesh(records, time.Now()) { - if service.Service == presence.Daemon && service.State != presence.StateDown { - return map[string]string{releaseupdate.ComponentDaemon: service.Version} - } - } - return nil - } -} - // gatewayVersionReporter renders /version from the Gateway's build info, // fetched per call with a timeout. func gatewayVersionReporter(ctx context.Context, chat messaging.ChatContract, timeout time.Duration) func() string { diff --git a/internal/app/archieui/compose.go b/internal/app/archieui/compose.go index 5008b243f..f6884040a 100644 --- a/internal/app/archieui/compose.go +++ b/internal/app/archieui/compose.go @@ -5,6 +5,7 @@ import ( "log/slog" "time" + "github.com/samcharles93/archie-core/internal/app/servicekit" controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/health" @@ -50,7 +51,7 @@ type deps struct { // compose builds the dashboard server from contract-backed dependencies. // Unset fields answer 501/503 or empty. -func compose(d deps) *webui.Server { +func compose(ctx context.Context, d deps) *webui.Server { srv := &webui.Server{ Store: d.Store, Log: d.Log, @@ -90,6 +91,7 @@ func compose(d deps) *webui.Server { wireOrgSurface(srv, d.Store) if presence, ok := d.Store.(storecontract.PresenceStore); ok { srv.Presence = presence + srv.RunningVersions = servicekit.RunningVersions(ctx, presence, 0) } if applyStatus, ok := d.Store.(storecontract.ApplyStatusStore); ok { srv.ApplyStatus = applyStatus diff --git a/internal/app/archieui/run.go b/internal/app/archieui/run.go index 4009849a8..85ebf1f56 100644 --- a/internal/app/archieui/run.go +++ b/internal/app/archieui/run.go @@ -85,7 +85,7 @@ func Run(ctx context.Context, options Options) error { return err } - srv := compose(deps{ + srv := compose(ctx, deps{ Options: opts, Log: log, Store: tasks, diff --git a/internal/app/servicekit/versions.go b/internal/app/servicekit/versions.go new file mode 100644 index 000000000..d00080486 --- /dev/null +++ b/internal/app/servicekit/versions.go @@ -0,0 +1,38 @@ +package servicekit + +import ( + "context" + "time" + + "github.com/samcharles93/archie-core/internal/domain/presence" + "github.com/samcharles93/archie-core/internal/domain/storecontract" + "github.com/samcharles93/archie-core/internal/releaseupdate" +) + +// RunningVersions reports the daemon version archied's own presence record +// carries, so an update report is checked against what archied compiled in +// rather than this process's build. A down or unreachable daemon, or a +// missing store, leaves the daemon unverified. The agent stays unverified: +// only archied observes it. +func RunningVersions(ctx context.Context, store storecontract.PresenceStore, timeout time.Duration) func() map[string]string { + return func() map[string]string { + if store == nil { + return nil + } + if timeout <= 0 { + timeout = 5 * time.Second + } + callCtx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + records, err := store.ListPresence(callCtx) + if err != nil { + return nil + } + for _, service := range presence.Mesh(records, time.Now()) { + if service.Service == presence.Daemon && service.State != presence.StateDown { + return map[string]string{releaseupdate.ComponentDaemon: service.Version} + } + } + return nil + } +}