Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): group a dashboard KPI figure unless it could be a year

marcoteb3c5fc3617a05
diff --git a/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts b/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts
index 1ce4577f6..2540eda34 100644
--- a/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts
+++ b/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts
@@ -201,6 +201,16 @@ describe('KPI figures', () => {
expect(html).toContain(`<p class="kpi-card__value">${shown}</p>`)
})
+ it.each([
+ ['Fiscal year', 2026, '2026'],
+ ['Revenue per year', 1250000, '1,250,000'],
+ ['Ingresos del año', 48210, '48,210'],
+ ['Margin this year', 0.1 + 0.2, '0.3'],
+ ])('leaves only a year-like figure ungrouped under the label %s', async (label, value, shown) => {
+ const { html } = await render({ data: { title: 'T', kpis: [{ label, value }] } })
+ expect(html).toContain(`<p class="kpi-card__value">${shown}</p>`)
+ })
+
it('signs a numeric delta and points its arrow the same way', async () => {
const { html } = await render({
data: {
diff --git a/mcp-host/src/workflow/internalTools.ts b/mcp-host/src/workflow/internalTools.ts
index a2ba60285..bd7e5c284 100644
--- a/mcp-host/src/workflow/internalTools.ts
+++ b/mcp-host/src/workflow/internalTools.ts
@@ -4342,8 +4342,14 @@ function renderKpis(items: unknown, where: string, ctx: DashRender, title?: stri
where,
(item, at) => {
const kpi = dashRecord(item, at, 'a KPI object {label, value}')
- // A year is not grouped: 2026, not 2,026.
- const year = typeof kpi.value === 'number' && YEAR_LABEL.test(dashText(kpi.label))
+ // A year is not grouped: 2026, not 2,026. Only a figure that could be one
+ // is taken for it; revenue per year is still grouped.
+ const year =
+ typeof kpi.value === 'number' &&
+ Number.isInteger(kpi.value) &&
+ kpi.value >= 1000 &&
+ kpi.value <= 9999 &&
+ YEAR_LABEL.test(dashText(kpi.label))
const value = year ? String(kpi.value) : dashFigure(kpi.value)
if (!value) {
throw new Error(`${at}.value is missing; pass the figure to show, e.g. "$1.2M" or 48.`)