Skip to content

Keep the live script off the clock unless its episode is playing - #92

Merged
RobbieTheWagner merged 1 commit into
media-redesignfrom
fix/livescript-clock
Nov 30, 2026
Merged

RobbieTheWagner merged 1 commit into
media-redesignfrom
fix/livescript-clock

Conversation

@RobbieTheWagner

Copy link
Copy Markdown
Member

Why

We want to merge media-redesign into main with confidence, and review flagged a render hot path first. LiveScript read currentTime.value during render, so every episode stage subscribed to the playback clock. Open episode B's page while episode A plays, and B's stage re-rendered about four times a second for nothing. Each of those renders also rebuilt a Set over every cue to count speakers.

What changed

  • LiveScript.tsx: the cues live in a signal, and the live line comes from useComputed. It returns -1 before reading currentTime when this episode isn't current, so non-current stages never subscribe to the clock. The playing stage re-renders only when the live index changes, not every quarter second. The +0.25 s lookahead and the idle preview are unchanged. speakers is memoised on the cues.
  • FullPlayButton.tsx: isCurrent is read through useComputed, as PlayToggle already does, so switching episodes re-renders only the buttons whose state flips.
  • Scrubber.tsx: the preview's portal target (.dock) is looked up once at mount instead of on every timeupdate render. The Island sits inside the persisted .dock, so the node is stable.
  • tests/unit/LiveScript.test.tsx: the live line follows the clock for the playing episode, a stage for another episode stays on its preview as the clock moves, and a render count. The render count is the perf contract this PR exists for: sweeping the clock 0 to 10 s in quarter seconds with one current and one non-current stage gives 1 render (the line change at 9.75 s). The old code gives 78 on the same test.

Verification

  • Browser, dev server on :4334, headless Chromium via Playwright. Play episode 120, client-side navigate to episode 230, count LiveScript renders over 10 s of playback with a temporary counter (removed before commit). Before: 38, 37, 37. After: 0, 0, 0. Media advanced 10 s in every run. CDP ScriptDuration over the window was 6.6 to 6.9 ms before and 7.3 to 11 ms after, which is within noise: those renders produced an unchanged tree, so their cost was small. The win is the removed subscription and render work, not a visible scripting drop.
  • pnpm test:unit: 31 files, 276 tests passed.
  • pnpm exec playwright test tests/e2e/episode.spec.ts tests/e2e/player.spec.ts --project=chromium against :4334: 37 passed. A first run with default workers had 3 player tests time out waiting for remote media to advance. The same 3 passed alone on both the base and this branch, and the full 37 passed with --workers=4.
  • pnpm lint: clean. pnpm build: exit 0, astro check 0 errors.

🤖 Generated with Claude Code

LiveScript read currentTime in render, so every episode stage re-rendered
on each timeupdate, playing or not, and rebuilt its speaker set from every
cue each time. The live line now comes from a computed signal that returns
-1 before reading the clock when the episode isn't current, so other stages
never subscribe and the playing one re-renders only when its line moves.

FullPlayButton reads whether it is current through a computed, as
PlayToggle does, and Scrubber looks up the dock once instead of per tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
starpod Ready Ready Preview Nov 30, 2026 3:09pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 49cc054 and f9d8584.

Files selected for processing: 4

  • packages/starpod/src/components/FullPlayButton.tsx
  • packages/starpod/src/components/media/LiveScript.tsx
  • packages/starpod/src/components/media/Scrubber.tsx
  • tests/unit/LiveScript.test.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@RobbieTheWagner
RobbieTheWagner merged commit 2840c82 into media-redesign Nov 30, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Preview — f9d85845 Deployed Nov 30, 2026 by vercel[bot]
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.

1 participant