Skip to content

fix: preserve Gateway when setup Reinstall is cancelled - #130617

Merged
steipete merged 1 commit into
mainfrom
codex/setup-preserve-service-reinstall
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/setup-preserve-service-reinstall

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

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.

Observation Baseline Patched
Before cancellation Gateway HTTP health live, LaunchAgent running Gateway HTTP health live, LaunchAgent running
At runtime chooser Existing LaunchAgent already moved to Trash Existing LaunchAgent retained
After Ctrl-C Exit 1; service absent; health connection refused Exit 1; identical PID and plist SHA-256; health still live
Completed Reinstall Not required for failing reproduction Real installer succeeds; replacement PID running; HTTP health live

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 skipHealth modes.

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, including openclaw/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.

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.
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 02:44
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:52 PM ET / August 27, 2026, 02:52 UTC.

ClawSweeper review

What this changes

This PR preserves an installed Gateway through Reinstall cancellation or preparation failure, then lets the platform service installer perform a successful replacement.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: 5065403cdab6de3646d4627d666fea03d3cb4ab6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused root-cause repair with targeted regression coverage and documented live macOS evidence; exact-head CI remains the normal landing gate.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this is a maintainer-authored PR; its body nevertheless documents an isolated macOS after-fix cancellation and replacement run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this is a maintainer-authored PR; its body nevertheless documents an isolated macOS after-fix cancellation and replacement run.
Evidence reviewed 7 items Current-main defect: configure: Current main uninstalls a loaded Gateway before the runtime selector and install preparation, so cancellation or preparation failure can leave no service.
Current-main defect: onboarding: Classic onboarding has the same pre-uninstall flow and uses a later service-status read to infer whether installation should occur.
Patch owner boundary: The proposed configure path retains the existing service during selection and planning, then calls the existing install owner only after preparation succeeds.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw -- --help

Result: FAIL (failed) — step 1 run pnpm openclaw -- --help: previous terminal command was still running after 30 seconds: "pnpm openclaw -- --help"

$ node scripts/run-node.mjs -- --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 110.69 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 15.0s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4425ms (slowest: built plugin control-plane loads 3659ms)
 •●●:.        .:●●•
:●●●●:        :●●●●:
.●●●●:.:•●●•:.:●●●●.
 .●●●: •●●●●• :●●●.    █▀▀▀█ █▀▀▀█ █▀▀▀▀ █▄  █ █▀▀▀▀ █     █▀▀▀█ █   █
 ..:••●●●●●●●●••:..    █   █ █▀▀▀▀ █▀▀▀  █ ▀▄█ █     █     █▀▀▀█ █▄▀▄█
.::••••●●●●●●••••::.   ▀▀▀▀▀ ▀     ▀▀▀▀▀ ▀   ▀ ▀▀▀▀▀ ▀▀▀▀▀ ▀   ▀ ▀   ▀
 . .:  •●●●●•  :. .
    .  :●●●●:  .
      .●●●●●●.
       :••••:

┌  Hi — I'm OpenClaw. I keep this system running. Let's get you set up.
│
◇  Setup choices ───────────────────────────────────────────────────────╮
│                                                                       │
│  For the full step-by-step wizard, run ˋopenclaw onbo
… output truncated …

Assertions:

  • FAIL expect_output: Usage:

How this fits together

Configure 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]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and hosted checks are still in progress, so landing needs an exact-head merge and CI refresh.
  • Complete next step (P2) - The protected maintainer label and pending exact-head CI require normal maintainer landing review; no repair task is identified.
Agent review details

Security

None.

PR surface

Source -26, Tests +158, Docs +1. Total +133 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 34 60 -26
Tests 2 171 13 +158
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 206 73 +133

Review metrics

Metric Value Why it matters
Production versus regression coverage production +34/-60 (net -26); tests +171/-13 (net +158); docs +1 The lifecycle repair reduces production code while adding focused coverage for the cancellation and preparation-failure regressions.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the two caller-level ordering repairs after exact-head checks confirm the current merge result; retain platform installers as the sole cutover owners.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label changes:

  • add P1: Cancelling or failing Gateway setup can take an already working Gateway service offline for affected operators.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is a maintainer-authored PR; its body nevertheless documents an isolated macOS after-fix cancellation and replacement run.

Label justifications:

  • P1: Cancelling or failing Gateway setup can take an already working Gateway service offline for affected operators.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is a maintainer-authored PR; its body nevertheless documents an isolated macOS after-fix cancellation and replacement run.

Evidence

What I checked:

  • Current-main defect: configure: Current main uninstalls a loaded Gateway before the runtime selector and install preparation, so cancellation or preparation failure can leave no service. (src/commands/configure.daemon.ts:74, adbb09d66107)
  • Current-main defect: onboarding: Classic onboarding has the same pre-uninstall flow and uses a later service-status read to infer whether installation should occur. (src/wizard/setup.finalize.ts:390, adbb09d66107)
  • Patch owner boundary: The proposed configure path retains the existing service during selection and planning, then calls the existing install owner only after preparation succeeds. (src/commands/configure.daemon.ts:76, 5065403cdab6)
  • Platform replacement owner: The service registry routes installation to launchd, systemd, or Windows Scheduled Task backends; launchd installation snapshots prior artifacts and supervision before activation. (src/daemon/service.ts:356, 5065403cdab6)
  • Focused regression coverage: The changed tests cover cancelled runtime selection, preparation failure, preservation through onboarding failure, explicit Skip/Restart behavior, and failed-replacement reporting. (src/wizard/setup.finalize.test.ts:1115, 5065403cdab6)
  • Area provenance: History shows Peter Steinberger as the dominant contributor across the configure, onboarding, and launchd service surfaces; the exact original unsafe line predates available local history. (src/wizard/setup.finalize.ts:425, 3d841472bd0e)

Likely related people:

  • steipete: History across the central configure, onboarding, and service-installation files is dominated by Peter Steinberger, who also authored the related merged runtime and service work. (role: dominant recent contributor; confidence: high; commits: 5065403cdab6, 6a6635abb3b5, 3d841472bd0e; files: src/commands/configure.daemon.ts, src/wizard/setup.finalize.ts, src/daemon/launchd-install.ts)
  • Vincent Koc: Recent history includes onboarding maintenance on the same wizard finalization surface. (role: recent adjacent contributor; confidence: medium; commits: beda1e97c620; files: src/wizard/setup.finalize.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the current-head merge and CI result before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the latest review and its rank-up move: CI run 33034230213 is now successful on the unchanged head 5065403cdab6de3646d4627d666fea03d3cb4ab6, including openclaw/ci-gate. Live mergeability is clear. Main has advanced, but the affected setup owners are unchanged; no rebase-only churn is needed. Native maintainer prepare/merge gates remain authoritative.

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 node openclaw.mjs --help run both pass; the latter exits 0 with Usage:. More importantly, the PR includes the real isolated macOS Reinstall/cancel before-and-after test, successful replacement, 237 focused passing tests, and the complete passing local changed-file gate. The extra Testbox sync timeout is documented separately and is not counted as proof.

@steipete
steipete merged commit 682ddcb into main Aug 27, 2026
292 checks passed
@steipete
steipete deleted the codex/setup-preserve-service-reinstall branch August 27, 2026 03:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Reinstall removes the working Gateway before cancellation or install preflight

1 participant