Skip to content

Commit 463bb82

Browse files
authored
feat: shows initial user message as prompt upon being invoked with inital query (#678)
1 parent 3d7318b commit 463bb82

File tree

1 file changed

+15
-4
lines changed
  • crates/q_cli/src/cli/chat

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,13 @@ Hi, I'm <g>Amazon Q</g>. Ask me anything.
547547
.is_ok_and(|s| !s.is_empty() && !queued_tools.is_empty())
548548
|| queued_tools.iter().all(|tool| !tool.1.requires_consent(&self.ctx));
549549

550-
let user_input = match self.initial_input.take() {
551-
Some(input) => input,
550+
let (user_input, is_initial_input) = match self.initial_input.take() {
551+
Some(input) => (input, true),
552552
None => match (skip_consent, queued_tools.is_empty()) {
553553
// Skip prompting the user if consent is not required.
554554
// TODO(bskiser): we should not set user input here so we can potentially have telemetry distinguish
555555
// between tool uses that the user accepts vs automatically consents to.
556-
(true, false) => "y".to_string(),
556+
(true, false) => ("y".to_string(), false),
557557
// Otherwise, read input.
558558
_ => {
559559
if !queued_tools.is_empty() {
@@ -577,7 +577,7 @@ Hi, I'm <g>Amazon Q</g>. Ask me anything.
577577
)?;
578578
}
579579
match self.input_source.read_line(Some("> "))? {
580-
Some(line) => line,
580+
Some(line) => (line, false),
581581
None => return Ok(None),
582582
}
583583
},
@@ -701,6 +701,17 @@ Hi, I'm <g>Amazon Q</g>. Ask me anything.
701701
_ => {
702702
self.tool_use_recursions = 0;
703703

704+
if is_initial_input {
705+
queue!(
706+
self.output,
707+
style::SetForegroundColor(Color::Magenta),
708+
style::Print("> "),
709+
style::SetAttribute(Attribute::Reset),
710+
style::Print(&user_input),
711+
style::Print("\n")
712+
)?;
713+
}
714+
704715
if self.is_interactive {
705716
queue!(self.output, style::SetForegroundColor(Color::Magenta))?;
706717
if user_input.contains("@history") {

0 commit comments

Comments
 (0)