Skip to content

Commit 730456e

Browse files
committed
UX update to Prompt & Context list command
1 parent 5d3628a commit 730456e

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

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

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,19 @@ impl ContextSubcommand {
153153
.get_context_files_by_path(os, path.get_path_as_str())
154154
.await
155155
{
156+
for (file_path, _content) in &context_files {
157+
execute!(session.stderr, style::Print(format!(" {file_path}\n")))?;
158+
}
159+
profile_context_files
160+
.extend(context_files.into_iter().map(|(path, content)| (path, content, false)));
161+
} else {
156162
execute!(
157163
session.stderr,
158-
StyledText::success_fg(),
159-
style::Print(format!(
160-
"({} match{})",
161-
context_files.len(),
162-
if context_files.len() == 1 { "" } else { "es" }
163-
)),
164-
StyledText::reset(),
164+
StyledText::secondary_fg(),
165+
style::Print(format!(" {} (no matches)\n", path.get_path_as_str())),
166+
StyledText::reset()
165167
)?;
166-
profile_context_files
167-
.extend(context_files.into_iter().map(|(path, content)| (path, content, false)));
168168
}
169-
execute!(session.stderr, style::Print("\n"))?;
170169
}
171170
execute!(session.stderr, style::Print("\n"))?;
172171
}
@@ -188,28 +187,23 @@ impl ContextSubcommand {
188187
)?;
189188
} else {
190189
for path in &session_owned_list {
191-
execute!(
192-
session.stderr,
193-
style::Print(format!(" - {} ", path.get_path_as_str()))
194-
)?;
195190
if let Ok(context_files) = context_manager
196191
.get_context_files_by_path(os, path.get_path_as_str())
197192
.await
198193
{
194+
for (file_path, _content) in &context_files {
195+
execute!(session.stderr, style::Print(format!(" {file_path}\n")))?;
196+
}
197+
profile_context_files
198+
.extend(context_files.into_iter().map(|(path, content)| (path, content, true)));
199+
} else {
199200
execute!(
200201
session.stderr,
201-
StyledText::success_fg(),
202-
style::Print(format!(
203-
"({} match{})",
204-
context_files.len(),
205-
if context_files.len() == 1 { "" } else { "es" }
206-
)),
207-
StyledText::reset(),
202+
StyledText::secondary_fg(),
203+
style::Print(format!(" {} (no matches)\n", path.get_path_as_str())),
204+
StyledText::reset()
208205
)?;
209-
profile_context_files
210-
.extend(context_files.into_iter().map(|(path, content)| (path, content, true)));
211206
}
212-
execute!(session.stderr, style::Print("\n"))?;
213207
}
214208
execute!(session.stderr, style::Print("\n"))?;
215209
}

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,11 @@ impl PromptsArgs {
719719
let (local_exists, global_exists) = (prompts.local.exists(), prompts.global.exists());
720720

721721
if global_exists {
722-
global_prompts.push(name);
722+
global_prompts.push((name, prompts.global.path.clone()));
723723
}
724724

725725
if local_exists {
726-
local_prompts.push(name);
726+
local_prompts.push((name, prompts.local.path.clone()));
727727
// Check for overrides using has_local_override method
728728
if global_exists {
729729
overridden_globals.push(name);
@@ -733,19 +733,15 @@ impl PromptsArgs {
733733
}
734734

735735
if !global_prompts.is_empty() {
736-
let global_dir = PathResolver::new(os)
737-
.global()
738-
.prompts_dir()
739-
.map_or_else(|_| "global prompts".to_string(), |p| p.display().to_string());
740736
queue!(
741737
session.stderr,
742738
style::SetAttribute(Attribute::Bold),
743-
style::Print(&format!("Global ({global_dir}):")),
739+
style::Print("Global:"),
744740
StyledText::reset_attributes(),
745741
style::Print("\n"),
746742
)?;
747-
for name in &global_prompts {
748-
queue!(session.stderr, style::Print("- "), style::Print(name))?;
743+
for (_name, path) in &global_prompts {
744+
queue!(session.stderr, style::Print(&path.to_string_lossy()))?;
749745
queue!(session.stderr, style::Print("\n"))?;
750746
}
751747
}
@@ -754,20 +750,16 @@ impl PromptsArgs {
754750
if !global_prompts.is_empty() {
755751
queue!(session.stderr, style::Print("\n"))?;
756752
}
757-
let local_dir = PathResolver::new(os)
758-
.workspace()
759-
.prompts_dir()
760-
.map_or_else(|_| "local prompts".to_string(), |p| p.display().to_string());
761753
queue!(
762754
session.stderr,
763755
style::SetAttribute(Attribute::Bold),
764-
style::Print(&format!("Local ({local_dir}):")),
756+
style::Print("Local:"),
765757
StyledText::reset_attributes(),
766758
style::Print("\n"),
767759
)?;
768-
for name in &local_prompts {
760+
for (name, path) in &local_prompts {
769761
let has_global_version = overridden_globals.contains(name);
770-
queue!(session.stderr, style::Print("- "), style::Print(name),)?;
762+
queue!(session.stderr, style::Print(&path.to_string_lossy()))?;
771763
if has_global_version {
772764
queue!(
773765
session.stderr,

0 commit comments

Comments
 (0)