refactor(updater): simplify source upgrade handoff#571
Merged
Conversation
Stop the supervisor before Pro bundle installation to prevent backend restart races. Preserve the captured public WebUI endpoint across legacy upgrades and cover v2026.7.1/v2026.7.15 handoffs.
6 tasks
xiami762
force-pushed
the
refactor/simple-upgrade-handoff
branch
from
July 20, 2026 10:56
0c43e43 to
517059f
Compare
stephamie7
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR simplifies source upgrades around a detached handoff: the active process prepares and backs up a verified release, while the handoff exclusively stops services, replaces source, installs the new runtime, and restores the previous service state.
It also preserves compatibility with legacy handoff protocols and shares the core source-installation path with
flocks doctor.Key Changes
flocks/updater/updater.py)ServiceConfig, daemon PID, andwas_runningonce, then pass them to the detached handoff.flocks/updater/restart_handoff.py)install_or_repair_source()foruv sync --no-python-downloads, Pro installation, WebUI dependency installation/build, runtime validation, CLI refresh, and version markers.flocks doctorcall the same core installer; Windows uses a helper so the current CLI process releases executable locks first.flocks update, and Pro bundles containing core source through the same handoff.serverestarts to the current managedstartcommand.upgrade-state.jsonwhen old handoffs lost the WebUI PID record and fell back to port 5173.UnicodeDecodeErrorfailures.Impact Scope
uv syncattempt has a 300-second timeout. Source backups continue to consume storage according to the configured retention count.Business Logic to Review
.venv, dependency directories, alldistoutput, logs, configuration, and runtime data; replacement preserves runtime/configuration directories but deliberately rebuildswebui/dist.127.0.0.1,0.0.0.0, explicit addresses, IPv6, custom ports, legacy backend endpoints,no_browser, andskip_frontend_build.servepayloads readupgrade-state.json; modern capturedServiceConfigremains authoritative.Why This Approach
The updater must replace the source and dependencies used by the process that initiated the update. A detached handoff provides the minimum safe boundary for releasing Python, CLI, daemon, and Windows file locks. Keeping backup and release preparation in the active process makes preflight failures non-disruptive; keeping stop, replacement, installation, and restart in one handoff makes the irreversible sequence explicit and testable. Reusing one core installer avoids separate updater and doctor dependency/build implementations without invoking the destructive full bootstrap installer.
Test Plan
Relevant automated regression suite:
Result after the latest compatibility fixes: 235 passed, 1 deselected.
Broader updater, CLI lifecycle, API, and Pro coverage: 330 passed, 2 skipped.
Ruff checks passed for changed updater/handoff code.
git diff --checkpassed.Real default-address daemon/backend restart: both PIDs changed,
/api/healthreturned 200, and status was healthy.Real source handoff: backup, replacement, shared install, restart, health check, and temporary-state cleanup completed.
Custom localhost ports were preserved across handoff.
Explicit interface and wildcard-host scenarios preserved their frontend and legacy backend endpoints.
Windows 2026.7.15 upgrade completed dependency sync, WebUI build, daemon restart, backend restart, and health recovery.
Legacy handoff regression verifies that a WebUI endpoint such as port 8888 is restored instead of falling back to 5173.
Compatibility, Migration & Rollback
.venv, dependency caches, configuration, logs, and runtime data remain in place according to the existing preservation rules.