From 70b28268f420df8bb32c943992eb93c8000c94b4 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 17 Dec 2024 14:23:57 -0500 Subject: [PATCH] Allow the use of both Assistants when in the `assistant2` feature flag (#22150) This PR makes it so both Assistant panels are visible when in the `assistant2` feature flag. This way folks can continue using Assistant1 if Assistant2 isn't meeting their needs. Right now they are shown as two different panels shown in the status bar (although using the same icon), but this is just a temporary state until we can surface the Assistant1 functionality in Assistant2 somehow. Note that the inline assist will always use the Assistant2 panel. Release Notes: - N/A --- crates/assistant2/src/assistant.rs | 12 ----------- crates/zed/src/zed.rs | 32 +++++++++++++----------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/crates/assistant2/src/assistant.rs b/crates/assistant2/src/assistant.rs index 93f3c3bace3971..9c13b4e9794612 100644 --- a/crates/assistant2/src/assistant.rs +++ b/crates/assistant2/src/assistant.rs @@ -15,7 +15,6 @@ mod thread_history; mod thread_store; mod ui; -use std::any::TypeId; use std::sync::Arc; use client::Client; @@ -79,10 +78,6 @@ pub fn init(fs: Arc, client: Arc, stdout_is_a_pty: bool, cx: &mu } fn feature_gate_assistant2_actions(cx: &mut AppContext) { - const ASSISTANT1_NAMESPACE: &str = "assistant"; - - let inline_assist_actions = [TypeId::of::()]; - CommandPaletteFilter::update_global(cx, |filter, _cx| { filter.hide_namespace(NAMESPACE); }); @@ -91,17 +86,10 @@ fn feature_gate_assistant2_actions(cx: &mut AppContext) { if is_enabled { CommandPaletteFilter::update_global(cx, |filter, _cx| { filter.show_namespace(NAMESPACE); - filter.hide_namespace(ASSISTANT1_NAMESPACE); - - // We're hiding all of the `assistant: ` actions, but we want to - // keep the inline assist action around so we can use the same - // one in Assistant2. - filter.show_action_types(inline_assist_actions.iter()); }); } else { CommandPaletteFilter::update_global(cx, |filter, _cx| { filter.hide_namespace(NAMESPACE); - filter.show_namespace(ASSISTANT1_NAMESPACE); }); } }) diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 5374dde1a87793..9f0819c86bba89 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -254,7 +254,6 @@ pub fn initialize_workspace( let git_ui_feature_flag = cx.wait_for_flag::(); let prompt_builder = prompt_builder.clone(); - let is_staff = cx.is_staff(); cx.spawn(|workspace_handle, mut cx| async move { let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone()); @@ -268,6 +267,8 @@ pub fn initialize_workspace( workspace_handle.clone(), cx.clone(), ); + let assistant_panel = + assistant::AssistantPanel::load(workspace_handle.clone(), prompt_builder, cx.clone()); let ( project_panel, @@ -276,6 +277,7 @@ pub fn initialize_workspace( channels_panel, chat_panel, notification_panel, + assistant_panel, ) = futures::try_join!( project_panel, outline_panel, @@ -283,6 +285,7 @@ pub fn initialize_workspace( channels_panel, chat_panel, notification_panel, + assistant_panel, )?; workspace_handle.update(&mut cx, |workspace, cx| { @@ -292,15 +295,15 @@ pub fn initialize_workspace( workspace.add_panel(channels_panel, cx); workspace.add_panel(chat_panel, cx); workspace.add_panel(notification_panel, cx); + workspace.add_panel(assistant_panel, cx); })?; - let git_ui_enabled = git_ui_feature_flag.await || is_staff; + let git_ui_enabled = git_ui_feature_flag.await; let git_panel = if git_ui_enabled { Some(git_ui::git_panel::GitPanel::load(workspace_handle.clone(), cx.clone()).await?) } else { None }; - workspace_handle.update(&mut cx, |workspace, cx| { if let Some(git_panel) = git_panel { workspace.add_panel(git_panel, cx); @@ -313,27 +316,20 @@ pub fn initialize_workspace( } else { assistant2_feature_flag.await }; - - let (assistant_panel, assistant2_panel) = if is_assistant2_enabled { - let assistant2_panel = - assistant2::AssistantPanel::load(workspace_handle.clone(), cx.clone()).await?; - - (None, Some(assistant2_panel)) + let assistant2_panel = if is_assistant2_enabled { + Some(assistant2::AssistantPanel::load(workspace_handle.clone(), cx.clone()).await?) } else { - let assistant_panel = - assistant::AssistantPanel::load(workspace_handle.clone(), prompt_builder, cx.clone()).await?; - - (Some(assistant_panel), None) + None }; workspace_handle.update(&mut cx, |workspace, cx| { - if let Some(assistant_panel) = assistant_panel { - workspace.add_panel(assistant_panel, cx); - workspace.register_action(assistant::AssistantPanel::inline_assist); - } - if let Some(assistant2_panel) = assistant2_panel { workspace.add_panel(assistant2_panel, cx); + } + + if is_assistant2_enabled { workspace.register_action(assistant2::InlineAssistant::inline_assist); + } else { + workspace.register_action(assistant::AssistantPanel::inline_assist); } }) })