fix #38: undo/redo no longer mis-attributes restored text in the review preview #39
Reference in New Issue
Block a user
Delete Branch "bug/38-undo-wrong-marks-in-preview"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Undo in the editor rendered wrong marks in the F10 review preview: restored baseline text (and reverted Claude text) was colored as human-authored.
Root cause
attributionController.onDidChangeattributed every non-seam document change tocurrentAuthor()(always human) and ignorede.reason. So an undo/redo that re-inserts text created a fresh human span over it.renderReviewis pure — the wrong marks came from these false author spans. (The disk-sync guard masks undo-to-saved-state; the bug bites on mid-edit undo, where the buffer stays dirty.)Fix
On
e.reason === Undo | Redo, reconcile span geometry (shift/clip/remove existing spans) but do not attribute the re-inserted chars — an undo is history navigation, not authorship.applyChangegains anattributeInsertedflag (defaulttrue;falseon undo/redo); seam matching is also skipped on undo/redo (the seam only applies forward edits).Known limitation (follow-up): restored text becomes neutral/unattributed rather than recovering its exact prior provenance (undoing a deletion of Claude's text shows it unattributed, not blue). Perfect restoration would need an attribution history stack synced to the editor's undo stack, which is fragile due to VS Code edit coalescing. The neutral behavior removes the misleading marks — the reported defect.
Tests
undoMarks.test.ts): reproduces the mid-edit-undo case and asserts restored "bravo" is unattributed + notcw-by-humanin the preview render.applyChangepath (no span for re-inserted chars; still shifts existing spans; still reconciles deletions).tsc --noEmitclean. No F7/F10 forward-edit behavior change.Closes #38
🤖 Generated with Claude Code