Skip to content

Commit 18d9b24

Browse files
saphidclaude
andcommitted
fix(server): Word text boxes are no longer extracted twice for agents
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f6503f0 commit 18d9b24

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎apps/server/src/provider/documentTextWorker.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ function xml(source: string, odfSpaces = false, htmlEntities = false): XmlNode {
4747
stack.push(node);
4848
});
4949
parser.on("closetag", () => {
50-
stack.pop();
50+
// Markup-compatibility fallbacks repeat their mc:Choice content, e.g. Word text boxes.
51+
if (stack.pop()!.name === "Fallback") stack.at(-1)!.children.pop();
5152
});
5253
const text = (value: string) => {
5354
stack.at(-1)!.children.push(value);

‎apps/server/src/provider/userInputAttachments.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,16 @@ describe("question answer paths", () => {
554554
expected: ["Start", "[Extracted text truncated at document extraction limits.]"],
555555
absent: ["Unneeded"],
556556
},
557+
{
558+
ext: "docx",
559+
bounded: true,
560+
parts: {
561+
"word/document.xml":
562+
'<w:document xmlns:w="urn:w" xmlns:mc="urn:mc"><w:body><w:p><w:r><w:t>Body</w:t></w:r></w:p><w:p><w:r><mc:AlternateContent><mc:Choice Requires="wps"><w:drawing><wps:wsp><wps:txbx><w:txbxContent><w:p><w:r><w:t>Callout box</w:t></w:r></w:p></w:txbxContent></wps:txbx></wps:wsp></w:drawing></mc:Choice><mc:Fallback><w:pict><v:shape><v:textbox><w:txbxContent><w:p><w:r><w:t>Callout box</w:t></w:r></w:p></w:txbxContent></v:textbox></v:shape></w:pict></mc:Fallback></mc:AlternateContent></w:r></w:p></w:body></w:document>',
563+
},
564+
expected: ["Body\nCallout box"],
565+
occurrences: { text: "Callout box", count: 1 },
566+
},
557567
{
558568
ext: "docx",
559569
bounded: true,

0 commit comments

Comments
 (0)