Skip to content

feat(catalog): move filters, calendar and trailer refresh to v2 - #381

Merged
Quick104 merged 1 commit into
mainfrom
apiv2-stack/33-filters-calendar-trailers-v2
Sep 23, 2026
Merged

Quick104 merged 1 commit into
mainfrom
apiv2-stack/33-filters-calendar-trailers-v2

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

Problem

SiloAPI still sent these requests to v1:

  • GET /api/v1/calendar from CalendarViewModel
  • GET /api/v1/catalog/filters from FacetLoader
  • POST /api/v1/items/{id}/trailers/refresh from ItemDetailViewModel through TrailerFetchCoordinator

APIv2Client.calendar, catalogFilters and refreshTrailers already existed with owner fences (F4 added the fence to catalogFilters), but only tests called them. OpenAPI requires X-Profile-Id on all three operations, and the v1 requests didn't bind the result to an owner.

Solution

The Calendar tab, the Browse facet lists and the "Find Trailers" action now use /api/v2, and the three v1 requests are gone.

  • Calendar: SiloAPI.calendarEvents captures the owner and calls apiV2Client.calendar. The response still decodes into CalendarResponse, which already matches the v2 Calendar schema. The persisted calendar.filter value goes through CalendarFilter(rawValue:), so the client only sends following, trending or everything, all of which are in the v2 enum.
  • Filters: SiloAPI.catalogFilters returns APIv2CatalogFilters. v2 inverts the technical-facets flag: technical facets are returned unless the request sends skip_technical=true, where v1 needed include_technical=true. CatalogFacets reads resolution and audio/subtitle languages from the nested technical object, and FacetLoader caches the v2 model. The v1-only CatalogFilters model is deleted.
  • Owner check after the fence: ResponseCache stores calendar weeks and facet lists per profile. After the client's owner fence releases a result, the facade checks the owner again and throws requestIdentityChanged if it changed, as the similar-cards read in W5-K does.
  • Trailer refresh: SiloAPI.requestTrailersRefresh calls apiV2Client.refreshTrailers. The client accepts only 202 queued and 200 cooldown|disabled. HTTPError.http never leaves the v2 client, so TrailerFetchCoordinator now reads a 429 from APIv2Error.problem or .httpStatus to keep the rate-limit copy. TrailerRefreshResponse moved unchanged from Models.swift to APIv2CatalogModels.swift.

Failure outcomes: refreshCatalogItemTrailers (x-silo-retry-safety: non_retryable)

Outcome Behavior
Definite success (202 queued, 200 cooldown/disabled) queued polls item detail. cooldown and disabled show their status right away.
Definite failure (not sent because the owner changed; any non-2xx, including 401, 409 and 429) The request is dispatched once. HTTPClient's shouldAttemptRefresh already exempts this route from 401 replay. The coordinator ends in .requestFailed, and a 429 gets its own copy.
Uncertain (sent, no answer) The request is not retried. The coordinator shows "Couldn't reach the server — try again", never "No trailers found", because the server may have spent the cooldown slot. Only a new tap sends another request.

The calendar and filters requests are reads with no mutation outcome.

Validation

  • iOS, tvOS and macOS builds passed.
  • Focused tests passed on iOS and tvOS: CatalogActionsAPITests (new), TrailerFetchCoordinatorTests, CatalogV2Tests, ItemVideosDecodingTests and ArtworkURLTests.
  • The new CatalogActionsAPITests run through SiloAPI on the stubbed transport. They check:
    • the calendar path, query and profile header, and that a week read for a replaced profile is refused
    • that the filters query omits skip_technical by default and sends it when technical facets are skipped, and that nested technical facets map into CatalogFacets
    • the trailer refresh POST path with percent-encoding, and all three outcomes
    • a single dispatch after a lost connection
    • a 429 surfaced as a problem
  • TrailerFetchCoordinatorTests now drive the rate-limit and generic-failure cases with v2 errors.
  • scripts/ci/check-no-api-v1.sh passed.
  • The final stack passed the full suites (iOS 1981 tests and tvOS 1792 tests, 0 failures), the macOS build and the v1 path guard. Every branch in the stack, this one included, builds on its own.

Risks and follow-ups

  • The Calendar, Browse filter and Find Trailers flows were not checked by hand on a signed simulator against a live server.
  • DiagnosticsPathTemplateTests and HTTPClientDiagnosticsClassificationTests still use /api/v1/catalog/filters as a path-templating test vector. They send no request. W5-W2 and Z1 own those files.
  • The in-memory catalogFilters: cache key has no version bump. The cache lives only for the process and is cleared on profile switch, and a lookup that finds a value of another type is treated as a miss.

AI disclosure

Code and description written by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.


Part 33 of 50 in the Apple API v2 stack. Base: apiv2-stack/32-similar-discover-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e8abd7f2-e55a-497c-95a0-c9882eac7942

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@greptile-apps greptile-apps 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.

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 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-09-23T13:22:42.234750Z 58c61e8 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.

@Quick104

Copy link
Copy Markdown
Contributor Author

Code review summary

Reviewed head: d162da04 (apiv2-stack/33-filters-calendar-trailers-v2).

Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration.

Verified findings: none.

Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no /api/v1 request from the new builds except the retained health probe.

Remaining: no open verified findings. Merge in stack order.

Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack.

Review by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code).

@Quick104
Quick104 force-pushed the apiv2-stack/32-similar-discover-v2 branch from 019a408 to 9faf9fd Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/33-filters-calendar-trailers-v2 branch from d162da0 to 58c61e8 Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/32-similar-discover-v2 branch from 9faf9fd to 2a2aa0c Compare September 23, 2026 13:42
Base automatically changed from apiv2-stack/32-similar-discover-v2 to main September 23, 2026 13:42
The Calendar tab, the Browse facet loader and the "Find Trailers" action
still called /api/v1/calendar, /api/v1/catalog/filters and
POST /api/v1/items/{id}/trailers/refresh, although owner-fenced v2 client
methods for all three already existed and were reached only from tests.

SiloAPI now calls APIv2Client.calendar, catalogFilters and refreshTrailers
with the captured owner. Calendar weeks and facet lists are cached per
profile, so the facade refuses a result whose owner changed after the
fence released it. Facets map from APIv2CatalogFilters: technical facets
are nested under `technical` and are requested unless skipped
(`skip_technical`, the inverse of v1's `include_technical`). The trailer
refresh stays a single dispatch (the route is non_retryable and exempt
from 401 replay), and the coordinator reads a 429 from the v2 problem or
status instead of HTTPError. The v1-only CatalogFilters model is deleted
and TrailerRefreshResponse moves next to the other v2 catalog models.

Stack-PR: W5-L
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 force-pushed the apiv2-stack/33-filters-calendar-trailers-v2 branch from 58c61e8 to 72a03f9 Compare September 23, 2026 13:42
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Quick104
Quick104 merged commit 35a6b17 into main Sep 23, 2026
3 checks passed
@Quick104
Quick104 deleted the apiv2-stack/33-filters-calendar-trailers-v2 branch September 23, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant