Repository navigation
Media request system for iOS, tvOS, and macOS - #44
Conversation
Bring the server's media-request system (already live on web and Android) to the Apple clients, user-facing only — moderation stays in the web admin. Everything is gated on GET /requests/status, so servers without the feature (or with it disabled) show no request UI at all. Entry points follow how requests actually happen: - Library search grows an "Available to request" TMDB section below local results — request the thing you just failed to find, with the query already typed (one extra row on tvOS, no second keyboard). - A Requests hub (profile avatar menu on iOS, profile dropdown on tvOS) with TMDB search, the user's own requests strip, and Trending / Crowd favorites discover carousels. - Request detail: slim title page with ONE server-state-computed action that morphs in place (single Button identity, tvOS focus-safe) — no confirmation dialog. Completed titles open the real library item. - My Requests: In motion / Landed in your library / Needs attention buckets, per-quality target summaries, cancel for pending requests. Architecture: - Typed endpoints as a ContinuumAPI extension; wire models decode via the existing snake_case strategy with unknown-tolerant enums. - Tested pure core (Screens/Requests/Core/) for the five-state status mapping, bucketing, error-token copy, TMDB image URLs, and carousel merging — mirrors Android's RequestPresentation so both clients encode identical rules. 26 focused XCTests. - RequestsFeatureStore mirrors the AICapabilities capability-gate pattern (generation-guarded, reset on sign-out/profile/server switch). - RequestsEventBus patches every visible card/ribbon in place after a create/cancel instead of refetching whole screens. - Status language: monochrome chips/ribbons with a single colored dot (amber pending, sky on-the-way, emerald in library, rose attention). UX concepts in docs/requests/mockups.html. Co-Authored-By: Claude Fable 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThis PR adds a media-requests feature across iOS and tvOS, including request models and API calls, feature gating and update propagation, request hub/detail/my-requests screens, search and menu entry points, tests, and a documentation mockup page. ChangesMedia Requests Feature
Estimated code review effort: 4 (Complex) | ~75 minutes Sequence Diagram(s)sequenceDiagram
participant RequestDetailView
participant RequestDetailViewModel
participant ContinuumAPI
participant RequestsEventBus
RequestDetailView->>RequestDetailViewModel: submitRequest()
RequestDetailViewModel->>ContinuumAPI: createRequest(input)
ContinuumAPI-->>RequestDetailViewModel: MediaRequest
RequestDetailViewModel->>RequestsEventBus: publish(record)
RequestDetailViewModel->>ContinuumAPI: requestsDetail(mediaType, tmdbId)
ContinuumAPI-->>RequestDetailViewModel: refreshed detail
RequestDetailViewModel-->>RequestDetailView: updated primary action
sequenceDiagram
participant RequestsHubView
participant RequestsHubViewModel
participant ContinuumAPI
RequestsHubView->>RequestsHubViewModel: load()
RequestsHubViewModel->>ContinuumAPI: requestsDiscover()
RequestsHubViewModel->>ContinuumAPI: myRequests()
ContinuumAPI-->>RequestsHubViewModel: sections + requests
RequestsHubView->>RequestsHubViewModel: onQueryChanged()
RequestsHubViewModel->>ContinuumAPI: requestsSearch(query)
ContinuumAPI-->>RequestsHubViewModel: search results
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2522d147cb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| #else | ||
| .buttonStyle(.borderless) | ||
| #endif | ||
| .disabled(!action.isInteractive) |
There was a problem hiding this comment.
Keep the tvOS request CTA in the focus graph
On tvOS, after the user presses Request, primaryAction transitions to .submitting and then .status, making action.isInteractive false. Applying .disabled(true) removes that Button from tvOS's focus graph, so the currently focused CTA drops focus during the morph despite the stable Button identity this view is relying on. Keep the button focusable on tvOS and ignore taps for noninteractive states instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (5)
iosApp/iosApp/Screens/Requests/Hub/RequestsHubView.swift (1)
41-45: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicated event-bus wiring across screens.
This exact
.onChange(of: RequestsEventBus.shared.lastUpdate) { _, update in if let update { viewModel.applyRequestUpdate(update) } }block is repeated verbatim inRequestDetailView.swift(lines 36-40) andMyRequestsView.swift(lines 36-40). Consider extracting a small view modifier (e.g..onRequestBusUpdate { viewModel.applyRequestUpdate($0) }) to keep the three screens in sync if the bus contract changes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Requests/Hub/RequestsHubView.swift` around lines 41 - 45, The RequestsEventBus update handler is duplicated across multiple screens, so extract the repeated `.onChange(of: RequestsEventBus.shared.lastUpdate)` logic into a reusable view modifier or helper (for example, an `onRequestBusUpdate` modifier) and use it from `RequestsHubView`, `RequestDetailView`, and `MyRequestsView` to keep the `applyRequestUpdate` wiring centralized.iosApp/iosApp/Screens/Requests/Detail/RequestDetailView.swift (1)
230-273: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMorph animation doesn't cover non-interactive → non-interactive transitions.
value: action.isInteractiveonly changes between.request/.openInLibraryand everything else. Going from.submittingto.status(.pending), or between different.statuscases, won't trigger the animation, so the icon/label swap is an abrupt cut rather than the "morphs into the status in place" behavior described in the header doc comment (Lines 3-11).💡 Proposed fix (requires RequestPrimaryAction: Equatable, already declared)
- .animation(.easeOut(duration: 0.15), value: action.isInteractive) + .animation(.easeOut(duration: 0.15), value: action)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Requests/Detail/RequestDetailView.swift` around lines 230 - 273, The primary action button animation in RequestDetailView only tracks action.isInteractive, so non-interactive state changes like .submitting to .status or between different .status cases do not animate. Update primaryActionButton to drive the animation from the full RequestPrimaryAction value instead, and make sure RequestPrimaryAction conforms to Equatable so SwiftUI can detect transitions and morph the icon/label changes in place.iosApp/iosApp/Screens/Requests/Hub/RequestsHubViewModel.swift (1)
71-84: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winSearch failures are indistinguishable from "no results".
On a thrown error (e.g. network failure)
performSearchsetssearchResults = []andhasSearched = true, which renders the "No matches / Nothing on TMDB matched that search" empty state (Line 88-96 inRequestsHubView.swift). A connectivity failure is presented identically to a genuine empty result, which can mislead users into thinking their search term doesn't exist on TMDB.💡 Proposed fix
private func performSearch(_ trimmed: String) async { isSearching = true do { let page = try await api.requestsSearch(query: trimmed) guard !Task.isCancelled else { return } searchResults = page.results.filter { $0.mediaType != .unknown } hasSearched = true } catch { guard !Task.isCancelled else { return } - searchResults = [] - hasSearched = true + searchResults = [] + hasSearched = false + searchError = ErrorState(error) } isSearching = false }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Requests/Hub/RequestsHubViewModel.swift` around lines 71 - 84, The search error handling in performSearch currently treats failures the same as empty results by clearing searchResults and setting hasSearched, which triggers the generic empty state in RequestsHubView. Update RequestsHubViewModel.performSearch to record search failures separately from a successful empty page, using a distinct error/loading state or flag that RequestsHubView can check before showing “No matches,” so network or API errors are surfaced differently from genuine no-result searches.iosApp/iosApp/Screens/Requests/MyRequests/MyRequestsView.swift (1)
3-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDoc comment claims "swipe on iOS" but only long-press context menu is implemented.
The header comment describes swipe-to-cancel on iOS, but
requestRowonly wires.contextMenu(long-press), identical to the tvOS path. Rows are also a customVStack/ForEach, not aList, so native.swipeActionsisn't directly available here. Either update the comment to reflect the actual (long-press) interaction, or migrate rows into aListand add real swipe actions for the more discoverable iOS-idiomatic cancel gesture.Also applies to: 112-158
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Requests/MyRequests/MyRequestsView.swift` around lines 3 - 6, The MyRequestsView documentation is out of sync with the actual cancellation interaction: the comment says iOS supports swipe-to-cancel, but requestRow currently only provides a long-press context menu. Update the header comment in MyRequestsView to describe the implemented behavior, or if you want true iOS swipe cancellation, refactor the row rendering in requestRow into a List-based presentation and add swipeActions while keeping the tvOS contextMenu path.iosApp/iosApp/Screens/Requests/Search/RequestSearchSectionViewModel.swift (1)
25-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffDuplicate debounce pattern across search view models.
This
onQueryChangedreimplements the same 300ms-debounce/cancel/trim skeleton already present inSearchViewModel.onQueryChangedandRequestsHubViewModel.onQueryChanged. Consider extracting a small shared debouncer utility to avoid drift between the three copies (e.g., mismatched debounce durations if one is tuned later).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Requests/Search/RequestSearchSectionViewModel.swift` around lines 25 - 39, The 300ms debounce/cancel logic in onQueryChanged is duplicated across multiple search view models, which risks them drifting apart over time. Extract the shared debounce flow into a small reusable helper used by RequestSearchSectionViewModel.onQueryChanged, SearchViewModel.onQueryChanged, and RequestsHubViewModel.onQueryChanged so they all call the same utility and keep one debounce duration/source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Networking/ServerRegistry.swift`:
- Around line 202-206: The server switch/remove flow resets RequestsFeatureStore
but does not refresh its state, so Requests entry points can stay hidden when
router.authState remains authenticated. After the existing resets in the
ServerRegistry path, also trigger RequestsFeatureStore.shared.refresh() (or the
equivalent refresh path used elsewhere) so the feature re-evaluates immediately
after a server change, alongside AICapabilities.shared.reset() and
RequestsEventBus.shared.reset().
In `@iosApp/iosApp/Screens/Requests/Components/RequestMediaCard.swift`:
- Around line 47-68: The tvOS branch in RequestMediaCard.body defines
Button(action: onTap) with only posterImage inside it, so the accessible label
does not include the caption text. Update the tvOS button to expose an explicit
accessibility label or otherwise make caption part of the button’s label so
VoiceOver announces the request title/year, while keeping the existing VStack
layout and .buttonStyle(.card) structure intact.
In `@iosApp/iosApp/Screens/Requests/Detail/RequestDetailViewModel.swift`:
- Around line 109-117: The untracked reload in applyRequestUpdate(_:), triggered
from the bus consumer path, can overlap and let older load() results overwrite
newer ones. Update RequestDetailViewModel to keep a reference to the in-flight
reload Task and cancel/replace it before starting a new reload, so only the
latest request update can complete and apply data. Use applyRequestUpdate(_:),
load(), and the existing isSubmitting/detail guards to locate and wire the fix.
In `@iosApp/iosApp/Screens/Requests/MyRequests/MyRequestsViewModel.swift`:
- Around line 54-60: The reload logic in
`MyRequestsViewModel.applyRequestUpdate(_:)` starts a new untracked Task for
every bus event, so overlapping refreshes can race and apply out-of-order
results. Add a stored in-flight reload task (or equivalent cancellation handle)
in `MyRequestsViewModel`, cancel any existing reload before starting a new
`load()` task, and clear/reset it when the load finishes, mirroring the fix used
in `RequestDetailViewModel.applyRequestUpdate`.
In `@iosApp/iosApp/Screens/Requests/Search/RequestSearchSectionViewModel.swift`:
- Around line 41-58: `performSearch(_:)` can leave `isLoading` stuck true when
the async task is cancelled before completion. Ensure `isLoading` is always
reset on every exit path by moving the cleanup into a defer or equivalent in
`RequestSearchSectionViewModel.performSearch`, so both the success, error, and
cancellation paths clear the loading state even when `Task.isCancelled` triggers
an early return.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Requests/Detail/RequestDetailView.swift`:
- Around line 230-273: The primary action button animation in RequestDetailView
only tracks action.isInteractive, so non-interactive state changes like
.submitting to .status or between different .status cases do not animate. Update
primaryActionButton to drive the animation from the full RequestPrimaryAction
value instead, and make sure RequestPrimaryAction conforms to Equatable so
SwiftUI can detect transitions and morph the icon/label changes in place.
In `@iosApp/iosApp/Screens/Requests/Hub/RequestsHubView.swift`:
- Around line 41-45: The RequestsEventBus update handler is duplicated across
multiple screens, so extract the repeated `.onChange(of:
RequestsEventBus.shared.lastUpdate)` logic into a reusable view modifier or
helper (for example, an `onRequestBusUpdate` modifier) and use it from
`RequestsHubView`, `RequestDetailView`, and `MyRequestsView` to keep the
`applyRequestUpdate` wiring centralized.
In `@iosApp/iosApp/Screens/Requests/Hub/RequestsHubViewModel.swift`:
- Around line 71-84: The search error handling in performSearch currently treats
failures the same as empty results by clearing searchResults and setting
hasSearched, which triggers the generic empty state in RequestsHubView. Update
RequestsHubViewModel.performSearch to record search failures separately from a
successful empty page, using a distinct error/loading state or flag that
RequestsHubView can check before showing “No matches,” so network or API errors
are surfaced differently from genuine no-result searches.
In `@iosApp/iosApp/Screens/Requests/MyRequests/MyRequestsView.swift`:
- Around line 3-6: The MyRequestsView documentation is out of sync with the
actual cancellation interaction: the comment says iOS supports swipe-to-cancel,
but requestRow currently only provides a long-press context menu. Update the
header comment in MyRequestsView to describe the implemented behavior, or if you
want true iOS swipe cancellation, refactor the row rendering in requestRow into
a List-based presentation and add swipeActions while keeping the tvOS
contextMenu path.
In `@iosApp/iosApp/Screens/Requests/Search/RequestSearchSectionViewModel.swift`:
- Around line 25-39: The 300ms debounce/cancel logic in onQueryChanged is
duplicated across multiple search view models, which risks them drifting apart
over time. Extract the shared debounce flow into a small reusable helper used by
RequestSearchSectionViewModel.onQueryChanged, SearchViewModel.onQueryChanged,
and RequestsHubViewModel.onQueryChanged so they all call the same utility and
keep one debounce duration/source of truth.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6982e366-afc9-4a84-852c-6acd1928c1d3
📒 Files selected for processing (39)
docs/requests/mockups.htmliosApp/Tests/MyRequestsBucketTests.swiftiosApp/Tests/RequestDisplayStateTests.swiftiosApp/Tests/RequestErrorCopyTests.swiftiosApp/Tests/RequestImageURLTests.swiftiosApp/iosApp/Components/TabTopBarActions.swiftiosApp/iosApp/ContentView.swiftiosApp/iosApp/Navigation/Route.swiftiosApp/iosApp/Networking/ContinuumAPI+Requests.swiftiosApp/iosApp/Networking/RequestsFeatureStore.swiftiosApp/iosApp/Networking/RequestsModels.swiftiosApp/iosApp/Networking/ServerRegistry.swiftiosApp/iosApp/Screens/Auth/AuthService.swiftiosApp/iosApp/Screens/Browse/LibrariesTabView.swiftiosApp/iosApp/Screens/Calendar/CalendarView.swiftiosApp/iosApp/Screens/Home/HomeView.swiftiosApp/iosApp/Screens/Recommendations/RecommendationsView.swiftiosApp/iosApp/Screens/Requests/Components/RequestCardRail.swiftiosApp/iosApp/Screens/Requests/Components/RequestMediaCard.swiftiosApp/iosApp/Screens/Requests/Components/RequestStatusChip.swiftiosApp/iosApp/Screens/Requests/Core/MyRequestsBucket.swiftiosApp/iosApp/Screens/Requests/Core/RequestCarouselMerge.swiftiosApp/iosApp/Screens/Requests/Core/RequestDisplayState.swiftiosApp/iosApp/Screens/Requests/Core/RequestErrorCopy.swiftiosApp/iosApp/Screens/Requests/Core/RequestImageURL.swiftiosApp/iosApp/Screens/Requests/Core/RequestStateSync.swiftiosApp/iosApp/Screens/Requests/Detail/RequestDetailView.swiftiosApp/iosApp/Screens/Requests/Detail/RequestDetailViewModel.swiftiosApp/iosApp/Screens/Requests/Hub/RequestsHubView.swiftiosApp/iosApp/Screens/Requests/Hub/RequestsHubViewModel.swiftiosApp/iosApp/Screens/Requests/MyRequests/MyRequestsView.swiftiosApp/iosApp/Screens/Requests/MyRequests/MyRequestsViewModel.swiftiosApp/iosApp/Screens/Requests/RequestsEventBus.swiftiosApp/iosApp/Screens/Requests/Search/RequestSearchSectionView.swiftiosApp/iosApp/Screens/Requests/Search/RequestSearchSectionViewModel.swiftiosApp/iosApp/Screens/Search/SearchView.swiftiosApp/iosApp/Theme/Colors.swiftiosApp/iosApp/tvOS/Navigation/TVMainTabView.swiftiosApp/iosApp/tvOS/Navigation/TVTopMenuBar.swift
- tvOS: keep the detail CTA enabled in non-interactive states — a disabled Button drops out of the focus graph, yanking focus mid-morph after submit (the exact drop the single-Button design prevents). The action closure already ignores presses in those states. iOS keeps .disabled. (Codex P2) - Re-probe requests_enabled after server switch/remove: switching between signed-in servers can keep authState at .authenticated, which skipped the usual refresh and left entry points hidden until the next foreground. (CodeRabbit) - tvOS card accessibility: explicit label (title, year, status) on the poster button, whose caption lives outside the .card-style label. - Track and cancel-replace bus-triggered reloads in RequestDetailViewModel/MyRequestsViewModel so a slow earlier response can't overwrite a newer event's result. - Clear isLoading/isSearching on the cancellation early-returns in both debounced searches so a mid-flight cancel can't strand the spinner. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Addressed all review feedback in c53f7e5:
iOS + tvOS builds green; all 26 unit tests pass. 🤖 Generated with Claude Code |
Summary
Brings the server's media-request system (already live on web and Android) to the Apple clients — user-facing only; moderation stays in the web admin. The entire feature is gated on
GET /api/v1/requests/status, so servers without the feature (or with it disabled, or pre-requests servers that 404 the probe) show no request UI at all.UX
SearchViewgrows an "Available to request" TMDB section below local results: request the title you just failed to find, with the query already typed (one extra row on tvOS, no second keyboard).Route.requestsHub) — TMDB search, the user's own requests strip with status ribbons, and Trending / Crowd favorites discover carousels. Entry: profile avatar menu (iOS), profile dropdown (tvOS).Buttonidentity so tvOS focus never drops mid-morph. Completed titles route to the real item detail.Architecture
ContinuumAPIextension; wire models rely on the existing snake_case decoding with unknown-tolerant enums (a new server status can never fail a whole payload).Screens/Requests/Core/) for status mapping, bucketing, error-token copy, TMDB image URLs, and carousel merging — mirrors Android'sRequestPresentationso both clients encode identical rules.RequestsFeatureStoreclones theAICapabilitiescapability-gate pattern (generation-guarded; reset on sign-out / profile / server switch).RequestsEventBuspatches every visible card/ribbon in place after a create/cancel.docs/requests/mockups.html.Testing
Silo(iOS),SiloTV(tvOS), andSiloMacall build green.silo-server(internal/requests/types.go, handlers, router), including date formats and thePOST /requests/trailing-slash route.🤖 Generated with Claude Code
Summary by CodeRabbit