Skip to content

fix(docx): preserve manual line breaks - #186

Open
dipeshbabu wants to merge 6 commits into
openai:mainfrom
dipeshbabu:agent/preserve-docx-line-breaks
Open

fix(docx): preserve manual line breaks#186
dipeshbabu wants to merge 6 commits into
openai:mainfrom
dipeshbabu:agent/preserve-docx-line-breaks

Conversation

@dipeshbabu

Copy link
Copy Markdown
Contributor

Summary

  • preserve DOCX manual line breaks while extracting knowledge-base text
  • extend the existing DOCX fixture with adjacent text separated by <w:br/>

Root cause

The DOCX extractor handled paragraph endings and tabs before stripping XML tags, but it did not handle WordprocessingML break elements. The generic tag removal therefore deleted <w:br/> without inserting whitespace and concatenated text from either side.

Impact

Prepared DOCX knowledge bases retain word boundaries and line structure around manual breaks, improving the text supplied to scans.

Overlap check

Searched open issues and pull requests for DOCX line breaks, manual knowledge-base breaks, and w:br; no overlapping work was found.

Validation

  • pnpm dlx bun test --timeout 30000 ./tests-ts/knowledge-base.test.ts (5 passed, 2 platform skips)
  • pnpm exec tsc --noEmit
  • pnpm exec prettier --check src/knowledge-base.ts tests-ts/knowledge-base.test.ts
  • git diff --check

@dipeshbabu
dipeshbabu force-pushed the agent/preserve-docx-line-breaks branch from 138e3b0 to 51f5909 Compare August 1, 2026 12:14
@mldangelo-oai mldangelo-oai added the bug Something isn't working label Aug 3, 2026
@mldangelo-oai mldangelo-oai changed the title Preserve DOCX manual line breaks fix(docx): preserve manual line breaks Aug 3, 2026
@mldangelo-oai

Copy link
Copy Markdown
Collaborator

Related DOCX parser change: #123 addresses malformed numeric XML references that can abort the knowledge-base load (issue #40), while this PR preserves manual line breaks. Both touch the same parser and tests but solve different defects, so they should be coordinated or rebased together rather than labeled duplicate.

@dipeshbabu
dipeshbabu force-pushed the agent/preserve-docx-line-breaks branch from 3fe6cf9 to c7d6b92 Compare August 3, 2026 03:23
@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review exact head effea4a

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: effea4accb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/src/knowledge-base.ts Outdated
return decodeXml(
xml
.replace(/<\/(?:\w+:)?p\s*>/gu, "\n")
.replace(/<(?:\w+:)?br\b[^>]*>/gu, "\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve w:cr carriage-return breaks

When a DOCX represents a manual text-wrapping break as the valid WordprocessingML element <w:cr/>, this replacement does not recognize it, and the later generic tag removal still turns <w:t>foo</w:t><w:cr/><w:t>bar</w:t> into foobar. Handle w:cr alongside w:br so these documents do not continue concatenating text across manual line breaks.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: effea4accb

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants