Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): say when a dashboard table drops an extra object or list cell
marcoteb0c52611ff2dd
diff --git a/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts b/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.tsindex 8f3ea7f5a..e8cfff3aa 100644--- a/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts+++ b/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts@@ -143,6 +143,62 @@ describe('tables', () => {expect(notes).not.toContain('rows[2]')})+ it.each([+ ['an object', { hidden: 1 }],+ ['a list', [1, 2]],+ ['an empty object', {}],+ ['an empty list', []],+ ['text', 'tail'],+ ['zero', 0],+ ['false', false],+ ])('says it left out an extra cell holding %s', async (_what, extra) => {+ const { html, notes } = await render({+ data: { title: 'T', tables: [{ headers: ['A'], rows: [['keep', extra]] }] },+ })+ expect(html.match(/<td>.*?<\/td>/g)).toEqual(['<td>keep</td>'])+ expect(notes).toContain(+ 'data.tables[0].rows[0] has 2 cells for 1 headers; the extra 1 was left out. Add headers for them or drop them.'+ )+ })++ it('cuts blank extra cells without a note and counts every row that lost a value', async () => {+ const quiet = await render({+ data: { title: 'T', tables: [{ headers: ['A'], rows: [['keep', '', ' ', null]] }] },+ })+ expect(quiet.html.match(/<td>.*?<\/td>/g)).toEqual(['<td>keep</td>'])+ expect(quiet.notes).not.toContain('left out')++ const { notes } = await render({+ data: {+ title: 'T',+ tables: [+ {+ headers: ['A'],+ rows: [+ ['a', { k: 1 }],+ ['b', ''],+ ['c', ['x']],+ ],+ },+ ],+ },+ })+ expect(notes).toContain(+ 'data.tables[0].rows[0] has 2 cells for 1 headers; the extra 1 was left out. ' ++ '1 more row(s) had extra cells too.'+ )+ })++ it('still shows a structured cell that has a header, as text with a note', async () => {+ const { html, notes } = await render({+ data: { title: 'T', tables: [{ headers: ['A', 'B'], rows: [[{ k: 1 }, [1, 2]]] }] },+ })+ expect(html).toContain('<td>{"k":1}</td>')+ expect(html).toContain('<td>1, 2</td>')+ expect(notes).toContain('data.tables[0]: 2 cell(s) held an object or a list and are shown')+ expect(notes).not.toContain('left out')+ })+it('lets a wide table scroll on screen and fit the page in print', async () => {const { html } = await render({ data: { title: 'T', kpis: [{ label: 'x', value: 1 }] } })expect(html).toMatch(/\.data-table-wrap \{[^}]*overflow-x: auto/)diff --git a/mcp-host/src/workflow/dashboardRender.ts b/mcp-host/src/workflow/dashboardRender.tsindex 95900501a..e4c4c5953 100644--- a/mcp-host/src/workflow/dashboardRender.ts+++ b/mcp-host/src/workflow/dashboardRender.ts@@ -1133,6 +1133,11 @@ function softBreaks(html: string): string {})}+/** Whether a cell holds a value: anything but blank text, null or nothing, an object or list included. */+function holdsValue(cell: unknown): boolean {+ return (cell !== null && typeof cell === 'object') || dashText(cell).trim() !== ''+}+/** Each row cut or padded to one cell per header, reporting cells that held a value and were cut. */function fitRowsToHeaders(rows: unknown[][],@@ -1147,7 +1152,7 @@ function fitRowsToHeaders(padded++return [...row, ...Array<string>(width - row.length).fill('')]}- if (row.slice(width).some(cell => dashText(cell).trim() !== '')) {+ if (row.slice(width).some(holdsValue)) {cut.push(`${where}.rows[${r}] has ${row.length} cells for ${width} headers; the extra ` +`${row.length - width} ${row.length - width === 1 ? 'was' : 'were'} left out.`