Repository navigation
docs(openspec): propose undo grouping by browser task - #201
Open
ilyamore88 wants to merge 3 commits into
Open
ilyamore88 wants to merge 3 commits into
ilyamore88 wants to merge 3 commits into
Conversation
Add the undo-grouping OpenSpec change: api.document.group(fn) and group ids on model events so a multi-operation action (e.g. paste) is a single undo step. Prerequisite for clipboard paste (#137).
ilyamore88
added this pull request to stack #202
October 10, 2026 11:49
Replace the explicit api.document.group(fn) + groupId design with implicit grouping in core's UndoRedoManager: local events of one browser task are buffered and become one undo step when the task made several changes. No public API, no model or event-payload changes. Rename the change to undo-group-by-task.
ilyamore88
marked this pull request as ready for review
October 10, 2026 12:06
Block events carry a single serialized block while the model's insertData/removeData expect a list, so undoing any block add/remove throws. Add the fix (wrap in a one-item list in UndoRedoManager) to the proposal, design, core spec and tasks.
ilyamore88
removed this pull request from stack #202
October 10, 2026 12:25
ilyamore88
added this pull request to stack #204
October 10, 2026 12:26
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
Planning only. This PR adds the
undo-group-by-taskOpenSpec change. It contains no code changes. It is the bottom of a stack: this ← #203 (implementation) ← #191 (clipboard paste proposal).It changes only
UndoRedoManagerin core. Local model events are buffered for the current browser task (the end of the task is detected withsetTimeout(0)):undo()andredo()record any events still buffered before acting.destroy()also clears the task timer.design.md, D5).There is no public API, no event-payload change and no change in the model.
Why
Core undo currently merges only consecutive text inserts or removals in one input. Any action with several model changes becomes several undo steps. Pressing Enter mid-paragraph is two steps today:
splitBlockemitsTextRemovedand thenBlockAdded. The upcoming paste would be three or more. All of these actions run synchronously in one browser task, so grouping by task fixes them in one place, without plugins or tools having to mark their changes.Notes for reviewers
api.document.group(fn)was the first draft. It was rejected for now: it needs public API, agroupIdon model events and about 24 model changes, and it doesn't fix Enter. It stays available if async actions (for example file upload) ever need to be one step (design.md, Alternatives).DataNodeAddedEvents thatBlockNodedispatches in a microtask during construction have nouserId, so undo never records them. That is what keeps redo from throwingAlreadyExistingKeyError. A test pins this (R2).collaboration-manager's undo/redo is unchanged, so multi-change actions still undo in several steps when collaboration is enabled. This is listed as follow-up.