From 7813e1449226a17fcac7934ce631f079da4e8050 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 12 Nov 2025 09:10:41 +0100 Subject: [PATCH] Add model name to footer stats line (right-aligned) --- packages/coding-agent/src/tui/footer.ts | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/src/tui/footer.ts b/packages/coding-agent/src/tui/footer.ts index 6eaf78c1..bdce112f 100644 --- a/packages/coding-agent/src/tui/footer.ts +++ b/packages/coding-agent/src/tui/footer.ts @@ -1,5 +1,6 @@ import type { AgentState } from "@mariozechner/pi-agent"; import type { AssistantMessage } from "@mariozechner/pi-ai"; +import { visibleWidth } from "@mariozechner/pi-tui"; import chalk from "chalk"; /** @@ -71,7 +72,35 @@ export class FooterComponent { if (totalCost) statsParts.push(`$${totalCost.toFixed(3)}`); statsParts.push(`${contextPercent}%`); - const statsLine = statsParts.join(" "); + const statsLeft = statsParts.join(" "); + + // Add model name on the right side + let modelName = this.state.model.id; + const statsLeftWidth = visibleWidth(statsLeft); + const modelWidth = visibleWidth(modelName); + + // Calculate available space for padding (minimum 2 spaces between stats and model) + const minPadding = 2; + const totalNeeded = statsLeftWidth + minPadding + modelWidth; + + let statsLine: string; + if (totalNeeded <= width) { + // Both fit - add padding to right-align model + const padding = " ".repeat(width - statsLeftWidth - modelWidth); + statsLine = statsLeft + padding + modelName; + } else { + // Need to truncate model name + const availableForModel = width - statsLeftWidth - minPadding; + if (availableForModel > 3) { + // Truncate model name to fit + modelName = modelName.substring(0, availableForModel); + const padding = " ".repeat(width - statsLeftWidth - visibleWidth(modelName)); + statsLine = statsLeft + padding + modelName; + } else { + // Not enough space for model name at all + statsLine = statsLeft; + } + } // Return two lines: pwd and stats return [chalk.gray(pwd), chalk.gray(statsLine)];