Skip to content

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

TypeScript

fix(mcp-host): keep PPTX KPI figures large when one value cannot fit a line

marcoteb880dd0fd5026
diff --git a/mcp-host/src/workflow/__tests__/internalTools.pptx.layout.test.ts b/mcp-host/src/workflow/__tests__/internalTools.pptx.layout.test.ts
index f49c42917..6d1e93177 100644
--- a/mcp-host/src/workflow/__tests__/internalTools.pptx.layout.test.ts
+++ b/mcp-host/src/workflow/__tests__/internalTools.pptx.layout.test.ts
@@ -339,6 +339,32 @@ describe('clerum__generate_pptx — text stays inside its box', () => {
expect(result.content).toContain('slides[0].kpis[0].value is too long for its space')
})
+ it('keeps KPI figures large when one value is too long for a line', async () => {
+ const result = await generatePptx(
+ {
+ filename: 'k.pptx',
+ slides: [
+ {
+ layout: 'kpis',
+ title: 'KPIs',
+ kpis: [
+ { label: 'Revenue', value: '$4.2M' },
+ { label: 'Churn', value: '38%' },
+ { label: 'Users', value: '1,240' },
+ { label: 'Segment', value: 'Enterprise and mid-market accounts' },
+ ],
+ },
+ ],
+ },
+ outputDir
+ )
+ expect(result.success, result.error).toBe(true)
+ const xml = slideXml(path.join(outputDir, 'k.pptx'), 1)
+ for (const figure of ['$4.2M', '38%', '1,240']) {
+ expect(shapeWithText(xml, figure).sizes).toEqual([24])
+ }
+ })
+
it('says when an eyebrow or a quote attribution is shortened to one line', async () => {
const result = await generatePptx(
{
diff --git a/mcp-host/src/workflow/pptxDeck.ts b/mcp-host/src/workflow/pptxDeck.ts
index 588a5309c..61faea308 100644
--- a/mcp-host/src/workflow/pptxDeck.ts
+++ b/mcp-host/src/workflow/pptxDeck.ts
@@ -920,12 +920,15 @@ function cardType(cards: PptxKpi[], cardW: number, columns: number, people: bool
: columns >= 3
? [24, 22, 20, 18, 16, 14, 12]
: [32, 28, 24, 20, 18, 16, 14, 12]
- // The largest size at which every value fits on one line; a value too long
- // even at the smallest wraps there.
+ // The largest size at which every value that can fit one line does; a value
+ // too long even at the smallest wraps at that size instead of shrinking the rest.
const inner = w - TEXT_INSET_X
+ const smallest = valueSizes[valueSizes.length - 1]
+ const oneLine = cards.filter(c => textWidth(c.value, smallest, true) <= inner)
const valueSize =
- valueSizes.find(size => cards.every(c => textWidth(c.value, size, true) <= inner)) ??
- valueSizes[valueSizes.length - 1]
+ (oneLine.length > 0 &&
+ valueSizes.find(size => oneLine.every(c => textWidth(c.value, size, true) <= inner))) ||
+ smallest
return { labelSize, labelHeight, valueSize }
}