Skip to content

player: chapters follow the played leaf, and the rail shows them - #7

Merged
GLinnik21 merged 1 commit into
mainfrom
unit-12-chapters-episode-path-rail-ticks
Jul 30, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
unit-12-chapters-episode-path-rail-ticks

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Unit 12 of the movie/TV parity work (docs/parity-gaps.md, player/stats appendix): "Chapters are
unavailable for any episode started from a show detail page" and "No chapter or intro/credits
markers on the scrubber rail".

1. The Chapters tab on the episode path

ui/chapters_panel.rs read metadata::current() in all four accessors. During a show-page episode
play current() is the SHOW (detail::play_episode_at says so in a comment) and a show container
carries no Chapter[], so has_chapters() was false and the HUD drew only the Info tab. The same
aliasing meant a current() holding a different leaf would seek with that item's offsets.

Chapters now ride metadata::PlayingItem beside markers — the store that exists for exactly this
identity problem — behind one new accessor, metadata::playing_chapters().

No extra PMS request, confirmed rather than assumed. Client::metadata already sends
includeChapters=1 (plex/library.rs), and both store-building paths already have the data:

  • detail-page play → cached_playing clones the loaded Detail's chapters (no GET, as before);
  • show-page / straight-from-Home play → fetch_playing_item was already making that GET for markers
    and streams and discarding the Chapter[] in the same response.

Device proof, playing an episode from the show page: playing item: rk=1886 audio=1 subs=38 markers=2 chapters=39 — one metadata GET, 39 chapters that used to be dropped.

The staleness this exposed

Moving chapters into PLAYING made a latent bug user-reachable, so request_play now retires that
store beside UP_NEXT, for the reason already documented there: it stays the PREVIOUS leaf's for
the whole resolve window (0.5-3 s, longer through a /decision handshake), and the HUD is up for
all of it. Markers were shielded by active_marker's is_playing() gate; a tab has no such gate,
and its OK would have seeked the new episode to another item's offset. The NowPlaying caption
can't move with it — play_episode_at sets it just before requesting the play — so the retirement
is PLAYING-only. chapters_panel::update also re-clamps its selection, since the list it indexes
can now be replaced under an open strip.

2. Chapter + intro/credits marks on the rail

Between the track and the knob:

  • intro/credits bands from metadata::playing_markers() — under the fill, so a watched segment
    reads as watched. A final credits marker's stated end is the container duration (it overshoots
    the decoder's), so the band is clamped to the rail.
  • chapter ticks over both, coloured by which side of the playhead they fall on — one colour
    can't serve both, since white vanishes into the fill and dark vanishes into the track.

Three new theme.rs tokens with doc lines; no inline colours, no text, no new font sizes.

