From bbe3dc6c2f88530fba93d0b2ef192af6ec9ee55c Mon Sep 17 00:00:00 2001 From: Shakker Date: Wed, 22 Apr 2026 04:14:44 +0100 Subject: [PATCH] fix: sanitize models list terminal output --- src/commands/models/list.table.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commands/models/list.table.ts b/src/commands/models/list.table.ts index f1d24c4701f..70249e18136 100644 --- a/src/commands/models/list.table.ts +++ b/src/commands/models/list.table.ts @@ -1,4 +1,5 @@ import { type RuntimeEnv, writeRuntimeJson } from "../../runtime.js"; +import { sanitizeTerminalText } from "../../terminal/safe-text.js"; import { colorize, theme } from "../../terminal/theme.js"; import { formatTag, isRich, pad, truncate } from "./list.format.js"; import type { ModelRow } from "./list.types.js"; @@ -25,7 +26,7 @@ export function printModelTable( if (opts.plain) { for (const row of rows) { - runtime.log(row.key); + runtime.log(sanitizeTerminalText(row.key)); } return; } @@ -42,18 +43,19 @@ export function printModelTable( runtime.log(rich ? theme.heading(header) : header); for (const row of rows) { - const keyLabel = pad(truncate(row.key, MODEL_PAD), MODEL_PAD); - const inputLabel = pad(row.input || "-", INPUT_PAD); + const keyLabel = pad(truncate(sanitizeTerminalText(row.key), MODEL_PAD), MODEL_PAD); + const inputLabel = pad(sanitizeTerminalText(row.input) || "-", INPUT_PAD); const ctxLabel = pad(formatTokenK(row.contextWindow), CTX_PAD); const localText = row.local === null ? "-" : row.local ? "yes" : "no"; const localLabel = pad(localText, LOCAL_PAD); const authText = row.available === null ? "-" : row.available ? "yes" : "no"; const authLabel = pad(authText, AUTH_PAD); + const tags = row.tags.map(sanitizeTerminalText); const tagsLabel = - row.tags.length > 0 + tags.length > 0 ? rich - ? row.tags.map((tag) => formatTag(tag, rich)).join(",") - : row.tags.join(",") + ? tags.map((tag) => formatTag(tag, rich)).join(",") + : tags.join(",") : ""; const coloredInput = colorize(