Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(linux): show waiting host updates and remind about new releases

leepokaia54d919a065f
diff --git a/apps/linux/src/compat.rs b/apps/linux/src/compat.rs
index f9c2d7cc..d0795b9e 100644
--- a/apps/linux/src/compat.rs
+++ b/apps/linux/src/compat.rs
@@ -30,7 +30,7 @@ fn parse(version: &str) -> Option<(u64, u64, u64)> {
parts.next().is_none().then_some(v)
}
-fn below(version: &str, minimum: &str) -> bool {
+pub fn below(version: &str, minimum: &str) -> bool {
matches!((parse(version), parse(minimum)), (Some(v), Some(m)) if v < m)
}
diff --git a/apps/linux/src/dialogs.rs b/apps/linux/src/dialogs.rs
index dc8370d4..47e942e8 100644
--- a/apps/linux/src/dialogs.rs
+++ b/apps/linux/src/dialogs.rs
@@ -1354,12 +1354,15 @@ fn host_updates_group(ui: &App) -> adw::PreferencesGroup {
group.add(&status);
group.add(&automatic);
let syncing = std::rc::Rc::new(std::cell::Cell::new(false));
+ // The App Store couldn't be asked: installing is the person's call ("Update anyway").
+ let skip_app_check = std::rc::Rc::new(std::cell::Cell::new(false));
let render = {
- let (status, install, automatic, syncing) = (
+ let (status, install, automatic, syncing, skip_app_check) = (
status.clone(),
install.clone(),
automatic.clone(),
syncing.clone(),
+ skip_app_check.clone(),
);
move |value: &Value| {
let standalone = value["method"] == "standalone";
@@ -1367,24 +1370,47 @@ fn host_updates_group(ui: &App) -> adw::PreferencesGroup {
status.set_title(
&version.map_or_else(|| "Host updates".to_owned(), |v| format!("Version {v}")),
);
- let description =
- match value["method"].as_str() {
- Some("homebrew") => "Update with brew upgrade leepokai/codync/codync-host",
- Some("development") => "Rebuild this development installation to update it.",
- Some("appBundle") => "Update the Codync Mac app to update its bundled host.",
- _ => value["state"]["error"].as_str().unwrap_or_else(|| {
- match value["state"]["phase"].as_str() {
- Some("complete") => "Update installed and host restarted.",
- Some("installing" | "checking" | "scheduled") => "Updating the host…",
- Some("upToDate") => "The host is up to date.",
- _ => "Checks signed releases for this computer.",
- }
- }),
- };
- status.set_subtitle(description);
+ let required = value["state"]["requiredApp"]
+ .as_str()
+ .filter(|_| value["state"]["phase"] == "waitingForApp");
+ let in_review = required.and(value["state"]["appStoreVersion"].as_str());
+ let description = match (value["method"].as_str(), required, in_review) {
+ (Some("homebrew"), ..) => {
+ "Update with brew upgrade leepokai/codync/codync-host".to_owned()
+ }
+ (Some("development"), ..) => {
+ "Rebuild this development installation to update it.".to_owned()
+ }
+ (Some("appBundle"), ..) => {
+ "Update the Codync Mac app to update its bundled host.".to_owned()
+ }
+ (_, Some(app), Some(store)) => format!(
+ "Waits for the iPhone app {app} (the App Store has {store}); it installs after review."
+ ),
+ (_, Some(app), None) => format!(
+ "Couldn't check the App Store for the iPhone app {app}. Paired iPhones may need it before they can connect."
+ ),
+ _ => value["state"]["error"]
+ .as_str()
+ .unwrap_or_else(|| match value["state"]["phase"].as_str() {
+ Some("complete") => "Update installed and host restarted.",
+ Some("installing" | "checking" | "scheduled") => "Updating the host…",
+ Some("upToDate") => "The host is up to date.",
+ _ => "Checks signed releases for this computer.",
+ })
+ .to_owned(),
+ };
+ status.set_subtitle(&description);
+ skip_app_check.set(required.is_some() && in_review.is_none());
+ install.set_label(if skip_app_check.get() {
+ "Update anyway"
+ } else {
+ "Install update"
+ });
install.set_sensitive(
standalone
&& version.is_some()
+ && in_review.is_none()
&& !matches!(
value["state"]["phase"].as_str(),
Some("installing" | "checking" | "scheduled" | "complete")
@@ -1458,7 +1484,7 @@ fn host_updates_group(ui: &App) -> adw::PreferencesGroup {
);
client::call(
"installHostUpdate",
- json!({"force": false}),
+ json!({"force": false, "skipAppCheck": skip_app_check.get()}),
move |result| match result {
Ok(_) => {
status.set_subtitle("Updating the host; reconnecting when it is ready…");
diff --git a/apps/linux/src/ui.rs b/apps/linux/src/ui.rs
index 28ee1b38..3848f253 100644
--- a/apps/linux/src/ui.rs
+++ b/apps/linux/src/ui.rs
@@ -41,6 +41,8 @@ pub struct State {
pub online: bool,
/// This app and the host can't work together until one of them updates.
pub mismatch: Option<crate::compat::Mismatch>,
+ /// The host/app versions a newer-release reminder was shown for (once each).
+ reminded: Option<String>,
pub outbox: HashMap<String, Outgoing>,
history_busy: HashSet<String>,
history_done: HashSet<String>,
@@ -907,6 +909,9 @@ fn connect(ui: &App) {
let mut st = ui2.state.borrow_mut();
st.mismatch = crate::compat::check(env!("CARGO_PKG_VERSION"), &hello);
st.hello = hello;
+ drop(st);
+ remind_updates(&ui2);
+ let mut st = ui2.state.borrow_mut();
// Open a specific bot on launch: `codync --bot <id>` (also used by desktop notifications).
let args: Vec<String> = std::env::args().collect();
if let Some(i) = args.iter().position(|a| a == "--bot") {
@@ -935,11 +940,72 @@ fn recheck_versions(ui: &App) {
st.mismatch = crate::compat::check(env!("CARGO_PKG_VERSION"), &hello);
st.hello = hello;
drop(st);
+ remind_updates(&ui2);
schedule(&ui2);
}
});
}
+/// Still compatible, but one side is behind a release the other already runs: a toast
+/// (gone on its own or when closed) offers the update, once per pair of versions.
+fn remind_updates(ui: &App) {
+ let (host_version, host) = {
+ let mut st = ui.state.borrow_mut();
+ let host_version = st.hello["version"].as_str().unwrap_or_default().to_owned();
+ let key = format!("{host_version}/{}", env!("CARGO_PKG_VERSION"));
+ if st.mismatch.is_some() || st.reminded.as_deref() == Some(key.as_str()) {
+ return;
+ }
+ st.reminded = Some(key);
+ let host = st.hello["name"]
+ .as_str()
+ .unwrap_or("this computer")
+ .to_owned();
+ (host_version, host)
+ };
+ let own = env!("CARGO_PKG_VERSION");
+ let (title, button, host_side) = if crate::compat::below(&host_version, own) {
+ (
+ format!("Codync {own} is available for {host} (it runs {host_version})"),
+ "Update host",
+ true,
+ )
+ } else if crate::compat::below(own, &host_version) {
+ (
+ format!("Codync {host_version} is available for this app"),
+ "Get update",
+ false,
+ )
+ } else {
+ return;
+ };
+ let reminder = adw::Toast::builder()
+ .title(title)
+ .button_label(button)
+ .timeout(10)
+ .build();
+ let ui2 = ui.clone();
+ reminder.connect_button_clicked(move |_| {
+ if host_side {
+ let ui3 = ui2.clone();
+ client::call(
+ "installHostUpdate",
+ json!({"force": false}),
+ move |r| match r {
+ Ok(_) => toast(&ui3, "Updating the host; reconnecting when it's ready…"),
+ Err(e) => toast(&ui3, &e),
+ },
+ );
+ } else {
+ let _ = gtk::gio::AppInfo::launch_default_for_uri(
+ "https://github.com/leepokai/Codync/releases/latest",
+ None::<&gtk::gio::AppLaunchContext>,
+ );
+ }
+ });
+ ui.toasts.add_toast(reminder);
+}
+
/// While one side needs an update nothing is sent: says so and returns true.
pub fn blocked_by_update(ui: &App) -> bool {
let st = ui.state.borrow();