oficina / slides Public

Slides: every change made while a refusal is pending is kept

Paul ranks a lost edit worse than a flash. Until now only the paste that
waited for its font was kept as its ProseMirror transaction; any other
change made on the refused text, or on a change that could not be
carried, was lost. Now every local change made while diverged is.

- stage.mjs's bindView takes a dispatchTransaction that applies the
  transaction with every one the plugins append and hands the state
  update to the editor's aroundDispatch, which, while diverged, holds
  the change as tr.before plus every step (transactions ySync makes to
  mirror Yjs, and ones that change nothing, are left alone). The font
  gate's aroundRun goes: its run dispatches through the same path.
- carry.mjs replays any entry whose own updates do not all integrate,
  the span recomputed against the rebuilt text each time, and falls back
  to what of the updates integrates when a replay cannot be made (never
  applying an entry of which nothing would).
- The carried changes undo in the steps they were made in: the keeper
  stamps each entry, and the undo manager stops capturing where two were
  made further apart than its 500 ms window.

Tests: carry.test.mjs gains Fable's general probe (five mixed changes,
nothing lost, page and server the same), a change that cannot be kept
in the middle, the fallback and the undo grouping (the last two fail on
10fcbf7's module). TestEnginesEveryChangeWhileARefusalIsPendingIsKept
runs fixtures/engines/diverged.mjs in Chromium and WebKit: mixed edits
(typing on the refused text, a paste elsewhere, a delete across server,
refused and new words, typing elsewhere), typing on the refused text
kept with more after it, and a change that cannot be kept in the
middle; the page, one undo and the server. On 10fcbf7 the typing on the
refused text is lost and one undo takes back every carried change, in
both engines. TestAChangeOnARefusedOneIsNotPosted becomes
TestChangesOnRefusedTextAreKeptWithoutIt: the two pastes after the
refused words are now kept, once, on the page and the server (lost on
10fcbf7), the refused words on neither.

Stacked on fix/carry-replay (10fcbf7, #28), whose span fix it needs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c766f88e8e3231666b09aff6c1fa92ffdd707f14 parent 57369b1
12 files changed, +500 −105
  • AGENTS.md +24 −11
  • fixtures/carry.mjs +47 −17
  • fixtures/carry.test.mjs +80 −0
  • fixtures/editor-entry.js +42 −29
  • fixtures/editor-fonts.mjs +5 −5
  • fixtures/engines/diverged.mjs +194 −0
  • fixtures/stage.mjs +15 −5
  • internal/slides/credits/assets.json +1 −1
  • internal/slides/static/{editor.596eb5f31695119e.js => editor.2f3aa24d34e03902.js} +15 −15
  • internal/slidestest/diverged_engines_browser_test.go +48 −0
  • internal/slidestest/fonts_engines_browser_test.go +7 −0
  • internal/slidestest/races_browser_test.go +22 −22
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/diverged.mjs

Loading diff…

fixtures/stage.mjs

Loading diff…

internal/slides/credits/assets.json

Loading diff…

internal/slides/static/{editor.596eb5f31695119e.js => editor.2f3aa24d34e03902.js}

Loading diff…

internal/slidestest/diverged_engines_browser_test.go

Loading diff…

internal/slidestest/fonts_engines_browser_test.go

Loading diff…

internal/slidestest/races_browser_test.go

Loading diff…