Keep interrupted prompts in conversation history (#33198)

## What changed

- Leave an output-free interrupted prompt in the transcript and open a blank
  composer for the user's next instruction.
- Use the normal interruption notice for both `Esc` and `Ctrl-C` interrupts.
- Track safety-buffering prompts separately so failed retries can still restore
  the prompt, including after switching between threads.

## Testing

- Cover output-free `Esc` and `Ctrl-C` interrupts, failed safety-buffer retries,
  and restoration of safety-buffer state from thread snapshots.

GitOrigin-RevId: 30b368d00dfdb981d06d4c95ce3f252389b7917c
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-07-15 01:07:29 +00:00
1 parent 4df8027a97
commit 70a0b1eef8
29 files changed
+186 -269

No files matched your search

-33
View File
@@ -31,7 +31,6 @@ use std::sync::Arc;
use crate::app::App;
use crate::app_command::AppCommand;
use crate::app_event::AppEvent;
use crate::chatwidget::UserMessage;
#[cfg(test)]
use crate::history_cell::AgentMessageCell;
use crate::history_cell::SessionInfoCell;
@@ -239,38 +238,6 @@ impl App {
}
}
pub(crate) fn apply_cancelled_turn_edit(&mut self, prompt: UserMessage) {
let user_total = user_count(&self.transcript_cells);
let selection = BacktrackSelection {
nth_user_message: user_total.saturating_sub(1),
prefill: prompt.text.clone(),
text_elements: prompt.text_elements.clone(),
local_image_paths: prompt
.local_images
.iter()
.map(|image| image.path.clone())
.collect(),
remote_image_urls: prompt.remote_image_urls.clone(),
};
if user_total == 0 {
if self.backtrack.pending_rollback.is_some() {
self.chat_widget
.add_error_message("Backtrack rollback already in progress.".to_string());
return;
}
self.backtrack.pending_rollback = Some(PendingBacktrackRollback {
selection,
thread_id: self.chat_widget.thread_id(),
});
self.chat_widget
.submit_op(AppCommand::thread_rollback(/*num_turns*/ 1));
self.chat_widget.restore_user_message_to_composer(prompt);
return;
}
self.apply_backtrack_rollback(selection);
self.chat_widget.restore_user_message_to_composer(prompt);
}
/// Open transcript overlay (enters alternate screen and shows full transcript).
pub(crate) fn open_transcript_overlay(&mut self, tui: &mut tui::Tui) {
let _ = tui.enter_alt_screen();