Add a send button to the assistant (#12171)
 Include the keybinding to help people discover how to submit from the keyboard. I'm also shifting from the word "Conversation" to "Context". Release Notes: - Added a send button to the assistant panel.
This commit is contained in:
parent
457fbd742f
commit
ea166f0b27
5 changed files with 44 additions and 20 deletions
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -339,11 +339,11 @@ pub struct LegacyAssistantSettingsContent {
|
|||
///
|
||||
/// Default: 320
|
||||
pub 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-preview
|
||||
pub 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/v1
|
||||
pub openai_api_url: Option<String>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue