Merge pull request #992 from samcharles93/feat/865-dashboard-vocabulary
feat(webui): serve change statuses and the config schema through /api/task-meta
This commit is contained in:
commit
5e6c3fa3d3
12 files changed
+352
-73
No files matched your search
@@ -210,6 +210,12 @@
|
||||
"section": "PRDs",
|
||||
"body": "# Dashboard port: what the agent delivers\n\n**Status:** Approved\n**Date:** 2026-09-20\n**Beads:** `archie-core-tavn` (epic), `archie-core-ocfm` (navigation)\n**Reads with:** `docs/prds/vue-migration-checklist.md` (the item-by-item),\n`docs/prds/dashboard-navigation-groups.md` (the approved nav design)\n\nThis is the standard the port is held to. The checklist says what to port; this\nsays how, and what counts as done. It exists because the first attempt ported\nthe flat topbar verbatim and invented a palette, both of which had already been\ndecided elsewhere.\n\n## The deliverable\n\nThe Preact dashboard, rebuilt in Vue 3 with shadcn-vue, feature complete\nagainst the checklist, gate clean, with `ui/dist` rebuilt and committed in the\nsame commit as the source it was built from.\n\n## Non-negotiables\n\n- **Vue 3 + shadcn-vue (Reka UI, Tailwind v4, Lucide).** A component that\n exists in shadcn-vue is not hand-rolled. Add it with the CLI\n (`npx shadcn-vue@latest add \u003cname\u003e`), do not paste it in.\n- **History routing.** `createWebHistory`, `base: \"/\"`. No hash routing.\n `src/legacy-hash-redirect.ts` handles old `#/path` links and stays.\n- **No test port.** 43 Preact test files are deliberately dropped.\n `task test:ui` is a `vue-tsc` typecheck. Write a test when there is a real\n failure to pin, not to re-assert a port.\n- **Do not downgrade TypeScript.** The target is TS 7 native, not TS 5.\n- **`ui/dist` is law.** Never hand-edit it, never omit it, never revert it.\n- **`task check` is the gate.** Not an assembled substitute for it.\n- **Beads, not markdown TODOs**, for anything that outlives the change.\n- **Conventional commits**, scoped `feat(webui):`. Commit gate-clean work\n without asking. Do not push without being told.\n\n## Componentisation\n\nOne component, one job, one file. A surface is composed from named components,\nnot assembled inside a single large file. The topbar is the worked example and\nthe required shape:\n\n```\ncomponents/topbar/\n Topbar.vue composes the header, owns nothing else\n Brand.vue Logo + BrandName, links to /\n Logo.vue\n BrandName.vue\n Nav.vue reads the nav model, renders links and groups\n NavTrigger.vue the shared top-level control, link or dropdown trigger\n NavGroup.vue one dropdown\n NavItem.vue one item inside a dropdown, with its tooltip\n SearchBar.vue\n SupportLink.vue\n ThemeToggle.vue\n ProfileDropdown.vue\n```\n\nThe same rule applies to every page ported after it. If a file is doing the\nwork of four named things, it is four files. Data and behaviour that more than\none component needs lives in `src/lib/`, not passed down through a chain of\nprops.\n\n## Ordering\n\nBuild the navigation restructure during the port, not after it. Porting the\nflat eleven-item bar first and restructuring later means writing the topbar\ntwice and touching the Go route registry twice. The approved design is five\ntop-level items (Dashboard, Work, Agent, Events, System), items renamed because\ntheir group carries the context, per-item descriptions shown as hover tooltips,\nConfiguration split into `/system/*`, `/settings` kept as a redirect, and Logs\nfinally given a nav entry.\n\n## Design authority\n\n- The approved documents win. Where a document decides something, implement it\n rather than re-deciding it.\n- **Do not invent a visual direction.** Palette, typography and density are the\n maintainer's call. A palette change is its own request, never a side effect\n of a port.\n- Contrast is AA against every surface the foreground lands on, hover states\n included. The corrected values (`--fg-subtle`, the dark\n `--primary-foreground`) came from a measured failure and must survive.\n- `color-scheme` follows the theme so the UA paints controls, scrollbars and\n overscroll to match.\n\n## Code style\n\nComment the non-obvious why: an invariant, a trap, a measurement, a contract\nanother file depends on. Do not narrate what the code plainly does, do not\nexplain a choice that was never in question, and do not write migration phase\nhistory into a diff. That history belongs in the commit message.\n\n## Done, per surface\n\n1. Renders with real data against `task dev`, not just typechecks.\n2. Keyboard reachable, focus visible, and the nav announces where you are.\n3. Works at 1440x900 and at 720px wide, with nothing clipped and no horizontal\n page scroll.\n4. Empty, loading, failed and unconfigured (501) states all say something true.\n A section that cannot load says so; it does not render blank.\n5. `task check` passes, `ui/dist` rebuilt, committed together.\n"
|
||||
},
|
||||
{
|
||||
"url": "/dev/prds/dashboard-vocabulary/",
|
||||
"title": "One source for the dashboard's server vocabularies",
|
||||
"section": "PRDs",
|
||||
"body": "# One source for the dashboard's server vocabularies\n\n**Status:** Finalised\n\n## Problem\n\nThe dashboard kept its own copies of two vocabularies the daemon owns:\n\n- the changed-file statuses (`added`, `modified`, `deleted`, `renamed`,\n `typechange`), which are the `Change*` constants in\n `internal/domain/workflow/task`;\n- the schema stamp on a `config_captured` payload, `events.ConfigCapturedSchema`.\n\nNothing derived one side from the other, while `/api/task-meta` already served\nthe status and action vocabularies for exactly this reason.\n\n## Decision\n\n`GET /api/task-meta` also serves `change_statuses` (id and label) and\n`config_schema`. `buildTaskMeta` in `internal/webui/api_task_meta.go` takes the\nids from the `Change*` constants and the stamp from `events.ConfigCapturedSchema`.\n\nThe dashboard renders `ui/src/lib/task-meta-snapshot.ts` until the served\ncatalog arrives, or when archied is unreachable. `loadTaskMeta` replaces only\nthe keys the payload carries, so a server without the new keys leaves the\nsnapshot in place. `changeStatusLabel` and `configSchema` in\n`ui/src/lib/task-meta.ts` are the only readers; an unknown status renders as\nits id.\n\n## Verification\n\n- `TestTaskMetaPayloadMatchesFixture` requires the handler to serve\n `internal/webui/testdata/task_meta.json` byte for byte. Regenerate it with\n `go test ./internal/webui -run TestTaskMetaPayloadMatchesFixture -update`.\n- `ui/test/task-meta-snapshot.test.ts` requires the snapshot to equal that\n fixture.\n- `TestTaskMetaChangeStatusesAreDeliberate` fails when a `Change*` constant is\n added without a label.\n\nA rename on one side therefore fails a test on the other.\n\n## Rejected\n\nDeleting `/api/task-meta` and accepting hand-copied constants. The endpoint is\nlive, and deleting it would still leave the two copies this document removes.\n"
|
||||
},
|
||||
{
|
||||
"url": "/dev/prds/deep-research-capability/",
|
||||
"title": "Deep research capability — design",
|
||||
@@ -324,6 +330,12 @@
|
||||
"section": "PRDs",
|
||||
"body": "# Operator-triggered PR review\n\n**Status:** Draft\n**Beads issue:** `archie-core-h019.8`\n\nThis PRD reuses the adversarial-self-review contract\n(`docs/prds/adversarial-self-review.md`) and the `workflow.Reviewer` /\n`workflow.ReviewReport` types from `internal/domain/workflow`. It decides\nonly what is new: how an operator asks for a review of an *existing* PR, and\nhow that PR's content reaches the reviewer.\n\n## Problem\n\nThe adversarial reviewer (`StageReview`) runs automatically before `StageOpenPR`\nand reviews the task's own worktree HEAD. There is no way to review a PR that\nalready exists: one archie opened, a human opened, or one whose findings the\noperator wants re-checked after a push.\n\n## Shape\n\nOne channel-neutral command — `review_pr` — accepts a repository and PR number\nand returns the structured `ReviewReport`. The Web UI chat and Telegram invoke\nthe same command; neither duplicates review behaviour. The reviewer model is\n`models.reviewer` (falling back to `models.builder`), already the rule the\nworkflow stage uses, so an operator configures it independently of\nplanner/builder.\n\n## Decisions\n\n1. **Forge read.** `GetPullRequest(owner, repo, number)` returns a\n forge-neutral `PullRequest{Number, Title, Body, HeadRef, BaseRef, HeadSHA,\n BaseSHA, State}`. Declared as a narrow `PullRequestReader` interface,\n implemented by GitHub and Gitea; the noop forge does not implement it, so\n the composition root type-asserts and refuses review with \"forge does not support PR\n review\". Adding to the fat `Forge` interface would churn every test fake for\n a capability the noop forge cannot honestly provide.\n\n2. **Materialisation.** `worktree.Manager.CheckoutPR(owner, repo, headRef,\n baseRef)` clones the repository fully and checks out `origin/\u003cheadRef\u003e`.\n `Diff(dir, baseRef)` and `Snapshot(dir, destDir)` then work unchanged:\n `Diff` resolves `origin/\u003cbaseRef\u003e` via the existing `resolveBase`, and\n `Snapshot` strips `.git` exactly as the workflow stage does. The head must\n already be pushed to the same repository — archie's own PRs always are; a\n cross-repo or deleted head is refused with that reason, not half-reviewed.\n\n3. **Reviewer reuse.** `agentworker.NewOperatorReviewer(models, providers)`\n builds the same `subagentReviewer` the stage uses, from daemon-level config\n rather than a `taskrun.Request`. It drops only the `Repo.ReviewEnabled`\n gate (the operator asked explicitly) and the task-run scaffolding.\n\n4. **Command.** A gateway tool `review_pr` (toolset `tasks`) bound to the\n channel's identity at construction — the model never names an identity,\n matching `task_spawn`/`task_action`. The Gateway process serves it: it\n composes the worktree manager it needs to materialise the PR head, and the\n composition root supplies `ChatPRReviewer`, a narrow gateway interface\n whose adapter maps `workflow.ReviewReport` into a gateway-owned result\n shape (gateway states what it needs, the composition root adapts — the\n `ChatTaskActor` pattern).\n\n5. **Authorization.** Identity-scoped repository allow-list, the\n `task_spawn` rule: a chat identity may only review a repo in its\n `TaskProfile.Repos`. `identity == nil` denotes an authenticated dashboard\n operator who may review any configured repository.\n\n6. **Determinism.** One review per (owner, repo, number) at a time: the\n Gateway holds an in-flight set; a concurrent request for the same PR returns\n \"review already in progress\" rather than launching a second reviewer and\n racing on the snapshot.\n\n## Files\n\n- `internal/forge/forge.go`, `github.go`, `gitea.go` — `PullRequest`,\n `PullRequestReader`, `GetPullRequest`.\n- `internal/worktree/worktree.go` — `CheckoutPR`.\n- `internal/app/agentworker/review.go` — `NewOperatorReviewer`.\n- `internal/gateway/review_tools.go` — `ChatPRReviewer`, result shape, `review_pr`.\n- `internal/gateway/turn.go`, `gateway.go` — tool wiring into the turn.\n- `internal/app/archied/pr_review.go` — the `ChatPRReviewer` adapter.\n- `internal/app/archied/{bootstrap.go,gateway.go,main.go}` — composition.\n\n## Not in scope\n\n- Surfacing findings on the PR body or the dashboard (h019.6).\n- Reviewer model per-invocation override: configuration via `models.reviewer`\n is the selection surface; a per-call override is a later knob.\n"
|
||||
},
|
||||
{
|
||||
"url": "/dev/prds/orgs-and-access/",
|
||||
"title": "Orgs, workspaces and access control",
|
||||
"section": "PRDs",
|
||||
"body": "# Orgs, workspaces and access control\n\n**Status:** Approved\n**Date:** 2026-09-24\n**Parent:** `docs/prds/event-automation.md`, epic `archie-core-t2db`\n\n## Why this exists\n\nArchie has no tenant boundary and no access control: one operator, one shared\ntoken, and no org on any record. The event automation design needs orgs to own\nsources, bindings, workflows and agents, and an agent's reach must be decided\nby the policies over it, never by the event that started it.\n\n## Concepts\n\n- **Org.** The tenant boundary. An instance admin creates an org and adds its\n first owner. An owner or admin adds further members by the sign-in\n provider's subject or email.\n- **Workspace.** A division of an org, named freely (`networking-prd`,\n `service-desk-dev`), with an optional `environment` attribute (any string)\n that policies can test. Sources, event types, mappings, bindings and runs\n belong to a workspace.\n- **Identity.** Every principal is an identity (`internal/domain/identity`):\n - a person is an identity of kind `user`, bound to the sign-in provider\n through the existing subject binding;\n - an agent is an identity of kind `bot` or `service_account`, assigned to\n one org and granted access, secrets and permissions the way a user is.\n\n Signing in and verifying credentials stay separate from identity; identity\n is who acts. Memberships, roles, grants and audit records all reference the\n identity ID.\n- **Instance admin.** Operates the installation: orgs, the sign-in provider,\n instance policies. Instance admins see an org's resources only as members\n of it.\n\n## What belongs where\n\n| Level | Owns |\n|---|---|\n| Instance | the shipped workflow catalogue, instance policies |\n| Org | members, identities and their grants, secrets, agent profiles, workspaces, org workflows and their enabled state |\n| Workspace | sources, event types, mappings, bindings, runs, captures, run events and logs, chat sessions, memory |\n\nEvery owned record carries its `org_id`, and workspace records also carry their\n`workspace_id`. An identity, secret or profile is used in a workspace only\nafter the org grants it to that workspace.\n\nA secret is granted to an identity. An agent profile holds the container\nimage, tools and network access, and no secrets; this supersedes the secret\nreferences in `event-automation.md`'s agent profiles.\n\nA workflow names the identity it runs as. A workflow called by another runs\nas its own identity, and the caller's identity must be permitted `run` on it.\n\n## Access decisions\n\n### Where it lives\n\n- `internal/domain/access` owns the policy schema, the action list, how\n principals and resources are turned into policy entities, and the\n `Authorizer` contract.\n- The Cedar implementation, using `github.com/cedar-policy/cedar-go`, lives in\n `internal/infrastructure/access`; `internal/app` wires it.\n- Exactly two places call the `Authorizer`: the dashboard and API request\n path, and dispatch. Every other service verifies a credential and never\n evaluates policy.\n\n### The model\n\n- **Principal:** an identity, with its memberships, roles and grants.\n- **Resource:** the record acted on, with its workspace and org as parents,\n its type, owner and state.\n- **Action:** one of `read`, `create`, `update`, `delete`, `approve`, `run`,\n `read_logs`, `read_secret`, `manage_members`, `manage_identities`,\n `manage_policies`.\n- **Context:** the event's signature result, the address it came from, the\n time, and the run and step when the principal is an agent.\n\n### The policy chain\n\n```\ninstance (+ network rules) ─▶ org ─▶ workspace ─▶ identity + workflow ─▶ object\n```\n\n- **Instance** policies hold across every org. They include network rules:\n which addresses may deliver events to any source on the instance.\n- **Object** policies attach to one object (an event source, a secret, an\n identity, a binding, a workflow): \"only `soc-responder` may read this\n secret\", \"this source accepts events only from 10.20.0.0/16\".\n- A request is allowed only if every level with policies for it permits it. A\n lower level narrows and never widens; a forbid at any level wins; with no\n permit the request is denied.\n- The shipped role policies mean the org level always has policies, so an\n object or workspace policy alone can never grant access.\n- Archie ships an instance policy, which no org can remove, forbidding any\n principal to act on a resource outside the orgs it belongs to.\n\n### Storing and changing policies\n\n- Policies are stored in the State Store per level, versioned, and every\n change is an audit event naming who made it.\n- A policy is checked against the current schema when it is saved, and every\n stored policy is checked again when archie starts. An invalid org, workspace\n or object policy makes its level deny everything and is reported as a health\n issue naming the policy and the errLine truncated
|
||||
},
|
||||
{
|
||||
"url": "/dev/prds/payload-field-mapping/",
|
||||
"title": "Payload field mapping -- decision",
|
||||
@@ -597,6 +609,10 @@
|
||||
"title": "Dashboard port: what the agent delivers",
|
||||
"url": "/dev/prds/dashboard-port-brief/"
|
||||
},
|
||||
{
|
||||
"title": "One source for the dashboard's server vocabularies",
|
||||
"url": "/dev/prds/dashboard-vocabulary/"
|
||||
},
|
||||
{
|
||||
"title": "Deep research capability — design",
|
||||
"url": "/dev/prds/deep-research-capability/"
|
||||
@@ -673,6 +689,10 @@
|
||||
"title": "Operator-triggered PR review",
|
||||
"url": "/dev/prds/operator-pr-review/"
|
||||
},
|
||||
{
|
||||
"title": "Orgs, workspaces and access control",
|
||||
"url": "/dev/prds/orgs-and-access/"
|
||||
},
|
||||
{
|
||||
"title": "Payload field mapping -- decision",
|
||||
"url": "/dev/prds/payload-field-mapping/"
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# One source for the dashboard's server vocabularies
|
||||
|
||||
**Status:** Finalised
|
||||
|
||||
## Problem
|
||||
|
||||
The dashboard kept its own copies of two vocabularies the daemon owns:
|
||||
|
||||
- the changed-file statuses (`added`, `modified`, `deleted`, `renamed`,
|
||||
`typechange`), which are the `Change*` constants in
|
||||
`internal/domain/workflow/task`;
|
||||
- the schema stamp on a `config_captured` payload, `events.ConfigCapturedSchema`.
|
||||
|
||||
Nothing derived one side from the other, while `/api/task-meta` already served
|
||||
the status and action vocabularies for exactly this reason.
|
||||
|
||||
## Decision
|
||||
|
||||
`GET /api/task-meta` also serves `change_statuses` (id and label) and
|
||||
`config_schema`. `buildTaskMeta` in `internal/webui/api_task_meta.go` takes the
|
||||
ids from the `Change*` constants and the stamp from `events.ConfigCapturedSchema`.
|
||||
|
||||
The dashboard renders `ui/src/lib/task-meta-snapshot.ts` until the served
|
||||
catalog arrives, or when archied is unreachable. `loadTaskMeta` replaces only
|
||||
the keys the payload carries, so a server without the new keys leaves the
|
||||
snapshot in place. `changeStatusLabel` and `configSchema` in
|
||||
`ui/src/lib/task-meta.ts` are the only readers; an unknown status renders as
|
||||
its id.
|
||||
|
||||
## Verification
|
||||
|
||||
- `TestTaskMetaPayloadMatchesFixture` requires the handler to serve
|
||||
`internal/webui/testdata/task_meta.json` byte for byte. Regenerate it with
|
||||
`go test ./internal/webui -run TestTaskMetaPayloadMatchesFixture -update`.
|
||||
- `ui/test/task-meta-snapshot.test.ts` requires the snapshot to equal that
|
||||
fixture.
|
||||
- `TestTaskMetaChangeStatusesAreDeliberate` fails when a `Change*` constant is
|
||||
added without a label.
|
||||
|
||||
A rename on one side therefore fails a test on the other.
|
||||
|
||||
## Rejected
|
||||
|
||||
Deleting `/api/task-meta` and accepting hand-copied constants. The endpoint is
|
||||
live, and deleting it would still leave the two copies this document removes.
|
||||
@@ -3,17 +3,53 @@ package webui
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
"github.com/samcharles93/archie-core/internal/events"
|
||||
"github.com/samcharles93/archie-core/internal/taskstate"
|
||||
)
|
||||
|
||||
// handleTaskMeta serves the lifecycle presentation catalog: the status
|
||||
// vocabulary (with label, pill severity, "needs you" grouping) and the operator
|
||||
// action controls (with label, button variant, confirm prompt). Everything the
|
||||
// dashboard can present is derived here, so the frontend never has to keep a
|
||||
// hand-synced copy of the vocabulary or the control set.
|
||||
// changeStatusMeta describes how to present one changes_captured status value.
|
||||
// The IDs are the producer's own constants (internal/domain/workflow/task), so
|
||||
// the dashboard never spells them out and a rename reaches the browser instead
|
||||
// of turning every row into a raw status code.
|
||||
type changeStatusMeta struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
// taskMetaView is the whole GET /api/task-meta payload. It is served as one
|
||||
// struct rather than an inline map so the wire shape is declared in one place
|
||||
// and pinned against the dashboard's freeze-dried snapshot by a fixture test.
|
||||
type taskMetaView struct {
|
||||
Statuses []taskstate.StatusMeta `json:"statuses"`
|
||||
Actions []taskstate.ActionMeta `json:"actions"`
|
||||
ChangeStatuses []changeStatusMeta `json:"change_statuses"`
|
||||
ConfigSchema string `json:"config_schema"`
|
||||
}
|
||||
|
||||
// buildTaskMeta derives the lifecycle presentation catalog: the status
|
||||
// vocabulary (with label, pill severity, "needs you" grouping), the operator
|
||||
// action controls (with label, button variant, confirm prompt), the
|
||||
// changes_captured status labels and the schema stamp a config_captured
|
||||
// payload carries. Everything the dashboard can present that also exists on
|
||||
// the server is derived here, so the frontend never has to keep a hand-synced
|
||||
// copy of the vocabulary or the control set.
|
||||
func buildTaskMeta() taskMetaView {
|
||||
return taskMetaView{
|
||||
Statuses: taskstate.Statuses(),
|
||||
Actions: taskstate.ActionCatalog(),
|
||||
ChangeStatuses: []changeStatusMeta{
|
||||
{ID: task.ChangeAdded, Label: "Added"},
|
||||
{ID: task.ChangeModified, Label: "Modified"},
|
||||
{ID: task.ChangeDeleted, Label: "Deleted"},
|
||||
{ID: task.ChangeRenamed, Label: "Renamed"},
|
||||
{ID: task.ChangeTypeChanged, Label: "Type changed"},
|
||||
},
|
||||
ConfigSchema: events.ConfigCapturedSchema,
|
||||
}
|
||||
}
|
||||
|
||||
// handleTaskMeta serves the catalog. See buildTaskMeta for what it carries.
|
||||
func (s *Server) handleTaskMeta(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, map[string]any{
|
||||
"statuses": taskstate.Statuses(),
|
||||
"actions": taskstate.ActionCatalog(),
|
||||
})
|
||||
writeJSON(w, buildTaskMeta())
|
||||
}
|
||||
@@ -1,12 +1,24 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
)
|
||||
|
||||
// updateTaskMetaFixture rewrites the committed payload fixture from the served
|
||||
// handler. It is the same generated-artifact discipline the repo already uses
|
||||
// for docs/data/generated/contracts.json (task docs:generate): the fixture is
|
||||
// committed, the gate checks rather than regenerates, and the -update run is
|
||||
// what blesses a deliberate vocabulary change.
|
||||
var updateTaskMetaFixture = flag.Bool("update", false, "rewrite testdata/task_meta.json from the served /api/task-meta payload")
|
||||
|
||||
// The dashboard derives everything it can present from /api/task-meta. If the
|
||||
// catalog is empty or malformed the frontend falls back to its own defaults and
|
||||
// the whole point of the endpoint -- one server-held vocabulary -- is lost.
|
||||
@@ -33,6 +45,11 @@ func TestTaskMetaCatalog(t *testing.T) {
|
||||
Kind string `json:"kind"`
|
||||
Confirm string `json:"confirm"`
|
||||
} `json:"actions"`
|
||||
ChangeStatuses []struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
} `json:"change_statuses"`
|
||||
ConfigSchema string `json:"config_schema"`
|
||||
}
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
@@ -44,6 +61,12 @@ func TestTaskMetaCatalog(t *testing.T) {
|
||||
if len(got.Actions) == 0 {
|
||||
t.Error("actions empty")
|
||||
}
|
||||
if len(got.ChangeStatuses) == 0 {
|
||||
t.Error("change_statuses empty; the dashboard renders raw status codes without it")
|
||||
}
|
||||
if got.ConfigSchema == "" {
|
||||
t.Error("config_schema empty; the config panel would call every capture an unknown schema")
|
||||
}
|
||||
for _, s := range got.Statuses {
|
||||
if s.ID == "" || s.Label == "" {
|
||||
t.Errorf("status missing id/label: %+v", s)
|
||||
@@ -54,4 +77,86 @@ func TestTaskMetaCatalog(t *testing.T) {
|
||||
t.Errorf("action missing id/label: %+v", a)
|
||||
}
|
||||
}
|
||||
for _, cs := range got.ChangeStatuses {
|
||||
if cs.ID == "" || cs.Label == "" {
|
||||
t.Errorf("change status missing id/label: %+v", cs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestTaskMetaChangeStatusesAreDeliberate pins the catalog's change-status IDs
|
||||
// to the producer's constants, in order, each with a distinct label. It is the
|
||||
// same guard config_schema_test.go applies to the config catalog: a sixth
|
||||
// Change* constant added without a label fails here rather than reaching the
|
||||
// dashboard as a raw status code.
|
||||
func TestTaskMetaChangeStatusesAreDeliberate(t *testing.T) {
|
||||
want := []string{
|
||||
task.ChangeAdded,
|
||||
task.ChangeModified,
|
||||
task.ChangeDeleted,
|
||||
task.ChangeRenamed,
|
||||
task.ChangeTypeChanged,
|
||||
}
|
||||
got := buildTaskMeta().ChangeStatuses
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("change_statuses has %d entries, want %d (one per Change* constant)", len(got), len(want))
|
||||
}
|
||||
labels := make(map[string]string, len(got))
|
||||
for i, cs := range got {
|
||||
if cs.ID != want[i] {
|
||||
t.Errorf("change_statuses[%d].id = %q, want %q", i, cs.ID, want[i])
|
||||
}
|
||||
if cs.Label == "" {
|
||||
t.Errorf("change status %q has no label", cs.ID)
|
||||
continue
|
||||
}
|
||||
if prev, dup := labels[cs.Label]; dup {
|
||||
t.Errorf("change statuses %q and %q share the label %q", prev, cs.ID, cs.Label)
|
||||
}
|
||||
labels[cs.Label] = cs.ID
|
||||
}
|
||||
}
|
||||
|
||||
// TestTaskMetaPayloadMatchesFixture pins the served payload byte-for-byte
|
||||
// against the committed fixture, and the fixture against the dashboard's
|
||||
// freeze-dried snapshot (ui/src/base/task-meta.jsx) via
|
||||
// ui/test/task-meta-catalogue.test.js. Between the two, a one-sided rename of a
|
||||
// status label, an action, a change status or the config schema fails a test on
|
||||
// whichever side was not updated -- the property neither per-side literal test
|
||||
// could provide.
|
||||
//
|
||||
// Regenerate with:
|
||||
//
|
||||
// go test ./internal/webui -run TestTaskMetaPayloadMatchesFixture -update
|
||||
func TestTaskMetaPayloadMatchesFixture(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/task-meta", nil)
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body %s", w.Code, w.Body)
|
||||
}
|
||||
served := w.Body.Bytes()
|
||||
|
||||
const fixture = "testdata/task_meta.json"
|
||||
if *updateTaskMetaFixture {
|
||||
if err := os.MkdirAll("testdata", 0o755); err != nil {
|
||||
t.Fatalf("mkdir testdata: %v", err)
|
||||
}
|
||||
if err := os.WriteFile(fixture, served, 0o644); err != nil {
|
||||
t.Fatalf("write fixture: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
committed, err := os.ReadFile(fixture)
|
||||
if err != nil {
|
||||
t.Fatalf("read %s: %v\nrun: go test ./internal/webui -run TestTaskMetaPayloadMatchesFixture -update", fixture, err)
|
||||
}
|
||||
if !bytes.Equal(served, committed) {
|
||||
t.Errorf("GET /api/task-meta no longer matches %s.\n"+
|
||||
"The fixture pins the dashboard's freeze-dried snapshot (ui/src/base/task-meta.jsx);\n"+
|
||||
"ui/test/task-meta-catalogue.test.js fails until both sides agree.\n"+
|
||||
"regenerate with: go test ./internal/webui -run TestTaskMetaPayloadMatchesFixture -update", fixture)
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"statuses":[{"id":"queued","label":"Queued","kind":"idle","needs_you":false},{"id":"running","label":"Working","kind":"info","needs_you":false},{"id":"waiting_human","label":"Waiting for you","kind":"warn","needs_you":true},{"id":"pr_open","label":"In review","kind":"ok","needs_you":false},{"id":"merged","label":"Merged","kind":"ok","needs_you":false},{"id":"parked","label":"Parked","kind":"warn","needs_you":true},{"id":"dead","label":"Stopped (too many retries)","kind":"danger","needs_you":false},{"id":"rejected","label":"Rejected","kind":"danger","needs_you":false},{"id":"closed_wont_do","label":"Won't do","kind":"idle","needs_you":false}],"actions":[{"id":"cancel","label":"Cancel","kind":"quiet","confirm":"Cancel \"{title}\"? This closes the forge issue."},{"id":"stop","label":"Stop","kind":"primary","confirm":"Stop \"{title}\"? Recoverable work will remain parked."},{"id":"approve","label":"Approve","kind":"primary","confirm":""},{"id":"reject","label":"Reject","kind":"quiet","confirm":"Reject \"{title}\"? This closes the forge issue."},{"id":"retry","label":"Retry","kind":"primary","confirm":""},{"id":"abandon","label":"Abandon","kind":"quiet","confirm":"Abandon \"{title}\"? This closes the forge issue."},{"id":"archive","label":"Archive","kind":"quiet","confirm":"Archive the local record for \"{title}\"?"},{"id":"open_pr","label":"Open PR","kind":"link","confirm":""},{"id":"open_issue","label":"Open issue","kind":"link","confirm":""}],"change_statuses":[{"id":"added","label":"Added"},{"id":"modified","label":"Modified"},{"id":"deleted","label":"Deleted"},{"id":"renamed","label":"Renamed"},{"id":"typechange","label":"Type changed"}],"config_schema":"archie/task-config@1"}
|
||||
Vendored
+1
-1
@@ -16,4 +16,4 @@ Defaulting to \`null\`.`),null)}function Ex(e){return wx(e)&&!Number.isNaN(e)&&e
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:rT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>rT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=aT(c),u=e+1<n.length?aT(n[e+1]):null;if(l&&u&&oT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=aT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>rT(e)),rows:r.map(e=>e.map(e=>rT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:rT(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:rT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function aT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function oT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var sT={class:`[overflow-wrap:anywhere]`},cT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},lT={class:`font-mono text-[0.85em]`},uT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},dT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},fT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},pT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},mT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},hT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},gT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},_T={key:8,class:`mb-2.5 last:mb-0`},vT=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>iT(t.text));return(e,t)=>(L(),R(`div`,sT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,cT,[B(`code`,lT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,uT,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(tT,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(tT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,dT,[V(tT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,fT,[V(tT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,pT,[V(tT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,mT,[V(tT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(tT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,gT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(tT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,_T,[V(tT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),yT={class:`truncate`},bT=N({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[V(A(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,yT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),xT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},ST={class:`font-semibold text-foreground`},CT={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},wT=N({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(bT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,xT,[V(A(qd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,ST,O(n.value),1),r.value?(L(),R(`code`,CT,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),TT={key:0,class:`mb-2 grid gap-0.5 text-xs`},ET={key:2,class:`whitespace-pre-wrap`},DT=N({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:D([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:D(A(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,TT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(wT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(vT,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,ET,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),OT={class:`w-full self-center justify-self-center py-6 text-center`},kT={class:`grid gap-2`},AT=[`onClick`],jT=N({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),R(`div`,OT,[t[0]||=B(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tA?`${n.slice(0,tA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var rA=[`title`],iA=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>Ok(n.event)),a=G(()=>nA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?yO(n.event.at):`—`);return(e,t)=>(L(),z(A(Qk),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,rA)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function aA(e,t){return`${e}:${t??0}`}function oA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=aA(nA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var sA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},cA={class:`max-h-[28rem] overflow-y-auto`},lA=[`aria-expanded`,`aria-label`,`onClick`],uA=[`title`],dA=N({__name:`LiveActivityCard`,setup(e){let t=eE(),{activity:n,streamKind:r,streamState:i}=ad(tk()),a=nn(new Set),o=G(()=>oA(n.value));function s(e){a.has(e)?a.delete(e):a.add(e)}function c(e){return a.has(e.key)}function l(e){return nA(e.representative)}function u(e){return e.representative.at?yO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(dO),null,{default:j(()=>[V(A(gO),null,{default:j(()=>[V(A(_O),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(fO),null,{default:j(()=>[V(A(ZD),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(pO),null,{default:j(()=>[B(`div`,sA,[B(`div`,cA,[V(A(Xk),null,{default:j(()=>[V(A(eA),{class:`sticky top-0 z-10 bg-card`},{default:j(()=>[V(A(Qk),null,{default:j(()=>[V(A($k),null,{default:j(()=>[...t[1]||=[H(`Event`,-1)]]),_:1}),V(A($k),null,{default:j(()=>[...t[2]||=[H(`Task`,-1)]]),_:1}),V(A($k),null,{default:j(()=>[...t[3]||=[H(`Detail`,-1)]]),_:1}),V(A($k),null,{default:j(()=>[...t[4]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(Zk),null,{default:j(()=>[A(n).length?U(``,!0):(L(),z(A(Qk),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(UD),null,{default:j(()=>[V(A(KD),null,{default:j(()=>[V(A(YD),null,{default:j(()=>[...t[5]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),A(n).length?(L(!0),R(I,{key:1},P(o.value,e=>(L(),R(I,{key:e.key},[e.count===1?(L(),z(iA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(L(),R(I,{key:1},[V(A(Qk),{class:D(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&d(e.taskID),onKeydown:[du(lu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),du(lu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[B(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":c(e),"aria-label":`${c(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:lu(t=>s(e.key),[`stop`])},[c(e)?(L(),z(A(xd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(L(),z(A(Cd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),H(` `+O(e.label)+` `,1),V(A(ZD),{variant:`idle`},{default:j(()=>[H(`×`+O(e.count),1)]),_:2},1024)],8,lA)]),_:2},1024),V(A($),{class:`font-mono`},{default:j(()=>[H(O(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},O(l(e).text),9,uA)]),_:2},1024),V(A($),null,{default:j(()=>[H(O(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(L(!0),R(I,{key:0},P(e.events,(t,n)=>(L(),z(iA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):U(``,!0)],64))],64))),128)):U(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),fA=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=$S(t,`class`);return(e,r)=>(L(),z(A(Dx),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Ox),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`tLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tA?`${n.slice(0,tA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var rA=[`title`],iA=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>Ok(n.event)),a=G(()=>nA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?yO(n.event.at):`—`);return(e,t)=>(L(),z(A(Qk),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,rA)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function aA(e,t){return`${e}:${t??0}`}function oA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=aA(nA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var sA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},cA={class:`max-h-[28rem] overflow-y-auto`},lA=[`aria-expanded`,`aria-label`,`onClick`],uA=[`title`],dA=N({__name:`LiveActivityCard`,setup(e){let t=eE(),{activity:n,streamKind:r,streamState:i}=ad(tk()),a=nn(new Set),o=G(()=>oA(n.value));function s(e){a.has(e)?a.delete(e):a.add(e)}function c(e){return a.has(e.key)}function l(e){return nA(e.representative)}function u(e){return e.representative.at?yO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(dO),null,{default:j(()=>[V(A(gO),null,{default:j(()=>[V(A(_O),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(fO),null,{default:j(()=>[V(A(ZD),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(pO),null,{default:j(()=>[B(`div`,sA,[B(`div`,cA,[V(A(Xk),null,{default:j(()=>[V(A(eA),{class:`sticky top-0 z-10 bg-card`},{default:j(()=>[V(A(Qk),null,{default:j(()=>[V(A($k),null,{default:j(()=>[...t[1]||=[H(`Event`,-1)]]),_:1}),V(A($k),null,{default:j(()=>[...t[2]||=[H(`Task`,-1)]]),_:1}),V(A($k),null,{default:j(()=>[...t[3]||=[H(`Detail`,-1)]]),_:1}),V(A($k),null,{default:j(()=>[...t[4]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(Zk),null,{default:j(()=>[A(n).length?U(``,!0):(L(),z(A(Qk),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(UD),null,{default:j(()=>[V(A(KD),null,{default:j(()=>[V(A(YD),null,{default:j(()=>[...t[5]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),A(n).length?(L(!0),R(I,{key:1},P(o.value,e=>(L(),R(I,{key:e.key},[e.count===1?(L(),z(iA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(L(),R(I,{key:1},[V(A(Qk),{class:D(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&d(e.taskID),onKeydown:[du(lu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),du(lu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[B(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":c(e),"aria-label":`${c(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:lu(t=>s(e.key),[`stop`])},[c(e)?(L(),z(A(xd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(L(),z(A(Cd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),H(` `+O(e.label)+` `,1),V(A(ZD),{variant:`idle`},{default:j(()=>[H(`×`+O(e.count),1)]),_:2},1024)],8,lA)]),_:2},1024),V(A($),{class:`font-mono`},{default:j(()=>[H(O(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},O(l(e).text),9,uA)]),_:2},1024),V(A($),null,{default:j(()=>[H(O(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(L(!0),R(I,{key:0},P(e.events,(t,n)=>(L(),z(iA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):U(``,!0)],64))],64))),128)):U(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),fA=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=$S(t,`class`);return(e,r)=>(L(),z(A(Dx),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Ox),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`tLine truncated
|
||||
@@ -0,0 +1,61 @@
|
||||
// The freeze-dried /api/task-meta catalog the dashboard renders before the
|
||||
// served one arrives, or when archied is unreachable. It has no imports so the
|
||||
// node test runner can compare it against the Go handler's committed fixture
|
||||
// (internal/webui/testdata/task_meta.json); task-meta.ts replaces it with the
|
||||
// live catalog.
|
||||
|
||||
/** A lifecycle status as the server describes it. */
|
||||
export interface StatusMeta {
|
||||
id: string;
|
||||
label: string;
|
||||
kind: string;
|
||||
needs_you?: boolean;
|
||||
}
|
||||
|
||||
/** An operator control as the server describes it. */
|
||||
export interface ActionMeta {
|
||||
id: string;
|
||||
label: string;
|
||||
kind: string;
|
||||
confirm?: string;
|
||||
}
|
||||
|
||||
/** A changes_captured file status as the server describes it. */
|
||||
export interface ChangeStatusMeta {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export const DEFAULT_STATUSES: StatusMeta[] = [
|
||||
{ id: "queued", label: "Queued", kind: "idle" },
|
||||
{ id: "running", label: "Working", kind: "info" },
|
||||
{ id: "waiting_human", label: "Waiting for you", kind: "warn", needs_you: true },
|
||||
{ id: "pr_open", label: "In review", kind: "ok" },
|
||||
{ id: "merged", label: "Merged", kind: "ok" },
|
||||
{ id: "parked", label: "Parked", kind: "warn", needs_you: true },
|
||||
{ id: "dead", label: "Stopped (too many retries)", kind: "danger" },
|
||||
{ id: "rejected", label: "Rejected", kind: "danger" },
|
||||
{ id: "closed_wont_do", label: "Won't do", kind: "idle" },
|
||||
];
|
||||
|
||||
export const DEFAULT_ACTIONS: ActionMeta[] = [
|
||||
{ id: "cancel", label: "Cancel", kind: "quiet", confirm: `Cancel "{title}"? This closes the forge issue.` },
|
||||
{ id: "stop", label: "Stop", kind: "primary", confirm: `Stop "{title}"? Recoverable work will remain parked.` },
|
||||
{ id: "approve", label: "Approve", kind: "primary" },
|
||||
{ id: "reject", label: "Reject", kind: "quiet", confirm: `Reject "{title}"? This closes the forge issue.` },
|
||||
{ id: "retry", label: "Retry", kind: "primary" },
|
||||
{ id: "abandon", label: "Abandon", kind: "quiet", confirm: `Abandon "{title}"? This closes the forge issue.` },
|
||||
{ id: "archive", label: "Archive", kind: "quiet", confirm: `Archive the local record for "{title}"?` },
|
||||
{ id: "open_pr", label: "Open PR", kind: "link" },
|
||||
{ id: "open_issue", label: "Open issue", kind: "link" },
|
||||
];
|
||||
|
||||
export const DEFAULT_CHANGE_STATUSES: ChangeStatusMeta[] = [
|
||||
{ id: "added", label: "Added" },
|
||||
{ id: "modified", label: "Modified" },
|
||||
{ id: "deleted", label: "Deleted" },
|
||||
{ id: "renamed", label: "Renamed" },
|
||||
{ id: "typechange", label: "Type changed" },
|
||||
];
|
||||
|
||||
export const DEFAULT_CONFIG_SCHEMA = "archie/task-config@1";
|
||||
+34
-39
@@ -22,59 +22,41 @@ import { computed, shallowRef } from "vue";
|
||||
|
||||
import { api } from "./api";
|
||||
|
||||
/** A lifecycle status as the server describes it. */
|
||||
export interface StatusMeta {
|
||||
id: string;
|
||||
label: string;
|
||||
kind: string;
|
||||
needs_you?: boolean;
|
||||
}
|
||||
import {
|
||||
type ActionMeta,
|
||||
type ChangeStatusMeta,
|
||||
DEFAULT_ACTIONS,
|
||||
DEFAULT_CHANGE_STATUSES,
|
||||
DEFAULT_CONFIG_SCHEMA,
|
||||
DEFAULT_STATUSES,
|
||||
type StatusMeta,
|
||||
} from "./task-meta-snapshot";
|
||||
|
||||
/** An operator control as the server describes it. */
|
||||
export interface ActionMeta {
|
||||
id: string;
|
||||
label: string;
|
||||
kind: string;
|
||||
confirm?: string;
|
||||
}
|
||||
|
||||
const DEFAULT_STATUSES: StatusMeta[] = [
|
||||
{ id: "queued", label: "Queued", kind: "idle" },
|
||||
{ id: "running", label: "Working", kind: "info" },
|
||||
{ id: "waiting_human", label: "Waiting for you", kind: "warn", needs_you: true },
|
||||
{ id: "pr_open", label: "In review", kind: "ok" },
|
||||
{ id: "merged", label: "Merged", kind: "ok" },
|
||||
{ id: "parked", label: "Parked", kind: "warn", needs_you: true },
|
||||
{ id: "dead", label: "Stopped (too many retries)", kind: "danger" },
|
||||
{ id: "rejected", label: "Rejected", kind: "danger" },
|
||||
{ id: "closed_wont_do", label: "Won't do", kind: "idle" },
|
||||
];
|
||||
|
||||
const DEFAULT_ACTIONS: ActionMeta[] = [
|
||||
{ id: "cancel", label: "Cancel", kind: "quiet", confirm: `Cancel "{title}"? This closes the forge issue.` },
|
||||
{ id: "stop", label: "Stop", kind: "primary", confirm: `Stop "{title}"? Recoverable work will remain parked.` },
|
||||
{ id: "approve", label: "Approve", kind: "primary" },
|
||||
{ id: "reject", label: "Reject", kind: "quiet", confirm: `Reject "{title}"? This closes the forge issue.` },
|
||||
{ id: "retry", label: "Retry", kind: "primary" },
|
||||
{ id: "abandon", label: "Abandon", kind: "quiet", confirm: `Abandon "{title}"? This closes the forge issue.` },
|
||||
{ id: "archive", label: "Archive", kind: "quiet", confirm: `Archive the local record for "{title}"?` },
|
||||
{ id: "open_pr", label: "Open PR", kind: "link" },
|
||||
{ id: "open_issue", label: "Open issue", kind: "link" },
|
||||
];
|
||||
export type { ActionMeta, ChangeStatusMeta, StatusMeta };
|
||||
|
||||
const statuses = shallowRef<StatusMeta[]>([...DEFAULT_STATUSES]);
|
||||
const actions = shallowRef<ActionMeta[]>([...DEFAULT_ACTIONS]);
|
||||
const changeStatuses = shallowRef<ChangeStatusMeta[]>([...DEFAULT_CHANGE_STATUSES]);
|
||||
const configSchemaRef = shallowRef<string>(DEFAULT_CONFIG_SCHEMA);
|
||||
|
||||
const statusById = computed(() => new Map(statuses.value.map((s) => [s.id, s])));
|
||||
const actionById = computed(() => new Map(actions.value.map((a) => [a.id, a])));
|
||||
const changeStatusById = computed(() => new Map(changeStatuses.value.map((c) => [c.id, c])));
|
||||
|
||||
// loadTaskMeta upgrades the dashboard from the server catalog. It never throws:
|
||||
// a failed fetch keeps the defaults so the UI still renders.
|
||||
export async function loadTaskMeta(): Promise<void> {
|
||||
try {
|
||||
const data = await api.taskMeta<{ statuses?: StatusMeta[]; actions?: ActionMeta[] } | null>();
|
||||
const data = await api.taskMeta<{
|
||||
statuses?: StatusMeta[];
|
||||
actions?: ActionMeta[];
|
||||
change_statuses?: ChangeStatusMeta[];
|
||||
config_schema?: string;
|
||||
} | null>();
|
||||
if (Array.isArray(data?.statuses)) statuses.value = data.statuses;
|
||||
if (Array.isArray(data?.actions)) actions.value = data.actions;
|
||||
if (Array.isArray(data?.change_statuses)) changeStatuses.value = data.change_statuses;
|
||||
if (data?.config_schema) configSchemaRef.value = data.config_schema;
|
||||
} catch {
|
||||
// archied unreachable or not yet serving this route; keep the defaults.
|
||||
}
|
||||
@@ -115,3 +97,16 @@ export function attentionStatusIds(): Set<string> {
|
||||
export function actionFor(id: string): ActionMeta | null {
|
||||
return actionById.value.get(id) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* changeStatusLabel names a changes_captured file status. An id the catalog
|
||||
* does not know renders as itself rather than breaking the row.
|
||||
*/
|
||||
export function changeStatusLabel(id: string | undefined): string {
|
||||
return (id && changeStatusById.value.get(id)?.label) || id || "unknown";
|
||||
}
|
||||
|
||||
/** configSchema is the schema stamp a recognised config_captured payload carries. */
|
||||
export function configSchema(): string {
|
||||
return configSchemaRef.value;
|
||||
}
|
||||
@@ -2,11 +2,12 @@
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { configSchema } from "@/lib/task-meta";
|
||||
|
||||
import JsonBlock from "./JsonBlock.vue";
|
||||
import PanelError from "./PanelError.vue";
|
||||
import PanelLoading from "./PanelLoading.vue";
|
||||
import { CONFIG_SCHEMA, selectConfigEvent } from "./attempt-config";
|
||||
import { selectConfigEvent } from "./attempt-config";
|
||||
import type { TaskEvent } from "./task-run";
|
||||
|
||||
/**
|
||||
@@ -28,7 +29,7 @@ const schema = computed(() => {
|
||||
return typeof data.schema === "string" ? data.schema : "";
|
||||
});
|
||||
const document = computed(() => event.value?.data?.document ?? {});
|
||||
const recognised = computed(() => schema.value === CONFIG_SCHEMA);
|
||||
const recognised = computed(() => schema.value === configSchema());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
*/
|
||||
import type { TaskEvent } from "./task-run";
|
||||
|
||||
// The schema name is owned by the daemon (events.ConfigCapturedSchema in
|
||||
// internal/events/events.go). A payload in an unrecognised schema is shown
|
||||
// verbatim with a note rather than reinterpreted, so a server-side bump
|
||||
// degrades to the raw view instead of rendering something wrong.
|
||||
export const CONFIG_SCHEMA = "archie/task-config@1";
|
||||
|
||||
export function selectConfigEvent(
|
||||
events: TaskEvent[] | null | undefined,
|
||||
attempt: number | null,
|
||||
|
||||
@@ -9,22 +9,9 @@
|
||||
*/
|
||||
import type { Capture, CaptureTotals, TaskRecord } from "./task-run";
|
||||
|
||||
// The change-status ids are a wire vocabulary owned by the daemon
|
||||
// (internal/domain/workflow/task/changes.go). Only the words are the
|
||||
// dashboard's: an id added on the server renders as its raw id rather than
|
||||
// breaking the row. The old test suite pinned the id set on both sides so a
|
||||
// one-sided rename failed instead of drifting.
|
||||
const FILE_STATUS: Record<string, string> = {
|
||||
added: "Added",
|
||||
modified: "Modified",
|
||||
deleted: "Deleted",
|
||||
renamed: "Renamed",
|
||||
typechange: "Type changed",
|
||||
};
|
||||
|
||||
export function fileStatusLabel(status: string | undefined): string {
|
||||
return (status && FILE_STATUS[status]) || status || "unknown";
|
||||
}
|
||||
// The change-status labels are served with the rest of the task vocabulary
|
||||
// (/api/task-meta), keyed by the daemon's own Change* constants.
|
||||
export { changeStatusLabel as fileStatusLabel } from "@/lib/task-meta";
|
||||
|
||||
/**
|
||||
* The forge links come from the same projection the task list uses: the task's
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const snapshot = await import("../src/lib/task-meta-snapshot.ts");
|
||||
|
||||
// internal/webui/testdata/task_meta.json is the served /api/task-meta payload,
|
||||
// pinned byte-for-byte by TestTaskMetaPayloadMatchesFixture. Comparing the
|
||||
// first-paint snapshot against it means a one-sided rename of any vocabulary
|
||||
// fails on whichever side was not updated.
|
||||
const fixture = JSON.parse(
|
||||
await readFile(new URL("../../internal/webui/testdata/task_meta.json", import.meta.url), "utf8"),
|
||||
);
|
||||
|
||||
// The server emits an unset optional field (needs_you, confirm) as its zero
|
||||
// value; the snapshot omits it.
|
||||
const dropZero = (rows: Record<string, unknown>[]) =>
|
||||
rows.map((row) => Object.fromEntries(Object.entries(row).filter(([, v]) => v !== false && v !== "")));
|
||||
|
||||
test("the status snapshot matches the served catalog", () => {
|
||||
assert.deepEqual(snapshot.DEFAULT_STATUSES, dropZero(fixture.statuses));
|
||||
});
|
||||
|
||||
test("the action snapshot matches the served catalog", () => {
|
||||
assert.deepEqual(snapshot.DEFAULT_ACTIONS, dropZero(fixture.actions));
|
||||
});
|
||||
|
||||
test("the change-status snapshot matches the served catalog", () => {
|
||||
assert.deepEqual(snapshot.DEFAULT_CHANGE_STATUSES, fixture.change_statuses);
|
||||
});
|
||||
|
||||
test("the config schema snapshot matches the served catalog", () => {
|
||||
assert.equal(snapshot.DEFAULT_CONFIG_SCHEMA, fixture.config_schema);
|
||||
});
|
||||
Reference in new issue
Block a user