refactor(models): reuse list format helpers in scan

This commit is contained in:
Peter Steinberger
2026-02-18 23:08:23 +00:00
parent 6eb0964fa6
commit 8e6a7a6343

View File

@@ -10,6 +10,7 @@ import {
stylePromptMessage,
stylePromptTitle,
} from "../../terminal/prompt-style.js";
import { pad, truncate } from "./list.format.js";
import { formatMs, formatTokenK, updateConfig } from "./shared.js";
const MODEL_PAD = 42;
@@ -33,18 +34,6 @@ function guardPromptCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
return value;
}
const pad = (value: string, size: number) => value.padEnd(size);
const truncate = (value: string, max: number) => {
if (value.length <= max) {
return value;
}
if (max <= 3) {
return value.slice(0, max);
}
return `${value.slice(0, max - 3)}...`;
};
function sortScanResults(results: ModelScanResult[]): ModelScanResult[] {
return results.slice().toSorted((a, b) => {
const aImage = a.image.ok ? 1 : 0;