Skip to content

Move the rail's script to rail.ts and hydrate the search palette when idle - #103

Merged
RobbieTheWagner merged 127 commits into
mainfrom
perf/layout-js
Dec 1, 2026
Merged

RobbieTheWagner merged 127 commits into
mainfrom
perf/layout-js

Conversation

@RobbieTheWagner

@RobbieTheWagner RobbieTheWagner commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Why

The goal is to merge media-redesign into main with confidence. Review found that every page's eager JS grew about 2.4x on this branch. Two of the causes are in Layout.astro. The rail's script was a long inline module in the layout. SearchDialog hydrated client:load even though it only opens on ⌘K or a click.

What changed

  • The rail's code lives in rail.ts. The divider's drag, fling and catch-mid-glide, the settle and glide, sync, and the travelling tooltip moved out of Layout.astro into rail.ts. The layout's script keeps only the event wiring. The code loads with the layout as before, so a press on the divider takes hold at once. It still uses slomo() from Treat --slomo 0 as 0 so reduced motion skips the motion waits #91 for the re-form hold and the hover release.
  • The palette hydrates later. SearchDialog now hydrates with client:idle={{ timeout: 500 }}. The timeout matters: without it, requestIdleCallback starved for over 30s in a busy Chromium e2e run. The ⌘K handler moved out of the island into search-shortcut.ts, a small eager module. A ⌘K pressed before hydration sets isSearchOpen, and the palette opens as soon as it hydrates. A click on a SearchButton before hydration works the same way.
  • Left as is. SearchButton stays client:load. Its two instances share one chunk, and its imports (icons, state, palette-episodes) load eagerly anyway, so client:idle would save no bytes and would only delay clicks.

An earlier revision also loaded the drag code lazily and replayed pointer events that arrived before it. That is gone. The replay was fragile, and it saved only 0.4 KB gz of eager JS in the measurement below.

Verification

I measured eager JS by parsing each built page's module scripts and its client:load/client:only island component and renderer URLs, then walking their static import graphs and summing per-file gzip -9. Both builds came from the same worktree, origin/media-redesign at 055932b against this branch.

page before (gz) after (gz) delta
/ 71.1 KB 67.4 KB -3.7 KB
/1/ (episode) 68.2 KB 64.0 KB -4.2 KB
/about/ 58.9 KB 54.6 KB -4.3 KB

SearchDialog (3.4 KB gz) moves off the eager path and loads when the page is idle. search-shortcut adds 0.7 KB gz. The rail's code is the same size eager as it was inline: its layout chunk is 3.3 KB gz before and after. The remaining growth is elsewhere: Island alone is 14.4 KB gz (client:only), and the / EpisodeList script is 11.9 KB gz. Neither is in scope here.

  • pnpm lint: clean.
  • astro check: 0 errors.
  • vitest run: 282/282. The ⌘K unit tests import search-shortcut.
  • pnpm build: OK.
  • tests/e2e/shell.spec.ts: firefox and webkit 23 passed, 4 skipped (existing skips). Chromium 26/27. The one failure, "loads its episodes only once it opens", times out in waitForLoadState('networkidle') and fails the same way on origin/media-redesign locally.
  • New e2e test: ⌘K pressed while SearchDialog is held back opens the palette with the input focused.

🤖 Generated with Claude Code

