Includes prior-session patches (carry forward so the app compiles): - crates/gpui/build.rs: cross-compile manifest fix - crates/gpui/src/platform.rs: PlatformWindow::activate_with_token trait method - crates/gpui/src/window.rs: Window::activate_with_token public API - crates/gpui_linux/src/linux/wayland/window.rs: WaylandWindow::activate_with_token + activate() keyboard-serial fix Plus the focus-serial fix: - serial.rs: SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; latest_serial_of() Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
69 lines
1.9 KiB
Rust
69 lines
1.9 KiB
Rust
mod cloud;
|
|
|
|
use client::{Client, UserStore};
|
|
use gpui::{App, Context, Entity};
|
|
use language_model::LanguageModelRegistry;
|
|
use std::sync::Arc;
|
|
use web_search::{WebSearchProviderId, WebSearchRegistry};
|
|
|
|
pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
|
|
let registry = WebSearchRegistry::global(cx);
|
|
registry.update(cx, |registry, cx| {
|
|
register_web_search_providers(registry, client, user_store, cx);
|
|
});
|
|
}
|
|
|
|
fn register_web_search_providers(
|
|
registry: &mut WebSearchRegistry,
|
|
client: Arc<Client>,
|
|
user_store: Entity<UserStore>,
|
|
cx: &mut Context<WebSearchRegistry>,
|
|
) {
|
|
register_zed_web_search_provider(
|
|
registry,
|
|
client.clone(),
|
|
user_store.clone(),
|
|
&LanguageModelRegistry::global(cx),
|
|
cx,
|
|
);
|
|
|
|
cx.subscribe(
|
|
&LanguageModelRegistry::global(cx),
|
|
move |this, registry, event, cx| {
|
|
if let language_model::Event::DefaultModelChanged = event {
|
|
register_zed_web_search_provider(
|
|
this,
|
|
client.clone(),
|
|
user_store.clone(),
|
|
®istry,
|
|
cx,
|
|
)
|
|
}
|
|
},
|
|
)
|
|
.detach();
|
|
}
|
|
|
|
fn register_zed_web_search_provider(
|
|
registry: &mut WebSearchRegistry,
|
|
client: Arc<Client>,
|
|
user_store: Entity<UserStore>,
|
|
language_model_registry: &Entity<LanguageModelRegistry>,
|
|
cx: &mut Context<WebSearchRegistry>,
|
|
) {
|
|
let using_zed_provider = language_model_registry
|
|
.read(cx)
|
|
.default_model()
|
|
.is_some_and(|default| default.is_provided_by_zed());
|
|
if using_zed_provider {
|
|
registry.register_provider(
|
|
cloud::CloudWebSearchProvider::new(client, user_store, cx),
|
|
cx,
|
|
)
|
|
} else {
|
|
registry.unregister_provider(WebSearchProviderId(
|
|
cloud::ZED_WEB_SEARCH_PROVIDER_ID.into(),
|
|
));
|
|
}
|
|
}
|