From a304067c534a13edf922a629ebfd749b8167fe2f Mon Sep 17 00:00:00 2001 From: Christian Pillsbury Date: Fri, 10 Jul 2026 07:30:30 -0700 Subject: [PATCH] wip(spf): cast instead of re-guarding resolved presentation in the derive effect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #5 review: the isResolvedPresentation guard in the derive effect's update() was runtime-redundant — the monitor gates `monitoring` on a resolved presentation and transitions before effects re-run, so `current` is always resolved there. Drop the guard and cast to `Presentation`, with a comment citing the invariant. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../spf/src/playback/behaviors/establish-start-media-time.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/spf/src/playback/behaviors/establish-start-media-time.ts b/packages/spf/src/playback/behaviors/establish-start-media-time.ts index f73c988f..be06ca9c 100644 --- a/packages/spf/src/playback/behaviors/establish-start-media-time.ts +++ b/packages/spf/src/playback/behaviors/establish-start-media-time.ts @@ -157,8 +157,11 @@ function establishStartMediaTimeSetup({ const containerData = state.mediaContainerData.get(); if (!containerData) return; const startMediaTimes = derive(containerData, selectionContext()); + // `current` is always resolved here — the monitor gates `monitoring` on a + // resolved presentation and transitions before effects re-run — so we cast + // to `Presentation` rather than re-narrowing. update(state.presentation as Signal, (current) => - isResolvedPresentation(current) ? stampTracks(current, startMediaTimes) : current + stampTracks(current as Presentation, startMediaTimes) ); }, },