APP-73Recommended
Undo only your own changes in a shared document
In a shared document, undo reverses only the local person's changes, never a collaborator's.
How to do it
A shared undo history lets one person's Ctrl+Z wipe out a colleague's paragraph. Tag local edits with an origin and let the undo manager track only that origin. Group fast typing into one undo step, such as all keys within half a second. Undo after an offline period still only touches the person's own changes. Deleting a whole document or record still follows Let people undo or confirm destructive actions.
Examples
TypeScript example
const LOCAL = Symbol('local-edit');
const body = doc.getText('body');
const undo = new Y.UndoManager(body, { trackedOrigins: new Set([LOCAL]), captureTimeout: 500 });
export function typeText(position: number, value: string) {
doc.transact(() => body.insert(position, value), LOCAL);
}
Python example
from playwright.sync_api import expect
def test_undo_leaves_other_peoples_text(browser):
first, second = (browser.new_context().new_page() for _ in range(2))
for page in (first, second):
page.goto("https://staging.example.com/docs/42")
first.get_by_role("textbox", name="Document").press_sequentially("one ")
second.get_by_role("textbox", name="Document").press_sequentially("two")
first.keyboard.press("Control+z")
expect(first.get_by_role("textbox", name="Document")).to_have_text("two")
How to check
A test with two browsers types "one" in the first and "two" in the second, then presses undo in the first. The document holds "two" and not "one".
Related rules
- APP-44 Let people undo or confirm destructive actions in Web app interface
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/app-ui/live-collaboration/undo-own-changes">Agent Wranglers web app interface playbook</a>. In code you write, add a comment next to it with the same link.