Skip to content

[BUG] TUI renders phantom quota 100% for disabled zero-minute secondary window #194

Description

@aic0d3r

Bug Description

The OpenCode TUI status renders a phantom quota 100% segment when OpenAI returns a disabled secondary quota window with window-minutes: 0 and used-percent: 0.

The real primary weekly value is displayed correctly, but the disabled secondary window is also included and formatted as a generic quota limit.

Example status:

7d 77% · quota 100%

Steps to Reproduce

  1. Use a paid Team workspace whose Codex response headers include a weekly primary window and a disabled secondary window:
x-codex-primary-used-percent: 23
x-codex-primary-window-minutes: 10080
x-codex-secondary-used-percent: 0
x-codex-secondary-window-minutes: 0
x-codex-secondary-reset-at:
x-codex-secondary-reset-after-seconds: 0
  1. Send a successful Codex request through the plugin.
  2. Observe the OpenCode TUI status line.
  3. Inspect ~/.local/state/opencode/oc-codex-multi-auth-tui-quota.json.

The generated cache includes:

{
  "label": "quota",
  "leftPercent": 100,
  "usedPercent": 0,
  "windowMinutes": 0
}

Deleting the cache does not resolve the issue; the clean v6.7.1 runtime recreates the same entry from subsequent response headers.

Expected Behavior

A secondary window explicitly reported with window-minutes: 0 should be treated as disabled and omitted from the TUI quota display. Only the real weekly limit should appear:

7d 77%

Actual Behavior

The TUI displays:

7d 77% · quota 100%

Environment

  • opencode version: 1.17.19
  • Plugin version: 6.7.1 (clean install; no local patches loaded)
  • Operating System: Linux
  • Node.js version: v24.3.0
  • Plan: paid Team

Possible Cause

In lib/tui-quota-cache.ts, parseLimit() formats a non-positive/absent window as quota. hasUsefulLimit() then retains it because usedPercent is numeric even when windowMinutes === 0:

return Boolean(
  limit.windowMinutes ||
  typeof limit.usedPercent === "number" ||
  typeof limit.resetAtMs === "number"
)

A narrow fix may be to reject a limit when windowMinutes === 0, while preserving generic limits where the window header is genuinely absent.

Logs

No raw request logs attached because they contain unrelated response metadata. The relevant sanitized x-codex-* fields are included above.

Compliance Checklist

  • I'm using this plugin for personal development only
  • I have an active paid ChatGPT Team subscription (Team equivalent; template says Plus/Pro)
  • This issue is not related to attempting commercial use or TOS violations
  • I've reviewed the FAQ and Troubleshooting sections

Additional Context

The server usage endpoint reports the real weekly allowance correctly. This issue is limited to parsing/rendering the disabled secondary header window in the TUI status cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions