Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(windows): installer waits for the exiting app in --updated/silent runs
reviewe63bdd4a161f
diff --git a/build/installer.nsh b/build/installer.nshindex ee6e81e65..2905c8109 100644--- a/build/installer.nsh+++ b/build/installer.nsh@@ -1,22 +1,62 @@# Override BOTH install and uninstall checks. The stock check can kill processes under INSTDIR,# including the detached session host. A renamed hard link still holds the installed image open.+#+# Unattended runs (silent, or the app's own --updated handoff) WAIT for the app to finish exiting:+# the updater starts the installer while nodeterm.exe (main, GPU, renderer) is still shutting+# down, so a single probe would abort nearly every self-update. The wait is bounded (~30 s), it+# waits only on "running" (10) — "could not verify" (20) stays fatal at once — and it never kills+# anything. The probe keeps its machine-wide name match: an OLD uninstaller may kill by name.!macro customCheckAppRunningInitPluginsDirFile /oname=$PLUGINSDIR\nodeterm-update-preflight.ps1 "${PROJECT_DIR}\scripts\windows-update-preflight.ps1"+ StrCpy $R1 0nodeterm_preflight_retry:nsExec::Exec /TIMEOUT=15000 '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$PLUGINSDIR\nodeterm-update-preflight.ps1" -InstallDirectory "$INSTDIR"'Pop $R0${If} $R0 == 0Goto nodeterm_preflight_clear${EndIf}+ ${If} $R0 == 10+ ${If} ${isUpdated}+ ${OrIf} ${Silent}+ ${If} $R1 < 30+ IntOp $R1 $R1 + 1+ Sleep 1000+ Goto nodeterm_preflight_retry+ ${EndIf}+ ${EndIf}+ ${EndIf}# Silent installs must fail closed too, with a nonzero result and no default consent.SetErrorLevel 2- IfSilent nodeterm_preflight_cancel+ IfSilent nodeterm_preflight_unattended${If} $R0 == 10- MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "nodeterm or a process using its installation is running. Closing the app keeps sessions alive.$\r$\n$\r$\nCancel, open nodeterm, and run Prepare for update (Ctrl+K, or the update card): it waits for busy agents, exits idle agents cleanly, stops the session host and quits. Canvas nodes are kept.$\r$\n$\r$\nWith an older nodeterm: save work, exit agents and shells normally, quit nodeterm and wait at least 30 seconds. If the host remains, verify its user and executable path in Task Manager Details, then end only that host. All processes it owns will stop. Saved nodes remain; agent resume needs supported, saved conversation history and cannot recover unsaved work.$\r$\n$\r$\nOther installations/users must prepare their own sessions too. Retry from Downloads, outside the install directory. This installer will not stop your sessions for you." /SD IDCANCEL IDRETRY nodeterm_preflight_retry+ MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "nodeterm is still running. Quit nodeterm, including from the system tray (right-click the tray icon, then Quit), then Retry. Your sessions keep running in the background session host and reattach after the update.$\r$\n$\r$\nOnly if this message comes back after quitting: Cancel, open nodeterm, and run Prepare for update (Ctrl+K, or the update card). It waits for busy agents, exits idle agents cleanly, stops the session host and quits. Canvas nodes are kept.$\r$\n$\r$\nWith an older nodeterm: save work, exit agents and shells normally, quit nodeterm and wait at least 30 seconds. If the host remains, verify its user and executable path in Task Manager Details, then end only that host. All processes it owns will stop. Saved nodes remain; agent resume needs supported, saved conversation history and cannot recover unsaved work.$\r$\n$\r$\nOther installations/users must prepare their own sessions too. Retry from Downloads, outside the install directory. This installer will not stop your sessions for you." /SD IDCANCEL IDRETRY nodeterm_preflight_retry${Else}MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "nodeterm could not verify whether the app or its background session host is running. No sessions have been stopped.$\r$\n$\r$\nCancel and check that Windows PowerShell and process queries are available. If another Windows user is running nodeterm, ask them to save work, exit agents and shells normally, and quit nodeterm. If their host remains, its owner must verify and stop it in Task Manager before retrying; keep saved canvas nodes." /SD IDCANCEL IDRETRY nodeterm_preflight_retry${EndIf}+ Goto nodeterm_preflight_cancel+ nodeterm_preflight_unattended:+ !ifndef BUILD_UNINSTALLER+ # The app handed itself over to this installer and has quit (or is quitting). Nothing has+ # been changed yet — this check runs before the old version is uninstalled — so put the user+ # back where they were: record why, for the app to report on its next start, and start the+ # installed build again instead of leaving nothing running.+ ${If} ${isUpdated}+ ReadEnvStr $R2 LOCALAPPDATA+ ${If} $R2 != ""+ CreateDirectory "$R2\nodeterm"+ ClearErrors+ FileOpen $R3 "$R2\nodeterm\update-failed.json" w+ ${IfNot} ${Errors}+ FileWrite $R3 '{"reason":"preflight","code":$R0,"version":"${VERSION}"}'+ FileClose $R3+ ${EndIf}+ ${EndIf}+ ${If} ${FileExists} "$INSTDIR\${APP_EXECUTABLE_FILENAME}"+ Exec '"$INSTDIR\${APP_EXECUTABLE_FILENAME}"'+ ${EndIf}+ ${EndIf}+ !endifnodeterm_preflight_cancel:Quitnodeterm_preflight_clear:diff --git a/scripts/windows-update-preflight.test.ts b/scripts/windows-update-preflight.test.tsindex ddcf0dff8..ceedbabdc 100644--- a/scripts/windows-update-preflight.test.ts+++ b/scripts/windows-update-preflight.test.ts@@ -92,10 +92,46 @@ describe('NSIS safety wiring', () => {expect(fs.readFileSync(templates + 'uninstaller.nsh', 'utf8')).toContain('!insertmacro CHECK_APP_RUNNING')expect(include).toContain('"${PROJECT_DIR}\\scripts\\windows-update-preflight.ps1"')})+ // U6: an update the app hands itself over to (--updated) or any silent run starts while the+ // app's own processes are still exiting. It waits for them — bounded, on "running" only — and,+ // if they never leave, gives the user their app back instead of nothing.+ it('unattended runs wait a bounded time, and only on exit code 10', () => {+ const body = include.slice(include.indexOf('nodeterm_preflight_retry:'), include.indexOf('SetErrorLevel 2'))+ expect(body).toMatch(+ /\$\{If\} \$R0 == 10\s+\$\{If\} \$\{isUpdated\}\s+\$\{OrIf\} \$\{Silent\}\s+\$\{If\} \$R1 < 30\s+IntOp \$R1 \$R1 \+ 1\s+Sleep 1000\s+Goto nodeterm_preflight_retry/+ )+ expect(include).toMatch(/StrCpy \$R1 0\s+nodeterm_preflight_retry:/)+ // Exit 20 (could not verify) never loops.+ expect(body).not.toMatch(/\$R0 == 20/)+ expect(body.match(/Goto nodeterm_preflight_retry/g)).toHaveLength(1)+ })+ it('a timed-out --updated install records why and relaunches the installed app before quitting', () => {+ const unattended = include.slice(include.indexOf('nodeterm_preflight_unattended:'), include.indexOf('nodeterm_preflight_cancel:'))+ expect(unattended).toContain('!ifndef BUILD_UNINSTALLER')+ expect(unattended).toMatch(/\$\{If\} \$\{isUpdated\}/)+ expect(unattended).toContain('ReadEnvStr $R2 LOCALAPPDATA')+ expect(unattended).toContain('"$R2\\nodeterm\\update-failed.json"')+ const marker = unattended.indexOf('FileWrite')+ const exec = unattended.indexOf('Exec \'"$INSTDIR\\${APP_EXECUTABLE_FILENAME}"\'')+ expect(marker).toBeGreaterThan(0)+ expect(exec).toBeGreaterThan(marker)+ expect(include.indexOf('nodeterm_preflight_cancel:')).toBeGreaterThan(include.indexOf('nodeterm_preflight_unattended:'))+ })+ it('tells the user to quit from the tray first, and to Prepare only if still blocked', () => {+ const running = include.split('\n').find((l) => l.includes('MessageBox') && l.includes('nodeterm is still running'))+ expect(running).toBeDefined()+ const tray = running!.indexOf('system tray')+ const prepare = running!.indexOf('Prepare for update')+ expect(tray).toBeGreaterThan(0)+ expect(prepare).toBeGreaterThan(tray)+ expect(running).toMatch(/Only if this message comes back after quitting/)+ })it('only proceeds on proven clear; silent, error and cancellation paths quit nonzero', () => {expect(include).toMatch(/\$R0 == 0\s+Goto nodeterm_preflight_clear/)- expect(include).toMatch(/SetErrorLevel 2\s+IfSilent nodeterm_preflight_cancel/)+ expect(include).toMatch(/SetErrorLevel 2\s+IfSilent nodeterm_preflight_unattended/)expect(include).toMatch(/nodeterm_preflight_cancel:\s+Quit/)+ // The interactive branch must not fall into the unattended relaunch below it.+ expect(include).toMatch(/\$\{EndIf\}\s+Goto nodeterm_preflight_cancel\s+nodeterm_preflight_unattended:/)expect(include.match(/\/SD IDCANCEL/g)).toHaveLength(2)const production = include + fs.readFileSync(script, 'utf8')expect(production).not.toMatch(/\b(?:Stop-Process|taskkill|KILL_PROCESS|_CHECK_APP_RUNNING|Set-ExecutionPolicy)\b/i)