Restore exact author attribution on undo/redo (follow-up to #38) #40
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Summary
Follow-up to #38. On undo/redo, restore each re-inserted character's exact prior
author attribution, rather than leaving re-inserted text unattributed/neutral
(the #38 fix).
Problem / pain
#38 fixed the wrong-marks bug by treating undo/redo as history navigation, not
authorship: on
e.reason === Undo|Redothe span geometry is reconciled butre-inserted chars get no attribution. That removes the false "human" coloring,
but it's lossy in one direction — undoing a deletion of Claude's text shows it
neutral/unattributed rather than restoring its original
agent(blue) span.Likewise redo of authored text comes back neutral.
Desired outcome / value
After undo/redo, author-coloring reflects the true provenance at that point in
history — Claude's restored text is blue again, the human's is green — so the
preview is fully faithful across history navigation, not just non-misleading.
Acceptance — "done right"
agentspan (blue), not neutral.Scope / non-goals
In scope: an attribution history mechanism that restores prior spans on undo/redo.
Non-goals: changing forward-edit attribution; the diff/baseline behavior.
Assumptions · constraints · dependencies
history/snapshot stack with VS Code's editor undo stack, which coalesces
edits (one undo can revert several change events) — a naive per-event snapshot
stack desyncs. Likely needs reconciliation keyed on the actual
contentChangesof each undo/redo event, or snapshotting attribution state keyed to document
versions.
Source / signal
Self-originated — planning-and-executing session vscode-cowriting-plugin-0034
(2026-06-12) while fixing #38; the minimal fix deliberately deferred exact
provenance restoration. Follows #38.
Priority (WSJF)
Value low (the #38 fix already removes the misleading marks; this is fidelity
on undo of cross-author edits) · Time-criticality low · Opportunity low ÷
Size medium (undo-stack sync is fiddly) → priority/P3.
Decomposition
Task. Checklist:
Implemented on branch
s40-undo-provenance(session 0048) — NOT merged, verification-blocked. Mechanism: per-doc text-keyed attribution snapshots (Map<documentText, spans>), captured after each forward edit + at load; on undo/redo, after the #38 geometry reconcile, restore the snapshot whose text equals the current buffer (offsets valid, identical text). Robust to VS Code undo coalescing; bounded history; far-back states fall back to #38 neutral. 222 unit + typecheck green.Blocker: the #40 host E2E (and the pre-existing #38 undoMarks E2E) drive
executeCommand("undo"), which is broken in the current local test instance — the untouched #38 test fails identically on cleanmain(the known undoMarks flake, now deterministic). The usual remedy (clearing.vscode-test/user-data) is permission-blocked in this session. Please verify in a working E2E environment, then merge. Keep open until verified.Conclusive undo-E2E diagnostic (session 0048).
executeCommand("undo")is non-functional in the local.vscode-testharness right now — proven by an isolated probe: open doc,showTextDocument(verifiedactiveTextEditor === doc), delete viaeditor.edit()(the active editors own undo stack), thenexecuteCommand("undo")→ text NOT restored (alpha charlie, deletion stands). So it is not stale user-data (moving it aside to force a fresh one did not help), not the edit mechanism (workspace.applyEditvseditor.edit— both fail), and not focus. Likely a VS Code-version / headless behavior of theundocommand in this harness. This blocks ALL undo-driven E2E (incl. the untouched #38 test, which fails identically on cleanmain). Recommend: try a different VS Code test version, or trigger undo differently, in a known-good environment — then verify+merges40-undo-provenance.Verification blocker now tracked as #54 (host E2E
undonon-functional in.vscode-test). #40 (branchs40-undo-provenance) is parked until #54 is resolved.