From 54e0fc342e61c9346b96972cea1ee652281fc027 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 22 Jan 2026 08:49:51 +0000 Subject: [PATCH] fix: wrap cli banner tagline --- src/cli/banner.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/cli/banner.ts b/src/cli/banner.ts index 023f0c85c..d697be8e5 100644 --- a/src/cli/banner.ts +++ b/src/cli/banner.ts @@ -1,10 +1,12 @@ import { resolveCommitHash } from "../infra/git-commit.js"; +import { visibleWidth } from "../terminal/ansi.js"; import { isRich, theme } from "../terminal/theme.js"; import { pickTagline, type TaglineOptions } from "./tagline.js"; type BannerOptions = TaglineOptions & { argv?: string[]; commit?: string | null; + columns?: number; richTty?: boolean; }; @@ -36,12 +38,28 @@ export function formatCliBannerLine(version: string, options: BannerOptions = {} const tagline = pickTagline(options); const rich = options.richTty ?? isRich(); const title = "🦞 Clawdbot"; + const prefix = "🦞 "; + const columns = options.columns ?? process.stdout.columns ?? 120; + const plainFullLine = `${title} ${version} (${commitLabel}) — ${tagline}`; + const fitsOnOneLine = visibleWidth(plainFullLine) <= columns; if (rich) { - return `${theme.heading(title)} ${theme.info(version)} ${theme.muted( + if (fitsOnOneLine) { + return `${theme.heading(title)} ${theme.info(version)} ${theme.muted( + `(${commitLabel})`, + )} ${theme.muted("—")} ${theme.accentDim(tagline)}`; + } + const line1 = `${theme.heading(title)} ${theme.info(version)} ${theme.muted( `(${commitLabel})`, - )} ${theme.muted("—")} ${theme.accentDim(tagline)}`; + )}`; + const line2 = `${" ".repeat(prefix.length)}${theme.muted("—")} ${theme.accentDim(tagline)}`; + return `${line1}\n${line2}`; } - return `${title} ${version} (${commitLabel}) — ${tagline}`; + if (fitsOnOneLine) { + return plainFullLine; + } + const line1 = `${title} ${version} (${commitLabel})`; + const line2 = `${" ".repeat(prefix.length)}— ${tagline}`; + return `${line1}\n${line2}`; } const LOBSTER_ASCII = [