Skip to content

Commit 35da9c0

Browse files
authored
assistant2: Move prompt editor item into dropdown menu (#27708)
This PR makes the plus icon button not a dropdown anymore, freeing it up to be always the new thread action. In consequence, I'm moving all of the other items into another dropdown, which now houses "new prompt editor", history, and settings, all of which there are keybindings for. <img src="https://github.com/user-attachments/assets/1d0d43da-9447-4218-8b9b-e692c0b74f61" width="700"/> Release Notes: - N/A
1 parent 8b3eb98 commit 35da9c0

File tree

3 files changed

+47
-44
lines changed

3 files changed

+47
-44
lines changed

assets/keymaps/default-linux.json

+2
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,9 @@
629629
"bindings": {
630630
"ctrl-n": "assistant2::NewThread",
631631
"new": "assistant2::NewThread",
632+
"ctrl-alt-n": "assistant2::NewPromptEditor",
632633
"ctrl-shift-h": "assistant2::OpenHistory",
634+
"ctrl-alt-c": "assistant2::OpenConfiguration",
633635
"ctrl-i": "assistant2::ToggleProfileSelector",
634636
"ctrl-alt-/": "assistant::ToggleModelSelector",
635637
"ctrl-shift-a": "assistant2::ToggleContextPicker",

assets/keymaps/default-macos.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,9 @@
281281
"use_key_equivalents": true,
282282
"bindings": {
283283
"cmd-n": "assistant2::NewThread",
284-
"cmd-alt-p": "assistant2::NewPromptEditor",
284+
"cmd-alt-n": "assistant2::NewPromptEditor",
285285
"cmd-shift-h": "assistant2::OpenHistory",
286+
"cmd-alt-c": "assistant2::OpenConfiguration",
286287
"cmd-i": "assistant2::ToggleProfileSelector",
287288
"cmd-alt-/": "assistant::ToggleModelSelector",
288289
"cmd-shift-a": "assistant2::ToggleContextPicker",

crates/assistant2/src/assistant_panel.rs

+43-43
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ pub fn init(cx: &mut App) {
6565
panel.update(cx, |panel, cx| panel.open_history(window, cx));
6666
}
6767
})
68+
.register_action(|workspace, _: &OpenConfiguration, window, cx| {
69+
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
70+
workspace.focus_panel::<AssistantPanel>(window, cx);
71+
panel.update(cx, |panel, cx| panel.open_configuration(window, cx));
72+
}
73+
})
6874
.register_action(|workspace, _: &NewPromptEditor, window, cx| {
6975
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
7076
workspace.focus_panel::<AssistantPanel>(window, cx);
@@ -113,7 +119,7 @@ pub struct AssistantPanel {
113119
active_view: ActiveView,
114120
history_store: Entity<HistoryStore>,
115121
history: Entity<ThreadHistory>,
116-
new_item_context_menu_handle: PopoverMenuHandle<ContextMenu>,
122+
assistant_dropdown_menu_handle: PopoverMenuHandle<ContextMenu>,
117123
width: Option<Pixels>,
118124
height: Option<Pixels>,
119125
}
@@ -213,7 +219,7 @@ impl AssistantPanel {
213219
.unwrap(),
214220
history_store: history_store.clone(),
215221
history: cx.new(|cx| ThreadHistory::new(weak_self, history_store, cx)),
216-
new_item_context_menu_handle: PopoverMenuHandle::default(),
222+
assistant_dropdown_menu_handle: PopoverMenuHandle::default(),
217223
width: None,
218224
height: None,
219225
}
@@ -659,8 +665,9 @@ impl Panel for AssistantPanel {
659665
}
660666

661667
impl AssistantPanel {
662-
fn render_toolbar(&self, cx: &mut Context<Self>) -> impl IntoElement {
668+
fn render_toolbar(&self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
663669
let thread = self.thread.read(cx);
670+
let focus_handle = self.focus_handle(cx);
664671

665672
let title = match self.active_view {
666673
ActiveView::Thread => {
@@ -680,7 +687,7 @@ impl AssistantPanel {
680687
})
681688
.unwrap_or_else(|| SharedString::from("Loading Summary…")),
682689
ActiveView::History => "History".into(),
683-
ActiveView::Configuration => "Assistant Settings".into(),
690+
ActiveView::Configuration => "Settings".into(),
684691
};
685692

686693
h_flex()
@@ -720,57 +727,47 @@ impl AssistantPanel {
720727
.border_color(cx.theme().colors().border)
721728
.gap(DynamicSpacing::Base02.rems(cx))
722729
.child(
723-
PopoverMenu::new("assistant-toolbar-new-popover-menu")
730+
IconButton::new("new", IconName::Plus)
731+
.icon_size(IconSize::Small)
732+
.style(ButtonStyle::Subtle)
733+
.tooltip(move |window, cx| {
734+
Tooltip::for_action_in(
735+
"New Thread",
736+
&NewThread,
737+
&focus_handle,
738+
window,
739+
cx,
740+
)
741+
})
742+
.on_click(move |_event, window, cx| {
743+
window.dispatch_action(NewThread.boxed_clone(), cx);
744+
}),
745+
)
746+
.child(
747+
PopoverMenu::new("assistant-menu")
724748
.trigger_with_tooltip(
725-
IconButton::new("new", IconName::Plus)
749+
IconButton::new("new", IconName::Ellipsis)
726750
.icon_size(IconSize::Small)
727751
.style(ButtonStyle::Subtle),
728-
Tooltip::text("New…"),
752+
Tooltip::text("Toggle Assistant Menu"),
729753
)
730754
.anchor(Corner::TopRight)
731-
.with_handle(self.new_item_context_menu_handle.clone())
755+
.with_handle(self.assistant_dropdown_menu_handle.clone())
732756
.menu(move |window, cx| {
733757
Some(ContextMenu::build(
734758
window,
735759
cx,
736760
|menu, _window, _cx| {
737-
menu.action("New Thread", NewThread.boxed_clone())
738-
.action(
739-
"New Prompt Editor",
740-
NewPromptEditor.boxed_clone(),
741-
)
761+
menu.action(
762+
"New Prompt Editor",
763+
NewPromptEditor.boxed_clone(),
764+
)
765+
.separator()
766+
.action("History", OpenHistory.boxed_clone())
767+
.action("Settings", OpenConfiguration.boxed_clone())
742768
},
743769
))
744770
}),
745-
)
746-
.child(
747-
IconButton::new("open-history", IconName::HistoryRerun)
748-
.icon_size(IconSize::Small)
749-
.style(ButtonStyle::Subtle)
750-
.tooltip({
751-
let focus_handle = self.focus_handle(cx);
752-
move |window, cx| {
753-
Tooltip::for_action_in(
754-
"History",
755-
&OpenHistory,
756-
&focus_handle,
757-
window,
758-
cx,
759-
)
760-
}
761-
})
762-
.on_click(move |_event, window, cx| {
763-
window.dispatch_action(OpenHistory.boxed_clone(), cx);
764-
}),
765-
)
766-
.child(
767-
IconButton::new("configure-assistant", IconName::Settings)
768-
.icon_size(IconSize::Small)
769-
.style(ButtonStyle::Subtle)
770-
.tooltip(Tooltip::text("Assistant Settings"))
771-
.on_click(move |_event, window, cx| {
772-
window.dispatch_action(OpenConfiguration.boxed_clone(), cx);
773-
}),
774771
),
775772
),
776773
)
@@ -1103,9 +1100,12 @@ impl Render for AssistantPanel {
11031100
.on_action(cx.listener(|this, _: &OpenHistory, window, cx| {
11041101
this.open_history(window, cx);
11051102
}))
1103+
.on_action(cx.listener(|this, _: &OpenConfiguration, window, cx| {
1104+
this.open_configuration(window, cx);
1105+
}))
11061106
.on_action(cx.listener(Self::open_active_thread_as_markdown))
11071107
.on_action(cx.listener(Self::deploy_prompt_library))
1108-
.child(self.render_toolbar(cx))
1108+
.child(self.render_toolbar(window, cx))
11091109
.map(|parent| match self.active_view {
11101110
ActiveView::Thread => parent
11111111
.child(self.render_active_thread_or_empty_state(window, cx))

0 commit comments

Comments
 (0)