Repository navigation
fix(player): return no marker occurrence before the first one starts - #1278
Conversation
markerOccurrenceAtTime seeded its result with occurrences[0], so a playhead before the first occurrence of that kind returned a range that had not started yet. Every current caller re-checks the playhead (the intro prompt needs currentTime inside the range, the skip pill and the recap auto-skip do the same), so no skip was offered early, but the helper's contract only held by accident for the next caller. Start from null, which makes the contract exact: the last occurrence that has started, or none. The previous occurrence is still kept after it ends so an intro skip can be undone. Adds the missing tests for the multi-occurrence helpers used by the player: resolveMarkerRegions (complete list preferred, singular fallback, ordering), markerOccurrenceAtTime (pre-start, inside, between, other kinds) and resolveAutoplayMarker (closing credits only, narrative gaps never spanned, preview only when previews may autoplay next). (cherry picked from commit 4256214)
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
313bac7
into
Silo-Server:codex/theintrodb-marker-sync
Problem
Related issue: #1120
Review follow-up to #1275.
markerOccurrenceAtTimeseeded its result withoccurrences[0], so a playheadbefore the first occurrence of that kind returned a range that had not started
yet. Every current caller re-checks the playhead (the intro prompt requires
currentTimeinside the range, and the skip pill and recap auto-skip do thesame), so no skip was offered early, but the helper's contract only held by
accident for the next caller. The three multi-occurrence helpers the player
relies on, and the realtime
marker_segmentspayload, also had no tests.Approach
Start from
nullinmarkerOccurrenceAtTime, which makes the contract exact:the last occurrence that has started, or none. The previous occurrence is still
kept after it ends, so an intro skip can still be undone.
Add unit tests for the helpers:
resolveMarkerRegions(complete occurrence listpreferred over the singular fields, singular fallback, unusable ranges dropped,
ordering by start time),
markerOccurrenceAtTime(before the first occurrence,inside it, between occurrences, other kinds), and
resolveAutoplayMarker(closing credits only, the narrative gap before them never spanned, preview
counted only when previews may autoplay next).
Validation
pnpm install --frozen-lockfile, thenpnpm vitest run src/player/utils/watchPageMarkers.test.ts: 13 tests pass, including the newpre-start case.
pnpm exec tsc --noEmitandprettier --checkon both changedfiles are clean.
No manual playback against a running server was done; this change is mechanical
and covered by the unit tests.
Risks
None identified. The helper's only behavior change is returning
nullwhere itpreviously returned a not-yet-started occurrence, and no caller depended on
that.
Checklist
AI Disclosure
pnpm,vitest, TypeScript and Prettierthat the requesting developer directed, verified by the test run above, and the
pull request was opened at their instruction. Maintainer review pending.
reviewers, and this finding came from the web player slice. The reviewer's
claim that the helper could produce a wrong skip button or countdown was
refuted by the call sites (each re-checks the playhead), and the remaining
contract problem is what this patch fixes. This patch itself has not had a
separate adversarial pass; the evidence for it is the test run above.