Conversation
- Add QuotaManager with TTL cache mechanism in Rust backend
- Support 5h sliding window and weekly quota parsing for Codex and Antigravity
- Implement dual-runtime commands and Axum endpoints (/api/quota/{agentType})
- Add ComposerQuotaBadge component in chat composer with countdown and progress bars
- Support manual refresh, low quota alerts, and full internationalization (10 languages)
- Add comprehensive unit tests covering models, parsers, and UI components
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 27, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 27, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 27, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Pick whichever window has less remaining percentage via pickBindingWindow - Map daily limit labels to 1d - Add tests covering ChatGPT Pro binding window and tie-breaking cases
Author
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 28, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 28, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 28, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SousekiL
added a commit
to SousekiL/codeg
that referenced
this pull request
Sep 28, 2026
Builds on the QuotaManager from xintaofei#845 with two more providers. Claude Code: reads the CLI's own OAuth credentials (macOS Keychain item "Claude Code-credentials", else <CLAUDE_CONFIG_DIR|~/.claude>/.credentials.json) and calls the same https://api.anthropic.com/api/oauth/usage endpoint the CLI's /usage command uses, mapping five_hour / seven_day utilization onto the 5-hour and weekly windows and subscriptionType onto the plan name. An expired login is reported as such rather than as an opaque HTTP error. Devin CLI: reads windsurf_api_key + api_server_url from ~/.local/share/devin/credentials.toml (XDG_DATA_HOME aware) and calls the CLI's SeatManagementService/GetUserStatus Connect RPC; PlanStatus supplies the daily / weekly remaining percentages and reset times, plan name and ACU counters. Both the built-in `devin` id and the `custom:devin` wire id of a user-registered Devin ACP agent resolve to this probe. Credentials are only ever sent to their issuing service and never stored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在多智能体协作与代码生成场景下,用户无法直观了解当前生效智能体的剩余配额窗口(如 5 小时短窗口限流、周额度、每日请求数等)。在密集编码或自动化调度过程中极易突遭 429 配额耗尽或限流中断。
现有的客户端和后端仅有各 Agent 会话本身的交互逻辑,缺少对主流 CLI / OAuth 智能体账户真实使用额度的读取、探测与状态展示。
改动
在输入框工具栏(Composer)新增智能体配额徽章(ComposerQuotaBadge),并在后端实现统一的
QuotaManager探测管理体系,首期打通 OpenAI Codex 与 Google Antigravity 的真实配额接口。几条定死的语义与机制保证:
~/.codex/auth.json与~/.gemini/antigravity-acp/acp_token.json),绝不向任何第三方转发凭据。未登录或凭据损坏时优雅降级为未登录提示,不阻断主窗口与正常对话流程。QuotaManager托管,默认 30 秒线程安全 TTL 缓存;快速切换 Agent 或连续发送消息时直接命中缓存,避免频繁请求触发第三方端点的反爬或频控。get_agent_quota;远程/Web 端走 Axum REST 端点GET /api/quota/:agent_type,同一套数据模型与业务逻辑。实现分布:
src-tauri/src/quota/:mod.rs— 核心QuotaManager,基于Arc<RwLock<HashMap<String, CachedQuota>>>管理缓存、失效及分发。codex.rs— 探通 OpenAI 官方 Wham usage 端点(https://chatgpt.com/backend-api/wham/usage)。自动解析access_token与可选的account_id(完美支持个人版与 ChatGPT Team 团队版空间),提取 5 小时主要窗口、周限制窗口使用率及精准重置倒计时。antigravity.rs— 接入 Google Cloud Code Private API (CCPA) Consumer Daily 端点(loadCodeAssist与retrieveUserQuotaSummary)。集成 Google OAuth Refresh Token 自动换票,解析用户套餐(如 Google AI Pro / Free Tier)及 Gemini 模型组(5h / weekly)实时配额 bucket。src-tauri/src/models/quota.rs:AgentQuotaInfo、QuotaWindow、SpendLimit数据模型,全链路 camelCase 序列化并配套 6 个 Rust 单测。src-tauri/src/commands/quota.rs&web/handlers/quota.rs:注册桌面 Tauri 命令与 Web 路由。src/components/chat/composer-quota-badge.tsx:src/components/chat/composer-quota-badge.test.tsx:覆盖挂载渲染、色标阶段、popover 详情、手动刷新及未登录降级等 7 个前端用例。zh-CN,zh-TW,en,ja,ko,es,fr,de,pt,ar)。验证
67% used / 33% remaining,5小时窗口倒计时精准匹配。loadCodeAssist套餐及retrieveUserQuotaSummaryGemini 5小时(剩余约 52.7%)与周额度(剩余约 86%)。cargo test quota --no-default-features --bin codeg-server --lib→ 21 个单测全部通过。pnpm test→ 439 个测试文件全量通过(含 7 个 quota badge 前端测试)。