Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the use of both Assistants when in the assistant2 feature flag #22150

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions crates/assistant2/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mod thread_history;
mod thread_store;
mod ui;

use std::any::TypeId;
use std::sync::Arc;

use client::Client;
Expand Down Expand Up @@ -79,10 +78,6 @@ pub fn init(fs: Arc<dyn Fs>, client: Arc<Client>, 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::<zed_actions::InlineAssist>()];

CommandPaletteFilter::update_global(cx, |filter, _cx| {
filter.hide_namespace(NAMESPACE);
});
Expand All @@ -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);
});
}
})
Expand Down
32 changes: 14 additions & 18 deletions crates/zed/src/zed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ pub fn initialize_workspace(
let git_ui_feature_flag = cx.wait_for_flag::<feature_flags::GitUiFeatureFlag>();

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());
Expand All @@ -254,6 +253,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,
Expand All @@ -262,13 +263,15 @@ pub fn initialize_workspace(
channels_panel,
chat_panel,
notification_panel,
assistant_panel,
) = futures::try_join!(
project_panel,
outline_panel,
terminal_panel,
channels_panel,
chat_panel,
notification_panel,
assistant_panel,
)?;

workspace_handle.update(&mut cx, |workspace, cx| {
Expand All @@ -278,15 +281,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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is_staff check was redundant with the staff-gating on the feature flag.


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);
Expand All @@ -299,27 +302,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);
}
})
})
Expand Down
Loading