Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/chat-cli/src/cli/chat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2150,8 +2150,11 @@ impl ChatSession {
)
.await;

if matches!(chat_state, ChatState::Exit)
|| matches!(chat_state, ChatState::HandleResponseStream(_))
if matches!(chat_state, ChatState::Exit) {
std::process::exit(0);
}

if matches!(chat_state, ChatState::HandleResponseStream(_))
|| matches!(chat_state, ChatState::HandleInput { input: _ })
// TODO(bskiser): this is just a hotfix for handling state changes
// from manually running /compact, without impacting behavior of
Expand Down
21 changes: 19 additions & 2 deletions crates/chat-cli/src/cli/chat/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,27 @@ pub fn rl(
rl.set_helper(Some(h));

// Load history from CLI bash history file
if let Err(e) = rl.load_history(&rl.helper().unwrap().get_history_path()) {
if !matches!(e, ReadlineError::Io(ref io_err) if io_err.kind() == std::io::ErrorKind::NotFound) {
// Use a separate thread to prevent indefinite blocking on corrupted files
let history_path = rl.helper().unwrap().get_history_path();
let history_path_clone = history_path.clone();

let load_handle = std::thread::spawn(move || {
std::fs::read_to_string(&history_path_clone)
});

match load_handle.join() {
Ok(Ok(contents)) => {
for line in contents.lines() {
let _ = rl.add_history_entry(line);
}
}
Ok(Err(e)) if e.kind() != std::io::ErrorKind::NotFound => {
eprintln!("Warning: Failed to load history: {}", e);
}
Err(_) => {
eprintln!("Warning: History loading failed unexpectedly");
}
_ => {} // NotFound is expected on first run
}

// Add custom keybinding for Ctrl+D to open delegate command (configurable)
Expand Down