fix: normalize tabs in usage notes rendering
Address P2 review: sanitizeText preserves \t which can create visual holes in rendered output. Add .replace(/\t/g, ' ') to provider-wide and per-limit notes in usage-report.ts and usage-cli.ts, matching the TUI path which already uses replaceTabs().
This commit is contained in:
@@ -452,7 +452,8 @@ export function formatUsageBreakdown(
|
||||
);
|
||||
// Provider-wide disclaimers render once per provider, not per limit.
|
||||
const providerNotes = [...new Set(providerReports.flatMap(report => report.notes ?? []))];
|
||||
for (const note of providerNotes) lines.push(` ${chalk.dim(sanitizeText(note.replace(/[\r\n]+/g, " ")))}`);
|
||||
for (const note of providerNotes)
|
||||
lines.push(` ${chalk.dim(sanitizeText(note.replace(/[\r\n]+/g, " ").replace(/\t/g, " ")))}`);
|
||||
|
||||
const labelWidth = providerReports
|
||||
.flatMap(report => report.limits)
|
||||
|
||||
@@ -55,7 +55,8 @@ function renderUsageReports(
|
||||
const activeAccount = resolveActiveAccount?.(provider);
|
||||
// Provider-wide disclaimers render once per provider, not per limit.
|
||||
const providerNotes = [...new Set(providerReports.flatMap(report => report.notes ?? []))];
|
||||
for (const note of providerNotes) lines.push(` ${sanitizeText(note.replace(/[\r\n]+/g, " "))}`);
|
||||
for (const note of providerNotes)
|
||||
lines.push(` ${sanitizeText(note.replace(/[\r\n]+/g, " ").replace(/\t/g, " "))}`);
|
||||
for (const report of providerReports) {
|
||||
const inUse = reportMatchesActiveAccount(report, activeAccount);
|
||||
const savedResets = report.resetCredits?.availableCount ?? 0;
|
||||
@@ -88,7 +89,9 @@ function renderUsageReports(
|
||||
lines.push(` resets in ${formatDuration(limit.window.resetsAt - nowMs)}`);
|
||||
}
|
||||
if (limit.notes && limit.notes.length > 0)
|
||||
lines.push(` ${limit.notes.map(n => sanitizeText(n.replace(/[\r\n]+/g, " "))).join(" • ")}`);
|
||||
lines.push(
|
||||
` ${limit.notes.map(n => sanitizeText(n.replace(/[\r\n]+/g, " ").replace(/\t/g, " "))).join(" • ")}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user