A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(update): read the update check switch and frequency from Settings
RoversXc244c0988822
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex 3ed162d8..7e37357a 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -1378,6 +1378,12 @@ pub(crate) struct NativeWorkspaceSettings {/// "direct" (GitHub only) or a mirror's host. An unknown name is the/// default. The CLI and the mux server read it from this file.pub(crate) update_download_source: String,+ /// Whether the app looks for a new release by itself. `None` follows+ /// `check_for_updates` in the configuration.+ pub(crate) check_for_updates: Option<bool>,+ /// How often it looks again while it runs, in seconds. `None` follows+ /// `check_for_updates_interval_seconds` in the configuration.+ pub(crate) update_check_interval_seconds: Option<u64>,/// Local terminals run in a background mux server (the default unix/// domain) instead of inside the GUI process, so they survive the GUI/// quitting, crashing or updating. Read once at launch.@@ -1394,6 +1400,8 @@ impl Default for NativeWorkspaceSettings {system_notifications_enabled: true,remote_update_keeps_sessions: true,update_download_source: thinkterm_update::DownloadSource::Auto.name().to_string(),+ check_for_updates: None,+ update_check_interval_seconds: None,// Preserve the behavior of older settings files without this field.// Fresh installs enable it in ThinkTermNativeSettings::for_new_install.local_sessions_via_mux: false,@@ -3019,6 +3027,23 @@ pub(crate) fn update_download_source(thinkterm_update::DownloadSource::from_name(&settings.workspaces.update_download_source)}+/// Whether the app looks for a new release by itself: Settings' switch, or+/// while that is untouched, the configuration.+pub(crate) fn checks_for_updates(settings: &ThinkTermNativeSettings) -> bool {+ settings+ .workspaces+ .check_for_updates+ .unwrap_or_else(|| config::configuration().check_for_updates)+}++/// How often, in seconds, the app looks for a new release while it runs.+pub(crate) fn update_check_interval_seconds(settings: &ThinkTermNativeSettings) -> u64 {+ settings+ .workspaces+ .update_check_interval_seconds+ .unwrap_or_else(|| config::configuration().check_for_updates_interval_seconds)+}+pub(crate) fn local_sessions_via_mux() -> bool {load().workspaces.local_sessions_via_mux}diff --git a/wezterm-gui/src/update.rs b/wezterm-gui/src/update.rsindex a37430b0..f3bee268 100644--- a/wezterm-gui/src/update.rs+++ b/wezterm-gui/src/update.rs@@ -1,4 +1,3 @@-use config::configuration;use mux::connui::ConnectionUI;use std::sync::atomic::{AtomicBool, Ordering};use std::sync::Mutex;@@ -97,7 +96,7 @@ fn set_update_available(available: bool, new_build: bool, latest: &Release) {/// first frame rather than after the checker's first delay. Called before/// any window exists, so it only stores: the first paint reads it.pub fn load_last_release_info() {- if !configuration().check_for_updates {+ if !crate::native_settings::checks_for_updates(&crate::native_settings::load_shared()) {return;}let status = cached_update_status();@@ -157,10 +156,15 @@ fn cached_release() -> Option<Release> {.and_then(|data| serde_json::from_slice::<Release>(&data).ok())}+/// When the last check on record was made: when its answer was written.+fn last_checked() -> Option<SystemTime> {+ let path = config::DATA_DIR.join("check_update");+ path.metadata().and_then(|meta| meta.modified()).ok()+}+pub fn cached_update_status() -> CachedUpdateStatus {let current_version = running_release_version();- let path = config::DATA_DIR.join("check_update");- let last_checked = path.metadata().and_then(|meta| meta.modified()).ok();+ let last_checked = last_checked();let latest = cached_release();let update_available = latest.as_ref().is_some_and(|latest| {is_newer_build(@@ -269,9 +273,15 @@ fn record_latest_release(latest: &Release) -> anyhow::Result<()> {/// Returns true if the provided socket path is dead.fn update_checker() {- // Every launch checks, a few seconds in so the check does not compete- // with starting up; after that, once every interval while it runs.+ // A check is due an interval after the last one, a few seconds in at the+ // earliest so it does not compete with starting up. The last one is the+ // record on disk -- whichever process made it, a "Check for Updates"+ // included -- so a weekly check stays weekly across launches; or this+ // process's last attempt, so a failing one is not retried every minute.+ // The switch and the interval are read again every minute, so a change+ // in Settings applies without first waiting out the interval it replaced.let initial_interval = Duration::from_secs(10);+ let poll = Duration::from_secs(60);let force_ui = always_show_update_ui();@@ -279,7 +289,23 @@ fn update_checker() {let my_sock = config::RUNTIME_DIR.join(format!("gui-sock-{}", unsafe { libc::getpid() }));+ // Wall-clock time, so a night the machine slept through counts.+ let mut last_attempt: Option<SystemTime> = None;loop {+ let settings = crate::native_settings::load_shared();+ let interval =+ Duration::from_secs(crate::native_settings::update_check_interval_seconds(&settings));+ let last_check = last_checked().max(last_attempt);+ let due = crate::native_settings::checks_for_updates(&settings)+ && last_check.map_or(true, |at| {+ at.elapsed().map_or(true, |elapsed| elapsed >= interval)+ });+ if !due {+ std::thread::sleep(poll);+ continue;+ }+ last_attempt = Some(SystemTime::now());+// Figure out which other wezterm-guis are running.// We have a little "consensus protocol" to decide which// of us will show the toast notification or show the update@@ -288,45 +314,41 @@ fn update_checker() {// running, we don't spam the user with a lot of notifications.let socks = wezterm_client::discovery::discover_gui_socks();- if configuration().check_for_updates {- if let Ok(mut latest) = get_latest_release_info() {- let current = running_release_version();- // A package made by hand with this release's version is told- // about the release once its code is the later one.- let verdict = judge_release(&mut latest, ¤t, cached_release().as_ref());- let newer = verdict.newer;- set_update_available(newer || force_ui, verdict.new_build, &latest);- if newer || force_ui {- log::info!(- "latest release {} is newer than current build {}",- latest.tag_name,- current- );+ if let Ok(mut latest) = get_latest_release_info() {+ let current = running_release_version();+ // A package made by hand with this release's version is told+ // about the release once its code is the later one.+ let verdict = judge_release(&mut latest, ¤t, cached_release().as_ref());+ let newer = verdict.newer;+ set_update_available(newer || force_ui, verdict.new_build, &latest);+ if newer || force_ui {+ log::info!(+ "latest release {} is newer than current build {}",+ latest.tag_name,+ current+ );- let url = release_tag_url(&latest.tag_name);-- if force_ui || socks.is_empty() || socks[0] == my_sock {- persistent_toast_notification_with_click_to_open_url(- &crate::i18n::tr(if verdict.new_build {- "update-toast-new-build-title"- } else {- "update-toast-title"- }),- &crate::i18n::tr("update-toast-body"),- &url,- );- }+ let url = release_tag_url(&latest.tag_name);++ if force_ui || socks.is_empty() || socks[0] == my_sock {+ persistent_toast_notification_with_click_to_open_url(+ &crate::i18n::tr(if verdict.new_build {+ "update-toast-new-build-title"+ } else {+ "update-toast-title"+ }),+ &crate::i18n::tr("update-toast-body"),+ &url,+ );}+ }- if let Err(err) = record_latest_release(&latest) {- log::warn!("{err:#}");- }+ if let Err(err) = record_latest_release(&latest) {+ log::warn!("{err:#}");}}- std::thread::sleep(Duration::from_secs(- configuration().check_for_updates_interval_seconds,- ));+ std::thread::sleep(poll);}}