Skip to content

Conversation

aibrahim-oai
Copy link
Collaborator

No description provided.

@aibrahim-oai aibrahim-oai changed the base branch from main to warning September 22, 2025 18:36
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 suggestions.

#[test]
fn rate_limit_warnings_emit_thresholds() {
let mut state = RateLimitWarningState::default();
let mut warnings: Vec<String> = Vec::new();
warnings.extend(state.take_warnings(10.0, 55.0));
warnings.extend(state.take_warnings(55.0, 10.0));
warnings.extend(state.take_warnings(10.0, 80.0));
warnings.extend(state.take_warnings(80.0, 10.0));
warnings.extend(state.take_warnings(10.0, 95.0));
warnings.extend(state.take_warnings(95.0, 10.0));
assert_eq!(
warnings.len(),
6,
"expected one warning per threshold per limit"
);
assert!(
warnings
.iter()
.any(|w| w.contains("Hourly usage exceeded 50%")),
"expected hourly 50% warning"
);
assert!(
warnings
.iter()
.any(|w| w.contains("Weekly usage exceeded 50%")),
"expected weekly 50% warning"
);
assert!(
warnings
.iter()
.any(|w| w.contains("Hourly usage exceeded 90%")),
"expected hourly 90% warning"
);
assert!(
warnings
.iter()
.any(|w| w.contains("Weekly usage exceeded 90%")),

[P1] Adjust warning tests for new rate-limit messages

The warning text was rephrased to "Heads up, you've used over …" in RateLimitWarningState, but the unit test still asserts that the warnings contain substrings such as "Hourly usage exceeded 50%" and "Weekly usage exceeded 50%". With the new wording none of these substrings appear, so rate_limit_warnings_emit_thresholds will now fail even when the runtime behaviour is correct. The test expectations should be updated to match the new messages or to check the thresholds in a wording-agnostic way.


Reply with @codex fix comments to fix any unresolved comments.

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, or 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 fix this CI failure" or "@codex address that feedback".

Comment on lines 487 to 494
fn parse_rate_limit_snapshot(headers: &HeaderMap) -> Option<RateLimitSnapshotEvent> {
let primary_used_percent = parse_header_f64(headers, "x-codex-primary-used-percent")?;
let weekly_used_percent = parse_header_f64(headers, "x-codex-protection-used-percent")?;
let primary_to_weekly_ratio_percent =
parse_header_f64(headers, "x-codex-primary-over-protection-limit-percent")?;
let secondary_used_percent = parse_header_f64(headers, "x-codex-secondry-used-percent")?;
let primary_to_secondary_ratio_percent =
parse_header_f64(headers, "x-codex-primary-over-secondry-limit-percent")?;
let primary_window_minutes = parse_header_u64(headers, "x-codex-primary-window-minutes")?;
let weekly_window_minutes = parse_header_u64(headers, "x-codex-protection-window-minutes")?;
let secondary_window_minutes = parse_header_u64(headers, "x-codex-secondry-window-minutes")?;
Copy link
Contributor

Choose a reason for hiding this comment

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

[P1] Use correct HTTP header names when parsing secondary limits

The new rate‑limit parsing still looks for headers named x-codex-secondry-* in several places. Given that the struct and surrounding code consistently use the fully spelled term “secondary”, these typos will fail to match the actual x-codex-secondary-* headers emitted by the server, and parse_rate_limit_snapshot will always return None. Downstream consumers (warning messages, TUI status) will silently lose rate‑limit information.

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.

will fix on the api side first.

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-core
  • just fix -p codex-tui
  • USER=root cargo test -p codex-core
  • cargo test -p codex-tui

View task →

Base automatically changed from warning to main September 22, 2025 18:52
@aibrahim-oai aibrahim-oai enabled auto-merge (squash) September 22, 2025 18:57
@aibrahim-oai aibrahim-oai enabled auto-merge (squash) September 22, 2025 21:02
@aibrahim-oai aibrahim-oai merged commit dd56750 into main Sep 22, 2025
19 checks passed
@aibrahim-oai aibrahim-oai deleted the change-headers branch September 22, 2025 21:06
@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 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.

2 participants