Repository navigation
Load the search palette's episodes on open, from a slim endpoint - #90
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou'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. View limit details
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. |
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>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
We want to merge
media-redesigninto 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:loadinLayout.astro) fetched/api/episodes/search.jsonwhile hydrating. That endpoint serialises every episode whole, show-notes HTML included, and the palette never readscontent.What changed
/api/palette.json, registered besidesearch.jsoninpackages/starpod/src/index.ts. It serves only what the palette matches on and renders:id,title,description,episodeNumber,episodeSlug,episodeThumbnail. Its type,PaletteEpisode, lives incomponents/palette-episodes.tswith a loader that fetches once per visit and retries after a failure.SearchDialogloads 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./api/episodes/search.jsonkeeps its shape and stays in the OpenAPI spec andllms.txt./api/palette.jsonis left out of both because it is internal to the palette and its shape may change.Verification
pnpm buildagainst a seeded local SQLite DB passed. With 263 episodes,api/palette.jsonis 183,135 bytes (61,284 gzipped).api/episodes/search.jsonis 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.search palette › loads its episodes only once it opens. It loads/aboutthen/, waits for hydration and network idle, and asserts that neither page requestedpalette.jsonorsearch.json. It then opens the palette with ⌘K, typescss, and asserts exactly one request, to/api/palette.json, and that the results match. All 24 tests intests/e2e/shell.spec.tspassed on chromium against a dev server on :4332, and so didtests/e2e/openapi.spec.ts.pnpm test:unit: 274/274 passed.pnpm lintis clean.🤖 Generated with Claude Code