feat(docx-core): sweep side-part revisions on accept/reject#218
Open
stevenobiajulu wants to merge 2 commits into
Open
feat(docx-core): sweep side-part revisions on accept/reject#218stevenobiajulu wants to merge 2 commits into
stevenobiajulu wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Peer review of PR #218 flagged that rejecting an addFootnote(..., ctx) removed the body w:footnoteReference but left the <w:footnote w:id=N> shell in word/footnotes.xml — and the symmetric case (acceptChanges over a tracked-deleted footnote) leaked the same shell. The reject path was therefore not really restoring pre-edit state. Add a post-sweep orphan prune in DocxDocument.acceptChanges / rejectChanges that drops non-reserved <w:footnote> entries whose ID is no longer referenced from the body. Reserved separator / continuationSeparator entries are preserved. Only runs when the body sweep actually removed a deletion (accept) or insertion (reject), so documents with pre-existing orphans and no revisions are untouched. Adds four BDD tests: addFootnote+reject, deleteFootnote+accept, deleteFootnote+reject (round-trip restoration), and updateFootnoteText +accept (replacement-wins case). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #165.
accept_changesnow resolves tracked-change markup indocument.xmlplus supported side-story parts:word/footnotes.xml,word/endnotes.xml, andword/comments.xml. The low-level accept/reject DOM primitives also work against story-root XML, andDocxDocumentexposes symmetric package-level accept and reject sweeps.Implementation
acceptChanges(doc)/rejectChanges(doc)to usew:bodywhen present, otherwise the document element as a story root.DocxDocument.acceptChanges()async so it can read and rewrite optional side parts from the DOCX ZIP.DocxDocument.rejectChanges()with the same package sweep behavior.accept_changestool to await the async document facade.footnotesXmlcache in sync after footnote-story accept/reject.SUPPORT.mdto classify comment replies as Table B package-level metadata and to document side-part accept/reject behavior.Verification
npm -w @usejunior/docx-core run test:run -- test-primitives/document.test.ts test-primitives/accept_changes.test.ts test-primitives/reject_changes.test.ts— 23 passednpm -w @usejunior/docx-mcp run test:run -- src/tools/add_accept_tracked_changes.test.ts— 12 passednpm -w @usejunior/docx-core run lintnpm -w @usejunior/docx-mcp run lintnpm -w @usejunior/docx-core run buildnpm -w @usejunior/docx-mcp run buildgit diff --checknpm run lint:allure-imports— passed with one pre-existing warning inpackages/docx-mcp/src/cli/commands/edit.test.ts:133Notes
This PR keeps revision-ID uniqueness separate from the side-part accept/reject sweep. That prerequisite is covered in draft PR #216 for #171.