diff --git a/src/cortex-cli/src/main.rs b/src/cortex-cli/src/main.rs index fce9e7216..dc3bb0169 100644 --- a/src/cortex-cli/src/main.rs +++ b/src/cortex-cli/src/main.rs @@ -121,6 +121,12 @@ async fn check_for_updates_background() { } } +fn should_check_for_updates_on_startup() -> bool { + cortex_engine::Config::load_sync(Default::default()) + .map(|config| config.check_for_update_on_startup) + .unwrap_or(true) +} + #[tokio::main] async fn main() -> Result<()> { // Install Ctrl+C handler to restore terminal state before exiting @@ -184,7 +190,7 @@ async fn main() -> Result<()> { // Background update check (non-blocking) let is_upgrade_cmd = matches!(&cli.command, Some(Commands::Upgrade(_))); let is_tui_mode = cli.command.is_none(); - if !is_upgrade_cmd && !is_tui_mode { + if !is_upgrade_cmd && !is_tui_mode && should_check_for_updates_on_startup() { tokio::spawn(async { check_for_updates_background().await; }); diff --git a/src/cortex-tui/src/runner/app_runner/runner.rs b/src/cortex-tui/src/runner/app_runner/runner.rs index e79ac3746..c08d455d8 100644 --- a/src/cortex-tui/src/runner/app_runner/runner.rs +++ b/src/cortex-tui/src/runner/app_runner/runner.rs @@ -555,19 +555,25 @@ impl AppRunner { tokio::task::spawn_blocking(|| CortexSession::list_recent(50).ok()); // 2. Background update check task - check for new versions without blocking startup + let check_for_update_on_startup = self.config.check_for_update_on_startup; let update_check_task = tokio::spawn(async move { - match UpdateManager::new() { - Ok(manager) => match manager.check_update().await { - Ok(info) => info, + if check_for_update_on_startup { + match UpdateManager::new() { + Ok(manager) => match manager.check_update().await { + Ok(info) => info, + Err(e) => { + tracing::debug!("Update check failed: {}", e); + None + } + }, Err(e) => { - tracing::debug!("Update check failed: {}", e); + tracing::debug!("Failed to create update manager: {}", e); None } - }, - Err(e) => { - tracing::debug!("Failed to create update manager: {}", e); - None } + } else { + tracing::debug!("Startup update check disabled by config"); + None } });