Skip to content

Conversation

@zhao-oai
Copy link
Collaborator

@zhao-oai zhao-oai commented Nov 17, 2025

fetching rate limits every minute asynchronously

@zhao-oai
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

@zhao-oai zhao-oai changed the title fetching rate limits when calling /status background rate limits fetch Nov 17, 2025
@zhao-oai
Copy link
Collaborator Author

@codex review

Copy link
Contributor

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

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.

ℹ️ 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 on lines 1763 to 1767
tokio::spawn(async move {
let mut interval = tokio::time::interval(Duration::from_secs(60));

loop {
if let Some(snapshot) = fetch_rate_limits(base_url.clone(), auth.clone()).await {
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge Cancel stale rate-limit pollers when creating new chat widgets

When a chat widget is constructed we now spawn a tokio task that loops forever fetching /usage snapshots, but the task is never tied to the widget’s lifetime or cancelled. If the user starts another session in the same TUI run (e.g. via AppEvent::NewSession), each new ChatWidget will add another infinite interval while the previous one keeps running, so /usage is hit multiple times per minute and RateLimitSnapshotFetched keeps firing with potentially stale auth. This stacks redundant network traffic and repeated UI updates until the process exits.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@codex can you check when this actually happens? then, implement a fix for this

Copy link
Contributor

Choose a reason for hiding this comment

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

Summary

Testing

  • just fmt
  • just fix -p codex-tui
  • cargo test -p codex-tui

View task →

@zhao-oai zhao-oai merged commit 4000e26 into main Nov 18, 2025
25 checks passed
@zhao-oai zhao-oai deleted the dev/zhao/fetch-updated-rate-limits branch November 18, 2025 00:06
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants