From 47071b586155831831d73092257a17bbb4c11fd0 Mon Sep 17 00:00:00 2001 From: iamdoubz <> Date: Tue, 14 Jul 2026 16:21:33 -0500 Subject: [PATCH] feat(app): set_auto_start command + default_settings/save_settings visibility --- src-tauri/src/commands.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index a0a27d8..0340017 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -55,7 +55,7 @@ pub struct StartRecordingArgs { // `settings.json` per `docs/03-data-model.md`; meeting rows/files go through // `AppState.store` (Phase 2, `storage::SqliteStore`). -fn default_settings() -> Settings { +pub(crate) fn default_settings() -> Settings { Settings { theme: "system".into(), storage_root: wa_root().display().to_string(), @@ -87,6 +87,7 @@ fn default_settings() -> Settings { mcp_port: 4849, mcp_expose: "none".into(), mcp_expose_recordings: false, + auto_start: false, } } @@ -97,7 +98,7 @@ pub(crate) fn load_settings() -> Settings { .unwrap_or_else(default_settings) } -fn save_settings(settings: &Settings) -> Result<(), WaError> { +pub(crate) fn save_settings(settings: &Settings) -> Result<(), WaError> { let path = settings_path(); if let Some(parent) = path.parent() { std::fs::create_dir_all(parent).map_err(|e| WaError::new("settings", e.to_string()))?; @@ -1444,6 +1445,26 @@ pub async fn set_preferred_backend(args: SetPreferredBackendArgs) -> WaResult<() save_settings(&settings) } +/// Enable/disable launch-at-login (NFR-RES-4). Writes a per-user `HKCU\...\Run` +/// entry via `tauri-plugin-autostart` (no admin) and persists the choice so the +/// startup reconcile in `lib.rs` keeps the OS entry in sync after a reinstall. +/// Opt-in only: nothing calls this unless the user toggles it (or an enterprise +/// deploy file set `auto_start=true`). +#[tauri::command] +pub async fn set_auto_start(app: AppHandle, enabled: bool) -> WaResult<()> { + use tauri_plugin_autostart::ManagerExt; + let manager = app.autolaunch(); + let res = if enabled { + manager.enable() + } else { + manager.disable() + }; + res.map_err(|e| WaError::new("autostart", e.to_string()))?; + let mut settings = load_settings(); + settings.auto_start = enabled; + save_settings(&settings) +} + /// True when the NPU ONNX Whisper model is downloaded (false on non-NPU builds). fn npu_model_installed() -> bool { #[cfg(feature = "npu")]