fix(lab): make replay pause authoritative

This commit is contained in:
DCCONSTRUCTIONS
2026-08-24 00:12:49 +03:00
parent a7caed70c1
commit 8877ee947f
4 changed files with 72 additions and 13 deletions
@@ -40,6 +40,23 @@ export function advanceRecordedEvidencePlayback(
return { ...playback, currentSeconds: clampRecordedEvidenceSeconds(next, range) };
}
export function synchronizeRecordedEvidencePlayback(
current: RecordedObservationPlayback,
observed: RecordedObservationPlayback,
range: RecordedEvidencePlaybackRange,
): RecordedObservationPlayback {
const currentSeconds = clampRecordedEvidenceSeconds(observed.currentSeconds, range);
return {
...current,
currentSeconds,
// The transport button owns play/pause intent. A native frame callback may
// still report the previous media state immediately after an operator
// command, so it must not restart playback. The sealed end is the only
// media-clock transition allowed to stop the shared LAB clock.
playing: currentSeconds >= range.endSeconds ? false : current.playing,
};
}
export function useRecordedEvidencePlayback(
range: RecordedEvidencePlaybackRange | null,
{ clock = "animation" }: { clock?: "animation" | "external" } = {},
@@ -106,11 +123,7 @@ export function useRecordedEvidencePlayback(
const synchronize = useCallback((next: RecordedObservationPlayback) => {
if (!validRange(range) || !Number.isFinite(next.currentSeconds)) return;
setPlayback((current) => ({
...current,
currentSeconds: clampRecordedEvidenceSeconds(next.currentSeconds, range),
playing: next.playing,
}));
setPlayback((current) => synchronizeRecordedEvidencePlayback(current, next, range));
}, [range]);
return useMemo(() => ({