Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

feat(live): cover graph and player mapping seams

David Nashash8a3e8cd1b5cb
diff --git a/app/src/main/java/com/streamvault/app/live/AppLivePlaybackRequestMapper.kt b/app/src/main/java/com/streamvault/app/live/AppLivePlaybackRequestMapper.kt
new file mode 100644
index 00000000..7f97bc84
--- /dev/null
+++ b/app/src/main/java/com/streamvault/app/live/AppLivePlaybackRequestMapper.kt
@@ -0,0 +1,45 @@
+package com.streamvault.app.live
+
+import com.streamvault.app.navigation.AppRouteCodec
+import com.streamvault.app.navigation.playerNavigationRequest
+import com.streamvault.app.navigation.toLivePlayerRequest
+import com.streamvault.core.navigation.PlayerNavigationRequest
+import com.streamvault.domain.playback.isArchivePlayable
+import com.streamvault.feature.live.api.LiveArchivePlaybackRequest
+import com.streamvault.feature.live.api.LiveChannelPlaybackRequest
+
+/** Maps feature-owned Live intents into the app's player payload at the composition boundary. */
+internal fun LiveChannelPlaybackRequest.toAppPlayerNavigationRequest(): PlayerNavigationRequest =
+ channel.toLivePlayerRequest(
+ categoryId = categoryId,
+ providerId = providerId,
+ isVirtual = isVirtual,
+ combinedProfileId = combinedProfileId,
+ combinedSourceFilterProviderId = combinedSourceFilterProviderId,
+ returnDestination = returnRoute?.let(AppRouteCodec::decode),
+ )
+
+/**
+ * Maps an archive intent only when the domain playback policy accepts its program. Keeping the
+ * rejection here preserves the existing app callback boundary and makes it testable in isolation.
+ */
+internal fun LiveArchivePlaybackRequest.toAppArchivePlayerNavigationRequest(
+ now: Long = System.currentTimeMillis(),
+): PlayerNavigationRequest? {
+ if (!channel.isArchivePlayable(program, now)) return null
+ return playerNavigationRequest(
+ streamUrl = channel.streamUrl,
+ title = channel.name,
+ channelId = channel.epgChannelId,
+ internalId = channel.id,
+ categoryId = categoryId,
+ providerId = channel.providerId,
+ isVirtual = isVirtual,
+ combinedProfileId = combinedProfileId,
+ contentType = "LIVE",
+ archiveStartMs = program.startTime,
+ archiveEndMs = program.endTime,
+ archiveTitle = "${channel.name}: ${program.title}",
+ returnDestination = returnRoute?.let(AppRouteCodec::decode),
+ )
+}
diff --git a/app/src/main/java/com/streamvault/app/navigation/graph/LiveGraph.kt b/app/src/main/java/com/streamvault/app/navigation/graph/LiveGraph.kt
index bd1b52d8..733c5b96 100644
--- a/app/src/main/java/com/streamvault/app/navigation/graph/LiveGraph.kt
+++ b/app/src/main/java/com/streamvault/app/navigation/graph/LiveGraph.kt
@@ -4,8 +4,8 @@ import androidx.navigation.NavGraphBuilder
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import com.streamvault.app.navigation.AppRouteCodec
import com.streamvault.app.navigation.AppRoutePatterns
-import com.streamvault.app.navigation.playerNavigationRequest
-import com.streamvault.app.navigation.toLivePlayerRequest
+import com.streamvault.app.live.toAppArchivePlayerNavigationRequest
+import com.streamvault.app.live.toAppPlayerNavigationRequest
import com.streamvault.app.ui.components.shell.AppNavigationChrome
import com.streamvault.app.ui.components.shell.AppScreenScaffold
import com.streamvault.app.ui.components.dialogs.AddToGroupDialog
@@ -145,35 +145,10 @@ internal fun NavGraphBuilder.registerLiveGraph(
)
},
onPlaybackRequested = { request ->
- actions.openPlayer(
- request.channel.toLivePlayerRequest(
- categoryId = request.categoryId,
- providerId = request.providerId,
- isVirtual = request.isVirtual,
- combinedProfileId = request.combinedProfileId,
- combinedSourceFilterProviderId = request.combinedSourceFilterProviderId,
- returnDestination = request.returnRoute?.let(AppRouteCodec::decode),
- )
- )
+ actions.openPlayer(request.toAppPlayerNavigationRequest())
},
onArchivePlaybackRequested = { request ->
- actions.openPlayer(
- playerNavigationRequest(
- streamUrl = request.channel.streamUrl,
- title = request.channel.name,
- channelId = request.channel.epgChannelId,
- internalId = request.channel.id,
- categoryId = request.categoryId,
- providerId = request.channel.providerId,
- isVirtual = request.isVirtual,
- combinedProfileId = request.combinedProfileId,
- contentType = "LIVE",
- archiveStartMs = request.program.startTime,
- archiveEndMs = request.program.endTime,
- archiveTitle = "${request.channel.name}: ${request.program.title}",
- returnDestination = request.returnRoute?.let(AppRouteCodec::decode),
- )
- )
+ request.toAppArchivePlayerNavigationRequest()?.let(actions::openPlayer)
},
onNavigate = { route ->
AppRouteCodec.decode(route)?.let(onTopLevelDestinationRequested)
diff --git a/app/src/test/java/com/streamvault/app/live/AppLivePlaybackRequestMapperTest.kt b/app/src/test/java/com/streamvault/app/live/AppLivePlaybackRequestMapperTest.kt
new file mode 100644
index 00000000..359cb9d7
--- /dev/null
+++ b/app/src/test/java/com/streamvault/app/live/AppLivePlaybackRequestMapperTest.kt
@@ -0,0 +1,125 @@
+package com.streamvault.app.live
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.app.navigation.AppRouteCodec
+import com.streamvault.core.navigation.AppDestination
+import com.streamvault.domain.model.Channel
+import com.streamvault.domain.model.Program
+import com.streamvault.domain.repository.ChannelRepository
+import com.streamvault.feature.live.api.LiveArchivePlaybackRequest
+import com.streamvault.feature.live.api.LiveChannelPlaybackRequest
+import org.junit.Test
+
+class AppLivePlaybackRequestMapperTest {
+
+ @Test
+ fun channelRequest_mapsToLivePlayerPayloadWithoutDroppingMetadata() {
+ val channel = Channel(
+ id = 42L,
+ name = "News",
+ streamUrl = "https://example.test/news.m3u8",
+ epgChannelId = "news-epg",
+ providerId = 7L,
+ )
+ val returnDestination = AppDestination.Guide(12L, 1_700_000_000_000L, true)
+
+ val request = LiveChannelPlaybackRequest(
+ channel = channel,
+ categoryId = null,
+ providerId = 7L,
+ isVirtual = true,
+ combinedProfileId = 34L,
+ combinedSourceFilterProviderId = 56L,
+ returnRoute = AppRouteCodec.encode(returnDestination),
+ ).toAppPlayerNavigationRequest()
+
+ assertThat(request.streamUrl).isEqualTo(channel.streamUrl)
+ assertThat(request.title).isEqualTo(channel.name)
+ assertThat(request.channelId).isEqualTo(channel.epgChannelId)
+ assertThat(request.internalId).isEqualTo(channel.id)
+ assertThat(request.categoryId).isEqualTo(ChannelRepository.ALL_CHANNELS_ID)
+ assertThat(request.providerId).isEqualTo(channel.providerId)
+ assertThat(request.isVirtual).isTrue()
+ assertThat(request.combinedProfileId).isEqualTo(34L)
+ assertThat(request.combinedSourceFilterProviderId).isEqualTo(56L)
+ assertThat(request.contentType).isEqualTo("LIVE")
+ assertThat(request.returnDestination).isEqualTo(returnDestination)
+ }
+
+ @Test
+ fun archiveRequest_mapsArchiveWindowAndGuideReturnDestination() {
+ val channel = Channel(
+ id = 42L,
+ name = "News",
+ streamUrl = "https://example.test/news.m3u8",
+ epgChannelId = "news-epg",
+ providerId = 7L,
+ catchUpSupported = true,
+ catchUpDays = 2,
+ catchUpSource = "https://example.test/archive/{start}/{end}",
+ )
+ val program = Program(
+ id = 99L,
+ channelId = "news-epg",
+ title = "The Briefing",
+ startTime = 1_700_000_000_000L,
+ endTime = 1_700_000_600_000L,
+ hasArchive = true,
+ providerId = 7L,
+ )
+ val returnDestination = AppDestination.Guide(12L, 1_700_000_000_000L, true)
+
+ val request = LiveArchivePlaybackRequest(
+ channel = channel,
+ program = program,
+ categoryId = 12L,
+ isVirtual = false,
+ combinedProfileId = 34L,
+ returnRoute = AppRouteCodec.encode(returnDestination),
+ ).toAppArchivePlayerNavigationRequest(now = program.endTime + 1L)
+
+ assertThat(request).isNotNull()
+ assertThat(request!!.streamUrl).isEqualTo(channel.streamUrl)
+ assertThat(request.title).isEqualTo(channel.name)
+ assertThat(request.channelId).isEqualTo(channel.epgChannelId)
+ assertThat(request.internalId).isEqualTo(channel.id)
+ assertThat(request.categoryId).isEqualTo(12L)
+ assertThat(request.providerId).isEqualTo(channel.providerId)
+ assertThat(request.isVirtual).isFalse()
+ assertThat(request.combinedProfileId).isEqualTo(34L)
+ assertThat(request.contentType).isEqualTo("LIVE")
+ assertThat(request.archiveStartMs).isEqualTo(program.startTime)
+ assertThat(request.archiveEndMs).isEqualTo(program.endTime)
+ assertThat(request.archiveTitle).isEqualTo("${channel.name}: ${program.title}")
+ assertThat(request.returnDestination).isEqualTo(returnDestination)
+ }
+
+ @Test
+ fun archiveRequest_rejectsUnplayableProgramAtMapperBoundary() {
+ val channel = Channel(
+ id = 42L,
+ name = "News",
+ streamUrl = "https://example.test/news.m3u8",
+ providerId = 7L,
+ )
+ val program = Program(
+ id = 99L,
+ channelId = "news-epg",
+ title = "The Briefing",
+ startTime = 1_700_000_000_000L,
+ endTime = 1_700_000_600_000L,
+ providerId = 7L,
+ )
+
+ val request = LiveArchivePlaybackRequest(
+ channel = channel,
+ program = program,
+ categoryId = 12L,
+ isVirtual = false,
+ combinedProfileId = null,
+ returnRoute = null,
+ ).toAppArchivePlayerNavigationRequest(now = program.endTime + 1L)
+
+ assertThat(request).isNull()
+ }
+}
diff --git a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
index b71d6b24..b9051e34 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -804,7 +804,7 @@ remain intact for other consumers. Copy exact values for every non-default
key, then run a comparison script before removing any app key. Locale parity
and removal are still open.
-- [ ] **Step 8: Run Home feature and app integration checks**
+- [x] **Step 8: Run Home feature and app integration checks**
```powershell
./gradlew.bat :feature:live:verifyFeatureLiveBoundary :feature:live:testDebugUnitTest --tests "com.streamvault.feature.live.home.*" :feature:live:compileDebugAndroidTestKotlin :app:compileDebugKotlin :app:compileDebugUnitTestKotlin --no-daemon --console=plain --warning-mode=none
@@ -812,7 +812,7 @@ and removal are still open.
Expected: PASS; no app or Playback feature import exists under `feature/live/src/main`.
-- [ ] **Step 9: Commit Home ownership**
+- [x] **Step 9: Commit Home ownership**
```powershell
git add app/src/main/java/com/streamvault/app/ui/screens/home app/src/test/java/com/streamvault/app/ui/screens/home feature/live
@@ -914,7 +914,7 @@ reminder, recording-conflict, notification-permission, and EPG-only shared
values in `feature/live`. Non-default locale parity and app-key removal remain
open; remove app entries only after `rg` proves no remaining consumer.
-- [ ] **Step 9: Run EPG feature and app integration checks**
+- [x] **Step 9: Run EPG feature and app integration checks**
```powershell
./gradlew.bat :feature:live:verifyFeatureLiveBoundary :feature:live:testDebugUnitTest --tests "com.streamvault.feature.live.epg.*" :feature:live:compileDebugAndroidTestKotlin :app:compileDebugKotlin :app:compileDebugUnitTestKotlin --no-daemon --console=plain --warning-mode=none
@@ -922,7 +922,7 @@ open; remove app entries only after `rg` proves no remaining consumer.
Expected: PASS with no app/feature implementation imports under live main source.
-- [ ] **Step 10: Commit EPG ownership**
+- [x] **Step 10: Commit EPG ownership**
```powershell
git add app/src/main/java/com/streamvault/app/ui/screens/epg app/src/test/java/com/streamvault/app/ui/screens/epg feature/live
@@ -946,7 +946,7 @@ git commit -m "feat(live): move EPG presentation into feature"
- Consumes: live route/request contracts, feature screens, `UiDestination`, app navigation adapters, and existing Playback planner.
- Produces: controller-free `registerLiveGraph` called by `AppNavHost`, with field-for-field player request mapping and app-composed MultiView planner.
-- [ ] **Step 1: Write failing graph contract tests**
+- [x] **Step 1: Add graph contract coverage**
Use `TestNavHostController`/Navigation testing to assert:
@@ -959,11 +959,16 @@ Use `TestNavHostController`/Navigation testing to assert:
Run the focused test; expected missing `registerLiveGraph` failure.
+`LiveGraphBehaviorTest` now runs connected on the TV emulator and verifies the
+Live category argument, Guide optional arguments, and typed channel/archive
+callback payloads. The test is green; a separate pre-implementation RED run
+was not needed because the feature graph was already present at this checkpoint.
+
- [x] **Step 2: Implement feature graph registration minimally**
Use the exact signature from the spec. Construct both `composable` destinations with current `NavType` and defaults. Call `HomeScreen` and `FullEpgScreen` directly. Do not import app route codecs or construct `PlayerNavigationRequest` in the feature.
-- [ ] **Step 3: Write failing app player-mapping tests**
+- [x] **Step 3: Write app player-mapping tests**
For a channel request assert stream URL, title, EPG channel ID, internal ID,
category fallback to `ChannelRepository.ALL_CHANNELS_ID`, provider, virtual,
@@ -973,6 +978,9 @@ For archive assert archive start/end/title, category/provider identity,
`contentType = "LIVE"`, and Guide return destination. Include the existing
`isArchivePlayable` rejection at the app callback boundary.
+`AppLivePlaybackRequestMapperTest` covers these fields and the rejection path;
+the first run was intentionally red until the mapper existed.
+
- [x] **Step 4: Implement app request mapping and run GREEN**
Delegate to the existing `playerNavigationRequest`/`toLivePlayerRequest`
@@ -993,7 +1001,7 @@ Replace the app graph call with `com.streamvault.feature.live.navigation.registe
First compile while the old app registration still exists and confirm the duplicate-route or duplicate-symbol problem is observable. Remove only the old `LiveGraph.kt`, then rerun.
-- [ ] **Step 7: Run route, mapping, app navigation, and feature checks**
+- [x] **Step 7: Run route, mapping, app navigation, and feature checks**
```powershell
./gradlew.bat :feature:live:testDebugUnitTest --tests "com.streamvault.feature.live.navigation.*" :app:testDebugUnitTest --tests "com.streamvault.app.live.AppLivePlaybackRequestMapperTest" --tests "com.streamvault.app.navigation.*" :feature:live:verifyFeatureLiveBoundary :app:compileDebugKotlin --no-daemon --console=plain --warning-mode=none
@@ -1001,6 +1009,9 @@ First compile while the old app registration still exists and confirm the duplic
Expected: PASS with one production owner for each live destination.
+The route/mapping/navigation bundle passed on 2026-08-29, including the Live
+boundary verifier and app Kotlin compilation.
+
- [ ] **Step 8: Commit graph ownership**
```powershell
diff --git a/feature/live/src/androidTest/java/com/streamvault/feature/live/navigation/LiveGraphBehaviorTest.kt b/feature/live/src/androidTest/java/com/streamvault/feature/live/navigation/LiveGraphBehaviorTest.kt
new file mode 100644
index 00000000..3e2f6fff
--- /dev/null
+++ b/feature/live/src/androidTest/java/com/streamvault/feature/live/navigation/LiveGraphBehaviorTest.kt
@@ -0,0 +1,171 @@
+package com.streamvault.feature.live.navigation
+
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.navigation.compose.ComposeNavigator
+import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
+import androidx.navigation.testing.TestNavHostController
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.Channel
+import com.streamvault.domain.model.Program
+import com.streamvault.feature.live.api.LiveArchivePlaybackRequest
+import com.streamvault.feature.live.api.LiveChannelPlaybackRequest
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class LiveGraphBehaviorTest {
+
+ @get:Rule
+ val composeRule = createComposeRule()
+
+ @Test
+ fun liveRoute_passesCategoryArgumentToFeatureContent() {
+ lateinit var navController: TestNavHostController
+ var receivedCategoryId: Long? = null
+
+ composeRule.setContent {
+ navController = rememberTestNavController()
+ NavHost(navController = navController, startDestination = "home") {
+ composable("home") {
+ LaunchedEffect(Unit) {
+ navController.navigate("live_tv?categoryId=42")
+ }
+ }
+ registerLiveGraph(
+ liveTvContent = { initialCategoryId, _, _ ->
+ receivedCategoryId = initialCategoryId
+ },
+ epgContent = { _, _, _, _, _, _ -> },
+ onPlaybackRequested = {},
+ onArchivePlaybackRequested = {},
+ onNavigate = {},
+ )
+ }
+ }
+
+ composeRule.waitUntil(5_000) { receivedCategoryId == 42L }
+ assertThat(navController.currentBackStackEntry?.arguments?.getLong("categoryId"))
+ .isEqualTo(42L)
+ assertThat(receivedCategoryId).isEqualTo(42L)
+ }
+
+ @Test
+ fun epgRoute_preservesOptionalArgumentsAndTypedPlaybackCallbacks() {
+ lateinit var navController: TestNavHostController
+ var receivedCategoryId: Long? = null
+ var receivedAnchorTime: Long? = null
+ var receivedFavoritesOnly = false
+ var channelRequest: LiveChannelPlaybackRequest? = null
+ var archiveRequest: LiveArchivePlaybackRequest? = null
+ val channel = Channel(
+ id = 7L,
+ name = "Guide News",
+ streamUrl = "https://example.test/live.m3u8",
+ providerId = 3L,
+ )
+ val program = Program(
+ id = 9L,
+ channelId = "guide-news",
+ title = "Headlines",
+ startTime = 1_700_000_000_000L,
+ endTime = 1_700_000_600_000L,
+ providerId = 3L,
+ )
+
+ composeRule.setContent {
+ navController = rememberTestNavController()
+ NavHost(navController = navController, startDestination = "home") {
+ composable("home") {
+ LaunchedEffect(Unit) {
+ navController.navigate(
+ "epg?categoryId=12&anchorTime=1700000000000&favoritesOnly=true"
+ )
+ }
+ }
+ registerLiveGraph(
+ liveTvContent = { _, _, _ -> },
+ epgContent = { categoryId, anchorTime, favoritesOnly, onPlayChannel, onPlayArchive, _ ->
+ receivedCategoryId = categoryId
+ receivedAnchorTime = anchorTime
+ receivedFavoritesOnly = favoritesOnly
+ LaunchedEffect(Unit) {
+ onPlayChannel(
+ LiveChannelPlaybackRequest(
+ channel = channel,
+ categoryId = categoryId,
+ providerId = channel.providerId,
+ isVirtual = false,
+ combinedProfileId = null,
+ combinedSourceFilterProviderId = null,
+ returnRoute = LiveRoutePatterns.epg(
+ categoryId,
+ anchorTime,
+ favoritesOnly,
+ ),
+ )
+ )
+ onPlayArchive(
+ LiveArchivePlaybackRequest(
+ channel = channel,
+ program = program,
+ categoryId = categoryId,
+ isVirtual = false,
+ combinedProfileId = null,
+ returnRoute = LiveRoutePatterns.epg(
+ categoryId,
+ anchorTime,
+ favoritesOnly,
+ ),
+ )
+ )
+ }
+ },
+ onPlaybackRequested = { channelRequest = it },
+ onArchivePlaybackRequested = { archiveRequest = it },
+ onNavigate = {},
+ )
+ }
+ }
+
+ composeRule.waitUntil(5_000) {
+ receivedCategoryId == 12L &&
+ receivedAnchorTime == 1_700_000_000_000L &&
+ receivedFavoritesOnly &&
+ channelRequest != null &&
+ archiveRequest != null
+ }
+
+ assertThat(navController.currentBackStackEntry?.arguments?.getLong("categoryId"))
+ .isEqualTo(12L)
+ assertThat(navController.currentBackStackEntry?.arguments?.getLong("anchorTime"))
+ .isEqualTo(1_700_000_000_000L)
+ assertThat(navController.currentBackStackEntry?.arguments?.getBoolean("favoritesOnly"))
+ .isTrue()
+ assertThat(channelRequest?.channel).isSameInstanceAs(channel)
+ assertThat(channelRequest?.returnRoute).isEqualTo(
+ "epg?categoryId=12&anchorTime=1700000000000&favoritesOnly=true"
+ )
+ assertThat(archiveRequest?.channel).isSameInstanceAs(channel)
+ assertThat(archiveRequest?.program).isSameInstanceAs(program)
+ assertThat(archiveRequest?.returnRoute).isEqualTo(
+ "epg?categoryId=12&anchorTime=1700000000000&favoritesOnly=true"
+ )
+ }
+
+ @Composable
+ private fun rememberTestNavController(): TestNavHostController {
+ val context = LocalContext.current
+ return remember(context) {
+ TestNavHostController(context).apply {
+ navigatorProvider.addNavigator(ComposeNavigator())
+ }
+ }
+ }
+}