mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-12-02 00:37:18 +00:00
## Summary
Replaces the single `queued` pre-execution state with explicit `pending`
and `runnable` states, and wires approve/deny actions for
parent-generated child runs that require human approval before they can
execute. This diff covers the web UI and OpenAPI spec layers of that
change.
## What changed
**Run status model**
- `queued` is removed from all TypeScript types, display maps, column
routing, and tests.
- `pending` (awaiting approval) and `runnable` (eligible for the
scheduler) replace it as distinct board columns and `RunStatus` variants
with their own labels and colors (`runnable` gets cyan; `pending` stays
muted).
**Approval actions**
- New `approveRun` / `denyRun` API calls in `run-actions.ts` invoke the
new `POST /runs/{id}/approve` and `POST /runs/{id}/deny` endpoints.
- `canApprove` predicate requires both `status.kind === "pending"` and
`lifecycle.approval?.state === "pending"` — a run whose status is
pending but has no approval record does not expose the action.
- `useApproveRun` / `useDenyRun` mutations in `mutations.ts` follow the
same pattern as `useCancelRun`.
- `ActionsMenu` in `run-detail.tsx` gains Approve (lifecycle group) and
Deny (destructive group) menu items.
**Board and event plumbing**
- `columnForStatus` now routes `pending → pending column` and `runnable
→ runnable column`; `submitted` stays in the pending column.
- `BOARD_STATUS_EVENTS` and `RUN_SUMMARY_EVENTS` replace `run.queued`
with `run.start_requested`, `run.pending`, `run.approved`, `run.denied`,
and `run.runnable`.
- The `pending` column is hidden when empty (same behaviour the old
`queued` column had).
**Waterfall phases (`run-phases.ts`)**
- `queued` phase is removed; `pending` and `runnable` phases are added
in order.
- The submitted phase closes at `run.start_requested` rather than
`run.queued`.
- Each phase derives its timestamps from its own event rather than a
single `firstTs` lookup, making multi-phase pre-execution timelines
accurate.
**OpenAPI spec**
- `POST /api/v1/runs/{id}/approve` and `POST /api/v1/runs/{id}/deny`
endpoints added with 200/404/409 responses.
- `startRun` description updated to describe the pending/runnable
branching behaviour.
- `cancelRun` description updated to reference `pending`/`runnable`
instead of `queued`.
### Plan Summary
- **Task 3** (OpenAPI schema additions for approve/deny endpoints) —
complete in this diff.
- **Task 6** (Web UI surfaces: board columns, run-detail actions,
waterfall phases, event subscriptions) — complete in this diff.
- **Task 7** (doc cleanup: references to `queued` replaced in plans,
brainstorms, and QA docs) — complete in this diff.
### Fabro Details
<details>
<summary>Ran 9 stages in 127m 37s for $104.98</summary>
| Stage | Duration | Cost | Retries |
|---|---|---|---|
| start | 0s | – | 0 |
| toolchain | 2s | – | 0 |
| preflight_compile | 2m 15s | – | 0 |
| preflight_lint | 2m 29s | – | 0 |
| implement | 92m 10s | $91.53 | 0 |
| simplify_opus | 18m 35s | $10.65 | 0 |
| simplify_gpt | 7m 36s | $2.81 | 0 |
| verify | 3m 42s | – | 0 |
| fmt | 3s | – | 0 |
| **Total** | **127m 37s** | **$104.98** | **0** |
</details>
<details>
<summary>Ran <code>ImplementPlan.fabro</code> (12 nodes and 15
edges)</summary>
```dot
digraph ImplementPlan {
graph [
goal="Implement and simplify",
model_stylesheet="
* { model: claude-opus-4-7; }
"
]
rankdir=LR
start [shape=Mdiamond, label="Start"]
exit [shape=Msquare, label="Exit"]
toolchain [label="Toolchain", shape=parallelogram, script="command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1", max_retries=0]
preflight_compile [label="Preflight Compile", shape=parallelogram, script="cargo check -q --workspace 2>&1", max_retries=0]
preflight_lint [label="Preflight Lint", shape=parallelogram, script="cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1", max_retries=0]
fix_lints [label="Fix Lints", prompt="The preflight lint step failed. Read the build output from context and fix all clippy lint warnings.", max_visits=3]
implement [label="Implement", prompt="Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD.", model="gpt-55", reasoning_effort="xhigh"]
simplify_opus [label="Simplify (Opus)", prompt="@prompts/simplify.md"]
simplify_gpt [label="Simplify (GPT-55)", prompt="@prompts/simplify.md", model="gpt-55"]
verify [label="Verify", shape=parallelogram, script="cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --cargo-quiet --workspace --status-level fail 2>&1 && cargo dev docs refresh 2>&1 && cargo dev docs check 2>&1", goal_gate=true, retry_target="fixup"]
fixup [label="Fixup", prompt="The verify step failed. Read the build output from context and fix all clippy lint warnings, test failures, and generated docs errors.", max_visits=3]
fmt [label="Format", shape=parallelogram, script="cargo +nightly-2026-04-14 fmt --all 2>&1", max_retries=0]
start -> toolchain
toolchain -> preflight_compile [condition="outcome=succeeded"]
toolchain -> exit
preflight_compile -> preflight_lint [condition="outcome=succeeded"]
preflight_compile -> exit
preflight_lint -> implement [condition="outcome=succeeded"]
preflight_lint -> fix_lints
fix_lints -> preflight_lint
implement -> simplify_opus -> simplify_gpt -> verify
verify -> fmt [condition="outcome=succeeded"]
verify -> fixup
fixup -> verify
fmt -> exit
}
```
</details>
⚒️ Generated with [Fabro](https://fabro.sh)
---------
Co-authored-by: Fabro <noreply@fabro.sh>
Co-authored-by: fabro <fabro@anthropic.com>
Co-authored-by: Bryan Helmkamp <bryan@brynary.com>
17 KiB
17 KiB
Production Web UI Test Plan
Harness requirements
1. Rust HTTP integration harness (existing)
- What it does: Sends HTTP requests to the fabro server via
tower::ServiceExt::oneshot()against an in-memoryAppState. No network, no boot overhead. - What it exposes: Full request/response cycle including headers, status codes, JSON bodies. Direct mutation of
AppState(e.g., setting run status) for precondition setup. - Estimated complexity: Already exists (
lib/crates/fabro-server/tests/it/helpers.rs). Providestest_app_state(),build_router(),body_json(),create_and_start_run(),api(), etc. - Which tests depend on it: Tests 1-6
2. Playwright browser harness (new -- must be built)
- What it does: Launches a real browser against a running fabro server that serves the built SPA. Exercises the full stack: React app fetching real HTTP endpoints, rendering real DOM, cookies for demo mode.
- What it exposes: Page navigation, DOM element inspection, cookie management, screenshot capture, click/interaction simulation.
- Estimated complexity: Moderate. Requires:
- Install
@playwright/testas a dev dependency inapps/fabro-web - Create
apps/fabro-web/tests/playwright.config.tswithwebServerconfig that builds the SPA and starts the fabro server withAuthMode::Disabledand in-memory store - The server already serves the built SPA when
FABRO_STATIC_DIRis configured. Auth disabled mode returns a synthetic user from/auth/me.
- Install
- Which tests depend on it: Tests 7-14
3. TypeScript unit test harness (existing)
- What it does: Runs bun tests for pure TypeScript functions and React component logic.
- What it exposes: Direct function calls, React
renderToStringfor context providers. - Estimated complexity: Already exists (
bun test). - Which tests depend on it: Tests 15-18
Test plan
Test 1: Demo /boards/runs returns RunListItem-shaped data
- Name: Requesting the runs board in demo mode returns run list items with repository, title, workflow, and board column status
- Type: integration
- Disposition: new
- Harness: Rust HTTP integration harness
- Preconditions: Server initialized with
AuthMode::Disabled. Demo headerX-Fabro-Demo: 1set on request. - Actions:
GET /api/v1/boards/runswithX-Fabro-Demo: 1header - Expected outcome: HTTP 200. Response body has
dataarray. First item has stringid, objectrepository(withname), stringtitle, objectworkflow(withslug), stringstatusthat is one of"working","pending","review","merge", and stringcreated_at. Source of truth: OpenAPI specPaginatedRunListschema and plan Decision 2. - Interactions: Demo data module (
demo/mod.rsruns::list_items())
Test 2: Demo GET /runs/{id} returns StoreRunSummary shape (not RunStatusResponse)
- Name: Requesting a single run in demo mode returns the StoreRunSummary shape with run_id, goal, and workflow fields instead of the old RunStatusResponse shape
- Type: integration
- Disposition: new
- Harness: Rust HTTP integration harness
- Preconditions: Server initialized with
AuthMode::Disabled. Demo header set. Run ID "run-1" exists in demo data. - Actions:
GET /api/v1/runs/run-1withX-Fabro-Demo: 1header - Expected outcome: HTTP 200. Body has
run_id(string),goal(string),workflow_slug(string),workflow_name(string),host_repo_path(string),status(string),duration_ms(number or null). Body does NOT havequeue_positionfield. Source of truth: OpenAPI specStoreRunSummaryschema and plan Decision 3. - Interactions: Demo data module
Test 3: Demo GET /runs/{id} returns 404 for unknown run
- Name: Requesting a nonexistent run in demo mode returns 404
- Type: boundary
- Disposition: new
- Harness: Rust HTTP integration harness
- Preconditions: Server initialized with
AuthMode::Disabled. Demo header set. - Actions:
GET /api/v1/runs/nonexistent-run-idwithX-Fabro-Demo: 1header - Expected outcome: HTTP 404. Source of truth: OpenAPI spec 404 error response.
- Interactions: Demo data module
Test 4: Real /boards/runs returns RunListItem shape with board columns
- Name: Requesting the runs board in production mode returns enriched run list items with board column statuses instead of lifecycle statuses
- Type: integration
- Disposition: new
- Harness: Rust HTTP integration harness
- Preconditions: Server initialized with
AuthMode::Disabled, no demo header. A run created and started, then set toRunStatus::Runningin state. - Actions:
GET /api/v1/boards/runs(no demo header) - Expected outcome: HTTP 200. Response has
dataarray. The created run appears with stringid, stringtitle, objectrepository(withname), objectworkflow(withslug), stringstatusequal to"working"(the board column mapping ofRunning), and stringcreated_at. Source of truth: OpenAPI specPaginatedRunListschema and plan Decision 1 (Running -> "working"). - Interactions:
state.runsmutex,state.store.list_runs()
Test 5: Real /boards/runs excludes non-board statuses
- Name: Runs with statuses that don't map to board columns (Submitted, Runnable, Starting, Failed, Cancelled) are excluded from the board response
- Type: boundary
- Disposition: new
- Harness: Rust HTTP integration harness
- Preconditions: Server initialized. A run created and started, then set to
RunStatus::Failed. - Actions:
GET /api/v1/boards/runs(no demo header) - Expected outcome: HTTP 200. The failed run does NOT appear in the
dataarray. Source of truth: Plan Decision 1 status mapping -- Failed is excluded. - Interactions:
state.runsmutex
Test 6: Real /boards/runs maps Paused to "pending" and Completed to "merge"
- Name: Board column mapping correctly translates Paused to pending and Completed to merge
- Type: integration
- Disposition: new
- Harness: Rust HTTP integration harness
- Preconditions: Server initialized. Two runs created: one set to
RunStatus::Paused, one set toRunStatus::Completed. - Actions:
GET /api/v1/boards/runs(no demo header) - Expected outcome: HTTP 200. Paused run has
status: "pending". Completed run hasstatus: "merge". Source of truth: Plan Decision 1 status mapping. - Interactions:
state.runsmutex,state.store.list_runs()
Test 7: Runs board loads without errors in production mode (browser)
- Name: Navigating to the runs board in production mode renders a page without error messages
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Fabro server running with auth disabled and in-memory store. SPA built and served. No demo cookie set.
- Actions: Navigate to
/runs. - Expected outcome: Page loads. Body does not contain "Unauthorized" or "500" or "error" (case-insensitive check excluding expected UI text). Screenshot captured as artifact at
test-results/runs-prod.png. Source of truth: User request ("make it production grade" -- the runs board is the primary view and must render). - Interactions: React Router loader ->
apiFetch("/boards/runs")-> server reallist_board_runshandler
Test 8: Navigation hides Workflows and Insights in production mode (browser)
- Name: The sidebar/header navigation does not show Workflows or Insights links when not in demo mode
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running, no demo cookie.
- Actions: Navigate to
/runs. Inspect thenavelement. - Expected outcome:
navelement does NOT contain text "Workflows".navelement does NOT contain text "Insights".navelement DOES contain text "Runs". Source of truth: Plan Decision 4 and user request ("remove the corresponding UI from fabro web for now"). - Interactions: App shell loader ->
getAuthMe()->demoMode: false->getVisibleNavigation(false)filters out demo-only items
Test 9: Settings page loads in production mode (browser)
- Name: The settings page loads successfully in production mode since /settings is implemented in the real server
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running, no demo cookie.
- Actions: Navigate to
/settings. - Expected outcome: Page loads without "Not implemented" or "500" error text. Screenshot captured at
test-results/settings-prod.png. Source of truth: Real server route table hasget(get_server_settings)for/settings. - Interactions: Settings route loader ->
apiJson("/settings")-> realget_server_settingshandler
Test 10: Demo mode runs board shows demo data (browser)
- Name: Navigating to the runs board with the demo cookie set renders demo run data
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running.
fabro-demo=1cookie set for localhost. - Actions: Navigate to
/runs. - Expected outcome: Page loads without error. Body content is not empty/blank (confirms demo data rendered). Screenshot captured at
test-results/runs-demo.png. Source of truth: Plan Decision 2 (demo/boards/runsreturns demo run list items). - Interactions: Demo cookie -> server
X-Fabro-Demomiddleware -> demolist_board_runs-> demo run data
Test 11: Navigation shows all items in demo mode (browser)
- Name: The navigation shows Workflows, Runs, and Insights links when in demo mode
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running. Demo cookie set.
- Actions: Navigate to
/runs. Inspectnavelement. - Expected outcome:
navcontains "Workflows", "Runs", and "Insights". Source of truth: Plan Decision 4 -- all nav items visible in demo mode. - Interactions: App shell loader ->
getAuthMe()->demoMode: true->getVisibleNavigation(true)includes all items
Test 12: Workflows page loads in demo mode (browser)
- Name: The workflows page renders successfully when in demo mode
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running. Demo cookie set.
- Actions: Navigate to
/workflows. - Expected outcome: Page loads without "error" or "500" text. Screenshot captured at
test-results/workflows-demo.png. Source of truth: Demo routes include workflow handlers. - Interactions: Workflows route loader -> demo workflow handlers
Test 13: Toggling demo mode changes navigation (browser)
- Name: Clicking the demo toggle button switches between production and demo navigation
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running. No demo cookie initially.
- Actions:
- Navigate to
/runs - Verify nav does NOT contain "Workflows"
- Click the beaker button (demo toggle --
button[title*="demo"], button[title*="Demo"]) - Wait for page to revalidate
- Verify nav now DOES contain "Workflows"
- Navigate to
- Expected outcome: Before toggle: no "Workflows" in nav. After toggle: "Workflows" appears in nav. Screenshot captured at
test-results/after-toggle-demo.png. Source of truth: Plan Decision 4 --toggleDemoMode()posts to/api/v1/demo/toggle, sets cookie, revalidates,demoModechanges, nav re-renders. - Interactions: Demo toggle button ->
POST /demo/toggle-> cookie set -> revalidate ->getAuthMe()returnsdemoMode: true->getVisibleNavigation(true)
Test 14: Run detail page loads in production mode (browser)
- Name: Navigating to a run detail page in production mode renders without crashing, even when no runs exist
- Type: scenario
- Disposition: new
- Harness: Playwright browser harness
- Preconditions: Server running with in-memory store, no demo cookie, no runs created.
- Actions: Navigate to
/runs/nonexistent-id. - Expected outcome: Page renders (may show "Run not found" message). Does NOT crash with unhandled error or blank page. Source of truth: Plan Decision 6 -- run-detail loader uses
/runs/{id}which returns 404, and component handlesrun: null. - Interactions: Run detail loader ->
apiJson("/runs/nonexistent-id")-> 404 -> graceful error handling
Test 15: mapRunSummaryToRunItem correctly maps StoreRunSummary fields to RunItem
- Name: The mapping function converts server run summary response fields to the UI's RunItem shape
- Type: unit
- Disposition: new
- Harness: TypeScript unit test harness (bun test)
- Preconditions: None (pure function).
- Actions: Call
mapRunSummaryToRunItem()with a completeRunSummaryResponseobject containingrun_id,goal,workflow_slug,host_repo_path,duration_ms. - Expected outcome: Returns
RunItemwithidequal torun_id,titleequal togoal,workflowequal toworkflow_slug,repoequal to last segment ofhost_repo_path,elapsedformatted fromduration_ms. Source of truth: Plan Decision 6 field mapping specification. - Interactions:
formatElapsedSecs()fromlib/format.ts
Test 16: mapRunSummaryToRunItem handles null optional fields
- Name: The mapping function provides sensible defaults when optional fields are null
- Type: boundary
- Disposition: new
- Harness: TypeScript unit test harness (bun test)
- Preconditions: None (pure function).
- Actions: Call
mapRunSummaryToRunItem()with all optional fields set to null (goal: null,workflow_slug: null,host_repo_path: null,duration_ms: null). - Expected outcome: Returns
RunItemwithtitle: "Untitled run",workflow: "unknown",repo: "unknown",elapsed: undefined. Source of truth: Plan Task 4 step 3 default values. - Interactions: None
Test 17: DemoModeProvider provides demo mode value to children
- Name: The React context correctly propagates the demo mode boolean to consumer components
- Type: unit
- Disposition: new
- Harness: TypeScript unit test harness (bun test)
- Preconditions: None.
- Actions: Render
<DemoModeProvider value={true}><TestConsumer /></DemoModeProvider>usingrenderToString.TestConsumerreadsuseDemoMode(). - Expected outcome: Rendered HTML contains
data-demo="true"and text "demo". Source of truth: Plan Decision 7 --DemoModeProviderwrapsOutletwith context value. - Interactions: React context system
Test 18: getVisibleNavigation filters demo-only items in production mode
- Name: The navigation filtering function excludes demo-only navigation items when not in demo mode
- Type: unit
- Disposition: new
- Harness: TypeScript unit test harness (bun test)
- Preconditions: None (pure function).
- Actions: Call
getVisibleNavigation(false)andgetVisibleNavigation(true). - Expected outcome:
getVisibleNavigation(false)returns items that include "Runs" but NOT "Workflows" or "Insights".getVisibleNavigation(true)returns items that include "Runs", "Workflows", and "Insights". Source of truth: Plan Decision 4 -- Workflows and Insights aredemoOnly: true. - Interactions: None
Coverage summary
Covered areas
| Area | Tests | Coverage approach |
|---|---|---|
Demo /boards/runs endpoint (new) |
1, 10 | Server integration + browser |
Demo GET /runs/{id} shape fix |
2, 3 | Server integration |
Real /boards/runs RunListItem enrichment |
4, 5, 6 | Server integration |
Real /boards/runs board column mapping |
4, 5, 6 | Server integration |
Run detail loader using /runs/{id} |
14, 15, 16 | Browser + unit |
| Demo mode toggle | 13 | Browser |
| Navigation filtering by demo mode | 8, 11, 18 | Browser + unit |
| DemoModeProvider context | 17 | Unit |
| mapRunSummaryToRunItem | 15, 16 | Unit |
| Runs board in production mode | 7 | Browser |
| Settings page in production mode | 9 | Browser |
| Workflows page in demo mode | 12 | Browser |
Explicitly excluded (per agreed strategy)
| Area | Reason | Risk |
|---|---|---|
| Run stages tab rendering | Hidden in production mode; demo-only route. Unchanged code. | Low -- existing demo data path untouched. |
| Run files tab | Always hidden (endpoint does not exist). Tab removed from UI. | None. |
| Insights page deep interaction | Demo-only route. Unchanged code. Out of scope per "remove UI for removed functionality." | Low. |
| Workflow detail/diagram/runs pages | Demo-only routes. Static data, unchanged. | Low. |
| Run overview graph rendering (Graphviz) | Depends on @viz-js/viz WASM, hard to test in headless browser. Loader resilience tested via browser smoke. |
Medium -- if WASM fails to load, graph won't render, but the page will still load with "No workflow graph available" fallback. |
| Run billing tab | Unchanged, already works in both modes. | None. |
| SSE event streaming | Unchanged, not part of this task. | None. |
| Performance benchmarks | Low performance risk -- no new hot paths, board query is bounded by in-memory run count. | Low. |
Existing server test regressions from /boards/runs shape change |
Existing tests that assert status_reason/pending_control from /boards/runs will need updating. Covered by implementation plan Task 3 Step 5, verified by running full cargo nextest run -p fabro-server. |
Medium -- if missed, existing tests fail, caught immediately by CI. |