Skip to content

feat(api): return the first home rows' items with the home layout - #2287

Merged
Quick104 merged 4 commits into
mainfrom
feat/home-layout-included-rows
Oct 11, 2026
Merged

Quick104 merged 4 commits into
mainfrom
feat/home-layout-included-rows

Conversation

@Quick104

@Quick104 Quick104 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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/layout and 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/layout takes 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 on GET /api/v2/home/sections/{id}/items): applies to the included items.

A new capability document, GET /api/v2/home/capabilities (getHomeCapabilities), reports include_items_max (4). v2 rejects unknown query parameters, so a client sends include_items only when this document reports it.

The response is a new HomeLayout schema: the existing sections plus included_sections, an array of the same Section objects the per-row endpoint returns. It is empty, never null, when nothing is requested. The library layout keeps SectionLayout, so its contract is unchanged. All changes are additive (one new operation, one new schema, new fields); verify-apiv2-contract reports 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_items the 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/sections and need no change; Silo-Server/silo-apple#731 and Silo-Server/silo-android#549 track whether they should adopt this.

Validation

  • Go build, vet, gofmt, 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):

GET /api/v2/home/layout
{"sections":[{"id":"continue_watching",...},...],"included_sections":[]}

GET /api/v2/home/layout?include_items=1
{"sections":[{"id":"continue_watching",...},...],
 "included_sections":[{"id":"continue_watching","items":[...],"total_count":...}]}

Risks

  • When Continue Watching misses the 300 ms budget and is cancelled, the next-up and dropped-series steps log context canceled at error level. On a test server Continue Watching took 13–48 ms, so this should be rare.
  • The sibling repos' vendored fixture copies need make apiv2-fixtures-sync after merge.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (Claude Agent SDK), running in T3 Code
  • Tool(s): Claude Code, including Claude Code subagents
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, at a maintainer's direction; maintainer review pending
  • Adversarial review: a separate Claude Code subagent compared the per-row endpoint before and after the refactor and reviewed the parallel fetch for leaks and races, cancellation of shared cache builds, access scoping, and contract consistency. It found no bugs; its remaining notes are under Risks.

🤖 Generated with Claude Code

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]>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4b45d7d-8e2c-4454-bdc0-77ec1c652d16

📥 Commits

Reviewing files that changed from the base of the PR and between b78c1ff and a121427.


📒 Files selected for processing (20)
  • contracts/api/v2/fixtures/get_home_capabilities_ok.json
  • contracts/api/v2/fixtures/get_home_layout_include_items_out_of_range.json
  • contracts/api/v2/fixtures/get_home_layout_ok.json
  • contracts/api/v2/fixtures/get_home_layout_with_items_ok.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/migration.json
  • contracts/api/v2/openapi.json
  • docs/architecture/api-contract.md
  • internal/api/handlers/home_layout_items_test.go
  • internal/api/handlers/home_views_service.go
  • internal/api/handlers/library_views_service.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/fixtures_test.go
  • internal/apiv2/home.go
  • internal/apiv2/home_test.go
  • internal/apiv2/router.go
  • internal/sections/resolvedlistcache.go
  • internal/sections/resolvedlistcache_test.go
  • web/src/api/v2/operations.ts
  • web/src/api/v2/schema.ts

  • 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

Comment @coderabbitai help to get the list of available commands.

@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T21:39:44.754149Z c1546e4 New commits
🔒 Security Review ✅ Completed 2026-10-11T21:40:57.830467Z c1546e4 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/apiv2/home.go Resolved
- 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

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

@Quick104
Quick104 merged commit c5f0edb into main Oct 11, 2026
20 checks passed
@Quick104
Quick104 deleted the feat/home-layout-included-rows branch October 11, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant