From 918866b7deccf6ca67ca99ece9f8534c56ce484b Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 17 Dec 2024 17:51:47 -0500 Subject: [PATCH] assistant2: Allow creating a new thread via the command palette (#22168) This PR allows a new thread to be created via the command palette when the Assistant2 panel is not focused. Release Notes: - N/A --- crates/assistant2/src/assistant_panel.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index 0d01ee5629aea..4858393f0d1f6 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -27,9 +27,16 @@ use crate::{NewThread, OpenHistory, ToggleFocus}; pub fn init(cx: &mut AppContext) { cx.observe_new_views( |workspace: &mut Workspace, _cx: &mut ViewContext| { - workspace.register_action(|workspace, _: &ToggleFocus, cx| { - workspace.toggle_panel_focus::(cx); - }); + workspace + .register_action(|workspace, _: &ToggleFocus, cx| { + workspace.toggle_panel_focus::(cx); + }) + .register_action(|workspace, _: &NewThread, cx| { + if let Some(panel) = workspace.panel::(cx) { + panel.update(cx, |panel, cx| panel.new_thread(cx)); + workspace.focus_panel::(cx); + } + }); }, ) .detach();