Skip to content

SSR demo chunks for guest first page view#67

Merged
suguanYang merged 1 commit into
stagingfrom
feat/wangbinqi/ssr-demo-chunks
May 13, 2026
Merged

SSR demo chunks for guest first page view#67
suguanYang merged 1 commit into
stagingfrom
feat/wangbinqi/ssr-demo-chunks

Conversation

@suguanYang
Copy link
Copy Markdown
Contributor

@suguanYang suguanYang commented May 13, 2026

Summary

Closes #66

Guest users previously saw an empty chunks panel on first visit while demo data was loaded client-side. This loads the first demo source's parsed chunks during SSR so they appear immediately — no loading spinner, no delay.

Caching

Uses unstable_cache from Next.js with revalidate: false so the demo chunk data is cached across all users. The Knowhere API demo chunks endpoint is called once, then the parsed result is served from memory for every subsequent request until the server restarts.

The prefetch is best-effort — if the API is unavailable during SSR, the client gracefully falls back to loading chunks on demand.

Changes

  • src/domains/workspace/initial-state.ts — In the guest path, fetches the first demo source's chunks via knowhereDemoApi.fetchChunkPage(), converts them to ParsedChunkView, and caches the result with unstable_cache. Passes as initialPrefetchedChunksBySourceId in the shell initial state.
  • src/components/workspace-shell.tsx — Accepts initialPrefetchedChunksBySourceId prop and passes it directly to useWorkspaceCitationFocus, which already supports seeding via initialPrefetchedChunksBySourceId.

Test plan

  • Build passes
  • Guest visit: chunks panel shows parsed content immediately on page load
  • Guest: switching demo sources still works (subsequent sources use client-side API)
  • Guest: citation clicks still navigate correctly
  • Authenticated: existing flow unchanged

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
knowhere-notebook-staging Ready Ready Preview, Comment May 13, 2026 10:49am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
knowhere-notebook Ignored Ignored Preview May 13, 2026 10:49am

Request Review

Load the first demo source's parsed chunks during the server render so
guest users see content immediately — no loading spinner on first visit.

Uses unstable_cache with revalidate: false so the fetched chunks are
shared across all users. The chunk prefetch is best-effort; if it fails,
the client falls back to loading chunks on demand.
@suguanYang suguanYang force-pushed the feat/wangbinqi/ssr-demo-chunks branch from d936789 to 40b3af0 Compare May 13, 2026 10:47
@suguanYang suguanYang merged commit 514384d into staging May 13, 2026
6 of 7 checks passed
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.

1 participant