Avoid loading the assistant panel on stable

This commit is contained in:
Antonio Scandurra 2023-06-14 12:08:49 +02:00
parent 56b0bf8601
commit 049c987310
2 changed files with 21 additions and 12 deletions

View file

@ -29,7 +29,7 @@ use std::{
borrow::Cow, cell::RefCell, cmp, fmt::Write, io, iter, ops::Range, rc::Rc, sync::Arc,
time::Duration,
};
use util::{post_inc, truncate_and_trailoff, ResultExt, TryFutureExt};
use util::{channel::ReleaseChannel, post_inc, truncate_and_trailoff, ResultExt, TryFutureExt};
use workspace::{
dock::{DockPosition, Panel},
item::Item,
@ -44,6 +44,12 @@ actions!(
);
pub fn init(cx: &mut AppContext) {
if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Stable {
cx.update_default_global::<collections::CommandPaletteFilter, _, _>(move |filter, _cx| {
filter.filtered_namespaces.insert("assistant");
});
}
settings::register::<AssistantSettings>(cx);
cx.add_action(
|workspace: &mut Workspace, _: &NewContext, cx: &mut ViewContext<Workspace>| {
@ -60,6 +66,11 @@ pub fn init(cx: &mut AppContext) {
cx.capture_action(AssistantEditor::copy);
cx.add_action(AssistantPanel::save_api_key);
cx.add_action(AssistantPanel::reset_api_key);
cx.add_action(
|workspace: &mut Workspace, _: &ToggleFocus, cx: &mut ViewContext<Workspace>| {
workspace.toggle_panel_focus::<AssistantPanel>(cx);
},
);
}
pub enum AssistantPanelEvent {

View file

@ -254,13 +254,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
workspace.toggle_panel_focus::<TerminalPanel>(cx);
},
);
cx.add_action(
|workspace: &mut Workspace,
_: &ai::assistant::ToggleFocus,
cx: &mut ViewContext<Workspace>| {
workspace.toggle_panel_focus::<AssistantPanel>(cx);
},
);
cx.add_global_action({
let app_state = Arc::downgrade(&app_state);
move |_: &NewWindow, cx: &mut AppContext| {
@ -368,9 +361,12 @@ pub fn initialize_workspace(
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
let (project_panel, terminal_panel, assistant_panel) =
futures::try_join!(project_panel, terminal_panel, assistant_panel)?;
let assistant_panel = if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Stable {
None
} else {
Some(AssistantPanel::load(workspace_handle.clone(), cx.clone()).await?)
};
let (project_panel, terminal_panel) = futures::try_join!(project_panel, terminal_panel)?;
workspace_handle.update(&mut cx, |workspace, cx| {
let project_panel_position = project_panel.position(cx);
workspace.add_panel(project_panel, cx);
@ -389,7 +385,9 @@ pub fn initialize_workspace(
}
workspace.add_panel(terminal_panel, cx);
workspace.add_panel(assistant_panel, cx);
if let Some(assistant_panel) = assistant_panel {
workspace.add_panel(assistant_panel, cx);
}
})?;
Ok(())
})