Skip to content

[BUG] Movies/Series grid loses its place after opening a title below the first page #20

Closed

Description

@lorenzooah

Bug Description

On the Movies and Series browse grids, opening a title that sits below the first page of results and pressing BACK does not return to that title. The grid jumps back up to the end of the first page (rows 3–4) and no card is highlighted. Titles in the first three rows are restored correctly.

Steps to Reproduce

  1. Starting screen: Main screen, then open Movies (or Series) from the top bar.
  2. Navigate to: press DOWN until at least row 5 of the grid (six cards per row, 20 results per page), e.g. DOWN ×10.
  3. Action taken: press ENTER on a card to open its details, then press BACK.
  4. Expected result: the grid is where it was left, with the same card selected.
  5. Actual result: the grid shows rows 3–4 and nothing looks selected; the selection has been reset to the first card, which is off screen.

Expected Behavior

Grid position and selection are kept when returning from media details, as they are for a card in the first page.

Actual Behavior

The position is lost whenever the saved position is past the first page. Opened "Scene" in row 11 of Movies; after BACK the visible rows were "Ramayana… / La Bola Negra / Drive" and "Fall 2 … The Fix", with no focused card.

Environment

  • App Version: 0.34.2 (Google Play). The same code is on main at 0.35.1 (c89d976).
  • Android TV Device: TCL Google TV (G08, MediaTek)
  • Android Version: Android TV 14
  • Seerr Server Type / Version / Authentication: not checked — the cause below is client-side list state and does not depend on the server.

Media Server Configuration

  • Media Server Type: Jellyfin

Additional Context

Cause

MediaBrowseScreen has:

LaunchedEffect(searchQuery) {
    if (searchQuery.isEmpty()) {
        ...
        MediaType.MOVIE -> viewModel.browseMovies(filters, sort)

Returning from details recomposes the screen, so this effect runs again with the same empty query and calls browseMovies(filters, sort) with loadMore = false. loadMoviesWithBrowse then does _searchResults.value = newResults, replacing every page loaded so far with page 1. The restore effect finds currentSavedPosition.first >= searchResults.size and takes the "saved index is out of bounds due to paged data" branch, which resets the selection to (0, 0). The grid state was created with the saved index, so the lazy grid clamps it to the end of the 20 items.

Suggested fix

Skip that reload when the screen is being restored and the ViewModel still holds this screen's browse list. Two files, +23 lines. Not built or tested on a device — it is offered as a starting point.

diff --git a/tv/src/main/java/ca/devmesh/seerrtv/ui/MediaBrowseScreen.kt b/tv/src/main/java/ca/devmesh/seerrtv/ui/MediaBrowseScreen.kt
index 8d964de..8f57ef7 100644
--- a/tv/src/main/java/ca/devmesh/seerrtv/ui/MediaBrowseScreen.kt
+++ b/tv/src/main/java/ca/devmesh/seerrtv/ui/MediaBrowseScreen.kt
@@ -295,6 +295,16 @@ fun MediaBrowseScreen(
     // for them raced that search and could overwrite its results with unfiltered discover data.
     LaunchedEffect(searchQuery) {
         if (searchQuery.isEmpty()) {
+            // Coming back from media details recomposes this screen, so this effect runs again
+            // with the same empty query. Browsing here would replace every page loaded so far
+            // with page 1: a position saved further down than that first page is then out of
+            // range, the restore above gives up, and the grid lands at the end of page 1 with the
+            // selection reset to the first card. The list is still in the ViewModel, so keep it.
+            // `shouldRestorePosition` rather than the manager's flag, which the restore effect
+            // may already have cleared by the time this one runs.
+            if (shouldRestorePosition && viewModel.isShowingBrowse(mediaType)) {
+                return@LaunchedEffect
+            }
             // Trigger browse with current filters and sort. Read the ViewModel directly: this runs
             // in the same frame as the initializer above, before the collected `currentFilters`
             // catches up, so after visiting the other browse screen it still held that screen's
diff --git a/tv/src/main/java/ca/devmesh/seerrtv/viewmodel/MediaDiscoveryViewModel.kt b/tv/src/main/java/ca/devmesh/seerrtv/viewmodel/MediaDiscoveryViewModel.kt
index f8bbdd2..5f0761e 100644
--- a/tv/src/main/java/ca/devmesh/seerrtv/viewmodel/MediaDiscoveryViewModel.kt
+++ b/tv/src/main/java/ca/devmesh/seerrtv/viewmodel/MediaDiscoveryViewModel.kt
@@ -765,6 +765,19 @@ class MediaDiscoveryViewModel @Inject constructor(
 
     // Browse methods for Movies/Series screens
 
+    /**
+     * True while the results held here are the browse list for [mediaType], with whatever pages
+     * have been appended to it. The browse screens use this on the way back from media details to
+     * tell "my list is still here" apart from "another target has reused this ViewModel".
+     */
+    fun isShowingBrowse(mediaType: MediaType): Boolean {
+        val mode = when (mediaType) {
+            MediaType.MOVIE -> DiscoveryMode.MOVIE_BROWSE
+            MediaType.TV -> DiscoveryMode.TV_BROWSE
+        }
+        return currentDiscoveryMode == mode && _searchResults.value.isNotEmpty()
+    }
+
     /**
      * Browse movies with filters and sorting
      */

Not covered by this change: if another discovery target (keyword, genre, studio) reused the shared ViewModel in between, the list really is gone and is reloaded from page 1 as before.

Checklist

  • You've searched existing issues to see if this bug has already been reported
  • You've provided all relevant environment information above
  • You've described the D-pad navigation path to reproduce the issue
  • For UI issues, you've included screenshots if possible

Activity

  1. added
    bug
    on Nov 13, 2026
  2. devmesh-git commented on Nov 18, 2026

    @devmesh-git
    Owner

    Thanks @lorenzooah, this was a great report. The root cause was spot on, and your suggested fix went in as written.

    It's fixed in v0.35.3. On the way back from details, the Movies and Series grids now keep the pages they've already loaded, so the card you opened is selected again in the same place.

    Tested on a Google TV emulator:

    • Movies row 13 and Series row 12: open a title, Back, and the same card is selected.
    • Scrolling on from there still loads the next pages.
    • A card on the first page is still restored.
    • Opening Movies or Series fresh from the top bar still starts at the top.

    The update is rolling out on Google Play now (it may take a little while to clear review), and the APKs are on the release page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions