Skip to content

Move Live TV and quality ladder to /api/v2 - #43

Merged
JonahMMay merged 2 commits into
mainfrom
feat/apiv2-livetv
Oct 13, 2026
Merged

JonahMMay merged 2 commits into
mainfrom
feat/apiv2-livetv

Conversation

@JonahMMay

@JonahMMay JonahMMay commented Oct 12, 2026 •

Copy link
Copy Markdown

Moves the Android phone and TV apps' Live TV and quality-ladder calls from /api/v1 to the new server /api/v2 routes (server: Prairie-Server/prairie-server#231). Context: Prairie-Server/prairie-smarttv#131.

Changes

  • LiveTvApi: /api/v2/livetv/..., problem+json errors via safeApiV2Call + ApiV2Gate.
    • channels / guide / recordings parse {items} envelopes.
    • guide sends repeated channel_id (was comma-separated channels).
    • session start is POST .../channels/{id}/sessions; play stream_url exactly as returned (it stays on v1 media routes). hls_url and the channel stream_url are dropped.
    • stop (DELETE .../sessions/{id}) returns 204, so releaseSession is ApiResult<Unit>.
  • LiveTvFeatureStore: a 409 capability_not_configured hides Live TV. Other errors still keep the previous value.
  • PlaybackApi: the quality ladder moves to /api/v2/playback/quality-ladder.
  • Tests updated for the new paths and parsing. Added tests for the items envelope, the 409 problem code and the feature-store hide.

Not applicable: the app has no admin Live TV routes, no series-rules UI and no dbg beacon. The vendored apiv2 fixtures and prairie-invariants.txt don't pin these paths.

Test checklist

  • Phone: Live TV tab shows channels and guide; a channel plays (HLS and MPEG-TS); leaving the player stops the session
  • Phone: schedule and cancel a recording; recordings list loads
  • Phone: quality picker shows the ladder
  • TV: Live TV tab shows channels and guide; a channel plays; back stops the session
  • TV: schedule and cancel a recording; quality picker shows the ladder
  • Both: Live TV entry is hidden when Live TV is off on the server (409)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Updated Live TV support for the latest service, including channel listings, guides, recordings, and playback sessions.
    • Live TV now becomes unavailable when the service reports that the feature is not configured.
    • Updated playback quality options to use the latest quality-ladder service.
  • Bug Fixes
    • Improved handling of Live TV responses and session release results.

Live TV viewer calls move to /api/v2/livetv: {items} envelopes, guide
uses repeated channel_id, session start POSTs .../sessions and plays the
returned stream_url (hls_url is gone), stop is 204, problem+json errors.
A 409 capability_not_configured now hides the Live TV surface. The
quality ladder moves to /api/v2/playback/quality-ladder.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f07b9555-27a0-4c44-8fb1-565afb9d1d9a
📥 Commits

Reviewing files that changed from the base of the PR and between f4877f1 and cacb464.

📒 Files selected for processing (1)
  • shared/src/commonTest/kotlin/org/prairieserver/prairie/viewmodel/HomeViewModelCacheIdentityTest.kt

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eb7a45bf-90eb-458a-b6f6-ac3cf5358757
📥 Commits

Reviewing files that changed from the base of the PR and between 7041ee8 and f4877f1.

📒 Files selected for processing (14)
  • androidApp/src/androidMain/kotlin/org/prairieserver/prairie/android/ui/screens/player/PlayerOverlay.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/di/NetworkModule.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/model/feature/LiveTvFeatureStore.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/model/livetv/LiveTvModels.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/network/api/LiveTvApi.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/network/api/PlaybackApi.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/playback/QualityLadder.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/repository/LiveTvRepository.kt
  • shared/src/commonMain/kotlin/org/prairieserver/prairie/repository/PlaybackRepository.kt
  • shared/src/commonTest/kotlin/org/prairieserver/prairie/model/feature/LiveTvFeatureStoreTest.kt
  • shared/src/commonTest/kotlin/org/prairieserver/prairie/network/api/LiveTvApiTest.kt
  • shared/src/commonTest/kotlin/org/prairieserver/prairie/network/api/PlaybackApiTest.kt
  • shared/src/commonTest/kotlin/org/prairieserver/prairie/repository/LiveTvRepositoryTest.kt
  • shared/src/commonTest/kotlin/org/prairieserver/prairie/viewmodel/LiveTvViewModelTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Walkthrough

Live TV requests now use v2 routes and response models. Session release returns Unit, and a current refresh disables Live TV for a 409 capability_not_configured error. The playback quality-ladder request now uses its v2 route.

Changes

Live TV API v2

Layer / File(s) Summary
Live TV response contracts
shared/src/commonMain/kotlin/org/prairieserver/prairie/model/livetv/LiveTvModels.kt
Response collections map from items. Session responses include channelId, status, and staleAfterSeconds, and recordings include nullable profileId. Session playback uses streamUrl.
Live TV v2 requests and release results
shared/src/commonMain/kotlin/org/prairieserver/prairie/network/api/LiveTvApi.kt, shared/src/commonMain/kotlin/org/prairieserver/prairie/repository/LiveTvRepository.kt, shared/src/commonMain/kotlin/org/prairieserver/prairie/di/NetworkModule.kt, shared/src/commonTest/kotlin/org/prairieserver/prairie/network/api/LiveTvApiTest.kt, shared/src/commonTest/kotlin/org/prairieserver/prairie/repository/LiveTvRepositoryTest.kt, shared/src/commonTest/kotlin/org/prairieserver/prairie/viewmodel/LiveTvViewModelTest.kt
Requests use /api/v2/livetv, guide channel IDs use repeated channel_id parameters, and session creation uses the plural /sessions path. Session release returns ApiResult<Unit>. Tests cover the updated routes and response shapes.
Capability error and Live TV state
shared/src/commonMain/kotlin/org/prairieserver/prairie/model/feature/LiveTvFeatureStore.kt, shared/src/commonTest/kotlin/org/prairieserver/prairie/model/feature/LiveTvFeatureStoreTest.kt
A current refresh disables Live TV when the API returns status 409 with error capability_not_configured. Other API errors and network errors leave the enabled state unchanged.

Playback quality ladder

Layer / File(s) Summary
Quality-ladder v2 route
shared/src/commonMain/kotlin/org/prairieserver/prairie/network/api/PlaybackApi.kt, shared/src/commonMain/kotlin/org/prairieserver/prairie/di/NetworkModule.kt, androidApp/src/androidMain/kotlin/org/prairieserver/prairie/android/ui/screens/player/PlayerOverlay.kt, shared/src/commonMain/kotlin/org/prairieserver/prairie/playback/QualityLadder.kt, shared/src/commonMain/kotlin/org/prairieserver/prairie/repository/PlaybackRepository.kt, shared/src/commonTest/kotlin/org/prairieserver/prairie/network/api/PlaybackApiTest.kt
The quality-ladder request and its test expectations use /api/v2/playback/quality-ladder. Related comments identify the v2 route.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant DefaultLiveTvApi
  participant safeApiV2Call
  participant PrairieServerV2LiveTvApi
  DefaultLiveTvApi->>safeApiV2Call: Build and send /api/v2/livetv request
  safeApiV2Call->>PrairieServerV2LiveTvApi: Forward request
  PrairieServerV2LiveTvApi-->>safeApiV2Call: Return response
  safeApiV2Call-->>DefaultLiveTvApi: Return ApiResult
Loading

Suggested reviewers: cursoragent

Merge Risk: ⚪ Minimal · up to f4877

No actionable issue remains in the reviewed changes. The reported overlapping-refresh behavior is not reachable through the production caller.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 2.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main change: moving Live TV and quality-ladder API calls to /api/v2.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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.

realtimeSignalsDuringARefreshRunOneMoreRefreshAfterIt returned while the
follow-up fetch was still out on the MockEngine's IO thread. It then resumed
onto a reset Dispatchers.Main and failed the next runTest (LiveTvViewModelTest)
with UncaughtExceptionsBeforeTest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@JonahMMay
JonahMMay merged commit e573e59 into main Oct 13, 2026
6 checks passed
@JonahMMay
JonahMMay deleted the feat/apiv2-livetv branch October 13, 2026 00:10
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