Document-edit flow SLICE-2 (specs/coauthoring-document-edit-flow.md §7.2,
INV-39/40/41 — P1 "too much to review"). A whole-document rewrite now proposes
ONE F4 proposal per CHANGED BLOCK (the unit a human reviews), but accepting a
block reconciles attribution at WORD granularity (the unit F3 records). Block =
decision unit; word = attribution unit. Supersedes INV-37's per-word cut for
document edits; selection edits unchanged.
- trackChangesModel.ts: new pure diffToBlockHunks(current, rewritten) — block-key
alignment (reusing diffArrays/diffBlocks keying): an isolated changed block →
one block-aligned hunk → the rewritten block raw (a code/mermaid fence is one
atomic whole-fence hunk, INV-23); insert/delete runs → one gap-span hunk over
the inter-anchor region (separators included) so reconstruction stays exact; a
zero-width gap-span is anchored (INV-41). Also split diffToHunks into the raw,
un-anchored wordEditHunks + the anchoring wrapper (the anchoring could grow an
insertion to overlap an adjacent hunk, corrupting a batch apply — a latent bug
that only surfaced once hunks are applied as a batch).
- trackChangesPreview.ts: runEditAndPropose document branch uses diffToBlockHunks
and tags each proposal granularity:"block".
- model.ts / proposalModel.ts: additive optional Proposal.granularity
("block"|"single"; absent ⇒ single, back-compat — no migration).
- proposalController.ts: accept of a block proposal runs an intra-block word
sub-diff (wordEditHunks, disjoint) and applies one applyAgentEdit per changed
run, descending offset — only the words Claude changed land Claude-attributed;
unchanged spans keep prior authorship (INV-40).
- Tests: diffToBlockHunks unit (reconstruction + fence atomic + add/remove);
f12Review host E2E (M blocks→M proposals, unchanged→none, fence atomic, INV-40
attribution, INV-41 insertion accept); updated the f11 document-path E2E to
per-block (INV-39 supersedes INV-37); MANUAL-SMOKE-F12 §2.
Seam note: pendingEdits.matchEvent resolves one registration per change event, so
INV-40's per-run attribution is sequential applyAgentEdit calls (N undo steps),
not one multi-replace WorkspaceEdit — see transcript Deferred decisions.
214 unit + 69/5 host E2E green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.9 KiB
Manual smoke — F12 document-edit flow
Covers the document-edit-flow cluster (specs/coauthoring-document-edit-flow.md,
#42 · #47 · #46). This file is filled in slice by slice.
SLICE-1 — #42 (reach): selection-aware Ask-Claude from body + tab (INV-38)
Run the extension (F5) on a markdown document under the sandbox workspace.
- Body, with selection (PUC-2). Select a paragraph, right-click the editor body. Expect Ask Claude to Edit Selection in the menu (and not "Edit Document"). Pick it → instruct → submit; a single proposal lands over the selection (existing F11 behavior, unchanged).
- Body, no selection (PUC-1). Clear the selection (click once), right-click the editor body. Expect Ask Claude to Edit Document (and not "Edit Selection"). Pick it → instruct → submit; the whole-document rewrite surfaces as F4 proposal(s) in the preview.
- Tab, with selection (PUC-3). With a selection active, right-click the editor tab. Expect Ask Claude to Edit Selection, acting on that tab's document.
- Tab, no selection (PUC-3). With no selection, right-click the editor tab. Expect Ask Claude to Edit Document, acting on that tab's document — even if a different editor is the active one. Open two markdown tabs A and B, make A active, right-click B's tab → Edit Document → the proposals land on B, not A.
- Markdown-gated. Open a non-markdown file (e.g.
.txt). Right-click body or tab: neither Ask Claude to Edit Selection nor Edit Document appears. - Single edit path. Both entries route through the same
runEditAndProposepath — there is no second edit code path (INV-38). Nothing is written to the document or sidecar by merely invoking the menu (INV-10/20/35) until you accept.
Pass criteria
The body and tab menus show exactly one Ask-Claude edit entry, matching the live selection state (selection → Edit Selection; none → Edit Document); the tab gesture targets the clicked tab's document, not the active editor; both are absent on non-markdown docs; no console errors.
SLICE-2 — #47 (review): per-block proposals + word-precise attribution (INV-39/40/41)
On a markdown doc with several paragraphs, Ask Claude to Edit Document with a light copy-edit instruction (e.g. "tighten the prose, fix typos").
- One proposal per changed block (INV-39). Claude's pass surfaces as one
✓/✗ block per changed paragraph/header/bullet, not a flurry of word-level
blocks. A paragraph with several word edits is a single proposal; the
word-level
<ins>/<del>still shows inside it. Untouched paragraphs show no proposal. - Changed fence is atomic (INV-23). If Claude edits a code/mermaid fence, it is one whole-fence proposal.
- Accept attributes only the changed words (INV-40). Accept a block proposal, then toggle the preview to Authorship/colors (or re-open in the on-state): only the words Claude actually changed are Claude-colored; the unchanged words in that block keep their prior author. The block is the decision unit; the word is the attribution unit.
- Inserted block accepts cleanly (INV-41). If Claude adds a new paragraph, its proposal accepts (it is anchored to an adjacent block, never a born-orphaned/zero-width proposal).
- Undo. Accepting a block is currently N undo steps (one per changed run
inside the block) —
Ctrl+Zrepeatedly restores it. (Spec deferred note: single-undo-step grouping is a possible follow-up.) - Selection edits unchanged. Edit Selection still produces exactly one proposal over the selection (no block fan-out).
Pass criteria
A document edit yields one in-context proposal per changed block (fences atomic); accepting a block lands the whole block but Claude-attributes only the words it changed; inserted blocks accept; selection edits are unaffected; no console errors.