fix(status-line): recognized kimi-code subscription windows in the usage segment

Kimi's usage provider built window ids from the raw duration/timeUnit ("300time_unit_minute") and left the aggregate quota on "default", so the status-line usage segment, which matches canonical "5h"/"7d" windows, never rendered for kimi-code sessions.

Derive window ids from the reported span instead (300 minutes -> "5h", 7 days -> "7d"), mirroring the minimax-code convention, and tag the aggregate quota as the weekly window. The payload carries only resetTime for the aggregate, but the observed reset horizon matches the plan's weekly cycle. The segment aggregator also falls back to the reported span (duration within a minute of 5h or 7d) when the id isn't canonical, so cache rows written by older builds still light up the 5h meter in mixed-version fleets.
This commit is contained in:
Bejay Cole
2026-08-10 15:36:05 -06:00
parent 45e12e5bb7
commit e7f487381b
4 changed files with 152 additions and 8 deletions
@@ -1389,7 +1389,7 @@ export class StatusLineComponent implements Component {
}
const l = limit as {
scope?: { windowId?: string; tier?: string };
window?: { resetsAt?: number };
window?: { resetsAt?: number; durationMs?: number };
amount?: { usedFraction?: number };
};
const fraction = l.amount?.usedFraction;
@@ -1397,9 +1397,22 @@ export class StatusLineComponent implements Component {
const windowId = l.scope?.windowId;
const tier = l.scope?.tier;
const resetsAt = l.window?.resetsAt;
// Canonical window ids win. Fall back to the reported span (same
// tolerance as the 5h priority-boost check) so providers that emit
// non-canonical ids, and cache rows written before a provider was
// canonicalized, still map onto the two subscription windows.
const durationMs = l.window?.durationMs;
const windowClass =
windowId === "5h" || windowId === "7d"
? windowId
: durationMs !== undefined && Math.abs(durationMs - 5 * 3_600_000) <= 60_000
? "5h"
: durationMs !== undefined && Math.abs(durationMs - 7 * 86_400_000) <= 60_000
? "7d"
: undefined;
// Accept tiered limits, but prefer untiered (backward compat with Anthropic).
// An untiered limit always replaces a tiered one; among same-tieredness, first wins.
if (windowId === "5h" && (!fiveHour || (fiveHourTier !== undefined && !tier))) {
if (windowClass === "5h" && (!fiveHour || (fiveHourTier !== undefined && !tier))) {
fiveHour = {
percent: fraction * 100,
resetMinutes:
@@ -1407,7 +1420,7 @@ export class StatusLineComponent implements Component {
};
fiveHourTier = tier || undefined;
}
if (windowId === "7d" && (!sevenDay || (sevenDayTier !== undefined && !tier))) {
if (windowClass === "7d" && (!sevenDay || (sevenDayTier !== undefined && !tier))) {
sevenDay = {
percent: fraction * 100,
resetHours: