Tui: Rate limits (#3977)

### /limits: show rate limits graph

<img width="442" height="287" alt="image"
src="https://github.com/user-attachments/assets/3e29a241-a4b0-4df8-bf71-43dc4dd805ca"
/>

### Warning on close to rate limits:

<img width="507" height="96" alt="image"
src="https://github.com/user-attachments/assets/732a958b-d240-4a89-8289-caa92de83537"
/>

Based on #3965
This commit is contained in:
Ahmed Ibrahim authored and GitHub committed 2025-09-21 10:20:49 -07:00
1 parent 04504d8218
commit a4ebd069e5
11 files changed
+910 -1

No files matched your search

@@ -0,0 +1,10 @@
---
source: tui/src/chatwidget/tests.rs
expression: visual
---
[magenta]/limits[/]
[bold]Rate limit usage snapshot[/]
[dim] Tip: run `/limits` right after Codex replies for freshest numbers.[/]
Real usage data is not available yet.
[dim] Send a message to Codex, then run /limits again.[/]
@@ -0,0 +1,29 @@
---
source: tui/src/chatwidget/tests.rs
expression: visual
---
[magenta]/limits[/]
[bold]Rate limit usage snapshot[/]
[dim] Tip: run `/limits` right after Codex replies for freshest numbers.[/]
• Hourly limit[dim] (≈5 hours window)[/]: [dark-gray+bold]30.0% used[/]
• Weekly limit[dim] (≈1 week window)[/]: [dark-gray+bold]60.0% used[/]
[green] Within current limits[/]
[dim] ╭─────────────────────────────────────────────────╮[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/][dim]│[/]
[dim]│[/][green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/][dim]│[/]
[dim]│[/][green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim] ╰─────────────────────────────────────────────────╯[/]
[bold]Legend[/]
• [dark-gray+bold]Dark gray[/] = weekly usage so far
• [green+bold]Green[/] = hourly capacity still available
• [bold]Default[/] = weekly capacity beyond the hourly window
@@ -0,0 +1,29 @@
---
source: tui/src/chatwidget/tests.rs
expression: visual
---
[magenta]/limits[/]
[bold]Rate limit usage snapshot[/]
[dim] Tip: run `/limits` right after Codex replies for freshest numbers.[/]
• Hourly limit[dim] (≈5 hours window)[/]: [dark-gray+bold]0.0% used[/]
• Weekly limit[dim] (≈1 week window)[/]: [dark-gray+bold]20.0% used[/]
[green] Within current limits[/]
[dim] ╭─────────────────────────────────────────────────╮[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/][dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim] ╰─────────────────────────────────────────────────╯[/]
[bold]Legend[/]
• [dark-gray+bold]Dark gray[/] = weekly usage so far
• [green+bold]Green[/] = hourly capacity still available
• [bold]Default[/] = weekly capacity beyond the hourly window
@@ -0,0 +1,29 @@
---
source: tui/src/chatwidget/tests.rs
expression: visual
---
[magenta]/limits[/]
[bold]Rate limit usage snapshot[/]
[dim] Tip: run `/limits` right after Codex replies for freshest numbers.[/]
• Hourly limit[dim] (≈5 hours window)[/]: [dark-gray+bold]20.0% used[/]
• Weekly limit[dim] (≈1 week window)[/]: [dark-gray+bold]20.0% used[/]
[green] Within current limits[/]
[dim] ╭─────────────────────────────────────────────────╮[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/] [dark-gray](>_)[/][dim]│[/]
[dim]│[/][green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] [green](>_)[/] (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim] ╰─────────────────────────────────────────────────╯[/]
[bold]Legend[/]
• [dark-gray+bold]Dark gray[/] = weekly usage so far
• [green+bold]Green[/] = hourly capacity still available
• [bold]Default[/] = weekly capacity beyond the hourly window
@@ -0,0 +1,29 @@
---
source: tui/src/chatwidget/tests.rs
expression: visual
---
[magenta]/limits[/]
[bold]Rate limit usage snapshot[/]
[dim] Tip: run `/limits` right after Codex replies for freshest numbers.[/]
• Hourly limit[dim] (≈5 hours window)[/]: [dark-gray+bold]98.0% used[/]
• Weekly limit[dim] (≈1 week window)[/]: [dark-gray+bold]0.0% used[/]
[green] Within current limits[/]
[dim] ╭─────────────────────────────────────────────────╮[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim]│[/](>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_) (>_)[dim]│[/]
[dim] ╰─────────────────────────────────────────────────╯[/]
[bold]Legend[/]
• [dark-gray+bold]Dark gray[/] = weekly usage so far
• [green+bold]Green[/] = hourly capacity still available
• [bold]Default[/] = weekly capacity beyond the hourly window