Repository navigation
iOS/tvOS in-player subtitle search (provider parity with Android/web) - #45
Conversation
Search external subtitle providers (OpenSubtitles/SubDL/Subsource) from the player and download a result mid-playback: - POST /subtitles/search + /subtitles/download wire types and ContinuumAI methods (synchronous, no job machinery; warnings surface per-provider soft failures) - SubtitleSearchMenu: one-tap language pick (preferred floats to top, no free-text field), score/provider/HI-badged results; iOS sheet + tvOS focus panel following the SubtitleTranslateMenu idioms - Downloaded track reuses the AI-subtitle sidecar handoff (re-list -> position -> synthesized combined-index stream URL -> register + auto- select) with no session restart; the subtitle_ready websocket echo is a no-op via the existing combined-index de-dupe - Entries in TrackSelectionSheet (iOS) and TVPlayerInfoHUD Subtitles pane (tvOS), gated on an active server session (hidden offline/local); tvOS Back is inert while a download is in flight - Focused tests for the wire contract (snake_case decode, download body echo, score tiers) 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 (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR adds in-player subtitle provider search and download support. It introduces new wire models and network calls, adds PlayerViewModel search/download orchestration, wires a new SubtitleSearchMenu into iOS and tvOS player UI, and adds contract tests. ChangesSubtitle Provider Search Feature
Estimated code review effort: 4 (Complex) | ~60 minutes 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: 36259803c3
ℹ️ 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".
| struct SubtitleSearchResult: Codable, Identifiable, Equatable { | ||
| let id: String |
There was a problem hiding this comment.
Key search rows by provider and subtitle id
When two providers return the same provider-local subtitle id, this Identifiable conformance exposes only id to SwiftUI ForEach(results), and the menu also uses that same value for download state and tvOS focus. In that case SwiftUI can coalesce distinct provider results and show the spinner/disabled state on the wrong row, even though the download API requires the (provider, subtitleId) pair. Use a composite identity such as provider plus id for result identity/state.
Useful? React with 👍 / 👎.
| ) | ||
| return false | ||
| } | ||
| guard let context = makeSubtitleHandoffContext(), |
There was a problem hiding this comment.
Revalidate the playback item before handoff
If a subtitle download is in flight and playback advances or the user dismisses the menu and starts another item before the awaits return, fileId still refers to the old media file but makeSubtitleHandoffContext() reads the current active session. That can synthesize and auto-select a /stream/{session}/subtitles/{position} URL for the new session using the old file's downloaded-subtitle position, yielding a wrong or invalid subtitle track. Capture/recheck the session or current file id before registering the descriptor.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
iosApp/iosApp/Screens/Player/Sheets/SubtitleSearchMenu.swift (1)
58-59: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win
searchTaskisn't cancelled on dismiss paths that bypassbackToLanguages().Both the tvOS backdrop tap (
onDismiss(), Line 266) and the iOS "Done" toolbar button (onDismiss(), Line 557) close the menu directly without cancellingsearchTask. If a search is in-flight (.searchingphase), the task keeps running and later mutates@Stateon an already-dismissed view.♻️ Proposed fix
var body: some View { `#if` os(tvOS) tvOSPanel `#else` phoneList `#endif` } + .onDisappear { searchTask?.cancel() }Also applies to: 145-165
🤖 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/Player/Sheets/SubtitleSearchMenu.swift` around lines 58 - 59, searchTask is only cancelled through backToLanguages(), but the direct dismiss paths in SubtitleSearchMenu’s onDismiss handlers can bypass that cleanup and leave the in-flight search mutating state after dismissal. Update the dismissal flow so every path that closes the sheet/menu also cancels searchTask before exiting, and make sure the existing backToLanguages()/onDismiss logic in SubtitleSearchMenu covers both the tvOS backdrop tap and the iOS Done button.
🤖 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/Screens/Player/Sheets/SubtitleSearchMenu.swift`:
- Around line 239-248: The tvOS empty-results state is missing an initial focus
target because focusFirstRow() only assigns results.first?.id in the .results
phase, which is nil when tvResultRows shows the "back-to-languages" fallback
row. Update focusFirstRow() in SubtitleSearchMenu to detect an empty results
list and set focusedRowID to the fallback row’s id (the same identifier used by
tvResultRows for the back-to-languages row), so on empty searches and when
.onChange(of: phase) runs, a valid row is focused instead of leaving focus
empty.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Player/Sheets/SubtitleSearchMenu.swift`:
- Around line 58-59: searchTask is only cancelled through backToLanguages(), but
the direct dismiss paths in SubtitleSearchMenu’s onDismiss handlers can bypass
that cleanup and leave the in-flight search mutating state after dismissal.
Update the dismissal flow so every path that closes the sheet/menu also cancels
searchTask before exiting, and make sure the existing
backToLanguages()/onDismiss logic in SubtitleSearchMenu covers both the tvOS
backdrop tap and the iOS Done button.
🪄 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: 8a5b4dfa-4ae2-4f44-b0ec-bd7cc0e0e996
📒 Files selected for processing (7)
iosApp/Tests/SubtitleSearchModelTests.swiftiosApp/iosApp/Networking/ContinuumAI.swiftiosApp/iosApp/Networking/SubtitleSearchModels.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/Sheets/SubtitleSearchMenu.swiftiosApp/iosApp/Screens/Player/Sheets/TrackSelectionSheet.swiftiosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swift
- Key search-result UI identity on the composite provider:id pair (uniqueKey) instead of the provider-local id, which can collide across providers — coalesced ForEach rows and misplaced spinner/disabled state (Codex) - Revalidate the current media file after the download awaits so a mid-download item change can't register the old file's listing position against the new session (Codex) - tvOS: focus the "Choose another language" fallback row when a search returns no results, so the remote isn't left unfocused (CodeRabbit) Co-Authored-By: Claude Fable 5 <[email protected]>
|
Addressed all three review findings in f3de1b9:
SiloTV build green, all 6 model tests pass. |
Summary
Search external subtitle providers (OpenSubtitles / SubDL / Subsource) from inside the player and download a result mid-playback — parity with the Android and web clients.
POST /subtitles/search+/subtitles/downloadwire types andContinuumAImethods (synchronous two-call API, no job machinery; per-provider soft failures surface as warnings).SubtitleSearchMenu: one-tap language pick (preferred language floats to top, no free-text field), score/provider/HI-badged results; iOS sheet + tvOS focus panel following theSubtitleTranslateMenuidioms.subtitle_readywebsocket echo is a no-op via the existing combined-index de-dupe.TrackSelectionSheet(iOS) and theTVPlayerInfoHUDSubtitles pane (tvOS), gated on an active server session (hidden for offline/local playback); tvOS Back is inert while a download is in flight.Testing
🤖 Generated with Claude Code
Summary by CodeRabbit