Repository navigation
perf(web): load home before the rest of the app shell - #2289
Conversation
GET /api/v2/home/layout takes optional include_items (0-4) and image_size.
The response (new HomeLayout schema) carries included_sections: the first
rows' items, built by the same code as GET /api/v2/home/sections/{id}/items.
Rows not ready within 300 ms, or whose fetch fails, are left out for the
client to fetch on its own. Without include_items the endpoint costs what it
did before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Home's layout request starts as soon as the session token is refreshed, beside the account read, and asks for the first three rows' items so they paint without a second round trip. Single-key effective-settings reads started in the same tick share one request. The admin activity indicator and the unread-notification badge wait until Home's first rows load (at most 1.5 s), so their requests no longer queue ahead of Home's on HTTP/1.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
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 34 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. Comment |
|
Rows and badges now appear at different times, even if the loaded page looks unchanged. Please add a before/after startup recording showing Home rows and the delayed badges at desktop and phone widths (or show mobile is unaffected), using the same data and naming the builds. The timing table includes #2288; keep that distinction clear in the captures too. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38bfb2fef3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const section of layout.included_sections) { | ||
| queryClient.setQueryData<HomeSectionItemsResponse>(sectionKeys.homeItems(section.id), { | ||
| section: sectionFromV2(section), | ||
| }); |
There was a problem hiding this comment.
Propagate included-row updates to the mounted Home page
When the layout refetches while Home is already mounted—for example, after its 10-minute stale time elapses and the window regains focus—these calls refresh the row caches, but Home renders from its separate loadedSections state. That state is only rebuilt when the layout structure or refresh signal changes, so an unchanged layout leaves the first three rows showing their old items even though their caches have just been marked fresh; completedIds also prevents the row loader from fetching them again. Update the mounted Home state when included rows arrive, or make Home observe those cache entries.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Visible behavior doesn't change here. Before this PR, a background layout refetch didn't update a mounted Home's rows either: Home rebuilds loadedSections only when the layout's cacheResetKey or section list changes, and completedIds keeps rows it already has. This PR only adds fresher entries to the row caches. Wherever Home marks a row complete from cache freshness (the reset effect), it reads that row's items from the same cache, so it can't skip a fetch and keep showing older items. A real refresh still invalidates the rows first (invalidateMediaSurfaceQueries), so it goes to the network.
setQueryData created the seeded row entries with the client's default 10-minute gcTime, and Home never refetches a fresh row to raise it, so the first rows were evicted before the later ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The 300 ms budget for included rows now covers each row's card lookups (user states, overlays, playable targets, artwork), not just its fetch, so a slow lookup leaves the row out instead of delaying the layout. - A caller waiting on a shared resolved-list rebuild stops waiting when its context ends; the rebuild keeps running detached and fills the cache. A panic in a detached build becomes an error. - Add GET /api/v2/home/capabilities (getHomeCapabilities) with include_items_max, so a client sends include_items only to a server that accepts it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…into perf/web-home-first-load
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fe7f822c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…into perf/web-home-first-load
…g key - A server that predates include_items (an older node during a rolling upgrade) or allows fewer rows answers 422; Home then reads the layout alone and loads every row itself. - An unknown setting key fails the whole effective-settings read with 422 and a query.keys error, not 404, so the per-caller retry never ran and one unknown key failed every batched read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…into perf/web-home-first-load
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: N/A
Validation tasks: changes #1142 C1 (Home loads the same rows sooner; not yet run)
On the web, Home's first row waits behind four requests in a row: token refresh, the account read, the layout, then the row's items. The layout itself waits until the account read finishes, and on a plain-HTTP server it also queues behind about fifteen startup requests from the app shell, because the browser opens at most six connections per server. On a 40 ms connection the first row appeared about 1.1 s after navigation. This change starts Home's requests earlier and sends fewer of them.
Uses
include_itemsonGET /api/v2/home/layout, added in #2287.Approach
/with a stored profile, the layout request starts right after the token refresh, beside the account read. Its request and token only need what the refresh already restored.include_items=3and writes each included row into that row's item cache before the layout resolves, so Home treats those rows as loaded and doesn't request them again. Later rows load as before. If the server rejectsinclude_itemswith 422 (an older node during a rolling upgrade), the layout is read again without it and Home loads every row itself.useSettingValue) started in the same tick for the same scope share one request; each query keeps its own cache entry and gets only its keys. If a shared request fails because of an unknown key (422 with aquery.keyserror), each query re-reads its own keys so only the one that asked for the unknown key fails.Validation
tsc -b,pnpm run lint(0 errors),pnpm run format:check,pnpm run build,pnpm run budget:check: pass.make test-web: 849 of 850 files pass; the one failure (GlobalSearch.test.tsx) happened while two suites ran on the same machine and passes on three reruns of that file. The signed-in boot test now asserts that the layout starts beside the account read and that boot sends 14 requests instead of 18.include_items, and the startup gate.Evidence
Headless Chromium against a test server over plain HTTP, fresh tab, logged in, 40 ms emulated round trip, rows of 40, medians of 5 runs. Measured with the companion rendering PR (#2288) applied:
Nothing changes visually; rows and badges appear sooner. Surface and build: web app, desktop.
Risks
Checklist
AI Disclosure
🤖 Generated with Claude Code