Break ground on assistant2 (#21109)

This PR breaks ground on a new `assistant2` crate.

In order to see this new version of the assistant, both of the following
must be true:
1. The `assistant2` feature flag is enabled for your user
   - It is **not** currently enabled for all staff.
2. You are running a development build of Zed

The intent here is to enable the folks working on `assistant2` to
incrementally land work onto `main` without breaking use of the current
Assistant for anyone.

<img width="1136" alt="Screenshot 2024-11-23 at 10 46 08 AM"
src="https://github.com/user-attachments/assets/5723a13f-5be1-4486-9460-ead7329ba78e">

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-11-23 11:24:52 -05:00 committed by GitHub
parent f30de4852a
commit 9adc3b4e82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 243 additions and 5 deletions

View file

@ -19,6 +19,7 @@ activity_indicator.workspace = true
anyhow.workspace = true
assets.workspace = true
assistant.workspace = true
assistant2.workspace = true
async-watch.workspace = true
audio.workspace = true
auto_update.workspace = true

View file

@ -406,6 +406,7 @@ fn main() {
stdout_is_a_pty(),
cx,
);
assistant2::init(cx);
assistant_hints::init(cx);
repl::init(
app_state.fs.clone(),

View file

@ -236,10 +236,29 @@ pub fn initialize_workspace(
.unwrap_or(true)
});
let release_channel = ReleaseChannel::global(cx);
let assistant2_feature_flag = cx.wait_for_flag::<feature_flags::Assistant2FeatureFlag>();
let prompt_builder = prompt_builder.clone();
cx.spawn(|workspace_handle, mut cx| async move {
let assistant_panel =
assistant::AssistantPanel::load(workspace_handle.clone(), prompt_builder, cx.clone());
let is_assistant2_enabled = if cfg!(test) {
false
} else {
let is_assistant2_feature_flag_enabled = assistant2_feature_flag.await;
release_channel == ReleaseChannel::Dev && is_assistant2_feature_flag_enabled
};
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))
} else {
let assistant_panel =
assistant::AssistantPanel::load(workspace_handle.clone(), prompt_builder, cx.clone()).await?;
(Some(assistant_panel), None)
};
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
let outline_panel = OutlinePanel::load(workspace_handle.clone(), cx.clone());
@ -257,7 +276,6 @@ pub fn initialize_workspace(
project_panel,
outline_panel,
terminal_panel,
assistant_panel,
channels_panel,
chat_panel,
notification_panel,
@ -265,14 +283,20 @@ pub fn initialize_workspace(
project_panel,
outline_panel,
terminal_panel,
assistant_panel,
channels_panel,
chat_panel,
notification_panel,
)?;
workspace_handle.update(&mut cx, |workspace, cx| {
workspace.add_panel(assistant_panel, cx);
if let Some(assistant_panel) = assistant_panel {
workspace.add_panel(assistant_panel, cx);
}
if let Some(assistant2_panel) = assistant2_panel {
workspace.add_panel(assistant2_panel, cx);
}
workspace.add_panel(project_panel, cx);
workspace.add_panel(outline_panel, cx);
workspace.add_panel(terminal_panel, cx);