From 51381d1c88a759a6bf4ca17743ca71b2844b8320 Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 9 Jul 2026 13:48:23 -0700 Subject: [PATCH] Prevent queued reset confirmations --- codex-rs/tui/src/chatwidget/tests/usage.rs | 23 ++-------------------- codex-rs/tui/src/chatwidget/usage.rs | 3 ++- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/codex-rs/tui/src/chatwidget/tests/usage.rs b/codex-rs/tui/src/chatwidget/tests/usage.rs index 06bc142670..82c201764e 100644 --- a/codex-rs/tui/src/chatwidget/tests/usage.rs +++ b/codex-rs/tui/src/chatwidget/tests/usage.rs @@ -515,7 +515,7 @@ async fn rate_limit_reset_confirmation_no_and_escape_return_to_picker() { } #[tokio::test] -async fn rejected_reset_confirmation_rearms_its_picker_row() { +async fn reset_picker_allows_only_one_pending_confirmation() { let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; let request_id = chat.show_rate_limit_reset_loading_popup(); let first_expiry = expiry_timestamp(/*day*/ 18, /*hour*/ 9, /*minute*/ 39); @@ -536,26 +536,7 @@ async fn rejected_reset_confirmation_rearms_its_picker_row() { chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE)); show_rate_limit_reset_confirmation_from_event(&mut chat, &mut rx); - let Ok(AppEvent::OpenRateLimitResetConfirmation { - picker_request_id, - confirmation_gate, - credit_id, - reset_title, - reset_detail, - reset_description, - }) = rx.try_recv() - else { - panic!("expected second reset confirmation event"); - }; - assert_eq!(reset_title, "Second reset"); - assert!(!chat.show_rate_limit_reset_confirmation( - picker_request_id, - confirmation_gate, - credit_id, - reset_title, - reset_detail, - reset_description, - )); + assert!(rx.try_recv().is_err()); chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE)); chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE)); diff --git a/codex-rs/tui/src/chatwidget/usage.rs b/codex-rs/tui/src/chatwidget/usage.rs index fdb0131108..bd7a2f434e 100644 --- a/codex-rs/tui/src/chatwidget/usage.rs +++ b/codex-rs/tui/src/chatwidget/usage.rs @@ -169,10 +169,11 @@ impl ChatWidget { picker_request_id: u64, reset_credits: &RateLimitResetCreditsSummary, ) -> SelectionViewParams { + let confirmation_gate = Arc::new(AtomicBool::new(true)); let mut items = reset_credit_options(reset_credits) .into_iter() .map(|option| { - let confirmation_gate = Arc::new(AtomicBool::new(true)); + let confirmation_gate = confirmation_gate.clone(); let credit_id = option.credit_id; let reset_title = option.name.clone(); let reset_detail = option.detail;