You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): headings in localized Word documents reach the agent - #44140
When a .docx saved by localized Word (e.g., German) is attached, its headings reach the agent as plain lines instead of Markdown headings. Localized Word writes localized style ids (berschrift1) in document.xml while keeping built-in English names (heading 1) in word/styles.xml.
Change
For .docx files, apps/server/src/provider/documentTextWorker.ts reads the styles part via the main part's relationships (falling back to styles.xml next to it). It maps paragraph styles named heading 1..heading 6 to their level and rewrites those style ids before reading paragraphs. Without a styles part, existing behavior is kept; non-heading styles stay plain.
Scope
Bug fix for lost data (heading structure dropped) in localized Word .docx files. Small fix for an obvious bug, so no issue is needed.
Verification
Setup: Linux, Node v26.13.1, synthetic bericht.docx shaped like German Word output (not saved by Word; word/styles.xml maps berschrift1/berschrift2 to heading 1/heading 2 and Titel/Standard to Title/Normal).
Steps: build bericht.docx → run node apps/server/src/bin.ts __document-text bericht.docx .docx (the server's document-attachment command) → run focused server tests.
Jahresbericht
# Einleitung
Text.
## Ziele
Mehr Text.
Regression test: the new exact case in apps/server/src/provider/userInputAttachments.test.ts fails on 74707f256ab8 (headings missing # / ##) and passes on 9317b50a034b.
Merged tree: on main (609178f9f4d6), the command still drops headings; merged locally with 9317b50a034b, it prints them and focused tests pass.
Localized Word saves heading paragraphs with a localized style id
("berschrift1", "Titre1") and keeps the built-in English name
("heading 1") in word/styles.xml. Document text only matched the
English id, so every heading of such a document came out as plain
text. Map style ids named "heading 1" to "heading 6" to their level
before reading paragraphs.
Reviewing files that changed from the base of the PR and between 9317b50 and 3c0de9e.
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
For .docx files, extraction now resolves paragraph styles and maps localized heading names to English heading style IDs before extracting paragraphs. A test covers German title and heading styles linked through a separate styles file.
Changes: DOCX heading style extraction
Layer / File(s)
Summary
Resolve and map DOCX heading styles apps/server/src/provider/documentTextWorker.ts, apps/server/src/provider/userInputAttachments.test.ts
The extractor resolves the document’s styles part, maps Heading 1 through Heading 6 names to English style IDs, and updates matching paragraph references before extraction. The test checks extracted text for German title and heading styles.
This change preserves heading structure for localized Word documents attached to the app. The change is narrowly scoped and covered by a focused test, so no concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the server fix for headings in localized Word documents reaching the agent. The raw summary and PR objectives both describe a change that maps localized style IDs for Heading 1 through…
Description check
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the expected behavior and the cause. The Change section explains the styles-part look…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the server fix for headings in localized Word documents reaching the agent. The raw summary and PR objectives both describe a change that maps localized style IDs for Heading 1 through Heading 6 in documentTextWorker.ts, so the title matches the main change. It follows the conventional commit form and is specific enough for a teammate scanning history.
Full details: Description check
Explanation
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the expected behavior and the cause. The Change section explains the styles-part lookup and the ID rewrite. The Scope section links the bug and explains why no issue is needed. The Verification section gives setup, steps, before and after output, and focused test results. The author also states what was not checked. The description does not link a maintainer request, which the template makes conditional, so this gap does not block the check.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Real web app, Chromium, 1280×800, light theme; fresh isolated state on each commit. Enter the reported prompt, attach a synthetic equivalent localized DOCX through the composer, and send. A deterministic ACP reader opens the actual server-extracted file and echoes the eight title lines verbatim. The comparison runner exited 0: base failed and head passed.
The original Word-saved fixture and Codex GPT-6-Luna were replaced by a synthetic equivalent and deterministic reader. The extraction itself runs through the real attachment pipeline.
Not shown:
The original Word-saved iso-template-de.docx was not supplied; the proof uses a synthetic equivalent with the reported titles, localized style IDs and English built-in style names.
Codex GPT-6-Luna behavior was not exercised; a deterministic ACP reader echoed the real server-produced extraction.
Heading levels 4–6 and ordinary-paragraph preservation were not shown in the captured title-only replies.
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
size:S10-29 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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.
Problem
When a
.docxsaved by localized Word (e.g., German) is attached, its headings reach the agent as plain lines instead of Markdown headings. Localized Word writes localized style ids (berschrift1) indocument.xmlwhile keeping built-in English names (heading 1) inword/styles.xml.Change
For
.docxfiles,apps/server/src/provider/documentTextWorker.tsreads the styles part via the main part's relationships (falling back tostyles.xmlnext to it). It maps paragraph styles namedheading 1..heading 6to their level and rewrites those style ids before reading paragraphs. Without a styles part, existing behavior is kept; non-heading styles stay plain.Scope
Bug fix for lost data (heading structure dropped) in localized Word
.docxfiles. Small fix for an obvious bug, so no issue is needed.Verification
Setup: Linux, Node v26.13.1, synthetic
bericht.docxshaped like German Word output (not saved by Word;word/styles.xmlmapsberschrift1/berschrift2toheading 1/heading 2andTitel/StandardtoTitle/Normal).Steps: build
bericht.docx→ runnode apps/server/src/bin.ts __document-text bericht.docx .docx(the server's document-attachment command) → run focused server tests.Base 74707f256ab8:
Head 9317b50a034b:
Regression test: the new
exactcase inapps/server/src/provider/userInputAttachments.test.tsfails on74707f256ab8(headings missing#/##) and passes on9317b50a034b.Merged tree: on
main(609178f9f4d6), the command still drops headings; merged locally with9317b50a034b, it prints them and focused tests pass.Links
apps/server/src/provider/userInputAttachments.test.tsNot shown
basedOn) heading styles are not handled (out of scope).Focused test output
Generated with Gemini 4 Neon in T3 Code Nightly