From 355eac044a8fc999b76f0f1cb52d26716443d4d2 Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Wed, 4 Dec 2024 16:43:45 -0500 Subject: [PATCH 1/4] fix: Don't do anything with an empty command --- crates/goose-cli/src/session.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/goose-cli/src/session.rs b/crates/goose-cli/src/session.rs index c600cd910..c82898298 100644 --- a/crates/goose-cli/src/session.rs +++ b/crates/goose-cli/src/session.rs @@ -107,6 +107,9 @@ impl<'a> Session<'a> { match input.input_type { InputType::Message => { if let Some(content) = &input.content { + if content.trim().is_empty() { + continue; + } self.messages.push(Message::user().with_text(content)); persist_messages(&self.session_file, &self.messages)?; } From 77bff6d8660b4870da8be0622a515bd5bf21ad1f Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Thu, 5 Dec 2024 15:48:43 -0500 Subject: [PATCH 2/4] Handle this in the right place --- crates/goose-cli/src/prompt/rustyline.rs | 8 +++++++- crates/goose-cli/src/session.rs | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/goose-cli/src/prompt/rustyline.rs b/crates/goose-cli/src/prompt/rustyline.rs index 9305b61a4..aabb4b8e0 100644 --- a/crates/goose-cli/src/prompt/rustyline.rs +++ b/crates/goose-cli/src/prompt/rustyline.rs @@ -316,7 +316,13 @@ impl Prompt for RustylinePrompt { }; message_text = message_text.trim().to_string(); - if message_text.eq_ignore_ascii_case("/exit") || message_text.eq_ignore_ascii_case("/quit") + if message_text.is_empty() { + return Ok(Input { + input_type: InputType::AskAgain, + content: None, + }); + } else if message_text.eq_ignore_ascii_case("/exit") + || message_text.eq_ignore_ascii_case("/quit") { Ok(Input { input_type: InputType::Exit, diff --git a/crates/goose-cli/src/session.rs b/crates/goose-cli/src/session.rs index c82898298..c600cd910 100644 --- a/crates/goose-cli/src/session.rs +++ b/crates/goose-cli/src/session.rs @@ -107,9 +107,6 @@ impl<'a> Session<'a> { match input.input_type { InputType::Message => { if let Some(content) = &input.content { - if content.trim().is_empty() { - continue; - } self.messages.push(Message::user().with_text(content)); persist_messages(&self.session_file, &self.messages)?; } From ddab5775e538d64b3cca532d3f89fc56ddab652c Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Thu, 5 Dec 2024 15:51:27 -0500 Subject: [PATCH 3/4] Don't treat EOF as an error --- crates/goose-cli/src/prompt/rustyline.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/goose-cli/src/prompt/rustyline.rs b/crates/goose-cli/src/prompt/rustyline.rs index aabb4b8e0..cbf343f2f 100644 --- a/crates/goose-cli/src/prompt/rustyline.rs +++ b/crates/goose-cli/src/prompt/rustyline.rs @@ -306,6 +306,7 @@ impl Prompt for RustylinePrompt { Err(e) => { match e { rustyline::error::ReadlineError::Interrupted => (), + rustyline::error::ReadlineError::Eof => (), _ => eprintln!("Input error: {}", e), } return Ok(Input { From fcaca531e10961f8a2105f535fff0be54d48c89c Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Thu, 5 Dec 2024 15:55:56 -0500 Subject: [PATCH 4/4] Use the expression --- crates/goose-cli/src/prompt/rustyline.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/goose-cli/src/prompt/rustyline.rs b/crates/goose-cli/src/prompt/rustyline.rs index cbf343f2f..01e102e30 100644 --- a/crates/goose-cli/src/prompt/rustyline.rs +++ b/crates/goose-cli/src/prompt/rustyline.rs @@ -318,10 +318,10 @@ impl Prompt for RustylinePrompt { message_text = message_text.trim().to_string(); if message_text.is_empty() { - return Ok(Input { + Ok(Input { input_type: InputType::AskAgain, content: None, - }); + }) } else if message_text.eq_ignore_ascii_case("/exit") || message_text.eq_ignore_ascii_case("/quit") {