Repository navigation
fix: preserve Gateway when setup Reinstall is cancelled - #130617
Conversation
Keep replacement preparation ahead of service mutation in configure and onboarding. Let platform installers own replacement, and report surviving Gateway reachability independently of failed setup.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:52 PM ET / August 27, 2026, 02:52 UTC. ClawSweeper reviewWhat this changesThis PR preserves an installed Gateway through Reinstall cancellation or preparation failure, then lets the platform service installer perform a successful replacement. Merge readinessKeep open. Current main still uninstalls the service before replacement preparation; this PR removes that ordering in both setup paths and delegates cutover to the platform installer. No blocking patch defect was found, but the protected maintainer label and pending exact-head CI keep landing under maintainer review. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherConfigure and onboarding decide whether to reuse, restart, or replace the local Gateway service. They prepare runtime and authentication details before calling the platform-specific service installer, which activates the replacement service. flowchart LR
A[Configure or onboarding] --> B[Existing Gateway detected]
B --> C[Reinstall selected]
C --> D[Runtime and auth preparation]
D -->|Cancelled or failed| E[Existing Gateway remains]
D -->|Prepared| F[Platform service installer]
F --> G[Replacement Gateway service]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -26, Tests +158, Docs +1. Total +133 across 8 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the two caller-level ordering repairs after exact-head checks confirm the current merge result; retain platform installers as the sole cutover owners. Do we have a high-confidence way to reproduce the issue? Yes. Current main visibly uninstalls before runtime selection and preparation in both callers, and the PR body supplies an isolated macOS command path for the cancellation case. Is this the best way to solve the issue? Yes. Removing premature caller-side lifecycle mutation and delegating successful replacement to the existing platform installer is the narrow owner-boundary repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against adbb09d66107. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Addressed the latest review and its rank-up move: CI run 33034230213 is now successful on the unchanged head Maintainer review is complete: the caller-side deletion is the root cause, the existing platform installers remain the replacement owners, and the independent review's surviving-Gateway reporting finding was repaired and rechecked. No actionable patch or security findings remain. The bot's timed-out help probe entered interactive setup and did not exercise the Reinstall scenario. The completed CLI startup build and a direct |
|
Merged via squash.
|
Closes #130602
What Problem This Solves
Fixes an issue where users choosing Reinstall in Gateway setup would lose their working Gateway when they cancelled the runtime chooser or replacement preparation failed. The old service was removed before setup knew whether it could install a replacement.
Why This Change Was Made
Configure and onboarding now prepare the replacement while leaving the existing service intact, then hand replacement to the platform installer—the same owner used by
gateway install --force. Onboarding follows the selected action directly instead of treating a later service-status change as permission to install after Skip or Restart. Obsolete uninstall progress strings are removed from all three locales.A failed replacement and Gateway reachability remain separate facts: one lightweight probe can discover the preserved Gateway and bind the TUI to it, while the outro still reports that replacement failed. Failed installation does not incur the 15-second startup wait.
Best-fix judgment: repair setup's premature lifecycle mutation, not a downstream cancellation guard or another rollback implementation. The launchd installer already snapshots/restores the prior definition and supervision. Systemd and Windows also own replacement, but this PR does not claim universal transactional rollback or change those platform backends.
Provenance: premature uninstall is present in stable
v2026.7.1-2; its introduction predates the available shallow history. The cancellation window became directly reachable again when #129593 restored the runtime chooser (authored and merged by @steipete). #120699 added launchd replacement rollback that setup's pre-uninstall bypassed. This is an AI-assisted maintainer fix by @steipete.User Impact
Cancelling Reinstall or failing authentication/planning no longer removes the existing Gateway. Successful replacement still uses the platform's canonical installer. Explicit Skip/Restart does not silently authorize an installation. No new flags, configuration keys, defaults, migrations, dependencies, or storage changes.
Release-note context: preserve the installed Gateway when setup Reinstall is cancelled or blocked, and distinguish replacement failure from the surviving Gateway's reachability.
Evidence
Baseline:
18c801daa1165f0bb7f30576b52f6642ff023233, macOS, Node 26.7.0. Live proof used a fresh named profile, isolated loopback port, no provider credentials or requests, and disabled plugins; the operator's Gateway was untouched.Real CLI path:
openclaw --profile <isolated-profile> configure --section daemon, Local → existing port → Reinstall → cancel at runtime selection.Regression proof: final configure fixture fails on the original uninstall path in four preservation cases, including cancellation using the real Clack cancellation sentinel. Original onboarding owner fails five preservation/action cases. The additional surviving-Gateway reporting cases fail before the reporting repair in both
skipHealthmodes.Focused results: configure 10 tests passed; onboarding finalizer 58 passed; launchd 164 passed (including exact prior plist/environment/wrapper and supervision restoration); daemon CLI install integration 5 passed. These are local tests, not live Linux/Windows service proof. Live macOS cancellation and successful replacement are recorded separately above.
Production delta: +34/-60, net -26. Tests: +171/-13, net +158. Documentation: +1. No generated or lockfile changes.
Final CLI startup build passed (including 48 built-module import checks). The complete local changed-file gate passed: formatting, production/test typechecks, lint, dead-code scan, and architecture/schema/auth guards. Fresh Codex autoreview reported no actionable P0 findings; separate full-severity independent review identified the surviving-Gateway reporting issue, which was fixed and rechecked. The isolated test service was uninstalled and its profile/logs moved to Trash; its port and launchd registration are gone.
Exact-head hosted CI run 33034230213 passed on
5065403cdab6de3646d4627d666fea03d3cb4ab6, includingopenclaw/ci-gate, without a rerun.An extra Blacksmith Testbox changed-gate attempt (run,
tbx_01m10hd7z97nkn508z5fem8zr1) timed out during synchronization and returned no validation result; its lease was stopped. This is not counted as passing proof. The local changed gate and the PR's exact-head CI are separate runs.Named follow-up: configure's immediate post-install WebSocket probe can report connection refused during startup, despite the replacement becoming HTTP-healthy shortly afterward. This pre-existing readiness timing issue is outside this service-preservation repair; the live proof does not claim an immediate authenticated WebSocket handoff or live Windows/Linux activation coverage.