Merge branch 'main' into pg/foundation

This commit is contained in:
sam committed 2026-09-24 22:21:24 +10:00
commit 335fb4bb22
12 files changed
+344 -75

No files matched your search

+10
View File
@@ -264,6 +264,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",
@@ -695,6 +701,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/"
+45
View File
@@ -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.
+45 -9
View File
@@ -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())
}
+105
View File
@@ -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
View File
@@ -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":"completed","label":"Done","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"}
+2 -2
View File
@@ -16,5 +16,5 @@ Defaulting to \`null\`.`),null)}function Mx(e){return Ax(e)&&!Number.isNaN(e)&&e
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:lT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>lT(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=dT(c),u=e+1<n.length?dT(n[e+1]):null;if(l&&u&&fT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=dT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>lT(e)),rows:r.map(e=>e.map(e=>lT(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:lT(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:lT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function dT(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 fT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var pT={class:`[overflow-wrap:anywhere]`},mT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},hT={class:`font-mono text-[0.85em]`},gT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},_T={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},vT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},yT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},bT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},xT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},ST={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},CT={key:8,class:`mb-2.5 last:mb-0`},wT=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=W(()=>uT(t.text));return(e,t)=>(I(),L(`div`,pT,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(F,{key:t},[e.kind===`pre`?(I(),L(`pre`,mT,[z(`code`,hT,D(e.code),1)])):e.kind===`table`?(I(),L(`table`,gT,[z(`thead`,null,[z(`tr`,null,[(I(!0),L(F,null,N(e.head,(e,t)=>(I(),L(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[B(sT,{inline:e},null,8,[`inline`])]))),128))])]),z(`tbody`,null,[(I(!0),L(F,null,N(e.rows,(e,t)=>(I(),L(`tr`,{key:t},[(I(!0),L(F,null,N(e,(e,t)=>(I(),L(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[B(sT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(I(),L(`blockquote`,_T,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(I(),L(`h1`,vT,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(I(),L(`h2`,yT,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(I(),L(`h3`,bT,[B(sT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(I(),L(`ul`,xT,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(sT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(I(),L(`ol`,ST,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(sT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(I(),L(`p`,CT,[B(sT,{inline:e.inline},null,8,[`inline`])])):H(``,!0)],64))),128))]))}}),TT={class:`truncate`},ET=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ha(`RouterLink`);return I(),R(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:A(()=>[B(k(bd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),z(`span`,TT,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),DT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},OT={class:`font-semibold text-foreground`},kT={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},AT=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=W(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=W(()=>t.tool.parameters||t.tool.Parameters||``),i=W(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=W(()=>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?(I(),R(ET,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(I(),L(`div`,DT,[B(k($d),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),z(`span`,OT,D(n.value),1),r.value?(I(),L(`code`,kT,D(r.value),1)):H(``,!0),z(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),jT={key:0,class:`mb-2 grid gap-0.5 text-xs`},MT={key:2,class:`whitespace-pre-wrap`},NT=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),L(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[z(`div`,{class:E(k(q)(`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?(I(),L(`div`,jT,[(I(!0),L(F,null,N(e.tools,(t,n)=>(I(),R(AT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):H(``,!0),e.assistant?(I(),R(wT,{key:1,text:e.text},null,8,[`text`])):(I(),L(`div`,MT,D(e.text),1)),P(t.$slots,`default`)],2)],2))}}),PT={class:`w-full self-center justify-self-center py-6 text-center`},FT={class:`grid gap-2`},IT=[`onClick`],LT=M({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(I(),L(`div`,PT,[t[0]||=z(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>oA?`${n.slice(0,oA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var cA=[`title`],lA=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>Pk(n.event)),a=W(()=>sA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=W(()=>n.event.at?TO(n.event.at):`—`);return(e,t)=>(I(),R(k(iA),{class:E(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:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,cA)]),_:1}),B(k(Q),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function uA(e,t){return`${e}:${t??0}`}function dA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=uA(sA(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 fA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},pA={class:`max-h-[28rem] overflow-y-auto`},mA=[`aria-expanded`,`aria-label`,`onClick`],hA=[`title`],gA=M({__name:`LiveActivityCard`,setup(e){let t=oE(),{activity:n,streamKind:r,streamState:i}=od(sk()),a=rn(new Set),o=W(()=>dA(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 sA(e.representative)}function u(e){return e.representative.at?TO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(_O),null,{default:A(()=>[B(k(SO),null,{default:A(()=>[B(k(CO),null,{default:A(()=>[...t[0]||=[V(`Live activity`,-1)]]),_:1}),B(k(vO),null,{default:A(()=>[B(k(rO),{variant:k(r)},{default:A(()=>[V(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(yO),null,{default:A(()=>[z(`div`,fA,[z(`div`,pA,[B(k(nA),null,{default:A(()=>[B(k(aA),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[B(k(iA),null,{default:A(()=>[B(k($),null,{default:A(()=>[...t[1]||=[V(`Event`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[2]||=[V(`Task`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[3]||=[V(`Detail`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[4]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(rA),null,{default:A(()=>[k(n).length?H(``,!0):(I(),R(k(iA),{key:0},{default:A(()=>[B(k(Q),{colspan:`4`},{default:A(()=>[B(k(YD),null,{default:A(()=>[B(k(QD),null,{default:A(()=>[B(k(tO),null,{default:A(()=>[...t[5]||=[V(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),k(n).length?(I(!0),L(F,{key:1},N(o.value,e=>(I(),L(F,{key:e.key},[e.count===1?(I(),R(lA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(I(),L(F,{key:1},[B(k(iA),{class:E(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:[fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[z(`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:uu(t=>s(e.key),[`stop`])},[c(e)?(I(),R(k(Sd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(I(),R(k(wd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),V(` `+D(e.label)+` `,1),B(k(rO),{variant:`idle`},{default:A(()=>[V(`×`+D(e.count),1)]),_:2},1024)],8,mA)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},D(l(e).text),9,hA)]),_:2},1024),B(k(Q),null,{default:A(()=>[V(D(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(I(!0),L(F,{key:0},N(e.events,(t,n)=>(I(),R(lA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):H(``,!0)],64))],64))),128)):H(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),_A=M({__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=aC(t,`class`);return(e,r)=>(I(),R(k(Nx),U({"data-slot":`progress`},k(n),{class:k(q)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:A(()=>[B(k(Px),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ye(`transLine truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function Bj(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function Vj(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function Hj(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function Uj(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}function Wj(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function Gj(e){return(e?.repository??`required`)!==`none`}function Kj(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function qj(e,t){switch(t){case`string`:return e;case`number`:return e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):e;case`bool`:return e===`true`||e!==`false`&&e;default:try{return JSON.parse(e)}catch{return e}}}var Jj={pending_approval:`pending approval`,armed:`armed`},Yj={pending_approval:`warn`,armed:`ok`};function Xj(e){return e?Jj[e]??e:`unknown`}function Zj(e){return Yj[e??``]??`idle`}function Qj(){return{id:null,name:``,eventTypeId:``,mappingId:``,filter:``,workflow:``,owner:``,repo:``,repoParam:``,inputs:{}}}function $j(e,t){let n=t.find(t=>t.id===e.mapping_id);return{id:e.id,name:e.name,eventTypeId:n?.event_type_id||``,mappingId:e.mapping_id||``,filter:e.filter||``,workflow:e.workflow||``,owner:e.owner||``,repo:e.repo||``,repoParam:e.repo_param||``,inputs:Object.fromEntries(Object.entries(e.inputs??{}).map(([e,t])=>[e,{param:t.param??``,value:t.param?``:typeof t.value==`string`?t.value:JSON.stringify(t.value)}]))}}function eM(e,t,n){let r=t.find(t=>t.id===e.eventTypeId),i=n?.inputs??{},a={};for(let[t,n]of Object.entries(i)){let r=e.inputs[t];r?.param?a[t]={param:r.param}:r&&r.value!==``&&(a[t]={value:qj(r.value,n.type)})}let o=Gj(n);return{name:e.name,matcher:{source:r?.source||``},mapping_id:e.mappingId,filter:e.filter.trim(),workflow:e.workflow,owner:o&&!e.repoParam?e.owner:``,repo:o&&!e.repoParam?e.repo:``,repo_param:o?e.repoParam:``,inputs:a}}function tM(e){return e.repo_param?`from ${e.repo_param}`:e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`}function nM(e,t){return t.find(t=>t.id===e.mapping_id)?.event_type_id}var rM={class:`font-mono`},iM={class:`text-fg-muted`},aM={class:`grid grid-cols-2 items-start gap-3`},oM={class:`grid grid-cols-2 items-start gap-3`},sM=`__constant__`,cM=`__none__`,lM=M({__name:`BindingEditor`,props:Va({binding:{},mappings:{},eventTypes:{},workflows:{},saving:{type:Boolean},error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:Va([`save`],[`update:open`]),setup(e,{emit:t}){let n=e,r=lo(e,`open`),i=t,a=O(Qj());j(r,e=>{e&&(a.value=n.binding?$j(n.binding,n.mappings):Qj())},{immediate:!0});let o=W(()=>Wj(n.mappings,a.value.eventTypeId));j(()=>a.value.eventTypeId,()=>{o.value.some(e=>e.id===a.value.mappingId)||(a.value.mappingId=``)});let s=W(()=>n.workflows.find(e=>e.id===a.value.workflow)),c=W(()=>Object.entries(s.value?.inputs??{}).sort(([e],[t])=>e.localeCompare(t))),l=W(()=>n.mappings.find(e=>e.id===a.value.mappingId)?.fields??[]),u=W(()=>Kj(l.value,`string`));function d(e){return a.value.inputs[e]??={param:``,value:``},a.value.inputs[e]}function f(e){return d(e).param||sM}function p(e,t){d(e).param=t===sM?``:String(t)}let m=W({get:()=>a.value.repoParam||cM,set:e=>{a.value.repoParam=e===cM?``:e}}),h=W(()=>n.binding?`Edit binding`:`New binding`);return(e,t)=>(I(),R(k(Mj),{open:r.value,"onUpdate:open":t[10]||=e=>r.value=e},{default:A(()=>[B(k(Pj),{class:`max-h-[85vh] overflow-y-auto sm:max-w-lg`},{default:A(()=>[B(k(Lj),null,{default:A(()=>[B(k(Rj),null,{default:A(()=>[V(D(h.value),1)]),_:1}),B(k(Fj),null,{default:A(()=>[...t[11]||=[V(` A binding is not armed until it is approved, and editing one drops it back to pending approval. `,-1)]]),_:1})]),_:1}),z(`form`,{onSubmit:t[9]||=uu(e=>i(`save`,a.value),[`prevent`])},[B(k(IC),null,{default:A(()=>[B(k(PC),null,{default:A(()=>[B(k(RC),{for:`binding-name`},{default:A(()=>[...t[12]||=[V(`Name`,-1)]]),_:1}),B(k(LO),{id:`binding-name`,modelValue:a.value.name,"onUpdate:modelValue":t[0]||=e=>a.value.name=e},null,8,[`modelValue`])]),_:1}),B(k(PC),null,{default:A(()=>[B(k(RC),{for:`binding-event-type`},{default:A(()=>[...t[13]||=[V(`Event type`,-1)]]),_:1}),B(k(JS),{modelValue:a.value.eventTypeId,"onUpdate:modelValue":t[1]||=e=>a.value.eventTypeId=e},{default:A(()=>[B(k(CC),{id:`binding-event-type`,class:`w-full`},{default:A(()=>[B(k(wC),{placeholder:`Pick an event type`})]),_:1}),B(k(_C),null,{default:A(()=>[B(k(vC),null,{default:A(()=>[(I(!0),L(F,null,N(n Line truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>oA?`${n.slice(0,oA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var cA=[`title`],lA=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>Pk(n.event)),a=W(()=>sA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=W(()=>n.event.at?TO(n.event.at):`—`);return(e,t)=>(I(),R(k(iA),{class:E(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:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,cA)]),_:1}),B(k(Q),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function uA(e,t){return`${e}:${t??0}`}function dA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=uA(sA(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 fA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},pA={class:`max-h-[28rem] overflow-y-auto`},mA=[`aria-expanded`,`aria-label`,`onClick`],hA=[`title`],gA=M({__name:`LiveActivityCard`,setup(e){let t=oE(),{activity:n,streamKind:r,streamState:i}=od(sk()),a=rn(new Set),o=W(()=>dA(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 sA(e.representative)}function u(e){return e.representative.at?TO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(_O),null,{default:A(()=>[B(k(SO),null,{default:A(()=>[B(k(CO),null,{default:A(()=>[...t[0]||=[V(`Live activity`,-1)]]),_:1}),B(k(vO),null,{default:A(()=>[B(k(rO),{variant:k(r)},{default:A(()=>[V(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(yO),null,{default:A(()=>[z(`div`,fA,[z(`div`,pA,[B(k(nA),null,{default:A(()=>[B(k(aA),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[B(k(iA),null,{default:A(()=>[B(k($),null,{default:A(()=>[...t[1]||=[V(`Event`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[2]||=[V(`Task`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[3]||=[V(`Detail`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[4]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(rA),null,{default:A(()=>[k(n).length?H(``,!0):(I(),R(k(iA),{key:0},{default:A(()=>[B(k(Q),{colspan:`4`},{default:A(()=>[B(k(YD),null,{default:A(()=>[B(k(QD),null,{default:A(()=>[B(k(tO),null,{default:A(()=>[...t[5]||=[V(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),k(n).length?(I(!0),L(F,{key:1},N(o.value,e=>(I(),L(F,{key:e.key},[e.count===1?(I(),R(lA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(I(),L(F,{key:1},[B(k(iA),{class:E(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:[fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`enter`]),fu(uu(t=>e.taskID>0&&d(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[z(`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:uu(t=>s(e.key),[`stop`])},[c(e)?(I(),R(k(Sd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(I(),R(k(wd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),V(` `+D(e.label)+` `,1),B(k(rO),{variant:`idle`},{default:A(()=>[V(`×`+D(e.count),1)]),_:2},1024)],8,mA)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:l(e).truncated?l(e).full:void 0},D(l(e).text),9,hA)]),_:2},1024),B(k(Q),null,{default:A(()=>[V(D(u(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),c(e)?(I(!0),L(F,{key:0},N(e.events,(t,n)=>(I(),R(lA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):H(``,!0)],64))],64))),128)):H(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),_A=M({__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=aC(t,`class`);return(e,r)=>(I(),R(k(Nx),U({"data-slot":`progress`},k(n),{class:k(q)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:A(()=>[B(k(Px),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ye(`transLine truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function qj(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function Jj(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function Yj(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function Xj(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}function Zj(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function Qj(e){return(e?.repository??`required`)!==`none`}function $j(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function eM(e,t){switch(t){case`string`:return e;case`number`:return e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):e;case`bool`:return e===`true`||e!==`false`&&e;default:try{return JSON.parse(e)}catch{return e}}}var tM={pending_approval:`pending approval`,armed:`armed`},nM={pending_approval:`warn`,armed:`ok`};function rM(e){return e?tM[e]??e:`unknown`}function iM(e){return nM[e??``]??`idle`}function aM(){return{id:null,name:``,eventTypeId:``,mappingId:``,filter:``,workflow:``,owner:``,repo:``,repoParam:``,inputs:{}}}function oM(e,t){let n=t.find(t=>t.id===e.mapping_id);return{id:e.id,name:e.name,eventTypeId:n?.event_type_id||``,mappingId:e.mapping_id||``,filter:e.filter||``,workflow:e.workflow||``,owner:e.owner||``,repo:e.repo||``,repoParam:e.repo_param||``,inputs:Object.fromEntries(Object.entries(e.inputs??{}).map(([e,t])=>[e,{param:t.param??``,value:t.param?``:typeof t.value==`string`?t.value:JSON.stringify(t.value)}]))}}function sM(e,t,n){let r=t.find(t=>t.id===e.eventTypeId),i=n?.inputs??{},a={};for(let[t,n]of Object.entries(i)){let r=e.inputs[t];r?.param?a[t]={param:r.param}:r&&r.value!==``&&(a[t]={value:eM(r.value,n.type)})}let o=Qj(n);return{name:e.name,matcher:{source:r?.source||``},mapping_id:e.mappingId,filter:e.filter.trim(),workflow:e.workflow,owner:o&&!e.repoParam?e.owner:``,repo:o&&!e.repoParam?e.repo:``,repo_param:o?e.repoParam:``,inputs:a}}function cM(e){return e.repo_param?`from ${e.repo_param}`:e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`}function lM(e,t){return t.find(t=>t.id===e.mapping_id)?.event_type_id}var uM={class:`font-mono`},dM={class:`text-fg-muted`},fM={class:`grid grid-cols-2 items-start gap-3`},pM={class:`grid grid-cols-2 items-start gap-3`},mM=`__constant__`,hM=`__none__`,gM=M({__name:`BindingEditor`,props:Va({binding:{},mappings:{},eventTypes:{},workflows:{},saving:{type:Boolean},error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:Va([`save`],[`update:open`]),setup(e,{emit:t}){let n=e,r=lo(e,`open`),i=t,a=O(aM());j(r,e=>{e&&(a.value=n.binding?oM(n.binding,n.mappings):aM())},{immediate:!0});let o=W(()=>Zj(n.mappings,a.value.eventTypeId));j(()=>a.value.eventTypeId,()=>{o.value.some(e=>e.id===a.value.mappingId)||(a.value.mappingId=``)});let s=W(()=>n.workflows.find(e=>e.id===a.value.workflow)),c=W(()=>Object.entries(s.value?.inputs??{}).sort(([e],[t])=>e.localeCompare(t))),l=W(()=>n.mappings.find(e=>e.id===a.value.mappingId)?.fields??[]),u=W(()=>$j(l.value,`string`));function d(e){return a.value.inputs[e]??={param:``,value:``},a.value.inputs[e]}function f(e){return d(e).param||mM}function p(e,t){d(e).param=t===mM?``:String(t)}let m=W({get:()=>a.value.repoParam||hM,set:e=>{a.value.repoParam=e===hM?``:e}}),h=W(()=>n.binding?`Edit binding`:`New binding`);return(e,t)=>(I(),R(k(zj),{open:r.value,"onUpdate:open":t[10]||=e=>r.value=e},{default:A(()=>[B(k(Vj),{class:`max-h-[85vh] overflow-y-auto sm:max-w-lg`},{default:A(()=>[B(k(Wj),null,{default:A(()=>[B(k(Gj),null,{default:A(()=>[V(D(h.value),1)]),_:1}),B(k(Hj),null,{default:A(()=>[...t[11]||=[V(` A binding is not armed until it is approved, and editing one drops it back to pending approval. `,-1)]]),_:1})]),_:1}),z(`form`,{onSubmit:t[9]||=uu(e=>i(`save`,a.value),[`prevent`])},[B(k(IC),null,{default:A(()=>[B(k(PC),null,{default:A(()=>[B(k(RC),{for:`binding-name`},{default:A(()=>[...t[12]||=[V(`Name`,-1)]]),_:1}),B(k(LO),{id:`binding-name`,modelValue:a.value.name,"onUpdate:modelValue":t[0]||=e=>a.value.name=e},null,8,[`modelValue`])]),_:1}),B(k(PC),null,{default:A(()=>[B(k(RC),{for:`binding-event-type`},{default:A(()=>[...t[13]||=[V(`Event type`,-1)]]),_:1}),B(k(JS),{modelValue:a.value.eventTypeId,"onUpdate:modelValue":t[1]||=e=>a.value.eventTypeId=e},{default:A(()=>[B(k(CC),{id:`binding-event-type`,class:`w-full`},{default:A(()=>[B(k(wC),{placeholder:`Pick an event type`})]),_:1}),B(k(_C),null,{default:A(()=>[B(k(vC),null,{default:A(()=>[(I(!0),L(F,null,N(n Line truncated
+62
View File
@@ -0,0 +1,62 @@
// 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: "completed", label: "Done", 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 -40
View File
@@ -22,60 +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: "completed", label: "Done", 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.
}
@@ -116,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;
}
+3 -2
View File
@@ -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>
-6
View File
@@ -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,
+3 -16
View File
@@ -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
+34
View File
@@ -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);
});