feat(web): build dist on demand for prod --web + end-to-end CI smoke (#1486) - #1497
Conversation
…1486) Prod `mcp-inspector --web` serves static assets from clients/web/dist, which only exists after a build. In a fresh checkout it was absent and the prod path served a broken page (ENOENT on index.html); the launcher smoke test only covered --help, so this path was unverified in CI. - ensure-web-build.ts: build dist on demand (vite build via build:client) when missing, or exit with an actionable error if the build can't run. - run-web.ts: invoke ensureWebBuild before startHonoServer in the prod path (--dev runs Vite directly and skips it). - scripts/smoke-web.mjs + smoke:web: start --web against built dist and assert GET / returns 200 with the injected __INSPECTOR_API_TOKEN__. Wired into validate:launcher and a new CI step. - Docs: launcher README + AGENTS.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@claude review |
|
Claude finished @cliffhall's task in 1m 42s —— View job Code Review — PR #1497
Solid, well-scoped change. The build-on-demand seam is clean, the actionable-error path is exactly the right call (no silent broken page), and the testing is thorough — injected seams for logic plus default-dependency tests so the real Things I like
Minor suggestions (non-blocking)
Things I verified
Nice work — the suggestions above are all polish, nothing needs to change to merge. |
Address PR #1497 review: - runViteBuild now logs result.error.message (e.g. ENOENT when npm isn't on PATH) before returning a null status, so the spawn-failure cause surfaces instead of only the generic actionable error. The build seam gains a `log` param; added a test covering the ENOENT path. - Reword scripts/smoke-web.mjs header so it no longer implies the readiness wait covers a cold build-on-demand vite build (it's sized for a pre-built dist, which validate/CI guarantee). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks for the review! Addressed both actionable suggestions in b1b39bc: 1. 2. Smoke timeout vs. cold build comment — fixed. Reworded the 3. |
|
@claude review |
|
Claude finished @cliffhall's task in 40s —— View job Re-review — PR #1497
Both actionable suggestions from the prior review are addressed cleanly in Verified the follow-ups
Other things I re-checked
Nice, tight follow-up. Nothing blocking. |
|
Thanks for the re-review — glad the follow-ups landed cleanly. No further changes; this is ready to merge. |
Closes #1486.
Problem
Prod
mcp-inspector --web(no--dev) serves static assets fromclients/web/dist/, which only exists afternpm run build. In a fresh dev checkoutdist/is absent and the prod path served a broken page (serveIndexHtmlENOENTonindex.html). The launcher smoke test only checked--help/--cli --help/--tui --help, so the prod web path was never exercised in CI.Changes
Build on demand (or fail clearly):
clients/web/server/ensure-web-build.ts(new) — whendist/index.htmlis missing, builds it on demand vianpm run build:client(vite build). If the build can't run (e.g. a stripped published install with no dev deps), throws an actionable error pointing atnpm run build/--devinstead of serving a broken page.run-web.ts— callsensureWebBuild()in the prod path beforestartHonoServer;--devskips it (Vite serves directly).clients/web/package.json— addedbuild:client(vite build, assets-only).End-to-end CI coverage:
scripts/smoke-web.mjs+smoke:web(new) — startsmcp-inspector --webagainst builtdist, assertsGET /returns HTTP 200 with the injected__INSPECTOR_API_TOKEN__, then shuts down.validate:launcherand a new.github/workflows/main.ymlstep.Docs: launcher README ("Production web build" section) +
AGENTS.md.Acceptance criteria
--webworks after build-on-demand, or fails with a clear, actionable error whendist/is missing (no silent broken page).dist/(servesindex.html200 with injected token).AGENTS.md/ launcher README.Testing
ensure-web-build.test.ts(8 tests) covers injected seams and real defaults (existsSync/spawnSync/console.log).run-web.test.ts: verifies the helper is invoked in prod, skipped in--dev, and that a build failure exits with the actionable error.smoke:webend-to-end, and confirmed build-on-demand by removingdistand watching--webauto-runvite buildand serve 200.🤖 Generated with Claude Code