Skip to content

feat(gui): show weighted Codex pool capacity and next recovery - #878

Open
luvs01 wants to merge 8 commits into
lidge-jun:devfrom
luvs01:feat/provider-capacity-aggregate
Open

feat(gui): show weighted Codex pool capacity and next recovery#878
luvs01 wants to merge 8 commits into
lidge-jun:devfrom
luvs01:feat/provider-capacity-aggregate

Conversation

@luvs01

@luvs01 luvs01 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a display-only configured-weight capacity estimate to the OpenAI (Codex login) Providers overview.
  • Keep the effective runtime account's raw quota visible as separate context, identify incomplete quota windows, and report the earliest reset as a percentage of total pool capacity restored.
  • Exclude unknown, incomplete, stale, paused, and reauthentication-required rows from numeric totals while preserving visible coverage context and safe fallback behavior.
  • Keep configured/weighted units and projected post-reset aggregates internal; the GUI shows weighted pool used %, effective-account raw %, reset time, and +N% pool capacity recovery only.
  • Preserve routing, pinning, thread affinity, pause state, cooldowns, and automatic switching behavior.

Closes #874

Verification

  • Root typecheck: bun run typecheck
  • Focused backend capacity/quota tests: 44/44 passed
  • Focused GUI adapter/shell tests: 17/17 passed
  • Full GUI test suite: 510/510 passed
  • cd gui && bun run build
  • cd gui && bun run lint
  • cd gui && bun run lint:i18n
  • Localized docs build: cd docs-site && bun run build (206 pages)
  • bun run privacy:scan
  • git diff --check
  • Independent post-fix and post-rebase reviews found no P0-P2 issues.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive surfaces were reviewed for secrets, auth, and unsafe defaults; this change exposes no account identifiers or credentials and does not alter routing policy.

Summary by CodeRabbit

  • New Features
    • Added provider overview capacity estimates for pooled accounts, including weighted usage, effective-account quotas, recovery timing, and capacity share.
    • Added indicators for incomplete or partial quota coverage and reset windows.
    • Added localized capacity and accessibility labels in English, German, Japanese, Korean, Russian, and Chinese.
  • Documentation
    • Documented provider capacity estimates and clarified they are display-only and do not affect routing or account selection.
  • Bug Fixes
    • Improved handling of stale, empty, failed, and incomplete quota data.

luvs01 added 7 commits August 2, 2026 17:28
Use configured plan weights to summarize routable Codex quota windows while retaining effective-account raw quota and incomplete coverage.

Show next capacity recovery as a share of the weighted pool without changing routing or account selection.

Refs lidge-jun#874
Carry weighted pool metadata through the provider workspace shell and reject stale per-account quota readings.

Key report caching to a privacy-safe signature of every aggregation-relevant account state while keeping configured weight units internal.

Refs lidge-jun#874
Document the Providers overview's weighted pool percentage, effective-account quota, recovery display, incomplete coverage, and display-only routing boundary.

Refs lidge-jun#874
Replace stale provider quota state authoritatively, retain per-window coverage, and distinguish aggregate, fallback, and coverage-only reports.

Reject cache commits when pool presentation state changes during a probe and allow recovery details to wrap in narrow panes.

Refs lidge-jun#874
Keep pool account counts partitioned while reporting partial limit-window coverage separately.

Render coverage-only reports in the Providers overview and expire stale effective-account fallbacks without restamping their quota data.

Refs lidge-jun#874
@github-actions github-actions Bot added the enhancement New feature or request label Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds weighted Codex pool-capacity aggregation, freshness-aware quota reporting, strict GUI parsing, Providers overview rendering, partial-window indicators, localized strings, responsive styling, documentation, and coverage tests.

Changes

Codex pool capacity

