refactor(codex): tighten status rate-limit formatting · openclaw/openclaw@d25bece
obviyus
·
2026-05-14
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
2 | 2 | import { |
3 | 3 | formatCodexUsageLimitErrorMessage, |
4 | 4 | resolveCodexUsageLimitResetAtMs, |
| 5 | +summarizeCodexRateLimits, |
5 | 6 | summarizeCodexAccountUsage, |
6 | 7 | } from "./rate-limits.js"; |
7 | 8 | |
@@ -66,3 +67,32 @@ describe("Codex rate limit blocking resets", () => {
|
66 | 67 | expect(summarizeCodexAccountUsage(payload, nowMs)?.blockedUntilMs).toBe(weeklyReset * 1000); |
67 | 68 | }); |
68 | 69 | }); |
| 70 | + |
| 71 | +describe("summarizeCodexRateLimits", () => { |
| 72 | +it("formats status limits like provider usage summaries", () => { |
| 73 | +const nowMs = 1_700_000_000_000; |
| 74 | +const nowSeconds = nowMs / 1000; |
| 75 | + |
| 76 | +expect( |
| 77 | +summarizeCodexRateLimits( |
| 78 | +{ |
| 79 | +rateLimits: { |
| 80 | +limitId: "codex", |
| 81 | +limitName: "Codex", |
| 82 | +primary: { |
| 83 | +usedPercent: 26, |
| 84 | +windowDurationMins: 300, |
| 85 | +resetsAt: nowSeconds + 3 * 60 * 60, |
| 86 | +}, |
| 87 | +secondary: { |
| 88 | +usedPercent: 4, |
| 89 | +windowDurationMins: 7 * 24 * 60, |
| 90 | +resetsAt: nowSeconds + 7 * 24 * 60 * 60, |
| 91 | +}, |
| 92 | +}, |
| 93 | +}, |
| 94 | +nowMs, |
| 95 | +), |
| 96 | +).toBe("Codex: primary 74% left ⏱3h · secondary 96% left ⏱7d"); |
| 97 | +}); |
| 98 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。