Skip to content

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.

fix(install): keep the desktop app working beside a server install

RoversXef4ad76fce91
diff --git a/README-DISTRO-MAINTAINER.md b/README-DISTRO-MAINTAINER.md
index b0ed9e4c..8ad9a364 100644
--- a/README-DISTRO-MAINTAINER.md
+++ b/README-DISTRO-MAINTAINER.md
@@ -44,7 +44,8 @@ string.
## Additional Resources
* `assets/shell-integration`, `assets/shell-completion`: should be deployed along with the `wezterm` executable
-* `assets/wezterm.desktop`, `assets/wezterm.appdata.xml`, `assets/wezterm-nautilus.py`: should be deployed along with `wezterm-gui`
+* `assets/wezterm.desktop`, `assets/wezterm.appdata.xml`, `assets/wezterm-nautilus.py`: should be deployed along with `wezterm-gui`.
+ Point `Exec=` and `TryExec=` in the `.desktop` file at your package's `thinkterm` by absolute path, as `ci/deploy.sh` does: by bare name it goes through `PATH`, where a `thinkterm` under `~/.local/bin` may come first and have no GUI to start.
## Building wezterm
diff --git a/assets/open-thinkterm-here b/assets/open-thinkterm-here
index 06fa6a5c..8d8023ce 100755
--- a/assets/open-thinkterm-here
+++ b/assets/open-thinkterm-here
@@ -2,4 +2,6 @@
# This script is a helper that starts a new terminal window
# in the cwd of the calling process, rather than using the
# default cwd which is usually the home directory.
-exec thinkterm start --cwd "$PWD" -- "$@"
+# The GUI by its own name: the first `thinkterm` on PATH may be an install
+# that has none.
+exec thinkterm-gui start --cwd "$PWD" -- "$@"
diff --git a/assets/open-wezterm-here b/assets/open-wezterm-here
index 06fa6a5c..8d8023ce 100755
--- a/assets/open-wezterm-here
+++ b/assets/open-wezterm-here
@@ -2,4 +2,6 @@
# This script is a helper that starts a new terminal window
# in the cwd of the calling process, rather than using the
# default cwd which is usually the home directory.
-exec thinkterm start --cwd "$PWD" -- "$@"
+# The GUI by its own name: the first `thinkterm` on PATH may be an install
+# that has none.
+exec thinkterm-gui start --cwd "$PWD" -- "$@"
diff --git a/assets/wezterm-nautilus.py b/assets/wezterm-nautilus.py
index 239fd9c1..2ceba256 100644
--- a/assets/wezterm-nautilus.py
+++ b/assets/wezterm-nautilus.py
@@ -35,7 +35,9 @@ class OpenInWezTermAction(GObject.GObject, Nautilus.MenuProvider):
"org.freedesktop.systemd1.Manager", None)
def _open_terminal(self, path):
- cmd = ['thinkterm', 'start', '--cwd', path]
+ # The GUI by its own name: the first `thinkterm` on PATH may be an
+ # install that has none.
+ cmd = ['thinkterm-gui', 'start', '--cwd', path]
child = Gio.Subprocess.new(cmd, Gio.SubprocessFlags.NONE)
if self._systemd:
# Move new terminal into a dedicated systemd scope to make systemd
diff --git a/ci/PKGBUILD.template b/ci/PKGBUILD.template
index 0b646fb2..6db037b4 100644
--- a/ci/PKGBUILD.template
+++ b/ci/PKGBUILD.template
@@ -68,6 +68,11 @@ package() {
"${pkgdir}/usr/share/icons/hicolor/128x128/apps/com.roversx.thinkterm.png"
install -Dm644 squashfs-root/usr/share/applications/com.roversx.thinkterm.desktop \
"${pkgdir}/usr/share/applications/com.roversx.thinkterm.desktop"
+ # By bare name it goes through PATH, where an install under ~/.local would
+ # decide what it starts.
+ sed -i -e 's|^TryExec=thinkterm$|TryExec=/usr/bin/thinkterm|' \
+ -e 's|^Exec=thinkterm |Exec=/usr/bin/thinkterm |' \
+ "${pkgdir}/usr/share/applications/com.roversx.thinkterm.desktop"
install -Dm644 squashfs-root/usr/share/nautilus-python/extensions/wezterm-nautilus.py \
"${pkgdir}/usr/share/nautilus-python/extensions/wezterm-nautilus.py"
}
diff --git a/ci/deploy.sh b/ci/deploy.sh
index be0e2e29..7aac028b 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -48,6 +48,14 @@ TAG_NAME=${TAG_NAME:-$(git -c "core.abbrev=8" show -s "--format=%cd-%h" "--date=
HERE=$(pwd)
+# The launcher in a package that installs to /usr/bin names that binary. By
+# bare name it goes through PATH, and an install under ~/.local, which usually
+# comes first, then decides what it starts: possibly a server with no GUI.
+# assets/wezterm.desktop itself stays as it is: an AppImage takes the name of
+# what it runs from it, Flatpak has no /usr/bin of its own to point at, and
+# install.sh rewrites the bare name for its own prefix.
+PIN_DESKTOP_EXEC="sed -i -e 's|^TryExec=thinkterm\$|TryExec=/usr/bin/thinkterm|' -e 's|^Exec=thinkterm |Exec=/usr/bin/thinkterm |'"
+
if test -z "${SUDO+x}" && hash sudo 2>/dev/null; then
SUDO="sudo"
fi
@@ -519,6 +527,7 @@ ln -s thinkterm %{buildroot}/etc/bash_completion.d/wezterm
ln -s thinkterm.fish %{buildroot}/usr/share/fish/vendor_completions.d/wezterm.fish
install -Dm644 assets/icon/terminal.png %{buildroot}/usr/share/icons/hicolor/128x128/apps/com.roversx.thinkterm.png
install -Dm644 assets/wezterm.desktop %{buildroot}/usr/share/applications/com.roversx.thinkterm.desktop
+$PIN_DESKTOP_EXEC %{buildroot}/usr/share/applications/com.roversx.thinkterm.desktop
install -Dm644 assets/wezterm.appdata.xml %{buildroot}/usr/share/metainfo/com.roversx.thinkterm.appdata.xml
install -Dm644 assets/wezterm-nautilus.py %{buildroot}/usr/share/nautilus-python/extensions/wezterm-nautilus.py
install -Dm644 NOTICE %{buildroot}/usr/share/licenses/thinkterm/NOTICE
@@ -691,6 +700,7 @@ EOF
install -Dm755 -t $root/usr/bin assets/open-thinkterm-here assets/open-wezterm-here
install -Dm644 assets/icon/terminal.png $root/usr/share/icons/hicolor/128x128/apps/com.roversx.thinkterm.png
install -Dm644 assets/wezterm.desktop $root/usr/share/applications/com.roversx.thinkterm.desktop
+ eval "$PIN_DESKTOP_EXEC $root/usr/share/applications/com.roversx.thinkterm.desktop"
install -Dm644 assets/wezterm.appdata.xml $root/usr/share/metainfo/com.roversx.thinkterm.appdata.xml
install -Dm644 assets/wezterm-nautilus.py $root/usr/share/nautilus-python/extensions/wezterm-nautilus.py
fi
@@ -874,6 +884,7 @@ package() {
install -Dm755 -t "\$pkgdir"/usr/bin "\$srcdir"/thinkterm-tailnet
install -Dm644 "\$srcdir"/wezterm.desktop "\$pkgdir"/usr/share/applications/com.roversx.thinkterm.desktop
+ $PIN_DESKTOP_EXEC "\$pkgdir"/usr/share/applications/com.roversx.thinkterm.desktop
install -Dm644 "\$srcdir"/wezterm.appdata.xml "\$pkgdir"/usr/share/metainfo/com.roversx.thinkterm.appdata.xml
install -Dm644 "\$srcdir"/terminal.png "\$pkgdir"/usr/share/pixmaps/com.roversx.thinkterm.png
install -Dm644 "\$srcdir"/wezterm-icon.svg "\$pkgdir"/usr/share/pixmaps/com.roversx.thinkterm.svg
diff --git a/ci/test-remote-update.py b/ci/test-remote-update.py
index a4d968da..3aa60ef0 100644
--- a/ci/test-remote-update.py
+++ b/ci/test-remote-update.py
@@ -331,6 +331,53 @@ class InstallerTests(unittest.TestCase):
self.assertEqual((installed / "pam" / policy.name).read_bytes(), policy.read_bytes())
self.assertFalse((prefix / "etc/pam.d/thinkterm-connect-auth").exists())
+ def test_server_says_when_it_leaves_a_desktop_app_behind(self):
+ self.tool("thinkterm-gui", "#!/bin/sh\nexit 0\n")
+ output = self.run_install()
+ self.assertIn("this install has no GUI", output)
+ self.assertIn(str(self.bin / "thinkterm-gui"), output)
+ self.assertIn("sh -s -- --desktop\n", output)
+
+ def test_server_offers_no_way_out_under_another_prefix(self):
+ self.tool("thinkterm-gui", "#!/bin/sh\nexit 0\n")
+ output = self.run_install("--prefix", str(self.root / "elsewhere"))
+ self.assertIn("this install has no GUI", output)
+ self.assertNotIn("--desktop", output)
+
+ def test_server_offers_no_way_out_the_host_cannot_take(self):
+ self.package(GZIP.replace(".tar.gz", "-glibc2.31.tar.gz"))
+ self.write_api()
+ self.env["TEST_GLIBC"] = "2.31"
+ self.tool("thinkterm-gui", "#!/bin/sh\nexit 0\n")
+ output = self.run_install()
+ self.assertIn("this install has no GUI", output)
+ self.assertNotIn("--desktop", output)
+
+ @unittest.skipIf(Path("/usr/share/applications/com.roversx.thinkterm.desktop").exists(),
+ "this machine has a packaged ThinkTerm")
+ def test_server_with_no_other_desktop_app_says_nothing_of_one(self):
+ self.assertNotIn("this install has no GUI", self.run_install())
+
+ @unittest.skipIf(Path("/usr/share/applications/com.roversx.thinkterm.desktop").exists(),
+ "this machine has a packaged ThinkTerm")
+ def test_server_replacing_its_own_desktop_says_nothing_of_it(self):
+ bindir = self.home / ".local/bin"
+ bindir.mkdir(parents=True)
+ (bindir / "thinkterm-gui").write_text("#!/bin/sh\nexit 0\n")
+ (bindir / "thinkterm-gui").chmod(0o755)
+ self.env["PATH"] = f"{bindir}:{self.env['PATH']}"
+ # Spelled differently from the PATH entry that finds it.
+ output = self.run_install("--prefix", f"{self.home}/.local/")
+ self.assertNotIn("this install has no GUI", output)
+ self.assertFalse((bindir / "thinkterm-gui").exists())
+
+ def test_desktop_beside_another_desktop_app_says_nothing_of_it(self):
+ archive = self.desktop_package()
+ self.tool("thinkterm-gui", "#!/bin/sh\nexit 0\n")
+ output = self.run_install("--desktop", "--from", str(archive),
+ "--sha256", hashlib.sha256(archive.read_bytes()).hexdigest())
+ self.assertNotIn("this install has no GUI", output)
+
def test_linux_desktop_without_authentication_assets_still_installs(self):
archive = self.desktop_package(authentication=False)
self.run_install("--desktop", "--from", str(archive),
diff --git a/docs/thinkterm/remote-updates.md b/docs/thinkterm/remote-updates.md
index 45a087ee..7512e446 100644
--- a/docs/thinkterm/remote-updates.md
+++ b/docs/thinkterm/remote-updates.md
@@ -29,6 +29,19 @@ The v1 script must preserve `--release-info`, `--version`, `--server`,
are `#!/bin/sh` and `# thinkterm-installer-v1`. Breaking that contract requires
a new channel and namespace; old clients continue using v1 or their fallback.
+The variant follows what the host has. The script's desktop variant stays. On
+Linux, a desktop app from a distro package, which writes no manifest, gets the
+desktop variant under `~/.local`, even where a server install already sits
+beside it: a server there can take the name `thinkterm` from the package's
+launcher and leaves the app on its old version, and a package cannot update
+itself. A host whose glibc is too old for the desktop variant gets the server,
+and the question says what happens to the app. A macOS bundle is left alone: it
+runs its own binaries and updates itself.
+
+A client never takes a host backwards. A server of a newer release than the
+client is left as it is and the client is told to update, because that server
+would not hand its sessions to the older build.
+
The client first asks the GitHub releases API for its exact release version.
If that fails, it tries `thinkterm-release.txt` and its detached `.sig` file,
using the configured download sources. A pinned Ed25519 public key verifies
diff --git a/install.sh b/install.sh
index 827f6af9..bf9a5fdf 100755
--- a/install.sh
+++ b/install.sh
@@ -397,6 +397,23 @@ if [ -f "$manifest" ]; then
case "$prev_app" in */ThinkTerm.app) ;; *) prev_app="" ;; esac
fi
+# A desktop app this prefix does not own: a distro package, or an install
+# under another prefix. The server variant never touches it, and it is worth
+# saying so, because the two then go separate ways: its launcher finds
+# `thinkterm` through PATH, where ~/.local/bin usually comes first, and this
+# install cannot start a GUI. Not on macOS, where an app runs its own binaries
+# and updates itself.
+other_gui=""
+if [ "$os" = linux ]; then
+ if other_gui=$(command -v thinkterm-gui 2>/dev/null) && [ ! "$other_gui" -ef "$bindir/thinkterm-gui" ]; then
+ :
+ elif [ -f /usr/share/applications/com.roversx.thinkterm.desktop ]; then
+ other_gui=/usr/share/applications/com.roversx.thinkterm.desktop
+ else
+ other_gui=""
+ fi
+fi
+
# Never guessed from the machine: a headless box may want the TUI, and a
# desktop may be somebody's SSH target. Ask when there is someone to ask.
# Under `curl | sh` stdin is the script itself, so the question goes through
@@ -407,6 +424,9 @@ if [ -z "$variant" ]; then
if [ -n "$prev_variant" ]; then
note "ThinkTerm $prev_variant${prev_version:+ $prev_version} is installed under $(pretty "$prefix")." > /dev/tty
fi
+ if [ -n "$other_gui" ]; then
+ note "The desktop app is also at $(pretty "$other_gui"); the server variant leaves it at its own version." > /dev/tty
+ fi
printf ' %sWhich ThinkTerm do you want on this machine?%s\n' "$ui_bold" "$ui_reset" > /dev/tty
printf ' %s1%s desktop %sGUI + CLI + TUI + mux server%s\n' "$ui_accent" "$ui_reset" "$ui_dim" "$ui_reset" > /dev/tty
printf ' %s2%s server %sCLI + TUI + mux server, no GUI (headless hosts, SSH targets)%s\n' \
@@ -1398,6 +1418,18 @@ if system=$(command -v thinkterm 2>/dev/null) && [ "$system" != "$bindir/thinkte
next ! "another thinkterm comes first on PATH: $(pretty "$system")"
fi
+if [ -n "$other_gui" ] && [ "$variant" = server ]; then
+ next ! "this install has no GUI, and the desktop app at $(pretty "$other_gui") stays at its own version."
+ note "Its launcher may find this install first and stop working."
+ # Only where it would work: the launcher looks in ~/.local/share, not under
+ # another prefix, and the GUI needs a newer glibc than the server.
+ if [ "$prefix" = "$HOME/.local" ] && { [ -z "$glibc" ] || [ "$(printf '%s\n%s\n' "$min_glibc_desktop" "$glibc" \
+ | sort -V 2>/dev/null | head -n1)" = "$min_glibc_desktop" ]; }; then
+ note "To keep them together, run:"
+ cmd "curl -fsSL https://raw.githubusercontent.com/$repo/main/install.sh | sh -s -- --desktop"
+ fi
+fi
+
if [ -n "$missing_libs" ]; then
next ! "the GUI needs these libraries; the CLI and mux server run without them:"
printf ' %s%-30s %s%s\n' "$ui_dim" "library" "package (apt / dnf / zypper)" "$ui_reset"
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftl
index a09996bd..87763280 100644
--- a/thinkterm-i18n/i18n/de-DE.ftl
+++ b/thinkterm-i18n/i18n/de-DE.ftl
@@ -424,6 +424,7 @@ menu-space-server-group-offline = { $name } (getrennt)
menu-space-server-group-connecting = { $name } (verbindet…)
menu-space-server-group-reconnecting = { $name } (verbindet erneut…)
remote-tree-mutation-offline = { $name } ist getrennt. Verbinden Sie sich erneut und versuchen Sie es noch einmal.
+session-server-newer = Dieses ThinkTerm ({ $version }) ist älter als der Sitzungsserver auf diesem Computer ({ $server }), daher führt dieses Fenster eigene Terminals aus. Ihre bisherigen Terminals laufen im Server weiter: Aktualisieren Sie ThinkTerm, um zu ihnen zurückzukehren. Um bei dieser Version zu bleiben, stoppen Sie den Sitzungsserver in den Einstellungen; dabei werden die Terminals beendet.
menu-new-space-here = Neuer Space hier
menu-new-space-on-server = Neuer Space auf Server
menu-add-remote-host = Remote-Host hinzufügen…
diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftl
index 411691a4..841f8332 100644
--- a/thinkterm-i18n/i18n/en-US.ftl
+++ b/thinkterm-i18n/i18n/en-US.ftl
@@ -424,6 +424,7 @@ menu-space-server-group-offline = { $name } (disconnected)
menu-space-server-group-connecting = { $name } (connecting…)
menu-space-server-group-reconnecting = { $name } (reconnecting…)
remote-tree-mutation-offline = { $name } is disconnected. Reconnect and try again.
+session-server-newer = This ThinkTerm ({ $version }) is older than the session server on this computer ({ $server }), so this window runs its own terminals. Yours are still in the server: update ThinkTerm to get back to them, or stay on this version by stopping the session server in Settings, which ends them.
menu-new-space-here = New Space Here
menu-new-space-on-server = New Space on Server
menu-add-remote-host = Add Remote Host…
diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftl
index 89a9fc33..3e672cc6 100644
--- a/thinkterm-i18n/i18n/fr-FR.ftl
+++ b/thinkterm-i18n/i18n/fr-FR.ftl
@@ -424,6 +424,7 @@ menu-space-server-group-offline = { $name } (déconnecté)
menu-space-server-group-connecting = { $name } (connexion…)
menu-space-server-group-reconnecting = { $name } (reconnexion…)
remote-tree-mutation-offline = { $name } est déconnecté. Reconnectez-vous et réessayez.
+session-server-newer = Ce ThinkTerm ({ $version }) est plus ancien que le serveur de session de cet ordinateur ({ $server }) : cette fenêtre exécute donc ses propres terminaux. Les vôtres continuent dans le serveur : mettez ThinkTerm à jour pour les retrouver. Pour rester sur cette version, arrêtez le serveur de session dans les réglages, ce qui y mettra fin.
menu-new-space-here = Nouvel espace ici
menu-new-space-on-server = Nouvel espace sur un serveur
menu-add-remote-host = Ajouter un hôte distant…
diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftl
index 54b4dfed..bd66ad04 100644
--- a/thinkterm-i18n/i18n/ja-JP.ftl
+++ b/thinkterm-i18n/i18n/ja-JP.ftl
@@ -409,6 +409,7 @@ menu-space-server-group-offline = { $name }(切断)
menu-space-server-group-connecting = { $name }(接続中…)
menu-space-server-group-reconnecting = { $name }(再接続中…)
remote-tree-mutation-offline = { $name } は切断されています。再接続してからもう一度お試しください。
+session-server-newer = この ThinkTerm({ $version })は、このコンピュータのセッションサーバー({ $server })より古いため、このウィンドウは独自のターミナルを実行します。これまでのターミナルはサーバーで動き続けています。ThinkTerm を更新すると戻れます。このバージョンを使い続ける場合は、設定でセッションサーバーを停止できますが、それらのターミナルは終了します。
menu-new-space-here = このサーバーに新しいスペース
menu-new-space-on-server = サーバーに新しいスペース
menu-add-remote-host = リモートホストを追加…
diff --git a/thinkterm-i18n/i18n/ru-RU.ftl b/thinkterm-i18n/i18n/ru-RU.ftl
index bd2a2969..1798da59 100644
--- a/thinkterm-i18n/i18n/ru-RU.ftl
+++ b/thinkterm-i18n/i18n/ru-RU.ftl
@@ -407,6 +407,7 @@ menu-space-server-group-offline = { $name } (отключено)
menu-space-server-group-connecting = { $name } (подключение…)
menu-space-server-group-reconnecting = { $name } (повторное подключение…)
remote-tree-mutation-offline = { $name } отключён. Подключитесь и повторите попытку.
+session-server-newer = Этот ThinkTerm ({ $version }) старее сервера сеансов на этом компьютере ({ $server }), поэтому это окно запускает собственные терминалы. Ваши терминалы продолжают работать на сервере: обновите ThinkTerm, чтобы вернуться к ним. Чтобы остаться на этой версии, остановите сервер сеансов в настройках — эти терминалы завершатся.
menu-new-space-here = Новое пространство здесь
menu-new-space-on-server = Новое пространство на сервере
menu-add-remote-host = Добавить удалённый узел…
diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftl
index c7bff5e7..e738392a 100644
--- a/thinkterm-i18n/i18n/zh-CN.ftl
+++ b/thinkterm-i18n/i18n/zh-CN.ftl
@@ -409,6 +409,7 @@ menu-space-server-group-offline = { $name }(已断开)
menu-space-server-group-connecting = { $name }(连接中…)
menu-space-server-group-reconnecting = { $name }(重连中…)
remote-tree-mutation-offline = { $name } 已断开。请重新连接后再试。
+session-server-newer = 这个 ThinkTerm({ $version })比这台电脑上的会话服务器({ $server })旧,所以这个窗口单独运行终端。你原来的终端还在服务器里:更新 ThinkTerm 就能回到它们;想留在这个版本,可以在设置里停止会话服务器,那些终端会随之结束。
menu-new-space-here = 在此服务器新建空间
menu-new-space-on-server = 在服务器上新建空间
menu-add-remote-host = 添加远程主机…
diff --git a/thinkterm-update/src/lib.rs b/thinkterm-update/src/lib.rs
index 90a14751..951273c3 100644
--- a/thinkterm-update/src/lib.rs
+++ b/thinkterm-update/src/lib.rs
@@ -995,6 +995,19 @@ pub fn is_newer_release(latest: &str, current: &str) -> bool {
}
}
+/// Is `version` a release older than the release `than`? Development builds
+/// are left out on purpose, unlike in `is_newer_release`: their stamps order
+/// by commit date, and a build of an older commit is not thereby behind. A
+/// release built with local changes counts as that release, where semver
+/// would read `-dirty` as coming before it.
+pub fn is_older_release(version: &str, than: &str) -> bool {
+ let release = |version: &str| parse_release(version.trim_end_matches("-dirty"));
+ matches!(
+ (release(version), release(than)),
+ (Some(version), Some(than)) if version < than
+ )
+}
+
/// Is `latest` -- a release made from a commit committed at
/// `latest_commit_time` -- something the running build, `current` committed
/// at `current_commit_time`, should be told about?
@@ -1400,6 +1413,23 @@ mod tests {
assert!(!is_newer_release("20260903-120000-abcdef12", "0.2.0"));
}
+ #[test]
+ fn only_two_releases_can_be_older_than_each_other() {
+ assert!(is_older_release("0.3.9", "0.4.0"));
+ assert!(is_older_release("v0.3.9", "0.4.0"));
+ assert!(!is_older_release("0.4.0", "0.4.0"));
+ assert!(!is_older_release("0.4.1", "0.4.0"));
+ assert!(!is_older_release("0.4.0-dirty", "0.4.0"));
+ assert!(!is_older_release("0.4.0", "0.4.0-dirty"));
+ assert!(is_older_release("0.3.9-dirty", "0.4.0"));
+ assert!(!is_older_release(
+ "20260903-120000-abcdef12",
+ "20260904-120000-abcdef12"
+ ));
+ assert!(!is_older_release("20260903-120000-abcdef12", "0.4.0"));
+ assert!(!is_older_release("0.4.0", "20260903-120000-abcdef12"));
+ }
+
#[test]
fn the_version_decides_and_only_a_tie_goes_on_to_the_commits() {
// A higher or lower version settles it, whatever the commits.
diff --git a/wezterm-client/src/domain.rs b/wezterm-client/src/domain.rs
index a249f1e3..40373c0a 100644
--- a/wezterm-client/src/domain.rs
+++ b/wezterm-client/src/domain.rs
@@ -6347,16 +6347,23 @@ impl ClientDomain {
// client's build whenever the two differ, codec mismatch or
// not: the running one hands its panes over and exits. A
// failed takeover leaves a compatible server serving and
- // an incompatible one refused as before.
+ // an incompatible one refused as before. A newer release
+ // is not brought back: compatible it serves, incompatible
+ // it is refused without trying.
if let (ClientDomainConfig::Unix(unix), true) =
(&config, config.is_local_session_host())
{
let needs_takeover = match &verified {
- Ok(info) => info.version_string != config::wezterm_version(),
+ Ok(info) => {
+ info.version_string != config::wezterm_version()
+ && !crate::local_update::server_is_newer(&info.version_string)
+ }
Err(err)
if err
.downcast_ref::<crate::client::IncompatibleVersionError>()
- .is_some() =>
+ .is_some_and(|mismatch| {
+ !crate::local_update::server_is_newer(&mismatch.version)
+ }) =>
{
true
}
diff --git a/wezterm-client/src/local_update.rs b/wezterm-client/src/local_update.rs
index c20ac429..860ca79f 100644
--- a/wezterm-client/src/local_update.rs
+++ b/wezterm-client/src/local_update.rs
@@ -65,6 +65,14 @@ pub fn local_session_host_started_by_us() -> bool {
STARTED_LOCAL_SESSION_HOST.load(std::sync::atomic::Ordering::Acquire)
}
+/// Whether the server running here, of `version`, is a newer release than
+/// this client: an app left behind by an update of the server. That server
+/// stays, sessions and all. A takeover would at best be refused, and the
+/// stop that follows one on Windows would end its terminals.
+pub fn server_is_newer(version: &str) -> bool {
+ thinkterm_update::is_older_release(config::wezterm_version(), version)
+}
+
/// Run the server this client ships with as a successor of the one
/// listening on `unix`'s socket. `Ok(true)` when that one no longer serves
/// -- this build's successor does, or another client's that took it over
diff --git a/wezterm-client/src/remote_update.rs b/wezterm-client/src/remote_update.rs
index 6fff0018..2d9ad89e 100644
--- a/wezterm-client/src/remote_update.rs
+++ b/wezterm-client/src/remote_update.rs
@@ -16,6 +16,8 @@
//! - pick "the latest release". The server has to match *this* client, which
//! may not be the latest; a development build has no release to match at
//! all and is told so.
+//! - take a host backwards. A newer server stays, and this client is the one
+//! told to update.
//! - end sessions to get the new version running, when it can help it. A
//! server that can hand over (`thinkterm-mux-server --takeover`) is asked
//! to; only when it cannot, or the person turned that off, does the old
@@ -92,6 +94,17 @@ pub fn offer_remote_update(
err.codec_vers,
codec::CODEC_VERSION
));
+ // Another client brought that server forward, and it would not hand its
+ // sessions to this release anyway: all an install could do is leave an
+ // older build beside it and a question about ending them.
+ if thinkterm_update::is_older_release(&local, &err.version) {
+ ui.output_str(&format!(
+ "That server is newer than this client, so nothing changes on {host}. \
+ Update ThinkTerm here to {} to connect.\n",
+ err.version
+ ));
+ return Ok(RemoteUpdateOutcome::Declined);
+ }
let answer = ui.input(&format!(
"Look up ThinkTerm {local} on GitHub to install on {host}? [y/N] "
));
@@ -120,8 +133,9 @@ pub fn offer_remote_update(
// The ssh session comes first: the host has to be asked what is
// installed there before the question can say what will change. A
- // workstation with the desktop variant keeps its GUI; --server would
- // have removed it.
+ // workstation with the desktop variant keeps its GUI, whoever installed
+ // it: --server would have removed the script's, and left a package's
+ // launcher starting a CLI that has no GUI to start.
let ssh_config = mux::ssh::ssh_domain_to_ssh_config(ssh_dom)?;
let mut ui_for_auth = ui.clone();
let session = mux::ssh::ssh_connect_with_ui_and_password(
@@ -130,16 +144,30 @@ pub fn offer_remote_update(
ssh_dom.stored_password.clone(),
)
.with_context(|| format!("opening an ssh session to {host} for the update"))?;
- let variant = remote_variant(&session);
+ let manifest = run_capture(&session, VARIANT_READ).unwrap_or_default();
+ let host_probe = run_capture(&session, HOST_PROBE).unwrap_or_default();
+ let gui_probe = run_capture(&session, GUI_PROBE).unwrap_or_default();
+ let (variant, package_gui) = remote_variant(&manifest, &host_probe, &gui_probe);
// A host the release binaries cannot run on gets the answer straight
// away, rather than an installer run that fails at its first check.
- if let Some(reason) = host_cannot_take_a_release(&session, variant) {
+ if let Some(reason) = release_refusal(&host_probe, variant) {
ui.output_str(&format!(
"{reason}, so the release build of {local} cannot be installed on {host}.\n{}\n",
thinkterm_update::build_from_source_instructions(&local)
));
return Ok(RemoteUpdateOutcome::Declined);
}
+ let package_note = match package_gui {
+ PackageGui::Absent => String::new(),
+ PackageGui::Updated => format!(
+ "{host} has the ThinkTerm desktop app, so this installs the app too, keeping the \
+ app and the server on one version. Its launcher moves to the new install.\n"
+ ),
+ PackageGui::LeftBehind(reason) => format!(
+ "{reason}, so the ThinkTerm desktop app on {host} cannot come along: only the server \
+ is updated, the app stays at its own version, and its launcher may stop working.\n"
+ ),
+ };
let command = thinkterm_update::install_command(variant, &local);
// Uncommitted changes can include a newer protocol than the release
@@ -158,7 +186,7 @@ pub fn offer_remote_update(
"ThinkTerm can install {local} there now ({variant} variant, as the ssh user, \
under ~/.local, with no root). A verified online installer (or bundled fallback) \
and trusted release information will be sent over SSH; the host downloads the archive.\n\
- {caveat}Install it? [y/N] ",
+ {package_note}{caveat}Install it? [y/N] ",
));
let answer = match answer {
Ok(answer) => answer,
@@ -389,6 +417,12 @@ const HOST_PROBE: &str =
const VARIANT_READ: &str =
"sed -n 's/^variant=//p' \"$HOME/.local/share/thinkterm/install-manifest\" 2>/dev/null";
+/// Prints `gui` where a desktop app is installed that may not be the
+/// script's: a package writes no manifest for `VARIANT_READ` to find.
+const GUI_PROBE: &str = "if command -v thinkterm-gui >/dev/null 2>&1 \
+ || [ -f /usr/share/applications/com.roversx.thinkterm.desktop ]; \
+ then echo gui; fi";
+
/// Why the host cannot run a release binary of `variant`, if it cannot: the
/// same two checks `install.sh` makes first, made here so the answer comes
/// before the question. An unreadable answer is not a refusal; the script
@@ -427,13 +461,35 @@ fn release_refusal(probe: &str, variant: &str) -> Option<String> {
None
}
-/// Which variant the script installed on the host, read from its manifest.
-/// Falls back to the server variant, which is the only one that makes sense
-/// on a host with no install to preserve.
-fn remote_variant(session: &Session) -> &'static str {
- match run_capture(session, VARIANT_READ).as_deref().map(str::trim) {
- Ok("desktop") => "desktop",
- _ => "server",
+/// What an update does about a desktop app the script did not install.
+#[derive(Debug, PartialEq, Eq)]
+enum PackageGui {
+ Absent,
+ /// The desktop variant goes in beside it, and its launcher takes over.
+ Updated,
+ /// The desktop variant cannot run on the host, for this reason.
+ LeftBehind(String),
+}
+
+/// The variant to install, from what `VARIANT_READ`, `HOST_PROBE` and
+/// `GUI_PROBE` printed on the host. The script's desktop variant stays what
+/// it is. So does a distro package's app, on Linux, and a server install
+/// that has already gone in beside one moves to the desktop variant with it:
+/// the package's launcher may go through PATH, where a server under ~/.local
+/// takes the name from it, and the package cannot update itself to keep up
+/// with that server. A macOS bundle has neither problem, so it is not
+/// replaced from here. The server variant is what is left.
+fn remote_variant(manifest: &str, host_probe: &str, gui_probe: &str) -> (&'static str, PackageGui) {
+ if manifest.trim() == "desktop" {
+ return ("desktop", PackageGui::Absent);
+ }
+ let linux = host_probe.lines().next().map(str::trim) == Some("Linux");
+ if !linux || gui_probe.trim() != "gui" {
+ return ("server", PackageGui::Absent);
+ }
+ match release_refusal(host_probe, "desktop") {
+ None => ("desktop", PackageGui::Updated),
+ Some(reason) => ("server", PackageGui::LeftBehind(reason)),
}
}
@@ -576,7 +632,7 @@ fn run_and_relay_status(
#[cfg(test)]
mod tests {
- use super::{is_yes, release_refusal, without_input};
+ use super::{is_yes, release_refusal, remote_variant, without_input, PackageGui};
#[test]
fn only_an_explicit_yes_counts() {
@@ -607,12 +663,98 @@ mod tests {
assert_eq!(release_refusal("Darwin\narm64\n\n", "desktop"), None);
}
+ #[test]
+ fn a_host_keeps_the_desktop_app_it_has() {
+ let ubuntu = "Linux\nx86_64\nglibc 2.35\n";
+ // Nothing to preserve.
+ assert_eq!(
+ remote_variant("", ubuntu, ""),
+ ("server", PackageGui::Absent)
+ );
+ assert_eq!(
+ remote_variant("server\n", ubuntu, ""),
+ ("server", PackageGui::Absent)
+ );
+ // The script's own.
+ assert_eq!(
+ remote_variant("desktop\n", ubuntu, "gui\n"),
+ ("desktop", PackageGui::Absent)
+ );
+ // A package's, which writes no manifest, and one that a server
+ // install has already gone in beside.
+ assert_eq!(
+ remote_variant("", ubuntu, "gui\n"),
+ ("desktop", PackageGui::Updated)
+ );
+ assert_eq!(
+ remote_variant("server\n", ubuntu, "gui\n"),
+ ("desktop", PackageGui::Updated)
+ );
+ // Unreadable answers change nothing.
+ assert_eq!(
+ remote_variant("", "", "gui\n"),
+ ("server", PackageGui::Absent)
+ );
+ }
+
+ #[test]
+ fn a_package_gui_the_release_cannot_replace_is_named_and_left_behind() {
+ let (variant, gui) = remote_variant("", "Linux\nx86_64\nglibc 2.31\n", "gui\n");
+ assert_eq!(variant, "server");
+ match gui {
+ PackageGui::LeftBehind(reason) => assert!(reason.contains("glibc 2.31"), "{}", reason),
+ other => panic!("{:?}", other),
+ }
+ }
+
+ #[test]
+ fn a_mac_app_is_not_replaced_from_here() {
+ assert_eq!(
+ remote_variant("", "Darwin\narm64\n\n", "gui\n"),
+ ("server", PackageGui::Absent)
+ );
+ assert_eq!(
+ remote_variant("desktop", "Darwin\narm64\n\n", "gui\n"),
+ ("desktop", PackageGui::Absent)
+ );
+ }
+
+ #[cfg(unix)]
+ #[test]
+ fn the_gui_probe_answers_from_the_path() {
+ use std::process::Command;
+ let dir = std::env::temp_dir().join(format!("thinkterm-gui-probe-{}", std::process::id()));
+ let empty = dir.join("empty");
+ let with_gui = dir.join("with-gui");
+ std::fs::create_dir_all(&empty).unwrap();
+ std::fs::create_dir_all(&with_gui).unwrap();
+ let gui = with_gui.join("thinkterm-gui");
+ std::fs::write(&gui, "#!/bin/sh\n").unwrap();
+ let mut mode = std::fs::metadata(&gui).unwrap().permissions();
+ std::os::unix::fs::PermissionsExt::set_mode(&mut mode, 0o755);
+ std::fs::set_permissions(&gui, mode).unwrap();
+ let answer = |path: &std::path::Path| {
+ let out = Command::new("/bin/sh")
+ .args(["-c", &without_input(super::GUI_PROBE)])
+ .env("PATH", path)
+ .output()
+ .unwrap();
+ String::from_utf8(out.stdout).unwrap()
+ };
+ assert_eq!(answer(&with_gui), "gui\n");
+ if !std::path::Path::new("/usr/share/applications/com.roversx.thinkterm.desktop").exists() {
+ assert_eq!(answer(&empty), "");
+ }
+ std::fs::remove_dir_all(&dir).unwrap();
+ }
+
#[cfg(unix)]
#[test]
fn every_remote_command_still_parses_once_its_input_is_cut() {
for command in [
super::HOST_PROBE.to_string(),
super::VARIANT_READ.to_string(),
+ super::GUI_PROBE.to_string(),
super::STOP_COMMAND.to_string(),
thinkterm_update::install_command("server", "9.9.9"),
thinkterm_update::takeover_command(),
diff --git a/wezterm-gui/src/local_sessions.rs b/wezterm-gui/src/local_sessions.rs
index 4819c61b..227fcbb4 100644
--- a/wezterm-gui/src/local_sessions.rs
+++ b/wezterm-gui/src/local_sessions.rs
@@ -15,9 +15,11 @@
//! domain the host is.
use config::{ConfigHandle, UnixDomain};
+use fluent_bundle::FluentArgs;
use mux::domain::Domain;
use mux::Mux;
use std::sync::{Arc, Mutex, OnceLock};
+use wezterm_client::client::IncompatibleVersionError;
use wezterm_client::domain::{ClientDomain, ClientDomainConfig};
use window::WindowOps as _;
@@ -301,6 +303,20 @@ pub(crate) fn fall_back_to_in_process(mux: &Mux, why: &anyhow::Error) {
there is no in-process domain to fall back to"
),
}
+ if let Some(server) = why
+ .downcast_ref::<IncompatibleVersionError>()
+ .filter(|mismatch| wezterm_client::local_update::server_is_newer(&mismatch.version))
+ {
+ // The person's terminals are in that server, out of sight of this
+ // launch, and nothing else on screen would say where they went.
+ let mut args = FluentArgs::new();
+ args.set("version", config::wezterm_version());
+ args.set("server", server.version.clone());
+ wezterm_toast_notification::persistent_toast_notification(
+ "ThinkTerm",
+ &crate::i18n::tr_args("session-server-newer", &args),
+ );
+ }
}
/// The host came back as a different, empty server (it crashed and was
diff --git a/wezterm-mux-server-impl/src/handoff.rs b/wezterm-mux-server-impl/src/handoff.rs
index 116dfcc5..eaccd4de 100644
--- a/wezterm-mux-server-impl/src/handoff.rs
+++ b/wezterm-mux-server-impl/src/handoff.rs
@@ -187,20 +187,28 @@ pub fn handoff_socket_path(socket_path: &Path) -> PathBuf {
// ---------------------------------------------------------------- framing
-fn write_message(stream: &mut UnixStream, message: &HandoffMessage) -> anyhow::Result<()> {
+fn encode_message(message: &HandoffMessage) -> anyhow::Result<Vec<u8>> {
let mut bytes = Vec::new();
let mut encode = varbincode::Serializer::new(&mut bytes);
message
.serialize(&mut encode)
.context("encoding a handoff message")?;
+ Ok(bytes)
+}
+
+fn write_frame(stream: &mut UnixStream, bytes: &[u8]) -> anyhow::Result<()> {
let len = u32::try_from(bytes.len()).context("a handoff message is too large")?;
stream.write_all(&len.to_le_bytes())?;
- stream.write_all(&bytes)?;
+ stream.write_all(bytes)?;
stream.flush()?;
Ok(())
}
-fn read_message(stream: &mut UnixStream) -> anyhow::Result<HandoffMessage> {
+fn write_message(stream: &mut UnixStream, message: &HandoffMessage) -> anyhow::Result<()> {
+ write_frame(stream, &encode_message(message)?)
+}
+
+fn read_frame(stream: &mut UnixStream) -> anyhow::Result<Vec<u8>> {
let mut len = [0u8; 4];
stream
.read_exact(&mut len)
@@ -211,11 +219,72 @@ fn read_message(stream: &mut UnixStream) -> anyhow::Result<HandoffMessage> {
}
let mut bytes = vec![0u8; len];
stream.read_exact(&mut bytes)?;
- let mut reader = &bytes[..];
- let mut decode = varbincode::Deserializer::new(&mut reader);
+ Ok(bytes)
+}
+
+fn decode_message(reader: &mut &[u8]) -> anyhow::Result<HandoffMessage> {
+ let mut decode = varbincode::Deserializer::new(reader);
HandoffMessage::deserialize(&mut decode).context("decoding a handoff message")
}
+fn read_message(stream: &mut UnixStream) -> anyhow::Result<HandoffMessage> {
+ let bytes = read_frame(stream)?;
+ decode_message(&mut &bytes[..])
+}
+
+/// `Ready`, then the build saying it, in the same frame but outside the
+/// message: a running server from before successors said their build
+/// decodes `Ready` and never looks past it, so this is not a change of
+/// shape and `HANDOFF_VERSION` stays, and updating from one still works.
+fn write_ready(stream: &mut UnixStream) -> anyhow::Result<()> {
+ let mut bytes = encode_message(&HandoffMessage::Ready {
+ version: HANDOFF_VERSION,
+ })?;
+ bytes.extend_from_slice(config::wezterm_version().as_bytes());
+ write_frame(stream, &bytes)
+}
+
+/// The handoff version and the build from `write_ready`. A successor from
+/// before it says no build.
+fn read_ready(stream: &mut UnixStream) -> anyhow::Result<(u32, Option<String>)> {
+ let bytes = read_frame(stream)?;
+ let mut rest = &bytes[..];
+ match decode_message(&mut rest)? {
+ HandoffMessage::Ready { version } => Ok((
+ version,
+ (!rest.is_empty()).then(|| String::from_utf8_lossy(rest).into_owned()),
+ )),
+ HandoffMessage::Refused(why) => bail!("the other side refused: {why}"),
+ message => bail!("expected Ready, got {message:?}"),
+ }
+}
+
+/// Why a server of release `own` keeps its panes from a successor of build
+/// `successor`, if it does. An app left behind by an update of the server
+/// (a distro package beside a newer install under ~/.local) starts its own
+/// server at every launch, and handing over to it would put the older build
+/// in charge of the panes and shut out the clients that updated the server
+/// in the first place. A successor that says no build predates this rule,
+/// and so this server. Development builds are not held to it, nor is one
+/// that says no build on Windows: there is only one install there, so that
+/// is a rollback on purpose, and an app from before this rule stops a server
+/// that refuses it, terminals and all.
+fn refusal_of_older_successor(own: &str, successor: Option<&str>) -> Option<String> {
+ if !thinkterm_update::is_release_version(own) {
+ return None;
+ }
+ match successor {
+ None if cfg!(windows) => None,
+ None => Some(format!(
+ "this server is {own}, which an older build does not take over"
+ )),
+ Some(successor) if thinkterm_update::is_older_release(successor, own) => Some(format!(
+ "this server is {own}, which the older build {successor} does not take over"
+ )),
+ Some(_) => None,
+ }
+}
+
fn expect(stream: &mut UnixStream, what: &str) -> anyhow::Result<HandoffMessage> {
match read_message(stream)? {
HandoffMessage::Refused(why) => bail!("the other side refused: {why}"),
@@ -233,7 +302,6 @@ fn placeholder(what: &str) -> HandoffMessage {
match what {
"Ack" => HandoffMessage::Ack,
"Owned" => HandoffMessage::Owned,
- "Ready" => HandoffMessage::Ready { version: 0 },
other => panic!("no placeholder for {}", other),
}
}
@@ -778,12 +846,15 @@ struct Capture {
}
fn serve_inner(stream: &mut UnixStream, socket_path: &Path) -> anyhow::Result<()> {
- let HandoffMessage::Ready { version } = expect(stream, "Ready")? else {
- unreachable!()
- };
+ let (version, successor_build) = read_ready(stream)?;
if version != HANDOFF_VERSION {
bail!("the successor speaks handoff version {version}, this server speaks {HANDOFF_VERSION}");
}
+ if let Some(why) =
+ refusal_of_older_successor(config::wezterm_version(), successor_build.as_deref())
+ {
+ bail!("{why}");
+ }
#[cfg(windows)]
let successor = Successor::of(stream)?;
let unix_domains = config::configuration().unix_domains.len();
@@ -1130,12 +1201,7 @@ pub fn begin(socket_path: &Path) -> anyhow::Result<Takeover> {
})?;
stream.set_read_timeout(Some(HELLO_TIMEOUT))?;
stream.set_write_timeout(Some(STEP_TIMEOUT))?;
- write_message(
- &mut stream,
- &HandoffMessage::Ready {
- version: HANDOFF_VERSION,
- },
- )?;
+ write_ready(&mut stream)?;
let hello = match read_message(&mut stream)? {
HandoffMessage::Hello(hello) => hello,
HandoffMessage::Refused(why) => {
@@ -1707,6 +1773,50 @@ mod tests {
));
}
+ #[cfg(unix)]
+ #[test]
+ fn the_build_of_a_successor_passes_servers_that_do_not_look_for_it() {
+ let (mut a, mut b) = UnixStream::pair().unwrap();
+ // What a server from before builds were said reads.
+ write_ready(&mut a).unwrap();
+ match read_message(&mut b).unwrap() {
+ HandoffMessage::Ready { version } => assert_eq!(version, HANDOFF_VERSION),
+ other => panic!("{:?}", other),
+ }
+
+ write_ready(&mut a).unwrap();
+ let (version, build) = read_ready(&mut b).unwrap();
+ assert_eq!(version, HANDOFF_VERSION);
+ assert_eq!(build.as_deref(), Some(config::wezterm_version()));
+
+ // What a successor from before builds were said sends.
+ write_message(
+ &mut a,
+ &HandoffMessage::Ready {
+ version: HANDOFF_VERSION,
+ },
+ )
+ .unwrap();
+ assert_eq!(read_ready(&mut b).unwrap(), (HANDOFF_VERSION, None));
+
+ write_message(&mut a, &HandoffMessage::Refused("no".to_string())).unwrap();
+ assert!(read_ready(&mut b).is_err());
+ }
+
+ #[test]
+ fn panes_go_only_to_a_successor_that_is_not_older() {
+ let refused = |own, successor| refusal_of_older_successor(own, successor).is_some();
+ assert!(refused("0.4.3", Some("0.4.2")));
+ // Says no build: from before successors did, so older than this.
+ assert_eq!(refused("0.4.3", None), !cfg!(windows));
+ assert!(!refused("0.4.3", Some("0.4.3")));
+ assert!(!refused("0.4.3", Some("0.4.4")));
+ // A development build on either side is free to.
+ assert!(!refused("0.4.3", Some("20261106-120000-abcdef12")));
+ assert!(!refused("20261106-120000-abcdef12", Some("0.4.2")));
+ assert!(!refused("20261106-120000-abcdef12", None));
+ }
+
#[cfg(unix)]
#[test]
fn messages_and_snapshots_survive_their_bytes() {
diff --git a/wezterm-mux-server-impl/src/web_relay.rs b/wezterm-mux-server-impl/src/web_relay.rs
index b9cddce0..57491b80 100644
--- a/wezterm-mux-server-impl/src/web_relay.rs
+++ b/wezterm-mux-server-impl/src/web_relay.rs
@@ -2088,6 +2088,14 @@ fn plan(
});
}
}
+ // Its sessions would not come to an older release, so the most this
+ // could do is ask to end them.
+ if let Some(theirs) = remote.filter(|theirs| thinkterm_update::is_older_release(ours, theirs))
+ {
+ return Plan::Cannot(format!(
+ "ThinkTerm there ({theirs}) is newer than this server ({ours}); update this server"
+ ));
+ }
if let Some(why) = blocked {
return Plan::Cannot(why.to_string());
}
@@ -2096,8 +2104,8 @@ fn plan(
}
let newer = match met {
Met::Other { newer, .. } => *newer,
- // Older by its own word is ours to update. Newer, or a version
- // that does not compare with this one, is the person's to decide.
+ // Older by its own word is ours to update. A version that does not
+ // compare with this one is the person's to decide.
Met::Mute {
version: Some(theirs),
..
@@ -3226,6 +3234,23 @@ mod tests {
plan(&ours, &other(true), OURS, None, consent),
Plan::Ask(AskKind::Replace, _)
));
+ // A newer release there: left alone, whatever was agreed to.
+ let newer = Met::Other {
+ newer: true,
+ version: "0.4.4".into(),
+ };
+ let agreed = Consent {
+ install: true,
+ replace: true,
+ };
+ assert!(matches!(
+ plan(&ours, &newer, "0.4.3", None, consent),
+ Plan::Cannot(why) if why.contains("0.4.4") && why.contains("0.4.3")
+ ));
+ assert!(matches!(
+ plan(&ours, &newer, "0.4.3", None, agreed),
+ Plan::Cannot(_)
+ ));
// Nothing there: asked once, then installed.
let empty = Probe {
bin: None,
diff --git a/wezterm-mux-server/src/main.rs b/wezterm-mux-server/src/main.rs
index 86a99b6b..a68a7c66 100644
--- a/wezterm-mux-server/src/main.rs
+++ b/wezterm-mux-server/src/main.rs
@@ -50,7 +50,8 @@ struct Opt {
/// Take over from the mux server already running on this socket:
/// its panes, windows and clients continue under this binary, and
- /// the running server exits. The running server must support it.
+ /// the running server exits. The running server must support it, and
+ /// does not hand over to an older release.
#[arg(long = "takeover")]
takeover: bool,
diff --git a/wezterm/src/main.rs b/wezterm/src/main.rs
index c12d360b..e9132715 100644
--- a/wezterm/src/main.rs
+++ b/wezterm/src/main.rs
@@ -1301,11 +1301,25 @@ fn delegate_to_gui(saver: UmaskSaver) -> anyhow::Result<()> {
"thinkterm-gui"
};
- let exe = std::env::current_exe()?
+ let exe = std::env::current_exe()?;
+ // On macOS this can be the link install.sh leaves in ~/.local/bin, and
+ // the GUI is beside what that points at. Not on Windows, where the
+ // canonical form is a verbatim path and there are no such links.
+ #[cfg(unix)]
+ let exe = exe.canonicalize().unwrap_or(exe);
+ let exe = exe
.parent()
.ok_or_else(|| anyhow!("exe has no parent dir!?"))?
.join(exe_name);
+ if !exe.exists() {
+ anyhow::bail!(
+ "this ThinkTerm has no GUI to start: {} is not installed. `thinkterm tui` runs in \
+ this terminal; the desktop install of ThinkTerm adds the GUI",
+ exe.display()
+ );
+ }
+
let mut cmd = Command::new(exe);
if cfg!(windows) {
cmd.arg("--attach-parent-console");