#47 (SLICE-2, review): per-block document proposals + word-precise accept
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>
This commit is contained in:
@@ -35,3 +35,35 @@ 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").
|
||||
|
||||
1. **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.
|
||||
2. **Changed fence is atomic (INV-23).** If Claude edits a code/mermaid fence, it
|
||||
is **one** whole-fence proposal.
|
||||
3. **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.
|
||||
4. **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).
|
||||
5. **Undo.** Accepting a block is currently **N undo steps** (one per changed run
|
||||
inside the block) — `Ctrl+Z` repeatedly restores it. (Spec deferred note:
|
||||
single-undo-step grouping is a possible follow-up.)
|
||||
6. **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.
|
||||
|
||||
Reference in New Issue
Block a user