Skip to content

Commit

Permalink
assistant2: Fix focus issues with opening history
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdeviant committed Dec 17, 2024
1 parent 411a011 commit a0edddd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/assistant2/src/assistant_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ pub fn init(cx: &mut AppContext) {
panel.update(cx, |panel, cx| panel.new_thread(cx));
workspace.focus_panel::<AssistantPanel>(cx);
}
})
.register_action(|workspace, _: &OpenHistory, cx| {
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
workspace.focus_panel::<AssistantPanel>(cx);
panel.update(cx, |panel, cx| panel.open_history(cx));
}
});
},
)
Expand Down Expand Up @@ -164,6 +170,12 @@ impl AssistantPanel {
self.message_editor.focus_handle(cx).focus(cx);
}

fn open_history(&mut self, cx: &mut ViewContext<Self>) {
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<Self>) {
let Some(thread) = self
.thread_store
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a0edddd

Please sign in to comment.