Skip to content

fix(converter): preserve CommentReference rStyle on comment anchor runs (SD-2910)#3252

Open
tupizz wants to merge 1 commit into
mainfrom
tadeu/sd-2910-bug-preserve-commentreference-run-style-on-comment-anchors
Open

fix(converter): preserve CommentReference rStyle on comment anchor runs (SD-2910)#3252
tupizz wants to merge 1 commit into
mainfrom
tadeu/sd-2910-bug-preserve-commentreference-run-style-on-comment-anchors

Conversation

@tupizz
Copy link
Copy Markdown
Contributor

@tupizz tupizz commented May 12, 2026

Summary

  • The exporter synthesized a fresh <w:r> for the inline <w:commentReference/> marker after each commentRangeEnd but emitted no w:rPr, dropping Word's <w:rStyle w:val="CommentReference"/> on round-trip (11 → 0 on the customer fixture).
  • The importer cannot carry the source w:rPr through (the commentReference element is consumed by comments-list import), so we synthesize the canonical rStyle on export.
  • Touched files: comment-range-translator.{js,test.js}. +22 / −9.

Linear

  • SD-2910 — Athenaintelligence (Enterprise tier)
  • SLA breached 2026-05-08; closes the regression for commented documents.

Why this fix and not "preserve the source value"

CommentReference is the canonical Word style name for comment-anchor runs and is universally defined in any DOCX that contains comments. The customer's repro and Word's default output both use this literal. Preserving an arbitrary rStyle value across import would require new plumbing for what is a single fixed string in practice — out of scope for this bug. If a future ticket reports a non-CommentReference value being dropped, that's a separate fix at the import boundary.

Test plan

  • Failing unit test added at the same commit (TDD red): both existing assertions in decode:commentRangeEndTranslator and does NOT wrap range markers when trackDelete mark is present now require the rStyle structure
  • pnpm --filter super-editor test -- --run comment-range-translator — 2 failures pre-fix, 0 failures post-fix
  • Full super-editor suite: 12,719 passed, 13 skipped, 0 failed
  • Manual round-trip with customer fixture (input.docx from the ticket) — verify grep -c '<w:rStyle w:val="CommentReference"/>' word/document.xml returns 11 on the export

Notes

  • commentRangeStart is unaffected — Word never synthesizes an anchor run there.
  • Tracked-change wrappers (<w:ins>/<w:del>) inherit the new child structure automatically; the SD-1519 bare-marker behavior for marked range nodes is preserved.
  • ECMA-376 §17.3.2 requires w:rPr to be the first child of w:r — the change respects ordering.

…ns (SD-2910)

The exporter synthesizes a fresh <w:r> to carry the inline <w:commentReference/>
marker after each commentRangeEnd, but emitted no run properties. Word marks
these anchor runs with <w:rPr><w:rStyle w:val="CommentReference"/></w:rPr>, so
round-tripping a commented DOCX dropped the rStyle reference (11 -> 0 on the
reported fixture). The importer cannot carry the source w:rPr through (the
commentReference element is consumed by comments-list import), so emit the
canonical rStyle when synthesizing the anchor run.

Updates the two existing assertions that pinned the old shape (plain and
trackDelete-marked variants) to match the corrected output.
@tupizz tupizz requested a review from a team as a code owner May 12, 2026 18:41
@linear
Copy link
Copy Markdown

linear Bot commented May 12, 2026

SD-2910

@tupizz tupizz self-assigned this May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The MCP permission prompts kept blocking, but the change is straightforward to verify against well-known OOXML structure.

Status: PASS

The PR adds the canonical w:rPrw:rStyle w:val="CommentReference" wrapper to the synthesized comment-anchor run. All four schema points check out:

  • w:r (CT_R) takes an optional w:rPr as its first child, followed by run-content elements — the new ordering puts w:rPr before w:commentReference, which is correct (run properties must precede run content per w:r).
  • w:rPr (CT_RPr) lists w:rStyle as its first allowed child (w:rPr).
  • w:rStyle carries a required w:val of ST_String referencing a style ID (w:rStyle).
  • w:commentReference is part of EG_RunInnerContent, so it's a legal child of w:r (w:commentReference).

CommentReference is the conventional styleId Word emits for comment-anchor runs (matching the built-in w:style w:styleId="CommentReference" definition). No fabricated attributes, no missing required attributes, child ordering is valid.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants