diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index 4858393f0d1f68..a42e35cabeb686 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -36,6 +36,12 @@ pub fn init(cx: &mut AppContext) { panel.update(cx, |panel, cx| panel.new_thread(cx)); workspace.focus_panel::(cx); } + }) + .register_action(|workspace, _: &OpenHistory, cx| { + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(cx); + panel.update(cx, |panel, cx| panel.open_history(cx)); + } }); }, ) @@ -164,6 +170,12 @@ impl AssistantPanel { self.message_editor.focus_handle(cx).focus(cx); } + fn open_history(&mut self, cx: &mut ViewContext) { + self.active_view = ActiveView::History; + self.history.focus_handle(cx).focus(cx); + cx.notify(); + } + pub(crate) fn open_thread(&mut self, thread_id: &ThreadId, cx: &mut ViewContext) { let Some(thread) = self .thread_store @@ -579,9 +591,7 @@ impl Render for AssistantPanel { this.new_thread(cx); })) .on_action(cx.listener(|this, _: &OpenHistory, cx| { - this.active_view = ActiveView::History; - this.history.focus_handle(cx).focus(cx); - cx.notify(); + this.open_history(cx); })) .child(self.render_toolbar(cx)) .map(|parent| match self.active_view {