Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add a send button to the assistant (#12171)
Nathan Soboea166f0b27ff
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 78c1475d614..ab10a3c5173 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -316,7 +316,7 @@// AI provider."provider": {"name": "openai",- // The default model to use when starting new conversations. This+ // The default model to use when creating new contexts. This// setting can take three values://// 1. "gpt-3.5-turbo"diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rsindex 3e60affc95e..32cc6995bbb 100644--- a/crates/assistant/src/assistant_panel.rs+++ b/crates/assistant/src/assistant_panel.rs@@ -61,7 +61,10 @@ use std::{};use telemetry_events::AssistantKind;use theme::ThemeSettings;-use ui::{popover_menu, prelude::*, ButtonLike, ContextMenu, Tab, TabBar, Tooltip};+use ui::{+ popover_menu, prelude::*, ButtonLike, ContextMenu, ElevationIndex, KeyBinding, Tab, TabBar,+ Tooltip,+};use util::{paths::CONVERSATIONS_DIR, post_inc, ResultExt, TryFutureExt};use uuid::Uuid;use workspace::{@@ -1057,15 +1060,25 @@ impl AssistantPanel {})}- fn render_assist_button(cx: &mut ViewContext<Self>) -> impl IntoElement {- IconButton::new("assist_button", IconName::MagicWand)- .on_click(cx.listener(|this, _event, cx| {- if let Some(active_editor) = this.active_conversation_editor() {- active_editor.update(cx, |editor, cx| editor.assist(&Default::default(), cx));- }- }))- .icon_size(IconSize::Small)- .tooltip(|cx| Tooltip::for_action("Assist", &Assist, cx))+ fn render_send_button(&self, cx: &mut ViewContext<Self>) -> Option<impl IntoElement> {+ self.active_conversation_editor+ .as_ref()+ .map(|conversation| {+ let focus_handle = conversation.editor.focus_handle(cx);+ ButtonLike::new("send_button")+ .style(ButtonStyle::Filled)+ .layer(ElevationIndex::ModalSurface)+ .children(+ KeyBinding::for_action_in(&Assist, &focus_handle, cx)+ .map(|binding| binding.into_any_element()),+ )+ .child(Label::new("Send"))+ .on_click(cx.listener(|this, _event, cx| {+ if let Some(active_editor) = this.active_conversation_editor() {+ active_editor.update(cx, |editor, cx| editor.assist(&Assist, cx));+ }+ }))+ })}fn render_saved_conversation(@@ -1194,8 +1207,7 @@ impl AssistantPanel {this.show_prompt_manager(cx)})).tooltip(|cx| Tooltip::text("Prompt Library…", cx)),- )- .child(Self::render_assist_button(cx)),+ ),),);@@ -1262,7 +1274,19 @@ impl AssistantPanel {.into_any_element()} else if let Some(editor) = self.active_conversation_editor() {let editor = editor.clone();- div().size_full().child(editor.clone()).into_any_element()+ div()+ .size_full()+ .child(editor.clone())+ .child(+ h_flex()+ .w_full()+ .absolute()+ .bottom_0()+ .p_4()+ .justify_end()+ .children(self.render_send_button(cx)),+ )+ .into_any_element()} else {div().into_any_element()},@@ -3503,7 +3527,7 @@ impl ConversationEditor {.summary.as_ref().map(|summary| summary.text.clone())- .unwrap_or_else(|| "New Conversation".into())+ .unwrap_or_else(|| "New Context".into())}}diff --git a/crates/assistant/src/assistant_settings.rs b/crates/assistant/src/assistant_settings.rsindex 31e32a28936..d822db8f702 100644--- a/crates/assistant/src/assistant_settings.rs+++ b/crates/assistant/src/assistant_settings.rs@@ -339,11 +339,11 @@ pub struct LegacyAssistantSettingsContent {////// Default: 320pub default_height: Option<f32>,- /// The default OpenAI model to use when starting new conversations.+ /// The default OpenAI model to use when creating new contexts.////// Default: gpt-4-1106-previewpub default_open_ai_model: Option<OpenAiModel>,- /// OpenAI API base URL to use when starting new conversations.+ /// OpenAI API base URL to use when creating new contexts.////// Default: https://api.openai.com/v1pub openai_api_url: Option<String>,diff --git a/crates/assistant2/src/assistant2.rs b/crates/assistant2/src/assistant2.rsindex 9ad1b7b99b3..72292c4d227 100644--- a/crates/assistant2/src/assistant2.rs+++ b/crates/assistant2/src/assistant2.rs@@ -1108,7 +1108,7 @@ impl Render for AssistantChat {.on_click(cx.listener(move |this, _event, cx| {this.new_conversation(cx);}))- .tooltip(move |cx| Tooltip::text("New Conversation", cx)),+ .tooltip(move |cx| Tooltip::text("New Context", cx)),).child(IconButton::new("assistant-menu", IconName::Menu)diff --git a/docs/src/assistant-panel.md b/docs/src/assistant-panel.mdindex 19a5cce9ab8..444b851f92b 100644--- a/docs/src/assistant-panel.md+++ b/docs/src/assistant-panel.md@@ -46,7 +46,7 @@ After submitting a message, the assistant's response will be streamed below, inThe stream can be canceled at any point with `escape`. This is useful if you realize early on that the response is not what you were looking for.-If you want to start a new conversation at any time, you can use the `New Conversation` button located at the top-right corner of the assistant panel.+If you want to start a new conversation at any time, you can hit `cmd-n` or use the `New Context` menu option in the hamburger menu at the top left of the panel.Simple back-and-forth conversations work well with the assistant. However, there may come a time when you want to modify the previous text in the conversation and steer it in a different direction.@@ -62,7 +62,7 @@ The assistant gives you the flexibility to have control over the conversation. Y6. Add additional context to your original message7. Submit the message with `cmd-enter`-Being able to edit previous messages gives you control over how tokens are used. You don't need to start up a new conversation to correct a mistake or to add additional context and you don't have to waste tokens by submitting follow-up corrections.+Being able to edit previous messages gives you control over how tokens are used. You don't need to start up a new context to correct a mistake or to add additional context and you don't have to waste tokens by submitting follow-up corrections.Some additional points to keep in mind: