feat(word-addin): conflicted cards gain "Accept & apply" - supersede pending revisions explicitly
WHY THIS MATTERS Mike refuses to apply an edit whose target passage already carries pending tracked changes, and that guard is correct: layering a tracked replacement over pending revisions would make the card's Accept/Reject silently resolve changes the card never showed, and Word hosts merge overlapping revisions differently. But the guard was a dead end - a pending one-word spelling fix blocked a whole-paragraph rewrite, and the card's only advice was to go resolve things in Word by hand. The common case (the pending changes are your own trivia; the rewrite subsumes them) deserved a one-click path. WHY NOT SILENT WARN-AND-APPLY The card system's core invariant is that the revisions bound to a card are exactly the revisions that card created - capture happens right after applying, and only holds because the range was revision-free. Applying over occupied text breaks Accept (resolves a stranger's change as a side effect), breaks Reject (reverts someone's fix as collateral), and rests on host-divergent revision merging. So superseding stays a human decision, made visible. HOW IT WORKS The conflicted card now carries an "Accept & apply" action: 1. acceptPendingRevisionsForEdit (useWordDoc) re-locates the target with the same search rules as apply (verbatim, then markdown-marker stripped; unique match unless occurrence=all) and accepts the revisions occupying it - making the range revision-free. 2. The edit's ORIGINAL apply lifecycle reruns from scratch (applyStreamedEdit, via a retry registry that conflicted outcomes populate), so replace-all passes, persistence, anchors, and direct mode all behave exactly as a first-time apply. Between the two steps the document can shift; that is safe because the rerun re-validates everything and simply reports conflicted again if new revisions appeared. If one occupying revision is an earlier Mike card, accepting it flows through that card's own revalidation and it reports resolved rather than dangling. The mock's seeded pre-existing revisions learn a real accept(): the acceptance is recorded and the seed retired, mirroring Word where an accepted change stops being pending. e2e proves the full arc - conflicted card, zero writes, one click, the occupying revision accepted, the edit landing as a fresh redline whose Accept resolves only itself. Full suite: 294 passed (chromium + webkit), 2 new. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| Repository | open-legal-products/mike |
|---|---|
| Author | Amal <mamalanand3@gmail.com> |
| Authored | |
| Parents | 0f54e7fb |
| Stats | 9 files changed , +287 , -9 |
| Part of | Make Word edit approval reliable across hosts |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-e99bfc5b.md
from inside the repo you want the change in.