Start out Copilot2;

Add hidden_action_types to CommandPaletteFilter.
WindowContext.available_actions now returns global actions as well.

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Piotr Osiewicz 2023-12-05 14:53:01 +01:00
parent 001ce47a0c
commit b73ccc8180
8 changed files with 388 additions and 357 deletions

View File

@ -23,11 +23,13 @@ pub type HashMap<K, V> = std::collections::HashMap<K, V>;
#[cfg(not(feature = "test-support"))] #[cfg(not(feature = "test-support"))]
pub type HashSet<T> = std::collections::HashSet<T>; pub type HashSet<T> = std::collections::HashSet<T>;
use std::any::TypeId;
pub use std::collections::*; pub use std::collections::*;
// NEW TYPES // NEW TYPES
#[derive(Default)] #[derive(Default)]
pub struct CommandPaletteFilter { pub struct CommandPaletteFilter {
pub filtered_namespaces: HashSet<&'static str>, pub hidden_namespaces: HashSet<&'static str>,
pub hidden_action_types: HashSet<TypeId>,
} }

View File

@ -109,7 +109,7 @@ impl PickerDelegate for CommandPaletteDelegate {
let filtered = cx.read(|cx| { let filtered = cx.read(|cx| {
if cx.has_global::<CommandPaletteFilter>() { if cx.has_global::<CommandPaletteFilter>() {
let filter = cx.global::<CommandPaletteFilter>(); let filter = cx.global::<CommandPaletteFilter>();
filter.filtered_namespaces.contains(action.namespace()) filter.hidden_namespaces.contains(action.namespace())
} else { } else {
false false
} }
@ -430,7 +430,7 @@ mod tests {
// Add namespace filter, and redeploy the palette // Add namespace filter, and redeploy the palette
cx.update(|cx| { cx.update(|cx| {
cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| { cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| {
filter.filtered_namespaces.insert("editor"); filter.hidden_namespaces.insert("editor");
}) })
}); });

View File

@ -49,7 +49,10 @@ impl CommandPalette {
.filter_map(|action| { .filter_map(|action| {
let name = gpui::remove_the_2(action.name()); let name = gpui::remove_the_2(action.name());
let namespace = name.split("::").next().unwrap_or("malformed action name"); let namespace = name.split("::").next().unwrap_or("malformed action name");
if filter.is_some_and(|f| f.filtered_namespaces.contains(namespace)) { if filter.is_some_and(|f| {
f.hidden_namespaces.contains(namespace)
|| f.hidden_action_types.contains(&action.type_id())
}) {
return None; return None;
} }
@ -429,7 +432,7 @@ mod tests {
cx.update(|cx| { cx.update(|cx| {
cx.set_global(CommandPaletteFilter::default()); cx.set_global(CommandPaletteFilter::default());
cx.update_global::<CommandPaletteFilter, _>(|filter, _| { cx.update_global::<CommandPaletteFilter, _>(|filter, _| {
filter.filtered_namespaces.insert("editor"); filter.hidden_namespaces.insert("editor");
}) })
}); });

View File

@ -58,16 +58,16 @@ pub fn init(
cx.update_default_global::<collections::CommandPaletteFilter, _, _>(move |filter, _cx| { cx.update_default_global::<collections::CommandPaletteFilter, _, _>(move |filter, _cx| {
match status { match status {
Status::Disabled => { Status::Disabled => {
filter.filtered_namespaces.insert(COPILOT_NAMESPACE); filter.hidden_namespaces.insert(COPILOT_NAMESPACE);
filter.filtered_namespaces.insert(COPILOT_AUTH_NAMESPACE); filter.hidden_namespaces.insert(COPILOT_AUTH_NAMESPACE);
} }
Status::Authorized => { Status::Authorized => {
filter.filtered_namespaces.remove(COPILOT_NAMESPACE); filter.hidden_namespaces.remove(COPILOT_NAMESPACE);
filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE); filter.hidden_namespaces.remove(COPILOT_AUTH_NAMESPACE);
} }
_ => { _ => {
filter.filtered_namespaces.insert(COPILOT_NAMESPACE); filter.hidden_namespaces.insert(COPILOT_NAMESPACE);
filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE); filter.hidden_namespaces.remove(COPILOT_AUTH_NAMESPACE);
} }
} }
}); });

View File

@ -22,6 +22,7 @@ use request::StatusNotification;
use settings::SettingsStore; use settings::SettingsStore;
use smol::{fs, io::BufReader, stream::StreamExt}; use smol::{fs, io::BufReader, stream::StreamExt};
use std::{ use std::{
any::TypeId,
ffi::OsString, ffi::OsString,
mem, mem,
ops::Range, ops::Range,
@ -32,13 +33,14 @@ use util::{
fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt, fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt,
}; };
// todo!() actions!(
// const COPILOT_AUTH_NAMESPACE: &'static str = "copilot_auth"; Suggest,
actions!(SignIn, SignOut); NextSuggestion,
PreviousSuggestion,
// todo!() Reinstall,
// const COPILOT_NAMESPACE: &'static str = "copilot"; SignIn,
actions!(Suggest, NextSuggestion, PreviousSuggestion, Reinstall); SignOut
);
pub fn init( pub fn init(
new_server_id: LanguageServerId, new_server_id: LanguageServerId,
@ -51,52 +53,63 @@ pub fn init(
move |cx| Copilot::start(new_server_id, http, node_runtime, cx) move |cx| Copilot::start(new_server_id, http, node_runtime, cx)
}); });
cx.set_global(copilot.clone()); cx.set_global(copilot.clone());
cx.observe(&copilot, |handle, cx| {
let copilot_action_types = [
TypeId::of::<Suggest>(),
TypeId::of::<NextSuggestion>(),
TypeId::of::<PreviousSuggestion>(),
TypeId::of::<Reinstall>(),
];
let copilot_auth_action_types = [TypeId::of::<SignIn>(), TypeId::of::<SignOut>()];
// TODO let status = handle.read(cx).status();
// cx.observe(&copilot, |handle, cx| { let filter = cx.default_global::<collections::CommandPaletteFilter>();
// let status = handle.read(cx).status();
// cx.update_default_global::<collections::CommandPaletteFilter, _, _>(move |filter, _cx| {
// match status {
// Status::Disabled => {
// filter.filtered_namespaces.insert(COPILOT_NAMESPACE);
// filter.filtered_namespaces.insert(COPILOT_AUTH_NAMESPACE);
// }
// Status::Authorized => {
// filter.filtered_namespaces.remove(COPILOT_NAMESPACE);
// filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE);
// }
// _ => {
// filter.filtered_namespaces.insert(COPILOT_NAMESPACE);
// filter.filtered_namespaces.remove(COPILOT_AUTH_NAMESPACE);
// }
// }
// });
// })
// .detach();
// sign_in::init(cx); match status {
// cx.add_global_action(|_: &SignIn, cx| { Status::Disabled => {
// if let Some(copilot) = Copilot::global(cx) { filter.hidden_action_types.extend(copilot_action_types);
// copilot filter.hidden_action_types.extend(copilot_auth_action_types);
// .update(cx, |copilot, cx| copilot.sign_in(cx)) }
// .detach_and_log_err(cx); Status::Authorized => {
// } for type_id in copilot_action_types
// }); .iter()
// cx.add_global_action(|_: &SignOut, cx| { .chain(&copilot_auth_action_types)
// if let Some(copilot) = Copilot::global(cx) { {
// copilot filter.hidden_action_types.remove(type_id);
// .update(cx, |copilot, cx| copilot.sign_out(cx)) }
// .detach_and_log_err(cx); }
// } _ => {
// }); filter.hidden_action_types.extend(copilot_action_types);
for type_id in &copilot_auth_action_types {
filter.hidden_action_types.remove(type_id);
}
}
}
})
.detach();
// cx.add_global_action(|_: &Reinstall, cx| { sign_in::init(cx);
// if let Some(copilot) = Copilot::global(cx) { cx.on_action(|_: &SignIn, cx| {
// copilot if let Some(copilot) = Copilot::global(cx) {
// .update(cx, |copilot, cx| copilot.reinstall(cx)) copilot
// .detach(); .update(cx, |copilot, cx| copilot.sign_in(cx))
// } .detach_and_log_err(cx);
// }); }
});
cx.on_action(|_: &SignOut, cx| {
if let Some(copilot) = Copilot::global(cx) {
copilot
.update(cx, |copilot, cx| copilot.sign_out(cx))
.detach_and_log_err(cx);
}
});
cx.on_action(|_: &Reinstall, cx| {
if let Some(copilot) = Copilot::global(cx) {
copilot
.update(cx, |copilot, cx| copilot.reinstall(cx))
.detach();
}
});
} }
enum CopilotServer { enum CopilotServer {

View File

@ -9,314 +9,319 @@
// }; // };
// use theme::ui::modal; // use theme::ui::modal;
// #[derive(PartialEq, Eq, Debug, Clone)] const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot";
// struct CopyUserCode;
// #[derive(PartialEq, Eq, Debug, Clone)] use crate::{Copilot, Status};
// struct OpenGithub; use gpui::{
px, size, AppContext, Bounds, Div, GlobalPixels, Point, Render, ViewContext, VisualContext,
WindowBounds, WindowHandle, WindowKind, WindowOptions,
};
// const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot"; pub fn init(cx: &mut AppContext) {
if let Some(copilot) = Copilot::global(cx) {
let mut verification_window: Option<WindowHandle<CopilotCodeVerification>> = None;
cx.observe(&copilot, move |copilot, cx| {
let status = copilot.read(cx).status();
// pub fn init(cx: &mut AppContext) { match &status {
// if let Some(copilot) = Copilot::global(cx) { crate::Status::SigningIn { prompt } => {
// let mut verification_window: Option<WindowHandle<CopilotCodeVerification>> = None; if let Some(window) = verification_window.as_mut() {
// cx.observe(&copilot, move |copilot, cx| { let updated = window
// let status = copilot.read(cx).status(); .update(cx, |verification, cx| {
verification.set_status(status.clone(), cx);
cx.activate_window();
})
.is_ok();
if !updated {
verification_window = Some(create_copilot_auth_window(cx, &status));
}
} else if let Some(_prompt) = prompt {
verification_window = Some(create_copilot_auth_window(cx, &status));
}
}
Status::Authorized | Status::Unauthorized => {
if let Some(window) = verification_window.as_ref() {
window
.update(cx, |verification, cx| {
verification.set_status(status, cx);
cx.activate(true);
cx.activate_window();
})
.ok();
}
}
_ => {
if let Some(code_verification) = verification_window.take() {
code_verification.update(cx, |_, cx| cx.remove_window());
}
}
}
})
.detach();
}
}
// match &status { fn create_copilot_auth_window(
// crate::Status::SigningIn { prompt } => { cx: &mut AppContext,
// if let Some(window) = verification_window.as_mut() { status: &Status,
// let updated = window ) -> WindowHandle<CopilotCodeVerification> {
// .root(cx) let window_size = size(GlobalPixels::from(280.), GlobalPixels::from(280.));
// .map(|root| { let window_options = WindowOptions {
// root.update(cx, |verification, cx| { bounds: WindowBounds::Fixed(Bounds::new(Point::default(), window_size)),
// verification.set_status(status.clone(), cx); titlebar: None,
// cx.activate_window(); center: true,
// }) focus: true,
// }) show: true,
// .is_some(); kind: WindowKind::Normal,
// if !updated { is_movable: true,
// verification_window = Some(create_copilot_auth_window(cx, &status)); display_id: None,
// } };
// } else if let Some(_prompt) = prompt { cx.open_window(window_options, |cx| {
// verification_window = Some(create_copilot_auth_window(cx, &status)); cx.build_view(|_| CopilotCodeVerification::new(status.clone()))
// } })
// } }
// Status::Authorized | Status::Unauthorized => {
// if let Some(window) = verification_window.as_ref() {
// if let Some(verification) = window.root(cx) {
// verification.update(cx, |verification, cx| {
// verification.set_status(status, cx);
// cx.platform().activate(true);
// cx.activate_window();
// });
// }
// }
// }
// _ => {
// if let Some(code_verification) = verification_window.take() {
// code_verification.update(cx, |cx| cx.remove_window());
// }
// }
// }
// })
// .detach();
// }
// }
// fn create_copilot_auth_window( pub struct CopilotCodeVerification {
// cx: &mut AppContext, status: Status,
// status: &Status, connect_clicked: bool,
// ) -> WindowHandle<CopilotCodeVerification> { }
// let window_size = theme::current(cx).copilot.modal.dimensions();
// let window_options = WindowOptions {
// bounds: WindowBounds::Fixed(RectF::new(Default::default(), window_size)),
// titlebar: None,
// center: true,
// focus: true,
// show: true,
// kind: WindowKind::Normal,
// is_movable: true,
// screen: None,
// };
// cx.add_window(window_options, |_cx| {
// CopilotCodeVerification::new(status.clone())
// })
// }
// pub struct CopilotCodeVerification { impl CopilotCodeVerification {
// status: Status, pub fn new(status: Status) -> Self {
// connect_clicked: bool, Self {
// } status,
connect_clicked: false,
}
}
// impl CopilotCodeVerification { pub fn set_status(&mut self, status: Status, cx: &mut ViewContext<Self>) {
// pub fn new(status: Status) -> Self { self.status = status;
// Self { cx.notify();
// status, }
// connect_clicked: false,
// }
// }
// pub fn set_status(&mut self, status: Status, cx: &mut ViewContext<Self>) { // fn render_device_code(
// self.status = status; // data: &PromptUserDeviceFlow,
// cx.notify(); // style: &theme::Copilot,
// } // cx: &mut ViewContext<Self>,
// ) -> impl IntoAnyElement<Self> {
// let copied = cx
// .read_from_clipboard()
// .map(|item| item.text() == &data.user_code)
// .unwrap_or(false);
// fn render_device_code( // let device_code_style = &style.auth.prompting.device_code;
// data: &PromptUserDeviceFlow,
// style: &theme::Copilot,
// cx: &mut ViewContext<Self>,
// ) -> impl IntoAnyElement<Self> {
// let copied = cx
// .read_from_clipboard()
// .map(|item| item.text() == &data.user_code)
// .unwrap_or(false);
// let device_code_style = &style.auth.prompting.device_code; // MouseEventHandler::new::<Self, _>(0, cx, |state, _cx| {
// Flex::row()
// .with_child(
// Label::new(data.user_code.clone(), device_code_style.text.clone())
// .aligned()
// .contained()
// .with_style(device_code_style.left_container)
// .constrained()
// .with_width(device_code_style.left),
// )
// .with_child(
// Label::new(
// if copied { "Copied!" } else { "Copy" },
// device_code_style.cta.style_for(state).text.clone(),
// )
// .aligned()
// .contained()
// .with_style(*device_code_style.right_container.style_for(state))
// .constrained()
// .with_width(device_code_style.right),
// )
// .contained()
// .with_style(device_code_style.cta.style_for(state).container)
// })
// .on_click(gpui::platform::MouseButton::Left, {
// let user_code = data.user_code.clone();
// move |_, _, cx| {
// cx.platform()
// .write_to_clipboard(ClipboardItem::new(user_code.clone()));
// cx.notify();
// }
// })
// .with_cursor_style(gpui::platform::CursorStyle::PointingHand)
// }
// MouseEventHandler::new::<Self, _>(0, cx, |state, _cx| { // fn render_prompting_modal(
// Flex::row() // connect_clicked: bool,
// .with_child( // data: &PromptUserDeviceFlow,
// Label::new(data.user_code.clone(), device_code_style.text.clone()) // style: &theme::Copilot,
// .aligned() // cx: &mut ViewContext<Self>,
// .contained() // ) -> AnyElement<Self> {
// .with_style(device_code_style.left_container) // enum ConnectButton {}
// .constrained()
// .with_width(device_code_style.left),
// )
// .with_child(
// Label::new(
// if copied { "Copied!" } else { "Copy" },
// device_code_style.cta.style_for(state).text.clone(),
// )
// .aligned()
// .contained()
// .with_style(*device_code_style.right_container.style_for(state))
// .constrained()
// .with_width(device_code_style.right),
// )
// .contained()
// .with_style(device_code_style.cta.style_for(state).container)
// })
// .on_click(gpui::platform::MouseButton::Left, {
// let user_code = data.user_code.clone();
// move |_, _, cx| {
// cx.platform()
// .write_to_clipboard(ClipboardItem::new(user_code.clone()));
// cx.notify();
// }
// })
// .with_cursor_style(gpui::platform::CursorStyle::PointingHand)
// }
// fn render_prompting_modal( // Flex::column()
// connect_clicked: bool, // .with_child(
// data: &PromptUserDeviceFlow, // Flex::column()
// style: &theme::Copilot, // .with_children([
// cx: &mut ViewContext<Self>, // Label::new(
// ) -> AnyElement<Self> { // "Enable Copilot by connecting",
// enum ConnectButton {} // style.auth.prompting.subheading.text.clone(),
// )
// .aligned(),
// Label::new(
// "your existing license.",
// style.auth.prompting.subheading.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(style.auth.prompting.subheading.container),
// )
// .with_child(Self::render_device_code(data, &style, cx))
// .with_child(
// Flex::column()
// .with_children([
// Label::new(
// "Paste this code into GitHub after",
// style.auth.prompting.hint.text.clone(),
// )
// .aligned(),
// Label::new(
// "clicking the button below.",
// style.auth.prompting.hint.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(style.auth.prompting.hint.container.clone()),
// )
// .with_child(theme::ui::cta_button::<ConnectButton, _, _, _>(
// if connect_clicked {
// "Waiting for connection..."
// } else {
// "Connect to GitHub"
// },
// style.auth.content_width,
// &style.auth.cta_button,
// cx,
// {
// let verification_uri = data.verification_uri.clone();
// move |_, verification, cx| {
// cx.platform().open_url(&verification_uri);
// verification.connect_clicked = true;
// }
// },
// ))
// .align_children_center()
// .into_any()
// }
// Flex::column() // fn render_enabled_modal(
// .with_child( // style: &theme::Copilot,
// Flex::column() // cx: &mut ViewContext<Self>,
// .with_children([ // ) -> AnyElement<Self> {
// Label::new( // enum DoneButton {}
// "Enable Copilot by connecting",
// style.auth.prompting.subheading.text.clone(),
// )
// .aligned(),
// Label::new(
// "your existing license.",
// style.auth.prompting.subheading.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(style.auth.prompting.subheading.container),
// )
// .with_child(Self::render_device_code(data, &style, cx))
// .with_child(
// Flex::column()
// .with_children([
// Label::new(
// "Paste this code into GitHub after",
// style.auth.prompting.hint.text.clone(),
// )
// .aligned(),
// Label::new(
// "clicking the button below.",
// style.auth.prompting.hint.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(style.auth.prompting.hint.container.clone()),
// )
// .with_child(theme::ui::cta_button::<ConnectButton, _, _, _>(
// if connect_clicked {
// "Waiting for connection..."
// } else {
// "Connect to GitHub"
// },
// style.auth.content_width,
// &style.auth.cta_button,
// cx,
// {
// let verification_uri = data.verification_uri.clone();
// move |_, verification, cx| {
// cx.platform().open_url(&verification_uri);
// verification.connect_clicked = true;
// }
// },
// ))
// .align_children_center()
// .into_any()
// }
// fn render_enabled_modal( // let enabled_style = &style.auth.authorized;
// style: &theme::Copilot, // Flex::column()
// cx: &mut ViewContext<Self>, // .with_child(
// ) -> AnyElement<Self> { // Label::new("Copilot Enabled!", enabled_style.subheading.text.clone())
// enum DoneButton {} // .contained()
// .with_style(enabled_style.subheading.container)
// .aligned(),
// )
// .with_child(
// Flex::column()
// .with_children([
// Label::new(
// "You can update your settings or",
// enabled_style.hint.text.clone(),
// )
// .aligned(),
// Label::new(
// "sign out from the Copilot menu in",
// enabled_style.hint.text.clone(),
// )
// .aligned(),
// Label::new("the status bar.", enabled_style.hint.text.clone()).aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(enabled_style.hint.container),
// )
// .with_child(theme::ui::cta_button::<DoneButton, _, _, _>(
// "Done",
// style.auth.content_width,
// &style.auth.cta_button,
// cx,
// |_, _, cx| cx.remove_window(),
// ))
// .align_children_center()
// .into_any()
// }
// let enabled_style = &style.auth.authorized; // fn render_unauthorized_modal(
// Flex::column() // style: &theme::Copilot,
// .with_child( // cx: &mut ViewContext<Self>,
// Label::new("Copilot Enabled!", enabled_style.subheading.text.clone()) // ) -> AnyElement<Self> {
// .contained() // let unauthorized_style = &style.auth.not_authorized;
// .with_style(enabled_style.subheading.container)
// .aligned(),
// )
// .with_child(
// Flex::column()
// .with_children([
// Label::new(
// "You can update your settings or",
// enabled_style.hint.text.clone(),
// )
// .aligned(),
// Label::new(
// "sign out from the Copilot menu in",
// enabled_style.hint.text.clone(),
// )
// .aligned(),
// Label::new("the status bar.", enabled_style.hint.text.clone()).aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(enabled_style.hint.container),
// )
// .with_child(theme::ui::cta_button::<DoneButton, _, _, _>(
// "Done",
// style.auth.content_width,
// &style.auth.cta_button,
// cx,
// |_, _, cx| cx.remove_window(),
// ))
// .align_children_center()
// .into_any()
// }
// fn render_unauthorized_modal( // Flex::column()
// style: &theme::Copilot, // .with_child(
// cx: &mut ViewContext<Self>, // Flex::column()
// ) -> AnyElement<Self> { // .with_children([
// let unauthorized_style = &style.auth.not_authorized; // Label::new(
// "Enable Copilot by connecting",
// unauthorized_style.subheading.text.clone(),
// )
// .aligned(),
// Label::new(
// "your existing license.",
// unauthorized_style.subheading.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(unauthorized_style.subheading.container),
// )
// .with_child(
// Flex::column()
// .with_children([
// Label::new(
// "You must have an active copilot",
// unauthorized_style.warning.text.clone(),
// )
// .aligned(),
// Label::new(
// "license to use it in Zed.",
// unauthorized_style.warning.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(unauthorized_style.warning.container),
// )
// .with_child(theme::ui::cta_button::<Self, _, _, _>(
// "Subscribe on GitHub",
// style.auth.content_width,
// &style.auth.cta_button,
// cx,
// |_, _, cx| {
// cx.remove_window();
// cx.platform().open_url(COPILOT_SIGN_UP_URL)
// },
// ))
// .align_children_center()
// .into_any()
// }
}
// Flex::column() impl Render for CopilotCodeVerification {
// .with_child( type Element = Div;
// Flex::column()
// .with_children([ fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
// Label::new( todo!()
// "Enable Copilot by connecting", }
// unauthorized_style.subheading.text.clone(), }
// )
// .aligned(),
// Label::new(
// "your existing license.",
// unauthorized_style.subheading.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(unauthorized_style.subheading.container),
// )
// .with_child(
// Flex::column()
// .with_children([
// Label::new(
// "You must have an active copilot",
// unauthorized_style.warning.text.clone(),
// )
// .aligned(),
// Label::new(
// "license to use it in Zed.",
// unauthorized_style.warning.text.clone(),
// )
// .aligned(),
// ])
// .align_children_center()
// .contained()
// .with_style(unauthorized_style.warning.container),
// )
// .with_child(theme::ui::cta_button::<Self, _, _, _>(
// "Subscribe on GitHub",
// style.auth.content_width,
// &style.auth.cta_button,
// cx,
// |_, _, cx| {
// cx.remove_window();
// cx.platform().open_url(COPILOT_SIGN_UP_URL)
// },
// ))
// .align_children_center()
// .into_any()
// }
// }
// impl Entity for CopilotCodeVerification { // impl Entity for CopilotCodeVerification {
// type Event = (); // type Event = ();

