Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(desktop): run the Windows update setup in passive mode

claude-opus-5-5-medium0e99631638b4
diff --git a/apps/desktop/packaging/win/installer.nsi b/apps/desktop/packaging/win/installer.nsi
index 005e7ea5..3b7b18cc 100644
--- a/apps/desktop/packaging/win/installer.nsi
+++ b/apps/desktop/packaging/win/installer.nsi
@@ -1,14 +1,17 @@
; Per-user installer for Linger on Windows. package.py passes VERSION,
; NUMERIC_VERSION (VERSION without a prerelease suffix, for the X.X.X.X field),
-; STAGE (the app folder) and OUTPUT. No administrator rights are needed. The folder
-; is fixed: the uninstaller removes all of it.
+; STAGE (the app folder) and OUTPUT. No administrator rights are needed. There is
+; no folder page: the uninstaller removes all of the folder. An install goes where
+; the last one went, else to the default folder, unless /D= names another.
Unicode true
!include "MUI2.nsh"
!include "FileFunc.nsh"
Name "Linger"
OutFile "${OUTPUT}"
+!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Linger"
InstallDir "$LOCALAPPDATA\Programs\Linger"
+InstallDirRegKey HKCU "${UNINSTALL_KEY}" "InstallLocation"
; Where installs from before the rename put the app, and the app id they
; named "Open at login" after. Only the upgrade below reads them.
!define LEGACY_INSTDIR "$LOCALAPPDATA\Programs\Simplex"
@@ -17,7 +20,6 @@ InstallDir "$LOCALAPPDATA\Programs\Linger"
!define RUN_KEY "Software\Microsoft\Windows\CurrentVersion\Run"
RequestExecutionLevel user
SetCompressor /SOLID lzma
-!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Linger"
VIProductVersion "${NUMERIC_VERSION}.0"
VIAddVersionKey "ProductName" "Linger"
@@ -29,14 +31,48 @@ VIAddVersionKey "LegalCopyright" "Linger"
!define MUI_ICON "${STAGE}\resources\linger.ico"
!define MUI_UNICON "${STAGE}\resources\linger.ico"
+; The app's self-update runs this setup with /update /relaunch after it quit
+; (updater.ts): the progress page alone, which closes when done (the finish
+; page's MUI sets SetAutoClose true), then Linger starts. Unlike /S, the
+; questions below stay visible. /S still installs without any window.
+Var Updating
+Var Relaunch
+; Set once the install starts replacing files: the earlier app can no longer
+; start after a failure.
+Var Replacing
!define MUI_FINISHPAGE_RUN "$INSTDIR\Linger.exe"
+!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowProgress
!insertmacro MUI_PAGE_INSTFILES
+!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipWhenUpdating
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
+Function .onInit
+ ${GetParameters} $0
+ ClearErrors
+ ${GetOptions} $0 "/update" $1
+ IfErrors +2
+ StrCpy $Updating 1
+ ClearErrors
+ ${GetOptions} $0 "/relaunch" $1
+ IfErrors +2
+ StrCpy $Relaunch 1
+FunctionEnd
+
+Function ShowProgress
+ StrCmp $Updating 1 0 done
+ !insertmacro MUI_HEADER_TEXT "Updating Linger" "Updating Linger to ${VERSION}..."
+ done:
+FunctionEnd
+
+Function SkipWhenUpdating
+ StrCmp $Updating 1 0 +2
+ Abort
+FunctionEnd
+
; A running Linger holds its files open. Its services, run on Linger.exe, are
; stopped again on Retry, in case it started them before it quit.
!macro CLOSE_LINGER UN
@@ -153,6 +189,7 @@ Section "Linger"
Call CloseLinger
Call RemoveLegacyInstall
; An update replaces the whole app folder.
+ StrCpy $Replacing 1
RMDir /r "$INSTDIR\resources"
File /r "${STAGE}\*"
FileOpen $0 "${STOP_MARKER}" w
@@ -170,14 +207,28 @@ Section "Linger"
WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoRepair" 1
SectionEnd
-; The app's self-update runs this setup with /S /relaunch after it quit
-; (updater.ts): a silent install shows no finish page to start Linger from.
+; Neither a silent install nor an update shows the finish page to start
+; Linger from.
Function .onInstSuccess
- ${GetParameters} $0
- ClearErrors
- ${GetOptions} $0 "/relaunch" $1
- IfErrors done
+ StrCmp $Relaunch 1 0 done
+ Exec '"$INSTDIR\Linger.exe"'
+ done:
+FunctionEnd
+
+; Runs after Cancel on a question, or Abort on a file that could not be
+; written, once the person closes the window. An update that stopped before
+; replacing files starts the earlier app again, which offers the update again;
+; otherwise only this setup can bring Linger back.
+Function .onInstFailed
+ StrCmp $Updating 1 0 done
+ StrCmp $Replacing 1 rerun
+ IfFileExists "$INSTDIR\Linger.exe" 0 rerun
+ MessageBox MB_OK|MB_ICONEXCLAMATION "Linger was not updated. It will start again and offer the update again." /SD IDOK
+ StrCmp $Relaunch 1 0 done
Exec '"$INSTDIR\Linger.exe"'
+ Goto done
+ rerun:
+ MessageBox MB_OK|MB_ICONEXCLAMATION "Linger was not updated and cannot start until it is. Run this setup again to finish the update:$\r$\n$EXEPATH" /SD IDOK
done:
FunctionEnd
diff --git a/apps/desktop/src/main/updater.test.ts b/apps/desktop/src/main/updater.test.ts
index af9ab210..e51a70d9 100644
--- a/apps/desktop/src/main/updater.test.ts
+++ b/apps/desktop/src/main/updater.test.ts
@@ -329,7 +329,7 @@ describe("UpdaterModule with the Windows setup program", () => {
expect(calls).toEqual([
{
file: path.join(downloads, SETUP),
- args: ["/S", "/relaunch"],
+ args: ["/update", "/relaunch"],
options: { detached: true, stdio: "ignore" },
},
]);
diff --git a/apps/desktop/src/main/updater.ts b/apps/desktop/src/main/updater.ts
index c7f93d6b..0a056acf 100644
--- a/apps/desktop/src/main/updater.ts
+++ b/apps/desktop/src/main/updater.ts
@@ -91,8 +91,9 @@ export type SpawnSetup = (
options: { detached: true; stdio: "ignore" },
) => SetupProcess;
-// installer.nsi: /S installs without pages, /relaunch starts Linger after.
-export const SETUP_ARGS = ["/S", "/relaunch"] as const;
+// installer.nsi: /update shows only its progress page and the questions about
+// a locked file, then closes; /relaunch starts Linger after.
+export const SETUP_ARGS = ["/update", "/relaunch"] as const;
const CHECK_DELAY_MS = 60_000;
const CHECK_INTERVAL_MS = 60 * 60_000;
diff --git a/apps/desktop/src/main/windows-installer.test.ts b/apps/desktop/src/main/windows-installer.test.ts
index ad697b6d..a35b9ddf 100644
--- a/apps/desktop/src/main/windows-installer.test.ts
+++ b/apps/desktop/src/main/windows-installer.test.ts
@@ -94,14 +94,70 @@ it("stops the services again when Retry follows a running Linger", () => {
);
});
-it("starts Linger after a silent install only when asked to relaunch", () => {
+it("reads /update and /relaunch from the command line", () => {
order(
- block("Function .onInstSuccess", "FunctionEnd"),
+ block("Function .onInit", "FunctionEnd"),
"${GetParameters} $0",
+ '${GetOptions} $0 "/update" $1',
+ "StrCpy $Updating 1",
'${GetOptions} $0 "/relaunch" $1',
- "IfErrors done",
+ "StrCpy $Relaunch 1",
+ );
+ expect(script).toContain('!include "FileFunc.nsh"');
+});
+
+it("starts Linger after an install only when asked to relaunch", () => {
+ order(
+ block("Function .onInstSuccess", "FunctionEnd"),
+ "StrCmp $Relaunch 1 0 done",
"Exec '\"$INSTDIR\\Linger.exe\"'",
"done:",
);
- expect(script).toContain('!include "FileFunc.nsh"');
+});
+
+it("shows an update only its progress page", () => {
+ order(
+ script,
+ "!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowProgress",
+ "!insertmacro MUI_PAGE_INSTFILES",
+ "!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipWhenUpdating",
+ "!insertmacro MUI_PAGE_FINISH",
+ );
+ expect(script.match(/!insertmacro MUI_PAGE_/g)).toHaveLength(2);
+ order(
+ block("Function SkipWhenUpdating", "FunctionEnd"),
+ "$Updating",
+ "Abort",
+ );
+ order(
+ block("Function ShowProgress", "FunctionEnd"),
+ "$Updating",
+ "Updating Linger to ${VERSION}",
+ );
+ // A custom folder from /D= stays where it is.
+ expect(script).toContain(
+ 'InstallDirRegKey HKCU "${UNINSTALL_KEY}" "InstallLocation"',
+ );
+});
+
+it("starts the earlier app after a failed update only if no file was replaced", () => {
+ order(
+ block('Section "Linger"', "SectionEnd"),
+ "Call RemoveLegacyInstall",
+ "StrCpy $Replacing 1",
+ 'RMDir /r "$INSTDIR\\resources"',
+ );
+ const failed = block("Function .onInstFailed", "FunctionEnd");
+ order(
+ failed,
+ "StrCmp $Updating 1 0 done",
+ "StrCmp $Replacing 1 rerun",
+ 'IfFileExists "$INSTDIR\\Linger.exe" 0 rerun',
+ "StrCmp $Relaunch 1 0 done",
+ "Exec '\"$INSTDIR\\Linger.exe\"'",
+ "rerun:",
+ "Run this setup again",
+ "$EXEPATH",
+ "done:",
+ );
});
diff --git a/docs/desktop-release.md b/docs/desktop-release.md
index 9049dc49..42e75c21 100644
--- a/docs/desktop-release.md
+++ b/docs/desktop-release.md
@@ -172,12 +172,23 @@ The app downloads the package from `releases/download/desktop-v<version>/` and
checks its size and SHA-256 while downloading. What happens next depends on
how Linger was installed:
-| Install | Update |
-| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| macOS `Linger.app` | The archive is unpacked beside the app. "Restart to Update" waits for running tasks, swaps the bundle and relaunches. |
-| Windows setup program | The setup program is downloaded. "Restart to Update" waits for running tasks, checks the file again, starts it with `/S /relaunch` and quits; the installer stops the services, replaces the app and starts it. |
-| Windows portable folder | No download: the tray offers "Download Linger <version>…", which opens the release page. |
-| Linux | The same as the portable folder. |
+| Install | Update |
+| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| macOS `Linger.app` | The archive is unpacked beside the app. "Restart to Update" waits for running tasks, swaps the bundle and relaunches. |
+| Windows setup program | The setup program is downloaded. "Restart to Update" waits for running tasks, checks the file again, starts it with `/update /relaunch` and quits; the installer stops the services, replaces the app in the folder it was installed to and starts it (details below). |
+| Windows portable folder | No download: the tray offers "Download Linger <version>…", which opens the release page. |
+| Linux | The same as the portable folder. |
+
+On Windows, `/update` runs the setup program in passive mode: it shows only its
+progress page, titled "Updating Linger to <version>...", and needs no click.
+It closes by itself when the files are in place, and `/relaunch` starts the new
+Linger. If a file stays locked, the same "Linger is running ... Retry" question
+as in a normal install appears, and Retry stops Linger's services again. After
+Cancel, or a file the setup could not write, the setup says Linger was not
+updated: if it had not replaced any file yet it starts the earlier Linger,
+which offers the update again; otherwise it names the setup program to run
+again. The install stays per user without administrator rights. `/S` still
+installs with no window at all, for scripted installs.
A system notification announces each new version once, and the tray shows the
state; after a failure "Try Updating Again" checks at once. The account menu