Skip to content

Commit d705b33

Browse files
authored
feat(cli): improve context file display (#983)
- Always show context file count regardless of expand flag - Let users know that no files are currently being added to context
1 parent 1b29eb7 commit d705b33

File tree

1 file changed

+38
-29
lines changed
  • crates/q_cli/src/cli/chat

1 file changed

+38
-29
lines changed

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

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -850,40 +850,49 @@ where
850850
execute!(self.output, style::Print("\n"))?;
851851
}
852852

853-
// If expand flag is set, show the expanded files
854-
if expand {
855-
match context_manager.get_context_files(false).await {
856-
Ok(context_files) => {
857-
if context_files.is_empty() {
858-
execute!(
859-
self.output,
860-
style::SetForegroundColor(Color::DarkGrey),
861-
style::Print("No files matched the patterns.\n\n"),
862-
style::SetForegroundColor(Color::Reset)
863-
)?;
864-
} else {
865-
execute!(
866-
self.output,
867-
style::SetForegroundColor(Color::Green),
868-
style::Print(format!("Expanded files ({}):\n", context_files.len())),
869-
style::SetForegroundColor(Color::Reset)
870-
)?;
871-
872-
for (filename, _) in context_files {
873-
execute!(self.output, style::Print(format!(" {}\n", filename)))?;
874-
}
875-
execute!(self.output, style::Print("\n"))?;
853+
match context_manager.get_context_files(false).await {
854+
Ok(context_files) => {
855+
if context_files.is_empty() {
856+
execute!(
857+
self.output,
858+
style::SetForegroundColor(Color::DarkGrey),
859+
style::Print("No files matched the configured context paths.\n\n"),
860+
style::SetForegroundColor(Color::Reset)
861+
)?;
862+
} else if expand {
863+
// Show expanded file list when expand flag is set
864+
execute!(
865+
self.output,
866+
style::SetForegroundColor(Color::Green),
867+
style::Print(format!("Expanded files ({}):\n", context_files.len())),
868+
style::SetForegroundColor(Color::Reset)
869+
)?;
870+
871+
for (filename, _) in context_files {
872+
execute!(self.output, style::Print(format!(" {}\n", filename)))?;
876873
}
877-
},
878-
Err(e) => {
874+
execute!(self.output, style::Print("\n"))?;
875+
} else {
876+
// Just show the count when expand flag is not set
879877
execute!(
880878
self.output,
881-
style::SetForegroundColor(Color::Red),
882-
style::Print(format!("Error expanding files: {}\n\n", e)),
879+
style::SetForegroundColor(Color::Green),
880+
style::Print(format!(
881+
"Number of context files in use: {}\n",
882+
context_files.len()
883+
)),
883884
style::SetForegroundColor(Color::Reset)
884885
)?;
885-
},
886-
}
886+
}
887+
},
888+
Err(e) => {
889+
execute!(
890+
self.output,
891+
style::SetForegroundColor(Color::Red),
892+
style::Print(format!("Error retrieving context files: {}\n\n", e)),
893+
style::SetForegroundColor(Color::Reset)
894+
)?;
895+
},
887896
}
888897
},
889898
command::ContextSubcommand::Add { global, force, paths } => {

0 commit comments

Comments
 (0)