VersionControl:PRs/rabbithole/13

From PickiPedia: A knowledge base of bluegrass, old time psychedelic jams, and other public domain music
Jump to navigationJump to search
rabbithole#13: Webamp's window has one home: a stylesheet rule, set before it renders
State 🟣 merged 2026-11-06 17:09:21
Worked on by magent, with skyler, justin
Moods #rabbithole
Deploy redeploy pickipedia.
Branch feat/webamp-ready → main, by magent-cryptograss
Opened · last pushed 2026-11-05 21:37:50 · 2026-11-05 21:38:04
Item 3 of the [player audit](https://pickipedia.xyz/wiki/26350517_Rabbithole_player_audit): Webamp drawn in one place, then moved. That's the jump into place Justin saw.

**Why it jumped.** Webamp renders its windows centred in the container, with each window's position as an inline `transform` written from its own state. Five loops then waited for the window and wrote our position over it: two timers and a MutationObserver in the player (sidebar layout), and a poll, a resize re-pin and a second observer in the shell (bar layout). Each landed a tick or more after the first paint.

**Invariant:** the window is home on the first paint, and stays there. **By construction:** the player writes one stylesheet rule at construction, before Webamp exists: `#webamp div:has(> #main-window) { transform: <home> !important }`, with the mobile stacking rule as a media query. A stylesheet rule beats an inline style on every paint, so there is nothing to wait for and nothing to put back after a drag, zoom reset or rotation. Everything else that needs Webamp's window hangs off `renderWhenReady()`: `#webamp` is moved into our container and the ensemble built in the same task as the render, no timers between. The player exposes the promise as `ready`.

**Gone:** `constrainWebampToContainer` and its 500ms wait, the 100ms wait and the poll for `#main-window`, the player's observer and its cleanup, the shell's `pinWebamp`, `repin` and `holdWebampStill`, and the two polls for Webamp's media (`wireVolume`, rhdiag), which exists from Webamp's constructor. Net −154 lines.

**Checked on pickipedia.xyz with the branch routed in,** recording the main window's position on every animation frame from the first frame it exists: sidebar layout, one position ever, (10,10) in the container; bar layout, one position ever, (0,0). Writing a drag's transform inline leaves the computed transform at home in both. Cards and parts strip present in both. Screenshots of both layouts look as before.

Also retires audit item 11 (an observer per song load; there is no observer now).

Deploy: redeploy pickipedia.
Worked on by: magent, with Skyler and Justin, in #rabbithole