oficina / docs Public

Docs: 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.
Slides has the same change (oficina/slides feat/replay-while-diverged).

- The editor view's dispatchTransaction applies each transaction with
  every one the plugins append and hands the state update to
  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 run dispatches
  through the same path.
- carry.mjs replays any entry whose own updates do not all integrate,
  the span recomputed against the rebuilt document 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 (in the gate) gains Fable's general probe, a
change that cannot be kept in the middle, the fallback and the undo
grouping (the last two fail on b8dbbf7's module).
TestEnginesEveryChangeWhileARefusalIsPendingIsKept runs
fixtures/engines/diverged.mjs in Chromium and WebKit: mixed edits,
typing on the refused text kept with more after it, and a change that
cannot be kept in the middle; the sheet, one undo and the server. On
b8dbbf7 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 sheet and the server (lost
on b8dbbf7), the refused words on neither.

Stacked on fix/carry-replay (b8dbbf7, #89), whose span fix it needs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 98037c7c34d5e061100b8cfdb9483a99c80c241e parent 29b6dea
10 files changed, +485 −72
  • AGENTS.md +27 −13
  • fixtures/carry.mjs +47 −17
  • fixtures/carry.test.mjs +80 −0
  • fixtures/editor-entry.js +44 −12
  • fixtures/engines/diverged.mjs +196 −0
  • internal/docs/diverged_engines_browser_test.go +49 −0
  • internal/docs/fonts_engines_browser_test.go +6 −1
  • internal/docs/resync_browser_test.go +22 −15
  • internal/docs/static/editor.279133e860986229.js +14 −0
  • internal/docs/static/editor.7ff107f6ce88eea0.js +0 −14
AGENTS.md

Loading diff…

fixtures/carry.mjs

Loading diff…

fixtures/carry.test.mjs

Loading diff…

fixtures/editor-entry.js

Loading diff…

fixtures/engines/diverged.mjs

Loading diff…

internal/docs/diverged_engines_browser_test.go

Loading diff…

internal/docs/fonts_engines_browser_test.go

Loading diff…

internal/docs/resync_browser_test.go

Loading diff…

internal/docs/static/editor.279133e860986229.js

Loading diff…

internal/docs/static/editor.7ff107f6ce88eea0.js

Loading diff…