View File

@ -1486,10 +1486,18 @@ impl<'a> WindowContext<'a> {
pub fn available_actions(&self) -> Vec<Box<dyn Action>> { pub fn available_actions(&self) -> Vec<Box<dyn Action>> {
if let Some(focus_id) = self.window.focus { if let Some(focus_id) = self.window.focus {
self.window let mut actions = self
.window
.current_frame .current_frame
.dispatch_tree .dispatch_tree
.available_actions(focus_id) .available_actions(focus_id);
actions.extend(
self.app
.global_action_listeners
.keys()
.filter_map(|type_id| self.app.actions.build_action_type(type_id).ok()),
);
actions
} else { } else {
Vec::new() Vec::new()
} }

View File

@ -101,7 +101,7 @@ pub fn init(cx: &mut AppContext) {
// will be initialized as disabled by default, so we filter its commands // will be initialized as disabled by default, so we filter its commands
// out when starting up. // out when starting up.
cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| { cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| {
filter.filtered_namespaces.insert("vim"); filter.hidden_namespaces.insert("vim");
}); });
cx.update_global(|vim: &mut Vim, cx: &mut AppContext| { cx.update_global(|vim: &mut Vim, cx: &mut AppContext| {
vim.set_enabled(settings::get::<VimModeSetting>(cx).0, cx) vim.set_enabled(settings::get::<VimModeSetting>(cx).0, cx)
@ -477,9 +477,9 @@ impl Vim {
cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| { cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| {
if self.enabled { if self.enabled {
filter.filtered_namespaces.remove("vim"); filter.hidden_namespaces.remove("vim");
} else { } else {
filter.filtered_namespaces.insert("vim"); filter.hidden_namespaces.insert("vim");
} }
}); });