fix(bindings): a new binding is created pending approval

Nothing moved a binding out of draft except an unrelated edit, so a newly created binding could not be approved and the dashboard showed no Approve button. Draft is removed; existing draft rows are promoted to pending_approval when the EDA store opens.
This commit is contained in:
sam committed 2026-09-23 23:13:49 +10:00
1 parent 528d6c4be2
commit 86690ef73e
15 files changed
+103 -109

No files matched your search

+9 -6
View File
@@ -24,7 +24,7 @@ type Binding struct {
MappingID // which Mapping resolves payload fields
Workflow // registered workflow name to dispatch to
Version // bumped on every edit
Status // draft | pending_approval | armed
Status // pending_approval | armed
Secret // HMAC-SHA256 shared secret, encrypted at rest, never returned by GET
}
```
@@ -59,18 +59,21 @@ binding currently says."
### State machine
```
draft ---> pending_approval ---> armed
^ ^ |
| | |
+--------------+-----------------+
create ---> pending_approval ---> armed
^ |
+----------------+
(any edit to an armed binding drops it back to pending_approval)
```
A binding is created `pending_approval`, so the operator who creates one can
approve it immediately. Bindings stored as `draft` by an earlier version are
moved to `pending_approval` when the EDA store opens.
Modeled directly on Telegram's existing `dangerousAction`/`pendingApproval`
flow (`internal/channels/telegram/dangerous.go`, `approval.go`) -- not a new
approval mechanism invented for this feature. **Only `armed` evaluates
against incoming events** (`binding.Matches`, `internal/domain/binding/
binding.go`); `draft` and `pending_approval` bindings are inert. An edit to
binding.go`); a `pending_approval` binding is inert. An edit to
an already-armed binding cannot bypass approval by silent mutation -- it
drops back to `pending_approval` and requires an explicit `Approve` call to
re-arm.
+1 -1
View File
@@ -22,7 +22,7 @@
"url": "/dev/architecture/bindings/",
"title": "Playbook bindings: model and threat model",
"section": "Architecture",
"body": "# Playbook bindings: model and threat model\n\n**Status:** Approved foundation (documents shipped code: `archie-core-t2db.1`\nthrough `.5`, `.7`, `.9`-`.15`)\n**Date:** 2026-09-03\n\nThis document covers the binding model and the intake threat model portion\nof `archie-core-t2db.6`. It does not cover the task-lifecycle provenance rule\n(`messaging-and-work-intake.md`'s \"Intake provenance\") or the operator\nwalkthrough -- that walkthrough remains an open piece of the same ticket.\n\n## What a binding is\n\nA `binding` (`internal/domain/binding.Binding`) ties four things together:\na **matcher** (which captured events it applies to), a **mapping**\n(`internal/domain/mapping.Mapping`, how fields are pulled out of a payload),\na **workflow** (which registered workflow runs on a match), and a **state\nmachine** governing whether it is live.\n\n```go\ntype Binding struct {\n ID, Name // identity\n Matcher // { Source string } -- the webhook path segment, e.g. \"sentry\"\n MappingID // which Mapping resolves payload fields\n Workflow // registered workflow name to dispatch to\n Version // bumped on every edit\n Status // draft | pending_approval | armed\n Secret // HMAC-SHA256 shared secret, encrypted at rest, never returned by GET\n}\n```\n\nBindings live in the store (SQLite), not `config.toml` -- operators author\nthem from the dashboard while the daemon runs, without a restart.\n\n### Matching\n\n`Matcher.Source` is the only predicate today: the path segment a sender\nPOSTs to (e.g. a webhook hitting `.../sentry` matches bindings with\n`Matcher.Source == \"sentry\"`). The storage column is plain `TEXT`, so adding\npredicates later is non-breaking -- extend `Matcher`, don't invent a second\nmatcher shape.\n\n### Mapping\n\n`mapping.Resolve(fields, payload)` walks a captured JSON payload against a\nlist of typed `Field`s (name, JSON path, expected type), returning resolved\nvalues plus a `[]Failure` for anything that didn't parse or type-match. This\nis schema-by-example in practice: a mapping is authored by pointing at a\nreal captured payload in the dashboard, not by guessing a schema in advance.\n\n### Versioning\n\n`Version` increments on every `UpdateBinding` call. This exists so an\neditor's later change can never silently rewrite the historical provenance\nof a task that already fired -- a dispatched task's binding reference is\npinned to the version that was armed when it fired, not \"whatever the\nbinding currently says.\"\n\n### State machine\n\n```\ndraft ---\u003e pending_approval ---\u003e armed\n ^ ^ |\n | | |\n +--------------+-----------------+\n (any edit to an armed binding drops it back to pending_approval)\n```\n\nModeled directly on Telegram's existing `dangerousAction`/`pendingApproval`\nflow (`internal/channels/telegram/dangerous.go`, `approval.go`) -- not a new\napproval mechanism invented for this feature. **Only `armed` evaluates\nagainst incoming events** (`binding.Matches`, `internal/domain/binding/\nbinding.go`); `draft` and `pending_approval` bindings are inert. An edit to\nan already-armed binding cannot bypass approval by silent mutation -- it\ndrops back to `pending_approval` and requires an explicit `Approve` call to\nre-arm.\n\n## The threat model\n\nThis is a public, unauthenticated-by-default intake surface whose output is\nan agent with a repo, a worktree, and tool access. The design brief\n(`archie-core-t2db.5`, `docs/prds/webhook-intake-security.md`) named five\nnon-negotiables; each is verified below against the actual shipped code,\nnot the design intent.\n\n### 1. Per-source authentication\n\nReuses `internal/channels/webhook`'s existing HMAC-SHA256 scheme --\ncapture accepts unsigned events (visible in the dashboard, marked\nunauthenticated), but **only authenticated events can ever match a\nbinding**. `binding.Matches`' doc comment states this plainly: \"an\nunauthenticated event can never trigger a binding, no matter how well it\nwould otherwise match.\" Enforced structurally at two points, not just\nconvention:\n\n- `captured_events.authenticated` is a real column (`internal/store/\n captures.go`), set at capture time.\n- `dispatchBindings` (`internal/daemon/daemon.go:479`) walks **authenticated\n captures whose source has at least one armed binding** -- an\n unauthenticated capture is never even considered for dispatch.\n\n### 2. Human approval before a binding goes live\n\nCovered by the state machine above. Nothing self-arms: `pending_approval -\u003e\narmed` requires an explicit `Approve` call, and any edit to an armed\nbinding reverts it.\n\n### 3. Rate and volume limits per source\n\nCapture writes are bounded independently of the approval gate, so a flood\nof unauthenticated traffic cannot exhaust disk or drown the inspector:\n`InsertCapture` (`internal/store/captures.go`) prunLine truncated
"body": "# Playbook bindings: model and threat model\n\n**Status:** Approved foundation (documents shipped code: `archie-core-t2db.1`\nthrough `.5`, `.7`, `.9`-`.15`)\n**Date:** 2026-09-03\n\nThis document covers the binding model and the intake threat model portion\nof `archie-core-t2db.6`. It does not cover the task-lifecycle provenance rule\n(`messaging-and-work-intake.md`'s \"Intake provenance\") or the operator\nwalkthrough -- that walkthrough remains an open piece of the same ticket.\n\n## What a binding is\n\nA `binding` (`internal/domain/binding.Binding`) ties four things together:\na **matcher** (which captured events it applies to), a **mapping**\n(`internal/domain/mapping.Mapping`, how fields are pulled out of a payload),\na **workflow** (which registered workflow runs on a match), and a **state\nmachine** governing whether it is live.\n\n```go\ntype Binding struct {\n ID, Name // identity\n Matcher // { Source string } -- the webhook path segment, e.g. \"sentry\"\n MappingID // which Mapping resolves payload fields\n Workflow // registered workflow name to dispatch to\n Version // bumped on every edit\n Status // pending_approval | armed\n Secret // HMAC-SHA256 shared secret, encrypted at rest, never returned by GET\n}\n```\n\nBindings live in the store (SQLite), not `config.toml` -- operators author\nthem from the dashboard while the daemon runs, without a restart.\n\n### Matching\n\n`Matcher.Source` is the only predicate today: the path segment a sender\nPOSTs to (e.g. a webhook hitting `.../sentry` matches bindings with\n`Matcher.Source == \"sentry\"`). The storage column is plain `TEXT`, so adding\npredicates later is non-breaking -- extend `Matcher`, don't invent a second\nmatcher shape.\n\n### Mapping\n\n`mapping.Resolve(fields, payload)` walks a captured JSON payload against a\nlist of typed `Field`s (name, JSON path, expected type), returning resolved\nvalues plus a `[]Failure` for anything that didn't parse or type-match. This\nis schema-by-example in practice: a mapping is authored by pointing at a\nreal captured payload in the dashboard, not by guessing a schema in advance.\n\n### Versioning\n\n`Version` increments on every `UpdateBinding` call. This exists so an\neditor's later change can never silently rewrite the historical provenance\nof a task that already fired -- a dispatched task's binding reference is\npinned to the version that was armed when it fired, not \"whatever the\nbinding currently says.\"\n\n### State machine\n\n```\ncreate ---\u003e pending_approval ---\u003e armed\n ^ |\n +----------------+\n (any edit to an armed binding drops it back to pending_approval)\n```\n\nA binding is created `pending_approval`, so the operator who creates one can\napprove it immediately. Bindings stored as `draft` by an earlier version are\nmoved to `pending_approval` when the EDA store opens.\n\nModeled directly on Telegram's existing `dangerousAction`/`pendingApproval`\nflow (`internal/channels/telegram/dangerous.go`, `approval.go`) -- not a new\napproval mechanism invented for this feature. **Only `armed` evaluates\nagainst incoming events** (`binding.Matches`, `internal/domain/binding/\nbinding.go`); a `pending_approval` binding is inert. An edit to\nan already-armed binding cannot bypass approval by silent mutation -- it\ndrops back to `pending_approval` and requires an explicit `Approve` call to\nre-arm.\n\n## The threat model\n\nThis is a public, unauthenticated-by-default intake surface whose output is\nan agent with a repo, a worktree, and tool access. The design brief\n(`archie-core-t2db.5`, `docs/prds/webhook-intake-security.md`) named five\nnon-negotiables; each is verified below against the actual shipped code,\nnot the design intent.\n\n### 1. Per-source authentication\n\nReuses `internal/channels/webhook`'s existing HMAC-SHA256 scheme --\ncapture accepts unsigned events (visible in the dashboard, marked\nunauthenticated), but **only authenticated events can ever match a\nbinding**. `binding.Matches`' doc comment states this plainly: \"an\nunauthenticated event can never trigger a binding, no matter how well it\nwould otherwise match.\" Enforced structurally at two points, not just\nconvention:\n\n- `captured_events.authenticated` is a real column (`internal/store/\n captures.go`), set at capture time.\n- `dispatchBindings` (`internal/daemon/daemon.go:479`) walks **authenticated\n captures whose source has at least one armed binding** -- an\n unauthenticated capture is never even considered for dispatch.\n\n### 2. Human approval before a binding goes live\n\nCovered by the state machine above. Nothing self-arms: `pending_approval -\u003e\narmed` requires an explicit `Approve` call, and any edit to an armed\nbinding reverts it.\n\n### 3. Rate and volume limits per source\n\nCapture writes are bounded independentlyLine truncated
},
{
"url": "/dev/architecture/configuration/",
+4 -22
View File
@@ -284,13 +284,10 @@ func seedMapping(t *testing.T, s *dispatchStores, sourceHint string, fields ...m
return id
}
// seedArmedBinding inserts a binding and walks it draft -> pending_approval
// -> armed, matching the operator flow an Approve button on the
// dashboard drives. InsertBinding forces status='draft' and the only
// sanctioned armed transition is ApproveBinding, so the helper
// advances through pending_approval via the store's test-only DB
// accessor -- production callers must use the structured methods
// (bindings.go) rather than touching the SQL directly.
// seedArmedBinding inserts a binding and approves it, matching the operator
// flow an Approve button on the dashboard drives: InsertBinding stores
// pending_approval and the only sanctioned armed transition is
// ApproveBinding.
func seedArmedBinding(t *testing.T, s *dispatchStores, source, mappingID string) (string, int) {
t.Helper()
return seedArmedBindingWithRepo(t, s, source, mappingID, "", "")
@@ -313,21 +310,6 @@ func seedArmedBindingWithRepo(t *testing.T, s *dispatchStores, source, mappingID
if err != nil {
t.Fatalf("InsertBinding: %v", err)
}
// Edit moves a draft to pending_approval through the real lifecycle,
// which is what makes it approvable. The old raw-SQL shortcut reached
// into a table the task store no longer owns.
if err := s.EdaStore.UpdateBinding(t.Context(), binding.Binding{
ID: id,
Name: "test " + source,
Matcher: binding.Matcher{Source: source},
MappingID: mappingID,
Workflow: "implement",
Owner: owner,
Repo: repo,
Secret: "0123456789abcdef0123456789abcdef",
}); err != nil {
t.Fatalf("UpdateBinding to pending_approval: %v", err)
}
if err := s.EdaStore.ApproveBinding(t.Context(), id); err != nil {
t.Fatalf("ApproveBinding: %v", err)
}
+4 -18
View File
@@ -11,14 +11,13 @@ import (
)
// Status is the binding lifecycle state. Mirrors telegram's
// dangerousAction / pendingApproval shape: armed is the only state that
// evaluates against incoming events; any edit drops armed back to
// pending_approval; only an explicit Approve call moves
// pending_approval -> armed.
// dangerousAction / pendingApproval shape: a binding is created
// pending_approval, armed is the only state that evaluates against incoming
// events, any edit drops armed back to pending_approval, and only an
// explicit Approve call moves pending_approval -> armed.
type Status string
const (
StatusDraft Status = "draft"
StatusPendingApproval Status = "pending_approval"
StatusArmed Status = "armed"
)
@@ -137,16 +136,3 @@ func (m Matcher) Matches(source string, authenticated bool) bool {
}
return m.Source == source
}
// Normalize clamps an arbitrary string into a recognised Status, falling
// back to StatusDraft for any unknown value. The DB CHECK constraint
// already rejects bad strings at write time; Normalize is the API-edge
// guard for inputs that arrive before they ever reach the store.
func Normalize(s Status) Status {
switch s {
case StatusDraft, StatusPendingApproval, StatusArmed:
return s
default:
return StatusDraft
}
}
@@ -194,7 +194,7 @@ func (s *Store) InsertBinding(ctx context.Context, b binding.Binding) (string, e
return "", err
}
r.Set("version", 1)
r.Set("status", string(binding.StatusDraft))
r.Set("status", string(binding.StatusPendingApproval))
if err := s.app.Save(r); err != nil {
return "", fmt.Errorf("edastore: insert binding: %w", err)
}
@@ -169,6 +169,9 @@ func TestFailedWritesNotifyNothing(t *testing.T) {
// Seed one binding and one mapping, then clear the seed-time events.
seedID := insertBinding(t, s, bindingInput{Name: "seed", Source: "src-seed", Workflow: "triage"})
if err := s.ApproveBinding(t.Context(), seedID); err != nil {
t.Fatalf("ApproveBinding(seed) error = %v", err)
}
mid, err := s.InsertMapping(t.Context(), mapping.Mapping{Name: "seed-map"})
if err != nil {
t.Fatalf("InsertMapping() error = %v", err)
@@ -181,7 +184,7 @@ func TestFailedWritesNotifyNothing(t *testing.T) {
t.Fatalf("UpdateBinding() error = %v, want ErrBindingNotFound", err)
}
})
t.Run("ApproveBinding refuses draft", func(t *testing.T) {
t.Run("ApproveBinding refuses an armed binding", func(t *testing.T) {
if err := s.ApproveBinding(t.Context(), seedID); !errors.Is(err, ErrBindingTransition) {
t.Fatalf("ApproveBinding() error = %v, want ErrBindingTransition", err)
}
+19 -5
View File
@@ -104,9 +104,12 @@ func ensureMappings(app core.App) error {
func ensureBindings(app core.App) error {
c, fresh, err := collection(app, CollBindings)
if err != nil || !fresh {
if err != nil {
return err
}
if !fresh {
return promoteDraftBindings(app)
}
mappings, err := app.FindCollectionByNameOrId(CollMappings)
if err != nil {
return fmt.Errorf("edastore: bindings need mappings: %w", err)
@@ -119,11 +122,10 @@ func ensureBindings(app core.App) error {
&core.TextField{Name: "owner"},
&core.TextField{Name: "repo"},
&core.NumberField{Name: "version"},
// status is the domain's three-state lifecycle, not a local
// vocabulary: draft -> pending_approval -> armed. Only
// ApproveBinding reaches armed, which is the epic's approval gate.
// status is the domain's lifecycle, not a local vocabulary:
// pending_approval -> armed. Only ApproveBinding reaches armed,
// which is the epic's approval gate.
&core.SelectField{Name: "status", MaxSelect: 1, Values: []string{
string(binding.StatusDraft),
string(binding.StatusPendingApproval),
string(binding.StatusArmed),
}},
@@ -135,6 +137,18 @@ func ensureBindings(app core.App) error {
return save(app, c)
}
// promoteDraftBindings moves bindings an earlier version stored as "draft",
// a state nothing could leave without an unrelated edit, to
// pending_approval so they can be approved. It is a no-op once none remain.
func promoteDraftBindings(app core.App) error {
_, err := app.DB().NewQuery("UPDATE " + CollBindings + " SET status = {:pending} WHERE status = 'draft'").
Bind(map[string]any{"pending": string(binding.StatusPendingApproval)}).Execute()
if err != nil {
return fmt.Errorf("edastore: promote draft bindings: %w", err)
}
return nil
}
func ensureBindingDispatches(app core.App) error {
c, fresh, err := collection(app, CollBindingDispatches)
if err != nil || !fresh {
+38 -23
View File
@@ -71,10 +71,10 @@ func TestPlaybookDispatchIsIdempotent(t *testing.T) {
}
}
// TestBindingStartsAsDraft pins the approval gate from the epic's acceptance
// criteria: "A binding cannot go live without explicit human approval." A
// binding created without a status must not default to anything live.
func TestBindingStartsAsDraft(t *testing.T) {
// TestBindingStartsPendingApproval pins the approval gate from the epic's
// acceptance criteria: "A binding cannot go live without explicit human
// approval." A new binding awaits that approval and is not live.
func TestBindingStartsPendingApproval(t *testing.T) {
st := newStore(t)
id, err := st.InsertBinding(t.Context(), binding.Binding{
Name: "n", Matcher: binding.Matcher{Source: "sentry"}, Workflow: "implement",
@@ -86,8 +86,8 @@ func TestBindingStartsAsDraft(t *testing.T) {
if err != nil {
t.Fatalf("GetBinding() error = %v", err)
}
if b.Status != binding.StatusDraft {
t.Errorf("new binding status = %q, want %q: a binding must not be live before approval", b.Status, binding.StatusDraft)
if b.Status != binding.StatusPendingApproval {
t.Errorf("new binding status = %q, want %q: a binding must not be live before approval", b.Status, binding.StatusPendingApproval)
}
}
@@ -129,7 +129,7 @@ var _ = core.Collection{}
// The states are the domain's, not this package's: collapsing them (as an
// earlier version of this store did) removes the review step while still
// looking like an approval gate, which is the worst of both.
func TestBindingLifecycleIsThreeStates(t *testing.T) {
func TestBindingLifecycle(t *testing.T) {
st := newStore(t)
id, err := st.InsertBinding(t.Context(), binding.Binding{
Name: "n", Matcher: binding.Matcher{Source: "sentry"}, Workflow: "implement",
@@ -138,23 +138,10 @@ func TestBindingLifecycleIsThreeStates(t *testing.T) {
t.Fatalf("InsertBinding() error = %v", err)
}
// A draft cannot skip review.
if err := st.ApproveBinding(t.Context(), id); !errors.Is(err, storecontract.ErrBindingTransition) {
t.Fatalf("ApproveBinding(draft) error = %v, want ErrBindingTransition: draft must not skip review", err)
}
// Editing sends it to pending_approval.
if err := st.UpdateBinding(t.Context(), binding.Binding{
ID: id, Name: "n2", Matcher: binding.Matcher{Source: "sentry"}, Workflow: "implement",
}); err != nil {
t.Fatalf("UpdateBinding() error = %v", err)
}
// It is created awaiting review.
b, err := st.GetBinding(t.Context(), id)
if err != nil {
t.Fatalf("GetBinding() error = %v", err)
}
if b.Status != binding.StatusPendingApproval {
t.Fatalf("status after edit = %q, want %q", b.Status, binding.StatusPendingApproval)
if err != nil || b.Status != binding.StatusPendingApproval {
t.Fatalf("status after insert = %q (err %v), want %q", b.Status, err, binding.StatusPendingApproval)
}
// Approval arms it, and only from pending_approval.
@@ -192,3 +179,31 @@ func TestOneBindingPerSource(t *testing.T) {
t.Errorf("second InsertBinding() error = %v, want ErrBindingOverlap", err)
}
}
// A binding stored as "draft" by an earlier version could never be approved.
// Opening the store moves it to pending_approval, so it can be.
func TestOpenMovesLegacyDraftBindingsToPendingApproval(t *testing.T) {
dir := t.TempDir()
cfg := edastore.Config{DBPath: filepath.Join(dir, "eda.sqlite"), DataDir: filepath.Join(dir, "pb_data")}
st, err := edastore.Open(cfg)
if err != nil {
t.Fatal(err)
}
id, err := st.InsertBinding(t.Context(), binding.Binding{Name: "n", Matcher: binding.Matcher{Source: "sentry"}, Workflow: "implement"})
if err != nil {
t.Fatal(err)
}
if _, err := st.App().DB().NewQuery("UPDATE bindings SET status = 'draft' WHERE id = {:id}").Bind(map[string]any{"id": id}).Execute(); err != nil {
t.Fatal(err)
}
_ = st.Close()
st, err = edastore.Open(cfg)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = st.Close() })
if err := st.ApproveBinding(t.Context(), id); err != nil {
t.Fatalf("ApproveBinding(legacy draft) = %v, want it approvable after reopen", err)
}
}
@@ -407,9 +407,12 @@ func TestStateStoreConformance(t *testing.T) {
if _, err := ec.ListBindings(ctx); err != nil {
t.Fatalf("ListBindings: %v", err)
}
if err := ec.ApproveBinding(ctx, bindingID); err != nil {
t.Fatalf("ApproveBinding from pending_approval = %v", err)
}
err = ec.ApproveBinding(ctx, bindingID)
if !errors.Is(err, store.ErrBindingTransition) {
t.Fatalf("ApproveBinding from draft = %v, want ErrBindingTransition", err)
t.Fatalf("ApproveBinding when armed = %v, want ErrBindingTransition", err)
}
err = ec.DeleteBinding(ctx, "rabsent00000000")
if !errors.Is(err, store.ErrBindingNotFound) {
+1 -1
View File
@@ -71,7 +71,7 @@ func (s *Server) handleBindingCreate(w http.ResponseWriter, r *http.Request) {
Owner: req.Owner,
Repo: req.Repo,
Secret: req.Secret,
Status: binding.Normalize(binding.StatusDraft),
Status: binding.StatusPendingApproval,
}
if err := b.Validate(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
+13 -23
View File
@@ -80,8 +80,8 @@ func TestHandleBindingCreateAndGet(t *testing.T) {
if created.ID == "" {
t.Fatalf("created.ID = 0; body = %s", w.Body.String())
}
if created.Status != binding.StatusDraft {
t.Fatalf("created.Status = %q, want %q", created.Status, binding.StatusDraft)
if created.Status != binding.StatusPendingApproval {
t.Fatalf("created.Status = %q, want %q", created.Status, binding.StatusPendingApproval)
}
if created.Secret != "" {
t.Fatalf("created.Secret = %q, want \"\" (response must strip secret)", created.Secret)
@@ -272,7 +272,7 @@ func TestHandleBindingUpdatePreservesOtherFields(t *testing.T) {
t.Fatalf("updated.MappingID = %q, want %q", updated.MappingID, mappingID)
}
// Status MUST not regress from a state the caller never asked for.
if updated.Status != binding.StatusDraft && updated.Status != binding.StatusPendingApproval {
if updated.Status != binding.StatusPendingApproval {
t.Fatalf("updated.Status = %q, want draft or pending_approval", updated.Status)
}
}
@@ -306,16 +306,18 @@ func TestHandleBindingUpdateWithEmptySecretPreservesExisting(t *testing.T) {
}
}
func TestHandleBindingApproveFromDraftRejected(t *testing.T) {
func TestHandleBindingApproveArmedRejected(t *testing.T) {
srv := bindingTestServer(t)
mappingID := seedMapping(t, srv, "m")
w := doJSON(t, srv, http.MethodPost, "/api/bindings", validBindingRequest("a", "sentry", mappingID))
var created binding.Binding
_ = json.Unmarshal(w.Body.Bytes(), &created)
if w = doJSON(t, srv, http.MethodPost, "/api/bindings/"+created.ID+"/approve", nil); w.Code != http.StatusOK {
t.Fatalf("first approve status = %d, want %d; body = %s", w.Code, http.StatusOK, w.Body.String())
}
// draft is NOT a valid source state for approve; the binding must
// first land in pending_approval (via PATCH). Approve from draft
// returns ErrBindingTransition -> 409.
// An armed binding is not a valid source state for approve:
// ErrBindingTransition -> 409.
w = doJSON(t, srv, http.MethodPost, "/api/bindings/"+created.ID+"/approve", nil)
if w.Code != http.StatusConflict {
t.Fatalf("status = %d, want %d; body = %s", w.Code, http.StatusConflict, w.Body.String())
@@ -323,27 +325,15 @@ func TestHandleBindingApproveFromDraftRejected(t *testing.T) {
}
func TestHandleBindingApproveHappyPath(t *testing.T) {
// Per docs/prds/webhook-intake-security.md point 2, ANY edit drops status
// to pending_approval. The happy path: POST creates draft, PATCH moves
// it to pending_approval, POST /approve moves it to armed. This test
// pins the rule end-to-end through the webui handlers.
// A created binding awaits approval, and approving it arms it: the
// operator who just created one can approve it without an edit.
srv := bindingTestServer(t)
mappingID := seedMapping(t, srv, "m")
w := doJSON(t, srv, http.MethodPost, "/api/bindings", validBindingRequest("a", "sentry", mappingID))
var created binding.Binding
_ = json.Unmarshal(w.Body.Bytes(), &created)
if created.Status != binding.StatusDraft {
t.Fatalf("created status = %q, want %q", created.Status, binding.StatusDraft)
}
w = doJSON(t, srv, http.MethodPatch, "/api/bindings/"+created.ID, validBindingRequest("renamed", "sentry", mappingID))
if w.Code != http.StatusOK {
t.Fatalf("patch status = %d, want %d; body = %s", w.Code, http.StatusOK, w.Body.String())
}
var patched binding.Binding
_ = json.Unmarshal(w.Body.Bytes(), &patched)
if patched.Status != binding.StatusPendingApproval {
t.Fatalf("patched status = %q, want %q", patched.Status, binding.StatusPendingApproval)
if created.Status != binding.StatusPendingApproval {
t.Fatalf("created status = %q, want %q", created.Status, binding.StatusPendingApproval)
}
w = doJSON(t, srv, http.MethodPost, "/api/bindings/"+created.ID+"/approve", nil)
+1 -1
View File
@@ -16,4 +16,4 @@ Defaulting to \`null\`.`),null)}function Tx(e){return Cx(e)&&!Number.isNaN(e)&&e
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:nT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>nT(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=iT(c),u=e+1<n.length?iT(n[e+1]):null;if(l&&u&&aT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=iT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>nT(e)),rows:r.map(e=>e.map(e=>nT(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:nT(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:nT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function iT(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 aT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oT={class:`[overflow-wrap:anywhere]`},sT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},cT={class:`font-mono text-[0.85em]`},lT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},uT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},dT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},fT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},pT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},mT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},hT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},gT={key:8,class:`mb-2.5 last:mb-0`},_T=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>rT(t.text));return(e,t)=>(L(),R(`div`,oT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,sT,[B(`code`,cT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,lT,[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(eT,{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(eT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,uT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,dT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,fT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,pT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,mT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,gT,[V(eT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),vT={class:`truncate`},yT=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`,vT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),bT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},xT={class:`font-semibold text-foreground`},ST={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},CT=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(yT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,bT,[V(A(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,xT,O(n.value),1),r.value?(L(),R(`code`,ST,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),wT={key:0,class:`mb-2 grid gap-0.5 text-xs`},TT={key:2,class:`whitespace-pre-wrap`},ET=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`,wT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(CT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(_T,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,TT,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),DT={class:`w-full self-center justify-self-center py-6 text-center`},OT={class:`grid gap-2`},kT=[`onClick`],AT=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`,DT,[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>eA?`${n.slice(0,eA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var nA=[`title`],rA=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>Dk(n.event)),a=G(()=>tA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?vO(n.event.at):`—`);return(e,t)=>(L(),z(A(Zk),{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,nA)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function iA(e,t){return`${e}:${t??0}`}function aA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=iA(tA(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 oA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},sA={class:`max-h-[28rem] overflow-y-auto`},cA=[`aria-expanded`,`aria-label`,`onClick`],lA=[`title`],uA=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(ek()),a=nn(new Set),o=G(()=>aA(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 tA(e.representative)}function u(e){return e.representative.at?vO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(uO),null,{default:j(()=>[V(A(hO),null,{default:j(()=>[V(A(gO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(dO),null,{default:j(()=>[V(A(XD),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(fO),null,{default:j(()=>[B(`div`,oA,[B(`div`,sA,[V(A(Yk),null,{default:j(()=>[V(A($k),{class:`sticky top-0 z-10 bg-card`},{default:j(()=>[V(A(Zk),null,{default:j(()=>[V(A(Qk),null,{default:j(()=>[...t[1]||=[H(`Event`,-1)]]),_:1}),V(A(Qk),null,{default:j(()=>[...t[2]||=[H(`Task`,-1)]]),_:1}),V(A(Qk),null,{default:j(()=>[...t[3]||=[H(`Detail`,-1)]]),_:1}),V(A(Qk),null,{default:j(()=>[...t[4]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(Xk),null,{default:j(()=>[A(n).length?U(``,!0):(L(),z(A(Zk),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(HD),null,{default:j(()=>[V(A(GD),null,{default:j(()=>[V(A(JD),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(rA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(L(),R(I,{key:1},[V(A(Zk),{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(XD),{variant:`idle`},{default:j(()=>[H(`×`+O(e.count),1)]),_:2},1024)],8,cA)]),_: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,lA)]),_: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(rA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):U(``,!0)],64))],64))),128)):U(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),dA=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=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),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(Dx),{"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>eA?`${n.slice(0,eA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var nA=[`title`],rA=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>Dk(n.event)),a=G(()=>tA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?vO(n.event.at):`—`);return(e,t)=>(L(),z(A(Zk),{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,nA)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}});function iA(e,t){return`${e}:${t??0}`}function aA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=iA(tA(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 oA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},sA={class:`max-h-[28rem] overflow-y-auto`},cA=[`aria-expanded`,`aria-label`,`onClick`],lA=[`title`],uA=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(ek()),a=nn(new Set),o=G(()=>aA(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 tA(e.representative)}function u(e){return e.representative.at?vO(e.representative.at):`—`}function d(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(uO),null,{default:j(()=>[V(A(hO),null,{default:j(()=>[V(A(gO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(dO),null,{default:j(()=>[V(A(XD),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(fO),null,{default:j(()=>[B(`div`,oA,[B(`div`,sA,[V(A(Yk),null,{default:j(()=>[V(A($k),{class:`sticky top-0 z-10 bg-card`},{default:j(()=>[V(A(Zk),null,{default:j(()=>[V(A(Qk),null,{default:j(()=>[...t[1]||=[H(`Event`,-1)]]),_:1}),V(A(Qk),null,{default:j(()=>[...t[2]||=[H(`Task`,-1)]]),_:1}),V(A(Qk),null,{default:j(()=>[...t[3]||=[H(`Detail`,-1)]]),_:1}),V(A(Qk),null,{default:j(()=>[...t[4]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(Xk),null,{default:j(()=>[A(n).length?U(``,!0):(L(),z(A(Zk),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(HD),null,{default:j(()=>[V(A(GD),null,{default:j(()=>[V(A(JD),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(rA,{key:0,event:e.representative,onOpen:d},null,8,[`event`])):(L(),R(I,{key:1},[V(A(Zk),{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(XD),{variant:`idle`},{default:j(()=>[H(`×`+O(e.count),1)]),_:2},1024)],8,cA)]),_: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,lA)]),_: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(rA,{key:`${e.key}:${n}`,event:t,onOpen:d},null,8,[`event`]))),128)):U(``,!0)],64))],64))),128)):U(``,!0)]),_:1})]),_:1})])])]),_:1})]),_:1}))}}),dA=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=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),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(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`tLine truncated
+3 -3
View File
@@ -28,9 +28,9 @@ const emit = defineEmits<{
<Pencil data-icon="inline-start" />
Edit
</Button>
<!-- Only a pending binding can be approved. A draft is not a state you
approve from and an armed binding is already firing, so the button
would be a no-op -- or worse, a misleading one. -->
<!-- Only a pending binding can be approved. An armed binding is
already firing, so the button would be a no-op -- or worse, a
misleading one. -->
<Button v-if="props.binding.status === 'pending_approval'" size="sm" @click="emit('approve', props.binding)">
<Check data-icon="inline-start" />
Approve
+1 -1
View File
@@ -2,7 +2,7 @@
import { Badge } from "@/components/ui/badge";
import { statusKind, statusLabel } from "./binding-draft";
/** A binding's lifecycle state: draft, pending approval, or armed. The
/** A binding's lifecycle state: pending approval or armed. The
* colour ramp is shared with every other status in the dashboard, so the
* same colour means the same thing here as it does on a task. */
const props = defineProps<{ status?: string }>();
-2
View File
@@ -40,13 +40,11 @@ export interface WorkflowOption {
export type StatusKind = "ok" | "warn" | "idle";
const STATUS_LABELS: Record<string, string> = {
draft: "draft",
pending_approval: "pending approval",
armed: "armed",
};
const STATUS_KINDS: Record<string, StatusKind> = {
draft: "idle",
pending_approval: "warn",
armed: "ok",
};