Extending the 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.
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
- A route file
web/dev/src/routes/_app.<name>.tsx(TanStack Router file routes). - Fetch with TanStack Query and the typed
api()client (src/api/client.ts); export the response type fromsrc/api/types.ts. - Use the shared components:
Card,Chip,StatCard,Drawer,Modal,Tabsfromcomponents/ui.tsx, andSelect,DatePicker,TimePickerfromcomponents/inputs.tsx— never the browser’s native<select>or date input. - Add it to the sidebar in
components/AppShell.tsx. - Deep-link state belongs in the URL (
validateSearch), so links like?tenant=7work.
make dev-web # Vite with hot reload on :8080/devmake web-typecheck # tscmake web-build # what the release embedsAdd a palette entry
web/dev/src/components/CommandPalette.tsx lists pages, Inspector tabs and actions; add yours to
the matching array so Ctrl+K can reach it.

