@@ -25,6 +25,7 @@ use defguard_client::{
2525 DB_POOL ,
2626 } ,
2727 enterprise:: provisioning:: handle_client_initialization,
28+ events:: handle_deep_link,
2829 periodic:: run_periodic_tasks,
2930 service,
3031 tray:: { configure_tray_icon, setup_tray, show_main_window} ,
@@ -34,6 +35,7 @@ use defguard_client::{
3435} ;
3536use log:: { Level , LevelFilter } ;
3637use tauri:: { AppHandle , Builder , Manager , RunEvent , WindowEvent } ;
38+ use tauri_plugin_deep_link:: DeepLinkExt ;
3739use tauri_plugin_log:: { Target , TargetKind } ;
3840
3941#[ macro_use]
@@ -272,6 +274,14 @@ fn main() {
272274
273275 let app_handle = app. app_handle ( ) ;
274276
277+ // Single Rust-side entry point for all deep link events (runtime).
278+ {
279+ let handle = app_handle. clone ( ) ;
280+ app. deep_link ( ) . on_open_url ( move |event| {
281+ handle_deep_link ( & handle, & event. urls ( ) ) ;
282+ } ) ;
283+ }
284+
275285 // Prepare `AppConfig`.
276286 let config = AppConfig :: new ( app_handle) ;
277287
@@ -360,21 +370,34 @@ fn main() {
360370 warn ! ( "Failed to pre-build full window: {e}" ) ;
361371 }
362372
373+ // If the app was cold-launched by a deep link the full view must open, not the tray.
374+ let launched_by_deep_link = app_handle
375+ . deep_link ( )
376+ . get_current ( )
377+ . ok ( )
378+ . flatten ( )
379+ . is_some ( ) ;
380+
363381 // Decide which window to show based on platform and available locations.
364382 #[ cfg( target_os = "linux" ) ]
365383 {
366384 let _ = WindowManager :: open_full_view ( app_handle) ;
367385 }
368386 #[ cfg( not( target_os = "linux" ) ) ]
369387 {
370- let has_locations = tauri:: async_runtime:: block_on (
371- defguard_client:: window_manager:: has_non_service_locations ( )
372- ) ;
373- if has_locations {
374- WindowManager :: open_tray ( app_handle) ?;
375- } else {
376- info ! ( "No locations found, showing full view on startup." ) ;
388+ if launched_by_deep_link {
389+ info ! ( "App launched via deep link, opening full view directly." ) ;
377390 let _ = WindowManager :: open_full_view ( app_handle) ;
391+ } else {
392+ let has_locations = tauri:: async_runtime:: block_on (
393+ defguard_client:: window_manager:: has_non_service_locations ( )
394+ ) ;
395+ if has_locations {
396+ WindowManager :: open_tray ( app_handle) ?;
397+ } else {
398+ info ! ( "No locations found, showing full view on startup." ) ;
399+ let _ = WindowManager :: open_full_view ( app_handle) ;
400+ }
378401 }
379402 }
380403
@@ -417,6 +440,11 @@ fn main() {
417440 ) ;
418441 tauri:: async_runtime:: block_on ( startup ( app_handle) ) ;
419442
443+ // Handle a deep link that launched the app (startup case).
444+ if let Ok ( Some ( urls) ) = app_handle. deep_link ( ) . get_current ( ) {
445+ handle_deep_link ( app_handle, & urls) ;
446+ }
447+
420448 // Handle Ctrl-C.
421449 debug ! ( "Setting up Ctrl-C handler." ) ;
422450 let app_handle_clone = app_handle. clone ( ) ;
0 commit comments