fix(platform): own WSL setup and notification dispatch gates

This commit is contained in:
kuddev committed 2026-09-20 19:53:50 +08:00
1 parent 553f25acb4
commit 92c97ed619
9 files changed
+32 -14

No files matched your search

-2
View File
@@ -18,8 +18,6 @@ mod ordering;
mod payload;
mod protocol;
pub(crate) mod remote;
#[cfg(windows)]
pub(crate) mod wsl;
pub(crate) use event::CodexHookMode;
pub use event::{
@@ -158,8 +158,7 @@ pub(super) fn local_options(
// 身份契约必须最后写:它以环境表里 `WSLENV` 的现值为基准合并,才能同时
// 保住上面那段的 cwd 上报条目。见 [`crate::agent_env`]。
crate::agent_env::apply(&mut options.env, pane_id);
#[cfg(windows)]
crate::ai_hook::wsl::prepare(&mut options);
crate::platform::wsl_hooks::prepare(&mut options);
options
}
+1 -1
View File
@@ -256,7 +256,7 @@ fn main() -> Result<(), Box<dyn Error>> {
#[cfg(windows)]
Some(Subcommands::SetupAi(options)) => {
if let Some(distro) = &options.wsl {
std::process::exit(crate::ai_hook::wsl::setup_cli(
std::process::exit(crate::platform::wsl_hooks::setup_cli(
distro,
options.wsl_user.as_deref(),
options.remove,
+1 -8
View File
@@ -517,14 +517,7 @@ fn spawn_actionable_toast(
activation: Option<ToastActivation>,
actions: Vec<crate::platform::notifications::ToastAction>,
) {
#[cfg(windows)]
crate::platform::notifications::toast_actionable(&title, &body, activation, actions);
#[cfg(not(windows))]
if let Err(error) = std::thread::Builder::new().name("pebrel-toast".into()).spawn(move || {
crate::platform::notifications::toast_actionable(&title, &body, activation, actions)
}) {
log::warn!("notify: failed to spawn toast thread: {error}");
}
crate::platform::notifications::dispatch(title, body, activation, actions);
}
#[cfg(test)]
+1
View File
@@ -36,6 +36,7 @@ pub mod startup;
pub(crate) mod update_installation;
#[cfg(feature = "gpui-shell")]
pub(crate) mod window_chrome;
pub(crate) mod wsl_hooks;
pub use capabilities::CAPABILITIES;
+19
View File
@@ -16,6 +16,25 @@ pub(crate) fn toast_clickable(title: &str, body: &str, activation: Option<ToastA
toast_actionable(title, body, activation, Vec::new());
}
/// Dispatch owns the platform's worker and COM lifetime; notification policy
/// remains in the application capability.
pub(crate) fn dispatch(
title: String,
body: String,
activation: Option<ToastActivation>,
actions: Vec<ToastAction>,
) {
#[cfg(windows)]
toast_actionable(&title, &body, activation, actions);
#[cfg(not(windows))]
if let Err(error) = std::thread::Builder::new()
.name("pebrel-toast".into())
.spawn(move || toast_actionable(&title, &body, activation, actions))
{
log::warn!("notify: failed to spawn toast thread: {error}");
}
}
#[cfg(target_os = "macos")]
static MACOS_READY: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+8
View File
@@ -0,0 +1,8 @@
//! Guest hook setup is a Windows transport capability. Provider policy stays in ai_hook.
#[cfg(windows)]
mod windows;
#[cfg(windows)]
pub(crate) use windows::{prepare, setup_cli};
#[cfg(not(windows))]
pub(crate) fn prepare(_options: &mut nebula_terminal::tty::Options) {}
@@ -13,7 +13,7 @@ use std::time::{Duration, Instant};
use nebula_terminal::tty;
use serde_json::json;
use super::remote::{self, Action, Snapshot};
use crate::ai_hook::remote::{self, Action, Snapshot};
const BUDGET: Duration = Duration::from_secs(8);
const MAX_OUTPUT: u64 = 20 * 1024 * 1024;