diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 69b6946eb..f80a2bcef 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -144,6 +144,8 @@ - Fixed thinking blocks appearing in the UI when thinking level is "off". Some providers (MiniMax, GLM, DeepSeek) return thinking blocks even with reasoning disabled; thinking blocks are now auto-hidden when the thinking level is "off", regardless of the `hideThinkingBlock` setting. Toggling thinking block visibility while thinking is off shows a status message instead of silently no-op'ing. ([#626](https://github.com/can1357/oh-my-pi/issues/626)) +- Fixed the TUI usage display failing to resolve a used fraction for limits that only populate `remainingFraction` (no `usedFraction`, `used`/`limit`, or `percent`+`used`). The TUI's local `resolveFraction` was missing the inverted-remaining fallback that the shared `resolveUsedFraction` from `@oh-my-pi/pi-ai` already handles — replaced the local copy with the shared function so the TUI and CLI paths resolve fractions identically. + ## [16.1.16] - 2026-06-23 ### Breaking Changes diff --git a/packages/coding-agent/src/modes/controllers/command-controller.ts b/packages/coding-agent/src/modes/controllers/command-controller.ts index e1264e3dd..969b45582 100644 --- a/packages/coding-agent/src/modes/controllers/command-controller.ts +++ b/packages/coding-agent/src/modes/controllers/command-controller.ts @@ -6,6 +6,7 @@ import { getEnvApiKey, getProviderDetails, type ProviderDetails, + resolveUsedFraction, type UsageLimit, type UsageReport, } from "@oh-my-pi/pi-ai"; @@ -1306,22 +1307,10 @@ export function renderProviderSection(details: ProviderDetails, uiTheme: Pick 0) { - return amount.used / amount.limit; - } - if (amount.unit === "percent" && amount.used !== undefined) { - return amount.used / 100; - } - return undefined; -} - function resolveProviderUsageTotal(reports: UsageReport[]): number { return reports .flatMap(report => report.limits) - .map(limit => resolveFraction(limit) ?? 0) + .map(limit => resolveUsedFraction(limit) ?? 0) .reduce((sum, value) => sum + value, 0); } @@ -1432,7 +1421,7 @@ function resolveAggregateStatus(limits: UsageLimit[]): UsageLimit["status"] { function formatAggregateAmount(limits: UsageLimit[]): string { const fractions = limits - .map(limit => resolveFraction(limit)) + .map(limit => resolveUsedFraction(limit)) .filter((value): value is number => value !== undefined); if (fractions.length === limits.length && fractions.length > 0) { const sum = fractions.reduce((total, value) => total + value, 0); @@ -1489,7 +1478,7 @@ function resolveStatusColor(status: UsageLimit["status"]): "success" | "warning" } function renderUsageBar(limit: UsageLimit, uiTheme: typeof theme, barWidth: number): string { - const fraction = resolveFraction(limit); + const fraction = resolveUsedFraction(limit); if (fraction === undefined) { return uiTheme.fg("dim", "·".repeat(barWidth)); } @@ -1619,7 +1608,7 @@ export function renderUsageReports( const entries = group.limits.map((limit, index) => ({ limit, report: group.reports[index], - fraction: resolveFraction(limit), + fraction: resolveUsedFraction(limit), index, })); entries.sort((a, b) => {