Skip to content

Fix dashboard data correctness + prebuild embedded SPA#148

Open
Exelord wants to merge 1 commit into
mainfrom
claude/dashboard-fixes
Open

Fix dashboard data correctness + prebuild embedded SPA#148
Exelord wants to merge 1 commit into
mainfrom
claude/dashboard-fixes

Conversation

@Exelord

@Exelord Exelord commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

User: "your testing needs to be wrong or holes. all data is wrong, works so so, not useful things. and prebuild cloud."

They were right. The previous PRs (#143#147) "PASS"ed verification because I ran them against /tmp/uitestN workspaces with 2 runs — enough for the app to mount, not enough to surface real data bugs. Driving the dashboard against this repo's actual cache.db (242 runs, 64 entries, 2 projects, 8 tasks) surfaced four real bugs that hit any non-trivial workspace.

Bugs the broader audit found

  1. TaskDetail + ProjectDetail were completely broken on any id containing # or / (i.e. every real id like @vzn/vx#test). useParams() from @solidjs/router returns the raw URL-encoded segment; my api layer then re-encoded it, producing %2540vzn%252Fvx%2523test on the wire. Server decoded once and still couldn't split on #. Fix: decode at the page boundary, encode only at the api layer.

  2. Cache footprint Treemap was a blank black box. The Treemap renders SVG <rect>; bg-chart-N (background-color) does nothing on SVG. Switched callers to fill-chart-N. The default fallback inside the component also flipped to fill-.

  3. UnoCSS safelist was missing the runtime chart palette. paletteFor() generates bg-chart-1..bg-chart-8 at runtime via template literals; UnoCSS's static analyzer can't see them, so the rules were absent. Added bg-/text-/stroke-/fill-/border-chart-{1..8} to the safelist.

  4. Overview hero cards defaulted to 24h windows. On a typical workspace where the last run was >24h ago — which describes most workspaces most of the time — every hero showed "Time saved <1ms / 0 hits / 0% rate" despite plenty of cached data. Switched the hero to lifetime totals (always have signal); widened the activity chart to 30 days with day buckets.

Plus

  • Parallelism chart x-axis was synthetic indices reading newest-to-oldest (#49 → #0). Replaced with real startedAt timestamps via formatDate.
  • getParallelismHistory now filters wall < 50 ms invocations — sub-50 ms cpu/wall ratios are measurement noise and were polluting the average down to ~0.5×.

Prebuilt embedded SPA

User: "prebuild cloud" — interpreted as: a fresh checkout should be able to bun build --compile without first installing 700 npm packages just to build the SPA.

  • .gitignore now exempts !apps/ui/dist/
  • apps/ui/dist/index.html (130 KB single self-contained HTML) is committed
  • The build.ui vx task still regenerates it on UI changes; binaries still embed the freshest version via with { type: 'file' }
  • But a checkout that just runs bun build --compile src/bin.ts no longer fails on a missing import

Verification (the protocol that should have been used from day 1)

Drove a Playwright Chromium against the compiled dist/vx-linux-x64 running against this repo's real .vx/cache/cache.dbnot a scratch workspace. Captured all 10 pages (Overview, Projects, Project detail for @vzn/vx, Tasks, three Task detail pages — #test, #lint.oxlint, #build.ui, Bottlenecks, Trends, Cache). Zero console / page / request errors after the fixes. Treemap renders. Hero shows lifetime totals. Task/Project detail pages work.

Test plan

  • bun src/bin.ts run ci — full gate green (934 tests, 24 metrics tests)
  • Playwright audit against real cache.db: 10 pages, 0 errors
  • TaskDetail loads for @vzn/vx#test, @vzn/vx#lint.oxlint, @vzn/vx#build.ui
  • ProjectDetail loads for @vzn/vx
  • Treemap renders with project-colored rectangles
  • HBar leaderboard bars colored per project
  • Compiled binary serves embedded SPA with prebuilt dist

Generated by Claude Code

Audit driving Playwright against this repo's actual cache.db (242 runs,
64 entries, 2 projects, 8 tasks) — instead of the 2-run scratch repo
the previous verifications used — surfaced four real bugs the user hit:

1. TaskDetail + ProjectDetail were completely broken on any id
   containing # or /. useParams() in @solidjs/router returns the raw
   URL-encoded segment; we then re-encoded it in the api layer, producing
   %2540vzn%252Fvx%2523test on the wire — server decoded once and still
   couldn't split on '#'. Decode at the page boundary, encode only at
   the api layer.

2. Cache footprint Treemap rendered as a blank black box. The Treemap
   uses SVG <rect>; bg-chart-N (background-color) does nothing on SVG.
   Switch Treemap callers to fill-chart-N. The default fallback inside
   the component also flipped to fill-.

3. UnoCSS safelist wasn't aware of the runtime-generated bg-chart-1..8
   / text-chart-* / stroke-chart-* / fill-chart-* used by paletteFor().
   The static analyzer couldn't see template-literal classes. Added
   them to the safelist.

4. Overview hero cards defaulted to 24h windows. On workspaces whose
   last run was >24h ago — which is most of them — that showed "Time
   saved <1ms / 0 cache hits / 0% hit rate" despite plenty of cached
   data. Switched the hero to lifetime totals (always have signal) and
   widened the activity chart to 30 days with day buckets.

Other fixes the audit produced:
- Parallelism chart x-axis was synthetic indices reading newest-to-oldest
  ("#49 → #0"). Use real startedAt timestamps with formatDate.
- getParallelismHistory now filters wall < 50ms invocations — sub-50ms
  cpu/wall ratios are measurement noise and polluted the avg.

Prebuild embedded SPA so a fresh `bun build --compile` works without a
SPA build step (user ask: "prebuild cloud"):
- Add !apps/ui/dist/ to .gitignore
- Commit apps/ui/dist/index.html (130 KB single-file)

apps/ui/dist/index.html is regenerated by the build.ui task and embedded
via `with { type: 'file' }`. The previously-required build sequence
(install → build.ui → build.bun.*) still works; now a checkout that just
runs build.bun.* finds the dist already present.

Full CI gate green. Verified end-to-end with Playwright + the real cache.db.
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.

2 participants