fix(platform): own WSL setup and notification dispatch gates
This commit is contained in:
1 parent
553f25acb4
commit
92c97ed619
9 files changed
+32
-14
No files matched your search
File renamed without changes.
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
Reference in new issue
Block a user