Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-portable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
run: cargo run --locked -p con-update --example transaction_smoke
- name: State presentation layout tests
run: |
cargo test --locked -p con --no-default-features --features con/bin-con-app --bin con-app updater::portable
cargo test --locked -p con --no-default-features --features con/bin-con-app --bin con-app updater::
cargo test --locked -p con --no-default-features --features con/bin-con-app --bin con-app settings_panel::tests
cargo test --locked -p con --no-default-features --features con/bin-con-app --bin con-app sidebar::
cargo test --locked -p con --no-default-features --features con/bin-con-app --bin con-app terminal_geometry::
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
run: cargo run --locked -p con-update --example transaction_smoke
- name: State presentation layout tests
run: |
cargo test --locked -p con --bin con updater::portable
cargo test --locked -p con --bin con updater::
cargo test --locked -p con --bin con settings_panel::tests
cargo test --locked -p con --bin con sidebar::
cargo test --locked -p con --bin con terminal_geometry::
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ jobs:
shell: bash
run: ./scripts/sparkle/download.sh

- name: Verify Sparkle update consent policy
shell: bash
env:
SPARKLE_FRAMEWORK: ${{ github.workspace }}/.sparkle/Sparkle.framework
run: bash scripts/macos/test-update-preferences.sh

- name: Build native app bundle
shell: bash
env:
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ All notable changes to con are documented here.

con is still pre-release, so entries may group related beta work while the product shape is stabilizing.

## `v0.1.0-beta.183` - 2026-11-17

### Fixed

**Updates**

