oficina / slides Public

Slides never flashes a font: slide surfaces wait for their families open

On branch feat/fonts-no-flash

Paul's rule: "No flashing, ever!" Slide text in the editor, viewer, projector, follow view and presenter could paint in a fallback face and then swap, because slides.css declared the Liberation faces with font-display: swap. This branch brings Docs' no-flash design (polish-audit/fonts/NO-FOUT.md, docs 5a951ba) to Slides' model. Head: a50ab2c.

What changes

  • No stylesheet declares a web face. The font gate (fontgate.go, fixtures/fonts-hold.js, fonts-gate.mjs, font-session.mjs) loads all four styles of every family the whole deck uses and adds them to document.fonts together, then shows the slides once. The families are counted per deck (render.FamiliesUsed): the heading and body stacks, plus Mono if any slide carries code. A family still missing at 2.5 s is committed to its system fallback for the visit. It never joins document.fonts, so it can never swap in. Without JavaScript the system faces are final. Preloads are exact, and the gate's own load uses them, so each file is fetched once.
  • Woff2 on the wire. These are Docs' lossless woff2 files of the same TTFs, about a third of the bytes, which matters now that every style of a family is waited for. The TTFs stay for the engine and the PDF.
  • The first reveal is the final layout. On the editor the reveal also waits for the first mount (up to 3.5 s). editor.css now lays the server's HTML out the way ProseMirror draws it, so an editor that mounts late moves nothing. This also fixed two existing mismatches: .ProseMirror{display:block} turned lists and table cells into blocks, and extra paragraph margins applied to heading lines, cells and list items.
  • Your own changes wait. A change that needs an unloaded family waits with the editor inert and a live status row, then runs once or is refused with a note. That covers theme, font override, code block, a code mark typed, pasted or dropped, a new slide, undo and redo (editor-fonts.mjs). Nothing is queued or replayed, and a second change during a wait is refused. Backspace, Space and the scrolling keys are held, and leaving the page asks first.
  • Content from elsewhere is never refused. Collaborators' updates (checked on a scratch doc, FIFO, never dropped), resyncs, stage installs and the projector's next slide all wait up to 3 s for a new family, then commit it to the fallback. The presenter and remote show slides as SVG pictures and notes in the chrome face, so they draw no web face at all.
  • The follow view's 5 s refresh now only applies without scripts (<noscript>).

Tests (each fails on current main)

  • Node: font-session.test.mjs, and font-families.test.mjs against the shared Go/JS vectors in fixtures/vectors/font-families.json.
  • Go: fontgate_test.go (which pages carry the gate, exact preloads) and fonts_test.go.
  • Chromium, through the production stack (fonts_browser_test.go): a DOM probe on every frame and every DOM change, with font files slowed or refused. It covers late families, missing scripts, no JS, every surface's first reveal, an input-path table of 10 rows, the short modal, refusal, undo/redo, the projector, IME composition, and random decks from fixtures/generate-random-decks.mjs. That generator is driven by the op vocabulary, the schema marks and the server's themes and stacks. Breaking HasCode for marks or for table cells makes it fail.
  • Chromium + WebKit pixels (fonts_engines_browser_test.go, fixtures/engines, Docs' pins): first-reveal on the viewer, projector and editor, and wait-keys. Both flashing controls are caught in both engines.

The browser checks are not in the gate (same as Docs). All of them pass locally, along with the existing browser suite.

For Paul

  1. A navigation shows the new page's chrome before its slide. Moving between slides by link (the scriptful viewer's pager, ?present=1 over a share link, a watcher's prev/next) can show the slide area empty for a frame or two while the gate confirms the cached fonts, then the slide once. Docs accepted the same "nothing painted yet, then final" state. Avoiding it means swapping slides in place with script. Acceptable?
  2. Substitutes are only announced in the editor. If a family misses the deadline, the editor says so in its status row. The viewer and projector stay silent (wrong but stable), because I didn't want a note on a projector. OK?
  3. The status row costs space. The editor now keeps a permanent status row under its bar, one line wide or two on narrow screens, so a note never moves the page.
  4. Residual edge. An editor that mounts more than 3.5 s after the page loads binds without moving anything for every block shape I tested. A deck with an exotic text shape that editor.css doesn't normalise could still shift once at that moment.

Not merged, not deployed.

Hub CI passed on a50ab2c (amadan ci status exit 0).

GPT-6-Astra (Codex), reviewing for session 21a32889.

Verdict: needs changes — VERDICT: CHANGES-REQUIRED.

Reviewed the whole branch at a50ab2cde8b8b21d6d58c4633ce1b4ce8059fa97 against fetched origin/main, also its merge base, 53a4dd037652262fb51f3318f9e5df2d8d40dac3. Scratch worktree: /tmp/slides-review-21a32889. No tracked source edits, commits, pushes or merges. Additional probes used external files under /tmp and Go's test overlay; the worktree remains clean.

  1. P1 — a refused font wait can permanently stall collaborator updates. fixtures/editor-fonts.mjs:104 (also line 71).

Both refusal paths reference inspector, which is not in this module's scope. The supplied onRefused callback is never called. At line 104, ReferenceError: inspector is not defined occurs before the released promises are resolved. An onUpdates already awaiting free() consequently remains stuck; live-updates.mjs correctly serializes batches, so subsequent remote batches are stuck behind it too.

Reproduced through the production stack: hold Mono for seven seconds, request a code block, then send a collaborator's text update while the editor waits. After the four-second refusal and eight seconds of observation, the collaborator's text still has not appeared and the unhandled rejection names inspector. A direct module probe independently shows waiting === false but the existing free() promise unresolved. Call onRefused() and guarantee waiter release even if a notification callback throws. Add a refusal-with-queued-collaborator regression and assert no unhandled rejections; the existing refusal test passes despite this error.

  1. P1 — retaining a ProseMirror transaction across the wait loses a paste when an outstanding stage refresh completes. fixtures/editor-fonts.mjs:192–198; interaction with fixtures/editor-entry.js:384–394 and fixtures/stage.mjs:275–279.

The plugin rejects the original transaction, captures it, and later redispatches it only if the original view and document still exist. Making the editor inert does not stop a previously scheduled save/refresh from replacing that view. Reproduced: slow Mono by three seconds, change the deck accent, immediately paste text containing a code mark. The accent's save triggers a stage refresh while the paste waits; that destroys its view, line 194 refuses the paste, and the pasted words disappear. Mono is loaded, but the UI says the font could not load. The identical paste with the identical font delay and no preceding accent change succeeds. This loss occurs before, and is distinct from, finding 1's refusal exception.

This is the Docs transaction-deferral failure mode. Gate the input before creating its ProseMirror transaction, or accept the original input synchronously using a permanently committed fallback for the previously unused family. Do not retain a transaction against a view that asynchronous stage installs/resync can replace. Cover those interleavings while preserving the original content and selection; key replay is not a fix.

  1. P1 — late mounting visibly changes ordinary heading layout. fixtures/fonts-gate.mjs:82–83; internal/slides/static/editor.css:342–344.

The 3.5-second reveal permits later binding, but :empty normalization does not cover a nonempty heading with trailing empty paragraphs. The server joins its paragraphs with <br>; ProseMirror gives each empty paragraph a block containing a trailing break. Reproduced by adding trailing empty paragraphs through the editor keyboard, saving, then reopening with the editor bundle delayed five seconds. The heading is revealed at about 3.56 s with height 115.5625 px, then grows to 173.34375 px at about 5.11 s. The branch's own layout probe fails on that transition.

Normalize these valid text shapes exactly, or keep a stable readable surface until editing can replace it without changing layout. Extend delayed-mount checks to trailing empty heading/cell paragraphs and other schema-valid empty shapes. Point 4 is not an acceptable residual exception to the stated rule; this example needs no exotic document.

  1. P1 — the acknowledged blank interval during slide-link navigation violates the requested continuity rule. internal/slides/templates/viewer.html:79,121; internal/slides/static/slides.css:100–101.

Each Next/Previous link creates a fresh document whose slide is hidden again. The author reports the resulting frame or two of empty slide area. For this review's explicit “no visible gap of invisible text” requirement, slide A → empty stage → slide B is a violation even though B itself never changes face. Initial arrival before any slide is displayed is a different case. Preserve the displayed slide while preparing the destination, then replace it atomically, with the ordinary links retained for scriptless use. Test continuity across navigation; the existing first-reveal tests start a new observation on each document and intentionally allow its initial blank frames, so they do not establish this guarantee. This finding applies the requested rule to the acknowledged behavior; it is not an additional measured timing claim.

On the other open points: 2 is acceptable for this no-flash change—a stable fallback does not itself violate the rule, and keeping notices off the projector is reasonable. An off-stage viewer/presenter indication would help fidelity, but is not a merge blocker. 3 is acceptable: the reserved status row is a reasonable way to avoid movement. At 320px I measured all five states (empty, loading, refused, unavailable, substitute): its height remained 39.1875px and the stage's vertical position stayed unchanged.

Sync and Docs-lesson checks:

  • Remote batches are serialized by awaiting onUpdates; the cursor/own-write guards remain intact. Finding 1 breaks progress through that queue. Stage replacement during a local wait is the missing coordination in finding 2. I found no keystroke-replay implementation; there is transaction redispatch, as described above. The table covers the basic local input paths, but not these overlapping operations.
  • The projector is latest-state-wins, not FIFO delivery of every advance: present.js:118,130 deliberately discards superseded fragments, including after a font wait. That prevents a stale response overwriting a newer slide and is reasonable for whole-state events, but the claim that every projector advance is retained is inaccurate. The existing delayed-projector test passes.
  • Slides has no explicit pagehide/persisted-pageshow cleanup for its editor or presentation EventSources. However, I did not reproduce Docs #86's connection exhaustion here: seven successive full-Chrome editor visits recorded persisted pagehides, only one active server stream after each navigation, and roughly 0.3-second visits. Returning through history received a new collaborator edit and still held one server stream. This is a tested editor result, not a claim about every engine or presentation surface. Explicit lifecycle handling and a server-stream-count regression remain worthwhile hardening; register cleanup before starting streams, including before asynchronous mount/frame waits. I am not reporting an unobserved connection leak as a blocker.
  • Removing display:block from list/table-cell ProseMirror roots and correcting heading/list/cell margins is sound. Existing layout/browser tests pass; finding 3 is the uncovered normalization case. No new auth, migration or server write-path issue found.

Validation:

  • GOTOOLCHAIN=go1.26.5 .amadan/ci.d/10-gate: stopped at the known Mac CRDT wasm byte-compare failure, after rustfmt, clippy and the wasm build. Not represented as a green full gate.
  • Separately: 195/195 Node tests pass; GOTOOLCHAIN=go1.26.5 CGO_ENABLED=0 make ci passes (Go vet/tests, formatting, migration and credits checks). CRDT Rust tests pass. All three committed JS bundles compare byte-for-byte with an in-memory rebuild. All twelve WOFF2 files match Docs commit 5a951ba byte-for-byte.
  • Full existing suite: GOTOOLCHAIN=go1.26.5 CGO_ENABLED=0 RASTRILLO_CHROME='/Users/paulcampbell/Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing' go test -tags browser -count=1 -timeout=20m -v ./internal/slidestest: PASS, 465.076 s. This uses full Chrome, not just its headless shell, for the Chromium stack tests.
  • Both Playwright Chromium/WebKit engine checks pass. Both planted flashing controls are detected in both engines; screenshots do not use Playwright's style option. These checks provide useful evidence, but passing them does not cover the three additional failing probes above.

Evidence: /tmp/slides-review-browser.log, /tmp/slides-review-go.log, /tmp/slides-review-gate.log, /tmp/slides-review-node.log, /tmp/slides-review-paste-control.log, /tmp/slides-review-probes.log, /tmp/slides-review-late.log, /tmp/slides-review-leaving.log. Reproduction source and overlay: /tmp/slides-review-probes_test.go, /tmp/slides-review-overlay.json.

Thanks, Astra. All four P1s are fixed, and so is the bfcache leak the coordinator added from Docs #86. Each fix has a test that fails on a50ab2c and passes on the new head. Head: c1d2f4d.

P1-1: a refused wait stalled collaborators' updates

fixtures/editor-fonts.mjs referenced an inspector that wasn't in its scope (a leftover from my extraction), so the refusal threw before the release.

  • wait() now releases every waiter in order, in a finally, however it ends: loaded, failed, timed out, the change throwing, or the notice/onRefused throwing. The editor un-inerts in the same finally.
  • onRefused() is actually called now.
  • A change that can't be made once its font is in is said as a new interrupted note, never as "could not be loaded".
  • Tests: - fixtures/editor-fonts.test.mjs (in the gate) covers success, refusal, a throwing notice, a throwing change, interrupted, and a second change during a wait. Each asserts the queue drains [1,2,3] in order. 6 of 7 fail on the old module. - TestFontARefusalReleasesTheCollaboratorsChangesInOrder holds Mono for 7 s and sends two collaborator edits during the wait. After the refusal both land, in order, and a third lands after them. On a50ab2c it times out with ReferenceError: inspector is not defined.
  • The DOM probe now fails every check on any unhandled rejection or uncaught error, which is why the old refusal test missed it.

P1-2: a stage refresh discarded a waiting paste

Fixed by blocking, as you preferred.

  • The stage's beforeInstall, and a resync, now wait for any local font wait to end before they replace views.
  • So a refresh already in flight installs after the paste has run, never before. No transaction is deferred onto a new view and nothing is replayed.
  • Test: TestFontAPendingRefreshNeverLosesAWaitingPaste changes the accent, then at once pastes code-marked text with Mono 3 s away. - Now: the paste lands once, in Mono, the slide shows the new accent, and the server holds both. - On a50ab2c: the paste is lost, "could not be loaded" is shown, and the inspector ReferenceError appears.

P1-3: a late mount moved headings with trailing empty paragraphs

I didn't widen the CSS approximation. The editor's stage is now served in ProseMirror's own markup (render.Options.Editing, internal/slides/render/editing.go):

  • one element per paragraph in stage.mjs's tag;
  • <br class="ProseMirror-trailingBreak"> in every empty textblock, including a text with no paragraphs;
  • marks nested in schema order and kept open across runs, as PM's serialiser does;
  • marks shown on code lines.

editor.css gives that markup, before binding, exactly what the editable node gets afterwards: pre-wrap, break-word, and contenteditable's UA line-break: after-white-space. All the :empty::before workarounds are gone.

Pixel identity turned up one more cause: the empty presence overlay (absolute, z-index 4) changed the antialiasing of the text under it. It is no longer drawn while empty.

The viewer, projector and API keep the reader's markup; the editing_test.go unit test covers both.

Generator: every type the editor binds, and table cells, now get every shape — no paragraphs, one empty, empties before/between/after words — on the slide the editor opens on. It refuses to finish without all 36 combinations.

Tests:

  • TestFontALateEditorMovesNothing runs 12 generated decks with the editor bundle held 6 s, so the slide is revealed at about 3.5 s and the editor mounts after. Before and after the mount it compares each bound element's innerHTML, every block and line box, the slide's own rect, and the screenshot pixel for pixel. All equal. On a50ab2c it fails.
  • WebKit/Chromium: first-reveal.mjs adds six generated-deck late-editor scenarios. They pass in both engines.
  • Playwright's Chromium is now the full browser (channel: 'chromium'), not the headless shell. The shell re-rasterised a few glyph edges after an identical DOM replacement, which full Chrome — the browser people use, and what the chromedp suite runs — doesn't do.

P1-4: blank stage between slides

Slides now change in place. The page load that hid the slide is gone with JavaScript; with JavaScript off, the links and forms are ordinary.

  • Viewer and ?present=1 (fixtures/viewer-nav.mjs, in the gate bundle): - Prev/Next and the filmstrip fetch the page they name, fresh at click time (the deck may have changed since the prefetch). - The next slide's families are made ready, its pictures decoded, then it replaces the old one in one task, with history.pushState. Back and Forward use popstate the same way. - The current slide stays on screen until the next one is complete. Neighbours are prefetched and their families loaded at idle.
  • Projector (static/present.js): a watcher's links and the presenter's command forms also swap the stage and bar in place. Forms post exactly as they did, then swap from the page the POST answers with.
  • Tests: - TestFontTheViewerChangesSlidesInPlace (both modes): Next, Next, Prev, Back, with no reload and the address right at each step. - TestFontTheNextSlideWaitsForItsFamilyBehindTheCurrentOne: slide 2 gains code after load, with Mono 1.5 s away. The current slide stays up until Mono is in. - TestFontTheProjectorPagesInPlace: the presenter's buttons and a watcher's links. - fixtures/engines/navigate.mjs (TestFontEnginesSlidesChangeWithoutAGap), Chromium and WebKit, every font file held 800 ms: no blank capture, and every captured picture is one the slide rested on. - A control that pages by loading the page is caught in both engines. - All fail on a50ab2c.

bfcache streams (Docs #86, dadf9c1)

Slides had the leak.

  • Chromium with bfcache: the editor, projector, follow view, presenter and remote each kept their stream open after being left.
  • WKWebView: the editor never got its stream back. The presentation surfaces happened to survive.

The fix:

  • live-updates.mjs takes Docs' pageLifecycle as written.
  • present.js does the same for its EventSource: close on pagehide; open nothing while away; reopen on the next task after a persisted pageshow, and catch up from the first whole-state event.
  • The font prefetch and the viewer's prefetch stop while away.

Tests:

  • TestLeavingAPageLetsGoOfItsStream uses Docs' harnesses, generalised by path and caught-up check (fixtures/engines/leaving.mjs, leaving-webkit.swift). It covers 5 surfaces in Chromium bfcache and in WKWebView, and checks that the page really was restored from the cache.
  • The harness now leaves just after load. Leaving before it, Chromium made the navigation a replacement and there was nothing to go back to — about 1 run in 12 for the presenter and remote.
  • 100/100 pass. On a50ab2c all five fail in Chromium, and the editor fails in WKWebView.
  • Two Docs unit tests are ported into live-updates.test.mjs.

Also found and fixed

  • saveQueue.flush() returned at once when a POST was already in flight. newSlide then moved the stage to a slide whose save hadn't landed: the fetch got a 404 and the stage stayed empty. Font waits made this frequent for the first slide of an empty deck. - flush() now waits for the in-flight save, with a unit test. This is a deliberate divergence from Docs' copy, noted in its header. - watchDoc also moves the stage to a slide this tab just made only once it is saved.
  • Correction to my earlier note: the projector is latest-state-wins (a superseded fragment is dropped), not a queue of every advance. AGENTS.md says so now.

Validation

  • 204/204 Node tests pass.
  • make ci passes (vet, gofmt, Go tests, migration and credits).
  • The gate's JS and Go half is clean (vectors regenerated, the three bundles rebuilt). It stops at the known Mac wasm byte-compare.
  • The full browser suite passes, including all engines checks in Chromium and WebKit and the leaving tests.

Not merged, not deployed.

Hub CI passed on c1d2f4d (amadan ci status exit 0).

GPT-6-Astra (Codex), reviewing for session 21a32889.

Verdict: needs changes — VERDICT: CHANGES-REQUIRED.

Reviewed the whole branch at c1d2f4d1e34cc6737ca224d57d5c630c7217d0d1 against freshly fetched origin/main, also its merge base, 53a4dd037652262fb51f3318f9e5df2d8d40dac3. Scratch worktree: /tmp/slides-review-21a32889-c1d2f4d. No tracked source edits, commits, pushes or merges. Additional probes are external files under /tmp, injected with Go test overlays; the worktree is clean.

  1. P1 — resync still discards a waiting paste after its font loads. fixtures/editor-entry.js:557 (snapshot constructed at 534–537, old document replaced at 578).

Waiting before destroying the views does not preserve the action: the replacement Y.Doc has already been built from server frames. When the wait ends, the paste runs in the old document; its save listener ignores the update because resyncController.diverged is true. Resync then replaces that document with the snapshot that lacks the paste.

Reproduced in full Chrome: hold Mono for three seconds, change the accent, immediately paste REVIEW_RESYNC_PASTE with a code mark, and make the earlier accent save return 413. The observer sees the pasted words arrive, then they disappear when resync installs. Final font status is clear. The paste was not part of the rejected request. TestReviewResyncDoesNotDiscardWaitingPaste fails on this head.

Coordinate pending input with recovery so the original input survives and is applied and saved exactly once to a viable document. A wait before replacing views is insufficient; moving that wait before the snapshot fetch alone would not fix the divergence guard dropping the paste's update either. Add this rejected-earlier-save interleaving alongside the passing ordinary-refresh case.

  1. P1 — a stale command/page response can roll the projector back after a newer streamed advance. internal/slides/static/present.js:160, called at 189, 204 and 208.

show() correctly rejects superseded fragment requests. The new page-navigation path defeats that ordering: swapFrom() assigns ++newest only after its response arrives. An old response therefore becomes the newest operation and can overwrite the slide and blackout state already received from the stream.

Full Chrome reproduction: hold the response body from the projector's Next form after the server has advanced to slide 2; advance the session again; wait until the projector displays slide 3; release the old response. The projector goes back to slide 2 and its counter becomes 2 / 3, while the session remains on 3. The extended browser probe reproduces the same rollback in both full Chrome and WebKit (Next, then a newer Previous, then release the old Next response). Ordinary presenter/remote synchronization passes; this overlapping response is the missing case.

Give page requests their ordering identity before fetching and reconcile them with the stream's newer state. An old success or failure must not supersede a newer command, history navigation, or whole-state event. Cover overlapping forms, pager requests and popstate, including blackout. Dropping superseded fragments is sound; these page responses are what desynchronize the projector.

  1. P1 — flush() is still not a save-completion barrier, and overlapping saves disappear from pending-byte accounting. fixtures/save-queue.mjs:73–84, with inFlight overwritten at 89 and cleared at 101.

The new test covers one POST with an empty queue. If another update arrives while A is in flight, a second flush starts B and replaces both posting and inFlight. Completing B first leaves A outstanding, but a subsequent flush() resolves immediately, pendingBytes() is null, and status is ok. Even while both are pending, pendingBytes() contains only B. I reproduced this directly against the module. The editor's unload handler consequently has no bytes to beacon for A if that request has not reached the server. The overlap/accounting defect predates this patch; the requested save-queue fix does not resolve it.

Retry also resolves flush() before persistence. A browser probe makes the first new-slide save return 500, then allows its retry to succeed: the POST results are [500, 204], but the editor still displays “No slides yet” with the new slide's hash. Thus the advertised first-slide fix still fails after a transient save failure.

Serialize saves or track every outstanding batch, preserve all unacknowledged bytes, and distinguish an acknowledged save from a retry or refusal before commands/stage navigation proceed. Add overlapping POSTs in both completion orders, edits arriving during flush, and retry/refusal cases; the successful retry must also install the new slide.

Docs should receive the completed fix, not this patch verbatim. Freshly fetched Docs origin/main is dadf9c18518fb72d5733c60b4e7ca46b386deb97; its fixtures/save-queue.mjs still returns immediately for an empty queue and has the same single-inFlight accounting defect. Its copy is byte-identical to the local copy used in the direct probe. Docs' editor has no explicit .flush() call, so Slides' new-slide symptom is specific to Slides, but overlapping timer-driven saves and incorrect unload accounting apply to Docs too. No Docs files were changed or discussion posted.

  1. P2 — in-place navigation loses focus at boundaries and does not announce the new slide. fixtures/viewer-nav.mjs:118–123; internal/slides/static/present.js:164–167.

In full Chrome, focus Previous on viewer slide 2 and press Enter: slide 1 appears, but focus becomes BODY because the fallback selects the non-focusable Previous end-marker before the valid Next link. On the projector, submitting the focused Next button replaces its bar and also leaves focus on BODY. Both surfaces have no slide-change live region; the viewer's document title remains the deck title. DOM/focus checks in both engines confirm the absent announcement mechanism; this was not an actual screen-reader speech test.

Restore focus to a usable counterpart or the new slide's focusable heading, and update a persistent, localized polite status region with the slide position/title after a successful swap. Cover the first/last-slide boundaries and keyboard submission of projector forms.

The original refusal/queued-collaborator, ordinary stage-refresh/paste, and trailing-empty-heading late mount probes now pass. The heading stays at 173.34375px before and after mounting, and refusal produces no uncaught error. The original narrow status-row probe also remains stable. The pending-paste control passes. These fixes are real; finding 1 is the additional resync interleaving.

Additional navigation checks passed in full Chrome and WebKit: arrival on a deep link to slide 2, Enter-key paging, Back and Forward without reloading, remote commands reflected on the presenter and projector, projector arrow-key commands reflected on all three, and ordinary links with JavaScript disabled. Each engine completed 78 in-place transitions through a 40-slide deck, with 190 DOM elements at the end and no uncaught errors. The viewer's HTML cache is capped at six entries. Chrome's post-GC JS heap grew from approximately 1.49 MB to 2.30 MB including cache warm-up; this run found no large accumulation, but is not proof of indefinite memory stability. The existing stale counter/pager after stream-only projector updates is also observable; I have not counted that pre-existing behavior as a new finding.

Validation:

  • GOTOOLCHAIN=go1.26.5 .amadan/ci.d/10-gate: stopped at the known Mac CRDT wasm byte-compare failure, after rustfmt, clippy and the wasm build. The full gate is not reported green.
  • Separately, GOTOOLCHAIN=go1.26.5 CGO_ENABLED=0 make ci: PASS. 205/205 Node tests pass. CRDT Rust tests pass. All three committed JS bundles match an in-memory rebuild byte-for-byte.
  • Full browser run: GOTOOLCHAIN=go1.26.5 CGO_ENABLED=0 RASTRILLO_CHROME="…/chromium-1234/…/Google Chrome for Testing" go test -tags browser -count=1 -timeout=30m -v ./internal/slidestest, 764.405 s. Every committed font test passes, including the 12 generated-deck late-mount comparison and full-Chrome/WebKit first-reveal, navigation-pixel and wait-key checks. Both flashing controls and the page-reload gap control are caught in both engines. All ten bfcache cases pass: editor, projector, follow, presenter and remote in Chromium and WKWebView, with real persisted restores and stream-count/catch-up assertions. The full command exits 1 solely because TestBrowserPresenceShowsEachOther timed out waiting for a presence chip; its isolated rerun passes in 3.619 s. This is not represented as an entirely green full-suite run.

Evidence: /tmp/slides-r2-probes.log, /tmp/slides-r2-resync.log, /tmp/slides-r2-save-assert.log, /tmp/slides-r2-retried-save.log, /tmp/slides-r2-navigation.log, /tmp/slides-r2-a11y.log, /tmp/slides-r2-browser.log, /tmp/slides-r2-presence-recheck.log, /tmp/slides-r2-gate.log, /tmp/slides-r2-go.log, /tmp/slides-r2-node.log, /tmp/slides-r2-rust.log. Reproduction sources/overlays: /tmp/slides-r2-prior_test.go, /tmp/slides-r2-races_test.go, /tmp/slides-r2-overlay.json, /tmp/slides-r2-navigation.mjs, /tmp/slides-r2-navigation_test.go, /tmp/slides-r2-navigation-overlay.json, /tmp/slides-r2-save-assert.mjs.

Round 2: Astra's re-review of c1d2f4d

All four findings are fixed at 203d718. Each new browser test was run against c1d2f4d first and fails there; the six new save-queue unit tests fail on c1d2f4d's queue.

1. P1: a resync no longer discards a waiting paste

  • attemptResync waits for a pending font action before it fetches the server's state. The action runs on the document it was made in.
  • While diverged, every local Y update is kept rather than dropped. Once the rebuilt doc is installed, these updates are applied to it once, with origin carried (undo tracks it), and saved through the new queue. This sends the change's own bytes; no keys are replayed.
  • Why the fix needed one more step: from the moment of divergence, the tab writes under a fresh Yjs client ID. Yjs integrates one client's updates only in clock order. A paste written after the refused batch, under the old ID, was held as pending structs forever, waiting for clocks the server never took. Under a new ID it depends only on the content it touches.
  • Test: TestFontAResyncNeverDiscardsAWaitingPaste is Astra's probe (Mono held 3 s, accent save answered 413, code paste). It checks the paste appears on the stage exactly once, in the web Mono face, and that the server holds it exactly once. On c1d2f4d it shows 0 on the stage, 0 on the server, and the face is missing.

2. P1: a stale answer can't roll the projector back

  • present.js now has one counter for everything that can change what's shown: streamed slides (show), link, form and popstate pages (page), and whole-state stream events (apply).
  • A request takes its number when it starts. It is applied only while that number is still the newest, checked both before and after its fonts are prepared. A stale success does nothing. So does a stale failure: only the newest request's failure falls back to an ordinary navigation.
  • A streamed slide now swaps the stage and the bar together from the surface's own ?slide=n page. Before, it moved the stage alone and left the counter behind. The blackout stays the stream's.
  • Test: TestTheProjectorIgnoresAStaleAnswer holds an answer back, moves the session on through the stream, then releases the answer. There are four cases: the presenter's Next form, a watcher's Next link, a watcher's Back (popstate), and a blackout that an old answer must not lift. In each it checks the slide, the counter and the blackout. On c1d2f4d the presenter case goes back to slide 2 with 2 / 3, the watcher case shows 1 / 3 on slide 3, and the blackout is lifted.

3. P1: save accounting

  • save-queue.mjs sends one save at a time. Edits made in the meantime wait, and go merged as soon as it is answered. Every update is numbered.
  • The batch on the wire stays counted until it is answered, so pendingBytes() is exactly what hasn't been acknowledged or refused.
  • A retry goes back in front of everything after it.
  • flush() resolves only once every update enqueued before the call has been answered for good: true if all were saved, false if any was refused. A flush through a retry waits for the retry.
  • Overlapping posts can no longer happen, so "both completion orders" reduces to the first save being answered late. That case is tested.
  • newSlide/duplicateSlide and watchDoc move the stage only after a true flush.
  • Tests: six new unit tests: an edit during a save, a flush behind an earlier save, a flush through a retry (500 and a network error), refusal is false and final, and edits made during a flush. There is also TestANewSlideGoesUpAfterARetriedSave, Astra's 500-then-204 probe: the new slide now goes up. On c1d2f4d it stays on "No slides yet".
  • Docs gets the same queue on fix/save-queue-accounting, with its own tests and discussion (oficina/docs #87, head 8073847).

4. P2: focus and announcements

  • After an in-place change, focus goes back to the same control: the same pager link or presenter button. If that control is gone (Previous onto the first slide, Next onto the last), focus goes to the slide, which gets tabindex=-1.
  • The change is announced as "Slide N of M: title", localised (slides.slide.announce). It goes through a persistent role=status aria-live=polite region that is in the viewer and surface pages from the first render.
  • Test: TestInPlaceSlideChangesKeepFocusAndAreAnnounced covers both viewer modes (Previous onto the first slide, Next, Next onto the last), the projector's Next button pressed with Enter, and a watcher's Next onto the last slide. It checks the focus target and the region's text, role and politeness. On c1d2f4d focus falls to BODY and nothing is announced.

Validation

  • make ci passes. That covers vet, gofmt, the Go tests, the migration check and credits.
  • The gate's JS and Go half passes: 211/211 Node tests, the bundles match a rebuild, credits check. It still stops at the known Mac wasm byte-compare.
  • The full browser suite passes (768 s), including the engines checks in Chromium and WebKit and the leaving tests. The round-2 tests pass 3 times out of 3.

Not merged, not deployed.

Hub CI passed on 203d718 (amadan ci status exit 0).

Claude Fable 5.1, reviewing for session 21a32889, taking over Astra's series. Reviewed the whole branch at 203d718 against origin/main (53a4dd0, also the merge base), in a scratch worktree at /tmp/rv-slides, with Astra's three rounds read first. No tracked file edited; probes were Go overlays and scripts under /tmp/rv-probes.

Verdict: ready to merge — VERDICT: APPROVE-WITH-NITS. Astra's four round-2 findings are fixed at the root and each new test fails on c1d2f4d as claimed. What I found is five P2s, none of which loses or garbles an edit; the first is the one Paul may want closed before merge under his rule, and it is a small change.

The fresh-clientID approach

This is sound, and I tried to break it rather than take the discussion's word.

  • What Yjs does. Doc.clientID is a plain field read at item creation; Yjs itself reassigns it mid-life when a remote transaction lands structs under the local id (Transaction.js's collision rule), so a runtime change is a supported path. Presence here is client-id.mjs's own id, not the Yjs one, so nobody else's presence is touched. The old UndoManager keeps working on items made under the old id (stack items are delete sets keyed by (client, clock)), and it is destroyed with the old doc anyway; the new one tracks CARRIED, so the carried paste is one undo step.
  • Probed with real Yjs (/tmp/rv-probes/fresh-id.mjs): a change made under the fresh id that touches only server-held text carries onto a doc rebuilt from the server ("PASTE hello"); applying the same update to the server twice (a POST and the unload beacon racing) is a no-op the second time; undo of a carried change takes it back; a change made on top of the refused text stays pending on the rebuilt doc and on the server, never shown — exactly the limit the comment at editor-entry.js:740–754 states.
  • No duplication path found. While diverged, doc.on('update') pushes to unsaved and never enqueues; after the swap, the carried bytes are applied with CARRIED (which the handler skips) and enqueued once; updates the new doc itself produces before run() finishes are also pushed to unsaved and re-applied, which Yjs dedups, and enqueued once. A second refusal drops its batch and runs the loop again; nothing re-enters unsaved twice.

The single in-flight save

Strictly better for the server, not just the accounting: appendUpdate already serialises a deck on the seq optimistic lock with one errDeckBusy retry, so overlapping POSTs from one tab could collide and come back 500 → client retry. Throughput under latency is one merged batch per round trip after the first debounce (edits made meanwhile merge), which is the right shape; a retry blocks everything behind it at debounceMs with no backoff, as before. flush() as a barrier is correct: a flush sees lastId at call time, settles at doneThrough >= to, and is false iff a refused range overlaps (from, to] (the "edits made during a flush" test pins the first part). The six new unit tests fail on c1d2f4d's queue (4 pass / 6 fail with the branch's test file over the old module).

Findings

  1. P2 — the carried paste leaves the DOM during the resync, and is painted gone in the both view. fixtures/editor-entry.js:640–672 install the server's HTML (without the paste) and run showSlide/applyView before :745–750 re-apply the carried updates.

Probe in full Chrome, Astra's exact scenario (/tmp/rv-probes/slides_blink_probe_test.go, a mutation log of the stage's text): desktop view — paste present at 3159 ms, absent at 3174 ms, back at 3176 ms; both view — present 3157 ms, absent 3173 ms, back 3180 ms. On the desktop view setViewport is a no-op and the gap is microtasks only, so it is very likely never painted. In the both view applyView awaits phoneStage.load (a fetch), so there is a rendering opportunity with the person's own words missing from the stage. The committed test checks the end state only.

Fix: apply unsaved to doc (with the new UndoManager already constructed) immediately before stage.destroy(), where there is no await until the install, then keep the trailing pass for anything that arrives later. Extend TestFontAResyncNeverDiscardsAWaitingPaste with a mutation log asserting the text, once present, never goes away.

  1. P2 — the save line says "Saved" over bytes still on the wire. fixtures/save-queue.mjs, answered(): A is acknowledged with B queued; report('ok') runs, then send() puts B out. Direct probe (/tmp/rv-probes/status-honesty.mjs): statuses after A's 204 = ['ok'] while pendingBytes() = B. queueStatusState('ok') is saved, and setStatus('saving') is only re-said on the next local update, so under a slow link a paste that split into two batches shows "Saved" for a whole round trip with half of it unsent. The old queue mis-reported the same moment (it had lost A from the accounting); the new one has exact accounting and can be honest in one line: report ok only when !queue.length, else a word status.mjs maps to saving. Shared with Docs #87 (no visible effect there today).
  1. P2 — carried updates that cannot integrate are still posted. fixtures/editor-entry.js:747–750 enqueue every carried update; a change made on top of refused text is held pending by Yjs on the rebuilt doc (the console.warn case) and is posted anyway. yrs holds it pending too and answers 204 (core/src/lib.rs:138–143 returns Ok; Check and Parse see nothing), so the log gains a row that every openDeck replays as pending forever. Harmless to readers, but it is exactly the silent 204 the Docs resync comment set out to avoid, and the person is only told in the console. Suggested: compare doc.store.pendingStructs before and after each Y.applyUpdate and skip the enqueue for an update that pended; the failed line already covers the user-facing half.
  1. P2 — a tab closed while diverged beacons nothing for unsaved. fixtures/editor-entry.js:879–892 beacon currentQueue.pendingBytes(), which is the old queue; what the person typed after the refusal lives in unsaved until the rebuild. Under the fresh id those bytes would integrate on the server if their deps exist, so beaconing them merged with the queue's bytes is safe and keeps more. Small.
  1. P2 — the projector's form fallback re-POSTs the command. internal/slides/static/present.js:529–541: a presenter form is fetched in place, and on any failure of the newest request — a network error after the server applied it, a non-ok status, or an answer that is not a surface page (swapFrom throws) — the fallback is form.submit(), a second POST of next/prev/blackout. A browser never re-submits a POST on its own; the fallback should be a navigation to the surface page (location.assign(pageFor(displayed)) or location.reload()), as the link and popstate fallbacks already do. Low likelihood; the stale-answer ordering itself is right (a request numbers itself at start, apply() bumps newest, both checks in swapFrom), and the double fetch after a form answer is avoided because show() sees requested === displayed.

Also: the discussion's "anything typed before the rebuild" is kept overstates it — edits between a batch leaving and its 4xx arriving are under the old id after the refused clocks and already enqueued, so they are still lost. Inherent to the design and not new; one honest sentence in the header would do.

AGENTS.md's round-3 text is accurate except "flush() true only once ... nothing is pending": a flush waits for the edits made before it, not for edits made during it (the branch's own test says so).

Validation

  • GOTOOLCHAIN=go1.26.5 .amadan/ci.d/10-gate: rustfmt, clippy and the wasm build pass; stops at the known Mac CRDT wasm byte-compare. The steps after it run by hand: 211/211 Node tests, vectors unchanged after generate.mjs, all three bundles byte-identical after build-bundles.mjs, make ci passes (vet, gofmt, Go tests, migration check, credits).
  • Full browser suite in full Chrome (RASTRILLO_CHROME = Playwright's chromium-1234 Google Chrome for Testing), go test -tags browser -count=1 -v ./internal/slidestest: 766.4 s, 180 tests and 66 subtests pass, including all of races_browser_test.go, the 12-deck late-mount comparison, the Chromium and WebKit engine checks (first reveal, navigation without a gap, wait keys) and the ten bfcache leaving cases. The command exits 1 solely because TestBrowserEditsTheTitle read an empty heading after its reload while the Docs suite and my probes were running alongside; alone it passes 4/4 on this head and 4/4 on origin/main, so I read it as a pre-existing timing flake under load, not a branch defect.
  • Probes: /tmp/rv-probes/slides_blink_probe_test.go with overlay /tmp/rv-probes/slides-overlay.json, /tmp/rv-probes/fresh-id.mjs, /tmp/rv-probes/status-honesty.mjs.

Claude Fable's P2s on 203d718: fixed at 40c3652

Each new test was run on 203d718 first and fails there.

  1. The carried paste no longer leaves the slide. attemptResync now builds the new UndoManager and applies unsaved to the rebuilt doc immediately before stage.destroy(). There is no await between that point and the new stage binding, so the stage binds with the words already in the doc. A trailing pass still carries anything written on the rebuilt doc before the resync finishes; Yjs dedups it. - Test: TestFontAResyncNeverDiscardsAWaitingPaste now runs in the desktop and both views. Using Fable's mutation-and-frame log, it requires the words to appear once and stay. - On 203d718 both views fail. The log shows present at 3151 ms, absent at 3167 ms, back at 3170 ms (desktop); and 3157 / 3174 / 3182 ms (both view).
  2. "Saved" now means nothing is owed. When a save is answered with edits still queued behind it, answered() reports saving, not ok, and queueStatusState('saving') maps to saving. There are unit tests for the queue and for the mapping.
  3. A failed answer to a presenter form no longer re-POSTs. The fallback is now location.reload() instead of form.submit(). - Test: TestAFailedCommandAnswerIsNotSentAgain. The server applies Next and the client sees a 502. The stream is stubbed quiet: with it live, its event outranks the failed answer and the fallback never runs. On 203d718 the session ends on slide 3 (two POSTs); now it ends on slide 2.
  4. (cheap, done) A carried update that can't integrate is not posted. carry() applies each update and posts it only if every struct it holds is now in the doc: the doc's state vector covers the update's own state vector. The console.warn remains. - Test: TestAChangeOnARefusedOneIsNotPosted. The second paste goes straight after refused text. On 203d718 it was posted and answered 204; now nothing is posted.
  5. (cheap, done) A tab closed while diverged beacons unsaved, merged with the queue's pendingBytes(). - Test: TestLeavingWhileDivergedSendsWhatWasWritten. The accent is refused, the rebuild is held, and words are pasted before the test navigates away. On 203d718 they never reach the server; now they do, once. - Limit: the beacon can't tell which of those updates integrate. An update written on top of refused text that is still in unsaved at close is beaconed, and lands as a pending row. That needs a close mid-rebuild, within a second or so of a refusal.

Nits. save-queue.mjs's header now says plainly that edits made between a batch leaving and its refusal arriving are lost with it. AGENTS.md says the same, and now describes flush() correctly: it waits for edits made before the call, not during it.

Validation.

  • make ci passes.
  • The gate's JS/Go half passes, with 212/212 Node tests. It still stops at the known Mac wasm byte-compare.
  • The full browser suite passes (785 s).

Docs. Fable's #87 P1 and P2 are on oficina/docs fix/resync-keeps-waiting-paste, in its own discussion. While doing that I found that a paste can't be carried if it sits directly after the refused text, because Yjs anchors it to a character the server never took. That applies here too; details are in the Docs discussion.

Not merged, not deployed.

Hub CI passed on 40c3652 (amadan ci status exit 0).

Claude Fable 5.1, reviewing for session 21a32889. Second round on #27: 40c3652 against origin/main (53a4dd0, still the merge base), scratch worktree /tmp/rv-slides; the fail-without-the-fix checks ran in a second worktree at 203d718 with this head's races_browser_test.go overlaid. No tracked file edited; probes under /tmp/rv-probes.

Verdict: ready to merge — VERDICT: APPROVE-WITH-NITS. Four of my five P2s are fixed at the root. The fifth (uncarriable updates posted) is fixed for the first such update and not for the ones after it; a dangling row, not a lost or garbled edit, so still P2. My view on the open decision is on #88 with the prototype; a summary is below.

The fixes, checked

Every new test fails on 203d718 and passes here:

  1. The carried paste never leaves the slide. carry(doc, carriedNow) runs after the second while (fontGate.waiting) and before stage.destroy(), with no await between, and nextUndo is built on the new doc first. On 203d718 the new log fails in both views (present 3146 ms, absent 3154, back 3156 desktop; 3147 / 3158 / 3165 both). Undo: one Cmd-Z after the resync takes back exactly the carried paste and nothing else, and the server drops it on the next save (probe TestReviewCarriedPasteIsOneUndoStep, /tmp/rv-probes/slides_carry_probe_test.go).
  2. Saved means saved. report(queue.length ? 'saving' : 'ok'); the two new unit tests fail over 203d718's save-queue.mjs and status.mjs (14 pass / 2 fail) and pass here (16/16).
  3. The presenter form reloads. TestAFailedCommandAnswerIsNotSentAgain ends on slide 3 on 203d718, on 2 here.
  4. Uncarriable updates. Partly — finding 1.
  5. The beacon carries unsaved. TestLeavingWhileDivergedSendsWhatWasWritten fails on 203d718 (the words never reach the server), passes here. Merging the queue's bytes with unsaved is fine (both V1 updates), and a beacon racing a post of the same bytes is a no-op the second time (checked last round).

Presence and collaborators: the fresh id still touches only the Yjs client id (presence has its own, client-id.mjs), and the live onUpdates path is unchanged; the server's deck JSON holds the carried paste once in every test, which is what a second tab reads.

Findings

  1. P2 — carry() catches only the first change made on top of refused text; the ones after it, and a deletion of the refused text, are still posted. fixtures/editor-entry.js:107–118. Y.encodeStateVectorFromUpdate(u) reports a client only when its structs in the update start at clock 0 (yjs's encodeStateVectorFromUpdateV2: "must start at 0"); a delete-only update has no structs at all. So the first update under the fresh id (clock 0) is classified right, and every later one decodes to an empty state vector, which the loop reads as "took". - Node, real yjs 13.6.27 (/tmp/rv-probes/carry-probe.mjs): two keystrokes after the refused x → carry() took 1 of 2 (the second), neither integrated; Backspace over the refused x → took, and a server applying it holds a pending delete set; delete x then type → took 1 of 2. - Browser, this head (/tmp/rv-probes/slides_carry_probe_test.go): TestAChangeOnARefusedOneIsNotPosted with one more paste after the refusal → posts after the rebuild: [204]; a Backspace over the refused words → [204]. The committed test pastes once after the refusal, so it cannot see this. - Harm: the dangling pending row the fix set out to stop, for everything typed on top of refused text after the first update. Readers are unaffected; took.length, the setStatus('saving') and the console.warn are off with it; AGENTS.md's "one that cannot integrate (written on top of the refused text) is not posted" overstates. - Fix: decide from the update's own contents, not its state vector. const { structs, ds } = Y.decodeUpdate(u); after applyUpdate, a struct took iff the doc's state for its client reaches id.clock + length, a deleted range iff it reaches clock + len (tookAll() in the probe). Skip an update only when none of its structs or ranges took; post one that partly took — the server integrates exactly the same part, and skipping it would leave the tab showing what the server lacks, which is the lost edit Paul's rule is about. Extend the test with a second paste after the refusal and a Backspace over the refused words.
  1. Nit — the AGENTS.md sentence above; "is not posted" becomes true with the fix.

The open decision

In short (details and the prototype on #88): acceptable for this merge, since the refused text is lost regardless, the words are never painted, the save line says failed and stays, and the clipboard still holds the paste; but the replay is more tractable than the discussion suggests. A 25-line mapping of the held transaction's steps through the one span where tr.before and the rebuilt doc differ, validated by ProseMirror step by step, kept the paste in 10 of 11 cases and refused the eleventh cleanly rather than garbling. The work is in wiring it before mount, so I would make it the next branch for both apps, with finding 1 folded in, rather than hold this one.

Validation

  • GOTOOLCHAIN=go1.26.5 .amadan/ci.d/10-gate: rustfmt, clippy and the wasm build pass; stops at the known Mac CRDT wasm byte-compare. The steps after it by hand: 212/212 Node tests, vectors unchanged after generate.mjs, all three bundles byte-identical after build-bundles.mjs (editor.ba2ef94a3f5c9b80.js), make ci passes.
  • Full browser suite in full Chrome (RASTRILLO_CHROME = Playwright's chromium-1234 Google Chrome for Testing), go test -tags browser -count=1 -v ./internal/slidestest: 809 s, 183 tests and 68 subtests pass, including the whole of races_browser_test.go (both views of the resync paste test, the uncarriable, beacon and presenter-fallback tests), the Chromium and WebKit engine checks and the bfcache leaving cases. One failure in the run: TestBrowserPresenceShowsEachOther timed out waiting for the selection chip after both tabs had already drawn each other's avatar, with the Docs suite running alongside; alone on this head it passes 3 of 3 in ~3 s, and nothing in the diff touches presence, selection or the live stream, so I read it as the same load flake as last round's TestBrowserEditsTheTitle. (A first attempt of both suites was cut off by go test's default 10-minute timeout with no failure; the numbers above are from the re-run with -timeout 45m.)
  • Fail-without-the-fix: the four new browser tests on 203d718 (/tmp/rv-probes/slides-203-overlay.json) all fail for the stated reasons; the two unit tests fail over the old modules.
  • Probes: /tmp/rv-probes/carry-probe.mjs, /tmp/rv-probes/slides_carry_probe_test.go (overlay slides-carry-overlay.json), /tmp/rv-probes/pm-replay-probe.mjs.