From 2cf9d435ccfb84009d9f7977539869d8cc51ac07 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 27 Oct 2026 10:46:52 +1100 Subject: [PATCH] feat(webui): derive the setup checklist from the caller's organisation and drop the optional chat channel step --- internal/config/chat_frontends.go | 12 ----- internal/webui/api_config.go | 10 +--- internal/webui/api_setup.go | 69 +++++++++++++--------------- internal/webui/server.go | 2 +- ui/src/dashboard/setup-preference.ts | 1 - 5 files changed, 33 insertions(+), 61 deletions(-) diff --git a/internal/config/chat_frontends.go b/internal/config/chat_frontends.go index fe22437c5..745431356 100644 --- a/internal/config/chat_frontends.go +++ b/internal/config/chat_frontends.go @@ -19,15 +19,3 @@ func (c ChatConfig) FrontEnds() []ChatFrontEnd { }, } } - -// AnyFrontEndConfigured reports whether at least one conversational front-end -// has credentials. The setup checklist asks this as a yes/no question; every -// other consumer wants the per-front-end detail FrontEnds returns. -func (c ChatConfig) AnyFrontEndConfigured() bool { - for _, frontEnd := range c.FrontEnds() { - if frontEnd.Configured { - return true - } - } - return false -} diff --git a/internal/webui/api_config.go b/internal/webui/api_config.go index 0266e9096..3ede9669f 100644 --- a/internal/webui/api_config.go +++ b/internal/webui/api_config.go @@ -152,9 +152,6 @@ type ChatView struct { // [chat]. Empty when unset, which the page renders as no greeting // rather than a hardcoded name. Operator string `json:"operator,omitempty"` - // ChannelConfigured reports that at least one conversational - // front-end has credentials. - ChannelConfigured bool `json:"channel_configured"` } // ConfigViewSchema names ConfigView's JSON shape; it changes on incompatible @@ -229,16 +226,11 @@ func BuildConfigView(in ConfigViewInput) ConfigView { MultiIdentity: len(cfg.Identities) > 0, Identities: identityForgesView(cfg.Identities), Catalog: append([]CatalogProviderView{}, in.Catalog...), - Chat: ChatView{ShowToolCalls: cfg.Chat.ShowToolCalls, Operator: strings.TrimSpace(cfg.Chat.Operator), ChannelConfigured: chatChannelConfigured(cfg.Chat)}, + Chat: ChatView{ShowToolCalls: cfg.Chat.ShowToolCalls, Operator: strings.TrimSpace(cfg.Chat.Operator)}, Reload: in.Reload, } } -// chatChannelConfigured reports whether any chat front-end is configured. -func chatChannelConfigured(chat config.ChatConfig) bool { - return chat.AnyFrontEndConfigured() -} - // RemoteConfigView reads the projection the configuration owner published. // The reading process cannot edit it: it has no update path, and the page is // told so rather than offering a control that would 503. diff --git a/internal/webui/api_setup.go b/internal/webui/api_setup.go index 0c1f2c365..547dd2fb1 100644 --- a/internal/webui/api_setup.go +++ b/internal/webui/api_setup.go @@ -2,7 +2,9 @@ package webui import ( "net/http" - "strings" + + "github.com/samcharles93/archie-core/internal/domain/identity" + "github.com/samcharles93/archie-core/internal/domain/org" ) // SetupStep is one item in the dashboard's getting-started checklist. Path is @@ -15,53 +17,44 @@ type SetupStep struct { Path string `json:"path,omitempty"` } -// handleSetup reports which setup steps are still missing, from live state. +// handleSetup reports which setup steps are still missing in the caller's +// organisation, from live state. Optional capabilities (a chat channel, a +// repository) are set up where they are used, not listed here. func (s *Server) handleSetup(w http.ResponseWriter, r *http.Request) { steps := []SetupStep{} - - // Every step is read from the configuration projection this process - // renders, so the checklist works the same whether configuration is - // held here or published by its owner. - view, found, err := s.configSource()(r.Context()) - if err != nil || !found { - // No configuration available: report nothing rather than - // guessing, so the dashboard simply omits the panel. + if s.Store == nil { writeJSON(w, map[string]any{"steps": steps}) return } - - // The operator's name is deployment data, configured once in [chat]. The - // dashboard greets with it rather than hardcoding a name, which would be - // wrong on every deployment but one. - operator := view.Chat.Operator - - steps = append(steps, SetupStep{ - Title: "Identity", - Detail: "Account Archie commits as.", - Done: strings.TrimSpace(view.Identity.BotUser) != "", - Path: "/org/agents", - }) - - steps = append(steps, SetupStep{ - Title: "Chat channel", - Detail: "Chat and approvals.", - Done: view.Chat.ChannelConfigured, - Path: "/org/channels", - }) - - // Only meaningful once there is somewhere to run work. + if done, ok := s.hasActiveAgent(r); ok { + steps = append(steps, SetupStep{Title: "Agent identity", Done: done, Path: "/org/agents"}) + } if count, err := s.Store.StatusCounts(r.Context()); err == nil { total := 0 for _, n := range count { total += n } - steps = append(steps, SetupStep{ - Title: "First task", - Detail: "Describe one above.", - Done: total > 0, - Path: "/tasks", - }) + steps = append(steps, SetupStep{Title: "First task", Done: total > 0, Path: "/tasks"}) } + writeJSON(w, map[string]any{"steps": steps}) +} - writeJSON(w, map[string]any{"steps": steps, "operator": operator}) +// hasActiveAgent reports whether the caller's org has an active bot or +// service account assigned; ok is false when that cannot be read. +func (s *Server) hasActiveAgent(r *http.Request) (done, ok bool) { + reader, isReader := s.Orgs.(org.AgentAssignments) + if !isReader || s.Identities == nil { + return false, false + } + assignments, err := reader.ListOrgAgents(r.Context(), policyOrg(r)) + if err != nil { + return false, false + } + for _, assignment := range assignments { + value, err := s.Identities.Get(r.Context(), assignment.IdentityID) + if err == nil && value.Kind.Agent() && value.Lifecycle == identity.LifecycleActive { + return true, true + } + } + return false, true } diff --git a/internal/webui/server.go b/internal/webui/server.go index 7e732f0c2..33d14c5ad 100644 --- a/internal/webui/server.go +++ b/internal/webui/server.go @@ -276,7 +276,7 @@ func (s *Server) Broadcast(e events.Event) { func (s *Server) registerCoreRoutes(mux *http.ServeMux) { mux.HandleFunc("GET /api/summary", s.handleSummary) - mux.HandleFunc("GET /api/setup", instanceOnly(s.handleSetup)) + mux.HandleFunc("GET /api/setup", s.handleSetup) mux.HandleFunc("GET /api/workflows", s.handleWorkflows) mux.HandleFunc("PUT /api/workflows/{id}/enabled", s.handleWorkflowEnabled) mux.HandleFunc("POST /api/work-requests", s.handleWorkRequest) diff --git a/ui/src/dashboard/setup-preference.ts b/ui/src/dashboard/setup-preference.ts index d4fc5d329..d73889d80 100644 --- a/ui/src/dashboard/setup-preference.ts +++ b/ui/src/dashboard/setup-preference.ts @@ -10,7 +10,6 @@ export interface SetupStep { export interface Setup { steps: SetupStep[]; - operator?: string; } export interface SetupPanelState {