vx serve --ui: bundle SPA, delete vx insights#145
Merged
Conversation
- apps/insights: vite 6→8, unocss 0.65→66 (calver renumber), Solid Router 0.15→0.16. SPA builds clean (17.5 KB gzipped JS). - apps/docs: astro 6.4.6→6.4.8, mermaid 11.6→11.15, sharp 0.34→0.35, unist-util-visit 5.0→5.1. - root: @anthropic-ai/sandbox-runtime 0.0.51→0.0.56, @types/bun 1.3.0→1.3.14, oxfmt 0.48→0.55, oxlint 1.63→1.70, oxlint-tsgolint 0.22→0.23. Lint + 923 tests green.
The SPA was a placeholder — one Overview list, no per-task drilldown, nothing about cache, no charts. Now it's a real dashboard. New SQL backed by /v1/* HTTP routes: - /v1/top-tasks — biggest time-burners (non-hit success totals) - /v1/failures — recent failed runs - /v1/cache/breakdown — bytes per project - /v1/cache/savings — estimated time the cache saved you (24h + all-time) - /v1/cache/entries — full entries listing, sortable by size/age/duration - /v1/tasks/:id — full per-task aggregate + 100 recent runs + latest cache entry Extended TaskHistoryRow with min/avg/max/total/lastSeenAt. RunSummaryRow now carries cpuMs + peakRssBytes (the columns were always there, just not surfaced). SPA pages: - Overview: 4-card hero (time saved 24h, hit rate, entries, total time saved), Top time-burners + Recent failures side-by-side, cache breakdown with bars, recent invocations. - Tasks (new): sortable table over every (project, task) — runs, success rate, hit rate, avg, p50, p99, total time, last run; substring filter; failure-mode dot. - TaskDetail (new): 10 stats (runs, success/hit rate, failure mode, last run, min/avg/p50/p99/max), Sparkline of last 100 durations with cache hits dotted in cyan, latest cache entry card (hash/size/exec/duration/ created/accessed), full recent-run table with CPU + peak RSS + hash. - Cache (new): stat cards, by-project breakdown, sortable entries table (largest/newest/recently-accessed/slowest). New Sparkline component — pure inline SVG, no chart lib. Tests: 6 new query tests (16 total); full CI gate green (946 tests). SPA bundle: 17.5 KB → 21.8 KB gzipped (still tiny).
The vx insights command was just spawning vx serve + Vite. Cut it: vx serve --ui serves the prebuilt SPA at /, alongside the same JSON API + WS + SSE. One process, one stack. - startServe gains a uiDir option; the fetch handler serves files from it with proper MIME, no-store for HTML, immutable cache for Vite's hashed assets, SPA fallback to index.html for hash-router routes. Containment check via path.resolve. - parseServeArgs adds --ui and --open. resolveUiDist() points at <vx-checkout>/apps/insights/dist (VX_INSIGHTS_DIST overrides). --open shells out to xdg-open / open / cmd start (best effort). - Delete src/cli/insights.ts, tests/insights.test.ts, the insights case in src/cli/index.ts, parseInsightsArgs export. - Add 12 serve tests covering --ui static serving (MIME, cache headers, SPA fallback, /v1/* still wins, traversal), --ui-off path, parseServeArgs. Docs: - Rewrite guides/insights.md around vx serve --ui --open - README + introduction + cli.md + docs/cli.md + sidebar updated - 943 tests pass (was 940). Lint clean.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
User: "Maybe we don't even need insight if it spawns a server. Maybe we just need —ui flag" → "Vx serve should serve it when flag passed".
vx insightswas just spawningvx serve+ a Vite dev server. Cut it.vx serve --uinow serves the prebuilt SPA at/alongside the same JSON API + WS + SSE.What changed
startServegains auiDiroption. The fetch handler serves files from it with proper MIME,no-storefor HTML, immutable cache for Vite's hashed assets, SPA fallback toindex.htmlfor hash-router routes.path.resolvecontainment check guards against traversal.parseServeArgs(renamed fromparsePort) handles--uiand--open.resolveUiDist()points at<vx-checkout>/apps/insights/dist(VX_INSIGHTS_DISToverrides).--openshells out toxdg-open/open/cmd startas best effort.vx insights—src/cli/insights.ts,tests/insights.test.ts, theinsightscase insrc/cli/index.ts, and theparseInsightsArgsre-export. Help text updated.Docs
guides/insights.mdaroundvx serve --ui --opendocs/cli.md+apps/docs/.../cli.md+ Astro sidebar updatedTest plan
bun src/bin.ts run ci— full gate green (12 serve tests, 943 total)/v1/*still wins over the static handler,--uioff keeps the barevx serveresponse, parseServeArgs (port/ui/open combinations, errors)One-liner UX
→ unified backend boots, SPA serves at
/, browser opens.Ctrl-Cstops it.Generated by Claude Code