first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use galaxyui::{Entity, ModelContext, SingletonEntity};
|
||||
use galaxyui_core::{Entity, ModelContext, SingletonEntity};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
|
||||
// Global execution mode, for logic that runs outside the UI framework.
|
||||
static GLOBAL_EXECUTION_MODE: OnceLock<ExecutionMode> = OnceLock::new();
|
||||
|
||||
@@ -11,6 +12,8 @@ pub enum ExecutionMode {
|
||||
App,
|
||||
/// Warp is running as a CLI.
|
||||
Sdk,
|
||||
/// Warp is running as the remote server daemon.
|
||||
RemoteServerDaemon,
|
||||
}
|
||||
|
||||
impl ExecutionMode {
|
||||
@@ -20,6 +23,7 @@ impl ExecutionMode {
|
||||
match self {
|
||||
ExecutionMode::App => "warp-app",
|
||||
ExecutionMode::Sdk => "warp-cli",
|
||||
ExecutionMode::RemoteServerDaemon => "warp-remote-server-daemon",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +70,7 @@ impl AppExecutionMode {
|
||||
|
||||
/// Whether the app can *automatically* update. This does not prevent manual updates.
|
||||
pub fn can_autoupdate(&self) -> bool {
|
||||
self.is_app()
|
||||
self.is_app() && cfg!(not(target_family = "wasm"))
|
||||
}
|
||||
|
||||
/// Whether the app can automatically start MCP servers from the previous session.
|
||||
@@ -74,6 +78,13 @@ impl AppExecutionMode {
|
||||
self.is_app()
|
||||
}
|
||||
|
||||
/// Whether the app can show interactive onboarding UIs (e.g. the onboarding
|
||||
/// callout tutorial). Onboarding requires a user to interact with it, so it
|
||||
/// is disabled in headless modes like SDK/CLI.
|
||||
pub fn can_show_onboarding(&self) -> bool {
|
||||
self.is_app()
|
||||
}
|
||||
|
||||
/// Whether the app can sync agent conversations (tasks and cloud conversation metadata).
|
||||
/// In CLI mode, we don't need this data since there's no user viewing it.
|
||||
pub fn can_fetch_agent_runs_for_management(&self) -> bool {
|
||||
@@ -81,17 +92,23 @@ impl AppExecutionMode {
|
||||
}
|
||||
|
||||
/// Whether telemetry should be sent synchronously at shutdown.
|
||||
/// In CLI mode, we synchronously send events at shutdown because there's a higher likelihood
|
||||
/// that they will be lost otherwise.
|
||||
/// In CLI and daemon modes, we synchronously send events at shutdown because there's a
|
||||
/// higher likelihood that they will be lost otherwise.
|
||||
pub fn send_telemetry_at_shutdown(&self) -> bool {
|
||||
matches!(self.mode, ExecutionMode::Sdk)
|
||||
matches!(
|
||||
self.mode,
|
||||
ExecutionMode::Sdk | ExecutionMode::RemoteServerDaemon
|
||||
)
|
||||
}
|
||||
|
||||
/// If true, the app is running autonomously, without a user present.
|
||||
/// Wherever possible, prefer more targeted capability checks like
|
||||
/// [`Self::can_autostart_mcp_servers`].
|
||||
pub fn is_autonomous(&self) -> bool {
|
||||
matches!(self.mode, ExecutionMode::Sdk)
|
||||
matches!(
|
||||
self.mode,
|
||||
ExecutionMode::Sdk | ExecutionMode::RemoteServerDaemon
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the client ID to report to the server.
|
||||
@@ -112,7 +129,7 @@ impl Entity for AppExecutionMode {
|
||||
|
||||
impl SingletonEntity for AppExecutionMode {}
|
||||
|
||||
/// Returns the current global client ID string ("warp-app" or "warp-cli").
|
||||
/// Returns the current global client ID string ("warp-app", "warp-cli", or "warp-remote-server-daemon").
|
||||
/// This is set when AppExecutionMode is constructed during application start.
|
||||
/// Returns None if the execution mode has not been set yet.
|
||||
pub fn current_client_id() -> Option<&'static str> {
|
||||
|
||||
Reference in New Issue
Block a user