---
title: "Undo only your own changes in a shared · Agent Wranglers"
url: https://agentwranglers.se/playbook/app-ui/live-collaboration/undo-own-changes
id: APP-73
level: Recommended
updated: 2026-10-22
tokens: 821
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Undo only your own changes in a shared document

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Live collaboration](https://agentwranglers.se/playbook/app-ui/live-collaboration.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: APP-73
- Level: Recommended
- Chapter: [Live collaboration](https://agentwranglers.se/playbook/app-ui/live-collaboration.md)
- Rule: In a shared document, undo reverses only the local person's changes, never a collaborator's.
- 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".
- How: 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](https://agentwranglers.se/playbook/app-ui/feedback-and-dialogs/confirm-or-undo.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
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

```python
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")
```

## Related rules

- APP-44 [Let people undo or confirm destructive actions](https://agentwranglers.se/playbook/app-ui/feedback-and-dialogs/confirm-or-undo.md) in Web app interface

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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.

- Previous: [Test that copies end up equal in any order](https://agentwranglers.se/playbook/app-ui/live-collaboration/convergence-tests.md)
- Next: [Erase deleted personal data from document history](https://agentwranglers.se/playbook/app-ui/live-collaboration/erase-document-history.md)
- [Live collaboration](https://agentwranglers.se/playbook/app-ui/live-collaboration.md)