- Add a persistent **Automatically Check for Updates** switch in Settings →
General → Updates. Turning it off stops background checks while keeping
manual checks available. Show the actual checking preference instead of the
ambiguous “Auto-update enabled” status.
_(PR [#565](https://github.com/nowledge-co/con-terminal/pull/565) by [@wey-gu](https://github.com/wey-gu))_

### Changed

**Updates**

- Require an explicit installation decision for each con-managed release.
macOS no longer offers silent automatic downloading or installation; portable
updates retain separate download and restart actions. Package-managed
installations continue using their original update mechanism.
_(PR [#565](https://github.com/nowledge-co/con-terminal/pull/565) by [@wey-gu](https://github.com/wey-gu))_

## `v0.1.0-beta.182` - 2026-11-17

### Changed
Expand Down
27 changes: 27 additions & 0 deletions crates/con-app/src/objc/sparkle_trampoline.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,30 @@ void con_sparkle_check_for_updates(void *controller) {
exception.name, exception.reason);
}
}

// Return -1 when unavailable; zero is a valid persisted user choice.
int con_sparkle_automatic_checks(void *controller) {
@try {
if (!controller) return -1;
id updater = ((id (*)(id, SEL))objc_msgSend)((__bridge id)controller, NSSelectorFromString(@"updater"));
if (!updater) return -1;
return ((BOOL (*)(id, SEL))objc_msgSend)(updater, NSSelectorFromString(@"automaticallyChecksForUpdates")) ? 1 : 0;
} @catch (NSException *exception) {
NSLog(@"[con-updater] Cannot read update checks preference: %@", exception);
return -1;
}
}

int con_sparkle_set_automatic_checks(void *controller, int enabled) {
@try {
if (!controller) return 0;
id updater = ((id (*)(id, SEL))objc_msgSend)((__bridge id)controller, NSSelectorFromString(@"updater"));
if (!updater) return 0;
((void (*)(id, SEL, BOOL))objc_msgSend)(updater, NSSelectorFromString(@"setAutomaticallyChecksForUpdates:"), enabled != 0);
BOOL actual = ((BOOL (*)(id, SEL))objc_msgSend)(updater, NSSelectorFromString(@"automaticallyChecksForUpdates"));
return actual == (enabled != 0) ? 1 : 0;
} @catch (NSException *exception) {
NSLog(@"[con-updater] Cannot change update checks preference: %@", exception);
return 0;
}
}
20 changes: 19 additions & 1 deletion crates/con-app/src/settings_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ pub struct SettingsPanel {
focus_handle: FocusHandle,
active_section: SettingsSection,
content_scroll_handle: ScrollHandle,
update_preference_error: Option<String>,
rendered_section: SettingsSection,
navigation_motion: [MotionValue; 7],
section_motion: MotionValue,
Expand Down Expand Up @@ -1868,6 +1869,7 @@ impl SettingsPanel {
focus_handle: cx.focus_handle(),
active_section: SettingsSection::General,
content_scroll_handle: ScrollHandle::new(),
update_preference_error: None,
rendered_section: SettingsSection::General,
navigation_motion: std::array::from_fn(|index| {
MotionValue::new(if index == 0 { 1.0 } else { 0.0 })
Expand Down Expand Up @@ -3599,7 +3601,23 @@ impl SettingsPanel {
)
}
}),
),
)
.child(toggle_row(
"Automatically Check for Updates",
"Check for new releases in the background. Changes apply immediately.",
Switch::new("automatic-update-checks").small()
.checked(crate::updater::automatic_checks_enabled().unwrap_or(false))
.disabled(crate::updater::automatic_checks_enabled().is_none())
.on_click(cx.listener(|this, checked: &bool, _, cx| {
this.update_preference_error = crate::updater::set_automatic_checks(*checked)
.err().map(|error| error.to_string());
cx.refresh_windows();
cx.notify();
})), theme, mobile,
))
.children(self.update_preference_error.as_ref().map(|error| div()
.px(rems(1.0)).pb(px(12.0)).text_size(ui_px(theme, 12.0))
.text_color(theme.danger).child(error.clone()))),
),
);
if crate::updater::portable::enabled() {
Expand Down
68 changes: 59 additions & 9 deletions crates/con-app/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use std::sync::{Mutex, OnceLock};
pub(crate) mod portable;
mod preferences;

#[cfg(target_os = "macos")]
use cocoa::base::{BOOL, YES, id, nil};
Expand All @@ -20,6 +21,8 @@ use objc::{class, msg_send, sel, sel_impl};
unsafe extern "C" {
fn con_sparkle_init_controller() -> *mut std::ffi::c_void;
fn con_sparkle_check_for_updates(controller: *mut std::ffi::c_void);
fn con_sparkle_automatic_checks(controller: *mut std::ffi::c_void) -> i32;
fn con_sparkle_set_automatic_checks(controller: *mut std::ffi::c_void, enabled: i32) -> i32;
}

/// Opaque handle to the Sparkle updater controller (macOS).
Expand Down Expand Up @@ -109,20 +112,18 @@ impl UpdaterStatus {

pub fn summary(self) -> &'static str {
match self {
Self::Active => "Auto-update enabled",
Self::Disabled(_) => "Auto-update unavailable",
Self::Active => match automatic_checks_enabled() {
Some(false) => "Manual checks only",
Some(true) => "Automatic checks on",
None => "Update settings unavailable",
},
Self::Disabled(_) => "Updates unavailable",
}
}

pub fn detail(self) -> &'static str {
match self {
Self::Active => {
if cfg!(target_os = "macos") {
"Sparkle is loaded and polling this release channel."
} else {
"Signed updates download while you work and install when you choose to restart."
}
}
Self::Active => "Updates require your confirmation before installation.",
Self::Disabled(UpdaterDisabledReason::ChannelDoesNotPoll) => {
"Development builds do not poll for updates."
}
Expand Down Expand Up @@ -151,6 +152,55 @@ impl UpdaterStatus {
}
}

/// Read the backend's authoritative preference, never a duplicated UI flag.
/// Sparkle calls must stay on the main thread.
pub fn automatic_checks_enabled() -> Option<bool> {
if !status().can_check_manually() {
return None;
}
if portable::enabled() {
return Some(preferences::enabled());
}
#[cfg(target_os = "macos")]
{
let controller = *CONTROLLER.get()? as *mut std::ffi::c_void;
return match unsafe { con_sparkle_automatic_checks(controller) } {
0 => Some(false),
1 => Some(true),
_ => None,
};
}
#[cfg(not(target_os = "macos"))]
None
}
pub fn set_automatic_checks(enabled: bool) -> anyhow::Result<()> {
anyhow::ensure!(
status().can_check_manually(),
"Update checking is unavailable in this build."
);
if portable::enabled() {
preferences::set(enabled)?;
if !enabled {
portable::cancel_automatic_check();
}
return Ok(());
}
#[cfg(target_os = "macos")]
{
let controller = *CONTROLLER
.get()
.ok_or_else(|| anyhow::anyhow!("Update checking is unavailable."))?
as *mut std::ffi::c_void;
anyhow::ensure!(
unsafe { con_sparkle_set_automatic_checks(controller, enabled as i32) } == 1,
"Could not save the update preference."
);
return Ok(());
}
#[cfg(not(target_os = "macos"))]
anyhow::bail!("Update checking is unavailable.")
}

/// Initialize the updater. Call once during app launch, after the
/// main window is open. Returns `true` if the update surface is live.
pub fn init() -> bool {
Expand Down
128 changes: 97 additions & 31 deletions crates/con-app/src/updater/portable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static REVISION: AtomicU64 = AtomicU64::new(0);
static RELEASE: Mutex<Option<Release>> = Mutex::new(None);
static PREPARED: Mutex<Option<Prepared>> = Mutex::new(None);
static CANCEL: AtomicBool = AtomicBool::new(false);
static AUTOMATIC_CHECK_CANCEL: Mutex<Option<tokio::sync::oneshot::Sender<()>>> = Mutex::new(None);
static BUSY: AtomicBool = AtomicBool::new(false);
static EXIT: AtomicBool = AtomicBool::new(false);
static LOCK: OnceLock<File> = OnceLock::new();
Expand Down Expand Up @@ -82,7 +83,21 @@ pub fn init() {
}
}
}
pub fn cancel_automatic_check() {
if let Some(cancel) = AUTOMATIC_CHECK_CANCEL.lock().unwrap().take() {
let _ = cancel.send(());
}
}
async fn cancellable_check<T>(
future: impl std::future::Future<Output = T>,
cancel: tokio::sync::oneshot::Receiver<()>,
) -> Option<T> {
tokio::select! { biased; _ = cancel => None, result = future => Some(result) }
}
pub fn check(manual: bool) {
if !manual && !super::preferences::enabled() {
return;
}
if let Some(prepared) = PREPARED.lock().ok().and_then(|p| p.clone()) {
state(CheckState::Ready {
version: prepared.release.version,
Expand All @@ -92,42 +107,64 @@ pub fn check(manual: bool) {
if BUSY.swap(true, Ordering::SeqCst) {
return;
}
let (sender, cancel) = tokio::sync::oneshot::channel();
let manual_guard = if manual {
Some(sender)
} else {
*AUTOMATIC_CHECK_CANCEL.lock().unwrap() = Some(sender);
None
};
state(CheckState::Checking);
runtime().spawn(async move {
let result = async {
let channel = con_core::release_channel::current();
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(20))
.build()?;
let url = channel.feed_url(
con_core::release_channel::host_platform(),
con_core::release_channel::host_arch(),
);
let mut response = client.get(url).send().await?.error_for_status()?;
let mut bytes = Vec::new();
while let Some(chunk) = response.chunk().await? {
anyhow::ensure!(
bytes.len() + chunk.len() <= 2 * 1024 * 1024,
"Update feed is too large"
let _manual_guard = manual_guard;
let result = cancellable_check(
async {
let channel = con_core::release_channel::current();
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(20))
.build()?;
let url = channel.feed_url(
con_core::release_channel::host_platform(),
con_core::release_channel::host_arch(),
);
bytes.extend_from_slice(&chunk);
let mut response = client.get(url).send().await?.error_for_status()?;
let mut bytes = Vec::new();
while let Some(chunk) = response.chunk().await? {
anyhow::ensure!(
bytes.len() + chunk.len() <= 2 * 1024 * 1024,
"Update feed is too large"
);
bytes.extend_from_slice(&chunk);
}
let release = con_update::parse_feed(
std::str::from_utf8(&bytes)?,
con_core::release_channel::host_platform(),
con_core::release_channel::host_arch(),
)?;
let skipped = !manual
&& fs::read_to_string(con_paths::app_data_dir().join("skipped-update"))
.ok()
.as_deref()
== Some(release.version.as_str());
let next = candidate_state(&release, &crate::app_display_version(), skipped);
*RELEASE.lock().unwrap() = Some(release);
Ok::<_, anyhow::Error>(next)
},
cancel,
)
.await;
if let Some(result) = result {
if manual || super::preferences::enabled() {
state(result.unwrap_or_else(|error| CheckState::Error(error.to_string())));
} else {
state(CheckState::Idle);
}
let release = con_update::parse_feed(
std::str::from_utf8(&bytes)?,
con_core::release_channel::host_platform(),
con_core::release_channel::host_arch(),
)?;
let skipped = !manual
&& fs::read_to_string(con_paths::app_data_dir().join("skipped-update"))
.ok()
.as_deref()
== Some(release.version.as_str());
let next = candidate_state(&release, &crate::app_display_version(), skipped);
*RELEASE.lock().unwrap() = Some(release);
Ok::<_, anyhow::Error>(next)
} else {
state(CheckState::Idle);
}
if !manual {
AUTOMATIC_CHECK_CANCEL.lock().unwrap().take();
}
.await;
state(result.unwrap_or_else(|error| CheckState::Error(error.to_string())));
BUSY.store(false, Ordering::SeqCst);
});
}
Expand Down Expand Up @@ -426,6 +463,35 @@ pub fn seed_review() -> bool {
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn disabling_checks_cancels_pending_fetch_and_discards_ready_results() {
let (sender, cancel) = tokio::sync::oneshot::channel();
let task = tokio::spawn(super::cancellable_check(
std::future::pending::<()>(),
cancel,
));
sender.send(()).unwrap();
assert!(
tokio::time::timeout(std::time::Duration::from_secs(1), task)
.await
.unwrap()
.unwrap()
.is_none()
);
let (sender, cancel) = tokio::sync::oneshot::channel();
sender.send(()).unwrap();
assert!(
super::cancellable_check(std::future::ready(123), cancel)
.await
.is_none()
);
let (_sender, cancel) = tokio::sync::oneshot::channel();
assert_eq!(
super::cancellable_check(std::future::ready(123), cancel).await,
Some(123)
);
}

#[test]
fn skipped_version_does_not_hide_that_it_is_already_installed() {
let release = Release {
Expand Down
Loading
Loading