Commit Graph
2 Commits
Author SHA1 Message Date
rouggy 8d01097ca8 fix(update): put back the two things the PowerShell helper did
Operators are still losing the relaunch, so I went and read the code
from before 0430aab — the commit that removed the helper — instead of
theorising again. It was:

  Wait-Process -Id <pid>; Start-Sleep -Milliseconds 400;
  Start-Process -FilePath <exe> -ArgumentList '--post-update'

Two things in there that the direct launch never had:

1. Start-Process made the new OpsLog a child of PowerShell, which then
   exited — so it was detached. The direct launch makes it a child of
   the instance that is dying, in the same process group and console.
   DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP puts it back on its own,
   so nothing aimed at the old process can reach the new one.

2. It slept 400 ms AFTER the old process was gone, before starting
   anything. A process's handles are released by the kernel as it dies,
   so the mutex is free the moment the wait returns — but the things
   around it are not on that clock: the WebView2 user-data lock, the log
   file, an antivirus that woke up when the exe was replaced. This is
   not a theory about which of those it was; it is the pause being put
   back where it was.

Not restored: the PowerShell itself. Defender removed 0.27.14 from a
station as Trojan:Script/Wacatac.H!ml, and "Script/" was that helper —
an unsigned binary replacing itself and spawning a windowless script to
start another executable is, byte for byte, a dropper. Bringing it back
trades this fault for one that deletes the program.

Also: the relaunch now logs the child's pid, which the new instance's
startup.log already records on the other side. Without the pair there is
no telling "the new instance never started" from "it started and gave up
waiting", and those have different causes.
2026-09-11 08:02:12 +02:00
rouggy a8e870e098 fix(update): the relaunched OpsLog was starting invisibly
The relaunch after an update called hideConsole on the command that
starts the new build. That sets SysProcAttr{HideWindow: true}, which on
Windows becomes SW_HIDE in the STARTUPINFO handed to CreateProcess — and
Windows applies it to the first top-level window the new process shows.
So the updated OpsLog started correctly, took the single-instance mutex,
opened the logbook and connected the rig, and never appeared.

That is the report, in full: a process in the task manager, no window,
no autostart programs, and ending it then launching OpsLog by hand
working every time. Two operators, both on 0.27.23.

Why 0.27.19 did not fix it: that commit fixed the other half of the same
symptom — the new instance being less patient than the old one is slow —
which was real and is still fixed. The window was never part of it.

Where it came from: removing the PowerShell helper. Start-Process
launched the exe with a normal show; the direct exec.Command that
replaced it borrowed hideConsole from the console tools next to it,
where hiding a console window is exactly right and where the three
remaining callers (tasklist, taskkill, the deferred-swap PowerShell)
still belong.

The proof it was this and not the waiting: OpsLog relaunches itself in
two places, and RestartApp — the database switch — was byte-identical
except that it never called hideConsole. It has never been reported
broken. Both now go through relaunchCmd, so the rule lives in one place
with the reason written down, rather than in two call sites that differed
by one line.

Two tests: relaunchCmd leaves SysProcAttr nil, and update.go does not
call hideConsole at all.
2026-09-10 15:40:02 +02:00