Geometry is pure and host-tested (chapter_tick_xs, marker_band): the 0:00 chapter and anything
within 8px of a cap are dropped (they are the rail's ends, not boundaries on it), and ticks coalesce
on distance — PMS does not sort these sibling arrays by offset (its Marker[] comes back
credits-before-intro), and a signed compare would silently drop everything after the first backward
step.

Verification

Gate Result
make check 60 passed (58 baseline + 2 new geometry tests)
make (ARM cross-build) clean, no new warnings
./tests/run.py --fps-player 7/7 PASS — fps:track-menu (its item draws 33 ticks) 54fps vs floor 45; fps:info-panel 53 vs 45
./tests/run.py --filter morning_show_skip_intro 2/2 PASS (morning_show_skip_intro, ..._press)
Show-page episode boot, final binary 60fps median with 35 ticks + both bands up; min 44 during pre-roll

Ticks land within a pixel of what the pure function predicts (157/198/252/282/317 px), and each
marker band measures ~2.4x the plain track's ink — both measured off the DISPLAY capture rather
than eyeballed, since the rail is semi-transparent over live video.

A correctness review was run over the diff; its one real finding (the stale-store window above) is
fixed here, along with three doc-accuracy notes and the non-monotone coalesce. Its out-of-scope
find, left alone: app.rs:1409-1410 has two identical else if vis && hud_nav.focus == 1 arms, the
first empty, so OK on a focused Subtitles/Audio disc is a no-op by remote — pre-existing, from
c1691d1, and already recorded in docs/parity-gaps.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc

Two gaps that share a cause and a fix.

The Chapters tab never appeared for an episode started from a show detail
page. `chapters_panel` read `metadata::current()`, which on that path is the
SHOW — `play_episode_at` says so in a comment — and a show container carries
no `Chapter[]`, so `has_chapters()` was false. The same aliasing meant a
`current()` holding some other leaf would have seeked with ITS offsets.

Chapters now ride `PlayingItem` beside `markers`, for the identity reason
that store already exists, read through one `metadata::playing_chapters()`.

No new PMS request, and this is the part worth checking rather than
believing: `Client::metadata` already sends `includeChapters=1`, so on the
show-page path `fetch_playing_item` was making that exact GET for markers and
streams and throwing the `Chapter[]` in the same response away. The
detail-page path clones the loaded `Detail`, as before. Verified on device —
`playing item: rk=1886 audio=1 subs=38 markers=2 chapters=39`, one metadata
GET, played from the show page.

Putting chapters in that store made a latent staleness user-reachable, so
`request_play` now retires it beside `UP_NEXT`, for the reason already
written there: until the resolve lands (0.5-3 s, all of it with the HUD up)
the store is the PREVIOUS leaf's. Markers were masked from this by
`active_marker`'s `is_playing` gate; a Chapters tab has no such gate, and its
OK would have seeked the NEW episode to another item's offset. The caption
cannot move with it — `play_episode_at` sets `NowPlaying` just before
requesting the play — hence a `PLAYING`-only retirement.

The rail then draws what it now knows:

  * intro/credits bands from the same markers the Skip control reads, UNDER
    the fill so a segment already watched reads as watched. A `final` credits
    marker's stated end is the container duration, which overshoots the
    decoder's, so the band is clamped to the rail.
  * chapter ticks OVER both, coloured by which side of the playhead they fall
    on. One colour cannot serve both: white vanishes into the fill and dark
    vanishes into the track.

Both are small opaque quads and the tick count is bounded by a minimum gap
rather than by the item's chapter count — that ceiling is a draw-call bound,
not a fill one, and it doubles as the reason a cluster of short chapters
cannot smear into a bar. The 0:00 chapter and anything within 8px of a cap
are dropped; they are the rail's ends, not boundaries on it. The coalesce
compares DISTANCE, because PMS does not sort these sibling arrays by offset
(its `Marker[]` comes back credits-before-intro) and a signed compare would
drop everything after the first backward step.

Device: 7/7 FPS scenes pass, player tier included — track-menu, whose item
draws 33 ticks, holds 54fps against a 45 floor; the show-page episode boot
runs 60fps median with 35 ticks and both bands up. Ticks land within a pixel
of where the pure geometry says (157/198/252/282/317), and each band measures
~2.4x the plain track's ink. Both `morning_show_skip_intro` cases pass.

Tests: +2 host (60)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc
Copilot AI review requested due to automatic review settings July 29, 2026 18:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@GLinnik21
GLinnik21 merged commit 103c4a2 into main Jul 30, 2026
@GLinnik21
GLinnik21 deleted the unit-12-chapters-episode-path-rail-ticks branch August 2, 2026 18:37
GLinnik21 added a commit that referenced this pull request Aug 3, 2026
The demuxer chose the default audio with av_find_best_stream, which picks the
"highest quality" track — on Home Alone (8 audio tracks, no default disposition)
it picked the DTS track (a=#7). But the Load payload carries Media[0].audioCodec
(ac3), so the pipeline was told AC3 while fed DTS: the audio ES never configures
and, with audioSync, the video slaves to the dead audio clock and wedges (~32s of
buffered video, then Feed() BufferFull forever, no window+PLAYING).

Now the default audio feeds the first track whose codec MATCHES the payload
(audio_stream_matching via avcodec_get_name), falling back to av_find_best_stream
only if none matches. Verified on rk 3: feeds a=#1 (ac3), window+PLAYING, timeline
climbs 72→142s. Caught by the new regression harness (home_alone_manyaudio).

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 23, 2026
…it (#61)

The margin token said 90 and `docs/lg-self-checklist.md` marked LG checklist
item #2 a pass on the words "MARGIN_X 90 (4.7%), inside the 5% overscan frame".
That reads as clearance and is the opposite: a smaller margin puts content
NEARER the edge, so every screen in the app sat six pixels inside the exclusion
zone. Nobody had ever measured one.

The vertical half was worse, because it did not exist. There was no MARGIN_Y
anywhere in the tree, so nothing bounded the top or bottom of anything, and
four places were further out than the horizontal margin ever was:

  - the shared top tab bar + profile chip, 18px (the "main page" the item names)
  - the detail page's pinned compact title, 14px — and 32 for a square
    clearLogo, which spills upward as paint rather than as layout
  - the Library's A-Z rail, 32px, the worst in the app
  - the Home / Library / Person scroll reveals, which settled a focused card's
    caption 24 / 16 / 40px off the bottom edge

Both margins are tokens now (96 / 54), and the requirement is a host test
rather than a literal. `no_required_content_enters_the_safe_area_exclusion_zone`
grades the COMPOSED rect of every screen and panel against `consts::SAFE`, so a
later audit can move a token — or give one screen a correction of its own —
without the test being rewritten to permit it. Deliberately no
`assert_eq!(MARGIN_X, 96.0)`: that passes today and forbids the fix.

"Required" is load-bearing. A full-bleed backdrop, a page ground, a scrim, a
focus glow and a shelf peeking off the bottom edge are all supposed to reach
the panel edge. Tiles are entered at REST for the same reason — the 1.09 focus
pop magnifies ink already inside the frame and its caption does not scale —
while the compact logo IS graded at its spill, because there the spill is the
logo.

The A-Z rail could not be fixed by moving the rail: with the grid filling
`SCR_W - 2*MARGIN_X` exactly there was no room inside the frame for a 44px
control to its right, so the grid now reserves the band unconditionally (a
reflow between two sections of one library is worse than a slightly narrower
grid that never moves).

One design cost, because it is a trade rather than a fix: dropping the top bar
18px grows the tab band's blur region by 18 rows of a ~1470px grab, which puts
`GLASS_TRACK_MAX` outside `gfx::GLASS_REGION_BUDGET`. It is the `min` of its
two constraints now instead of the "must not touch" rule alone, so the glass
comes off a strip wider than ~672px rather than ~848. The product's strip is
572, so today's bar is unaffected and one more library still keeps it. If that
is too tight the lever is the measured budget, not the frame.

Checklist item #7 (idle / focused / selected distinguishable) was audited screen
by screen at the same time and needed no change; the doc row says what was
looked at instead of what was believed.

Verified: `make check` 980 green, and the simulator at a real 1920x1080 —
Library's ink went x 77..1877 / y 36..1060 to x 83..1823 / y 54..1078 (the 83
is the focused card's own drop shadow, the 1078 the scrolling shelf's peek).
No television: this lane is host-only.


Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 26, 2026
The demuxer chose the default audio with av_find_best_stream, which picks the
"highest quality" track — on Home Alone (8 audio tracks, no default disposition)
it picked the DTS track (a=#7). But the Load payload carries Media[0].audioCodec
(ac3), so the pipeline was told AC3 while fed DTS: the audio ES never configures
and, with audioSync, the video slaves to the dead audio clock and wedges (~32s of
buffered video, then Feed() BufferFull forever, no window+PLAYING).

Now the default audio feeds the first track whose codec MATCHES the payload
(audio_stream_matching via avcodec_get_name), falling back to av_find_best_stream
only if none matches. Verified on rk 3: feeds a=#1 (ac3), window+PLAYING, timeline
climbs 72→142s. Caught by the new regression harness (home_alone_manyaudio).

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
…it (#61)

The margin token said 90 and `docs/lg-self-checklist.md` marked LG checklist
item #2 a pass on the words "MARGIN_X 90 (4.7%), inside the 5% overscan frame".
That reads as clearance and is the opposite: a smaller margin puts content
NEARER the edge, so every screen in the app sat six pixels inside the exclusion
zone. Nobody had ever measured one.

The vertical half was worse, because it did not exist. There was no MARGIN_Y
anywhere in the tree, so nothing bounded the top or bottom of anything, and
four places were further out than the horizontal margin ever was:

  - the shared top tab bar + profile chip, 18px (the "main page" the item names)
  - the detail page's pinned compact title, 14px — and 32 for a square
    clearLogo, which spills upward as paint rather than as layout
  - the Library's A-Z rail, 32px, the worst in the app
  - the Home / Library / Person scroll reveals, which settled a focused card's
    caption 24 / 16 / 40px off the bottom edge

Both margins are tokens now (96 / 54), and the requirement is a host test
rather than a literal. `no_required_content_enters_the_safe_area_exclusion_zone`
grades the COMPOSED rect of every screen and panel against `consts::SAFE`, so a
later audit can move a token — or give one screen a correction of its own —
without the test being rewritten to permit it. Deliberately no
`assert_eq!(MARGIN_X, 96.0)`: that passes today and forbids the fix.

"Required" is load-bearing. A full-bleed backdrop, a page ground, a scrim, a
focus glow and a shelf peeking off the bottom edge are all supposed to reach
the panel edge. Tiles are entered at REST for the same reason — the 1.09 focus
pop magnifies ink already inside the frame and its caption does not scale —
while the compact logo IS graded at its spill, because there the spill is the
logo.

The A-Z rail could not be fixed by moving the rail: with the grid filling
`SCR_W - 2*MARGIN_X` exactly there was no room inside the frame for a 44px
control to its right, so the grid now reserves the band unconditionally (a
reflow between two sections of one library is worse than a slightly narrower
grid that never moves).

One design cost, because it is a trade rather than a fix: dropping the top bar
18px grows the tab band's blur region by 18 rows of a ~1470px grab, which puts
`GLASS_TRACK_MAX` outside `gfx::GLASS_REGION_BUDGET`. It is the `min` of its
two constraints now instead of the "must not touch" rule alone, so the glass
comes off a strip wider than ~672px rather than ~848. The product's strip is
572, so today's bar is unaffected and one more library still keeps it. If that
is too tight the lever is the measured budget, not the frame.

Checklist item #7 (idle / focused / selected distinguishable) was audited screen
by screen at the same time and needed no change; the doc row says what was
looked at instead of what was believed.

Verified: `make check` 980 green, and the simulator at a real 1920x1080 —
Library's ink went x 77..1877 / y 36..1060 to x 83..1823 / y 54..1078 (the 83
is the focused card's own drop shadow, the 1078 the scrolling shelf's peek).
No television: this lane is host-only.


Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 27, 2026
…it (#61)

The margin token said 90 and `docs/lg-self-checklist.md` marked LG checklist
item #2 a pass on the words "MARGIN_X 90 (4.7%), inside the 5% overscan frame".
That reads as clearance and is the opposite: a smaller margin puts content
NEARER the edge, so every screen in the app sat six pixels inside the exclusion
zone. Nobody had ever measured one.

The vertical half was worse, because it did not exist. There was no MARGIN_Y
anywhere in the tree, so nothing bounded the top or bottom of anything, and
four places were further out than the horizontal margin ever was:

  - the shared top tab bar + profile chip, 18px (the "main page" the item names)
  - the detail page's pinned compact title, 14px — and 32 for a square
    clearLogo, which spills upward as paint rather than as layout
  - the Library's A-Z rail, 32px, the worst in the app
  - the Home / Library / Person scroll reveals, which settled a focused card's
    caption 24 / 16 / 40px off the bottom edge

Both margins are tokens now (96 / 54), and the requirement is a host test
rather than a literal. `no_required_content_enters_the_safe_area_exclusion_zone`
grades the COMPOSED rect of every screen and panel against `consts::SAFE`, so a
later audit can move a token — or give one screen a correction of its own —
without the test being rewritten to permit it. Deliberately no
`assert_eq!(MARGIN_X, 96.0)`: that passes today and forbids the fix.

"Required" is load-bearing. A full-bleed backdrop, a page ground, a scrim, a
focus glow and a shelf peeking off the bottom edge are all supposed to reach
the panel edge. Tiles are entered at REST for the same reason — the 1.09 focus
pop magnifies ink already inside the frame and its caption does not scale —
while the compact logo IS graded at its spill, because there the spill is the
logo.

The A-Z rail could not be fixed by moving the rail: with the grid filling
`SCR_W - 2*MARGIN_X` exactly there was no room inside the frame for a 44px
control to its right, so the grid now reserves the band unconditionally (a
reflow between two sections of one library is worse than a slightly narrower
grid that never moves).

One design cost, because it is a trade rather than a fix: dropping the top bar
18px grows the tab band's blur region by 18 rows of a ~1470px grab, which puts
`GLASS_TRACK_MAX` outside `gfx::GLASS_REGION_BUDGET`. It is the `min` of its
two constraints now instead of the "must not touch" rule alone, so the glass
comes off a strip wider than ~672px rather than ~848. The product's strip is
572, so today's bar is unaffected and one more library still keeps it. If that
is too tight the lever is the measured budget, not the frame.

Checklist item #7 (idle / focused / selected distinguishable) was audited screen
by screen at the same time and needed no change; the doc row says what was
looked at instead of what was believed.

Verified: `make check` 980 green, and the simulator at a real 1920x1080 —
Library's ink went x 77..1877 / y 36..1060 to x 83..1823 / y 54..1078 (the 83
is the focused card's own drop shadow, the 1078 the scrolling shelf's peek).
No television: this lane is host-only.


Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 28, 2026
…it (#61)

The margin token said 90 and `docs/lg-self-checklist.md` marked LG checklist
item #2 a pass on the words "MARGIN_X 90 (4.7%), inside the 5% overscan frame".
That reads as clearance and is the opposite: a smaller margin puts content
NEARER the edge, so every screen in the app sat six pixels inside the exclusion
zone. Nobody had ever measured one.

The vertical half was worse, because it did not exist. There was no MARGIN_Y
anywhere in the tree, so nothing bounded the top or bottom of anything, and
four places were further out than the horizontal margin ever was:

  - the shared top tab bar + profile chip, 18px (the "main page" the item names)
  - the detail page's pinned compact title, 14px — and 32 for a square
    clearLogo, which spills upward as paint rather than as layout
  - the Library's A-Z rail, 32px, the worst in the app
  - the Home / Library / Person scroll reveals, which settled a focused card's
    caption 24 / 16 / 40px off the bottom edge

Both margins are tokens now (96 / 54), and the requirement is a host test
rather than a literal. `no_required_content_enters_the_safe_area_exclusion_zone`
grades the COMPOSED rect of every screen and panel against `consts::SAFE`, so a
later audit can move a token — or give one screen a correction of its own —
without the test being rewritten to permit it. Deliberately no
`assert_eq!(MARGIN_X, 96.0)`: that passes today and forbids the fix.

"Required" is load-bearing. A full-bleed backdrop, a page ground, a scrim, a
focus glow and a shelf peeking off the bottom edge are all supposed to reach
the panel edge. Tiles are entered at REST for the same reason — the 1.09 focus
pop magnifies ink already inside the frame and its caption does not scale —
while the compact logo IS graded at its spill, because there the spill is the
logo.

The A-Z rail could not be fixed by moving the rail: with the grid filling
`SCR_W - 2*MARGIN_X` exactly there was no room inside the frame for a 44px
control to its right, so the grid now reserves the band unconditionally (a
reflow between two sections of one library is worse than a slightly narrower
grid that never moves).

One design cost, because it is a trade rather than a fix: dropping the top bar
18px grows the tab band's blur region by 18 rows of a ~1470px grab, which puts
`GLASS_TRACK_MAX` outside `gfx::GLASS_REGION_BUDGET`. It is the `min` of its
two constraints now instead of the "must not touch" rule alone, so the glass
comes off a strip wider than ~672px rather than ~848. The product's strip is
572, so today's bar is unaffected and one more library still keeps it. If that
is too tight the lever is the measured budget, not the frame.

Checklist item #7 (idle / focused / selected distinguishable) was audited screen
by screen at the same time and needed no change; the doc row says what was
looked at instead of what was believed.

Verified: `make check` 980 green, and the simulator at a real 1920x1080 —
Library's ink went x 77..1877 / y 36..1060 to x 83..1823 / y 54..1078 (the 83
is the focused card's own drop shadow, the 1078 the scrolling shelf's peek).
No television: this lane is host-only.


Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants