fix(status): show 2 usage windows in /status (#1101)

Thanks @rhjoh.

Co-authored-by: Rhys Johnston <rhys.johnston00@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-17 18:46:18 +00:00
parent 2f6d9417bd
commit 8ec4af4641
5 changed files with 36 additions and 24 deletions

View File

@@ -104,7 +104,12 @@ describe("trigger handling", () => {
{
provider: "anthropic",
displayName: "Anthropic",
windows: [],
windows: [
{
label: "5h",
usedPercent: 20,
},
],
},
],
});

View File

@@ -14,7 +14,7 @@ import type { ClawdbotConfig } from "../../config/config.js";
import type { SessionEntry, SessionScope } from "../../config/sessions.js";
import { logVerbose } from "../../globals.js";
import {
formatUsageSummaryLine,
formatUsageWindowSummary,
loadProviderUsageSummary,
resolveUsageProviderId,
} from "../../infra/provider-usage.js";
@@ -148,11 +148,15 @@ export async function buildStatusReply(params: {
providers: [currentUsageProvider],
agentDir: statusAgentDir,
});
const summaryLine = formatUsageSummaryLine(usageSummary, {
now: Date.now(),
maxProviders: 1,
});
if (summaryLine) usageLine = summaryLine;
const usageEntry = usageSummary.providers[0];
if (usageEntry && !usageEntry.error && usageEntry.windows.length > 0) {
const summaryLine = formatUsageWindowSummary(usageEntry, {
now: Date.now(),
maxWindows: 2,
includeResets: true,
});
if (summaryLine) usageLine = `📊 Usage: ${summaryLine}`;
}
} catch {
usageLine = null;
}