The same dashboard is served by the daemon, which holds every runtime handle, and by the UI process, which holds two remote contracts. A section with nothing behind it still answers -- an empty list, a "disabled" marker, a 501 -- and the browser cannot tell that from a deployment where nothing has happened yet. GET /api/capabilities says which sections this process can back, and the nav drops the rest rather than offering a page that is permanently empty. It fails open in both directions: an unreported section stays visible, and a failed read hides nothing, because an entry that silently vanished is worse than a page that explains itself. Mappings and bindings move the other way. Both are ratified State Store contracts carried by the client the UI process already holds, so leaving them nil degraded two pages that have an owner; compose wires them. A table test now enumerates every route whose capability is daemon-local and pins what it answers without one (requirement 4 of archie-core-8cda.5.4): task logs, the log feed and its stream, version and the update flow, channels and reload, curators, memory, skills, workflows and work requests. Adding a route with no owner now fails that test rather than the operator's browser.
42 lines
1.7 KiB
Go
42 lines
1.7 KiB
Go
package webui
|
|
|
|
import "net/http"
|
|
|
|
// handleCapabilities reports which dashboard sections this process can
|
|
// actually serve.
|
|
//
|
|
// The dashboard is served by two different compositions: the daemon, which
|
|
// holds every runtime handle, and the UI process, which holds two remote
|
|
// contracts and nothing else. Sections whose capability lives only in the
|
|
// daemon still answer -- with an empty list, a "disabled" marker, or a 501 --
|
|
// and the page cannot tell that apart from a deployment where nothing has
|
|
// happened yet. Rather than have every page guess, the server says which
|
|
// sections it can back, and the browser hides the rest.
|
|
//
|
|
// A section is reported available when the handle behind it is wired, which
|
|
// is the same condition its handler already uses to decide between real data
|
|
// and its degraded answer. Sections backed by the task store are absent from
|
|
// this list: the store is mandatory in both compositions.
|
|
func (s *Server) handleCapabilities(w http.ResponseWriter, _ *http.Request) {
|
|
writeJSON(w, map[string]any{
|
|
"sections": map[string]bool{
|
|
"chat": s.Chat != nil && s.Chat.Contract != nil,
|
|
"logs": s.LogFeed != nil,
|
|
"skills": s.Cfg != nil,
|
|
"memory": s.Memory != nil,
|
|
"curators": s.Curators != nil,
|
|
"channels": s.Channels != nil || s.Cfg != nil,
|
|
"captures": s.Captures != nil,
|
|
"mappings": s.Mappings != nil,
|
|
"bindings": s.Bindings != nil,
|
|
// The workflows page draws its statistics from the task store
|
|
// and its definition list from the local registry, so it is
|
|
// worth showing with only the former.
|
|
"workflows": true,
|
|
// Configuration renders from whichever source is wired; the
|
|
// page reports its own editability (see ConfigView.Editable).
|
|
"settings": true,
|
|
},
|
|
})
|
|
}
|