RobbieTheWagner and others added 30 commits November 20, 2026 06:31
The leaves of the media-first redesign (#76), split out so it can be
reviewed in pieces. Nothing here changes how the current pages work:

- styles/tokens.css: the design tokens the new shell and stage use.
- motion/propflip: the shared FLIP helper for things that move between
  homes on the page.
- lib: cast, cues, entities and transcript changes the stage and the
  live transcript build on.
- utils/config: the config the redesign reads.
- Icon, illustration and sponsor SVGs redrawn for the new palette.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A shared middle name is no longer taken for a shared surname.
- Page names group full names before short aliases, so input order can't
  merge two Adams.
- SRT <font> tags are stripped from timed cues.
- The reduced-motion reset writes identity with transitions off.
- Document that flip targets must not nest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second slice of the media-first redesign (#76). One persistent <video>
plays an episode's HLS video (hls.js outside Safari) or its MP3, moving
between an episode's stage, a floating corner and the player bar. Shared
state lives in components/state.ts; the island (components/media/Island)
holds the scrubber, the medium switch and the Up next board.

The layout still mounts the old player here: the shell slice swaps the
island in and removes the old player components.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- First names that agree now pair with a short surname or an initial
  (Jen Lee ~ Jennifer Lee, Adam Argyle ~ Adam A.).
- Cue tags strip in any case, and <span>/<br> go too, a break as a space.
- The markdown transcript escapes decoded cue text, so it carries no HTML.
- flipFrom() and commit() never scale from or to a zero size.
- Drop propFlip() and .flip-hold: nothing calls them; flip() does the work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine:
- Plays an MP3 without asking for CORS; only video, whose frames are
  sampled for the stage's light, is loaded with crossorigin.
- A source that ran out of retries is forgotten, so the next Play loads
  it again where it stopped.
- Saves progress only for the episode whose source is ready: a source
  being reset no longer writes 0 over the next episode's place.
- Survives a failed hls.js import (falling back to the MP3) and drops a
  stale import's continuation by source generation.
- Honours a Pause made while the next source loads.
- Binds a deferred seek to its episode; a newer seek or another episode
  cancels it.

The queue, board and island:
- playNext() moves past an episode that ended while still in Up next.
- The shelf is cached only once it loads; a failure is asked for again
  when the card opens. Every queued episode stays off the shelf, a cover
  gets artwork that arrives later, and a cover dropped on the shelf's
  last slot stays shown.
- A drag belongs to one pointer, drops where it is released, and a
  cancel or a lost capture drops nothing. A board stopped mid-drag lets
  go of its listeners.
- The card returns focus to what opened it, and closing mid-swipe resets
  the swipe's styles.

Smaller fixes: one resume rule for the engine and every label
(resumePoint), saved positions that aren't finite are ignored, cues are
sorted before their binary search, the live script refetches for a new
episode and drops late replies, the stage light blends after its first
frame, and Watch/Listen takes arrow keys as a radio group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Redesign 1/6: foundations (tokens, motion, libraries)
- A video from a host without CORS headers is asked for again without
  CORS before the retry is spent, rather than never playing.
- The chosen speed survives a new source (defaultPlaybackRate).
- A lock-screen scrub keeps play or pause as it is.
- A failed cue fetch isn't cached, so the transcript recovers.
- Drop a swap error listener that never fired and later cut a retry's
  hold short.
- Save the place on pause, seek and pagehide, not only every 5s playing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Redesign 2/6: media engine and the player island
The third slice of the media-first redesign (#76). An episode opens on its
stage (EpisodeStage): the picture or artwork, the play controls and a live
transcript line. Below it, a sticky section bar leads to the show notes,
the people (guests first, hosts after), sponsors, the transcript and
onward episodes. Transcript timestamps become seek chips (seek-chip in
the rehype plugin), and whoever is speaking lights up wherever their
portrait is.

The episode page's styles are imported by the shell slice, which swaps in
the new layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The section bar's glide re-aims when the transcript groups it passes
settle to their real height, but groups above the section can still
settle after it lands. Chromium and Firefox keep the section put with
scroll anchoring; WebKit has none, so in CI's WebKit a link after the
transcript opened left its section up to ~500px from the bar. Where
overflow-anchor isn't supported the section is now held under the bar
for 1.5s after the glide, until you take over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WebKit reports CSS.supports('overflow-anchor', 'auto') but doesn't keep a
section put when the transcript groups above it settle, so the hold
never ran there. It now runs everywhere: where scroll anchoring did its
job, the section is already in place and nothing moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In CI's WebKit the hold left sections 1px off: it only corrected gaps
over 2px, the glide's own tolerance. It now corrects anything over half
a pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- LiveTurn reads the live group's own intersection entry.
- Section links leave modified clicks (new tab or window) to the browser.
- No speaker is published before the first line starts.
- The split divider follows only the pointer that grabbed it.
- Opening a preview unhides only its until-found groups.
- Previews fade only when they clip something.
- Groups still hidden until found keep the browser's content-visibility.
- One set of phone limits for the live script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Focus opens a preview only on a control it cuts off.
- Only transcripts are grouped and hidden until found; other markdown
  pages have no script to open them.
- The section hold lets go when you scroll the page yourself.
- No transcript turn is live before the first one starts.
- Times in show-note code aren't turned into seek chips.
- No 'More episodes' section when there's nowhere onward.
- LONG_TURN counts characters, as its comment now says.
- People without a photo get a face that follows light and dark mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging the two phone blocks kept the one before the base .script rule,
which overrides it at the same specificity, so phones got the desktop
limits. The limits now sit where the block that applied them was: after
the base rules and before the foldables, which override them in turn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The episode page's transcript heading is now "Transcript" and its
timestamps are the shared seek chip, so the tests look for those, and for
bold speaker names as proof of the markdown source. These updates came
with the shell slice; they belong with the page that changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Redesign 3/6: the episode page, built around its stage
The fourth slice of the media-first redesign (#76). The home page is the
whole archive as cards: search, filter by guest or topic and sort from a
sticky toolbar, open a card in a close-up with its play, Up next and
episode link, and come back to the card you left. Filters live in the
URL (explorer/query), so a filtered view can be linked and stepped
back through.

Its styles are imported by the shell slice, which swaps in the new layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The close-up sticks under the toolbar, and the open card's artwork,
facts, title, detail and play are anchored to slots inside it. Firefox
resolves those anchors as if the close-up weren't stuck, so once the page
has scrolled (opening a card scrolls it) the parts sat off their slots by
the close-up's sticky offset: 54px in CI. A still, invisible marker
anchored like the artwork shows where the browser puts it; on opening,
scrolling and resizing the explorer measures it against the slot and the
parts make up the gap through --xp-cu-fix. Where anchors follow a stuck
box the gap is 0 and nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It showed from 30s on, where the engine resumes only past 30s
(resumePoint, from #79's review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In CI's Chromium the correction for Firefox's anchors sometimes fired: a
measurement in the scroll event can read the marker before Chromium has
moved anchored boxes for the scroll, which showed a 54px gap that wasn't
there, and nothing measured again once the scroll stopped. Measurements
now run in an animation frame (after scrolls, their end, resizes and
opening), and a new correction is taken only when two frames in a row
agree on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Back from an episode comes home to the row it was opened from (card or
  hero), remembered per episode.
- An unreachable guests database leaves the archive without a cast
  rather than failing the home page; the cast is asked for once.
- Details ids come from the card's index, so no two can collide.
- A sort that moves cards in the DOM keeps keyboard focus where it was.
- A pause updates the loaded card's progress, the In progress count and
  that cut, from the place the engine saved.
- A progress bar clears once an episode is no longer in progress.
- The close-up offers no saved resume for the loaded episode, and follows
  it when the loaded episode changes.
- The live play control is unmounted when the page swaps.
- In progress follows the engine's resume rule: past 30 seconds.
- Without anchor positioning the archive no longer folds into the strip;
  the card opens in place.
- Filter changes keep the address's fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like transcripts, people now come from either of two optional sources: the
guests database where it lists the episode, else the feed's
<podcast:person> tags (name, role, photo, link). A feed name the database
knows is that record, so one person has one id and photo across both.
src/lib/people.ts gathers them once for the explorer, the episode page,
the stage and the search palette; with neither source, the pieces that
show people leave themselves out. Feed photos are resized like local ones.

The JSON API's episodes carry the feed's people too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Astro's router treats a change of query as another page, so each filter
step and each Back fetched and swapped the home page. A change of hash
alone is the router's move within the page: no fetch, no swap, and Back
and Forward step through it. The explorer now writes its state to the
hash with navigate(), and follows the address on hashchange and the
Navigation API's currententrychange, in place of intercepting popstate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Redesign 4/6: the home page becomes an episode explorer
The fifth slice of the media-first redesign (#76), where it comes
together. The layout gains a resizable rail (drag, throw, double-click or
step its divider), mounts the player island in place of the old player,
and imports the redesign's styles. The about, contact, sponsor, 404 and
for-LLMs pages and the search dialog move onto the new tokens; the old
player components and their assets go.

The e2e suites for the shell, the player, the explorer and the episode
page land here, where the whole redesign runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A probe in CI's Firefox (#78) timed the home → episode → home trip at
2–3s and 1s on its own, with the page idle and frames on time, but 5–9s
under the full suite's load: past Playwright's 5s default. The
navigation steps wait up to 15s, as the card-return test already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RobbieTheWagner and others added 16 commits November 30, 2026 21:25
Point CLAUDE.md at packages/starpod and list PageHeader in the README
Delete dead code and stale references
Treat --slomo 0 as 0 so reduced motion skips the motion waits
One test logs each time the page sets the search box while
`javascript` is typed, and expects none of those writes to change what
the box holds. Without the `writing` guard in `fromAddress()`, the
router's rewrite of the entry it leaves rolls the box back to the
previous words on each key (`ja` to `j`) before restoring them.

The other sets the search and picks Video in one task, before typing's
frame runs, and expects the address and the box to keep the words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Do a keystroke's explorer work once, not three times
Fix CI e2e flakes: section links in Chromium, and 4K video in WebKit
The e2e jobs ran in the Playwright image, whose tag had to match the
@playwright/test version by hand. They now install the browser for the
version pnpm-lock.yaml resolves, cached per version and browser, so the
lockfile is the only place the version lives. The exact pin in
package.json goes back to a caret range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Let e2e run on any port and pin Playwright to the CI image
Fetch the feed once per build and load sponsors in one batch
Name the explorer filter, its clear buttons and the palette's groups
Render the feed transcript on the server, not as a load island
Layout.astro keeps this branch's slim script that imports rail.ts, with
#91's slomo() for the hover release. rail.ts takes #91's slomo() for the
re-form hold and #95's comment without demos/split.html. The SearchDialog
test imports both act (this branch) and within (#98).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Search the palette the way the explorer does
The divider's drag code loaded on first want, and a press made before it
landed was recorded and played back. That replay was fragile for about
1.2 KB, so rail-drag.ts folds back into rail.ts: one module, loaded with
the layout, and a press takes hold at once. The near-rail preload, the
replay, and the two e2e tests that only existed for the lazy load go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobbieTheWagner RobbieTheWagner changed the title Load the rail's drag code and the search palette off the critical path Move the rail's script to rail.ts and hydrate the search palette when idle Dec 1, 2026
RobbieTheWagner and others added 3 commits December 1, 2026 10:34
#98 renamed the box to "Filter episodes" while #105's two typing tests
were in review, and they still looked for "Search episodes".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Find the explorer's search box by its new name in the typing tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from media-redesign to main December 1, 2026 16:46
main now holds media-redesign as one squashed commit (#110) with the same
files, so this records it as merged without changing any.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobbieTheWagner
RobbieTheWagner merged commit bf66f3c into main Dec 1, 2026
9 checks passed
@RobbieTheWagner RobbieTheWagner added the enhancement New feature or request label Dec 1, 2026
@RobbieTheWagner
RobbieTheWagner deleted the perf/layout-js branch December 1, 2026 18:15
@github-actions github-actions Bot mentioned this pull request Dec 1, 2026

This branch was successfully deployed

1 active deployment
Preview — 68b7ab32 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant