@devries-cameron20 / t3code Mirror · read-only / commits / 5842231421
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 08:30 UTC

fix(server): DOCX text for agents no longer includes object position numbers (#38116)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Fuksss committed Nov 17, 2026 at 14:32 UTC 5842231421d0058f1ca7e829a66f648cb472aff1
2 files changed +39 -2
apps/server/src/provider/documentTextWorker.ts
+8 -2
@@ -15,7 +15,8 @@ type TextPart = string | typeof CELL_START | typeof CELL_END | { fallback: strin
15
16 const TRUNCATED = "\n\n[Extracted text truncated at document extraction limits.]";
17 // Parts the document never displays: the XHTML head, tracked deletions and moves, field codes,
18 -// phonetic guides, paragraph properties such as tab-stop definitions.
18 +// phonetic guides, paragraph properties such as tab-stop definitions, drawing anchor layout
19 +// values and encoded field data.
20 const HIDDEN = new Set([
21 "head",
22 "script",
@@ -28,6 +29,11 @@ const HIDDEN = new Set([
29 "delInstrText",
30 "tracked-changes",
31 "pPr",
32 + "positionH",
33 + "positionV",
34 + "sizeRelH",
35 + "sizeRelV",
36 + "fldData",
37 ]);
38
39 // @effect-diagnostics-next-line extendsNativeError:off - this worker loads no Effect runtime; Truncation is a local throw sentinel.
@@ -109,7 +115,7 @@ function xml(source: string, extension: string): XmlNode {
115 parent.children.pop();
116 return;
117 }
112 - if (!node.hasText && node.name !== "noBreakHyphen") return;
118 + if (HIDDEN.has(node.name) || (!node.hasText && node.name !== "noBreakHyphen")) return;
119 parent.hasText = true;
120 if (node.name === "Choice") parent.hasTextChoice = true;
121 });
apps/server/src/provider/userInputAttachments.test.ts
+31
@@ -483,6 +483,37 @@ describe("question answer paths", () => {
483 Effect.gen(function* () {
484 const config = yield* ServerConfig.ServerConfig;
485 const cases = [
486 + // Word stores object layout and field data outside the visible document text.
487 + {
488 + ext: "docx",
489 + bounded: true,
490 + parts: {
491 + "word/document.xml":
492 + '<w:document xmlns:w="urn:w" xmlns:wp="urn:wp" xmlns:wp14="urn:wp14" xmlns:mc="urn:mc"><w:body><w:p><w:r><w:t>Total cost is </w:t><w:drawing><wp:anchor><wp:positionH><wp:posOffset>1905000</wp:posOffset></wp:positionH><wp:positionV><wp:posOffset>-635</wp:posOffset></wp:positionV><wp14:sizeRelH><wp14:pctWidth>0</wp14:pctWidth></wp14:sizeRelH><wp14:sizeRelV><wp14:pctHeight>0</wp14:pctHeight></wp14:sizeRelV></wp:anchor></w:drawing><w:t>42 EUR.</w:t></w:r></w:p></w:body></w:document>',
493 + },
494 + expected: ["Total cost is 42 EUR."],
495 + absent: ["1905000", "-635", "0042"],
496 + },
497 + {
498 + ext: "docx",
499 + bounded: true,
500 + parts: {
501 + "word/document.xml":
502 + '<w:document xmlns:w="urn:w" xmlns:wp="urn:wp" xmlns:wp14="urn:wp14" xmlns:mc="urn:mc"><w:body><w:p><mc:AlternateContent><mc:Choice Requires="cx"><w:drawing><wp:anchor><wp:positionH><wp:posOffset>1905000</wp:posOffset></wp:positionH><wp:positionV><wp:posOffset>-635</wp:posOffset></wp:positionV><wp14:sizeRelH><wp14:pctWidth>0</wp14:pctWidth></wp14:sizeRelH><wp14:sizeRelV><wp14:pctHeight>0</wp14:pctHeight></wp14:sizeRelV></wp:anchor></w:drawing><cx:chart/></mc:Choice><mc:Fallback><w:pict><v:shape><v:textbox><w:txbxContent><w:p><w:r><w:t>Chart caption</w:t></w:r></w:p></w:txbxContent></v:textbox></v:shape></w:pict></mc:Fallback></mc:AlternateContent></w:p></w:body></w:document>',
503 + },
504 + expected: ["Chart caption"],
505 + absent: ["1905000", "-635"],
506 + },
507 + {
508 + ext: "docx",
509 + bounded: true,
510 + parts: {
511 + "word/document.xml":
512 + '<w:document xmlns:w="urn:w" xmlns:wp="urn:wp" xmlns:wp14="urn:wp14" xmlns:mc="urn:mc"><w:body><w:p><w:r><w:t>As shown </w:t><w:fldChar><w:fldData>RU5ETk9URQ==</w:fldData></w:fldChar><w:t>(Smith 2020) earlier.</w:t></w:r></w:p></w:body></w:document>',
513 + },
514 + expected: ["As shown (Smith 2020) earlier."],
515 + absent: ["RU5ETk9URQ=="],
516 + },
517 {
518 ext: "docx",
519 bounded: true,