Repository navigation
Ask AI: outlines, and undoing its changes later - #285
Merged
Merged
Conversation
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>
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.
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 aty. This is the same rule PDF import uses.Undo
History.group).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").model/change-set.tscompares 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
src/model/**is in the coverage list). There are also new tests for history, ask-tools, ask-session and ai-client.ocr/model-pipelinereadingnode_modulesdirectly; the worktree has none.undo_changestakes back the latest answer's changes.Review page: https://claude.ai/artifact/Xmdbz7VYcuD9jSVSBWTKdS
🤖 Generated with Claude Code