Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant2: Allow creating a new thread via the command palette (#22168)

Marshall Bowers918866b7decc
diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs
index 0d01ee5629a..4858393f0d1 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>| {
- workspace.register_action(|workspace, _: &ToggleFocus, cx| {
- workspace.toggle_panel_focus::<AssistantPanel>(cx);
- });
+ workspace
+ .register_action(|workspace, _: &ToggleFocus, cx| {
+ workspace.toggle_panel_focus::<AssistantPanel>(cx);
+ })
+ .register_action(|workspace, _: &NewThread, cx| {
+ if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
+ panel.update(cx, |panel, cx| panel.new_thread(cx));
+ workspace.focus_panel::<AssistantPanel>(cx);
+ }
+ });
},
)
.detach();