diff --git a/assets/icons/quote_15.svg b/assets/icons/quote_15.svg new file mode 100644 index 0000000000..be5eabd9b0 --- /dev/null +++ b/assets/icons/quote_15.svg @@ -0,0 +1 @@ + diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 354599cf5b..78ab13fbb1 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -111,6 +111,7 @@ pub enum AssistantPanelEvent { } pub struct AssistantPanel { + workspace: WeakViewHandle, width: Option, height: Option, active_editor_index: Option, @@ -143,6 +144,7 @@ impl AssistantPanel { .unwrap_or_default(); // TODO: deserialize state. + let workspace_handle = workspace.clone(); workspace.update(&mut cx, |workspace, cx| { cx.add_view::(|cx| { const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100); @@ -171,6 +173,7 @@ impl AssistantPanel { toolbar }); let mut this = Self { + workspace: workspace_handle, active_editor_index: Default::default(), prev_active_editor_index: Default::default(), editors: Default::default(), @@ -364,6 +367,7 @@ impl AssistantPanel { if self.active_editor().is_some() { vec![ Self::render_split_button(&style.split_button, cx).into_any(), + Self::render_quote_button(&style.quote_button, cx).into_any(), Self::render_assist_button(&style.assist_button, cx).into_any(), ] } else { @@ -413,6 +417,31 @@ impl AssistantPanel { ) } + fn render_quote_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + let tooltip_style = theme::current(cx).tooltip.clone(); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + .mouse::(0) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(workspace) = this.workspace.upgrade(cx) { + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + ConversationEditor::quote_selection(workspace, &Default::default(), cx) + }); + }); + } + }) + .with_tooltip::( + 1, + "Assist".into(), + Some(Box::new(QuoteSelection)), + tooltip_style, + cx, + ) + } + fn render_plus_button(style: &IconStyle) -> impl Element { enum AddConversation {} Svg::for_style(style.icon.clone()) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 7a6b554247..e828f8ba97 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -996,6 +996,7 @@ pub struct AssistantStyle { pub hamburger_button: IconStyle, pub split_button: IconStyle, pub assist_button: IconStyle, + pub quote_button: IconStyle, pub zoom_in_button: IconStyle, pub zoom_out_button: IconStyle, pub plus_button: IconStyle, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 153b2f9e42..db3f419b14 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -41,6 +41,19 @@ export default function assistant(colorScheme: ColorScheme) { margin: { left: 12 }, } }, + quoteButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/quote_15.svg", + dimensions: { + width: 15, + height: 15, + }, + }, + container: { + margin: { left: 12 }, + } + }, assistButton: { icon: { color: text(layer, "sans", "default", { size: "sm" }).color, @@ -51,7 +64,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 12, right: 12 }, + margin: { left: 12, right: 24 }, } }, zoomInButton: {