Skip to content

feat(serve): variant selector + filtering in dashboard#179

Merged
avrabe merged 4 commits intomainfrom
feat/v041-serve-variant-filter
Apr 22, 2026
Merged

feat(serve): variant selector + filtering in dashboard#179
avrabe merged 4 commits intomainfrom
feat/v041-serve-variant-filter

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 22, 2026

Summary

Closes the UX gap reported as "in rivet serve how would I even see the variant, currently don't know or to filter".

  • Dropdown + banner: A variant selector appears in the context bar when the project has a feature model. Selecting a variant pushes ?variant=<name> and a "Filtered to variant: X (N of M artifacts shown)" banner with a Clear filter link is rendered above the content.
  • Variant-aware scoping: /stats, /artifacts, /coverage, /validate, /stpa, /matrix plus their /api/v1/* counterparts honor ?variant=NAME. Unknown variant names return 400 with a JSON error body on the API, and a 400 HTML page on the browser routes.
  • /variants overview: Table of every declared variant with PASS / FAIL solver status (inline error messages when FAIL), feature count, bound-artifact count, and quick-picks that jump into the scoped dashboard.
  • Graceful degradation: Projects without a feature model see no dropdown and the /variants page explains how to scaffold one. All existing flows are untouched.
  • Discovery convention: Looks for artifacts/feature-model.yaml + artifacts/bindings.yaml + artifacts/variants/*.yaml (also recognises feature_model.yaml and feature-bindings.yaml; also walks every path declared in rivet.yaml sources plus the project root).

Test plan

  • cargo test -p rivet-cli — all suites green (86 unit + 33 serve_integration including 7 new variant tests)
  • cargo clippy -p rivet-cli --all-targets -- -D warnings clean
  • Playwright serve-variant.spec.ts (8 tests) — runs in CI; local env does not have Playwright deps installed
  • Integration tests cover: 400 on bad variant, scope reduces counts, /variants lists all, banner appears, dropdown renders when model present
  • Manual: build completes, rivet validate still produces the same pre-existing diagnostics

Files of interest

  • rivet-cli/src/serve/variant.rs — discovery + resolution (new, ~300 LOC with tests)
  • rivet-cli/src/serve/mod.rs::build_variant_scope — owns the scoped Store + LinkGraph + filtered diagnostics
  • rivet-cli/src/serve/layout.rs — dropdown, banner, /variants overview renderer
  • rivet-cli/src/serve/views.rs::try_build_scope — single helper used by all scoped handlers
  • artifacts/feature-model.yaml + artifacts/variants/*.yaml — minimal fixtures so existing Playwright/integration harness can exercise the feature

🤖 Generated with Claude Code

avrabe and others added 4 commits April 22, 2026 07:38
Discover the project's feature model, binding, and variant YAML files
at load/reload time and hang them off AppState. Adds
build_variant_scope, which filters the in-memory Store, LinkGraph, and
cached diagnostics down to the artifacts bound to a variant's
effective features. Routes /stats, /artifacts, /coverage, /validate,
/stpa, /matrix plus the matching /api/v1 endpoints now honor an
optional ?variant=NAME query param and return 400 for unknown names.

A variant dropdown is rendered in the context bar whenever a feature
model is present; selecting one reloads the page with ?variant=X. A
"Filtered to variant: X (N of M)" banner appears above the content
with a Clear filter link; a small HTMX sync script keeps the banner
honest after cross-page swaps by reloading when the URL variant drifts
from the rendered banner.

Implements: REQ-007
Refs: REQ-045, FEAT-001

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Surface every declared variant in a dedicated nav entry (only shown
when the project has a feature model). Each row reports the solver
outcome (PASS/FAIL with inline error messages), the effective feature
count, the bound artifact count, and the fraction of the total store
the variant covers. Quick-pick links jump into the scoped dashboard,
coverage, or artifact listings for that variant.

When no feature model is configured, /variants renders a friendly
hint instead — the rest of the dashboard behaves identically for
non-variant projects.

Implements: REQ-007
Refs: REQ-045, FEAT-001

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a minimal feature-model / binding / two variant configs
(minimal-ci, dashboard-only) to the main project's artifacts/ tree so
the existing Playwright and serve_integration harnesses can exercise
the variant-filter UX without a bespoke test project. The fixtures
are parsed as "no artifacts" by the generic-yaml adapter so they
don't pollute the existing suite.

* Seven new serve_integration tests cover:
  - /api/v1/artifacts scoped down to 1 row for minimal-ci
  - /api/v1/artifacts?variant=bogus returns 400 + JSON error
  - /api/v1/stats and /api/v1/coverage honor the scope
  - /variants overview renders every declared variant with PASS status
  - Dashboard header renders the variant-selector dropdown
  - /stats?variant=... emits the "Filtered to variant" banner

* serve-variant.spec.ts (Playwright) covers the UI flow:
  dropdown population, selection pushing ?variant, Clear filter,
  reload-preserves-scope, /variants overview, unknown-variant 400,
  HTMX-driven nav triggering the sync reload.

Verifies: REQ-045
Refs: REQ-007, FEAT-001

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Replace useless format!() with .to_string() in the banner.
* Suppress result_large_err on try_build_scope — the `Err` arm is
  deliberately an already-built axum Response so handlers can early-
  return via `return resp` without re-rendering, and the Err path is
  the uncommon case.

Trace: skip

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avrabe avrabe force-pushed the feat/v041-serve-variant-filter branch from 8d3b01a to 7fd5a9b Compare April 22, 2026 06:04
@avrabe avrabe merged commit 22b936f into main Apr 22, 2026
@avrabe avrabe deleted the feat/v041-serve-variant-filter branch April 22, 2026 06:04
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rivet Criterion Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 7fd5a9b Previous: f46fb62 Ratio
traceability_matrix/1000 61408 ns/iter (± 1081) 44392 ns/iter (± 1656) 1.38

This comment was automatically generated by workflow using github-action-benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant