fix: fetch quota on manual refresh button click#449
Conversation
Previously, clicking the refresh button on an account card only refreshed the OAuth token without querying upstream quota data. Now, after a successful token refresh, we also call the Codex usage API to fetch and cache the current quota (7-day and 5-hour windows), so users can see usage data even without making proxy requests. Changes: - POST /auth/accounts/:id/refresh now fetches quota after token refresh - GET /auth/accounts?quota=fresh actively fetches quota for all accounts - Added tls.disable_websocket config option for proxies that don't support WebSocket - Proxy auto-detection now respects empty proxy_url config Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Use getConfig() when checking disable_websocket during implicit resume so the branch builds cleanly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Review notes: 这个 PR 目前我建议先不要合并,主要风险是它把一个现有代码刻意避开的路径重新加回来了。 现有 src/routes/accounts.ts 和 src/auth/health-check.ts 里已经有明确设计:RT exchange / health-check 只打 OAuth refresh endpoint,不要在刷新 RT 后马上请求 Codex /codex/usage,因为之前标注过这会触发 OpenAI risk detection / deactivation。 但这个 PR 在 POST /auth/accounts/:id/refresh 成功 probeAccount() 后马上 new CodexApi(...).getUsage(),等于手动 refresh 后立刻打 /codex/usage,风险比较高。 另外还有两个实现问题:
建议把 quota fresh 做成单独、受限、可选的路径,复用现有 quota refresher 的 concurrency / throttle 策略;不要挂在 token refresh 的同步路径后面。tls.disable_websocket 这部分也建议拆开或补完整设置入口和测试,尤其 implicit resume 依赖 WebSocket 支持 previous_response_id,禁用后的行为需要明确。 |
|
感谢 PR,但有几处需要先调整: [P1] RT rotation 后立即调 [P2] WebSocket 禁用时 previous_response_id 续链断 — [P2] WS 禁用时 implicit resume 也要关 — [P3] TS no-any — |
Summary
quota=freshonGET /auth/accountsby actively refreshing quotas for active accountstls.disable_websocketconfig support and fix emptyproxy_urlhandling for environments where WebSocket/proxy behavior needs to be controlledProblem
After importing or adding accounts, the dashboard could show no quota usage until an account was actually used for a proxy request. Clicking the account refresh button only refreshed the OAuth token and checked health; it did not call the upstream Codex usage API. The top-level refresh button already requested
?quota=fresh, but the backend ignored that parameter.Solution
POST /auth/accounts/:id/refreshnow fetches upstream usage viaCodexApi.getUsage()after a successful token refresh and stores it viapool.updateCachedQuota().GET /auth/accounts?quota=freshnow refreshes quota for all active accounts before returning the account list.Test Plan
npm run build:webcd packages/electron && npm run build && npm run pack:win