Skip to content

fix(tui): avoid false prompt queueing from credits-only rate-limit state#6

Merged
Loongphy merged 1 commit into
Loongphy:mainfrom
xPokerr:codex/fix-rate-limit-queueing
Jun 1, 2026
Merged

fix(tui): avoid false prompt queueing from credits-only rate-limit state#6
Loongphy merged 1 commit into
Loongphy:mainfrom
xPokerr:codex/fix-rate-limit-queueing

Conversation

@xPokerr
Copy link
Copy Markdown

@xPokerr xPokerr commented May 31, 2026

fix(tui): avoid false prompt queueing from credits-only rate-limit state

Summary

Fixes a TUI regression where prompt submissions could be queued indefinitely even though the account still had available Codex usage.

The bug came from treating a missing separate credits balance as a hard quota exhaustion signal. That was too strict: credits.has_credits == false does not necessarily mean the active Codex usage windows are exhausted.

Fixes #5.

Root cause

In codex-rs/tui/src/chatwidget/rate_limits.rs, rate_limit_snapshot_has_exhausted_quota() treated this state as exhausted quota:

credits.has_credits == false && !credits.unlimited

That conflated two different concepts:

  • normal Codex usage quota from the primary and secondary rate-limit windows
  • a separate credits balance that may be unavailable without blocking normal model usage

When that false exhaustion state was detected, the TUI enabled queue suppression and stopped autosending queued prompts.

What changed

  • remove the credits-only exhaustion check from rate_limit_snapshot_has_exhausted_quota()
  • pause queue autosend only when the snapshot reports an actual hard limit:
    • rate_limit_reached_type explicitly indicates a rate, usage, or credits limit
    • a primary or secondary usage window reports used_percent >= 100
  • when a fresh Codex snapshot reports available quota again:
    • clear stale codex_rate_limit_reached_type
    • clear input_queue.suppress_queue_autosend
    • disable composer queue mode
    • autosend the next queued message if queue suppression had previously been active

User-visible behavior

Before:

  • pressing Enter could queue a normal prompt instead of sending it immediately
  • the queued prompt could remain stuck indefinitely

After:

  • normal prompts submit immediately when Codex usage windows still have capacity
  • queue suppression only activates on real quota exhaustion
  • stale queue suppression is cleared once a healthy Codex snapshot arrives
  • normal follow-up queueing during an active turn is unchanged

Scope

This patch is limited to:

  • codex-rs/tui/src/chatwidget/rate_limits.rs

Validation

  • cargo build -p codex-cli
  • cargo build -p codex-cli --release

@xPokerr xPokerr marked this pull request as ready for review May 31, 2026 14:41
@Loongphy Loongphy merged commit 8846a85 into Loongphy:main Jun 1, 2026
@xPokerr xPokerr deleted the codex/fix-rate-limit-queueing branch June 1, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Queued follow-up inputs ? can't send direct prompt, only queued messages which will not be processed.

2 participants