Skip to content

Commit 55053d5

Browse files
authored
fix(cli): Improve chat input handling and keyboard shortcut display (#1073)
- Add keyboard symbols (⌥, ⏎) to make shortcuts more recognizable - Handle empty line inputs by reprompting the user instead of processing
1 parent 6665ff4 commit 55053d5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

crates/q_cli/src/cli/chat/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const WELCOME_TEXT: &str = color_print::cstr! {"
102102
<em>/help</em> <black!>Show the help dialogue</black!>
103103
<em>/quit</em> <black!>Quit the application</black!>
104104
105-
<cyan!>Use Alt+Enter to provide multi-line prompts.</cyan!>
105+
<cyan!>Use Alt(⌥) + Enter(⏎) to provide multi-line prompts.</cyan!>
106106
107107
"};
108108

@@ -131,8 +131,8 @@ const HELP_TEXT: &str = color_print::cstr! {"
131131
<em>clear</em> <black!>Clear all files from current context [--global]</black!>
132132
133133
<cyan,em>Tips:</cyan,em>
134-
<em>!{command}</em> <black!>Quickly execute a command in your current session</black!>
135-
<em>Alt+Enter</em> <black!>Insert new-line to provide multi-line prompt. Alternatively, [Ctrl+j]</black!>
134+
<em>!{command}</em> <black!>Quickly execute a command in your current session</black!>
135+
<em>Alt(⌥) + Enter(⏎)</em> <black!>Insert new-line to provide multi-line prompt. Alternatively, [Ctrl+j]</black!>
136136
137137
"};
138138

@@ -573,7 +573,13 @@ where
573573
let prompt = prompt::generate_prompt(self.conversation_state.current_profile());
574574

575575
match (self.input_source.read_line(Some(&prompt))?, ctrl_c) {
576-
(Some(line), _) => break line,
576+
(Some(line), _) => {
577+
// Handle empty line case - reprompt the user
578+
if line.trim().is_empty() {
579+
continue;
580+
}
581+
break line;
582+
},
577583
(None, false) => {
578584
execute!(
579585
self.output,

crates/q_cli/src/cli/chat/prompt.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ impl Validator for MultiLineValidator {
167167
fn validate(&self, ctx: &mut ValidationContext<'_>) -> rustyline::Result<ValidationResult> {
168168
let input = ctx.input();
169169

170-
if input.trim().is_empty() {
171-
return Ok(ValidationResult::Incomplete);
172-
}
173-
174170
// Check for explicit multi-line markers
175171
if input.starts_with("```") && !input.ends_with("```") {
176172
return Ok(ValidationResult::Incomplete);

0 commit comments

Comments
 (0)