Skip to content

Ask AI: outlines, and undoing its changes later - #285

Merged
Joost-8 merged 1 commit into
mainfrom
claude/ai-outlines-undo-83f66d
Nov 21, 2026
Merged

Joost-8 merged 1 commit into
mainfrom
claude/ai-outlines-undo-83f66d

Conversation

@Joost-8

@Joost-8 Joost-8 commented Nov 21, 2026

Copy link
Copy Markdown
Owner

From Joost's feedback page (21 Nov): "Add AI: ask, be able to add and create outlines for notebooks and PDFs. As well as a way to undo with AI, and even undo an action of AI later."

Outlines

  • read_outline: the notebook's contents (page, level 1–3, title or heading), plus the PDFs behind the pages and each PDF's own bookmarks.
  • set_outline: writes the outline in one call and one undo step, either adding entries or replacing the outline (a replaced outline also clears page-less chapters). An entry at the top of a page becomes its title; any other becomes a heading at y. This is the same rule PDF import uses.
  • It refuses on a PDF's tab, because that tab's contents are the PDF's own outline and can't be edited.

Undo

  • Right after: everything one answer changed is one step of the normal undo (History.group).
  • Later: each change the AI makes gets a number (model/change-ledger.ts). A ↶ at the end of its row in the chat undoes it, and ↷ redoes it once undone. The AI can also do this itself (undo_changes, or asking "undo what you did").
  • Never the user's edits: model/change-set.ts compares the notebook before and after each AI edit, part by part (elements by id, page fields, added pages, page order). A later undo writes back only those parts, and only if each is still exactly as the AI left it. If not, nothing changes and a notice names the page. AI edits run in a synchronous window (asAi), so no user edit can slip into one.

Checks

  • New pure modules with tests: change-set, change-ledger, outline-edit (src/model/** is in the coverage list). There are also new tests for history, ask-tools, ask-session and ai-client.
  • lint, lint:review, lint:css, typecheck, test and build all pass locally. The one local test failure is ocr/model-pipeline reading node_modules directly; the worktree has none.
  • Run in the real view through the UI gallery: a two-tool answer is undone and redone in one step; after the user renames a chapter, undoing the outline is refused and nothing changes; an untouched change still undoes after the user's edit; undo_changes takes back the latest answer's changes.
  • Not tried on the iPad yet.

Review page: https://claude.ai/artifact/Xmdbz7VYcuD9jSVSBWTKdS

🤖 Generated with Claude Code

Ask AI can read and write a notebook's outline (contents, levels 1-3), for
notes and for notebooks made from a PDF: read_outline lists the entries and
each PDF's own bookmarks; set_outline writes or replaces the outline in one
undo step.

Everything one answer changes is one step of the normal undo. Each change
is also numbered and can be undone later, from a control on its row in the
chat or by asking the AI (undo_changes). A later undo compares each part the
AI changed with how it left it, and refuses (naming the page) when an edit
since touched one, so the user's own edits are never undone.

New pure modules: model/change-set.ts, model/change-ledger.ts,
model/outline-edit.ts, with tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Joost-8
Joost-8 merged commit a0645fa into main Nov 21, 2026
1 check passed
@Joost-8
Joost-8 deleted the claude/ai-outlines-undo-83f66d branch November 21, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant