Skip to content

Markdown agent: rewrite what you selected, and undo - #104

Open
jpcamara wants to merge 1 commit into
feat/agent-in-viewfrom
feat/markdown-undo
Open

jpcamara wants to merge 1 commit into
feat/agent-in-viewfrom
feat/markdown-undo

Conversation

@jpcamara

Copy link
Copy Markdown
Owner

Stacked on #103. Brings the markdown page level with the Lexxy page on the two things it lacked.

Rewrite what you selected

  • The agent keeps each person's last non-collapsed selection from awareness as two anchors (before the start, after the end), for two minutes. A request like @agent rewrite this in one sentence, from the person whose caret is on that line, applies only to the paragraphs the selection covers, wherever they are by then. With no recent selection, the paragraph above the request.
  • The request line is removed, the edit plan is held to that paragraph range (MarkdownEditor gets only:), and the rewrite is typed in place at the drafting pace with the text selected as it grows.

Undo

  • Each action records a region: two anchors bracketing the bytes it touched, plus the text that was there. @agent undo resolves the anchors and puts the old text back, wherever that region has moved to. Covers a rewrite, a contribution after a change, an answer (the region is empty, so undo removes it), and a drafted section including its heading.
  • Buttons for "Rewrite what I selected" and "Undo its last change" on both pages.

Verified

  • Unit: a region records, survives an insert above, and reverts byte-exact.
  • Chrome, stub: a request with a selection rewrites that paragraph and nothing else; undo after an insert above restores it exactly; a second undo removes the last drafted section.
  • Chrome, real model: the intro selected and rewritten as one sentence in 5s, every other line byte-identical except the removed request line and the why-line under the review; undo restored it exactly after a preface was inserted above.

The markdown page gets the two things the Lexxy page had and it did not.

Selection memory: each person's last non-collapsed selection is kept as two
anchors from their awareness state, so "@agent rewrite this in one
sentence" applies to what they selected, wherever that text sits by the
time the agent reads the line. Without a recent selection, the paragraph
above the request. The request line goes, the plan is held to those
paragraphs, and the rewrite is typed in their place with the same pace and
selection as a draft.

Undo: every action records a region, two anchors bracketing the bytes it
touched and the text that was there, so "@agent undo" puts the old text
back wherever it has moved to. That covers a rewrite, a contribution after
a change, an answer, and a whole drafted section. Buttons for both on both
pages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TeaovH2jyHARHJSyQ8Afo
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