oficina / slides Public

Slides: an undo while diverged stays undone; multi-step changes rebase; carrying is linear

Claude Fable's review of #29 at 72f74b0 (rebased onto 57369b1).

- P1: an undo made while diverged, after a change the resync replays,
  brought the undone text back and posted it (the undo's delete names
  the original ids, the replay makes new ones). The keeper now follows
  the undo manager (watchUndo): an undo marks the entries whose structs
  it took back, and its own delete of just those, undone, and take
  leaves them out; a redo of such an undo brings those entries back and
  leaves its own re-insert out. Undo items that also hold what was not
  kept here (the refused text, saved text) still mark what was; a redo
  of those goes as its own updates, so nothing doubles.
- P2: every step of a multi-step transaction was mapped through the one
  span map; a later step near the span's edge landed off by what the
  earlier ones moved, or was refused, and a mark could lose a letter.
  replaySteps now rebases prosemirror-collab's way.
- P2: cost. A fresh id per change was quadratic over a long divergence
  (4000 changes, 27 s) and left a client per keystroke in the deck. Ids
  now come from the doc's beforeTransaction: a ProseMirror change takes
  one per 500 ms window (every later ProseMirror change has its
  transactions to replay, so a held one strands none), any other change
  one of its own. carry reads clocks from the struct store and keeps one
  running probe copy, made again only after an entry did not carry
  whole; an entry of which nothing would take is never applied, on any
  path. freshClientID never returns an id the doc already holds.

Tests, failing first on c766f88 unless said: carry.test.mjs gains the
multi-step cases (Fable's rv-multistep-probe.mjs), undo and redo while
diverged (undo; undo then typing; undo, redo; undo, redo, undo; undo,
redo, typing; an undo that takes back the refused text too), the id
windows (two changes in one window, one held, nothing stranded), the
collision guard, and 4000 changes carried in under a second (25.9 s on
c766f88) with the client count bounded; the 2000-replays bound, the
undo of a carried change and of a saved one pass there and stay as
guards. TestAnUndoWhileARefusalIsPendingStaysUndone (Fable's probe):
Cmd-Z, Cmd-Z then typing, and Cmd-Z then Cmd-Shift-Z in the real
editor; the first two fail on c766f88 ("hello worlda", "hello
worldab"), the redo one reaches the same text there by accident.
diverged.mjs gains an undo in the middle, failing on c766f88 in both
engines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c0990c8494c76e530630d34b1c8ecbbac2f219de parent c766f88
11 files changed, +544 −81
  • AGENTS.md +19 −5
  • fixtures/carry.mjs +186 −50
  • fixtures/carry.test.mjs +235 −2
  • fixtures/editor-entry.js +18 −4
  • fixtures/engines/diverged.mjs +18 −0
  • internal/slides/credits/assets.json +1 −1
  • internal/slides/static/editor.2f3aa24d34e03902.js +0 −16
  • internal/slides/static/editor.edeb171c568b6ea8.js +16 −0
  • internal/slidestest/carry_browser_test.go +47 −0
  • internal/slidestest/diverged_engines_browser_test.go +3 −2
  • internal/slidestest/fonts_engines_browser_test.go +1 −1

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/engines/diverged.mjs

Loading diff…

internal/slides/credits/assets.json

Loading diff…

internal/slides/static/editor.2f3aa24d34e03902.js

Loading diff…

internal/slides/static/editor.edeb171c568b6ea8.js

Loading diff…

internal/slidestest/carry_browser_test.go

Loading diff…

internal/slidestest/diverged_engines_browser_test.go

Loading diff…

internal/slidestest/fonts_engines_browser_test.go

Loading diff…