Skip to content

fix(server): paragraphs and headings start on a new line after inline text in EPUB and DOCX documents - #43411

Open
saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-55a9341411
Open

saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-55a9341411

Conversation

@saphid

@saphid saphid commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Problem

EPUB paragraphs and headings after inline text run into the preceding words. DOCX text-box paragraphs have the same problem, so agents read IntroBody paragraph or BeforeBox text instead of separate paragraphs.

Deterministic repro on origin/main (0df79074ad5f21478b616fe812746c0896ec90d7): after vp i, run the copyable Python ZIP fixture builder and Node extractDocumentText() command in the runtime transcript. The EPUB chapter body is <div>Intro<p>Body paragraph</p></div>, <ul><li>Summary<p>Details</p></li></ul>, <div>Intro<h2>Section Title</h2></div>, or <table><tr><td>First<p>Second</p></td></tr></table>. The DOCX fixture contains Before, an inline w:txbxContent paragraph containing Box text, then After in the enclosing paragraph.

Observed → expected (JSON string notation):

  • "IntroBody paragraph" → "Intro\nBody paragraph"
  • "SummaryDetails" → "Summary\nDetails"
  • "Intro## Section Title" → "Intro\n## Section Title"
  • "FirstSecond" → "First Second" inside a table cell
  • "BeforeBox text\nAfter" → "Before\nBox text\nAfter"

The committed archive regression can also be run with vp test run apps/server/src/provider/userInputAttachments.test.ts -t "preserves office structure and EPUB reading order with bounded archives"; applying only its test diff to base reproduces the failing assertion.

Change

Emit the existing deferred paragraph boundary before paragraph/heading text and its heading prefix. The common server extractor handles EPUB and DOCX attachments for every client and provider; table cells keep their existing whitespace normalization. Extend the existing archive fixture table and correct its DOCX text-box heading expectation.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • The regression fails on unmodified base with IntroBody paragraph where Intro\nBody paragraph is expected.
  • Three consecutive full runs of vp test run apps/server/src/provider/userInputAttachments.test.ts: 61/61 tests pass each time.
  • vp run check:changed: exit 0.
  • Before/after runtime transcript and copyable reproducer show all five cases through the real extractor.
  • Not shown: full app attachment upload, real office-generated files, web/desktop/mobile UI interaction, or a live provider turn. No client, contract, translation, provider-adapter, or connection-mode changes are required for this shared server parser fix.

Authored by GPT-6.1 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5610f64 and f77cb84.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The paragraph worker now emits a thematic-break marker before each paragraph or heading. Archive extraction tests add EPUB and DOCX fixtures that check text order, including a newline before a DOCX text-box heading.

Changes: Document text extraction

Layer / File(s) Summary
Paragraph boundaries and archive extraction coverage
apps/server/src/provider/documentTextWorker.ts, apps/server/src/provider/userInputAttachments.test.ts
The paragraph worker emits a thematic-break marker before each paragraph or heading. EPUB tests cover nested paragraphs, lists, a heading, and table cells. DOCX tests check text-box content order and require a newline before the text-box heading.

Estimated code review effort: 2 (Simple) | ~7 minutes

Change: Bug fix

Suggested reviewers: only21mil, lucenx9

Merge Risk: Minimal · previous review 5610f

This change makes paragraphs and headings start on a new line after inline text in EPUB and DOCX attachments. It is a small, localized extraction fix with regression tests, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: EPUB and DOCX paragraphs and headings now start on a new line after inline text. It matches the raw summary (a thematic-break marker before each paragraph or heading) …
Description check Passed The description covers the problem, a reproduction, the change, scope, and verification. It follows the template sections: Problem, Change, Scope, and Verification. It gives observed and expected outp…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: EPUB and DOCX paragraphs and headings now start on a new line after inline text. It matches the raw summary (a thematic-break marker before each paragraph or heading) and the PR objectives. It follows the conventional commit format and is specific.

Full details: Description check

Explanation

The description covers the problem, a reproduction, the change, scope, and verification. It follows the template sections: Problem, Change, Scope, and Verification. It gives observed and expected outputs for five cases, names the regression test, and states what was not checked. The template's optional agent-attribution line is present. The description is detailed and matches the objectives, though it relies on an external gist for the runtime transcript.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 147028a and 5610f64.

Files selected for processing: 2

  • apps/server/src/provider/documentTextWorker.ts
  • apps/server/src/provider/userInputAttachments.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). takeover:in-progress A takeover lead is working on this PR vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants