Repository navigation
feat(api): return the first home rows' items with the home layout - #2287
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]>
|
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 30 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 |
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:
|
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf50ff7e55
ℹ️ 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".
- 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]>
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:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #1140 C4 (included rows are a new response path for the same row items; not yet run)
The web Home page loads
GET /api/v2/home/layoutand only then requests each row's items, so the first row always waits for two round trips in a row. This change lets the layout response carry the first rows' items, so a client can paint them after one request.Approach
GET /api/v2/home/layouttakes two optional query parameters:include_items(0–4, default 0): include items for the first N rows in layout order.image_size(same values as onGET /api/v2/home/sections/{id}/items): applies to the included items.A new capability document,
GET /api/v2/home/capabilities(getHomeCapabilities), reportsinclude_items_max(4). v2 rejects unknown query parameters, so a client sendsinclude_itemsonly when this document reports it.The response is a new
HomeLayoutschema: the existingsectionsplusincluded_sections, an array of the sameSectionobjects the per-row endpoint returns. It is empty, never null, when nothing is requested. The library layout keepsSectionLayout, so its contract is unchanged. All changes are additive (one new operation, one new schema, new fields);verify-apiv2-contractreports no breaking change.Included rows are built by the same code as
GET /api/v2/home/sections/{id}/items: access filtering, hide-watched filtering, next-up injection, user states, overlays, playable targets, and artwork. The per-row endpoint now uses that shared builder. Included rows skip the cross-row duplicate filter, so each one matches what the per-row endpoint returns and a client can use it as that endpoint's cached answer.The layout resolves once and the included rows are built in parallel. The 300 ms budget covers each row's whole build: the item fetch and the card lookups (user states, overlays, playable targets, artwork). A row not built in time is left out and its build is cancelled; a shared cache rebuild it started keeps running, so the client's follow-up request usually finds it warm. Requests waiting on that shared rebuild stop waiting when their own context ends. A row whose fetch fails is left out and logged at warn. Without
include_itemsthe endpoint does no extra work.The web change that uses this is a separate PR stacked on this branch. Native clients use
GET /api/v2/home/sectionsand need no change; Silo-Server/silo-apple#731 and Silo-Server/silo-android#549 track whether they should adopt this.Validation
make lint-changed: clean.go test ./internal/apiv2/ ./internal/api/handlers/ ./internal/sections/: pass; the new tests also pass with-race. The DB test that compares included rows with the per-row endpoint passed against Postgres. New tests cover a hung card lookup (the layout still returns within the budget without that row), a panicking row build, a cancelled waiter on a shared cache rebuild, and the capability document (including that its maximum matches the parameter's OpenAPI maximum).verify-apiv2-openapi,verify-apiv2-contract,verify-apiv2-fixtures,verify-apiv2-web-types,verify-route-inventory,verify-migration-ledger,verify-local-paths: pass.Evidence
Evidence: none, no user-visible change. The response with and without the parameter (trimmed):
Risks
context canceledat error level. On a test server Continue Watching took 13–48 ms, so this should be rare.make apiv2-fixtures-syncafter merge.Checklist
AI Disclosure
🤖 Generated with Claude Code