-
Notifications
You must be signed in to change notification settings - Fork 67
Ask for confirmation before clearing chat history #1180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1180 +/- ##
==========================================
+ Coverage 13.46% 13.98% +0.51%
==========================================
Files 2346 2364 +18
Lines 201210 204636 +3426
Branches 181574 185000 +3426
==========================================
+ Hits 27091 28611 +1520
- Misses 172822 174620 +1798
- Partials 1297 1405 +108 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
crates/q_cli/src/cli/chat/mod.rs
Outdated
execute!( | ||
self.output, | ||
style::Print(format!( | ||
"\n(To exit, press Ctrl+C or Ctrl+D again or type {})\n\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely shouldn't duplicate this - if anything, add an extra parameter to the ChatState::HandleInput
enum stating we are in the middle of clearing state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
28ac80f
to
37cf67a
Compare
crates/q_cli/src/cli/chat/mod.rs
Outdated
execute!( | ||
self.output, | ||
style::SetForegroundColor(Color::Red), | ||
style::Print(format!("\nError using tools: {}\n\n", e)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message doesn't make much sense imo, this is just prompting the user regardless of whether or not tools are being presented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
crates/q_cli/src/cli/chat/mod.rs
Outdated
@@ -2141,6 +2162,41 @@ where | |||
Ok(()) | |||
} | |||
|
|||
/// Helper function to read user input with a prompt and Ctrl+C handling | |||
fn read_user_input(&mut self, prompt: &str) -> Result<String, ChatError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this logic would just bubble up errors or return an exit state, so now we have to handle errors when instead it would be nicer to just have:
let input = match self.read_user_input(...)? {
Some(input) => input,
None => return ChatState::Exit
}
Prevents us from now handling errors verbosely in multiple locations.
Essentially change this to return a Result<Option<String>, ChatError>
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! This is much cleaner now
14c84ec
to
a9283a7
Compare
123414a
to
02939ea
Compare
02939ea
to
63f853d
Compare
Sometimes users may habitually type
/clear
to clean the console output but inq chat
, this actually erase chat history.Adding a confirmation dialog to prevent mistakes.
Screen.Recording.2025-04-10.at.4.10.38.PM.mov