refactor(viewer): port to Solid + TypeScript with Vite single-file build#11
Conversation
The viewer moves from inline vanilla JS in viewer/index.html to Solid components in viewer/src/, typed against server/types.ts. Vite + vite-plugin-singlefile builds it into one self-contained viewer/dist/index.html, so both runtimes keep serving the viewer as a single in-memory document (Node readFile, Workers Text-rule import) — no static-asset routes, and withOrigin rewriting still applies. - npm run build:viewer builds; npm run dev adds a Vite watch build - typecheck gains a third tsc program (tsconfig.viewer.json) - e2e builds the viewer via Playwright global setup; suite unchanged - npm package ships viewer/dist/ instead of viewer/ source https://claude.ai/code/session_01ApwZm1DNZoCQTJHha19thS
… the Solid viewer main changed the old inline-JS viewer this branch replaced; the conflict resolution re-implements both changes in viewer/src/: - optimistic comment echo (pending until POST confirms, deduped against the SSE refetch by id), failed sends restore the input with a toast - new snippets only auto-scroll near the bottom; otherwise the "new snippet" pill offers the jump - unread activity badges the tab title; returning to the tab clears the selected session; hidden-tab activity counts as away - SSE reconnect resyncs the session list, snippets, and comments - sidebar collapses into an off-canvas drawer behind a top bar below 700px; hover-only actions stay visible on narrow/touch screens All 10 e2e tests (5 new from main) pass on chromium. https://claude.ai/code/session_01ApwZm1DNZoCQTJHha19thS
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
What
Rewrites the viewer from ~390 lines of inline vanilla JS in
viewer/index.htmlto Solid + TypeScript components inviewer/src/, typed againstserver/types.ts.How it keeps the serving model intact
Vite +
vite-plugin-singlefilebuilds everything into one self-containedviewer/dist/index.html, so the server keeps serving the viewer as a single in-memory document on both runtimes:server/index.tsreads the built file at boot (friendly error pointing atnpm run build:viewerif missing)workers/index.tsimports it via the existing**/*.htmlText rulewithOriginURL rewriting unchanged — the onboardinglocalhost:4242literals survive minification, verified in the built bundleBehavior parity
All DOM structure, class names, and flows are preserved (the e2e suite is unchanged and passes): SSE-driven cards, version select, iframe
srconly changes when the version does (no sandbox reloads on unrelated refetches), postMessage bridge, session thread last in the stream, unread dots, contenteditable rename.Two small improvements fall out naturally:
Build wiring
npm run devruns a Vite watch build alongside the servertypecheckadds a third tsc program (tsconfig.viewer.json: DOM lib, solid JSX)npm packbuilds the viewer in prepack; package shipsviewer/dist/instead of viewer source (verified vianpm pack --dry-run)deploy/dev:cloudbuild the viewer firstValidation
server/snippetPage.ts, untouched here, but the e2e CI job is the real confirmationhttps://claude.ai/code/session_01ApwZm1DNZoCQTJHha19thS
Generated by Claude Code