Skip to main content

Module updating_window

Module updating_window 

Source
Expand description

The “Updating to ” window of an in-app upgrade that has to stop the running launcher first: a setup.exe install on Windows, a .dmg install on macOS.

The old launcher has to exit so the installer can replace its files, and the installer runs hidden (upgrade_restart::installer_script): from the moment the person confirms the restart until the new version’s own splash appears, nothing of AgentMux is on screen. This window fills that gap. It looks like the splash (same logo, same card) and its footer says which version is coming.

It is a copy of this launcher, started from a folder in the temp directory (the install folder’s files are about to be replaced, and a running one cannot be), with --updating-window <version> <script pid> <folder>.

On macOS the copy is of the whole .app, made with clonefile(2) (instant, and no disk space: the clone shares the original’s blocks). A launcher copied out of its bundle on its own is killed by the kernel on current macOS (its signature covers the bundle’s Info.plist, and AppleSystemPolicy refuses it); a clone of the bundle keeps the signature valid and notarized, so Gatekeeper accepts it, and it never carries the quarantine flag. Where the bundle can’t be cloned (a volume without clonefile), there is no window and the upgrade goes on without one. The new launcher’s splash tells the window it is up by creating new_splash_marker in the window’s folder, and the hand-off script (the macOS one) leaves failed_marker when the swap failed. It shows nothing but that text and ends by itself, never by waiting on anything that may not come:

  • the new launcher’s splash is on screen (it sets the event event_name): the normal end;
  • the hand-off script has ended and the new splash has not come within QUIET_END: gone quietly;
  • the script ended after an install that did not succeed (it leaves failed_marker): it says so for FAILED_HOLD, while the script starts the version the person had, then ends;
  • SLOW_AFTER: the text says it is taking longer; HARD_CAP: it ends whatever happens.

The upgrade does not depend on it: if the copy cannot be made or started, the upgrade goes on without it.

Structs§

Inputs
What the window knows each moment.

Enums§

Phase
What the window shows.

Constants§

ARG
The argument that makes a launcher run only this window.
DIR_PREFIX 🔒
The folder (in the temp directory) a hand-off’s window runs from: agentmux-updating-<pid of the old launcher>.
FAILED_HOLD
How long a failed install’s message stays after the script ended.
HARD_CAP
The window never lives longer than this.
QUIET_END
How long after the hand-off script ended the window waits for the new splash before it leaves on its own.
SLOW_AFTER
After this long with no end, the text says the update is taking longer than usual.
STALE_AFTER 🔒
A hand-off folder left this long ago is removed by the next start (the window removes its own on macOS).

Functions§

dir
The folder this launcher’s hand-off window runs from; the script’s marker is in it too.
early
Nothing to do on Linux.
event_name
The name of the event the new launcher’s splash sets when it is on screen (the session’s own namespace).
failed_marker
The file the hand-off script leaves when the install did not succeed (the installer’s exit code was not 0, or the installer was not the one checked): the window then says so.
footer
The footer’s two lines, in place of user@host and the version: the version shown is the one coming, never the one that is leaving.
footer_mac
footer for the macOS card: its footer is 13 pt fixed-pitch text on a 220 pt card, 26 characters at most, so the lines are shorter. Same meaning, ASCII only.
headline
The line in the splash’s stage area. ASCII only: the splash font has no more.
is_hand_off_dir_name 🔒
Whether name is the folder name of a hand-off’s window (dir).
new_splash_marker
The file the new launcher’s splash leaves in the window’s folder when it is on screen (macOS: the Windows window uses event_name instead).
parse_request 🔒
What --updating-window was given: the version to show, the hand-off script’s pid, the folder. None when the arguments are not a request for the window; Some(Err(())) when they are but are not usable.
phase
What to show now, or that the window is done.
remove_stale_in
Remove the folders of hand-offs long over from root: those last changed more than older_than ago. A running copy can’t delete itself on Windows, so each start tidies the earlier ones. Returns how many it removed.
signal_new_splash_in
Tell every hand-off window with a folder in root that the new launcher’s splash is on screen. Nothing happens when none is up (the usual case: it is one directory listing). A marker is created new, never over a link.
valid_version
A version the window will show: what a release is called (digits, dots, and a -/+ suffix), and no longer than that. Anything else is not drawn: this process is started with it as an argument.