Skip to content

Commit cf1350a

Browse files
committed
feat: save transcript checkpoints at additional points
Save transcript state when: - User cancels a request (ESC during streaming) - Waiting for tool approval (before user input) - Agent encounters an error This ensures transcript progress is preserved even when the agent doesn't complete its turn normally.
1 parent 8a2fe2f commit cf1350a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/app.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ impl App {
626626
agent_mutex.lock().await.cancel();
627627
}
628628
self.chat.finish_turn(&mut self.terminal);
629+
if let Err(e) = self.chat.transcript.save() {
630+
tracing::error!("Failed to save transcript on cancel: {}", e);
631+
}
629632
self.input_mode = InputMode::Normal;
630633
Ok(())
631634
}
@@ -818,6 +821,9 @@ impl App {
818821
},
819822
AgentStep::Error(msg) => {
820823
self.chat.transcript.mark_active_block(Status::Error);
824+
if let Err(e) = self.chat.transcript.save() {
825+
tracing::error!("Failed to save transcript on error: {}", e);
826+
}
821827
self.input_mode = InputMode::Normal;
822828

823829
let alert_msg = if let Some(start) = msg.find('{') {
@@ -910,7 +916,10 @@ impl App {
910916
self.decide_pending_tool(decision).await;
911917
},
912918
None => {
913-
// Ask user for approval
919+
// Ask user for approval - save transcript checkpoint while waiting
920+
if let Err(e) = self.chat.transcript.save() {
921+
tracing::error!("Failed to save transcript before tool approval: {}", e);
922+
}
914923
self.input_mode = InputMode::ToolApproval;
915924
},
916925
}

0 commit comments

Comments
 (0)