Repository navigation
Load Home Recently Added lists in bounded pages - #567
Conversation
GLinnik21
left a comment
There was a problem hiding this comment.
Thank you! This is a really important improvement.
Read the diff, didn't build or run it. A few questions inline.
| s.retry_n = 0; | ||
| s.retry_s = 0.0; | ||
| } else { | ||
| landed_ok(s, b); |
There was a problem hiding this comment.
A normal refetch (e.g. after playback) puts the row back to the first 12, so you lose your place. What do we do here?
There was a problem hiding this comment.
Yep, the normal refresh was replacing the loaded window with the first 12 cards. Have changed it to reload the current window and keep the selected card if it still exists. Tested scrolling further down, starting playback and returning in the simulator.
| if let Some(dt) = dt { | ||
| for s in srcs.iter_mut() { | ||
| if s.state != HubState::Ready && !s.fetching && retry_due(s, dt) { | ||
| if (s.state != HubState::Ready || s.page.is_some()) && !s.fetching && retry_due(s, dt) { |
There was a problem hiding this comment.
A failed page retries forever, even after you leave the row, and blocks every other row's paging on that server. Should it just give up?
There was a problem hiding this comment.
Have limited page retries to three attempts. Leaving the row now releases its pending request so another row can load, and any late result from the old request gets ignored. Tested a failing movie row followed by a working TV row in the simulator.
|
|
||
| fn fetch_page(client: &plx_plex::plex::Client, sid: ServerId, page: &PageQuery) -> Option<SourceBuild> { | ||
| let mc = client.hub_items_paged(&page.key, page.start as i64, MAX_SHELF_ITEMS as i64)?; | ||
| if mc.offset != page.start as i64 { return None; } |
There was a problem hiding this comment.
Does a real PMS echo offset on /hubs/home/recentlyAdded? It's not in the spec, and if it doesn't every page fails.
There was a problem hiding this comment.
Checked this against my server through Plex Web. The first response had offset=0, size=36, totalSize=50, and the next had offset=36, size=14, totalSize=50. Have added a test for that response shape.
| if !recent_listing(id, key) || (before && shelf.offset == 0) || (!before && !shelf.more) { return None; } | ||
| let step = HUB_FETCH_COUNT as usize; | ||
| // Half a window overlaps the prior page so focus and scroll can follow the same item. | ||
| let start = if before { shelf.offset.saturating_sub(step) } |
There was a problem hiding this comment.
This steps by server offsets but the row is filtered by library pins after. With an unpinned library, can the focused card fall out of the next window?
There was a problem hiding this comment.
Yep, the overlap used server positions, which could include mostly hidden cards and drop the selected visible card. Have separated server positions from visible cards so each page retains the visible overlap. Tested sparse pages with a hidden library in the simulator, in both directions.
| // settled once focus left it. | ||
| shelf.on(&ScreenEvent::Tick(t), cx, &src, fx); | ||
| let want = shelf.on(&ScreenEvent::Tick(t), cx, &src, fx); | ||
| let before = focused.is_some_and(|(r, col)| r == row && col < 6) |
There was a problem hiding this comment.
This pushes a Page command every frame while focus sits in the first six cards. Once is enough, no?
There was a problem hiding this comment.
Have changed the shelf to send the request once when focus reaches the edge. It can request again when new data arrives or the user moves away and returns. Added a test that holds focus there for 90 frames and checks that it sends one command.
| start: usize, | ||
| } | ||
|
|
||
| fn recent_listing(id: &str, key: &str) -> bool { |
There was a problem hiding this comment.
Only Recently Added pages. What about the other Home rows, collections and the rest, do they stay at 12?
There was a problem hiding this comment.
This PR covers the Recently Added rows. Collections and the other Home rows still use their existing 12-card previews. Have made that scope clear in the docs.
| pid = int(segs[2]) if segs[2].isdigit() else -1 | ||
| return j(self.container(Metadata=lib.person_media(pid))) | ||
| if catalog and segs[:2] == ["hubs", "demo"] and len(segs) == 3: | ||
| hub = next((hub for hub in lib.data["hubs"] if hub.get("hubIdentifier") == segs[2] and "recent" in hub), None) |
There was a problem hiding this comment.
lib.data doesn't exist on either library class, so this route throws. How did the sim scrolling run?
There was a problem hiding this comment.
Oops, that route was reading lib.data, but the catalog lives in lib.catalog. The earlier simulator checks did not cover this catalog route. Have corrected it, added a regression test and tested paging through the catalog route in the simulator.
| @@ -0,0 +1,144 @@ | |||
| use super::*; | |||
There was a problem hiding this comment.
Tests only cover clean 24-item windows. Can we get one for a refetch while paged, one with pinned-out items, and one where a page never succeeds?
There was a problem hiding this comment.
Yep, the original tests missed these interactions. Have added coverage for refresh after paging, hidden libraries, repeated failures, leaving a row with a request pending, and repeated commands at the page edge. Also tested the affected flows in the simulator.
A backward page requested 24 rows, prepended them to the 12 retained rows and dropped the front back down to 24, then published the request start as the window offset. The dropped 12 rows were never shown and the next backward page started before them, so every page skipped 12 cards. Ask only for the room left beside the retained overlap so every fetched row is kept and offset stays the first server position of the window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The row's once-per-(len,end) request latch is cleared only by a Hubs landing or by leaving the row. When a page failed three times the store dropped it without a landing, so the latch stayed set and focus moves or edge presses on that row never requested the page again until the owner left and came back. Clear the row's latches on an in-row focus move and on an at-edge Left/Right press; the store still admits one page per source, so a press sends at most one request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
HubRequest::fetch returned None for the whole source when reloading one paged row's window failed, although /hubs had already succeeded. Skip the reload for that row so it keeps the shelf as /hubs returned it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
home-recent-paging presses Down once to reach the Recently Added Movies row, then Right 96 times (about eight server pages of 12), rests, and Left 96 times back, against the synthetic mock with 300 movies. It is a row variant of the existing key walk: the same pacing, window cut and heartbeat grading, with the key plan (down/right/left only) and the rest point derived from walk.row_down and walk.cards. The result prints the window's fps median/min, frame_gt33, worst frame, p99 and the page landings (hubs: landed lines) seen; frame_gt33 is not graded yet. The scene fails with "paging did not happen" when the forward half saw fewer than six landings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- pms.rs: restore the module header, HOME_CARDS_MAX and MAX_SHELF_ITEMS rationale and the retry_now_with doc, rewording only what paging made false. - pms.rs: Shelf::is and find_shelf replace the open-coded (hub_id, key) lookups; run_page_cmd is the one body of Page/CancelPage for both command runners. - stores/hubs.rs: HubsCmd::is_paging replaces the repeated matches!. - plex: is_pageable_hub_key is shared by hub_items_paged and recent_listing. - bootstrap.rs: hubs_descriptor builds the Hubs admission descriptor once. - home/mod.rs: PAGE_EDGE_CARDS and hub_page_cmd replace the literal 6 and the duplicated identity unpacking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stable focus (#605) #567 made Home's Recently Added rows page. This applies the same rule to every list the app shows, and adds a gate so a new cap cannot arrive unnoticed. Three requirements hold for every list: nothing is unreachable (a list pages to its real end), memory and per-frame work stay bounded however long the list is, and focus never moves under the user when a page lands, a window slides, or a page is re-read. - Home rows, Library hub rows, Search rows, Detail's Related row and collection-backed rows keep a sliding 24-card window (sliding by 12) and page in both directions to the listing's real end. - The Library grid and Collection pages page through the whole listing; a slot whose page has not landed asks again while it is in view. - Long seasons page through a directory of 60-episode pages and keep at most 8 loaded. - Search reads past the hub preview, falling back to growing the hub limit on servers that answer nothing for typed search. - Back from an opened card, and a same-item re-read of Detail, return to the card the user left even when it is past the first window. - A failed or withdrawn page read is retried on a ladder (0.25 s up to 30 s, then every 30 s) for as long as the user is at that edge. - Embedded ASS subtitles and attached fonts are bounded by a byte budget instead of fixed counts. One paging vocabulary in the Plex layer (plex/paging.rs) and one page store in the data layer (stores/paging.rs, stores/page_cache.rs) serve Home, Library, Search, Detail and Collection; the shared card widgets (Shelf, Grid) own the window, the edge asks and the retry. ci/list-caps.ini and ci/check-list-caps.py (in make check) class every take/truncate/MAX_* site in the list paths; `reach` must be zero (239 sites, reach(open) 0). ci/check-plex-requests.py does the same for paged PMS requests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Home's Recently Added lists stop at the initial preview. This change loads more cards as the user scrolls and loads earlier cards when the user scrolls back.
Each list keeps at most 24 cards, with a 12-item overlap between pages. It uses the existing shelf widget to draw only visible cards and the existing worker to fetch pages. Page changes keep focus on the same card. Failed requests keep the current cards and retry after the existing delay. Loading a page keeps the banner items and other Home rows.
Most of the diff is recorded test data. The new paging fields change the recorded Home state, so the three replay fixtures were recorded again against the synthetic server.
Checks on
48f57f55:make checkpassed.--no-default-features.Screen test output:
TV frame rate still needs a device check. This machine has no TV connection configured.