oficina / slides Public

Slides: a paste that waited for its font survives a refused save

Claude Fable's follow-up on #27/#88, branch fix/carry-replay.

carry() moves to fixtures/carry.mjs and decides from each update itself
(Y.decodeUpdate): a struct took when the doc's state for its client
reaches its end, a deleted range likewise. encodeStateVectorFromUpdate
named a client only when its structs start at clock 0, and a
delete-only update has none, so every update after a client's first,
and every Backspace, read as taken and was posted. An update of which
nothing took is held back; of one that partly took, only the part that
integrated is posted, so nothing sits pending in the server's log (a
paste into marked text rewrites the formatting around it as well).

A paste that waited for its font and ran after the refusal is kept as
its ProseMirror transaction too (editor-fonts.mjs's aroundRun). When its
own updates cannot integrate, anchored to the refused text, it is
replayed: its steps mapped through the one span where the rebuilt text
differs from tr.before and applied with maybeStep, written back with
y-prosemirror in one CARRIED transaction before any view is mounted
(one undo step, never off the slide), and that update posted. Where
ProseMirror refuses a step (a paste into a paragraph the refused Enter
made) the paste is left out as before: nothing posted, the save line
failed, the clipboard untouched.

Tests: carry.test.mjs holds Fable's eleven replay cases and his
classification probes with the real Yjs and y-prosemirror;
TestFontEnginesAWaitingPasteSurvivesARefusedSave runs the eleven through
the real editor in Chromium and WebKit (fixtures/engines/replay.mjs),
checking the page, the server and that the words never leave the page;
TestAChangeOnARefusedOneIsNotPosted adds a second paste and a Backspace
over the refused words. On 52983f8: cases (a) (Fable's probe), (c), (e),
(h), (j), (k) fail in both engines, as do the classification tests and
the browser test; (b), (f), (g), (i) were kept already and (d) is
refused in both, and they stay as guards.

prosemirror-transform 1.12.1 (already in the lockfile) is now a direct
dependency. AGENTS.md and resync-controller.mjs's header describe the
carry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c49ed4e1c8c86a49baccaf6bce86d8cb4129855b parent 52983f8
15 files changed, +851 −67
  • AGENTS.md +16 −3
  • fixtures/carry.mjs +186 −0
  • fixtures/carry.test.mjs +213 −0
  • fixtures/editor-entry.js +48 −33
  • fixtures/editor-fonts.mjs +5 −2
  • fixtures/engines/replay.mjs +212 −0
  • fixtures/package-lock.json +1 −0
  • fixtures/package.json +1 −0
  • fixtures/resync-controller.mjs +9 −0
  • internal/slides/credits/assets.json +3 −3
  • internal/slides/static/editor.07a0c82a854673ff.js +16 −0
  • internal/slides/static/editor.ba2ef94a3f5c9b80.js +0 −16
  • internal/slidestest/fonts_engines_browser_test.go +16 −1
  • internal/slidestest/races_browser_test.go +31 −9
  • internal/slidestest/replay_engines_browser_test.go +94 −0

CI passed — run details

AGENTS.md

Loading diff…

fixtures/carry.mjs

Loading diff…

fixtures/carry.test.mjs

Loading diff…

fixtures/editor-entry.js

Loading diff…

fixtures/editor-fonts.mjs

Loading diff…

fixtures/engines/replay.mjs

Loading diff…

fixtures/package-lock.json

Loading diff…

fixtures/package.json

Loading diff…

fixtures/resync-controller.mjs

Loading diff…

internal/slides/credits/assets.json

Loading diff…

internal/slides/static/editor.07a0c82a854673ff.js

Loading diff…

internal/slides/static/editor.ba2ef94a3f5c9b80.js

Loading diff…

internal/slidestest/fonts_engines_browser_test.go

Loading diff…

internal/slidestest/races_browser_test.go

Loading diff…

internal/slidestest/replay_engines_browser_test.go

Loading diff…