Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib/quota-command-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/

import type { QuotaToastEntry, QuotaToastError, SessionTokensData } from "./entries.js";
import type { PercentDisplayMode } from "./types.js";
import { isValueEntry } from "./entries.js";
import { bar, clampInt, padRight } from "./format-utils.js";
import { bar, clampInt, formatDisplayedPercentLabel, padRight } from "./format-utils.js";
import { formatGroupedHeader } from "./grouped-header-format.js";
import { groupQuotaEntries } from "./grouped-entry-normalization.js";
import { renderPlainTextReport, type ReportDocument, type ReportSection } from "./report-document.js";
Expand Down Expand Up @@ -46,6 +47,7 @@ function buildQuotaCommandDocument(params: {
errors: QuotaToastError[];
sessionTokens?: SessionTokensData;
generatedAtMs?: number;
percentDisplayMode?: PercentDisplayMode;
}): ReportDocument {
const groups = groupQuotaEntries(params.entries, "quota");
const normalizedEntries = groups.flatMap((group) => group.entries);
Expand All @@ -72,7 +74,8 @@ function buildQuotaCommandDocument(params: {
}

const pct = clampInt(row.percentRemaining, 0, 100);
lines.push(` ${labelCol} ${bar(pct, barWidth)} ${pct}% left${suffix}`);
const pctLabel = formatDisplayedPercentLabel(row.percentRemaining, params.percentDisplayMode);
lines.push(` ${labelCol} ${bar(pct, barWidth)} ${pctLabel}${suffix}`);
}
return {
id: `group-${index}`,
Expand Down Expand Up @@ -116,6 +119,7 @@ export function formatQuotaCommand(params: {
errors: QuotaToastError[];
sessionTokens?: SessionTokensData;
generatedAtMs?: number;
percentDisplayMode?: PercentDisplayMode;
}): string {
return renderPlainTextReport(buildQuotaCommandDocument(params));
}
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,7 @@ export const QuotaToastPlugin: Plugin = async ({ client }) => {
formatQuotaCommand({
...reportData,
generatedAtMs,
percentDisplayMode: runtime.config.percentDisplayMode,
}),
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/plugin.quota-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ describe("/quota command behavior", () => {

expect(client.session.prompt).toHaveBeenCalledTimes(1);
const injected = getPromptText(client);
expect(injected).toContain("81% left");
expect(injected).not.toContain("19% left");
expect(injected).toContain("19% used");
expect(injected).not.toContain("81% left");
});

it("rewrites default_agent only when one zero-width-normalized key matches", async () => {
Expand Down