Skip to content

feat(edit): warn when a whole-paragraph edit resolves other authors' revisions - #18

Merged
kklimuk merged 1 commit into
mainfrom
claude/triage-issue-17-warn-whole-paragraph
Oct 8, 2026
Merged

kklimuk merged 1 commit into
mainfrom
claude/triage-issue-17-warn-whole-paragraph

Conversation

@kklimuk

@kklimuk kklimuk commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

🤖 docx-cli triage

What was wrong

A whole-paragraph content edit rebuilds the paragraph as if one author wrote it. On a paragraph holding Reviewer A's pending insertion and Reviewer B's pending deletion, edit --at p0 --text "…" --track --author Editor turned A's insertion into plain text and removed B's deletion. It printed edit p0 and exited 0.

What changed

This is option D, the interim fix you chose: the edit still applies, and a warning now goes to stderr (exit 0):

warning: p0 had pending tracked changes by Reviewer A, Reviewer B; a whole-paragraph edit resolves them without review …
To keep them pending, edit only the words that change: `docx replace FILE OLD NEW --track` or `docx edit FILE --at p0:START-END --text NEW --track`.
  • What it covers: edit --at pN with --text/--markdown/--runs, range edits (pN-pM), --batch (one warning per entry), and code edit. A bare-cell target suggests the valid tN:rRcC:p0:START-END form. --track appears in the suggestions only when the edit itself was tracked.
  • How detection works: watchPendingRevisions (src/core/track-changes/pending-authors.ts) records other authors' <w:ins>/<w:del>/<w:moveFrom>/<w:moveTo>/<w:pPrChange> in the edited region before the rebuild, and reports the ones missing after it. Each rebuild path keeps something different: the --text diff carries text boxes through, while --markdown drops them. So only before/after comparison avoids false alarms and misses.
  • Plumbing: Edit.paragraph now returns { node, resolvedAuthors } and Edit.range returns the authors. The CLI only prints.
  • Unchanged: the editing author's own pending changes don't warn, and span edits (replace, edit --at pN:S-E) don't warn because they keep revisions.

Verification

  • The issue repro now warns naming Reviewer A and Reviewer B; the edit still applies and exits 0.
  • 11 new tests cover:
    • the single edit, batch and range edit paths, and code edit;
    • the bare-cell hint;
    • no warning for the editor's own pending changes;
    • text-box revisions kept by --text (no warning) and dropped by --markdown (warns);
    • a dropped <w:pPrChange>;
    • revisions the edit keeps (no false alarm).
  • bun run check ✅ bun run test:unit ✅ (1724 tests; the pre-commit hook's full bun test passed 1748).
  • /simplify: moved the detection into the Edit lens instead of duplicating the edit-kind checks in two CLI files. /code-review xhigh: replaced a predict-what-survives scan with the before/after comparison, and extended coverage to range edits and code edit.

Decisions for you

  • I left a few things alone; each can be its own issue:
    • --dry-run can't warn, because it exits before the edit runs.
    • The warning isn't in the --verbose JSON confirmation; it's stderr only.
    • A tracked line removal (edit --text "" / docx delete) also drops other authors' insertions, without a warning.
    • edit --markdown on a paragraph anchoring a text box deletes the box. That's an older bug, outside this change.
  • This may conflict with fix(core): tracked span replace inside another author's insertion #15 in src/core/track-changes/CLAUDE.md and tests/cli/edit.test.ts. I'll merge main into whichever lands second.

Refs #17. This keeps #17 open for the real fix: keeping the revisions, e.g. by routing through #15's span engine.

🤖 Generated with Claude Code

https://claude.ai/code/session_012GoxD36rnNfg6uArkVxtJL


Generated by Claude Code

…revisions

A whole-paragraph content edit (`edit --at pN --text/--markdown/--runs`, a
range edit, `--batch`, `code edit`) rebuilds the paragraph under a
single-author model, so another author's pending insertion became plain text
(or was dropped) and their deletion vanished — silently, exit 0. Interim
behavior per maintainer decision on #17: the edit still applies, but the CLI
now warns on stderr naming those authors and pointing at span edits, which
keep the revisions pending. Detection diffs the edited region's revisions
before vs after the rebuild, so it reports only what was actually lost.

Refs #17

Triage-Routine: true
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012GoxD36rnNfg6uArkVxtJL
@kklimuk
kklimuk merged commit 82225b4 into main Oct 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants