Skip to content

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearHands-off: unambiguous bug, obvious fix, no decisions. Don't even look - an agent can fully solve.bugSomething isn't workingtriage: reproducibleClear repro + clear fix path

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions