Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cortex-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
});
Expand Down
22 changes: 14 additions & 8 deletions src/cortex-tui/src/runner/app_runner/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});

Expand Down