Skip to content

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

refactor(live): move Home ViewModel into feature

David Nashashf5b069ff3afd
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
index 351f1581..2ddb3afa 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
@@ -50,6 +50,7 @@ import androidx.lifecycle.compose.LifecycleEventEffect
import com.streamvault.app.ui.components.CategoryRow
import com.streamvault.app.ui.components.ChannelCard
import com.streamvault.feature.live.presentation.components.LiveChannelProgressTicker
+import com.streamvault.feature.live.home.HomeViewModel
import com.streamvault.app.ui.components.LiveSourceSwitcher
import com.streamvault.core.ui.components.shell.ContentMetadataStrip
import com.streamvault.app.ui.components.shell.LiveChannelRowSurface
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
index ff98d248..9944496a 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
@@ -13,6 +13,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.streamvault.app.R
import com.streamvault.feature.live.presentation.home.HomeUiState
+import com.streamvault.feature.live.home.HomeViewModel
import com.streamvault.app.navigation.Routes
import com.streamvault.core.ui.components.SearchInput
import com.streamvault.app.ui.components.dialogs.AddToGroupDialog
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index 031e5887..371e34f0 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -126,9 +126,10 @@ These are transitional adapters, not new policy owners:
The `:feature:live` module itself depends only on `:core:navigation`, `:core:ui`,
`:domain`, `:data`, and `:player`; its boundary verifier rejects app and
-feature-to-feature imports. Home and Guide ViewModels currently remain in
-`:app` while their preview and platform dependencies are ported. Live-owned
-presentation primitives, `HomeUiState`, and Guide mode/density/reminder
-presentation models are now independent of app code; screen/resource moves,
-golden/runtime/performance gates, and legacy app cleanup remain open, so no
-live slice acceptance gate is claimed yet.
+feature-to-feature imports. Home and Guide ViewModels are being moved behind
+the live boundary incrementally: `HomeViewModel` is now feature-owned while
+the Home screen/dialog/sidebar composition remains in `:app`. Live-owned
+presentation primitives, `HomeUiState`, `HomePreviewUiState`, and Guide
+mode/density/reminder presentation models are independent of app code;
+screen/resource moves, golden/runtime/performance gates, and legacy app cleanup
+remain open, so no live slice acceptance gate is claimed yet.
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 0e63ea27..72109878 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -10,20 +10,24 @@
**Spec:** `docs/superpowers/specs/2026-08-28-phase-5-live-feature-extraction-design.md`
-**Implementation status (2026-08-28):** Tasks 0–1, the preview/platform port
+**Implementation status (2026-08-29):** Tasks 0–1, the preview/platform port
portion of Tasks 2–4, the Live presentation primitive set, HomeUiState, and
-the pure Guide presentation models are complete and committed. Home/Guide
-screen and ViewModel ownership, feature-owned resources, golden/runtime/
-performance gates, and legacy app cleanup remain open; this plan does not
+the pure Guide presentation models and HomeViewModel are complete and committed.
+Home/Guide screen and ViewModel ownership, feature-owned resource migration,
+golden/runtime/performance gates, and legacy app cleanup remain open; this plan does not
claim the Live slice or Phase 5 complete.
+Status update (2026-08-29): `HomeViewModel` is now feature-owned and its
+relocated test suite is green. Home screen/dialog/sidebar composition,
+feature-owned resource migration, and acceptance gates remain open.
+
Route patterns were subsequently moved behind `LiveRoutePatterns`; the app
codec still owns encode/decode compatibility and no route behavior changed.
The feature-owned `registerLiveGraph` now owns Live destination argument
registration; the app graph supplies existing screen content and performs
typed player-request mapping. Pure guide lookup/time-format and Guide
-mode/density/reminder-message seams are also feature-owned. Screen/resource
-ownership is still open.
+mode/density/reminder-message seams are also feature-owned. Home
+screen/dialog/sidebar and resource ownership are still open.
## Global Constraints
@@ -572,7 +576,7 @@ git commit -m "feat(live): add app-independent presentation primitives"
- Consumes: Tasks 3-5 ports/components and current Home constructor/state/method behavior.
- Produces: feature-owned `HomeViewModel`, `HomeUiState`, `HomePreviewUiState`, `HomeScreen`, dialogs, sidebars, resources, and independent tests.
-- [ ] **Step 1: Move the Home tests first and verify RED**
+- [x] **Step 1: Move the Home tests first and verify RED**
Change only package/imports needed for the feature test source set. Replace direct app/Playback implementation fixtures with fakes for the Task 3 ports while preserving every repository and state expectation.
@@ -584,7 +588,10 @@ Run:
Expected: FAIL because feature-owned `HomeViewModel` is absent.
-- [ ] **Step 2: Move Home state/ViewModel mechanically**
+Observed RED on 2026-08-29 after moving the test package: unresolved
+`HomeViewModel` and dependent members in the feature test source set.
+
+- [x] **Step 2: Move Home state/ViewModel mechanically**
Move `HomePreviewUiState.kt` and `HomeViewModel.kt`; change packages and resources only. Replace:
@@ -598,6 +605,11 @@ MultiViewManager slots/capacity -> LiveMultiViewStatusPort.status
Keep constructor order otherwise stable. Preserve the separate `_uiState` and `_previewUiState`, session versioning, job cancellation, player configuration, adaptive reprime delay, error strings, and engine identity checks.
+`HomeViewModel` now lives under `com.streamvault.feature.live.home`, uses the
+feature resource namespace, and keeps the existing port-based preview and
+surface-refresh seams. `HomeUiState` and `HomePreviewUiState` remain
+feature-owned.
+
- [ ] **Step 3: Add and run focused preview RED/GREEN tests**
`HomePreviewPortTest` must assert:
@@ -611,7 +623,7 @@ Keep constructor order otherwise stable. Preserve the separate `_uiState` and `_
Run the focused test after each minimal adapter replacement. Expected: RED on the old direct implementation call, then PASS after the corresponding port call.
-- [ ] **Step 4: Run the complete moved Home suite**
+- [x] **Step 4: Run the complete moved Home suite**
```powershell
./gradlew.bat :feature:live:testDebugUnitTest --tests "com.streamvault.feature.live.home.*" --no-daemon --console=plain --warning-mode=none
@@ -619,6 +631,9 @@ Run the focused test after each minimal adapter replacement. Expected: RED on th
Expected: PASS with the same behavioral assertions as the pre-extraction app suite.
+Observed GREEN on 2026-08-29 for `com.streamvault.feature.live.home.*`; the
+feature boundary verifier and app Kotlin/unit-test compilation also pass.
+
- [ ] **Step 5: Write failing Home screen behavior tests**
Cover route category initialization, source/category/channel focus, quick-filter visibility, search, Back/dialog ordering, PIN unlock, preview placeholder/loading/error/render states, stable channel semantics, and planner callbacks. The planner fake records `pendingChannel`, dismiss, and launch events without importing Playback.
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt b/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt
index b101998b..e487abfd 100644
--- a/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt
+++ b/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt
@@ -1,4 +1,4 @@
-package com.streamvault.app.ui.screens.home
+package com.streamvault.feature.live.home
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@@ -56,7 +56,7 @@ import com.streamvault.player.PlayerEngine
import com.streamvault.feature.live.presentation.home.HomePreviewUiState
import com.streamvault.feature.live.presentation.home.HomeUiState
import dagger.hilt.android.lifecycle.HiltViewModel
-import com.streamvault.app.R
+import com.streamvault.feature.live.R
import java.util.concurrent.CancellationException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
diff --git a/feature/live/src/main/res/values/strings.xml b/feature/live/src/main/res/values/strings.xml
new file mode 100644
index 00000000..82c645f9
--- /dev/null
+++ b/feature/live/src/main/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="home_error_load_failed">Failed to load channels. Please check your connection and try again.</string>
+ <string name="settings_live_tv_quick_filter_blank">Enter a filter before saving it.</string>
+ <string name="settings_live_tv_quick_filter_duplicate">%1$s is already saved.</string>
+ <string name="settings_live_tv_quick_filter_added">Saved %1$s to Live TV quick filters.</string>
+ <string name="live_preview_failed">Preview unavailable</string>
+ <string name="home_added_to_favorites">Added %1$s to Favorites</string>
+ <string name="home_removed_from_favorites">Removed %1$s from Favorites</string>
+ <string name="home_group_name_invalid">Enter a group name</string>
+ <string name="home_group_name_reserved">Cannot create group named \'Favorites\'</string>
+ <string name="home_group_name_duplicate">Group \'%1$s\' already exists</string>
+ <string name="home_group_requires_provider_scope">Select a single provider source to create groups</string>
+ <string name="home_group_created">Group \'%1$s\' created</string>
+ <string name="home_group_renamed">Renamed group to %1$s</string>
+ <string name="home_group_deleted">Group \'%1$s\' deleted</string>
+ <string name="category_pinned">Pinned %1$s.</string>
+ <string name="category_unpinned">Unpinned %1$s.</string>
+</resources>
diff --git a/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt
index c22273b8..dea2bad2 100644
--- a/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt
+++ b/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt
@@ -1,4 +1,4 @@
-package com.streamvault.app.ui.screens.home
+package com.streamvault.feature.live.home
import android.app.Application
import androidx.lifecycle.ViewModel
diff --git a/validation/phase5_live/task0-inventory.md b/validation/phase5_live/task0-inventory.md
index 54b16166..813c472f 100644
--- a/validation/phase5_live/task0-inventory.md
+++ b/validation/phase5_live/task0-inventory.md
@@ -22,7 +22,7 @@ app/src/main/java/com/streamvault/app/ui/screens/home/HomePreviewUiState.kt
app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
app/src/main/java/com/streamvault/app/ui/screens/home/HomeSidebarComponents.kt
-app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt
+feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt
app/src/main/java/com/streamvault/app/ui/screens/epg/EpgControlComponents.kt
app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt
app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt