* fix(ui): make the served lifecycle vocabulary actually load
base/task-meta.jsx documents the backend as the source of truth: /api/task-meta
returns the statuses (label, pill severity, "needs you") and the operator
actions, and loadTaskMeta() replaces the freeze-dried defaults with that
catalog. Nothing called it. Every pill, status filter and action control read
the snapshot, so a catalogue change on the server never reached the browser --
the module's first paragraph was simply not true.
main.jsx now asks for the catalog once at boot, alongside the capabilities read
it already does for the same reason: the shell paints immediately and upgrades a
moment later.
The two vocabularies the dashboard mirrors rather than serves -- FILE_STATUS
(ids owned by internal/domain/workflow/task/changes.go) and CONFIG_SCHEMA
(events.ConfigCapturedSchema) -- are now documented as the deliberate second
tier, with their two-sided pins named, so the tree stops telling two stories
about where a vocabulary comes from. Both degrade to a raw id or the verbatim
payload rather than rendering something wrong, which is why mirroring is
tolerable there and not for a presentation catalog.
RED before (loader never called):
x booting the dashboard replaces the freeze-dried vocabulary with the served catalog
actual: 'custom_status', expected: 'Custom status'
Also repairs a drifted LAW asset. A fresh build of pristine main dirties both
ui/dist/assets/index.css and index.js: 04d4d8f1 (#889, memory unification slice
5) changed ui/src without rebuilding ui/dist, and task check runs task ui --
which repairs dist instead of verifying it -- so a stale dist is invisible to
the gate. Rebuilding here restores the invariant; a dist-freshness gate is filed
as follow-up.
* fix(ui,gateway): restore the search focus the port dropped, and the page registry truth
An adversarial review of the port (278b7fc6) found three things worth acting on.
1. Topbar search -- a regression the port introduced. The el() version focused
the input when the narrow-layout toggle opened it, and blurred it after a
successful jump; the port kept neither. That layout hides the field with
width:0/pointer-events:none until .is-open or :focus-within, so without
focus() the caret was not in the field the operator had just opened, and
without blur() :focus-within left it expanded across the topbar after the
jump. Both calls are back, with the ref they need.
2. dashboard_tools.go advertised a page that does not exist and omitted two that
do. The registry calls itself "the single source of truth for what the
dashboard exposes", but it is a hand-copy of the route table in
ui/src/main.jsx: /memory stayed after the page was deleted (that deletion
also left ui/dist stale -- archie-core-1vhh), and /bindings and /curators
were never added. So the agent could hand the operator a chip to a route that
now falls back to the dashboard, and could not answer "where do I go for
playbook bindings?".
3. TestDashboardPagesRegistryCoversEveryRoute did not test that. It asserted
three hardcoded paths and passed while the registry listed a deleted page. It
now reads the route table back out of ui/src/main.jsx and compares in both
directions, which is what makes the registry's claim holdable. RED before:
route "/bindings" is a dashboard page the registry does not list, so the agent cannot point at it
route "/curators" is a dashboard page the registry does not list, so the agent cannot point at it
registry lists "/memory" (Memory), which is not a dashboard route: the agent would send the operator somewhere that does not exist
Also deletes the dead .chat-page rules the deleted chatPage() bridge left
behind: nothing renders .chat-page any more (chat.jsx renders
.chat-page-content, and the drawer sizes it from layout.css).
Not changed: the unreachable `soon` path, which predates the port and was
reported rather than acted on.
* fix(build): verify ui/dist is fresh instead of never looking at it
ui/dist is committed because the Go build embeds it, so it is a generated
source file. Nothing in the gate read it: task check does not run task ui, and
nothing else compares the bundle with ui/src. So when 04d4d8f1 (#889) changed
ui/src without rebuilding, the committed bundle went on serving the Memory page
whose source had been deleted -- with the gate green throughout.
task ui:check (tools/uidist.sh) rebuilds into a temporary directory and compares,
never rewriting the committed artifact. That is the rule docs:check already
states for the contract reference -- a gate that silently rewrote the artifact
would bless an unintended change with no reviewer ever seeing it -- and it
matters more now that several agents work in their own worktrees, where each
could otherwise pass while producing a different bundle.
Evidence:
fresh tree exit 0, matches
hand-staled bundle exit 1, names the differing file
the #889 drift replayed exit 1, names BOTH index.css and index.js
(pre-#889 bundle, post-#889 sources)
git status after a run unchanged: the check never writes ui/dist
Cost: ui:check declares ui:deps like ui and test:ui do, so the gate runs npm
install once per dependent. Task's sources/generates up-to-date check does not
apply to a node_modules directory (measured: it ran on every invocation), so the
target does not claim otherwise; guarding that is follow-up work.
Gate: task check exit 0, UI suite 230/230, all Go packages ok.
* fix(ui): make the served vocabulary reach an already-painted page
Greptile's finding on the first cut of this fix, and it was right: loadTaskMeta()
resolves after a page has painted and only mutated module state. The route tree
renders into its own root, so App re-rendering cannot reach it, and a painted
page kept the freeze-dried labels it read on the way up.
show() is split so the page render can be repeated on its own: renderRoute()
mounts the current route into the outlet without the teardown/chrome side
effects, and the catalog effect calls it once the catalog lands. The key is
unchanged, so Preact re-renders the mounted page in place and keeps its state.
Deeper instance of the same defect, found while fixing that one:
task-filters.jsx captured the vocabulary in module-level constants at import
(ATTENTION_STATUSES/TASK_STATUSES), so the task filter could never see a served
status, no matter when or how correctly the catalog landed. Both are read at
call time now.
Tests, and what they actually cover:
- the task-filter test has teeth: with the source fix stashed it fails, with
the fix it passes.
- task-meta-late-catalog.test.js guards the boot fetch end to end (it fails
when loadTaskMeta is never called), but it does NOT isolate the re-render:
a page also re-renders for its own reasons, so the assertion holds without
renderRoute too. Said plainly here rather than implied as coverage -- the
fix makes the re-render deterministic instead of incidental, and this
harness cannot tell those apart.
- it lives in its own file because main.jsx boots once per process; a second
test in the same file would assert against a detached tree.
UI suite 232/232, task check exit 0.
119 lines
5.3 KiB
Go
119 lines
5.3 KiB
Go
package gateway
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/samcharles93/archie-core/internal/tools"
|
|
)
|
|
|
|
// DashboardPage describes one dashboard surface so the chat agent can both
|
|
// understand what each place is for and point the operator there.
|
|
type DashboardPage struct {
|
|
// Path is the route (e.g. "/tasks"). It is what the browser hash becomes.
|
|
Path string
|
|
// Label is the human name shown in navigation (e.g. "Tasks").
|
|
Label string
|
|
// Description is a one-line plain-language explanation of what the page
|
|
// shows, so the agent can answer "where do I go for that?" correctly.
|
|
Description string
|
|
}
|
|
|
|
// dashboardPages is the single source of truth for what the dashboard exposes.
|
|
// It is deliberately a package-level registry rather than a per-router field:
|
|
// the same pages are shown regardless of identity, and the prompt's current
|
|
// page line and the dashboard_navigate tool both draw from it, so the agent
|
|
// never points at a page it was not told about.
|
|
var dashboardPages = []DashboardPage{
|
|
{Path: "/", Label: "Dashboard", Description: "The control room: what Archie is working on, what needs you, and token spend."},
|
|
{Path: "/chat", Label: "Chat", Description: "Conversations with Archie and the web chat session tools."},
|
|
{Path: "/tasks", Label: "Tasks", Description: "Issues Archie has picked up and where they stand: the work queue."},
|
|
{Path: "/logs", Label: "Logs", Description: "The daemon log stream, filterable by level and component."},
|
|
{Path: "/captures", Label: "Event inspector", Description: "Captured inbound events for inspection."},
|
|
{Path: "/mappings", Label: "Field mappings", Description: "How inbound event fields map onto internal ones."},
|
|
{Path: "/bindings", Label: "Playbook bindings", Description: "How captured events are bound to the workflows they start."},
|
|
{Path: "/skills", Label: "Skills", Description: "The SKILL.md capabilities Archie can activate."},
|
|
{Path: "/workflows", Label: "Workflows", Description: "The routed workflows (bootstrap, implement, tdd, feasibility) and their run history."},
|
|
{Path: "/curators", Label: "Curators", Description: "The scheduled passes that curate Archie's memory and captures."},
|
|
{Path: "/channels", Label: "Channels", Description: "Inbound chat and notification channels (e.g. Telegram) and their state."},
|
|
{Path: "/settings", Label: "Configuration", Description: "Daemon configuration editable from the dashboard."},
|
|
}
|
|
|
|
// DashboardPages returns a copy of the dashboard page registry.
|
|
func DashboardPages() []DashboardPage {
|
|
out := make([]DashboardPage, len(dashboardPages))
|
|
copy(out, dashboardPages)
|
|
return out
|
|
}
|
|
|
|
// PageIndexResult is what page_index returns: the full list of dashboard pages
|
|
// and what each one shows, so the agent can answer where to go.
|
|
type PageIndexResult struct {
|
|
Pages []DashboardPage `json:"pages"`
|
|
}
|
|
|
|
// pageIndexTool returns the tool that lists every dashboard page. It is only
|
|
// registered for the web channel (see PageIndexTools), because pointing a
|
|
// non-web operator at an internal dashboard route is meaningless.
|
|
func pageIndexTool() (tools.ToolEntry, bool) {
|
|
entry := tools.ToolEntry{
|
|
Name: "page_index",
|
|
Toolset: "dashboard",
|
|
Description: "List every dashboard page and, in one line, what it shows. Use it to tell the operator where to go for something rather than guessing.",
|
|
Classification: tools.ClassIdempotent,
|
|
Handler: func(_ context.Context, _ map[string]any) (any, error) {
|
|
return PageIndexResult{Pages: DashboardPages()}, nil
|
|
},
|
|
}
|
|
return entry, true
|
|
}
|
|
|
|
// dashboardNavigateTool resolves a page path and returns the navigation the UI
|
|
// can follow. It validates against the registry and refuses an unknown route
|
|
// rather than guessing, so a chip is only ever produced for a real page.
|
|
func dashboardNavigateTool() (tools.ToolEntry, bool) {
|
|
entry := tools.ToolEntry{
|
|
Name: "dashboard_navigate",
|
|
Toolset: "dashboard",
|
|
Description: "Point the operator at a dashboard page. Pass the page path (e.g. /tasks). Returns the page to navigate to; the web chat renders it as a clickable chip. Never guess a path, look it up with page_index first.",
|
|
Classification: tools.ClassIdempotent,
|
|
Schema: tools.JSONSchema{
|
|
"type": "object",
|
|
"properties": map[string]any{
|
|
"path": map[string]any{
|
|
"type": "string",
|
|
"description": "The dashboard route to navigate to, e.g. /tasks. Must match a page_index entry.",
|
|
},
|
|
},
|
|
"required": []any{"path"},
|
|
},
|
|
Handler: func(_ context.Context, input map[string]any) (any, error) {
|
|
path := strings.TrimSpace(asString(input["path"]))
|
|
if path == "" {
|
|
return nil, errors.New("dashboard_navigate: path is required")
|
|
}
|
|
for _, p := range dashboardPages {
|
|
if p.Path == path {
|
|
return DashboardNavigateResult{Path: p.Path, Label: p.Label}, nil
|
|
}
|
|
}
|
|
return nil, fmt.Errorf("dashboard_navigate: unknown page %s", path)
|
|
},
|
|
}
|
|
return entry, true
|
|
}
|
|
|
|
// PageIndexTools returns the dashboard tools for a channel. Only the web UI
|
|
// has a dashboard (and only the web chat sends a Current page), so a non-web
|
|
// channel (e.g. telegram) gets none.
|
|
func PageIndexTools(channel string) []tools.ToolEntry {
|
|
if !strings.EqualFold(channel, "web") {
|
|
return nil
|
|
}
|
|
pageIndex, _ := pageIndexTool()
|
|
navigate, _ := dashboardNavigateTool()
|
|
return []tools.ToolEntry{pageIndex, navigate}
|
|
}
|