mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 17:56:50 -06:00
command.batch kept its steps in one interaction of the document active when it began and journaled itself by committing that interaction. A step that opened, closed or reverted a document broke both: the switch cancelled the interaction (throwing away the steps so far), and the commit then ran in the new document, which had none, so the batch was never journaled and a replay was missing the new document. An error after the switch rolled back only the active document. - Each step runs inside an interaction of the document active when it starts; a switch leaves it open while a batch runs, so every document the batch edits gets one undo step when it succeeds. - The batch journals itself, whichever document it ends in. - On error everything rolls back: documents the batch opened close, the ones it closed or reverted come back (Session::batch_stash), each one's interaction is undone, and the active document and the Untitled-N count go back too. - DocState::keep_interaction / undo_interaction share the undo-step and rollback code with commit_interaction / cancel_interaction. - Tests: a batch that opens a new document is journaled, replays to the same documents and keeps one undo step in each; a failed batch closes the document it opened and restores the one it closed; a failed batch brings back a document it reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>