Move reset picker cancel action to the end

This commit is contained in:
jay
2026-07-08 11:21:29 -07:00
parent d02a810418
commit 4c18e632ce
4 changed files with 39 additions and 44 deletions
@@ -5,9 +5,9 @@ expression: "render_bottom_popup(&chat, 44)"
Usage limit resets
2 usage limit resets available.
› 1. Cancel
2. Full reset Expires 09:39 on 18 Jun
› 1. Full reset Expires 09:39 on 18 Jun
2026.
3. Full reset Does not expire.
2. Full reset Does not expire.
3. Cancel
Press enter to confirm or esc to go back
@@ -12,9 +12,9 @@ expression: "states.join(\"\\n---\\n\")"
Usage limit resets
2 usage limit resets available.
› 1. Cancel
2. Full reset (Weekly + 5 hr) Expires 09:39 on 18 Jun 2026.
3. Full reset (Weekly + 5 hr) Expires 08:59 on 27 Jun 2026.
› 1. Full reset (Weekly + 5 hr) Expires 09:39 on 18 Jun 2026.
2. Full reset (Weekly + 5 hr) Expires 08:59 on 27 Jun 2026.
3. Cancel
Press enter to confirm or esc to go back
---
+1 -5
View File
@@ -441,7 +441,6 @@ async fn rate_limit_reset_confirmation_uses_backend_copy_snapshot() {
vec![credit],
)),
));
chat.handle_key_event(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
let Ok(AppEvent::OpenRateLimitResetConfirmation {
@@ -495,7 +494,6 @@ async fn rate_limit_reset_confirmation_no_and_escape_return_to_picker() {
Vec::new(),
Ok(reset_credits(/*available_count*/ 1)),
));
chat.handle_key_event(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
let picker = render_bottom_popup(&chat, /*width*/ 80);
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
@@ -533,7 +531,6 @@ async fn rejected_reset_confirmation_rearms_its_picker_row() {
)),
));
chat.handle_key_event(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
@@ -594,7 +591,7 @@ async fn rate_limit_reset_picker_starts_with_soonest_expiries_and_keeps_all_rows
);
assert!(!rendered.contains("Full reset ("), "{rendered}");
for _ in 0..9 {
for _ in 0..8 {
chat.handle_key_event(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
}
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
@@ -629,7 +626,6 @@ async fn rate_limit_reset_confirmation_can_use_reset() {
)),
));
chat.handle_key_event(KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
show_rate_limit_reset_confirmation_from_event(&mut chat, &mut rx);
assert!(rx.try_recv().is_err());
+32 -33
View File
@@ -169,42 +169,41 @@ impl ChatWidget {
picker_request_id: u64,
reset_credits: &RateLimitResetCreditsSummary,
) -> SelectionViewParams {
let mut items = vec![SelectionItem {
let mut items = reset_credit_options(reset_credits)
.into_iter()
.map(|option| {
let confirmation_gate = Arc::new(AtomicBool::new(true));
let credit_id = option.credit_id;
let reset_title = option.name.clone();
let reset_detail = option.detail;
let reset_description = option.description;
let picker_description = reset_detail
.clone()
.unwrap_or_else(|| reset_description.clone());
SelectionItem {
name: option.name,
description: Some(picker_description),
actions: vec![Box::new(move |tx| {
if confirmation_gate.swap(false, Ordering::AcqRel) {
tx.send(AppEvent::OpenRateLimitResetConfirmation {
picker_request_id,
confirmation_gate: confirmation_gate.clone(),
credit_id: credit_id.clone(),
reset_title: reset_title.clone(),
reset_detail: reset_detail.clone(),
reset_description: reset_description.clone(),
});
}
})],
..Default::default()
}
})
.collect::<Vec<_>>();
items.push(SelectionItem {
name: "Cancel".to_string(),
dismiss_on_select: true,
..Default::default()
}];
items.extend(
reset_credit_options(reset_credits)
.into_iter()
.map(|option| {
let confirmation_gate = Arc::new(AtomicBool::new(true));
let credit_id = option.credit_id;
let reset_title = option.name.clone();
let reset_detail = option.detail;
let reset_description = option.description;
let picker_description = reset_detail
.clone()
.unwrap_or_else(|| reset_description.clone());
SelectionItem {
name: option.name,
description: Some(picker_description),
actions: vec![Box::new(move |tx| {
if confirmation_gate.swap(false, Ordering::AcqRel) {
tx.send(AppEvent::OpenRateLimitResetConfirmation {
picker_request_id,
confirmation_gate: confirmation_gate.clone(),
credit_id: credit_id.clone(),
reset_title: reset_title.clone(),
reset_detail: reset_detail.clone(),
reset_description: reset_description.clone(),
});
}
})],
..Default::default()
}
}),
);
});
SelectionViewParams {
view_id: Some(RATE_LIMIT_RESET_VIEW_ID),
title: Some("Usage limit resets".to_string()),