From 47acf5645d872cfcb154e7a754e5f80d73d28506 Mon Sep 17 00:00:00 2001 From: Michel Liao Date: Sat, 21 Nov 2026 14:03:35 -0500 Subject: [PATCH] fix(server): Word table cells wrapped in a content control reach the agent Word nests a table cell inside `w:sdt` when a content control wraps the whole cell, as form fields, checkbox columns and title cells bound to a document property do. The document text extractor only took a row's direct `w:tc` children, so those cells were dropped: a form lost its field column, and a document whose only text sat in such cells failed with "No text extracted". Cells are now collected the same way rows already are, through any wrapper between the row and the cell. A table nested inside a cell is unaffected because the search stops at each cell. Claude Fable 5.2 in Claude Code, running in T3 Code. Co-Authored-By: Claude Fable 5.2 --- apps/server/src/provider/documentTextWorker.ts | 5 ++--- apps/server/src/provider/userInputAttachments.test.ts | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/provider/documentTextWorker.ts b/apps/server/src/provider/documentTextWorker.ts index 9cec14dadd67e..4cd3963034ffb 100644 --- a/apps/server/src/provider/documentTextWorker.ts +++ b/apps/server/src/provider/documentTextWorker.ts @@ -256,9 +256,8 @@ function hasCellText(cell: XmlNode): boolean { function* table(node: XmlNode): Generator { let rowCount = 0; for (const row of all(node, ["tr", "table-row"])) { - const cells = children(row).filter((cell) => - ["tc", "table-cell", "covered-table-cell", "td", "th"].includes(cell.name), - ); + // Word nests a cell inside w:sdt when a content control wraps the whole cell. + const cells = [...all(row, ["tc", "table-cell", "covered-table-cell", "td", "th"])]; // ODS writers pad sheets with repeated empty rows and trailing cells. while (cells.length && !hasCellText(cells.at(-1)!)) cells.pop(); if (!cells.length) continue; diff --git a/apps/server/src/provider/userInputAttachments.test.ts b/apps/server/src/provider/userInputAttachments.test.ts index 7bf24acb0b40a..9babc35d7066a 100644 --- a/apps/server/src/provider/userInputAttachments.test.ts +++ b/apps/server/src/provider/userInputAttachments.test.ts @@ -775,11 +775,12 @@ describe("question answer paths", () => { bounded: true, parts: { "word/document.xml": - 'Report & totalsNorth1234BeforeInnerAfterNeighbor', + 'Report & totalsNorth1234Annual reportDraftBeforeInnerAfterNeighbor', }, expected: [ "## Report & totals", "North\t12 34", + "Annual report\tDraft", "Before Inner After\tNeighbor\t\u2011\n\u2011", ], },