Skip to content

feat(apiv2): let clients size each artwork slot by drawn width - #2627

Merged
Quick104 merged 5 commits into
mainfrom
feat/artwork-slot-widths
Oct 17, 2026
Merged

Quick104 merged 5 commits into
mainfrom
feat/artwork-slot-widths

Conversation

@Quick104

@Quick104 Quick104 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: Silo-Server/silo-apple#819, Silo-Server/silo-android#609, #2611
Validation tasks: none

A v2 response takes one image_size, but a TV screen draws one item's artwork at very different sizes. A home row shows each item's poster as a card and the focused item's backdrop full-screen behind it, and a detail page pairs a full-screen hero with small cast photos. With one size, a TV client either downloads large posters for every card or shows a soft hero. This adds per-slot target widths to the v2 API: a client says how wide it draws each field and gets the narrowest cached image that covers it.

Stacked on #2626, which adds the sizes these widths resolve to.

Approach

  • Every v2 read that takes image_size also takes poster_width, backdrop_width, logo_width, still_width and photo_width, in device pixels from 1 to 7680. That covers catalog items, browse and query, item and watch detail, seasons and episodes, home and library sections, favorites, the watchlist, history, shuffles, the not-interested list and notification series.
  • A slot is named for the response field. backdrop_width governs backdrop_url and backdrop_urls, including an episode's backdrop that holds its still, which then resolves on the still ladder.
  • A slot width overrides image_size for that slot; other slots keep image_size, or the per-context default when it is absent. The server returns the narrowest size of the image's own ladder at least that wide, including sizes image_size cannot name, else the original. Plugin-hosted artwork gets the nearest semantic hint for its slot; listings resolve cached keys in one batch and plugin-hosted paths once per hint, so a card poster and a hero backdrop from the same plugin are asked for at different sizes. A headshot keeps the large hint cast lists already use unless its width needs the original, because plugins' smaller headshots (TMDB's are 185px) are softer than a cast card.
  • Banner, thumb, clear art and disc art keep following image_size.
  • Cursors already bound to image_size (catalog browse and query, audiobook groups, history) are bound to the widths too. The widths are appended only when present, so cursors issued before this change stay valid. Lists whose cursors never bound image_size, such as favorites and the watchlist, do not bind the widths either.
  • GET /api/v2/images/capabilities gains slot_width_params. A server without this change rejects the parameters with 422 validation_failed, so clients must check the capability first.
  • /api/v1 does not take the parameters, and the widths stay out of every key derived from the access filter's encoding.

Validation

  • Unit tests for width resolution on each ladder and slot, precedence over image_size, plugin hints, cursor binding, the 1–7680 bounds, extended art ignoring backdrop_width, and the v2 home seam: pass.
  • OpenAPI, web types and fixtures regenerated and current. make verify-apiv2-contract reports only additions (new optional query parameters).
  • Top-of-stack gate as in feat(artwork): cache originals up to 4K and add wider rungs #2626. Web lint, format check, build and make test-web pass with the regenerated schema.ts.
  • Sandboxes: the Android TV and Apple TV 4K requests from the client issues return the sizes their specs expect; the main build answers each of them with 422.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/artwork-slot-widths/

API responses for the TV requests on home, item detail and episodes, from a main build and this stack.

Risks

  • Additive v2 change. Responses to requests without width parameters are unchanged.
  • A client that sends widths to an older server gets 422; slot_width_params is the feature check.

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, running in T3 Code
  • Tool(s): Claude Code; Codex for the adversarial review
  • Model(s): claude-opus-5-5; gpt-6.1-sol (review)
  • Involvement: Fully AI-generated, human verified. The maintainer chose the design and checked the artwork on devices; the code has not had a line-by-line human review.
  • Adversarial review: Codex (gpt-6.1-sol) reviewed the whole three-commit stack in three read-only rounds, checking for keys that name sizes an image never had, unintended /api/v1 or unsized v2 changes, cursor binding, manifest fallbacks, the backfill query, Jellyfin sizing and plugin hints. It found Jellyfin Primary and fallback images sized on the wrong ladder, plugin-hosted artwork on list endpoints ignoring slot widths, and unsized hero logos degrading to 500px on artwork cached before revision manifests; all three are fixed with tests. It also flagged that favorites, watchlist and similar cursors ignore widths; that is unchanged on purpose, because those cursors never bound image_size either. Separately, captures from the sandboxes showed that headshot widths sent plugins a hint that returns 185px images, so headshots keep the large hint unless they need the original.

🤖 Generated with Claude Code

Note

Add per-slot artwork width query params to API v2 artwork sizing

  • Clients can now request separate pixel widths for poster, backdrop, logo, still, and photo artwork via new query params like poster_width and backdrop_width, on top of the existing image_size. The shared ArtworkQuery model in artwork_query.go replaces standalone image_size fields across all apiv2 inputs, and widths are retained in pagination cursors for listings.
  • Wider artwork ladders were added: poster w1000, still w1280, backdrop w2560 (ladder version 3), and the cached original cap rose from 1920 to 3840 in artworkkey.go and imageutil.go. Cached paths are now resized on the ladder encoded in the path itself, so a still used in a backdrop slot stays on the still ladder.
  • Card, featured, detail, personal-list, and history artwork resolution now batches per slot through the new ArtworkBatch/ArtworkURLs types in artwork_batch.go, deduplicating cached paths and resolving plugin-hosted paths per variant hint.
  • Jellyfin compatibility now selects ladder-specific variant sizes from maximum/fill dimension boxes, encoding multiple ladder choices in one composite request-size key (image_variants.go).
  • The v3 backfill fence migration (20261017015325_fence_image_ladder_backfill_v3.sql) reopens ladder backfill when a published local path lacks the expected current rung. Docs and the OpenAPI contract (openapi.json) were updated, including a new slot_width_params capability.
  • Behavioral Change: artwork URLs that previously resolved to the old widest rungs (w780/w1920) now use the new wider ladders, and Jellyfin image sizing follows aspect-ratio and per-ladder rules instead of single-bucket selection. Legacy artwork without a manifest clamps above-medium requests to medium.

Macroscope summarized 9d5bfe8.

Quick104 and others added 2 commits October 16, 2026 21:03
Cached originals were downscaled to 1920px on ingest, so a 4K TV hero or a
high-density tablet never got more than a 1080p backdrop. Originals now keep
the source's resolution up to 3840px, and the ladder gains rungs between the
old default and the original: backdrop w2560, poster w1000, still w1280
(LadderVersion 3, so the one-shot backfill regenerates existing artwork,
backdrops included).

Every storage backend now reads the publication manifest, so a request for a
rung an older revision never generated falls back to one it did publish
instead of a 404. Local and direct-S3 backends only look up the added rungs;
external delivery still checks every key.

Unsized defaults stop serving the 4K original where no client draws it: cast
headshots in item detail use the 500px rung, and an episode still standing
in for a backdrop uses the widest still rung that fits. Jellyfin-compatible
MaxWidth/MaxHeight/FillWidth/FillHeight requests pick the narrowest rung
covering four fifths of the requested width on the resolved image's own
ladder and aspect ratio; a request is sized on every ladder it can resolve
to, since Primary and fallbacks land on different image types.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One image_size per response cannot serve a TV home row, which draws each
item's poster as a card and its backdrop full-screen behind the focused row,
or a detail page with a full-screen hero beside small cast photos. Every v2
read that takes image_size now also takes poster_width, backdrop_width,
logo_width, still_width and photo_width: the width in device pixels the
client draws that response field at.

The server returns the narrowest cached rung at least that wide on the
image's own ladder, including rungs image_size cannot name, else the
original. A slot is named for the field, so backdrop_width also governs an
episode's still when it fills backdrop_url. A slot width overrides
image_size for that slot; slots without one keep image_size or the
per-context default. Plugin-hosted art gets the nearest semantic hint for
its slot: listings resolve cached keys in one batch and plugin-hosted paths
once per hint. Cursors bound to image_size are bound to the widths too, and
only when widths are present, so existing cursors stay valid.

The images capability lists the parameters as slot_width_params. /api/v1 is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Oct 17, 2026
@coderabbitai

coderabbitai Bot commented Oct 17, 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 23 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: 9c978305-c449-454d-8528-5f17d91f49b4
📥 Commits

Reviewing files that changed from the base of the PR and between 552a7bf and 9d5bfe8.

📒 Files selected for processing: 49
  • contracts/api/v2/fixtures/get_image_capabilities_ok.json
  • contracts/api/v2/openapi.json
  • docs/images-api.md
  • internal/api/handlers/artwork_widths_test.go
  • internal/api/handlers/audiobook_groups.go
  • internal/api/handlers/catalog.go
  • internal/api/handlers/catalog_items_service.go
  • internal/api/handlers/catalog_resources.go
  • internal/api/handlers/favorites.go
  • internal/api/handlers/home_views_service.go
  • internal/api/handlers/image_size.go
  • internal/api/handlers/items.go
  • internal/api/handlers/items_catalog_response_test.go
  • internal/api/handlers/library_collections.go
  • internal/api/handlers/library_views_service.go
  • internal/api/handlers/people.go
  • internal/api/handlers/sections.go
  • internal/api/handlers/sections_concurrency_test.go
  • internal/api/handlers/sections_home_watched_test.go
  • internal/apiv2/artwork_query.go
  • internal/apiv2/catalog_actions.go
  • internal/apiv2/catalog_items.go
  • internal/apiv2/catalog_letters.go
  • internal/apiv2/favorites.go
  • internal/apiv2/history.go
  • internal/apiv2/home.go
  • internal/apiv2/home_test.go
  • internal/apiv2/library_views.go
  • internal/apiv2/not_interested.go
  • internal/apiv2/notification_series.go
  • internal/apiv2/operational_discovery.go
  • internal/apiv2/shuffles.go
  • internal/apiv2/theme_songs.go
  • internal/apiv2/watch.go
  • internal/apiv2/watchlist.go
  • internal/apiv2/watchlist_titles.go
  • internal/catalog/access_filter.go
  • internal/catalog/artwork_batch.go
  • internal/catalog/artwork_batch_test.go
  • internal/catalog/detail.go
  • internal/catalog/detail_extra_artwork.go
  • internal/catalog/detail_extra_artwork_test.go
  • internal/catalog/image_size_test.go
  • internal/catalog/item_cards.go
  • internal/catalog/person_credit_image_test.go
  • internal/imagesize/imagesize.go
  • internal/imagesize/widths.go
  • internal/imagesize/widths_test.go
  • 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-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 stacked Base is another open PR; merge in stack order named in the body labels Oct 17, 2026
Quick104 and others added 2 commits October 16, 2026 22:03
…twork

The database fence that reopens a finished ladder backfill still checked for
the v2 rungs: every poster or still published under ladder v3 lacks w780, so
each newly cached image would have reset a completed backfill, and backdrops
were not fenced at all. A new migration replaces it with one trigger function
that takes the fenced ladder version and checks the v3 rungs on posters,
stills, logos, backdrops and extra backdrops; its Down restores the v2 fence.

A revision cached under an earlier ladder now serves its own widest rung that
fits a request (a w780 poster for a w1000 request during the backfill), not
only the current ladder's.

Favorites, the watchlist and history resolved each card image on its own,
which now costs a manifest lookup per image for rungs wider than medium. They
resolve in one batch per hint instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from feat/artwork-4k-ladder to main October 17, 2026 02:42
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	contracts/api/v2/fixtures/get_image_capabilities_ok.json
#	internal/api/handlers/favorites.go
#	internal/api/handlers/sections.go
#	internal/catalog/detail.go
@silo-kody

silo-kody Bot commented Oct 17, 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 ❌

@Quick104
Quick104 merged commit 2fe4518 into main Oct 17, 2026
20 checks passed
@Quick104
Quick104 deleted the feat/artwork-slot-widths branch October 17, 2026 03:04
Quick104 added a commit to Silo-Server/silo-android that referenced this pull request Oct 17, 2026
Silo-Server/silo-server#2627 merged, so the vendored bodies now come
from main at 2fe4518e9 instead of an uncommitted server checkout. The
bodies are unchanged; SOURCE now names that commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit to Silo-Server/silo-android that referenced this pull request Oct 17, 2026
* test(fixtures): vendor the image capability fixture

The capability response now advertises per-slot artwork widths
(slot_width_params), and the client decodes it, so the contract test
needs the server's body. Add get_image_capabilities_ok to the vendored
subset and re-vendor from the server checkout that carries it.

The bodies come from an unmerged silo-server change (branch
feat/episode-image-original-quality); SOURCE records snapshot=uncommitted.
Re-vendor from the merged server commit before relying on them. The
other fixture diffs are drift between the previously vendored commit
and that checkout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(artwork): request artwork at the size each screen draws it

Artwork came back at the server's default sizes however large a screen
drew it. On Android TV that left detail logos (drawn up to 650px from a
500px image) and episode stills soft, and the hero preload assumed 2x
density. On phones the detail hero, episode cards and grid posters were
upscaled.

Servers that list slot_width_params in /api/v2/images/capabilities take
poster_width, backdrop_width, logo_width, still_width and photo_width on
every v2 read that returns artwork. Each app now describes how wide it
draws each surface (dp x the device's density), and the repositories
send those widths when the active server advertises them:

- Android TV: Home, For You and library shelves send poster 88dp,
  backdrop 672dp (fills the 614x378dp hero) and logo 440dp; detail
  sends the same backdrop with logo 325dp and photo 100dp, so opening
  an item reuses the hero image Home loaded. Episodes send still 180dp
  on the series page and 230dp elsewhere, the similar rail poster
  130dp, catalog grids poster 138dp. The hero and startup preloads use
  density-derived sizes instead of 1229x756px.
- Phone and tablet: the detail hero, episodes and catalog grids send
  widths from their layouts, taking the larger of both orientations so
  rotating keeps a listing's widths. Rails (Home, For You, similar) ask
  for their cards at the largest card size, since that preference loads
  after launch. Opening a Home card warms its backdrop at full-screen
  size only on servers without widths, where detail uses the same URL.

Requests wait up to 2s for the capability probe and otherwise go out
as today, as they do on older servers, which reject width parameters.
Widths are bound to the server that advertised them, so a read issued
during a server switch can't carry them to the next server, and a
probe that fails on the network is retried with backoff. Catalog
cursors keep the widths of their first page, and the Room caches key
detail, episodes, library pages and Home by the widths the device draws
them at.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(artwork): size cards by the card-size preference and keep cache keys stable

Review follow-ups on the per-slot artwork widths:

- Cards and grid cells grow with the card-size preference: TV cards,
  episode stills and grids scale with cardScaled(), and phone grids
  drop columns for larger posters. Requests sized them at the standard
  card size, so Large posters got an image a size too small (a phone
  grid cell of 551px got a 500px poster). Each app now reads the active
  preference when it builds a request. Cache keys stay at the standard
  size, so they don't change when the preference loads after launch.
- Cache writes rebuilt their key from the live layout, so a fold while
  a read was in flight filed one layout's artwork under the other's key.
  Detail, episodes, library pages, library sections and Home now capture
  the key before the read and cache the answer under it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(fixtures): re-vendor the API fixtures from server main

Silo-Server/silo-server#2627 merged, so the vendored bodies now come
from main at 2fe4518e9 instead of an uncommitted server checkout. The
bodies are unchanged; SOURCE now names that commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(artwork): keep pre-update caches and skip caching unsized reads

- Rows cached before artwork widths existed are keyed without them, so
  after an update offline Home, detail, episodes, library pages and
  library sections found nothing. A read now falls back to the old row
  until that item is cached again, which removes it.
- A read that went without widths only because the capability check
  hadn't answered was still cached under the layout's key, and
  prefetch then reused it after the check succeeded. Such reads are no
  longer cached; reads to a server that doesn't take widths still are.
  The cache key is captured with the widths, after the check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(artwork): load the saved card size before the first reads

The startup Home warm-up ran before the card-size preference loaded, so
a user with Large cards got Home sized for Standard (a 420px request for
a 504px card at 3.5x). Cache keys also used the standard size while
requests used the active one, so after a card-size change cached Home,
library and episode reads reused smaller images.

The layouts now seed the preference from its local cache, without the
network, the first time a read needs it, and cache keys use the active
card size again. A card-size change starts a new cache entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(artwork): decide cacheability with the request and retire only the writer's legacy row

A read that went without widths because the capability check timed out
could still be cached if the check answered before the response: the
write consulted live probe state. ArtworkSizing.sizedRead now returns
the widths and whether the answer may be cached together, before the
read goes out, and replaces mayCache.

Retiring a pre-update cache row re-read the active identity after the
write, so a profile switch during Room's upsert could delete the next
profile's row. put() now returns the owner it wrote for, and only that
owner's legacy row is deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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 size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant