From 4d9399f737eb29236732da4fdb4ad24eb8844ef2 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Thu, 22 Jan 2026 10:18:15 +0530 Subject: [PATCH] fix(cli): use '> ' as readline prompt when project active Previously used empty string as readline prompt after printing colored prefix, which caused cursor positioning issues (large gap between project name and cursor). Now the prefix contains 'butler | finances' (colored) and readline gets '> ' as its prompt, so cursor appears immediately after '> '. --- crates/g3-cli/src/interactive.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/g3-cli/src/interactive.rs b/crates/g3-cli/src/interactive.rs index 4dba1e9..fb735ab 100644 --- a/crates/g3-cli/src/interactive.rs +++ b/crates/g3-cli/src/interactive.rs @@ -38,15 +38,15 @@ pub fn build_prompt(in_multiline: bool, agent_name: Option<&str>, active_project .file_name() .and_then(|n| n.to_str()) .unwrap_or("project"); - // Return colored prefix to print, and plain prompt for readline + // Return colored prefix (without "> "), and "> " as the readline prompt let prefix = format!( - "{} {}| {}>{} ", + "{} {}| {}{}", base_name, SetForegroundColor(Color::Blue), project_name, ResetColor ); - (prefix, String::new()) + (prefix, "> ".to_string()) } else { (String::new(), format!("{}> ", base_name)) } @@ -377,11 +377,11 @@ mod tests { fn test_build_prompt_with_project() { let project = Some(create_test_project("myapp")); let (prefix, prompt) = build_prompt(false, None, &project); - // Project name should be in the colored prefix, prompt should be empty + // Project name should be in the colored prefix, prompt should be "> " assert!(prefix.contains("g3")); assert!(prefix.contains("myapp")); assert!(prefix.contains("|")); - assert!(prompt.is_empty()); + assert_eq!(prompt, "> "); } #[test] @@ -392,7 +392,7 @@ mod tests { assert!(prefix.contains("carmack")); assert!(prefix.contains("myapp")); assert!(prefix.contains("|")); - assert!(prompt.is_empty()); + assert_eq!(prompt, "> "); } #[test] @@ -418,7 +418,7 @@ mod tests { }); let (prefix, prompt) = build_prompt(false, None, &project); assert!(prefix.contains("awesome-app")); - assert!(prompt.is_empty()); + assert_eq!(prompt, "> "); } }