Repository navigation
collabui: Ctrl+Z in a shared text undoes this participant's edits, never a peer's - #592
Merged
Merged
Conversation
…ver a peer's The editor's snapshot undo restores a whole buffer. In a text other people edit, that buffer predates what they typed since, and CollabText publishes whatever the buffer became, so the restore went out as the local user deleting their text (#591). The new test fails on main: A types, B types after it, A presses Ctrl+Z through the widget, and B's text is gone on every replica. TextView gains SetHistoryDelegate: while one is set the keys, Undo/Redo and CanUndo/CanRedo answer from it and the view keeps no snapshot. CollabText sets one backed by collab's own-edit undo, groups typing per word (a space, a deletion or a jump ends the group), and shows the result after each undo. The snapshot history of a view without a delegate is unchanged (control test). go.mod points collab and crdt at the heads of go-crdt/collab and go-crdt/crdt pull requests; the pins move to release tags before this merges. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The nested module requires the root module, so a change to the root's crdt requirement leaves its go.mod untidy; its CI lane refuses that. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
crdt#182 and collab#286 are released. Replace the pseudo-versions of their branches with the tags, in the root module and in rougelex, so nothing here depends on an unreleased commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ctrl+Z in a
CodeEditorbound to a livecollabui.CollabTextsession undoes this participant's own edits and nothing else. Closes #591.Verified first
collabui/collabundo_test.gowas written before any fix: two (then three)CollabTexts on one session, A types, B types after it, A presses Ctrl+Z through the widget's key path. Onmainit fails, and B's text is deleted on every replica:(expected "b"; A's undo restored the empty buffer that predated B's insertion, and
syncLocalpublished that as a local deletion.) The three-participant variant fails the same way.Fix
TextView.SetHistoryDelegate(*HistoryDelegate): while set, Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z,Undo,Redo,CanUndoandCanRedoanswer from the delegate and the view keeps no snapshot (pushUndostill announces the edit toOnHistory).nilreturns to the snapshot history, which was left as it was.CollabTextsets a delegate backed bycollab.Text.Undo/Redo(own-edit undo ofcrdt/structured, by character identity: an undo is an ordinary edit, so peers need no code), and shows the result after each undo or redo.TestHistoryDelegateRemovedRestoresSnapshotsand the existing undo tests are the control.Depends on, before merge
go.modpinsgo-crdt/collabandgo-crdt/crdtto heads of open pull requests (pseudo-versions): collab Refs go-crdt/collab#286, crdt Refs go-crdt/crdt#182. Move both pins to release tags after those merge. Thegodirective moved to 1.27.4 as collab requires.Checked, not changed
IsoDiagram.Undo(isodiagram.go:1282) has the same shape: a whole-document snapshot, restored by removing every entity and putting the old ones back. Over anIsoCRDTDocumentthat removes peers' entities and re-puts older ones as local operations. Not cheap (needs the structured Diagram's own-edit undo and an IsoDocument seam), so it is filed separately as Refs #593.SpreadsheetandCollabSheethave no undo of their own;UndoStackis an application command history and records whatever commands the application defines.Full
go test ./...green locally.🤖 Generated with Claude Code