feat(search): client side fts - #22
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
◈ PR Lens
Architecture 17 components touched across 6 lanes. Inside the changed components — 3 viewsComponent view — Client-Side Search Engine Browser-side full-text search running sqlite-wasm and FTS5 inside a Web Worker, hydrated from immutable CDN-cached snapshot artifacts. Component view — Build-Time Snapshot & Cold-Start Seeding Nuxt build module that verifies commit tree integrity, generates pre-parsed content snapshots, and stores them in Nitro server assets for instant cold starts. Component view — Revalidation & Invalidation Pipeline Webhook handler that diffs incoming commit changes against live manifests, warms new commit search artifacts, and purges affected ISR edge cache routes. Data flow
The other flows — 2 sequences
Drill down
|
Summary
Move search to client-side full-text search: a web worker owns a browser
comark-contentinstance (sqlite-wasm FTS5) hydrated from per-commit snapshot artifacts, replacing thesearch-sectionsendpoint that shipped a flat section list on every page hydration.Built on comarkdown/comark-content#109 (persisted snapshot & manifest artifacts): the webhook parses once per content push and update the cached artifactfs so consumers reuse the cached version.
How it works
Client.
useSearchpins hydration to the production commit via the new/api/content/headendpoint, then a worker fetches/api/content/blob/<sha>/manifest.jsonand/snapshot/content.json(SHA-pinned, immutable,isr: truecached at the CDN forever) and builds the FTS index through the plugin's cache-first path.Queries run in the worker: BM25 ranking, heading-weighted scores, snippets.
Server.
The webhook's cache warm becomes
warmSnapshot(): one full parse per push, which persists the snapshot artifact into the per-SHA Runtime Cache namespace. The first request on a new SHA is a single cache read, then ISR pins the URL; old SHA URLs simply become unreachable, so search needs no purges. Head-of-branch/blob/<sha>requests reuse the shared prod instance instead of minting a duplicate preview instance. Thesearch-sectionsplugin, endpoint, route rules, and per-page payload are deleted.Debug mode
On by default in dev; in production via
?debug=search. Both threads log onto one page-relative timeline — fixed-width lines showing stage durations, decoded/wire sizes, and result counts:Next steps to discuss
Extract the search stack into a plugin — useful for nuxt.com (migration on comark-content in progress).
Version-aware search — the hydration URLs are already per-SHA (
/api/content/blob/<sha>/…), so searching any historical version is just pointing the worker at that commit's artifacts, which the/blob/<sha>routes already serve and self-heal on first request. Would pair with the existing version-history UI; main open question is worker lifecycle when switching versions (one instance per SHA vs. reset + rehydrate).