Skip to content

fix(read): hide a revision nested inside a hidden one in the accepted/baseline views - #19

Merged
kklimuk merged 1 commit into
mainfrom
claude/triage-nested-revision-views
Oct 8, 2026
Merged

kklimuk merged 1 commit into
mainfrom
claude/triage-nested-revision-views

Conversation

@kklimuk

@kklimuk kklimuk commented Oct 8, 2026

Copy link
Copy Markdown
Owner

🤖 docx-cli triage

What was wrong

The reader decided whether a run is visible in --accepted/--baseline from its innermost tracked-change wrapper only. A deletion nested inside another author's insertion therefore showed its text in read --baseline, even though rejecting every change removes it:

$ docx read doc.docx --baseline      # Editor's <w:del> nested in Reviewer A's <w:ins>
The Client disputed amount           # wrong — should be "The Client "

What changed

  • One rule, one place: a run is visible in a view only if every enclosing tracked change is visible in that view (isRevisionVisible in src/core/track-changes/revision-visibility.ts). Accepted hides deletions/move-sources, baseline hides insertions/move-targets, current shows all.
  • The reader records the enclosing chain on nested changes only (TrackedChange.within, optional; the run's own kind/id stays the innermost wrapper). read --ast is unchanged for documents without nested tracked changes.
  • All view consumers use the predicate: read (markdown), find, wc, iterateBlocks({ view }). track-changes list output shape is unchanged. Schema widened for within.
  • Replace/edit engines and accept/reject machinery are untouched.

Verification

  • Now read --baseline ≡ track-changes reject --all and read --accepted ≡ accept --all on: a deletion nested in another author's insertion, a third author's deletion nested in an insertion, and an insertion nested in a deletion. Tests assert all six equivalences plus wc counts and find --baseline no longer matching nested-deleted text.
  • Golden comparison vs main: read (all views, --ast), wc (all views) and find (all views) over all 36 fixtures — 540 commands, 0 differences.
  • bun run check ✅ bun run test:unit ✅ (1736 tests, +12 new, no existing expectation changed).
  • Independent /code-review xhigh of the full diff: no regressions against main. Pre-existing gaps it noted, left alone on purpose (each would change read output for existing fixtures or is outside this change): the markdown renderer still prints a <w:br/>/<w:tab/> inside a hidden wrapper; tracked-deleted table rows are hidden by read but not by find/wc; equations and note references ignore views; revN grouping is nesting-blind (fixed separately in the replace --track inside another author's pending insertion credits the new text to that author, and misses the target next to a nested deletion #13 PR).

Decisions for you

  • None required. If you want the pre-existing markdown break/tab gap fixed, say so and I'll file it as an issue.

Part of the fix for #13 (the minimal #13 PR handles the write side; this handles the read side).

🤖 Generated with Claude Code

https://claude.ai/code/session_012GoxD36rnNfg6uArkVxtJL


Generated by Claude Code

…/baseline views

A run was classified by its innermost revision wrapper only, so an
Editor's <w:del> nested inside Reviewer A's still-pending <w:ins> showed
its text in `read --baseline` (and `wc`/`find --baseline`), although
`track-changes reject --all` removes the whole insertion with it.

A run is now visible in a view iff EVERY enclosing wrapper is visible in
that view (accepted hides del/moveFrom, baseline hides ins/moveTo,
current shows all). The reader keeps `trackedChange` as the innermost
wrapper and records the enclosing chain in the new optional
`TrackedChange.within` (absent on top-level wrappers, so an un-nested
document's AST is unchanged); one shared predicate, `isRevisionVisible`
in core/track-changes/revision-visibility.ts, is read by
paragraphTextAccepted/Baseline (so `wc` follows), find's per-view run
text, iterateBlocks({ view }) and the markdown renderer.
`track-changes list` keeps its record shape (no `within`).

Golden comparison against origin/main over every tests/fixtures/*.docx
(read in all views + --ast, wc and find in all views): 540 commands,
0 diffs. New tests cover del-in-ins (two authors), ins-in-del, and a
<w:br/> inside the nested deletion: `read --baseline` ≡ `reject --all`,
`read --accepted` ≡ `accept --all`, same for `wc`, and `find --baseline`
no longer matches the nested-deleted text.

Triage-Routine: true
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012GoxD36rnNfg6uArkVxtJL
@kklimuk
kklimuk merged commit 16d0ada 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