Repository navigation
home: a failed hub fetch says so, and retries, instead of blanking the screen - #11
Merged
Merged
Conversation
…e screen `pms_fetch_hubs` built the catalog, the shelves and the hero pool and committed all three unconditionally, so a failed GET /hubs committed an EMPTY catalog — the doc line said so outright: "A failed fetch commits empty, blanking the home consistently." One bare dark screen then stood in for three entirely different situations (still fetching / server unreachable / library genuinely empty), and nothing ever tried again: the only ways out were an app restart or a playback session happening to end. The fetch now has a state machine — Loading / Ready / Failed — modelled on browse.rs's page store, which had already learned both lessons this needed. A failure keeps the catalog it already had rather than overwriting it (one wifi hiccup must not blank a populated Home), and a fast-failing network is held off by a countdown instead of re-spawning a worker every frame. Only an identity change still wipes the catalog: pms::reset, called from install_pms beside the browse::reset that was already there — without it a profile switch whose fetch failed would leave the previous user's shelves on screen. Home draws that state through the shared StatusOverlay, and only when there are no shelves at all. A background refresh that fails behind a populated Home stays silent and heals underneath, rather than throwing an error over content the user can still use. StatusKind gains Empty — neutral, no spinner — because a library with nothing in it is an answer, not a fault, and must not wear the danger tint. Retry is both automatic and manual, because on a television neither alone is enough. The ladder (2 -> 4 -> 8 -> 16 -> 30s) runs unattended, so Home is populated when someone walks back into the room without anyone having pressed anything — a failed boot fetch is precisely the case where nobody is at the remote yet. The control kicks a fetch now, from the bottom of the ladder, because the likeliest cause is a server that was asleep and is now awake: the user knows it is back before we do. The retry runs off-thread, unlike the blocking boot fetch, which is what makes a live loading state possible at all — a blocking fetch on the SDL loop draws no frames while it runs, so its spinner would never reach the panel. Two invariants the change had to earn rather than assume. A landing carries the generation it was spawned in, so a retry still in flight across a profile switch is dropped whole instead of committing the old account's hubs over the new one's. And "no shelves means no grid" is now one pure rule applied in two places: DOWN cannot dive into an empty grid, and a catalog that empties UNDER a committed snap is pinned back — left at 1.0, app.rs's pointer gate sends clicks to the empty grid's hit-test instead of the hero rects, which would leave the Retry control, the one way back, silently unclickable. Rebasing onto the parity staging branch collided with a second width formula: unit 8 had added a free `widgets::pill_w(label, sz)` that assumes the pill carries an icon, and told icon-less callers to measure themselves from `text::text_width` — a second sizing path, which is the drift ui/CLAUDE.md exists to prevent, and Home's new Retry pill is exactly such a caller. The two collapse into one `Button::pill_w(label, sz, icon)` reading the same named metrics `Button::draw` lays out with, so the measurer and the renderer cannot disagree. Both hero pills pass icon: true and are byte-identical to before; detail's pill moves to it, and the free function is gone. The stale TabPill comment pointing at `pill_w` now names `TabPill::width`, which is what a tab actually uses. Device verification is deferred to the coordinator (netcond recipe in the PR). Tests: +10 host (132) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc
GLinnik21
force-pushed
the
unit11-home-loading-error-retry
branch
from
July 29, 2026 18:28
6b39550 to
ef3ccb0
Compare
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
The catalog fetch was movies-only (section 1, hardcoded). Make it discover the section keys from /library/sections and fetch every movie AND show library — movies first (the hero stays a movie), shows appended into the later grid rows. - New PmsMovie.kind field (0=movie, 1=show). - fetch_section() appends a section's items at an offset (extracted from the old single-shot loop); shows carry no Media/Part (you play episodes, not the show), so the keep-condition is title && (part || is_show) instead of title && part. - pms_fetch_movies() drops the `sec` arg; iterates movie sections then show sections. Verified on-device: nmovies 23 -> 35 (23 movies + 12 shows), grid renders show posters in the lower rows, 59fps. First step toward the detail page (#11): a show card will open the show detail (seasons/episodes); a movie card opens movie detail. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018QbpQTKYjwp6fDNLdXzGzr
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
…ility) The final detail-page section — the About footer at the bottom of the scroll. - metadata.rs: extracted parse_streams(item, &mut Detail); load_detail now backfills a SHOW's audio/subs from its first episode's full metadata (shows carry no streams at the show level), so the Languages/Accessibility columns populate for shows and movies alike. - ui/detail.rs: section 5 = About (always present). draw_about: an "About" heading + a rounded card (title, comma-joined genres, wrapped summary + MORE), then three columns — Information (Released / Run Time / Rated / Regions of Origin), Languages (Original Audio + the audio-track list "Lang (CODEC)"), Accessibility (CC/SDH/AD badges + standard descriptions, shown only when present). ABOUT_Y spaced so the footer clears the cast row when focused. Verified on the TV (Severance): footer matches the Apple-TV reference — card, and all three columns populated (18 Feb 2022 / 0 hr 50 min / TV-MA / United States; Русский + full audio list from episode 1; CC with its description). Completes the detail page (#11): hero -> season tabs + episodes -> related -> cast -> about, all scrolling as one page, with movie + show playback wired. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018QbpQTKYjwp6fDNLdXzGzr
GLinnik21
added a commit
that referenced
this pull request
Aug 26, 2026
The catalog fetch was movies-only (section 1, hardcoded). Make it discover the section keys from /library/sections and fetch every movie AND show library — movies first (the hero stays a movie), shows appended into the later grid rows. - New PmsMovie.kind field (0=movie, 1=show). - fetch_section() appends a section's items at an offset (extracted from the old single-shot loop); shows carry no Media/Part (you play episodes, not the show), so the keep-condition is title && (part || is_show) instead of title && part. - pms_fetch_movies() drops the `sec` arg; iterates movie sections then show sections. Verified on-device: nmovies 23 -> 35 (23 movies + 12 shows), grid renders show posters in the lower rows, 59fps. First step toward the detail page (#11): a show card will open the show detail (seasons/episodes); a movie card opens movie detail. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018QbpQTKYjwp6fDNLdXzGzr
GLinnik21
added a commit
that referenced
this pull request
Aug 26, 2026
…ility) The final detail-page section — the About footer at the bottom of the scroll. - metadata.rs: extracted parse_streams(item, &mut Detail); load_detail now backfills a SHOW's audio/subs from its first episode's full metadata (shows carry no streams at the show level), so the Languages/Accessibility columns populate for shows and movies alike. - ui/detail.rs: section 5 = About (always present). draw_about: an "About" heading + a rounded card (title, comma-joined genres, wrapped summary + MORE), then three columns — Information (Released / Run Time / Rated / Regions of Origin), Languages (Original Audio + the audio-track list "Lang (CODEC)"), Accessibility (CC/SDH/AD badges + standard descriptions, shown only when present). ABOUT_Y spaced so the footer clears the cast row when focused. Verified on the TV (Severance): footer matches the Apple-TV reference — card, and all three columns populated (18 Feb 2022 / 0 hr 50 min / TV-MA / United States; Русский + full audio list from episode 1; CC with its description). Completes the detail page (#11): hero -> season tabs + episodes -> related -> cast -> about, all scrolling as one page, with movie + show playback wired. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018QbpQTKYjwp6fDNLdXzGzr
GLinnik21
added a commit
that referenced
this pull request
Oct 8, 2026
…loor, no secret echo) (#557) CodeQL py/* alerts #4-8, #10, #11, #16-20. serve_fixtures resolves and checks containment before isfile; every dev SSLContext sets minimum_version TLS 1.2; gen-release-audit parses the DSN host instead of a substring test; the census arm regex no longer backtracks; plxnative-lab start stops echoing the session secret (pkg/lab.json, 0600, carries it); remote-dpad echoes only a password it generated. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the parity-gap appendix entry "Home has no loading, empty or error state, and never retries a failed hub fetch" (
docs/parity-gaps.md:397).What was wrong
pms_fetch_hubsbuiltnew_cat/new_hubs/new_pooland committed all three unconditionally, so a failedGET /hubscommitted an empty catalog — the old doc line said so outright: "A failed fetch commits empty, blanking the home consistently." One bare dark screen then stood in for three entirely different situations (still fetching / server unreachable / library genuinely empty), with no spinner, no message, no affordance, and nothing that would ever try again: the only ways out were an app restart or a playback session happening to end.What this does
pms.rsgained a fetch state machine —HubState::{Loading, Ready, Failed}— modelled onbrowse.rs's page store, which had already learned both lessons this needed: a failed fetch must never overwrite a populated store (a wifi hiccup once blanked a whole grid permanently), and a fast-failing network must be held off by a countdown instead of re-spawning a worker every frame. A failure now keeps the catalog it already had; only an identity change (pms::reset, called frominstall_pmsbeside the existingbrowse::reset) wipes it.ui/home.rsdraws the read-out from that state through the sharedwidgets::StatusOverlay— spinner + "Loading your library…", danger-tinted "Can't reach your Plex server", or a neutral "Nothing on this server yet" — with one pill under it. It appears only when there are no shelves at all: a background refresh that fails behind a populated Home stays silent and heals underneath rather than throwing an error over content the user can still use.widgets.rsgainedStatusKind::Empty(neutral tint, no spinner) rather than a fourth hand-rolled empty-state Label, plusButton::pill_wso the+68pill-padding rule lives on the button instead of being re-derived at each call site.app.rsis two one-line hooks:pms::reset()ininstall_pms, andhome::status_activate(hf)at the top of the one home activation.Retry: both, and why
Automatic on an exponential backoff (2 → 4 → 8 → 16 → 30s, then 30s) and a focusable control. Neither alone is enough on this product:
So the ladder runs unattended, and
Try Again/Refreshkicks a fetch now, from the bottom of the ladder. The 30s cap means a server coming back is picked up within half a minute; the 2s floor means a transient blip costs nothing.The retry is off-thread (
task::spawn_small→ mailbox →pumpon the main thread), unlike the blocking boot fetch. That is what makes a live loading state possible at all: a blocking fetch on the SDL loop draws no frames while it runs, so the spinner it is meant to be spinning would never reach the panel.pump(dt)is driven fromhome_update, so the machine ticks exactly while Home is the screen that cares, and nothing spawns a background fetch behind the player.Invariants preserved
home.rs:65-75,:740-749) — untouched. A retry that repopulates the shelves lands throughcommit, and every focus read re-clamps against the new bounds, so focus is valid by construction.pump's commit also runsdetail::reselect(), the same post-mutation ritualrefetch_hubs_reconcileperforms.HUB_GEN, bumped byresetand by the blocking fetch): a retry still in flight across a profile switch is dropped whole — neither committed nor blamed — instead of putting the old account's hubs over the new one's.pinned_snap) applied in two places.set_snap_targetrefuses a new dive, andhome_updatere-applies it every frame because a catalog can empty under a snap already committed. That second half is load-bearing: left at 1.0,app.rs's pointer gate (snap_pos() < 0.5) routes clicks to the empty grid's hit-test instead of the hero rects, which would leave the Retry control — the one way back — silently unclickable. Found by review, not by luck.hero_item()isNoneandHero::drawreturns before recording anything).Rebase: two
pill_ws became oneThe only conflict worth a paragraph. Unit 8 added a free
widgets::pill_w(label, sz)— "the ONE hero-pill width formula" — and I had independently addedButton::pill_w(label, sz, icon). Two width formulas for one control is precisely the driftui/CLAUDE.mdexists to prevent.Kept mine, on
Button, reading unit 8's named metrics. The deciding factor is not authorship but that unit 8's own doc names its gap: "Assumes the pill CARRIES an icon … an icon-less button measured through this gets an icon box of air it will not fill. Size that one fromtext::text_widthdirectly." That sentence is a second sizing path, and this unit's Retry pill is exactly the caller it sends down it. Theiconflag closes it, so there is one formula for every pill in the product.It lives on
Buttonbecause the icon box and gap areButton's private layout, and it now readsBTN_ICON_RATIO/BTN_ICON_GAP/BTN_PILL_AIR— the same constantsButton::drawlays out with, so measurer and renderer cannot disagree rather than being asked to stay in step.icon: true, Home's Retry passesfalse. The free function is gone; nowidgets::pill_wcall site remains.icon: truethe expression is byte-identical to unit 8's, which matters because staging notes detail's pill is deliberately pixel-identical to home's.TabPillbanner comment claimedpill_w(label, sz)sizes a tab (it doesn't —TabPill::widthdoes, and a tab has no icon box), and staging'sui/CLAUDE.mdhad picked up twowidgets.rstable rows from parallel merges. Folded into one row carrying every unit's clauses.The other three conflicts were mechanical:
Button's icon metrics (took staging's named constants),home_draw's call order (staging deliberately moveddraw_chipon top of the tab track — the status read-out slots into the content layer above both), and one test that looped over the now-deletedwidgets::MAX_TABS, which unit 10 replaced with an uncapped scrolling strip.Verification
Tests: +10 host — 132/132 on the staging base (122 before this branch).
make check(which now also runsmake lint, the clippy shadowed-branch gate) is green, andmakecross-builds clean with no new warnings.pms.rs(7): the backoff ladder doubles then holds at the ceiling; a failed landing never blanks a populated Home; a successful landing commits and retires the backoff; a server with no hubs lands Ready-and-empty rather than Failed; the countdown fires when the backoff elapses; a landing from before aresetis dropped whole;resetwipes the catalog and re-arms the fetch.ui/home.rs(3): the read-out tells Loading/Empty/Failed apart and content silences it; the status screen takes OK but never the top band; no shelves means no grid snap.vert_cannot_walk_past_the_shelf_array) now also takestestlock::serial()— it readspms's catalog statics, which this change makes other modules' tests write, andcommitfrees the oldHUBSbuffer. That is a use-after-free, not a flaky assertion.A correctness review over the full diff found one real bug (the snap/pointer interaction above), one test-isolation bug (that lock), and six nits; all are fixed in this branch.
Device verification: deferred to coordinator
Not run here — no TV time was taken, and
PMS_PORTinsrc/config.local.hwas never modified. Everything below is exactly what I would have run; please run it and nothing more.Setup (host).
PMS_PORT→32499in the gitignoredsrc/config.local.h. Restore it to32400when done — a stale port there silently breaks every later run. Never commit that file.127.0.0.1:32401itself and the more specific bind wins, so the proxy is silently bypassed and a "failure" test quietly passes against a healthy server. 32499 is free (verified on this host).CLAUDE.mdnow documents as netcond's default, so this matches the tree):python3 tools/netcond.py --listen 32499 --target 127.0.0.1:32400 --mode pass --control /tmp/netcond-unit11.mode(it binds
0.0.0.0, so the TV reaches it atPMS_HOST:32499.)make && make deploy.Boot deterministically.
tests/run.pyis not involved. Write the owner token fromsrc/config.local.hto/tmp/plxnative-tokenon the TV — that installs the client and, being aplxnative-*trigger, suppresses the who's-watching picker, so the boot lands on Home.rmit afterwards.The three states, in one app run (
make run RUN_SECS=170in the background; capture withtools/capture-screen.sh <out>.png DISPLAY):/tmp/plxnative-events.logecho reject > /tmp/netcond-unit11.modebefore launchhubs: fetch FAILED (attempt N) — retrying in Nsrepeating on the 2/4/8/16/30 ladder, interleaved withhubs: retrying (off-thread)echo blackhole > /tmp/netcond-unit11.modehubs: retryinglinehubs: retrying (off-thread)with noFAILEDfor ~15s (the app'sSO_RCVTIMEO)echo pass > /tmp/netcond-unit11.modehubs: retry landed — N items, M shelvesTiming to expect. First retry 2s after the boot failure, then 4/8/16/30, capped. Step 3 must heal with no input — that is the auto-retry half of the feature. Pressing OK on Try Again at any point should fire a fetch immediately (a
hubs: retryingline within a frame), which is the manual half.Worth a glance while you are there: with the error state up, LEFT/RIGHT keeps the single pill lit (never a dead focus slot), UP reaches the profile chip, and the tab pills still enter a library section — those are the escapes from a dead Home.
Then: restore
PMS_PORTto32400,make && make deploy, stop netcond,rm /tmp/plxnative-tokenon the TV.FPS gate.
./tests/run.py --fps(UI tier) on the restored build. This change adds onepms::pumpcall per Home frame (a mailbox take plus a few reads) and one draw call that early-returns whenever there is content, sohome-hero/home-gridshould be unchanged against a real server.🤖 Generated with Claude Code
https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc