Handle Ctrl+C quit when idle (#1402)

## Summary
- show `Ctrl+C to quit` hint when pressing Ctrl+C with no active task
- exiting with Ctrl+C if the hint is already visible
- clear the hint when tasks begin or other keys are pressed


https://github.com/user-attachments/assets/931e2d7c-1c80-4b45-9908-d119f74df23c



------
https://chatgpt.com/s/cd_685ec8875a308191beaa95886dc1379e

Fixes #1245
This commit is contained in:
Gabriel Peal
2025-06-27 13:37:11 -04:00
committed by GitHub
parent 64feeb3803
commit 2e293ce903
4 changed files with 65 additions and 7 deletions

View File

@@ -37,6 +37,7 @@ pub(crate) struct BottomPane<'a> {
app_event_tx: AppEventSender,
has_input_focus: bool,
is_task_running: bool,
ctrl_c_quit_hint: bool,
}
pub(crate) struct BottomPaneParams {
@@ -52,6 +53,7 @@ impl BottomPane<'_> {
app_event_tx: params.app_event_tx,
has_input_focus: params.has_input_focus,
is_task_running: false,
ctrl_c_quit_hint: false,
}
}
@@ -100,6 +102,26 @@ impl BottomPane<'_> {
self.composer.set_input_focus(has_focus);
}
pub(crate) fn show_ctrl_c_quit_hint(&mut self) {
self.ctrl_c_quit_hint = true;
self.composer
.set_ctrl_c_quit_hint(true, self.has_input_focus);
self.request_redraw();
}
pub(crate) fn clear_ctrl_c_quit_hint(&mut self) {
if self.ctrl_c_quit_hint {
self.ctrl_c_quit_hint = false;
self.composer
.set_ctrl_c_quit_hint(false, self.has_input_focus);
self.request_redraw();
}
}
pub(crate) fn ctrl_c_quit_hint_visible(&self) -> bool {
self.ctrl_c_quit_hint
}
pub fn set_task_running(&mut self, running: bool) {
self.is_task_running = running;
@@ -130,6 +152,10 @@ impl BottomPane<'_> {
}
}
pub(crate) fn is_task_running(&self) -> bool {
self.is_task_running
}
/// Update the *context-window remaining* indicator in the composer. This
/// is forwarded directly to the underlying `ChatComposer`.
pub(crate) fn set_token_usage(