From cd20593375d10eacd664f84520cca04b9670f7f5 Mon Sep 17 00:00:00 2001 From: Michel Liao Date: Sat, 21 Nov 2026 14:55:06 -0500 Subject: [PATCH] fix(server): ODT attachments no longer repeat index titles or template separators An OpenDocument index (table of contents, bibliography, table of figures and the other four kinds) is stored as two parts: the source it is generated from, then the generated body. The attachment text extractor emitted the text of both, so the agent read a LibreOffice table of contents as "Table of ContentsTable of Contents" and a bibliography after a run of the separators from its entry templates (": , , : , ,"). The seven index source elements are now skipped; the index body, which holds the title and the entries, is extracted as before. Claude Fable 5.2 in Claude Code, running in T3 Code. Co-Authored-By: Claude Fable 5.2 --- .../server/src/provider/documentTextWorker.ts | 8 ++++++++ .../src/provider/userInputAttachments.test.ts | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/server/src/provider/documentTextWorker.ts b/apps/server/src/provider/documentTextWorker.ts index 8509b490ccee..1e9e8e86b57c 100644 --- a/apps/server/src/provider/documentTextWorker.ts +++ b/apps/server/src/provider/documentTextWorker.ts @@ -34,6 +34,14 @@ const HIDDEN = new Set([ "sizeRelH", "sizeRelV", "fldData", + // An OpenDocument index keeps its templates beside the generated index; only the latter is content. + "table-of-content-source", + "illustration-index-source", + "table-index-source", + "object-index-source", + "user-index-source", + "alphabetical-index-source", + "bibliography-source", ]); // @effect-diagnostics-next-line extendsNativeError:off - this worker loads no Effect runtime; Truncation is a local throw sentinel. diff --git a/apps/server/src/provider/userInputAttachments.test.ts b/apps/server/src/provider/userInputAttachments.test.ts index 556351b225ba..3dde0927fbd7 100644 --- a/apps/server/src/provider/userInputAttachments.test.ts +++ b/apps/server/src/provider/userInputAttachments.test.ts @@ -1048,10 +1048,25 @@ describe("question answer paths", () => { ext: "odt", parts: { "content.xml": - '\n Orchard\n19violetcrates \n\t shipped todayDockGate\u00a0B SecondAconsole.log(1);\n B', + '\n Orchard\n19violetcrates \n\t shipped todayDockGate\u00a0B SecondAconsole.log(1);\n B' + + [ + "table-of-content", + "illustration-index", + "table-index", + "object-index", + "user-index", + "alphabetical-index", + "bibliography", + ] + .map( + (name) => + `Contents: ContentsOrchard 1`, + ) + .join("") + + "", }, expected: [ - "## Orchard\n19 violet crates shipped today\tDock\nGate\u00a0B\nSecond\nA B", + `## Orchard\n19 violet crates shipped today\tDock\nGate\u00a0B\nSecond\nA B${"\nContents\nOrchard 1".repeat(7)}`, ], }, {