BlueGit

ict rusty-teams

feat(update): update by install kind, release page where the app cannot replace itself (#86)

metis Joe Mild · pushed by metis

Authored 2026-11-25 · 6 days ago

Hash
a90a74addbc2c51cf7cfbf62a9efaf9abd4605b0
Parent
68fb4b73
9 files changed +294 −70
README.md +3 −3
@@ -82,7 +82,7 @@
82 82
83 83 **App**
84 84 - Dark theme, opens instantly from the cache
85 - Self-update from GitHub releases (Windows, and the installed Linux binary)
85 - Windows downloads a newer release quietly and restarts when idle. Linux under `~/.local` asks first. Other installs open the release page. Flatpak does not check.
86 86 - Single instance: a second start brings the window to the front
87 87 - Guest orgs: the avatar menu lists every org of your account (home and guest tenants) with unread counts; picking one restarts on it with its own cache. Messages from the other orgs show as toasts
88 88
@@ -94,7 +94,7 @@
94 94 | Sign-in | Embedded WebView2 | Your browser, headless | Your browser, headless |
95 95 | Download | `.exe` | `.tar.gz`, self-installs to the app menu | Universal `.app` (arm64 + x86_64) |
96 96 | Tray icon | Yes | StatusNotifierItem | Menu bar |
97 | Auto-update | - | Yes | - |
97 | Updates | Quiet download, idle restart | Asks when installed under `~/.local`; otherwise opens the release page | Opens the release page |
98 98
99 99 <details>
100 100 <summary><b>Sign-in on Linux and macOS</b></summary>
@@ -113,7 +113,7 @@
113 113 <summary><b>Linux details</b></summary>
114 114
115 115 - **Install:** on first start the app offers to install itself to `~/.local/share/rusty-teams/teams` and adds it to the application menu. Settings > General can install, replace or remove it.
116 - **Updates:** the installed release build checks GitHub releases and asks before it downloads and restarts.
116 - **Updates:** a release build installed under `~/.local` asks, then downloads and restarts. Other copies open the release page. Flatpak does not check.
117 117 - **Tray:** KDE Plasma natively, GNOME with the AppIndicator extension. "Show icon in the tray" plus "On close, keep the application running" keeps the app in the tray.
118 118 - **Window id:** `rusty-teams`, for window manager rules.
119 119 - **Emoji:** a bundled Noto Color Emoji font, so they look the same on every distro.
@@ -82,7 +82,7 @@
82
82
83**App**
83**App**
84- Dark theme, opens instantly from the cache
84- Dark theme, opens instantly from the cache
85- Self-update from GitHub releases (Windows, and the installed Linux binary)
85- Windows downloads a newer release quietly and restarts when idle. Linux under `~/.local` asks first. Other installs open the release page. Flatpak does not check.
86- Single instance: a second start brings the window to the front
86- Single instance: a second start brings the window to the front
87- Guest orgs: the avatar menu lists every org of your account (home and guest tenants) with unread counts; picking one restarts on it with its own cache. Messages from the other orgs show as toasts
87- Guest orgs: the avatar menu lists every org of your account (home and guest tenants) with unread counts; picking one restarts on it with its own cache. Messages from the other orgs show as toasts
88
88
@@ -94,7 +94,7 @@
94| Sign-in | Embedded WebView2 | Your browser, headless | Your browser, headless |
94| Sign-in | Embedded WebView2 | Your browser, headless | Your browser, headless |
95| Download | `.exe` | `.tar.gz`, self-installs to the app menu | Universal `.app` (arm64 + x86_64) |
95| Download | `.exe` | `.tar.gz`, self-installs to the app menu | Universal `.app` (arm64 + x86_64) |
96| Tray icon | Yes | StatusNotifierItem | Menu bar |
96| Tray icon | Yes | StatusNotifierItem | Menu bar |
97| Auto-update | - | Yes | - |
97| Updates | Quiet download, idle restart | Asks when installed under `~/.local`; otherwise opens the release page | Opens the release page |
98
98
99<details>
99<details>
100<summary><b>Sign-in on Linux and macOS</b></summary>
100<summary><b>Sign-in on Linux and macOS</b></summary>
@@ -113,7 +113,7 @@
113<summary><b>Linux details</b></summary>
113<summary><b>Linux details</b></summary>
114
114
115- **Install:** on first start the app offers to install itself to `~/.local/share/rusty-teams/teams` and adds it to the application menu. Settings > General can install, replace or remove it.
115- **Install:** on first start the app offers to install itself to `~/.local/share/rusty-teams/teams` and adds it to the application menu. Settings > General can install, replace or remove it.
116- **Updates:** the installed release build checks GitHub releases and asks before it downloads and restarts.
116- **Updates:** a release build installed under `~/.local` asks, then downloads and restarts. Other copies open the release page. Flatpak does not check.
117- **Tray:** KDE Plasma natively, GNOME with the AppIndicator extension. "Show icon in the tray" plus "On close, keep the application running" keeps the app in the tray.
117- **Tray:** KDE Plasma natively, GNOME with the AppIndicator extension. "Show icon in the tray" plus "On close, keep the application running" keeps the app in the tray.
118- **Window id:** `rusty-teams`, for window manager rules.
118- **Window id:** `rusty-teams`, for window manager rules.
119- **Emoji:** a bundled Noto Color Emoji font, so they look the same on every distro.
119- **Emoji:** a bundled Noto Color Emoji font, so they look the same on every distro.
ROADMAP.md +2 −2
@@ -32,9 +32,9 @@ Feature parity with the Microsoft Teams desktop client.
32 32 |---|---|---|
33 33 | Sign in on Windows through embedded WebView2, single sign-on | Done | |
34 34 | Start from the local cache, no spinner | Done | |
35 | Self-update | Done | |
35 | Updates | Done | Windows downloads quietly and restarts when idle and not in a call. Linux under `~/.local` asks first. Other installs open the release page. Flatpak does not check |
36 36 | Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |
37 | Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
37 | Linux install and menu entry | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the Teams icon is downloaded from Microsoft, not shipped. That copy updates itself after asking. Other Linux installs open the release page. Flatpak does not check |
38 38 | Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
39 39 | Single instance, second start brings the window to front | Done | |
40 40 | Sign in on macOS without starting Chrome by hand | Done | Same managed browser as on Linux, profile in Application Support. Takes the first of Chrome, Chromium, Edge, Brave, Helium, Vivaldi; checked live with Helium |
@@ -32,9 +32,9 @@ Feature parity with the Microsoft Teams desktop client.
32|---|---|---|
32|---|---|---|
33| Sign in on Windows through embedded WebView2, single sign-on | Done | |
33| Sign in on Windows through embedded WebView2, single sign-on | Done | |
34| Start from the local cache, no spinner | Done | |
34| Start from the local cache, no spinner | Done | |
35| Self-update | Done | |
35| Updates | Done | Windows downloads quietly and restarts when idle and not in a call. Linux under `~/.local` asks first. Other installs open the release page. Flatpak does not check |
36| Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |
36| Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |
37| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
37| Linux install and menu entry | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the Teams icon is downloaded from Microsoft, not shipped. That copy updates itself after asking. Other Linux installs open the release page. Flatpak does not check |
38| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
38| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
39| Single instance, second start brings the window to front | Done | |
39| Single instance, second start brings the window to front | Done | |
40| Sign in on macOS without starting Chrome by hand | Done | Same managed browser as on Linux, profile in Application Support. Takes the first of Chrome, Chromium, Edge, Brave, Helium, Vivaldi; checked live with Helium |
40| Sign in on macOS without starting Chrome by hand | Done | Same managed browser as on Linux, profile in Application Support. Takes the first of Chrome, Chromium, Edge, Brave, Helium, Vivaldi; checked live with Helium |
crates/app-base/locales/app.yml +18 −15
@@ -825,14 +825,14 @@ install:
825 825 en: Updates
826 826 de: Updates
827 827 updates_detail:
828 en: "%{version}, updates from GitHub releases"
829 de: "%{version}, Updates über GitHub-Releases"
830 updates_detail_not_installed:
831 en: "%{version}. Install Rusty Teams above to get updates"
832 de: "%{version}. Installiere Rusty Teams oben, um Updates zu erhalten"
833 updates_need_install:
834 en: Install Rusty Teams first (Application menu > Install), then it can update itself
835 de: Installiere Rusty Teams zuerst (Anwendungsmenü > Installieren), dann kann es sich selbst aktualisieren
828 en: "%{version}. An installed copy updates itself. Other copies open the release page"
829 de: "%{version}. Eine Installation aktualisiert sich. Sonst öffnet sich die Release-Seite"
830 updates_detail_dev:
831 en: "%{version}. This build does not look for releases"
832 de: "%{version}. Dieser Build sucht nicht nach Releases"
833 updates_dev_build:
834 en: This build does not look for releases
835 de: Dieser Build sucht nicht nach Releases
836 836 check_now:
837 837 en: Check now
838 838 de: Jetzt prüfen
@@ -840,17 +840,17 @@ install:
840 840 en: Checking for updates...
841 841 de: Suche nach Updates...
842 842 auto_updates:
843 en: Automatic updates
844 de: Automatische Updates
843 en: Updates
844 de: Updates
845 845 auto_updates_detail:
846 en: Look for new releases and ask before installing
847 de: Nach neuen Releases suchen und vor der Installation fragen
846 en: Look for new releases. An installed copy updates itself; other copies open the release page
847 de: Nach neuen Releases suchen. Eine Installation aktualisiert sich, sonst öffnet sich die Release-Seite
848 848 update_available_title:
849 849 en: Update available
850 850 de: Update verfügbar
851 851 update_available_body:
852 en: "Rusty Teams %{version} is available. You have %{current}. Update now?"
853 de: "Rusty Teams %{version} ist verfügbar. Installiert ist %{current}. Jetzt aktualisieren?"
852 en: "Rusty Teams %{version} is available. You have %{current}."
853 de: "Rusty Teams %{version} ist verfügbar. Installiert ist %{current}."
854 854 update_now:
855 855 en: Update
856 856 de: Aktualisieren
@@ -865,13 +865,16 @@ install:
865 865 de: Update bereit
866 866 update_ready_body:
867 867 en: "%{version} is downloaded. Restart Rusty Teams to finish the update."
868 de: "%{version} ist heruntergeladen. Starte Rusty Teams neu, um das Update abzuschließen."
868 de: "%{version} ist heruntergeladen. Starte Rusty Teams neu, um das Update abzuschliessen."
869 869 later:
870 870 en: Later
871 871 de: Später
872 872 restart_now:
873 873 en: Restart now
874 874 de: Jetzt neu starten
875 open_release:
876 en: Open release
877 de: Release öffnen
875 878 up_to_date:
876 879 en: Rusty Teams is up to date
877 880 de: Rusty Teams ist aktuell
@@ -825,14 +825,14 @@ install:
825 en: Updates
825 en: Updates
826 de: Updates
826 de: Updates
827 updates_detail:
827 updates_detail:
828 en: "%{version}, updates from GitHub releases"
828 en: "%{version}. An installed copy updates itself. Other copies open the release page"
829 de: "%{version}, Updates über GitHub-Releases"
829 de: "%{version}. Eine Installation aktualisiert sich. Sonst öffnet sich die Release-Seite"
830 updates_detail_not_installed:
830 updates_detail_dev:
831 en: "%{version}. Install Rusty Teams above to get updates"
831 en: "%{version}. This build does not look for releases"
832 de: "%{version}. Installiere Rusty Teams oben, um Updates zu erhalten"
832 de: "%{version}. Dieser Build sucht nicht nach Releases"
833 updates_need_install:
833 updates_dev_build:
834 en: Install Rusty Teams first (Application menu > Install), then it can update itself
834 en: This build does not look for releases
835 de: Installiere Rusty Teams zuerst (Anwendungsmenü > Installieren), dann kann es sich selbst aktualisieren
835 de: Dieser Build sucht nicht nach Releases
836 check_now:
836 check_now:
837 en: Check now
837 en: Check now
838 de: Jetzt prüfen
838 de: Jetzt prüfen
@@ -840,17 +840,17 @@ install:
840 en: Checking for updates...
840 en: Checking for updates...
841 de: Suche nach Updates...
841 de: Suche nach Updates...
842 auto_updates:
842 auto_updates:
843 en: Automatic updates
843 en: Updates
844 de: Automatische Updates
844 de: Updates
845 auto_updates_detail:
845 auto_updates_detail:
846 en: Look for new releases and ask before installing
846 en: Look for new releases. An installed copy updates itself; other copies open the release page
847 de: Nach neuen Releases suchen und vor der Installation fragen
847 de: Nach neuen Releases suchen. Eine Installation aktualisiert sich, sonst öffnet sich die Release-Seite
848 update_available_title:
848 update_available_title:
849 en: Update available
849 en: Update available
850 de: Update verfügbar
850 de: Update verfügbar
851 update_available_body:
851 update_available_body:
852 en: "Rusty Teams %{version} is available. You have %{current}. Update now?"
852 en: "Rusty Teams %{version} is available. You have %{current}."
853 de: "Rusty Teams %{version} ist verfügbar. Installiert ist %{current}. Jetzt aktualisieren?"
853 de: "Rusty Teams %{version} ist verfügbar. Installiert ist %{current}."
854 update_now:
854 update_now:
855 en: Update
855 en: Update
856 de: Aktualisieren
856 de: Aktualisieren
@@ -865,13 +865,16 @@ install:
865 de: Update bereit
865 de: Update bereit
866 update_ready_body:
866 update_ready_body:
867 en: "%{version} is downloaded. Restart Rusty Teams to finish the update."
867 en: "%{version} is downloaded. Restart Rusty Teams to finish the update."
868 de: "%{version} ist heruntergeladen. Starte Rusty Teams neu, um das Update abzuschließen."
868 de: "%{version} ist heruntergeladen. Starte Rusty Teams neu, um das Update abzuschliessen."
869 later:
869 later:
870 en: Later
870 en: Later
871 de: Später
871 de: Später
872 restart_now:
872 restart_now:
873 en: Restart now
873 en: Restart now
874 de: Jetzt neu starten
874 de: Jetzt neu starten
875 open_release:
876 en: Open release
877 de: Release öffnen
875 up_to_date:
878 up_to_date:
876 en: Rusty Teams is up to date
879 en: Rusty Teams is up to date
877 de: Rusty Teams ist aktuell
880 de: Rusty Teams ist aktuell
crates/app-base/src/release_feed.rs +58 −1
@@ -20,6 +20,7 @@ pub const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);
20 20 const RELEASES_URL: &str =
21 21 "https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
22 22 /// The release asset this platform installs, and the magic bytes it must start with.
23 #[cfg(test)]
23 24 fn asset_suffix_for(os: &str, arch: &str) -> &'static str {
24 25 match (os, arch) {
25 26 ("windows", "aarch64") => "-windows-arm64.exe",
@@ -133,6 +134,34 @@ pub fn is_newer(tag: &str, running_tag: &str) -> bool {
133 134 )
134 135 }
135 136
137 const RELEASE_PAGE: &str = "https://github.com/danieldaeschle/rusty-teams/releases/tag/";
138
139 /// The GitHub page for one tag. Installs that must not replace themselves open this.
140 pub fn release_page_url(tag: &str) -> String {
141 format!("{RELEASE_PAGE}{tag}")
142 }
143
144 /// A newer tag, even when this platform has no installable asset.
145 #[derive(Debug, Clone, PartialEq, Eq)]
146 pub struct TaggedRelease {
147 pub tag: String,
148 }
149
150 /// The newest release newer than `running_tag`, ignoring whether an asset exists.
151 pub fn newest_release<'a>(running_tag: &str, releases: &'a [Release]) -> Option<&'a Release> {
152 let running = parse_version(running_tag)?;
153 let follows_pre_releases = !running.pre_release.is_empty();
154 releases
155 .iter()
156 .filter(|release| !release.draft && (follows_pre_releases || !release.prerelease))
157 .filter_map(|release| {
158 let version = parse_version(&release.tag_name).filter(|version| *version > running)?;
159 Some((version, release))
160 })
161 .max_by(|left, right| left.0.cmp(&right.0))
162 .map(|(_, release)| release)
163 }
164
136 165 /// Pre-releases are offered only to a build that runs a pre-release itself.
137 166 pub fn newest_update<'a>(
138 167 running_tag: &str,
@@ -249,6 +278,22 @@ async fn get(
249 278 }
250 279 }
251 280
281 /// Looks for a newer tag, without requiring an asset and without downloading.
282 pub fn find_release(
283 running_tag: &'static str,
284 cx: &App,
285 ) -> Task<Result<Option<TaggedRelease>, String>> {
286 let client = cx.http_client();
287 cx.background_executor().spawn(async move {
288 let releases: Vec<Release> =
289 serde_json::from_slice(&get(&client, RELEASES_URL, None).await?)
290 .map_err(|error| error.to_string())?;
291 Ok(newest_release(running_tag, &releases).map(|release| TaggedRelease {
292 tag: release.tag_name.clone(),
293 }))
294 })
295 }
296
252 297 /// Looks for a release newer than `running_tag`, without downloading it.
253 298 pub fn find_update(
254 299 running_tag: &'static str,
@@ -394,10 +439,22 @@ mod tests {
394 439 fn a_release_without_a_windows_exe_or_a_dev_build_gets_nothing() {
395 440 let mut bare = release("v0.2.0", false);
396 441 bare.assets.clear();
397 assert!(newest_update("v0.1.0", &[bare]).is_none());
442 assert!(newest_update("v0.1.0", &[bare.clone()]).is_none());
443 assert_eq!(
444 newest_release("v0.1.0", &[bare]).map(|release| release.tag_name.as_str()),
445 Some("v0.2.0")
446 );
398 447 assert!(newest_update("0356d1d-20261107T101752Z", &[release("v0.2.0", false)]).is_none());
399 448 }
400 449
450 #[test]
451 fn the_release_page_is_the_tag_url() {
452 assert_eq!(
453 release_page_url("v0.5.0"),
454 "https://github.com/danieldaeschle/rusty-teams/releases/tag/v0.5.0"
455 );
456 }
457
401 458 #[test]
402 459 fn a_download_must_match_size_header_and_digest() {
403 460 let bytes = EXECUTABLE_MAGIC;
@@ -20,6 +20,7 @@ pub const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);
20const RELEASES_URL: &str =
20const RELEASES_URL: &str =
21 "https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
21 "https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
22/// The release asset this platform installs, and the magic bytes it must start with.
22/// The release asset this platform installs, and the magic bytes it must start with.
23#[cfg(test)]
23fn asset_suffix_for(os: &str, arch: &str) -> &'static str {
24fn asset_suffix_for(os: &str, arch: &str) -> &'static str {
24 match (os, arch) {
25 match (os, arch) {
25 ("windows", "aarch64") => "-windows-arm64.exe",
26 ("windows", "aarch64") => "-windows-arm64.exe",
@@ -133,6 +134,34 @@ pub fn is_newer(tag: &str, running_tag: &str) -> bool {
133 )
134 )
134}
135}
135
136
137const RELEASE_PAGE: &str = "https://github.com/danieldaeschle/rusty-teams/releases/tag/";
138
139/// The GitHub page for one tag. Installs that must not replace themselves open this.
140pub fn release_page_url(tag: &str) -> String {
141 format!("{RELEASE_PAGE}{tag}")
142}
143
144/// A newer tag, even when this platform has no installable asset.
145#[derive(Debug, Clone, PartialEq, Eq)]
146pub struct TaggedRelease {
147 pub tag: String,
148}
149
150/// The newest release newer than `running_tag`, ignoring whether an asset exists.
151pub fn newest_release<'a>(running_tag: &str, releases: &'a [Release]) -> Option<&'a Release> {
152 let running = parse_version(running_tag)?;
153 let follows_pre_releases = !running.pre_release.is_empty();
154 releases
155 .iter()
156 .filter(|release| !release.draft && (follows_pre_releases || !release.prerelease))
157 .filter_map(|release| {
158 let version = parse_version(&release.tag_name).filter(|version| *version > running)?;
159 Some((version, release))
160 })
161 .max_by(|left, right| left.0.cmp(&right.0))
162 .map(|(_, release)| release)
163}
164
136/// Pre-releases are offered only to a build that runs a pre-release itself.
165/// Pre-releases are offered only to a build that runs a pre-release itself.
137pub fn newest_update<'a>(
166pub fn newest_update<'a>(
138 running_tag: &str,
167 running_tag: &str,
@@ -249,6 +278,22 @@ async fn get(
249 }
278 }
250}
279}
251
280
281/// Looks for a newer tag, without requiring an asset and without downloading.
282pub fn find_release(
283 running_tag: &'static str,
284 cx: &App,
285) -> Task<Result<Option<TaggedRelease>, String>> {
286 let client = cx.http_client();
287 cx.background_executor().spawn(async move {
288 let releases: Vec<Release> =
289 serde_json::from_slice(&get(&client, RELEASES_URL, None).await?)
290 .map_err(|error| error.to_string())?;
291 Ok(newest_release(running_tag, &releases).map(|release| TaggedRelease {
292 tag: release.tag_name.clone(),
293 }))
294 })
295}
296
252/// Looks for a release newer than `running_tag`, without downloading it.
297/// Looks for a release newer than `running_tag`, without downloading it.
253pub fn find_update(
298pub fn find_update(
254 running_tag: &'static str,
299 running_tag: &'static str,
@@ -394,10 +439,22 @@ mod tests {
394 fn a_release_without_a_windows_exe_or_a_dev_build_gets_nothing() {
439 fn a_release_without_a_windows_exe_or_a_dev_build_gets_nothing() {
395 let mut bare = release("v0.2.0", false);
440 let mut bare = release("v0.2.0", false);
396 bare.assets.clear();
441 bare.assets.clear();
397 assert!(newest_update("v0.1.0", &[bare]).is_none());
442 assert!(newest_update("v0.1.0", &[bare.clone()]).is_none());
443 assert_eq!(
444 newest_release("v0.1.0", &[bare]).map(|release| release.tag_name.as_str()),
445 Some("v0.2.0")
446 );
398 assert!(newest_update("0356d1d-20261107T101752Z", &[release("v0.2.0", false)]).is_none());
447 assert!(newest_update("0356d1d-20261107T101752Z", &[release("v0.2.0", false)]).is_none());
399 }
448 }
400
449
450 #[test]
451 fn the_release_page_is_the_tag_url() {
452 assert_eq!(
453 release_page_url("v0.5.0"),
454 "https://github.com/danieldaeschle/rusty-teams/releases/tag/v0.5.0"
455 );
456 }
457
401 #[test]
458 #[test]
402 fn a_download_must_match_size_header_and_digest() {
459 fn a_download_must_match_size_header_and_digest() {
403 let bytes = EXECUTABLE_MAGIC;
460 let bytes = EXECUTABLE_MAGIC;
crates/app/src/linux_update.rs +143 −14
@@ -1,7 +1,7 @@
1 //! Linux self-update, always with consent: a newer GitHub release is offered in a
2 //! dialog; "Update" downloads it with progress and "Restart now" swaps the binary
3 //! and relaunches. Nothing restarts without a click. Settings > General turns the
4 //! periodic check off; "Check now" works either way.
1 //! Release check for every install kind. A Linux copy under `~/.local` asks, then
2 //! downloads and swaps. Windows downloads quietly from the shell poll. Every other
3 //! release build opens the release page and leaves the binary in place. Flatpak and
4 //! a build without a release tag stay quiet. Settings > General uses `updates.enabled`.
5 5
6 6 use std::collections::HashMap;
7 7 use std::sync::Arc;
@@ -19,7 +19,7 @@ use crate::i18n::{tr, tr_args};
19 19 use crate::theme;
20 20 use crate::updater;
21 21
22 const ENABLED_META_KEY: &str = "linux.updates.enabled";
22 const ENABLED_META_KEY: &str = "updates.enabled";
23 23 /// How often an offer waits for a main window closed into the tray to come back.
24 24 const WINDOW_WAIT: Duration = Duration::from_secs(30);
25 25 /// How often the progress dialog redraws while downloading.
@@ -35,6 +35,7 @@ enum Stage {
35 35 progress: Arc<AtomicU64>,
36 36 },
37 37 Ready(String),
38 Notice(String),
38 39 Failed(String),
39 40 }
40 41
@@ -80,6 +81,31 @@ pub fn set_enabled(enabled: bool, cx: &mut App) {
80 81 cx.refresh_windows();
81 82 }
82 83
84 /// Flatpak updates through the package. A build without a release tag does not look.
85 pub fn checks_releases() -> bool {
86 #[cfg(target_os = "linux")]
87 {
88 let flatpak = std::env::var_os("FLATPAK_ID");
89 if flatpak.is_some_and(|id| !id.is_empty()) {
90 return false;
91 }
92 }
93 app_base::version::release_tag().is_some()
94 }
95
96 /// Linux under `~/.local` replaces itself after the user agrees. Windows does that
97 /// quietly from the shell poll, so this module does not download there.
98 fn installed_release() -> Option<&'static str> {
99 #[cfg(target_os = "linux")]
100 {
101 crate::linux_install::updatable_release()
102 }
103 #[cfg(not(target_os = "linux"))]
104 {
105 None
106 }
107 }
108
83 109 fn declined(cx: &App) -> Option<String> {
84 110 cx.try_global::<LinuxUpdates>()
85 111 .and_then(|updates| updates.declined.clone())
@@ -131,13 +157,13 @@ fn ensure_state(cx: &mut App) {
131 157 }
132 158 }
133 159
134 /// Starts the periodic check. Only the installed copy of a release build updates.
160 /// Starts the periodic check. Windows keeps its own quiet poll.
135 161 pub fn start(cx: &mut App) {
136 if crate::linux_install::updatable_release().is_none() {
162 if !checks_releases() || cfg!(windows) {
137 163 return;
138 164 }
139 165 ensure_state(cx);
140 if let Some(running_tag) = crate::linux_install::updatable_release()
166 if let Some(running_tag) = installed_release()
141 167 && let Some(tag) = staged_update(running_tag)
142 168 {
143 169 set_stage(Stage::Ready(tag), cx);
@@ -163,10 +189,15 @@ pub fn start(cx: &mut App) {
163 189 /// Looks for a newer release. `manual` (Settings > Check now) also offers a version
164 190 /// declined with "Not now" in this run and reports "up to date" and errors.
165 191 pub fn check(manual: bool, cx: &mut App) {
166 let Some(running_tag) = crate::linux_install::updatable_release() else {
167 if manual {
168 notice(tr("install.updates_need_install"), cx);
169 }
192 if !checks_releases() {
193 return;
194 }
195 if cfg!(windows) {
196 check_windows(manual, cx);
197 return;
198 }
199 let Some(running_tag) = installed_release() else {
200 check_notice(manual, cx);
170 201 return;
171 202 };
172 203 ensure_state(cx);
@@ -175,7 +206,7 @@ pub fn check(manual: bool, cx: &mut App) {
175 206 open_dialog(cx);
176 207 return;
177 208 }
178 Stage::Idle | Stage::Offer(_) | Stage::Failed(_) => {}
209 Stage::Idle | Stage::Offer(_) | Stage::Notice(_) | Stage::Failed(_) => {}
179 210 }
180 211 if manual {
181 212 notice(tr("install.update_checking"), cx);
@@ -199,6 +230,70 @@ pub fn check(manual: bool, cx: &mut App) {
199 230 .detach();
200 231 }
201 232
233 fn check_windows(manual: bool, cx: &mut App) {
234 if !manual && !enabled(cx) {
235 return;
236 }
237 let Some(running_tag) = app_base::version::release_tag() else {
238 return;
239 };
240 let Some(paths) = updater::current_paths() else {
241 return;
242 };
243 if manual {
244 notice(tr("install.update_checking"), cx);
245 }
246 let fetch = release_feed::fetch_update(running_tag, paths, cx);
247 cx.spawn(async move |cx| {
248 let found = fetch.await;
249 cx.update(|cx| match found {
250 Ok(Some(tag)) if manual => notice(
251 tr_args("install.update_ready_body", &args("version", tag)),
252 cx,
253 ),
254 Ok(_) if manual => notice(tr("install.up_to_date"), cx),
255 Ok(_) => {}
256 Err(error) if manual => {
257 notice(tr_args("install.update_failed", &args("detail", error)), cx)
258 }
259 Err(error) => log::warn!("update check failed: {error}"),
260 });
261 })
262 .detach();
263 }
264
265 fn check_notice(manual: bool, cx: &mut App) {
266 let Some(running_tag) = app_base::version::release_tag() else {
267 return;
268 };
269 ensure_state(cx);
270 if matches!(stage(cx), Stage::Notice(_)) {
271 open_dialog(cx);
272 return;
273 }
274 if manual {
275 notice(tr("install.update_checking"), cx);
276 }
277 let find = release_feed::find_release(running_tag, cx);
278 cx.spawn(async move |cx| {
279 let found = find.await;
280 cx.update(|cx| match found {
281 Ok(Some(update)) if manual || declined(cx).as_deref() != Some(&update.tag) => {
282 set_stage(Stage::Notice(update.tag), cx);
283 show_when_window_is_open(cx);
284 }
285 Ok(Some(_)) => {}
286 Ok(None) if manual => notice(tr("install.up_to_date"), cx),
287 Ok(None) => {}
288 Err(error) if manual => {
289 notice(tr_args("install.update_failed", &args("detail", error)), cx)
290 }
291 Err(error) => log::warn!("update check failed: {error}"),
292 });
293 })
294 .detach();
295 }
296
202 297 fn offer(update: AvailableUpdate, cx: &mut App) {
203 298 set_stage(Stage::Offer(update), cx);
204 299 show_when_window_is_open(cx);
@@ -212,7 +307,10 @@ fn show_when_window_is_open(cx: &mut App) {
212 307 cx.background_executor().timer(WINDOW_WAIT).await;
213 308 }
214 309 cx.update(|cx| {
215 if matches!(stage(cx), Stage::Offer(_) | Stage::Ready(_)) {
310 if matches!(
311 stage(cx),
312 Stage::Offer(_) | Stage::Ready(_) | Stage::Notice(_)
313 ) {
216 314 open_dialog(cx);
217 315 }
218 316 });
@@ -345,6 +443,37 @@ fn build_dialog(dialog: Dialog, cx: &App) -> Dialog {
345 443 ),
346 444 )
347 445 }
446 Stage::Notice(tag) => {
447 let mut text_args = args("version", tag.clone());
448 text_args.insert("current".to_owned(), running.to_owned());
449 let open = tag.clone();
450 (
451 tr("install.update_available_title"),
452 tr_args("install.update_available_body", &text_args),
453 DialogFooter::new()
454 .child(
455 Button::new("update-not-now")
456 .label(tr("install.not_now"))
457 .on_click(move |_, window, cx| {
458 decline(&tag, cx);
459 set_stage(Stage::Idle, cx);
460 close_dialog(window, cx);
461 }),
462 )
463 .child(
464 Button::new("update-open-release")
465 .primary()
466 .label(tr("install.open_release"))
467 .on_click(move |_, window, cx| {
468 let url = release_feed::release_page_url(&open);
469 decline(&open, cx);
470 set_stage(Stage::Idle, cx);
471 close_dialog(window, cx);
472 cx.open_url(&url);
473 }),
474 ),
475 )
476 }
348 477 Stage::Ready(tag) => (
349 478 tr("install.update_ready_title"),
350 479 tr_args("install.update_ready_body", &args("version", tag)),
@@ -1,7 +1,7 @@
1//! Linux self-update, always with consent: a newer GitHub release is offered in a
1//! Release check for every install kind. A Linux copy under `~/.local` asks, then
2//! dialog; "Update" downloads it with progress and "Restart now" swaps the binary
2//! downloads and swaps. Windows downloads quietly from the shell poll. Every other
3//! and relaunches. Nothing restarts without a click. Settings > General turns the
3//! release build opens the release page and leaves the binary in place. Flatpak and
4//! periodic check off; "Check now" works either way.
4//! a build without a release tag stay quiet. Settings > General uses `updates.enabled`.
5
5
6use std::collections::HashMap;
6use std::collections::HashMap;
7use std::sync::Arc;
7use std::sync::Arc;
@@ -19,7 +19,7 @@ use crate::i18n::{tr, tr_args};
19use crate::theme;
19use crate::theme;
20use crate::updater;
20use crate::updater;
21
21
22const ENABLED_META_KEY: &str = "linux.updates.enabled";
22const ENABLED_META_KEY: &str = "updates.enabled";
23/// How often an offer waits for a main window closed into the tray to come back.
23/// How often an offer waits for a main window closed into the tray to come back.
24const WINDOW_WAIT: Duration = Duration::from_secs(30);
24const WINDOW_WAIT: Duration = Duration::from_secs(30);
25/// How often the progress dialog redraws while downloading.
25/// How often the progress dialog redraws while downloading.
@@ -35,6 +35,7 @@ enum Stage {
35 progress: Arc<AtomicU64>,
35 progress: Arc<AtomicU64>,
36 },
36 },
37 Ready(String),
37 Ready(String),
38 Notice(String),
38 Failed(String),
39 Failed(String),
39}
40}
40
41
@@ -80,6 +81,31 @@ pub fn set_enabled(enabled: bool, cx: &mut App) {
80 cx.refresh_windows();
81 cx.refresh_windows();
81}
82}
82
83
84/// Flatpak updates through the package. A build without a release tag does not look.
85pub fn checks_releases() -> bool {
86 #[cfg(target_os = "linux")]
87 {
88 let flatpak = std::env::var_os("FLATPAK_ID");
89 if flatpak.is_some_and(|id| !id.is_empty()) {
90 return false;
91 }
92 }
93 app_base::version::release_tag().is_some()
94}
95
96/// Linux under `~/.local` replaces itself after the user agrees. Windows does that
97/// quietly from the shell poll, so this module does not download there.
98fn installed_release() -> Option<&'static str> {
99 #[cfg(target_os = "linux")]
100 {
101 crate::linux_install::updatable_release()
102 }
103 #[cfg(not(target_os = "linux"))]
104 {
105 None
106 }
107}
108
83fn declined(cx: &App) -> Option<String> {
109fn declined(cx: &App) -> Option<String> {
84 cx.try_global::<LinuxUpdates>()
110 cx.try_global::<LinuxUpdates>()
85 .and_then(|updates| updates.declined.clone())
111 .and_then(|updates| updates.declined.clone())
@@ -131,13 +157,13 @@ fn ensure_state(cx: &mut App) {
131 }
157 }
132}
158}
133
159
134/// Starts the periodic check. Only the installed copy of a release build updates.
160/// Starts the periodic check. Windows keeps its own quiet poll.
135pub fn start(cx: &mut App) {
161pub fn start(cx: &mut App) {
136 if crate::linux_install::updatable_release().is_none() {
162 if !checks_releases() || cfg!(windows) {
137 return;
163 return;
138 }
164 }
139 ensure_state(cx);
165 ensure_state(cx);
140 if let Some(running_tag) = crate::linux_install::updatable_release()
166 if let Some(running_tag) = installed_release()
141 && let Some(tag) = staged_update(running_tag)
167 && let Some(tag) = staged_update(running_tag)
142 {
168 {
143 set_stage(Stage::Ready(tag), cx);
169 set_stage(Stage::Ready(tag), cx);
@@ -163,10 +189,15 @@ pub fn start(cx: &mut App) {
163/// Looks for a newer release. `manual` (Settings > Check now) also offers a version
189/// Looks for a newer release. `manual` (Settings > Check now) also offers a version
164/// declined with "Not now" in this run and reports "up to date" and errors.
190/// declined with "Not now" in this run and reports "up to date" and errors.
165pub fn check(manual: bool, cx: &mut App) {
191pub fn check(manual: bool, cx: &mut App) {
166 let Some(running_tag) = crate::linux_install::updatable_release() else {
192 if !checks_releases() {
167 if manual {
193 return;
168 notice(tr("install.updates_need_install"), cx);
194 }
169 }
195 if cfg!(windows) {
196 check_windows(manual, cx);
197 return;
198 }
199 let Some(running_tag) = installed_release() else {
200 check_notice(manual, cx);
170 return;
201 return;
171 };
202 };
172 ensure_state(cx);
203 ensure_state(cx);
@@ -175,7 +206,7 @@ pub fn check(manual: bool, cx: &mut App) {
175 open_dialog(cx);
206 open_dialog(cx);
176 return;
207 return;
177 }
208 }
178 Stage::Idle | Stage::Offer(_) | Stage::Failed(_) => {}
209 Stage::Idle | Stage::Offer(_) | Stage::Notice(_) | Stage::Failed(_) => {}
179 }
210 }
180 if manual {
211 if manual {
181 notice(tr("install.update_checking"), cx);
212 notice(tr("install.update_checking"), cx);
@@ -199,6 +230,70 @@ pub fn check(manual: bool, cx: &mut App) {
199 .detach();
230 .detach();
200}
231}
201
232
233fn check_windows(manual: bool, cx: &mut App) {
234 if !manual && !enabled(cx) {
235 return;
236 }
237 let Some(running_tag) = app_base::version::release_tag() else {
238 return;
239 };
240 let Some(paths) = updater::current_paths() else {
241 return;
242 };
243 if manual {
244 notice(tr("install.update_checking"), cx);
245 }
246 let fetch = release_feed::fetch_update(running_tag, paths, cx);
247 cx.spawn(async move |cx| {
248 let found = fetch.await;
249 cx.update(|cx| match found {
250 Ok(Some(tag)) if manual => notice(
251 tr_args("install.update_ready_body", &args("version", tag)),
252 cx,
253 ),
254 Ok(_) if manual => notice(tr("install.up_to_date"), cx),
255 Ok(_) => {}
256 Err(error) if manual => {
257 notice(tr_args("install.update_failed", &args("detail", error)), cx)
258 }
259 Err(error) => log::warn!("update check failed: {error}"),
260 });
261 })
262 .detach();
263}
264
265fn check_notice(manual: bool, cx: &mut App) {
266 let Some(running_tag) = app_base::version::release_tag() else {
267 return;
268 };
269 ensure_state(cx);
270 if matches!(stage(cx), Stage::Notice(_)) {
271 open_dialog(cx);
272 return;
273 }
274 if manual {
275 notice(tr("install.update_checking"), cx);
276 }
277 let find = release_feed::find_release(running_tag, cx);
278 cx.spawn(async move |cx| {
279 let found = find.await;
280 cx.update(|cx| match found {
281 Ok(Some(update)) if manual || declined(cx).as_deref() != Some(&update.tag) => {
282 set_stage(Stage::Notice(update.tag), cx);
283 show_when_window_is_open(cx);
284 }
285 Ok(Some(_)) => {}
286 Ok(None) if manual => notice(tr("install.up_to_date"), cx),
287 Ok(None) => {}
288 Err(error) if manual => {
289 notice(tr_args("install.update_failed", &args("detail", error)), cx)
290 }
291 Err(error) => log::warn!("update check failed: {error}"),
292 });
293 })
294 .detach();
295}
296
202fn offer(update: AvailableUpdate, cx: &mut App) {
297fn offer(update: AvailableUpdate, cx: &mut App) {
203 set_stage(Stage::Offer(update), cx);
298 set_stage(Stage::Offer(update), cx);
204 show_when_window_is_open(cx);
299 show_when_window_is_open(cx);
@@ -212,7 +307,10 @@ fn show_when_window_is_open(cx: &mut App) {
212 cx.background_executor().timer(WINDOW_WAIT).await;
307 cx.background_executor().timer(WINDOW_WAIT).await;
213 }
308 }
214 cx.update(|cx| {
309 cx.update(|cx| {
215 if matches!(stage(cx), Stage::Offer(_) | Stage::Ready(_)) {
310 if matches!(
311 stage(cx),
312 Stage::Offer(_) | Stage::Ready(_) | Stage::Notice(_)
313 ) {
216 open_dialog(cx);
314 open_dialog(cx);
217 }
315 }
218 });
316 });
@@ -345,6 +443,37 @@ fn build_dialog(dialog: Dialog, cx: &App) -> Dialog {
345 ),
443 ),
346 )
444 )
347 }
445 }
446 Stage::Notice(tag) => {
447 let mut text_args = args("version", tag.clone());
448 text_args.insert("current".to_owned(), running.to_owned());
449 let open = tag.clone();
450 (
451 tr("install.update_available_title"),
452 tr_args("install.update_available_body", &text_args),
453 DialogFooter::new()
454 .child(
455 Button::new("update-not-now")
456 .label(tr("install.not_now"))
457 .on_click(move |_, window, cx| {
458 decline(&tag, cx);
459 set_stage(Stage::Idle, cx);
460 close_dialog(window, cx);
461 }),
462 )
463 .child(
464 Button::new("update-open-release")
465 .primary()
466 .label(tr("install.open_release"))
467 .on_click(move |_, window, cx| {
468 let url = release_feed::release_page_url(&open);
469 decline(&open, cx);
470 set_stage(Stage::Idle, cx);
471 close_dialog(window, cx);
472 cx.open_url(&url);
473 }),
474 ),
475 )
476 }
348 Stage::Ready(tag) => (
477 Stage::Ready(tag) => (
349 tr("install.update_ready_title"),
478 tr("install.update_ready_title"),
350 tr_args("install.update_ready_body", &args("version", tag)),
479 tr_args("install.update_ready_body", &args("version", tag)),
crates/app/src/main.rs +2 −1
@@ -18,7 +18,6 @@ mod linux_browser;
18 18 mod linux_install;
19 19 #[cfg(any(target_os = "linux", target_os = "macos"))]
20 20 mod linux_park;
21 #[cfg(target_os = "linux")]
22 21 mod linux_update;
23 22 mod main_window;
24 23 pub mod notify;
@@ -398,6 +397,8 @@ fn main() {
398 397 #[cfg(target_os = "linux")]
399 398 if !arguments.demo {
400 399 linux_install::start(cx);
400 }
401 if !arguments.demo {
401 402 linux_update::start(cx);
402 403 }
403 404 if !arguments.autostart {
@@ -18,7 +18,6 @@ mod linux_browser;
18mod linux_install;
18mod linux_install;
19#[cfg(any(target_os = "linux", target_os = "macos"))]
19#[cfg(any(target_os = "linux", target_os = "macos"))]
20mod linux_park;
20mod linux_park;
21#[cfg(target_os = "linux")]
22mod linux_update;
21mod linux_update;
23mod main_window;
22mod main_window;
24pub mod notify;
23pub mod notify;
@@ -398,6 +397,8 @@ fn main() {
398 #[cfg(target_os = "linux")]
397 #[cfg(target_os = "linux")]
399 if !arguments.demo {
398 if !arguments.demo {
400 linux_install::start(cx);
399 linux_install::start(cx);
400 }
401 if !arguments.demo {
401 linux_update::start(cx);
402 linux_update::start(cx);
402 }
403 }
403 if !arguments.autostart {
404 if !arguments.autostart {
crates/app/src/settings/general.rs +43 −28
@@ -86,6 +86,7 @@ pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &
86 86 })
87 87 .children(external_browser_rows(app, cx))
88 88 .children(install_rows(cx))
89 .children(update_rows(cx))
89 90 .child(caption(tr("settings.caption.compose_box")))
90 91 .child(account_select(
91 92 app,
@@ -114,7 +115,7 @@ fn settings_toggle(
114 115 })
115 116 }
116 117
117 /// Linux only: the application menu install, the install question and updates.
118 /// Linux only: the application menu install and the install question.
118 119 fn install_rows(cx: &App) -> Vec<AnyElement> {
119 120 #[cfg(not(target_os = "linux"))]
120 121 {
@@ -174,37 +175,51 @@ fn install_rows(cx: &App) -> Vec<AnyElement> {
174 175 .into_any_element(),
175 176 );
176 177 }
177 let automatic = crate::linux_update::enabled(cx);
178 rows.push(
179 toggle_row(
180 "settings-auto-updates",
181 tr("install.auto_updates"),
182 tr("install.auto_updates_detail"),
183 theme::text_muted(),
184 automatic,
185 )
186 .on_click(move |_, _, cx| crate::linux_update::set_enabled(!automatic, cx))
187 .into_any_element(),
188 );
189 let version = linux_install::running_release().to_owned();
190 let updates_detail = if linux_install::updatable_release().is_some() {
191 with("install.updates_detail", "version", version)
192 } else {
193 with("install.updates_detail_not_installed", "version", version)
194 };
195 rows.push(
196 control_row(
197 tr("install.updates_title"),
198 updates_detail,
199 text_button("settings-check-updates", tr("install.check_now"))
200 .on_click(|_, _, cx| crate::linux_update::check(true, cx)),
201 )
202 .into_any_element(),
203 );
204 178 rows
205 179 }
206 180 }
207 181
182 /// Same release check on every OS. Flatpak hides it; the package owns updates.
183 fn update_rows(cx: &App) -> Vec<AnyElement> {
184 if !crate::linux_update::checks_releases() {
185 return Vec::new();
186 }
187 use std::collections::HashMap;
188
189 use super::rows::{control_row, text_button};
190 use crate::i18n::tr_args;
191
192 let version = app_base::version::release_tag()
193 .unwrap_or(concat!("v", env!("CARGO_PKG_VERSION")))
194 .to_owned();
195 let mut version_args = HashMap::new();
196 version_args.insert("version".to_owned(), version);
197 let detail_key = if app_base::version::release_tag().is_some() {
198 "install.updates_detail"
199 } else {
200 "install.updates_detail_dev"
201 };
202 let automatic = crate::linux_update::enabled(cx);
203 vec![
204 toggle_row(
205 "settings-auto-updates",
206 tr("install.auto_updates"),
207 tr("install.auto_updates_detail"),
208 theme::text_muted(),
209 automatic,
210 )
211 .on_click(move |_, _, cx| crate::linux_update::set_enabled(!automatic, cx))
212 .into_any_element(),
213 control_row(
214 tr("install.updates_title"),
215 tr_args(detail_key, &version_args),
216 text_button("settings-check-updates", tr("install.check_now"))
217 .on_click(|_, _, cx| crate::linux_update::check(true, cx)),
218 )
219 .into_any_element(),
220 ]
221 }
222
208 223 fn external_browser_rows(app: &Entity<AppState>, cx: &App) -> Vec<AnyElement> {
209 224 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
210 225 {
@@ -86,6 +86,7 @@ pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &
86 })
86 })
87 .children(external_browser_rows(app, cx))
87 .children(external_browser_rows(app, cx))
88 .children(install_rows(cx))
88 .children(install_rows(cx))
89 .children(update_rows(cx))
89 .child(caption(tr("settings.caption.compose_box")))
90 .child(caption(tr("settings.caption.compose_box")))
90 .child(account_select(
91 .child(account_select(
91 app,
92 app,
@@ -114,7 +115,7 @@ fn settings_toggle(
114 })
115 })
115}
116}
116
117
117/// Linux only: the application menu install, the install question and updates.
118/// Linux only: the application menu install and the install question.
118fn install_rows(cx: &App) -> Vec<AnyElement> {
119fn install_rows(cx: &App) -> Vec<AnyElement> {
119 #[cfg(not(target_os = "linux"))]
120 #[cfg(not(target_os = "linux"))]
120 {
121 {
@@ -174,37 +175,51 @@ fn install_rows(cx: &App) -> Vec<AnyElement> {
174 .into_any_element(),
175 .into_any_element(),
175 );
176 );
176 }
177 }
177 let automatic = crate::linux_update::enabled(cx);
178 rows.push(
179 toggle_row(
180 "settings-auto-updates",
181 tr("install.auto_updates"),
182 tr("install.auto_updates_detail"),
183 theme::text_muted(),
184 automatic,
185 )
186 .on_click(move |_, _, cx| crate::linux_update::set_enabled(!automatic, cx))
187 .into_any_element(),
188 );
189 let version = linux_install::running_release().to_owned();
190 let updates_detail = if linux_install::updatable_release().is_some() {
191 with("install.updates_detail", "version", version)
192 } else {
193 with("install.updates_detail_not_installed", "version", version)
194 };
195 rows.push(
196 control_row(
197 tr("install.updates_title"),
198 updates_detail,
199 text_button("settings-check-updates", tr("install.check_now"))
200 .on_click(|_, _, cx| crate::linux_update::check(true, cx)),
201 )
202 .into_any_element(),
203 );
204 rows
178 rows
205 }
179 }
206}
180}
207
181
182/// Same release check on every OS. Flatpak hides it; the package owns updates.
183fn update_rows(cx: &App) -> Vec<AnyElement> {
184 if !crate::linux_update::checks_releases() {
185 return Vec::new();
186 }
187 use std::collections::HashMap;
188
189 use super::rows::{control_row, text_button};
190 use crate::i18n::tr_args;
191
192 let version = app_base::version::release_tag()
193 .unwrap_or(concat!("v", env!("CARGO_PKG_VERSION")))
194 .to_owned();
195 let mut version_args = HashMap::new();
196 version_args.insert("version".to_owned(), version);
197 let detail_key = if app_base::version::release_tag().is_some() {
198 "install.updates_detail"
199 } else {
200 "install.updates_detail_dev"
201 };
202 let automatic = crate::linux_update::enabled(cx);
203 vec![
204 toggle_row(
205 "settings-auto-updates",
206 tr("install.auto_updates"),
207 tr("install.auto_updates_detail"),
208 theme::text_muted(),
209 automatic,
210 )
211 .on_click(move |_, _, cx| crate::linux_update::set_enabled(!automatic, cx))
212 .into_any_element(),
213 control_row(
214 tr("install.updates_title"),
215 tr_args(detail_key, &version_args),
216 text_button("settings-check-updates", tr("install.check_now"))
217 .on_click(|_, _, cx| crate::linux_update::check(true, cx)),
218 )
219 .into_any_element(),
220 ]
221}
222
208fn external_browser_rows(app: &Entity<AppState>, cx: &App) -> Vec<AnyElement> {
223fn external_browser_rows(app: &Entity<AppState>, cx: &App) -> Vec<AnyElement> {
209 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
224 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
210 {
225 {
crates/app/src/views/shell.rs +7 −0
@@ -150,6 +150,13 @@ fn watch_releases(running_tag: &'static str, cx: &mut App) {
150 150 .timer(release_feed::FIRST_CHECK_DELAY)
151 151 .await;
152 152 loop {
153 let allowed = cx.update(|cx| crate::linux_update::enabled(cx));
154 if !allowed {
155 cx.background_executor()
156 .timer(release_feed::CHECK_INTERVAL)
157 .await;
158 continue;
159 }
153 160 let Some(paths) = updater::current_paths() else {
154 161 return;
155 162 };
@@ -150,6 +150,13 @@ fn watch_releases(running_tag: &'static str, cx: &mut App) {
150 .timer(release_feed::FIRST_CHECK_DELAY)
150 .timer(release_feed::FIRST_CHECK_DELAY)
151 .await;
151 .await;
152 loop {
152 loop {
153 let allowed = cx.update(|cx| crate::linux_update::enabled(cx));
154 if !allowed {
155 cx.background_executor()
156 .timer(release_feed::CHECK_INTERVAL)
157 .await;
158 continue;
159 }
153 let Some(paths) = updater::current_paths() else {
160 let Some(paths) = updater::current_paths() else {
154 return;
161 return;
155 };
162 };
docs/decisions/0014-linux-installs-and-updates-itself.md +18 −6
@@ -3,20 +3,32 @@ status: accepted
3 3 date: 2026-11-14
4 4 ---
5 5
6 # ADR 0014: The Linux binary installs and updates itself
6 # ADR 0014: The Linux binary installs itself
7
8 Revised 2026-11-25: a newer release updates the copy that owns its install, and opens the release page everywhere else.
7 9
8 10 ## Context
9 11
10 12 The Linux release is a bare binary in a tarball. Users had to copy a `.desktop` file and an icon by hand, and only Windows updated itself from GitHub releases. The options were: an AppImage (FUSE mount on every start, its own update tooling), distro packages (one per distro, repositories to run), or letting the binary install itself into the user's data folder and reuse the Windows updater.
11 13
14 What decides an update is how the app was installed, not the operating system. A package manager already owns deb, rpm, Flatpak, and Snap. Swapping a Mach-O inside a signed macOS `.app` breaks the signature. An AppImage has its own update tool. A tarball copied into `~/.local` and the Windows per-user install can replace their own binary.
15
12 16 ## Decision
13 17
14 On start the binary offers to install itself into `~/.local/share/rusty-teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. The installed copy updates itself from the same GitHub releases as Windows (`release_feed.rs`, `updater.rs`), but always with consent (`linux_update.rs`): when Settings > General > Automatic updates is on (the default), a newer release is offered in a dialog; Update downloads the `rusty-teams-<version>-linux-amd64` asset (the tag without a leading `v`) with progress and checks size, ELF header and the SHA-256 digest GitHub reports; Restart now swaps the file and relaunches. Not now holds for the running session; the next start asks again. There is no idle restart and no install on quit on Linux: a download left for later is offered again on the next start (Restart now, no second download). Settings > General > Check now runs the same flow on demand. A build compares releases against its release tag, or against the workspace version (kept equal to the latest release) when built locally. Binaries outside the install folder never replace themselves; Settings > General still shows the switch and Check now and explains that the app has to be installed first.
18 On start the binary offers to install itself into `~/.local/share/rusty-teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. That install is not an update.
19
20 A release-tagged build looks for a newer GitHub tag when Settings > General > Updates is on (`updates.enabled`, one key on every OS, on by default). The old Linux key is not read.
21
22 - Windows downloads quietly and restarts when the app is idle and not in a call. The Windows deploy still swaps the binary from `update\`.
23 - Linux installed under `~/.local` asks first, downloads the platform asset, checks size, header, and the SHA-256 digest GitHub reports, then restarts only when the user asks.
24 - macOS, Linux deb/rpm/AppImage, and a binary that is not the `~/.local` install open the release page. Nothing is downloaded.
25 - Flatpak (`FLATPAK_ID`) does not check and hides the settings row.
26 - A build without a release tag does not check.
27
28 Not now holds for this run. Check now runs the same path on demand.
15 29
16 30 ## Consequences
17 31
18 32 - One binary, no root, no FUSE; menu entry and dock matching work after one click.
19 - Releases must keep publishing the bare `-linux-amd64` binary next to the tarball.
20 - Windows keeps its quiet download and idle restart; the two platforms differ on purpose.
21 - A self-built binary that is installed is offered releases newer than its workspace version; starting a newer build offers to replace the installed one.
22 - System packages (deb, rpm, Flatpak) stay possible and should simply not offer the install.
33 - Package-managed installs stay on the package manager. The dialog does not replace them.
34 - The Windows ARM64 asset name stays `-windows-arm64.exe`.
@@ -3,20 +3,32 @@ status: accepted
3date: 2026-11-14
3date: 2026-11-14
4---
4---
5
5
6# ADR 0014: The Linux binary installs and updates itself
6# ADR 0014: The Linux binary installs itself
7
8Revised 2026-11-25: a newer release updates the copy that owns its install, and opens the release page everywhere else.
7
9
8## Context
10## Context
9
11
10The Linux release is a bare binary in a tarball. Users had to copy a `.desktop` file and an icon by hand, and only Windows updated itself from GitHub releases. The options were: an AppImage (FUSE mount on every start, its own update tooling), distro packages (one per distro, repositories to run), or letting the binary install itself into the user's data folder and reuse the Windows updater.
12The Linux release is a bare binary in a tarball. Users had to copy a `.desktop` file and an icon by hand, and only Windows updated itself from GitHub releases. The options were: an AppImage (FUSE mount on every start, its own update tooling), distro packages (one per distro, repositories to run), or letting the binary install itself into the user's data folder and reuse the Windows updater.
11
13
14What decides an update is how the app was installed, not the operating system. A package manager already owns deb, rpm, Flatpak, and Snap. Swapping a Mach-O inside a signed macOS `.app` breaks the signature. An AppImage has its own update tool. A tarball copied into `~/.local` and the Windows per-user install can replace their own binary.
15
12## Decision
16## Decision
13
17
14On start the binary offers to install itself into `~/.local/share/rusty-teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. The installed copy updates itself from the same GitHub releases as Windows (`release_feed.rs`, `updater.rs`), but always with consent (`linux_update.rs`): when Settings > General > Automatic updates is on (the default), a newer release is offered in a dialog; Update downloads the `rusty-teams-<version>-linux-amd64` asset (the tag without a leading `v`) with progress and checks size, ELF header and the SHA-256 digest GitHub reports; Restart now swaps the file and relaunches. Not now holds for the running session; the next start asks again. There is no idle restart and no install on quit on Linux: a download left for later is offered again on the next start (Restart now, no second download). Settings > General > Check now runs the same flow on demand. A build compares releases against its release tag, or against the workspace version (kept equal to the latest release) when built locally. Binaries outside the install folder never replace themselves; Settings > General still shows the switch and Check now and explains that the app has to be installed first.
18On start the binary offers to install itself into `~/.local/share/rusty-teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. That install is not an update.
19
20A release-tagged build looks for a newer GitHub tag when Settings > General > Updates is on (`updates.enabled`, one key on every OS, on by default). The old Linux key is not read.
21
22- Windows downloads quietly and restarts when the app is idle and not in a call. The Windows deploy still swaps the binary from `update\`.
23- Linux installed under `~/.local` asks first, downloads the platform asset, checks size, header, and the SHA-256 digest GitHub reports, then restarts only when the user asks.
24- macOS, Linux deb/rpm/AppImage, and a binary that is not the `~/.local` install open the release page. Nothing is downloaded.
25- Flatpak (`FLATPAK_ID`) does not check and hides the settings row.
26- A build without a release tag does not check.
27
28Not now holds for this run. Check now runs the same path on demand.
15
29
16## Consequences
30## Consequences
17
31
18- One binary, no root, no FUSE; menu entry and dock matching work after one click.
32- One binary, no root, no FUSE; menu entry and dock matching work after one click.
19- Releases must keep publishing the bare `-linux-amd64` binary next to the tarball.
33- Package-managed installs stay on the package manager. The dialog does not replace them.
20- Windows keeps its quiet download and idle restart; the two platforms differ on purpose.
34- The Windows ARM64 asset name stays `-windows-arm64.exe`.
21- A self-built binary that is installed is offered releases newer than its workspace version; starting a newer build offers to replace the installed one.
22- System packages (deb, rpm, Flatpak) stay possible and should simply not offer the install.