feat(vite): whole-project analysis in the dev dashboard - #152
Conversation
buildHtmlDocument gains an optional third argument
(opts?: { routeBadges?: Record<string, 'measured' | 'static'> }) that renders a
provenance badge on route headings, for the dev dashboard's measured/static
distinction. Unknown badge values are dropped, and output is byte-identical to
before when the option is omitted (pinned by test). formatHtmlReport (the CLI
--reporter html path) is unchanged.
The live dashboard (svelteVitals({ ui: true })) now integrates the CLI's
whole-project static analysis (analyzeProject from svelte-vitals, loaded via
dynamic import inside the dev-only ui plugin so build mode never touches it):
- one async analysis at dev-server startup (never blocking), showing all
routes and all categories with a real project Health before any page visit
- debounced (500ms) re-analysis on relevant source changes via server.watcher,
with mid-run changes coalescing into a single follow-up run
- the store gains a static layer; live (rendered) results replace static
results per route by the payload's rule-id set, while site-wide findings and
unvisited routes keep the static result
- route headings carry a measured/static provenance badge (core's routeBadges)
- analysis failures warn and fall back to the previous live-only behavior
Design doc: docs/superpowers/specs/2026-07-08-dev-dashboard-whole-project-design.md
(plan 021).
|
Caution Review failedFailed to post review comments. GitHub was unavailable or timed out while CodeRabbit was posting the review. Please request a new review later if the pull request still needs one. Use ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (22)
|
| Layer / File(s) | Summary |
|---|---|
Core HTML reporter badge support packages/core/src/reporter/html.ts, packages/core/test/html-report.test.ts |
buildHtmlDocument/renderRoutes gain optional routeBadges, render clamped/escaped badge markup and CSS, with tests confirming byte-identical output when omitted. |
Layered findings store packages/vite/src/ui/store.ts, packages/vite/test/ui-store.test.ts |
Store now tracks static and live layers separately with setStatic, badges, composeSnapshot, and composeBadges merging live results over static per route. |
Analysis runner packages/vite/src/ui/analysis.ts, packages/vite/test/ui-analysis.test.ts |
createAnalysisRunner lazily imports analyzeProject, debounces notifyChange, coalesces in-flight runs, and reports results/errors via callbacks. |
Plugin/middleware wiring packages/vite/src/plugin.ts, packages/vite/src/ui/middleware.ts, packages/vite/src/ui/serve.ts, packages/vite/package.json, packages/vite/test/ui-middleware.test.ts, packages/vite/test/ui-plugin.test.ts, packages/vite/test/ui-watch-relevance.test.ts |
configureServer creates the store and runner, filters watcher events via isRelevant, stops runner on shutdown, and forwards the store/badges through installUiMiddleware/renderDashboard. |
Fixture and integration tests packages/vite/test/fixtures/basic-project/*, packages/vite/test/ui-integration.test.ts |
Adds a SvelteKit fixture project and integration tests validating static analysis, live ingest override, and badge transitions end-to-end. |
Docs and design spec .changeset/dev-dashboard-whole-project.md, docs/src/content/docs/guides/dev-overlay.md, docs/src/content/docs/ja/guides/dev-overlay.md, docs/superpowers/specs/2026-07-08-dev-dashboard-whole-project-design.md |
Updates changelog and dev-overlay guides (EN/JA) and adds a design spec describing the whole-project analysis architecture and merge rules. |
Estimated code review effort: 4 (Complex) | ~60 minutes
Sequence Diagram(s)
sequenceDiagram
participant Vite as ViteDevServer
participant Plugin as configureServer
participant Runner as AnalysisRunner
participant Store as FindingsStore
participant Middleware as installUiMiddleware/Dashboard
Vite->>Plugin: configureServer(server)
Plugin->>Store: createStore()
Plugin->>Runner: createAnalysisRunner(...)
Plugin->>Middleware: installUiMiddleware(server, config, store)
Runner->>Store: setStatic(initial results)
Vite->>Plugin: watcher 'all' event (relevant file)
Plugin->>Runner: notifyChange(file)
Runner->>Runner: debounce & re-run analyzeProject
Runner->>Store: setStatic(updated results)
Middleware->>Store: set(route, liveResults) on page visit
Middleware->>Store: snapshot() / badges()
Middleware-->>Vite: renderDashboard(mergedResults, badges)
Possibly related PRs
- oekazuma/svelte-vitals#47: Introduces the
buildHtmlDocument/renderRoutescore HTML reporter that this PR extends withrouteBadges. - oekazuma/svelte-vitals#49: Builds the
svelteVitals({ ui: true })live dashboard (store/middleware/serve) that this PR extends with static analysis and provenance badges.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main change: whole-project analysis in the Vite dev dashboard. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Resolves conflicts with PR #150 (core version drift visibility): coreVersion threading and the routeBadges/store integration are combined — renderDashboard and buildHtmlDocument accept both, installUiMiddleware takes (server, config, version, store, coreVersion?). Dropped the now-obsolete docs paragraph claiming component-scoped rules never appear in the dev overlay (the whole-project static layer now surfaces them); kept the new Version drift section (en/ja).
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Implements plan
plans/021-dev-dashboard-whole-project.md(design doc included in this PR:docs/superpowers/specs/2026-07-08-dev-dashboard-whole-project-design.md).The live dashboard (
svelteVitals({ ui: true })) previously showed only routes you had physically visited, covered only SEO<head>rules, and computed Health over visited routes — the deliberate v1 boundaries of the original live-UI design. This PR integrates the CLI's whole-project static analysis into the dev server, so the dashboard now shows all routes and all five categories with a real project Health from the momentvite devstarts:configureServerkicks offanalyzeProjectasynchronously (never blocking dev-server startup); results land in a new static layer of the findings store and fan out over the existing SSE channel.server.watcherevents undersrc/,static/, or onsvelte.config.*/svelte-vitals.config.*(excludingnode_modules/.svelte-kit/build/dist) trigger a debounced (500 ms) re-run; changes arriving mid-run coalesce into exactly one follow-up.measured(live) vsstatic, via a new optionalrouteBadgesargument on core'sbuildHtmlDocument. With the option omitted the output is byte-identical (pinned by test), so the CLI's--reporter htmlis untouched.Architecture notes
@svelte-vitals/vitenow depends onsvelte-vitals(workspace) — the same precedent as@svelte-vitals/mcp, which already importsanalyzeProject. The import is a dynamic import inside the dev-only ui plugin (grepfor a static import is a done criterion), so build-mode usage loads none of the CLI package.composeSnapshot/composeBadgesfunctions.console.warnand the dashboard falls back to today's live-only behavior.runner.stop()rides the existing http-server close cleanup.Verification
pnpm typecheck,pnpm test(947 tests: core 382 / cli 437 / vite 115 / mcp 13),pnpm lint— all greenanalyzeProject(through the real dynamic import) against a new SvelteKit fixture: unvisited routes and multiple categories appear with zero page visits; a live ingest replaces exactly the matching rule ids on that route and flips its badge; unvisited/site findings are deep-equal untouched@svelte-vitals/viteand@svelte-vitals/core🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
vite devstarts, then updates in place as you work.Bug Fixes
Documentation