Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat(desktop): splash screen, quit daemon prompt, update flow (#318)
Gener1ae48192d090
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b99f2d121..f8959e66a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -118,6 +118,9 @@ importers:'@tauri-apps/plugin-deep-link':specifier: ^2.2.0version: 2.4.9+ '@tauri-apps/plugin-dialog':+ specifier: ^2.2.0+ version: 2.7.1'@tauri-apps/plugin-global-shortcut':specifier: ^2.2.0version: 2.3.2@@ -3002,6 +3005,9 @@ packages:'@tauri-apps/[email protected]':resolution: {integrity: sha512-u0SKOUHnJ1wqeqXsDFq2+kASCBj9xxbG0g9XZWPy9SOmU4wXtp6b/wiYpm6oH6/5fBTQsLqnLhIvqLBRpgHJlA==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-OK1UBXYt+ojcmxMktzzuyonYIFta8CmAASpX+CA+DTGK24KlHjhYI6x2iOJ/TjZF4N7/ACK1oFmEOjIY9IhzOQ==}+'@tauri-apps/[email protected]':resolution: {integrity: sha512-UReHNXrLvpEjylE4jb4oCYiy96uRykPUthoCQCmRXYrd5hs5X9DrW+qOn7GLW57EJN4tdK8bgK5twBTz2NOxzA==}@@ -10834,6 +10840,10 @@ snapshots:dependencies:'@tauri-apps/api': 2.11.0+ '@tauri-apps/[email protected]':+ dependencies:+ '@tauri-apps/api': 2.11.0+'@tauri-apps/[email protected]':dependencies:'@tauri-apps/api': 2.11.0diff --git a/src/desktop/package.json b/src/desktop/package.jsonindex 877263b83..4e84df3f5 100644--- a/src/desktop/package.json+++ b/src/desktop/package.json@@ -13,6 +13,7 @@"@tauri-apps/api": "^2.5.0","@tauri-apps/plugin-autostart": "^2.2.0","@tauri-apps/plugin-deep-link": "^2.2.0",+ "@tauri-apps/plugin-dialog": "^2.2.0","@tauri-apps/plugin-global-shortcut": "^2.2.0","@tauri-apps/plugin-notification": "^2.2.0","@tauri-apps/plugin-shell": "^2.2.0"diff --git a/src/desktop/src-tauri/Cargo.lock b/src/desktop/src-tauri/Cargo.lockindex 5d559f3b2..66559b866 100644--- a/src/desktop/src-tauri/Cargo.lock+++ b/src/desktop/src-tauri/Cargo.lock@@ -36,6 +36,7 @@ dependencies = [name = "alook-desktop"version = "0.0.139"dependencies = [+ "base64 0.22.1","objc2","objc2-app-kit","objc2-foundation",@@ -46,6 +47,7 @@ dependencies = ["tauri-plugin-autostart","tauri-plugin-biometric","tauri-plugin-deep-link",+ "tauri-plugin-dialog","tauri-plugin-global-shortcut","tauri-plugin-notification","tauri-plugin-push",@@ -3161,6 +3163,30 @@ dependencies = ["web-sys",]+[[package]]+name = "rfd"+version = "0.16.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a15ad77d9e70a92437d8f74c35d99b4e4691128df018833e99f90bcd36152672"+dependencies = [+ "block2",+ "dispatch2",+ "glib-sys",+ "gobject-sys",+ "gtk-sys",+ "js-sys",+ "log",+ "objc2",+ "objc2-app-kit",+ "objc2-core-foundation",+ "objc2-foundation",+ "raw-window-handle",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+ "windows-sys 0.60.2",+]+[[package]]name = "ring"version = "0.17.14"@@ -4089,6 +4115,48 @@ dependencies = ["windows-result 0.3.4",]+[[package]]+name = "tauri-plugin-dialog"+version = "2.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65981abb771e74e571a38196c3baa11c459379164791eba0e67abc1a5fac9884"+dependencies = [+ "log",+ "raw-window-handle",+ "rfd",+ "serde",+ "serde_json",+ "tauri",+ "tauri-plugin",+ "tauri-plugin-fs",+ "thiserror 2.0.18",+ "url",+]++[[package]]+name = "tauri-plugin-fs"+version = "2.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b7ecc274121aca0c036a2b42d1cbe83d368d348f54e0bb8a735c2b1548e8f371"+dependencies = [+ "anyhow",+ "dunce",+ "glob",+ "log",+ "objc2-foundation",+ "percent-encoding",+ "schemars 0.8.22",+ "serde",+ "serde_json",+ "serde_repr",+ "tauri",+ "tauri-plugin",+ "tauri-utils",+ "thiserror 2.0.18",+ "toml 1.1.2+spec-1.1.0",+ "url",+]+[[package]]name = "tauri-plugin-global-shortcut"version = "2.3.2"diff --git a/src/desktop/src-tauri/Cargo.toml b/src/desktop/src-tauri/Cargo.tomlindex 40a9995bf..dbc6d7cb4 100644--- a/src/desktop/src-tauri/Cargo.toml+++ b/src/desktop/src-tauri/Cargo.toml@@ -15,7 +15,7 @@ crate-type = ["lib", "cdylib", "staticlib"]tauri-build = { version = "2", features = [] }[dependencies]-tauri = { version = "2", features = ["tray-icon", "image-png"] }+tauri = { version = "2", features = ["tray-icon", "image-png", "macos-private-api"] }tauri-plugin-deep-link = "2"tauri-plugin-notification = "2"serde = { version = "1", features = ["derive"] }@@ -26,6 +26,8 @@ tauri-plugin-shell = "2"tauri-plugin-autostart = "2"tauri-plugin-global-shortcut = "2"tauri-plugin-updater = "2"+tauri-plugin-dialog = "2"+base64 = "0.22"[target."cfg(target_os = \"macos\")".dependencies]objc2 = "0.6"diff --git a/src/desktop/src-tauri/capabilities/desktop.json b/src/desktop/src-tauri/capabilities/desktop.jsonindex d0d867536..75b268e3f 100644--- a/src/desktop/src-tauri/capabilities/desktop.json+++ b/src/desktop/src-tauri/capabilities/desktop.json@@ -16,6 +16,7 @@"autostart:allow-is-enabled","core:tray:default","core:window:allow-start-dragging",- "updater:default"+ "updater:default",+ "dialog:default"]}diff --git a/src/desktop/src-tauri/src/commands.rs b/src/desktop/src-tauri/src/commands.rsindex 822ef0352..d4820a633 100644--- a/src/desktop/src-tauri/src/commands.rs+++ b/src/desktop/src-tauri/src/commands.rs@@ -129,6 +129,123 @@ fn to_command_result(output: CliOutput) -> CommandResult {}}+// --- Splashscreen ---++#[cfg(desktop)]+static SPLASH_CLOSED: AtomicBool = AtomicBool::new(false);++#[cfg(desktop)]+static SPLASH_READY: AtomicBool = AtomicBool::new(false);++#[cfg(desktop)]+static SPLASH_MIN_ELAPSED: AtomicBool = AtomicBool::new(false);++#[cfg(desktop)]+pub fn splash_html() -> String {+ use base64::Engine;+ let icon_bytes = include_bytes!("../icons/icon.png");+ let icon_b64 = base64::engine::general_purpose::STANDARD.encode(icon_bytes);+ format!(+ concat!(+ "<html><head><meta charset=\"utf-8\"><style>",+ "*{{margin:0;padding:0;box-sizing:border-box}}",+ "html,body{{width:100%;height:100%;overflow:hidden;background:transparent;",+ "display:flex;align-items:center;justify-content:center;",+ "-webkit-user-select:none;user-select:none}}",+ ".logo{{width:96px;height:96px;border-radius:22px;opacity:0;",+ "animation:fi .4s ease-out .1s forwards;",+ "box-shadow:0 8px 32px rgba(0,0,0,0.18)}}",+ "@keyframes fi{{from{{opacity:0;transform:scale(.88)}}to{{opacity:1;transform:scale(1)}}}}",+ "</style></head><body>",+ "<img class=\"logo\" src=\"data:image/png;base64,{}\" draggable=\"false\">",+ "</body></html>",+ ),+ icon_b64+ )+}++#[cfg(desktop)]+pub fn create_splash_window(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {+ use tauri::{WebviewUrl, WebviewWindowBuilder};++ WebviewWindowBuilder::new(app, "splash", WebviewUrl::CustomProtocol("splash://index".parse()?))+ .title("Alook")+ .inner_size(200.0, 200.0)+ .center()+ .decorations(false)+ .resizable(false)+ .transparent(true)+ .shadow(false)+ .always_on_top(true)+ .skip_taskbar(true)+ .build()?;++ Ok(())+}++#[cfg(desktop)]+pub fn do_close_splashscreen(handle: &AppHandle) {+ if SPLASH_CLOSED.swap(true, Ordering::SeqCst) {+ return;+ }+ if let Some(main) = handle.get_webview_window("main") {+ let _ = main.show();+ let _ = main.set_focus();+ }+ let h = handle.clone();+ std::thread::spawn(move || {+ fade_out_and_close_splash(&h);+ });+}++#[cfg(desktop)]+fn fade_out_and_close_splash(handle: &AppHandle) {+ let Some(splash) = handle.get_webview_window("splash") else { return };++ #[cfg(target_os = "macos")]+ {+ use objc2::runtime::AnyObject;+ use objc2::msg_send;+ unsafe {+ let ns_window = splash.ns_window().unwrap() as *mut AnyObject;+ for i in (0..=5).rev() {+ let alpha = i as f64 / 5.0;+ let _: () = msg_send![ns_window, setAlphaValue: alpha];+ std::thread::sleep(std::time::Duration::from_millis(40));+ }+ }+ }++ #[cfg(not(target_os = "macos"))]+ {+ std::thread::sleep(std::time::Duration::from_millis(200));+ }++ let _ = splash.close();+}++#[cfg(desktop)]+fn try_close_splashscreen(handle: &AppHandle) {+ if SPLASH_READY.load(Ordering::SeqCst) && SPLASH_MIN_ELAPSED.load(Ordering::SeqCst) {+ do_close_splashscreen(handle);+ }+}++#[cfg(desktop)]+pub fn mark_splash_min_elapsed(handle: &AppHandle) {+ SPLASH_MIN_ELAPSED.store(true, Ordering::SeqCst);+ try_close_splashscreen(handle);+}++#[cfg(desktop)]+#[tauri::command]+pub fn close_splashscreen(app: AppHandle) {+ SPLASH_READY.store(true, Ordering::SeqCst);+ try_close_splashscreen(&app);+}++// --- CLI commands ---+#[cfg(desktop)]#[tauri::command]pub fn get_cli_info() -> CliInfo {@@ -236,13 +353,22 @@ pub async fn cli_check(app: AppHandle) -> Result<CommandResult, String> {})}-#[derive(Serialize)]+// --- App updater ---++#[derive(Serialize, Clone)]pub struct UpdateInfo {pub available: bool,pub version: Option<String>,pub notes: Option<String>,}+#[derive(Serialize, Clone)]+struct UpdateProgress {+ percent: f64,+ downloaded: u64,+ total: Option<u64>,+}+#[cfg(desktop)]#[tauri::command]pub async fn check_for_updates(app: AppHandle) -> Result<UpdateInfo, String> {@@ -267,10 +393,27 @@ pub async fn check_for_updates(app: AppHandle) -> Result<UpdateInfo, String> {#[tauri::command]pub async fn install_update(app: AppHandle) -> Result<(), String> {use tauri_plugin_updater::UpdaterExt;+ use tauri::Emitter;+let updater = app.updater().map_err(|e| e.to_string())?;let update = updater.check().await.map_err(|e| e.to_string())?.ok_or("No update available".to_string())?;- update.download_and_install(|_, _| {}, || {}).await.map_err(|e| e.to_string())?;++ let handle = app.clone();+ let mut cumulative: u64 = 0;+ update.download_and_install(+ move |chunk_size, total| {+ cumulative += chunk_size as u64;+ let percent = total.map(|t| (cumulative as f64 / t as f64) * 100.0).unwrap_or(0.0);+ let _ = handle.emit("update://progress", UpdateProgress {+ percent,+ downloaded: cumulative,+ total,+ });+ },+ || {},+ ).await.map_err(|e| e.to_string())?;+app.restart();}@@ -308,6 +451,8 @@ pub fn is_daemon_online() -> bool {DAEMON_ONLINE.load(Ordering::Relaxed)}+// --- Daemon state ---+#[cfg(desktop)]pub static DAEMON_ONLINE: AtomicBool = AtomicBool::new(false);@@ -320,6 +465,8 @@ static UPDATE_AVAILABLE_VERSION: std::sync::Mutex<Option<String>> = std::sync::M#[cfg(desktop)]static UPDATE_IN_PROGRESS: AtomicBool = AtomicBool::new(false);+// --- System tray ---+#[cfg(desktop)]pub fn setup_tray(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {use tauri::{@@ -365,10 +512,7 @@ pub fn setup_tray(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {}"quit" => {let handle = app.clone();- tauri::async_runtime::spawn(async move {- stop_daemon_async(&handle).await;- handle.exit(0);- });+ quit_with_daemon_prompt(&handle);}_ => {}})@@ -407,16 +551,49 @@ pub fn setup_tray(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {Ok(())}+// --- Quit with daemon prompt ---++#[cfg(desktop)]+fn quit_with_daemon_prompt(handle: &AppHandle) {+ use tauri_plugin_dialog::{DialogExt, MessageDialogButtons};++ if !DAEMON_STARTED_BY_US.load(Ordering::Relaxed) {+ handle.exit(0);+ return;+ }++ let h = handle.clone();+ handle.dialog()+ .message("The Alook daemon is running in the background.\n\nWould you like to keep it running after quitting?")+ .title("Quit Alook")+ .buttons(MessageDialogButtons::OkCancelCustom("Keep Running".into(), "Stop & Quit".into()))+ .show(move |keep_running| {+ if !keep_running {+ let h2 = h.clone();+ tauri::async_runtime::spawn(async move {+ let _ = run_cli(&h2, &["daemon", "stop"]).await;+ h2.exit(0);+ });+ } else {+ h.exit(0);+ }+ });+}++// --- Update flow ---+#[cfg(desktop)]async fn do_install_update(handle: &AppHandle) {use tauri_plugin_updater::UpdaterExt;+ use tauri_plugin_dialog::{DialogExt, MessageDialogButtons};+ use tauri::Emitter;if UPDATE_IN_PROGRESS.swap(true, Ordering::SeqCst) {- let _ = handle.notification()- .builder()+ handle.dialog()+ .message("An update is already in progress.").title("Alook")- .body("Update already in progress...")- .show();+ .buttons(MessageDialogButtons::OkCustom("OK".into()))+ .show(|_| {});return;}@@ -424,11 +601,11 @@ async fn do_install_update(handle: &AppHandle) {Ok(u) => u,Err(e) => {UPDATE_IN_PROGRESS.store(false, Ordering::SeqCst);- let _ = handle.notification()- .builder()- .title("Alook")- .body(&format!("Update check failed: {}", e))- .show();+ handle.dialog()+ .message(&format!("Could not check for updates: {}", e))+ .title("Update Check Failed")+ .buttons(MessageDialogButtons::OkCustom("OK".into()))+ .show(|_| {});return;}};@@ -436,38 +613,91 @@ async fn do_install_update(handle: &AppHandle) {match updater.check().await {Ok(Some(update)) => {let version = update.version.clone();+ let notes = update.body.clone().unwrap_or_default();+ let msg = if notes.is_empty() {+ format!("Version {} is available. Download and install?", version)+ } else {+ format!("Version {} is available.\n\n{}\n\nDownload and install?", version, notes)+ };++ let (tx, rx) = std::sync::mpsc::channel();+ handle.dialog()+ .message(&msg)+ .title("Update Available")+ .buttons(MessageDialogButtons::OkCancelCustom("Update".into(), "Later".into()))+ .show(move |confirmed| {+ let _ = tx.send(confirmed);+ });++ let confirmed = rx.recv().unwrap_or(false);+ if !confirmed {+ UPDATE_IN_PROGRESS.store(false, Ordering::SeqCst);+ return;+ }+let _ = handle.notification().builder().title("Alook")- .body(&format!("Installing update v{}...", version))+ .body(&format!("Downloading v{}...", version)).show();- match update.download_and_install(|_, _| {}, || {}).await {- Ok(_) => handle.restart(),++ let h = handle.clone();+ let mut cumulative: u64 = 0;+ let result = update.download_and_install(+ move |chunk_size, total| {+ cumulative += chunk_size as u64;+ let percent = total.map(|t| (cumulative as f64 / t as f64) * 100.0).unwrap_or(0.0);+ let _ = h.emit("update://progress", UpdateProgress {+ percent,+ downloaded: cumulative,+ total,+ });+ },+ || {},+ ).await;++ match result {+ Ok(_) => {+ let (tx2, rx2) = std::sync::mpsc::channel();+ handle.dialog()+ .message(&format!("Version {} has been installed. Restart now?", version))+ .title("Update Complete")+ .buttons(MessageDialogButtons::OkCancelCustom("Restart".into(), "Later".into()))+ .show(move |restart| {+ let _ = tx2.send(restart);+ });++ if rx2.recv().unwrap_or(false) {+ handle.restart();+ } else {+ UPDATE_IN_PROGRESS.store(false, Ordering::SeqCst);+ }+ }Err(e) => {UPDATE_IN_PROGRESS.store(false, Ordering::SeqCst);- let _ = handle.notification()- .builder()- .title("Alook")- .body(&format!("Update failed: {}", e))- .show();+ handle.dialog()+ .message(&format!("Download failed: {}", e))+ .title("Update Failed")+ .buttons(MessageDialogButtons::OkCustom("OK".into()))+ .show(|_| {});}}}Ok(None) => {UPDATE_IN_PROGRESS.store(false, Ordering::SeqCst);- let _ = handle.notification()- .builder()- .title("Alook")- .body("You're on the latest version.")- .show();+ handle.dialog()+ .message("You're on the latest version.")+ .title("No Updates Available")+ .buttons(MessageDialogButtons::OkCustom("OK".into()))+ .show(|_| {});}Err(e) => {UPDATE_IN_PROGRESS.store(false, Ordering::SeqCst);- let _ = handle.notification()- .builder()- .title("Alook")- .body(&format!("Update check failed: {}", e))- .show();+ handle.dialog()+ .message(&format!("Could not check for updates: {}", e))+ .title("Update Check Failed")+ .buttons(MessageDialogButtons::OkCustom("OK".into()))+ .show(|_| {});}}}@@ -477,10 +707,9 @@ pub fn auto_check_updates(handle: AppHandle) {use tauri_plugin_updater::UpdaterExt;std::thread::spawn(move || {- // Initial delay — let app finish launchingstd::thread::sleep(std::time::Duration::from_secs(30));- let interval = std::time::Duration::from_secs(30 * 60); // 30 minutes+ let interval = std::time::Duration::from_secs(30 * 60);loop {let h = handle.clone();let found = tauri::async_runtime::block_on(async {@@ -508,6 +737,8 @@ pub fn auto_check_updates(handle: AppHandle) {});}+// --- Daemon helpers ---+#[cfg(desktop)]async fn check_daemon_online(handle: &AppHandle) -> bool {match run_cli(handle, &["daemon", "status"]).await {@@ -516,11 +747,6 @@ async fn check_daemon_online(handle: &AppHandle) -> bool {}}-#[cfg(desktop)]-async fn stop_daemon_async(handle: &AppHandle) {- let _ = run_cli(handle, &["daemon", "stop"]).await;-}-#[cfg(desktop)]pub fn auto_start_daemon(handle: AppHandle) {tauri::async_runtime::spawn(async move {diff --git a/src/desktop/src-tauri/src/lib.rs b/src/desktop/src-tauri/src/lib.rsindex 44fda025c..46d7758ae 100644--- a/src/desktop/src-tauri/src/lib.rs+++ b/src/desktop/src-tauri/src/lib.rs@@ -17,7 +17,8 @@ pub fn run() {None,)).plugin(tauri_plugin_global_shortcut::Builder::new().build())- .plugin(tauri_plugin_updater::Builder::new().build());+ .plugin(tauri_plugin_updater::Builder::new().build())+ .plugin(tauri_plugin_dialog::init());}// Mobile-only plugins@@ -31,6 +32,18 @@ pub fn run() {.plugin(tauri_plugin_deep_link::init()).plugin(tauri_plugin_notification::init());+ // Register splash:// protocol to serve inline HTML for the splash window+ #[cfg(desktop)]+ {+ builder = builder.register_uri_scheme_protocol("splash", |_ctx, _req| {+ let html = commands::splash_html();+ tauri::http::Response::builder()+ .header("content-type", "text/html; charset=utf-8")+ .body(html.into_bytes())+ .unwrap()+ });+ }+// Register IPC commands (desktop only)#[cfg(desktop)]{@@ -46,6 +59,7 @@ pub fn run() {commands::install_update,commands::set_window_theme,commands::is_daemon_online,+ commands::close_splashscreen,]);}@@ -57,12 +71,28 @@ pub fn run() {commands::auto_start_daemon(app.handle().clone());commands::auto_check_updates(app.handle().clone());+ // Create splash window with inline HTML (frontendDist is remote, so url won't work)+ commands::create_splash_window(app)?;++ // Minimum splash display time (1s) to prevent flash+ let h1 = app.handle().clone();+ std::thread::spawn(move || {+ std::thread::sleep(std::time::Duration::from_millis(1000));+ commands::mark_splash_min_elapsed(&h1);+ });++ // Safety timeout: force-close splash after 5s even if frontend never signals+ let h2 = app.handle().clone();+ std::thread::spawn(move || {+ std::thread::sleep(std::time::Duration::from_secs(5));+ commands::do_close_splashscreen(&h2);+ });+// macOS: inset the webview with rounded corners, window bg as frame#[cfg(target_os = "macos")]{use tauri::Manager;if let Some(window) = app.get_webview_window("main") {- // Set default light background (Web will call set_window_theme to sync)commands::set_window_theme(window.clone(), false);macos_window::setup_inset_webview(&window);}diff --git a/src/desktop/src-tauri/tauri.conf.json b/src/desktop/src-tauri/tauri.conf.jsonindex dff97b2e6..cdf19cd7b 100644--- a/src/desktop/src-tauri/tauri.conf.json+++ b/src/desktop/src-tauri/tauri.conf.json@@ -23,6 +23,7 @@},"app": {"withGlobalTauri": true,+ "macOSPrivateApi": true,"windows": [{"label": "main",@@ -32,6 +33,7 @@"minWidth": 800,"minHeight": 600,"center": true,+ "visible": false,"titleBarStyle": "Overlay","hiddenTitle": true,"trafficLightPosition": {diff --git a/src/web/src/components/tauri-theme-sync.tsx b/src/web/src/components/tauri-theme-sync.tsxindex 7121b56a0..528771d0c 100644--- a/src/web/src/components/tauri-theme-sync.tsx+++ b/src/web/src/components/tauri-theme-sync.tsx@@ -11,9 +11,9 @@ export function TauriThemeSync() {if (!isTauri() || !isDesktop()) return;if (!resolvedTheme) return;- tauriInvoke("set_window_theme", { dark: resolvedTheme === "dark" }).catch(- () => {},- );+ tauriInvoke("set_window_theme", { dark: resolvedTheme === "dark" })+ .then(() => tauriInvoke("close_splashscreen"))+ .catch(() => {});}, [resolvedTheme]);return null;