Layer / File(s) Summary
Capacity aggregation
src/codex/auth-api.ts, src/providers/codex-capacity.ts, tests/provider-capacity.test.ts
The backend resolves the effective account and aggregates eligible Codex accounts using configured plan weights. It reports window usage, recovery, exclusions, incomplete coverage, and current-account data.
Quota reporting and cache coherence
src/providers/quota.ts, tests/provider-quota.test.ts
Quota reporting publishes sanitized aggregation metadata, supports aggregate, fallback, and coverage-only results, and uses pool-sensitive cache validation.
GUI report parsing and freshness
gui/src/provider-workspace/report.ts, gui/src/components/provider-workspace/ProviderWorkspaceShell.tsx, gui/tests/provider-capacity.test.ts, gui/tests/provider-capacity-shell.test.tsx
The GUI validates aggregation contracts, rejects stale or malformed reports, replaces reports on successful empty responses, and retains only fresh data after failures.
Providers overview display
gui/src/components/provider-workspace/ProviderOverviewDashboard.tsx, gui/src/components/QuotaBars.tsx, gui/src/styles/*, gui/src/i18n/*, docs-site/src/content/docs/guides/*
The overview displays weighted estimates, recovery details, current-account quotas, coverage warnings, and localized partial-window markers. Documentation describes the display-only estimate and routing boundary.

Estimated code review effort: 5 (Critical) | ~90 minutes

Possibly related PRs

Suggested labels: documentation

Suggested reviewers: lidge-jun, wibias, ingwannu

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation covers weighted aggregation, effective-account context, recovery reporting, exclusions, freshness, fallback behavior, display-only scope, and related tests for issue #874.
Out of Scope Changes check ✅ Passed The documentation, backend, GUI, localization, styling, caching, and tests directly support the weighted Codex pool-capacity feature in issue #874.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: displaying weighted Codex pool capacity and the next recovery time in the GUI.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74a6e22a8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/providers/codex-capacity.ts
Comment thread src/providers/quota.ts
Comment thread src/providers/codex-capacity.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Around line 27-46: Update the localized providers guides in
ja/guides/providers.md, ko/guides/providers.md, ru/guides/providers.md, and
zh-cn/guides/providers.md to include the English guide’s Pool capacity section:
configured-weight pool capacity estimates, the effective account’s raw quota,
reset recovery information, incomplete and partial-window coverage behavior, and
the display-only routing limitation. Translate the content appropriately while
preserving the existing Pool/Direct guidance.

In `@gui/src/components/provider-workspace/ProviderOverviewDashboard.tsx`:
- Around line 255-260: Update the recoveryRows rendering and its row key near
recoveryRows so each row uses a stable unique identifier based on its window
source rather than the display label. Distinguish fiveHour, weekly, monthly, and
each custom window (using an appropriate custom-window identity), while
preserving labels for display and avoiding collisions across localized standard
labels and raw custom labels.

In `@gui/src/components/provider-workspace/ProviderWorkspaceShell.tsx`:
- Around line 278-286: Add the cancelled check at the start of the quota
request’s catch handler, before setQuotaReports or writeSessionListCache can
run. Keep the existing freshQuotaReportRecord fallback unchanged, and ensure
rejected superseded or unmounted requests perform no state or cache updates
while preserving the finally loading cleanup.

In `@gui/src/i18n/de.ts`:
- Line 1383: Update the German translation value for pws.capacity.estimate to
grammatical wording that conveys an estimate calculated from the configured plan
weights, matching the English source meaning and preserving its use as the
ProviderCapacityQuota label.

In `@gui/src/i18n/ru.ts`:
- Line 1045: Update the Russian translation value for "pws.capacity.incomplete"
so the unknown-plan count is explicitly presented as a subset included within
the excluded-account count, matching the relationship expressed by the other
locale translations rather than as an additive parallel count.

In `@gui/src/provider-workspace/report.ts`:
- Around line 106-113: Rename the flatMap callback parameter in the
customWindows transformation from value to entry, updating all references within
that callback while preserving its existing filtering and mapping behavior.

In `@gui/tests/provider-capacity-shell.test.tsx`:
- Line 19: Update the recovery timestamp assertion near RECOVERY_AT to derive
the expected formatted value with the same Intl.DateTimeFormat configuration
used by ProviderCapacityQuota, including the test locale and ambient timezone,
instead of hardcoding date/time alternatives. Keep the assertion focused on the
formatter output so it remains valid across runner timezones.
- Around line 267-278: The aggregatePayload helper currently omits the
partialWindowAccounts and monthly members later assigned by the test, and the
test file is not type-checked in CI. Widen aggregatePayload’s declared payload
shape or include both members in its returned literal, then add the GUI test
TypeScript project to CI so provider-capacity-shell.test.tsx is checked.

In `@gui/tests/provider-capacity.test.ts`:
- Around line 100-107: Update the assertions in the provider capacity test to
scope each flex-wrap and overflow-wrap check to its intended selector, matching
the existing css.slice(css.indexOf(...)) pattern used for the container rule.
Ensure .pws-capacity-recovery assertions inspect only that rule and
.quota-stacked-limit-group assertions inspect only its rule, rather than the
entire stylesheet text.

In `@src/providers/codex-capacity.ts`:
- Around line 85-90: Update configuredWeight to use Object.hasOwn when checking
normalized against CODEX_CONFIGURED_CAPACITY_WEIGHTS, ensuring inherited
Object.prototype keys such as constructor, toString, and valueOf are rejected
and the function only returns configured numeric weights.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: be790c01-eace-4bae-85b8-98c8187c4557

📥 Commits

Reviewing files that changed from the base of the PR and between f9b9440 and 74a6e22.

📒 Files selected for processing (21)
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/guides/web-dashboard.md
  • gui/src/components/QuotaBars.tsx
  • gui/src/components/provider-workspace/ProviderOverviewDashboard.tsx
  • gui/src/components/provider-workspace/ProviderWorkspaceShell.tsx
  • gui/src/i18n/de.ts
  • gui/src/i18n/en.ts
  • gui/src/i18n/ja.ts
  • gui/src/i18n/ko.ts
  • gui/src/i18n/ru.ts
  • gui/src/i18n/zh.ts
  • gui/src/provider-workspace/report.ts
  • gui/src/styles/provider-overview-dashboard.css
  • gui/src/styles/provider-quota.css
  • gui/tests/provider-capacity-shell.test.tsx
  • gui/tests/provider-capacity.test.ts
  • src/codex/auth-api.ts
  • src/providers/codex-capacity.ts
  • src/providers/quota.ts
  • tests/provider-capacity.test.ts
  • tests/provider-quota.test.ts

Comment thread docs-site/src/content/docs/guides/providers.md
Comment thread gui/src/components/provider-workspace/ProviderOverviewDashboard.tsx Outdated
Comment thread gui/src/components/provider-workspace/ProviderWorkspaceShell.tsx
Comment thread gui/src/i18n/de.ts Outdated
Comment thread gui/src/i18n/ru.ts Outdated
Comment thread gui/src/provider-workspace/report.ts
Comment thread gui/tests/provider-capacity-shell.test.tsx
Comment thread gui/tests/provider-capacity-shell.test.tsx
Comment thread gui/tests/provider-capacity.test.ts Outdated
Comment thread src/providers/codex-capacity.ts
@luvs01
luvs01 force-pushed the feat/provider-capacity-aggregate branch from 74a6e22 to b4f963d Compare August 2, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant