#8260: fix(macOS): gateway readiness detection + reversible Configure later
app: macos
commands
stale
Cluster:
Gateway and macOS Improvements
## Summary
Fixes #6156
- **Early bailout on startup failure**: `waitForGatewayReady()` now checks `GatewayProcessManager.status` each poll iteration — if the gateway startup already failed (e.g. CLI not found), it returns immediately instead of wasting the full timeout.
- **Surface actual failure reason**: The onboarding wizard now shows the real error (e.g. "openclaw CLI not found. Install it (npm i -g openclaw) or add it to your PATH.") instead of the generic "Gateway did not become ready."
- **Reversible "Configure later"**: A "Run Setup…" button now appears in the menu bar when `connectionMode == .unconfigured`, calling the existing `DebugActions.restartOnboarding()`.
- **CLI IPv6 fallback**: `probeGatewayReachable()` retries with `[::1]` when `127.0.0.1` fails (uses the correct WebSocket protocol via `callGateway`).
## Root Cause
`setActive(true)` fires `enableLaunchdGateway()` in a background Task. When the `openclaw` CLI isn't found, that method fails immediately and sets `status = .failed(reason)`. But `waitForGatewayReady()` never checked for this — it kept polling the WebSocket health endpoint for the full 12-second timeout, then threw a generic error that hid the actual cause.
## Files Changed
| File | Change |
|------|--------|
| `GatewayProcessManager.swift` | +2 lines: early bailout when `status == .failed` |
| `OnboardingWizard.swift` | Surface actual failure reason from process manager status |
| `GatewayEnvironment.swift` | Better error message suggesting `npm i -g openclaw` |
| `MenuContentView.swift` | "Run Setup…" button when unconfigured |
| `onboard-helpers.ts` | IPv6 loopback fallback in CLI gateway probe |
| `onboarding.ts` | Use `resolvedUrl` from probe result |
| `CHANGELOG.md` | Changelog entries |
## Testing Done
- Built macOS app locally via `scripts/package-mac-app.sh` (ad-hoc signed)
- Launched app without `openclaw` CLI globally installed — confirmed the error now surfaces the actual reason ("openclaw CLI not found") immediately instead of polling for 12 seconds and showing a generic message
- Verified the "Run Setup…" button appears in the menu bar when connection mode is unconfigured
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR improves macOS onboarding and gateway startup UX by (1) bailing out of `waitForGatewayReady()` immediately if the gateway process is already in a `.failed` state, (2) surfacing the underlying failure reason in the onboarding wizard instead of a generic timeout message, (3) adding a reversible “Run Setup…” menu bar action when the app is unconfigured, and (4) improving the CLI onboarding probe by retrying loopback connectivity via IPv6 (`[::1]`) and threading through a `resolvedUrl`.
The changes fit into the existing architecture by reusing `GatewayProcessManager.status` as the single source of truth for startup failure state on macOS, and by keeping the gateway health check logic centralized in `probeGatewayReachable()`/`callGateway()` for the CLI wizard.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge; the changes are localized and mostly improve error reporting and readiness detection.
- Mac app changes are small and leverage existing state (`GatewayProcessManager.status`) without changing startup mechanics. The main risk area is the new IPv6 fallback URL rewrite in the CLI probe, which currently uses substring matching and string replacement and could mis-handle edge-case URLs.
- src/commands/onboard-helpers.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#11455: fix(gateway): default gateway.mode to local when unset
by AnonO6 · 2026-02-07
82.7%
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
82.1%
#18236: macOS daemon: bootstrap LaunchAgent on gateway start after stop
by agisilaos · 2026-02-16
82.0%
#2530: fix(gateway): improve auth error for native apps
by Episkey-G · 2026-01-27
81.5%
#15306: fix: explicit exit after onboarding command completes
by jeroenbaas · 2026-02-13
80.8%
#12234: gateway: incident tracking, recover command, and ciao ERR_SERVER_CL...
by levineam · 2026-02-09
79.5%
#17835: Fix misleading gateway stop hints for standalone listeners
by ConnorCallison · 2026-02-16
79.3%
#13084: fix(daemon): multi-layer defense against zombie gateway processes
by openperf · 2026-02-10
78.4%
#18438: macOS: add in-app CLI + gateway install with reset support
by rimusz · 2026-02-16
78.3%
#5823: fix(config): exit cleanly on invalid config instead of high CPU loop
by gavinbmoore · 2026-02-01
78.1%