Skip to main content

Module upgrade_restart

Module upgrade_restart 

Source
Expand description

“Upgrade & restart” (docs/specs/SPEC_UPGRADE_FOR_USERS_AND_AGENTS_2026_10_15.md §4.1, phases 3b, 3c and 3d): restart a Windows portable into the newer release srv downloaded, verified and unpacked next to it, run the newer release’s installer on a setup.exe install, or replace a macOS AgentMux.app from the release’s .dmg (upgrade_macos; backend/update/download.rs).

srv asks with an AGENTMUXSRV-UPGRADE line on its stderr (agentmux_common::srv_stderr); the reader in srv_spawner hands it here. The supervisor then:

  1. checks what srv names again (staged): an AgentMux portable of exactly that version, newer than this one, beside a portable; or that version’s installer, with the release’s digest, in this version’s own updates/<v>/, on a setup.exe install;
  2. goes ahead when srv marks the request confirmed (the restart was decided in the app: the user’s own click or turn, or an approved request’s in-app countdown with no veto); a request without the mark, from an older srv, is asked with a native dialog (confirm), which no page or agent tool in AgentMux can click;
  3. quits the host the way the tray’s Quit does, which closes the windows and saves the session;
  4. after srv has stopped (so the new version copies complete data, srv/src/migrations/carry_forward.rs), starts the new launcher, or a hidden PowerShell that waits for this launcher to be gone, runs the installer silently and starts AgentMux again (relaunch), and exits.

Enums§

DialogOutcome 🔒
How the restart question ended.
Staged
What a confirmed upgrade restarts into.

Constants§

ANSWER_WITHIN
A Yes counts only this long after its dialog opened (the dialog itself can’t time out). Shorter than srv’s wait (RESTART_GRACE, 3 minutes in srv/src/backend/update/restart.rs), so by the time the panel says the restart didn’t happen, no open dialog can still start one.
CONFIRMED_FOR
A confirmed restart that hasn’t happened within this long (the host never quit) no longer restarts into the new version on a later quit.
DIALOG_TITLE 🔒
KEPT_ENV 🔒
The variables that say WHICH data the launcher uses: the root, the config folder and the channel. The restart keeps them: an instance a person pointed at a root of its own (a test, a second profile) must come back on that root, not on the machine’s real channel, which the next version would then migrate.

Statics§

DIALOG_THREAD 🔒
The thread showing the open dialog, 0 when none (Windows).
LATEST_ASK 🔒
The latest request asked about: only its dialog’s Yes counts.
REQUESTS 🔒

Functions§

answer_counts 🔒
Whether a Yes to request ask, given waited after its dialog opened, still counts when latest is the newest request.
ask_then
Restart as srv asked, on a thread of its own. When the restart is confirmed (srv’s line says so: the user’s own click or turn, or an approved request whose in-app countdown ran out with no veto) nothing more is asked: no native dialog, so a computer nobody sits at restarts. The staged file was checked again before this (staged), and on a .deb or .rpm install the OS’s own permission prompt still stands: that one is the system’s, not a question of ours. A request that does not say it is confirmed is asked about, and on_yes is called only for an explicit Yes that still counts (answer_counts): one given within ANSWER_WITHIN, to the latest request. One dialog at a time: a newer request closes the open one, and a dialog closes itself (as No) once its time is up. A Yes that slips past either is told it expired. stopping lists what agents left running that the restart stops (stopping_note); the dialog names it. host_pid is the host’s process id: on Windows the dialog sits over the host’s window, so it comes up in front of the person instead of waiting on the taskbar.
check_package 🔒
confirm 🔒
Linux: zenity or kdialog (upgrade_linux::confirm). Shows the AppImage, or the portable’s folder. For a .deb or .rpm, a Yes is followed by the desktop’s password prompt (upgrade_package::authorize), and counts only once the install helper has accepted the file and is waiting for this launcher to quit.
confirmed_go 🔒
Whether to go on with a restart srv says is decided: always, except on a .deb or .rpm install, where the OS’s own permission prompt for the install is asked here and may be refused or go unanswered.
confirmed_outcome 🔒
How a decided restart went: on, or (the permission prompt of a package install said no, or was not answered within ANSWER_WITHIN) not.
current_thread 🔒
Off Windows, an id of its own for each dialog, so a superseded dialog’s timer never closes a newer one.
dialog_outcome 🔒
What became of the question: yes is the dialog’s answer, timed_out that the timer closed it, ask this request’s number and latest the newest one’s, waited how long it was open.
dismiss 🔒
Close the open dialog; the callers check thread is its.
encoded_command 🔒
-EncodedCommand’s form of script (base64 of UTF-16LE): the paths in it reach PowerShell as they are, through no shell’s parsing.
env_to_strip 🔒
The variables of vars the restart strips: AGENTMUX would make the next launcher think it was started from a pane, and the other AGENTMUX_* this launcher (or a parent) set (background service, tray) would override the next one’s settings. KEPT_ENV stays.
file_sha256 🔒
The file’s SHA-256 in lowercase hex, or None if it can’t be read.
forward
From the srv stderr reader.
has_uninstaller 🔒
Whether dir holds Inno Setup’s uninstaller (unins000.exe, …): a setup.exe install.
installer_script 🔒
The hidden PowerShell that upgrades a setup.exe install: wait a few seconds for this launcher to be gone (its files are replaced), run the installer silently, then start AgentMux again whatever the installer did, so a failed or declined install leaves the old version running, not none.
is_portable 🔒
A portable folder. setup.exe installs the same runtime/, marker and all, so a folder with Inno Setup’s uninstaller isn’t one.
is_sha256_hex 🔒
64 lowercase hex digits: all that is ever put in the script.
powershell_exe 🔒
Windows PowerShell by its full path, never whatever is first on PATH.
ps_quote 🔒
path as a PowerShell single-quoted string: nothing in it is expanded (no $, no %VAR%). Every character PowerShell takes as a single quote is written twice: ' and the typographic ones (U+2018 to U+201B), which a user name can hold.
relaunch
Restart into staged, detached, without this AgentMux’s own environment except where it keeps its data (KEPT_ENV).
relaunch_with_env 🔒
relaunch with the environment it was started in given, so a test can say what the old launcher had without changing this process’s.
requests
The supervisor’s end of srv’s upgrade requests. One per process: it lasts across srv respawns, since the reader of each new srv sends here too.
restart_env 🔒
What a process started to bring AgentMux back up gets for an environment: vars (this process’s), less what the next version must not inherit (env_to_strip, crate::upgrade_linux::NOT_INHERITED), and on Unix AppImageLauncher off.
restart_question 🔒
The question for a restart into the new version at from.
staged
What to restart into, if req names a newer release than own_version that fits this install (in own_dir, with its data in data_dir and its channel in channel_dir): a portable of exactly that version beside a portable (or, on Linux, where srv unpacked it, upgrade_linux), or that version’s installer in this version’s own updates/<v>/ on a setup.exe install.
still_confirmed
Whether a restart confirmed at at still stands.
stopping_note
The list srv leaves beside the staged update (updates/stopping.txt in this version’s data folder; srv’s background_work) of what agents left running that the restart stops: a dev server, another AgentMux. One written more than 15 minutes ago is from an earlier attempt and ignored.
stopping_paragraph 🔒
The dialog’s paragraph naming what the restart stops, or nothing.
version_core 🔒
major.minor.patch, or None.
write_declined 🔒
Tell srv the restart it asked for won’t happen, and why ([agentmux_common::srv_stderr::UPGRADE_DECLINED_FILE]): it is waiting on this launcher and would otherwise say “Restarting” for minutes after a No.