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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(linux): say which side to update when versions don't match
leepokaie122624a04f5
diff --git a/apps/linux/Cargo.lock b/apps/linux/Cargo.lockindex 7d51fb19..0a3c5989 100644--- a/apps/linux/Cargo.lock+++ b/apps/linux/Cargo.lock@@ -152,7 +152,7 @@ dependencies = [[[package]]name = "codync-gtk"-version = "2.1.0"+version = "2.4.0"dependencies = ["async-channel","dirs",diff --git a/apps/linux/Cargo.toml b/apps/linux/Cargo.tomlindex 7de7b101..b1ef2269 100644--- a/apps/linux/Cargo.toml+++ b/apps/linux/Cargo.toml@@ -1,6 +1,6 @@[package]name = "codync-gtk"-version = "2.1.0"+version = "2.4.0"edition = "2024"description = "Codync for Linux: message your coding-agent bots (GTK 4 + libadwaita)"license = "MIT"diff --git a/apps/linux/src/compat.rs b/apps/linux/src/compat.rsnew file mode 100644index 00000000..f9c2d7cc--- /dev/null+++ b/apps/linux/src/compat.rs@@ -0,0 +1,109 @@+//! Phone/host compatibility (docs/reference/compatibility.md), mirroring `host/src/compat.rs`:+//! the host sends the oldest app it serves as `minApp` in `hello`; this app keeps its own floor.++use serde_json::Value;++/// The oldest host this app works with. Raise it only when the app starts depending on+/// something older hosts don't have.+pub const MIN_HOST: &str = "2.3.0";++#[derive(Debug, Clone, PartialEq, Eq)]+pub enum Mismatch {+ /// This app is older than the host's `minApp`.+ UpdateApp { minimum: String },+ /// The host is older than `MIN_HOST`.+ UpdateHost { version: String, minimum: String },+}++/// `major.minor.patch`, ignoring a leading `v` and any pre-release or build suffix; missing+/// parts count as 0. `None` for anything else, which never blocks.+fn parse(version: &str) -> Option<(u64, u64, u64)> {+ let core = version.trim().trim_start_matches('v');+ let core = core.split(['-', '+']).next()?;+ let mut parts = core.split('.');+ let mut next = |required: bool| match parts.next() {+ Some(p) => p.parse::<u64>().ok(),+ None if required => None,+ None => Some(0),+ };+ let v = (next(true)?, next(false)?, next(false)?);+ parts.next().is_none().then_some(v)+}++fn below(version: &str, minimum: &str) -> bool {+ matches!((parse(version), parse(minimum)), (Some(v), Some(m)) if v < m)+}++/// This app (`app`) against a host's `hello`; hosts that predate `minApp` only get the floor check.+pub fn check(app: &str, hello: &Value) -> Option<Mismatch> {+ if let Some(minimum) = hello["minApp"].as_str()+ && below(app, minimum)+ {+ return Some(Mismatch::UpdateApp {+ minimum: minimum.to_owned(),+ });+ }+ let version = hello["version"].as_str().unwrap_or_default();+ below(version, MIN_HOST).then(|| Mismatch::UpdateHost {+ version: version.to_owned(),+ minimum: MIN_HOST.to_owned(),+ })+}++/// What to update, in the words every client uses.+pub fn text(m: &Mismatch, host: &str) -> String {+ match m {+ Mismatch::UpdateApp { minimum } => {+ format!("Update this app: {host} needs Codync {minimum} or newer here.")+ }+ Mismatch::UpdateHost { version, minimum } => format!(+ "Update Codync on {host}: it runs {version}, this app needs {minimum} or newer."+ ),+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use serde_json::json;++ #[test]+ fn floor_never_exceeds_this_release() {+ assert!(!below(env!("CARGO_PKG_VERSION"), MIN_HOST));+ assert!(parse(MIN_HOST).is_some());+ }++ #[test]+ fn decides_which_side_updates() {+ assert_eq!(+ parse("2.10.0").cmp(&parse("2.9.9")),+ std::cmp::Ordering::Greater+ );+ assert_eq!(parse("v2.4"), Some((2, 4, 0)));+ assert_eq!(parse("2.4.0-dev"), Some((2, 4, 0)));+ assert_eq!(parse("2.4.0.1"), None);+ assert_eq!(+ check("2.4.0", &json!({"version": "2.4.0", "minApp": "2.3.0"})),+ None+ );+ assert_eq!(+ check("2.4.0", &json!({"version": "2.6.0", "minApp": "2.5.0"})),+ Some(Mismatch::UpdateApp {+ minimum: "2.5.0".into()+ })+ );+ assert_eq!(+ check("2.4.0", &json!({"version": "2.2.3"})),+ Some(Mismatch::UpdateHost {+ version: "2.2.3".into(),+ minimum: MIN_HOST.into()+ })+ );+ // Unknown versions never lock anyone out.+ assert_eq!(check("2.4.0", &json!({})), None);+ assert_eq!(+ check("dev", &json!({"version": "2.6.0", "minApp": "2.5.0"})),+ None+ );+ }+}diff --git a/apps/linux/src/compose.rs b/apps/linux/src/compose.rsindex bedc9c86..c4b75a18 100644--- a/apps/linux/src/compose.rs+++ b/apps/linux/src/compose.rs@@ -320,6 +320,9 @@ fn remove(ui: &App, id: &str) {/// Return in To: picks the top match, or with the field empty, starts the chat.fn submit_to(ui: &App) {+ if ui::blocked_by_update(ui) {+ return;+ }if ui.compose_page.to.text().trim().is_empty() {start(ui);} else if let Some(first) = matches(ui).first() {@@ -331,6 +334,9 @@ fn submit_to(ui: &App) {/// One bot: its chat. Several: their group chat.fn start(ui: &App) {+ if ui::blocked_by_update(ui) {+ return;+ }let ids = ui.compose_page.recipients.borrow().clone();match ids.len() {0 => {}diff --git a/apps/linux/src/main.rs b/apps/linux/src/main.rsindex b0f3ca94..fbed4f1f 100644--- a/apps/linux/src/main.rs+++ b/apps/linux/src/main.rs@@ -2,6 +2,7 @@mod avatar;mod client;+mod compat;mod compose;mod connections;mod dialogs;diff --git a/apps/linux/src/ui.rs b/apps/linux/src/ui.rsindex bf95c104..28ee1b38 100644--- a/apps/linux/src/ui.rs+++ b/apps/linux/src/ui.rs@@ -39,6 +39,8 @@ pub struct State {pub hide_details: bool,pub search: String,pub online: bool,+ /// This app and the host can't work together until one of them updates.+ pub mismatch: Option<crate::compat::Mismatch>,pub outbox: HashMap<String, Outgoing>,history_busy: HashSet<String>,history_done: HashSet<String>,@@ -372,6 +374,7 @@ pub fn build(app: &adw::Application) -> App {.css_classes(["search-field"]).build();let banner = adw::Banner::new("Reconnecting to the Codync host…");+let (sidebar_box, roster, roster_empty, account_btn) = sidebar(&new_btn, &search, &banner);let sidebar_page = adw::NavigationPage::new(&sidebar_box, "Codync");@@ -605,6 +608,11 @@ pub fn build(app: &adw::Application) -> App {});// Wiring+ {+ let ui2 = ui.clone();+ ui.banner+ .connect_button_clicked(move |_| update_for_mismatch(&ui2));+ }{let ui2 = ui.clone();ui.roster.connect_row_activated(move |_, row| {@@ -897,6 +905,7 @@ fn connect(ui: &App) {client::call("hello", client::empty(), move |r| match r {Ok(hello) => {let mut st = ui2.state.borrow_mut();+ st.mismatch = crate::compat::check(env!("CARGO_PKG_VERSION"), &hello);st.hello = hello;// Open a specific bot on launch: `codync --bot <id>` (also used by desktop notifications).let args: Vec<String> = std::env::args().collect();@@ -918,6 +927,59 @@ fn connect(ui: &App) {});}+fn recheck_versions(ui: &App) {+ let ui2 = ui.clone();+ client::call("hello", client::empty(), move |r| {+ if let Ok(hello) = r {+ let mut st = ui2.state.borrow_mut();+ st.mismatch = crate::compat::check(env!("CARGO_PKG_VERSION"), &hello);+ st.hello = hello;+ drop(st);+ schedule(&ui2);+ }+ });+}++/// 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();+ let Some(m) = &st.mismatch else {+ return false;+ };+ let text = crate::compat::text(m, st.hello["name"].as_str().unwrap_or("this computer"));+ drop(st);+ toast(ui, &text);+ true+}++/// The banner's button: what this app can do about a version mismatch.+fn update_for_mismatch(ui: &App) {+ let Some(mismatch) = ui.state.borrow().mismatch.clone() else {+ return;+ };+ match mismatch {+ crate::compat::Mismatch::UpdateHost { .. } => {+ let ui2 = ui.clone();+ client::call(+ "installHostUpdate",+ json!({"force": false}),+ move |r| match r {+ // The host restarts; the reconnect checks the versions again.+ Ok(_) => toast(&ui2, "Updating the host; reconnecting when it's ready…"),+ Err(e) => toast(&ui2, &e),+ },+ );+ }+ crate::compat::Mismatch::UpdateApp { .. } => {+ // The desktop app is package-managed; its releases are on GitHub.+ let _ = gtk::gio::AppInfo::launch_default_for_uri(+ "https://github.com/leepokai/Codync/releases/latest",+ None::<>k::gio::AppLaunchContext>,+ );+ }+ }+}+pub fn refresh_screen(ui: &App) {let ui2 = ui.clone();client::call("screenStatus", client::empty(), move |r| {@@ -935,7 +997,13 @@ fn handle(ui: &App, ev: Event) {{let mut st = ui.state.borrow_mut();match ev {- Event::Online(on) => st.online = on,+ Event::Online(on) => {+ if on && !st.online {+ // Back after a drop: the host may have been updated (or replaced) meanwhile.+ recheck_versions(ui);+ }+ st.online = on;+ }Event::Message(m) => match m["type"].as_str().unwrap_or_default() {"hello" | "usage" => st.usage = m["usage"].clone(),"bot" => {@@ -1089,7 +1157,23 @@ pub fn schedule(ui: &App) {}pub fn render(ui: &App) {- ui.banner.set_revealed(!ui.state.borrow().online);+ {+ let st = ui.state.borrow();+ let host = st.hello["name"].as_str().unwrap_or("this computer");+ // A version mismatch outranks a reconnect: it won't go away by waiting.+ if let Some(m) = &st.mismatch {+ ui.banner.set_title(&crate::compat::text(m, host));+ ui.banner.set_button_label(Some(match m {+ crate::compat::Mismatch::UpdateApp { .. } => "Get update",+ crate::compat::Mismatch::UpdateHost { .. } => "Update host",+ }));+ ui.banner.set_revealed(true);+ } else {+ ui.banner.set_title("Reconnecting to the Codync host…");+ ui.banner.set_button_label(None);+ ui.banner.set_revealed(!st.online);+ }+ }render_roster(ui);let composing = ui.state.borrow().composing;if composing {@@ -1916,6 +2000,10 @@ fn send(ui: &App, in_thread: bool) {if (text.is_empty() && c.files.borrow().is_empty()) || (in_thread && thread.is_none()) {return;}+ if blocked_by_update(ui) {+ // The draft stays; it sends once the update is done.+ return;+ }let files = c.files.take();buf.set_text("");show_files(ui, in_thread);