Skip to content

Load the search palette's episodes on open, from a slim endpoint - #90

Merged
RobbieTheWagner merged 2 commits into
media-redesignfrom
fix/palette-payload
Nov 30, 2026
Merged

RobbieTheWagner merged 2 commits into
media-redesignfrom
fix/palette-payload

Conversation

@RobbieTheWagner

Copy link
Copy Markdown
Member

Why

We want to merge media-redesign into main with confidence. The review found that every page load downloads about 2 MB for the search palette before anyone opens it. The palette island (client:load in Layout.astro) fetched /api/episodes/search.json while hydrating. That endpoint serialises every episode whole, show-notes HTML included, and the palette never reads content.

What changed

  • New prerendered endpoint /api/palette.json, registered beside search.json in packages/starpod/src/index.ts. It serves only what the palette matches on and renders: id, title, description, episodeNumber, episodeSlug, episodeThumbnail. Its type, PaletteEpisode, lives in components/palette-episodes.ts with a loader that fetches once per visit and retries after a failure.
  • SearchDialog loads episodes when it opens (click, ⌘K, or tab), not on hydration. The search triggers prefetch on pointer enter or focus, so the data is usually there by the time the palette opens.
  • A query typed before the episodes land is matched once they arrive. Until then the empty state reads "Searching..." rather than "Nothing found".
  • Matching is unchanged. The open and close animation is unchanged.
  • /api/episodes/search.json keeps its shape and stays in the OpenAPI spec and llms.txt. /api/palette.json is left out of both because it is internal to the palette and its shape may change.

Verification

  • pnpm build against a seeded local SQLite DB passed. With 263 episodes, api/palette.json is 183,135 bytes (61,284 gzipped). api/episodes/search.json is 2,039,361 bytes (351,824 gzipped). That is about 9% of the old size. Most of what remains is the descriptions, which matching needs.
  • New e2e test search palette › loads its episodes only once it opens. It loads /about then /, waits for hydration and network idle, and asserts that neither page requested palette.json or search.json. It then opens the palette with ⌘K, types css, and asserts exactly one request, to /api/palette.json, and that the results match. All 24 tests in tests/e2e/shell.spec.ts passed on chromium against a dev server on :4332, and so did tests/e2e/openapi.spec.ts.
  • New unit test: nothing is fetched while the palette is closed. A query typed before the data resolves shows "Searching..." and then the matching episode. It fails on the old code. pnpm test:unit: 274/274 passed. pnpm lint is clean.

🤖 Generated with Claude Code

The palette fetched /api/episodes/search.json on every page as it
hydrated: about 2 MB, most of it show-notes HTML the palette never reads.
It now fetches /api/palette.json (only the fields it matches on and
shows) the first time it opens, or when a search trigger is pointed at or
focused. A query typed before the episodes land is answered once they do,
with "Searching..." in place of "Nothing found" meanwhile. The public
search.json is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
starpod Ready Ready Preview Nov 30, 2026 3:37pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 49cc054 and 7bde971.

Files selected for processing: 7

  • packages/starpod/src/components/SearchButton.tsx
  • packages/starpod/src/components/SearchDialog.tsx
  • packages/starpod/src/components/palette-episodes.ts
  • packages/starpod/src/index.ts
  • packages/starpod/src/pages/api/palette.json.ts
  • tests/e2e/shell.spec.ts
  • tests/unit/SearchDialog.test.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

An error status with a JSON body would otherwise be stored as the
episode list and break the palette on its next render. Throwing clears
the cached promise, so the next open asks again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobbieTheWagner
RobbieTheWagner merged commit 9765576 into media-redesign Nov 30, 2026
8 of 9 checks passed

This branch was successfully deployed

1 active deployment
Preview — 7bde9712 Deployed Nov 30, 2026 by vercel[bot]
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