@@ -4,7 +4,7 @@ use super::auth_status::AuthStatus;
44use super :: exit_info:: { AppExitInfo , ExitReason } ;
55use super :: trusted_workspaces:: { is_workspace_trusted, mark_workspace_trusted} ;
66
7- use crate :: app:: AppState ;
7+ use crate :: app:: { AppState , UpdateStatus } ;
88use crate :: bridge:: SessionBridge ;
99use crate :: providers:: ProviderManager ;
1010use crate :: runner:: event_loop:: EventLoop ;
@@ -15,7 +15,9 @@ use anyhow::Result;
1515use cortex_engine:: Config ;
1616use cortex_login:: { CredentialsStoreMode , load_auth, logout_with_fallback} ;
1717use cortex_protocol:: ConversationId ;
18+ use cortex_update:: UpdateManager ;
1819use std:: path:: PathBuf ;
20+ use std:: time:: Duration ;
1921use tracing;
2022
2123// ============================================================================
@@ -552,6 +554,23 @@ impl AppRunner {
552554 let session_history_task =
553555 tokio:: task:: spawn_blocking ( || CortexSession :: list_recent ( 50 ) . ok ( ) ) ;
554556
557+ // 2. Background update check task - check for new versions without blocking startup
558+ let update_check_task = tokio:: spawn ( async move {
559+ match UpdateManager :: new ( ) {
560+ Ok ( manager) => match manager. check_update ( ) . await {
561+ Ok ( info) => info,
562+ Err ( e) => {
563+ tracing:: debug!( "Update check failed: {}" , e) ;
564+ None
565+ }
566+ } ,
567+ Err ( e) => {
568+ tracing:: debug!( "Failed to create update manager: {}" , e) ;
569+ None
570+ }
571+ }
572+ } ) ;
573+
555574 // 3. Models prefetch and session validation - spawn in background
556575 // We use a channel to receive results and update provider_manager later
557576 let models_and_validation_task = {
@@ -640,6 +659,23 @@ impl AppRunner {
640659 ) ;
641660 }
642661
662+ // Collect update check result (with short timeout to not block startup)
663+ if let Ok ( Ok ( Some ( info) ) ) =
664+ tokio:: time:: timeout ( Duration :: from_secs ( 3 ) , update_check_task) . await
665+ {
666+ tracing:: info!(
667+ "Update available: {} -> {}" ,
668+ info. current_version,
669+ info. latest_version
670+ ) ;
671+ app_state. set_update_status ( UpdateStatus :: Available {
672+ version : info. latest_version . clone ( ) ,
673+ } ) ;
674+ app_state. set_update_info ( Some ( info) ) ;
675+ } else {
676+ tracing:: debug!( "Update check did not complete in time or no update available" ) ;
677+ }
678+
643679 // Check validation result (with short timeout - don't block TUI)
644680 // We'll handle models update after event loop is created
645681 let validation_result = tokio:: time:: timeout (
0 commit comments