Skip to content

Codex quota widget shows two weekly bars when the hourly window is absent #869

Closed

Description

@ravshansbox

Summary

After Codex stopped returning an hourly quota, Jcode renders the remaining two quota windows as two separate weekly bars. This is misleading because neither returned window is an hourly limit.

Reproduction

  1. Sign in with a Codex/OpenAI OAuth account whose current usage response has no hourly window and contains two weekly windows.
  2. Start Jcode and inspect the OpenAI limits in the info widget or compact header.
  3. Jcode shows two quota lines, both labeled with the backend's weekly window label.

Expected

Render the reported windows without assigning an hourly role when the response does not contain an hourly window. In particular, do not display two weekly windows as the legacy five_hour and seven_day slots. The UI could use a generic ordered list of returned windows, or correctly distinguish the two weekly quotas when the backend supplies an identifier.

Actual

The first weekly window is stored in the seven_day field because its name matches the weekly detector. The generic fallback then stores that same first window in five_hour, because no hourly window was found. The widget renders both field labels verbatim, so users see the same weekly quota twice.

Root cause

crates/jcode-base/src/usage/openai_helpers.rs still models OpenAI usage as fixed five_hour, seven_day, and spark slots. In classify_openai_limits:

if five_hour.is_none() {
    five_hour = generic_non_spark.first().cloned();
}
if seven_day.is_none() {
    seven_day = generic_non_spark.iter().find(/* a different item */).cloned();
}

This fallback causes the first generic window to fill the historical hourly slot whenever no limit matches limit_mentions_five_hour. A weekly limit has already filled seven_day, so that same weekly quota is rendered through both legacy slots. A second returned weekly window is not meaningfully represented.

crates/jcode-tui/src/tui/app/tui_state.rs then forwards window.name as each display label, and info_widget_usage.rs renders both bars. Therefore the issue is not merely cosmetic label text: the model cannot represent the changed Codex quota shape.

Validation

  • Inspected the v0.75.0 source at commit 5ae2385.
  • Ran cargo test -p jcode-base test_classify_openai_limits --lib --quiet successfully (2 tests passed). Existing coverage only tests the old 5h + 1w shape and does not cover two weekly windows.

Suggested fix

Replace the fixed two-window fallback for OpenAI with a list of normalized windows, or only populate the hourly slot when a returned limit explicitly identifies an hourly duration. Add a regression test with two 7-day window limits and no hourly limit. The regression should assert that the first weekly window is not duplicated into an hourly slot and that both returned windows remain distinguishable.

Activity

  1. added
    bug
    triage: reproducible
    autonomous: clear
    on Aug 10, 2026
  2. 1jehuang commented on Aug 10, 2026

    @1jehuang
    Owner

    The duplication is reproducible in classify_openai_limits. A focused fix now excludes an already-classified weekly window from the generic fallback and adds coverage for two weekly windows with no hourly window. I will link the verified PR here shortly.


    — Jcode agent (automated triage), on behalf of @1jehuang

  3. 1jehuang commented on Aug 10, 2026

    @1jehuang
    Owner

    The focused classification tests pass, and the verified fix is now available in #882.


    — Jcode agent (automated triage), on behalf of @1jehuang

  4. added a commit that references this issue on Aug 15, 2026
    a8e0afd
  5. added 5 commits that reference this issue on Aug 30, 2026
    ddad7c6
    bce5764
    cf5f3b4
    2b946f1
    b85ddc9
  6. added a commit that references this issue on Sep 18, 2026
    e80d901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugtriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions