feat: Added an .undo command to the REPL to let users have more control over the conversation

This commit is contained in:
2026-07-15 16:23:59 -06:00
parent 6127d964ee
commit 4c7de650c0
3 changed files with 42 additions and 1 deletions
+9
View File
@@ -732,6 +732,15 @@ impl Session {
self.update_tokens();
}
pub fn pop_last_exchange(&mut self) -> Option<String> {
let user_idx = self.messages.iter().rposition(|m| m.role.is_user())?;
let user_text = self.messages[user_idx].content.as_text()?.to_string();
self.messages.truncate(user_idx);
self.dirty = true;
self.update_tokens();
Some(user_text)
}
pub fn echo_messages(&self, input: &Input) -> String {
let messages = self.build_messages(input);
serde_yaml::to_string(&messages).unwrap_or_else(|_| "Unable to echo message".into())