Extending the dashboard
- API
- dev dashboard
Add a maintenance command
The Commands panel runs an allowlist — nothing else can run from the browser. Add an entry to
internal/app/dev_commands.go:
{ Name: "products:reindex", Label: "Reindex products", Group: "Maintenance", Description: "Rebuilds the product search index.", Confirm: true, // changes data → the UI asks first Background: true, // slow → returns at once; watch the run Timeout: 10 * time.Minute, Options: []dev.CommandOption{ {Name: "tenant", Label: "Tenant id", Type: "number", Description: "Empty = every tenant."}, {Name: "dry_run", Label: "Dry run", Type: "bool", Default: "true"}, }, Run: func(ctx context.Context, opts map[string]string, out io.Writer) error { count, err := p.Products.Reindex(ctx, opts["tenant"], opts["dry_run"] == "true") if err != nil { return err } fmt.Fprintf(out, "reindexed %d products\n", count) return nil },},- Option types:
bool,number,text,select(withChoices). - Write human-readable output to
out; it is stored with the run and shown in the panel. - Every run is audited (
command.run) with its options, status and duration. - Keep the CLI and the dashboard doing the same work: call the same service method from the Cobra command, and give both the same name (CLI commands).
Add a dashboard endpoint
- A service method in
internal/modules/dev(or call an existing module service). - A handler on
dev.Handler— it embeds the samehttpx.Kitas every module (h.Bind,h.PathID,h.Data). - The route in
internal/modules/dev/routes.go; mutations addr.With(h.manage)and record an audit entry withh.audit.Record(...). - Document it in
api/openapi.yaml, runmake openapiandmake openapi-check. - Refresh the SPA’s types:
npm --prefix web/dev run openapi:gen.
Add a panel
Every panel follows the same template, so a new one fits without a redesign:
- A route file
web/dev/src/routes/_app.<name>.tsx(TanStack Router file routes). - One entry in
web/dev/src/components/navigation.tswith its group, icon andgshortcut letter. The sidebar, the command palette, the shortcuts sheet and the top bar all read that list. - Fetch with TanStack Query and the typed
api()client (src/api/client.ts); export the response type fromsrc/api/types.ts. - Build the page from the kit in
components/ui.tsx:PageHeader(title, one-line description, actions, meta), then an optional filter row, then content inCards;StatTile,Badge,StatusDot,LiveDot(running work only),Drawer,Modal,Tabs,DetailStrip; layout withStack,Cluster,SplitandGrid. Charts come fromcomponents/charts.tsx(Recharts):DonutChartfor parts of a whole,HBarChartfor one bar per row,TimeBarsfor counts over time. Colour them with tones (series-1…series-6for categories, oraccent,ok,warn,danger,mutedfor a meaning), never a colour value; the figures always appear in text too (legend, readout or tooltip). UseSelect,DatePicker,TimePickerfromcomponents/inputs.tsx, never the browser’s native<select>or date input. - No inline
style={{…}}for layout and no raw colours: styles use the tokens insrc/styles/tokens.css, and a panel’s own rules go insrc/styles/screens/<name>.css. Inline styles are for data-driven values only (a bar’s width, a virtual row’s offset). - Deep-link state belongs in the URL (
validateSearch), so links like?tenant=7work. - Check it at
/dev/kitand on the page in both themes and at phone width.
make dev-web # Vite with hot reload on :8080/devmake web-typecheck # tscmake web-style-check # contrast, type scale, no raw coloursmake web-build # what the release embedsAdd a palette entry
Pages come from navigation.ts (above). web/dev/src/components/CommandPalette.tsx lists
Inspector tabs and actions; add yours to the matching array so Ctrl+K can reach it.

