Skip to content

Commit e7ed28f

Browse files
authored
UX Fix for hard to distinguish between user and assistant responses (#130)
1 parent e870e74 commit e7ed28f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,10 +1369,9 @@ impl ChatContext {
13691369
self.send_tool_use_telemetry(telemetry).await;
13701370

13711371
if self.interactive {
1372-
queue!(self.output, style::SetForegroundColor(Color::Magenta))?;
1373-
queue!(self.output, style::SetForegroundColor(Color::Reset))?;
1372+
// Print newlines before starting the assistant response
1373+
execute!(self.output, style::Print("\n\n"))?;
13741374
queue!(self.output, cursor::Hide)?;
1375-
execute!(self.output, style::Print("\n"))?;
13761375
self.spinner = Some(Spinner::new(Spinners::Dots, "Thinking...".to_owned()));
13771376
}
13781377

@@ -3207,6 +3206,18 @@ impl ChatContext {
32073206
)?;
32083207
}
32093208

3209+
// Add assistant indicator at the beginning of the response
3210+
if self.interactive {
3211+
queue!(
3212+
self.output,
3213+
style::SetForegroundColor(Color::Yellow),
3214+
style::SetAttribute(Attribute::Bold),
3215+
style::Print("Amazon Q > "),
3216+
style::SetAttribute(Attribute::Reset),
3217+
style::SetForegroundColor(Color::Reset),
3218+
)?;
3219+
}
3220+
32103221
loop {
32113222
match parser.recv().await {
32123223
Ok(msg_event) => {

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn generate_prompt(current_profile: Option<&str>, warning: bool) -> String {
8787
.map(|p| format!("[{p}] ").cyan().to_string())
8888
.unwrap_or_default();
8989

90-
format!("{profile_part}{warning_symbol}{}", "> ".magenta())
90+
format!("{profile_part}{warning_symbol}{}", "> ".cyan().bold())
9191
}
9292

9393
/// Complete commands that start with a slash
@@ -310,20 +310,23 @@ mod tests {
310310
#[test]
311311
fn test_generate_prompt() {
312312
// Test default prompt (no profile)
313-
assert_eq!(generate_prompt(None, false), "> ".magenta().to_string());
313+
assert_eq!(generate_prompt(None, false), "> ".cyan().bold().to_string());
314314
// Test default prompt with warning
315-
assert_eq!(generate_prompt(None, true), format!("{}{}", "!".red(), "> ".magenta()));
315+
assert_eq!(
316+
generate_prompt(None, true),
317+
format!("{}{}", "!".red(), "> ".cyan().bold())
318+
);
316319
// Test default profile (should be same as no profile)
317-
assert_eq!(generate_prompt(Some("default"), false), "> ".magenta().to_string());
320+
assert_eq!(generate_prompt(Some("default"), false), "> ".cyan().bold().to_string());
318321
// Test custom profile
319322
assert_eq!(
320323
generate_prompt(Some("test-profile"), false),
321-
format!("{}{}", "[test-profile] ".cyan(), "> ".magenta())
324+
format!("{}{}", "[test-profile] ".cyan(), "> ".cyan().bold())
322325
);
323326
// Test another custom profile with warning
324327
assert_eq!(
325328
generate_prompt(Some("dev"), true),
326-
format!("{}{}{}", "[dev] ".cyan(), "!".red(), "> ".magenta())
329+
format!("{}{}{}", "[dev] ".cyan(), "!".red(), "> ".cyan().bold())
327330
);
328331
}
329332

0 commit comments

Comments
 (0)