Skip to content

The agent that grows with you

fix(desktop): release Windows app locks at staged promotion

Tekniumf17f18cd11e0
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 3d281d69929..05386391ffc 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -207,6 +207,10 @@ def _swap_staged_desktop_app(desktop_dir: Path, staging_dir: Path) -> Optional[P
shutil.rmtree(previous, ignore_errors=True)
moved_aside = live_root.exists()
if moved_aside:
+ # A Desktop may have reopened during the long packaging step.
+ stopped = _stop_desktop_processes_locking_build(desktop_dir)
+ if stopped:
+ logger.info("stopped desktop processes before staged app promotion: %s", stopped)
os.rename(live_root, previous)
try:
os.rename(staged_root, live_root)
@@ -669,11 +673,15 @@ def _stop_desktop_processes_locking_build(desktop_dir: Path) -> list[int]:
# Wait for the handles (and thus the file locks) to actually release.
with contextlib.suppress(Exception):
_, alive = psutil.wait_procs(victims, timeout=5)
+ killed = []
for proc in alive:
try:
proc.kill()
+ killed.append(proc)
except Exception:
continue
+ if killed:
+ psutil.wait_procs(killed, timeout=5)
return stopped
diff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.md
index d70ca052859..72f290d4918 100644
--- a/website/docs/getting-started/updating.md
+++ b/website/docs/getting-started/updating.md
@@ -46,6 +46,8 @@ When you run `hermes update`, the following steps occur:
If the maintained updater script is missing (for example after antivirus quarantine), the legacy update forwarder fails instead of reporting a successful hand-off. Repair the installation and review the security software's quarantine report before retrying; do not disable antivirus protection. Before reporting success, the maintained updater checks the CLI import, Windows executable header, ASAR header and packaged main entry, readable renderer HTML with a local module entry, initial module files, and current build stamp. These are minimum artifact checks, not a full dependency audit or an application/backend launch test. Missing Python is reported before waiting for Desktop shutdown; dependency repair is still allowed to run as part of the update. Electron checks maintained handoff prerequisites before stopping backends when that layout is present; genuine legacy-flat updater layouts remain supported, so not every missing updater file is detected before backend shutdown.
+On Windows, a Desktop reopened during packaging is stopped again immediately before the staged build is promoted. This cleanup is restricted to executables inside that checkout's Desktop release tree; unrelated installations are not stopped. A remaining lock still makes staged promotion fail rather than bypassing the rename error.
+
### Updating against a non-default branch: `--branch`
By default `hermes update` tracks `origin/main`. Pass `--branch <name>` to update against a different branch — useful for QA channels, feature branches, or release-candidate testing: