perf: cut background polling and log noise
- Codex usage poll: run the repo-pinned CLI (0.159.3) instead of a global 0.128 install, hold the account lease while polling (skip if a run holds it, so the poller cannot rotate a token under a live reviewer session), and poll every 5 min instead of every minute (~1,440 app-server spawns a day). - Claude usage poll: 5 min instead of 1 min. The 1-minute cadence only served the auto-paired-mode gate, which is not wired into the runtime; it drew ~32 HTTP 429s a day. - Dashboard duplicate cleanup: was a 2 s poll fetching 100 messages (~43k Discord REST calls a day) plus a fetch after every edit. Clean up only when a fresh status message is posted or on first render, with a 5 min sweep. - Logging: one line per event and no ANSI colors outside a TTY (events were split into ~11 journal lines). Progress-edit audits, Discord progress edits, streamed-activity and per-bucket Codex usage logs move to debug; sends, agent output and the usage summary stay at info. - Two tests wrote under the real data/ipc and left fake room folders that the live 1 s IPC watcher kept polling; they now clean up after themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,16 +128,17 @@ describe('Claude usage 429 Retry-After backoff', () => {
|
||||
expect(held[0].usageRateLimited).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps backing off after the 60s throttle elapses but before the cooldown closes', async () => {
|
||||
// This is the core regression: a 93s Retry-After must outlast the 60s
|
||||
// MIN_FETCH_INTERVAL throttle. Without the cooldown the poller would refetch
|
||||
// at ~60s — mid rate-limit window — and re-trip the 429 forever.
|
||||
it('keeps backing off after the 5-minute throttle elapses but before the cooldown closes', async () => {
|
||||
// This is the core regression: a Retry-After longer than the 5-minute
|
||||
// MIN_FETCH_INTERVAL throttle must still be honoured. Without the cooldown
|
||||
// the poller would refetch once the throttle elapses — mid rate-limit
|
||||
// window — and re-trip the 429 forever.
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date('2026-06-20T00:00:00Z'));
|
||||
|
||||
const fetchMock = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(makeResponse(429, { 'retry-after': '93' }))
|
||||
.mockResolvedValueOnce(makeResponse(429, { 'retry-after': '393' }))
|
||||
.mockResolvedValueOnce(makeResponse(200));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
@@ -146,13 +147,13 @@ describe('Claude usage 429 Retry-After backoff', () => {
|
||||
await fetchAllClaudeUsage();
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
// +70s: past the 60s throttle, still inside the ~98s cooldown → no refetch.
|
||||
vi.setSystemTime(Date.now() + 70_000);
|
||||
// +370s: past the 300s throttle, still inside the ~398s cooldown → no refetch.
|
||||
vi.setSystemTime(Date.now() + 370_000);
|
||||
const held = await fetchAllClaudeUsage();
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(held[0].usageRateLimited).toBe(true);
|
||||
|
||||
// +100s total: cooldown window closed → poller is allowed to fetch again.
|
||||
// +400s total: cooldown window closed → poller is allowed to fetch again.
|
||||
vi.setSystemTime(Date.now() + 30_000);
|
||||
const resumed = await fetchAllClaudeUsage();
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
Reference in New Issue
Block a user