From ae85ecba2d54abe2dbdfc11c408c78bc2d256aa0 Mon Sep 17 00:00:00 2001
From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Date: Thu, 28 Nov 2024 18:26:59 -0300
Subject: [PATCH] Make fetch slash command visible in the command selector
(#21302)
The `/fetch` command is naturally already accessible via the completion
menu when you type / in the assistant panel, but it wasn't on the "Add
Context" command selector. I think it should! It's a super nice/powerful
one, and I've seen folks not knowing it existed. Side-note: maybe, in
the near future, it'd be best to rename it to "`/web`, as that's an
easier name to parse and assume what it does.
Release Notes:
- N/A
---
assets/icons/globe.svg | 1 +
crates/assistant/src/assistant.rs | 3 +--
crates/assistant/src/slash_command/fetch_command.rs | 6 +++++-
crates/ui/src/components/icon.rs | 9 +++++----
4 files changed, 12 insertions(+), 7 deletions(-)
create mode 100644 assets/icons/globe.svg
diff --git a/assets/icons/globe.svg b/assets/icons/globe.svg
new file mode 100644
index 0000000000..2082a43984
--- /dev/null
+++ b/assets/icons/globe.svg
@@ -0,0 +1 @@
+
diff --git a/crates/assistant/src/assistant.rs b/crates/assistant/src/assistant.rs
index 7e4e38e320..6d619a76b9 100644
--- a/crates/assistant/src/assistant.rs
+++ b/crates/assistant/src/assistant.rs
@@ -342,8 +342,7 @@ fn register_slash_commands(prompt_builder: Option>, cx: &mut
slash_command_registry.register_command(terminal_command::TerminalSlashCommand, true);
slash_command_registry.register_command(now_command::NowSlashCommand, false);
slash_command_registry.register_command(diagnostics_command::DiagnosticsSlashCommand, true);
- slash_command_registry.register_command(fetch_command::FetchSlashCommand, false);
- slash_command_registry.register_command(fetch_command::FetchSlashCommand, false);
+ slash_command_registry.register_command(fetch_command::FetchSlashCommand, true);
if let Some(prompt_builder) = prompt_builder {
cx.observe_flag::({
diff --git a/crates/assistant/src/slash_command/fetch_command.rs b/crates/assistant/src/slash_command/fetch_command.rs
index 4d38bb20a7..96ea05c302 100644
--- a/crates/assistant/src/slash_command/fetch_command.rs
+++ b/crates/assistant/src/slash_command/fetch_command.rs
@@ -108,6 +108,10 @@ impl SlashCommand for FetchSlashCommand {
"Insert fetched URL contents".into()
}
+ fn icon(&self) -> IconName {
+ IconName::Globe
+ }
+
fn menu_text(&self) -> String {
self.description()
}
@@ -162,7 +166,7 @@ impl SlashCommand for FetchSlashCommand {
text,
sections: vec![SlashCommandOutputSection {
range,
- icon: IconName::AtSign,
+ icon: IconName::Globe,
label: format!("fetch {}", url).into(),
metadata: None,
}],
diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs
index 161f4c60b7..03000f0638 100644
--- a/crates/ui/src/components/icon.rs
+++ b/crates/ui/src/components/icon.rs
@@ -160,7 +160,6 @@ pub enum IconName {
Copy,
CountdownTimer,
CursorIBeam,
- TextSnippet,
Dash,
DatabaseZap,
Delete,
@@ -171,8 +170,8 @@ pub enum IconName {
EllipsisVertical,
Envelope,
Escape,
- Exit,
ExpandVertical,
+ Exit,
ExternalLink,
Eye,
File,
@@ -198,6 +197,7 @@ pub enum IconName {
GenericMinimize,
GenericRestore,
Github,
+ Globe,
Hash,
HistoryRerun,
Indicator,
@@ -223,13 +223,13 @@ pub enum IconName {
PageUp,
Pencil,
Person,
+ PhoneIncoming,
Pin,
Play,
Plus,
PocketKnife,
Public,
PullRequest,
- PhoneIncoming,
Quote,
RefreshTitle,
Regex,
@@ -275,6 +275,7 @@ pub enum IconName {
SwatchBook,
Tab,
Terminal,
+ TextSnippet,
Trash,
TrashAlt,
Triangle,
@@ -287,11 +288,11 @@ pub enum IconName {
Wand,
Warning,
WholeWord,
+ X,
XCircle,
ZedAssistant,
ZedAssistantFilled,
ZedXCopilot,
- X,
}
impl From for Icon {