Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): read a number in a right-to-left DOCX table right to left
marcoteb1b544d77e5f1
diff --git a/mcp-host/src/workflow/__tests__/internalTools.docxText.test.ts b/mcp-host/src/workflow/__tests__/internalTools.docxText.test.tsindex 08a177c54..7ae55ab6a 100644--- a/mcp-host/src/workflow/__tests__/internalTools.docxText.test.ts+++ b/mcp-host/src/workflow/__tests__/internalTools.docxText.test.ts@@ -179,7 +179,15 @@ describe('generate_docx right-to-left text', () => {'| المنطقة | الإيرادات |\n|---|---|\n| الرياض | 1,200 |',})const paragraphs = bodyParagraphs(xml)- for (const text of ['عنوان التقرير', 'البند الأول', 'פריט ראשון', 'اقتباس', 'الرياض']) {+ // A number in a right-to-left table takes the table's direction.+ for (const text of [+ 'عنوان التقرير',+ 'البند الأول',+ 'פריט ראשון',+ 'اقتباس',+ 'الرياض',+ '1,200',+ ]) {const p = paragraphs.find(x => paragraphText(x) === text)expect(p, text).toBeDefined()expect(p, text).toContain('<w:bidi/>')diff --git a/mcp-host/src/workflow/docxTable.ts b/mcp-host/src/workflow/docxTable.tsindex 385063d8d..8880d662b 100644--- a/mcp-host/src/workflow/docxTable.ts+++ b/mcp-host/src/workflow/docxTable.ts@@ -283,6 +283,10 @@ export function buildDocxTable(}const size = fit.size * 2const { side, widths } = fit+ const rtlTable = isRtlText(head.join(' '))+ // A cell with no letter, such as a number, reads in the table's direction.+ const cellDirection = (text: string): { bidirectional?: true } =>+ /\p{L}/u.test(text) ? docxDirection(text) : rtlTable ? { bidirectional: true } : {}const headerRow = new TableRow({tableHeader: true,@@ -293,7 +297,7 @@ export function buildDocxTable(shading: { type: ShadingType.CLEAR, fill: docxHex(palette.primary), color: 'auto' },children: [new Paragraph({- ...docxDirection(h),+ ...cellDirection(h),children: inlineRuns(h, { color: 'FFFFFF', bold: true, size }, warnings),}),],@@ -312,7 +316,7 @@ export function buildDocxTable(...(fill ? { shading: { type: ShadingType.CLEAR, fill, color: 'auto' } } : {}),children: [new Paragraph({- ...docxDirection(cell),+ ...cellDirection(cell),children: inlineRuns(cell, { color: docxHex(palette.text), size }, warnings),}),],@@ -326,7 +330,7 @@ export function buildDocxTable(width: { size: sum(widths), type: WidthType.DXA },columnWidths: widths,...(fit.fixed ? { layout: TableLayoutType.FIXED } : {}),- ...(isRtlText(head.join(' ')) ? { visuallyRightToLeft: true } : {}),+ ...(rtlTable ? { visuallyRightToLeft: true } : {}),rows: [headerRow, ...bodyRows],borders: borders(layout, palette),})