Prevent queued reset confirmations

This commit is contained in:
jay
2026-07-09 13:48:23 -07:00
parent 4c18e632ce
commit 51381d1c88
2 changed files with 4 additions and 22 deletions
+2 -21
View File
@@ -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));
+2 -1
View File
@@ -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;