Skip to content

fix(desktop): retry controller startup after readiness failure#750

Merged
mrcfps merged 5 commits intomainfrom
fix/desktop-controller-readiness-retry
Apr 1, 2026
Merged

fix(desktop): retry controller startup after readiness failure#750
mrcfps merged 5 commits intomainfrom
fix/desktop-controller-readiness-retry

Conversation

@mrcfps
Copy link
Copy Markdown
Contributor

@mrcfps mrcfps commented Apr 1, 2026

What

Add controller post-start validation with a single bounded recovery retry, and gate real macOS launchd tests behind an explicit opt-in flag.

Why

Packaged desktop could fail to start when the controller exited or became unreachable right after launch, leaving the shell waiting on a dead readiness probe. Separately, the real launchd integration tests were capable of mutating live host launchd state unless they were run intentionally.

How

  • validate controller startup immediately after launchd start using launchd status, port reachability, and /api/internal/desktop/ready with fallback to /api/auth/get-session
  • if validation fails, boot out the controller once, choose the next free port, regenerate the controller plist, and retry exactly once with structured failure logging
  • add startup regression coverage for exit/unreachable/retry-success/retry-failure scenarios
  • require RUN_REAL_LAUNCHD_TESTS=1 before executing real launchd desktop integration tests

Affected areas

  • Desktop app (Electron shell)
  • Controller (backend / API)
  • Web dashboard (React UI)
  • OpenClaw runtime
  • Skills
  • Shared schemas / packages
  • Build / CI / Tooling

Checklist

  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes
  • pnpm generate-types run (if API routes/schemas changed)
  • No credentials or tokens in code or logs
  • No any types introduced (use unknown with narrowing)

Notes for reviewers

The main behavior change is in apps/desktop/main/services/launchd-bootstrap.ts, specifically the new controller post-start validation and one-time retry path. The real launchd tests are still available, but now require RUN_REAL_LAUNCHD_TESTS=1 to avoid accidental host-state mutation during routine runs.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 860914304f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/main/services/launchd-bootstrap.ts Outdated
Comment thread apps/desktop/main/services/launchd-bootstrap.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4f8015ebf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/main/services/launchd-bootstrap.ts Outdated
Comment thread apps/desktop/main/services/launchd-bootstrap.ts Outdated
@mrcfps mrcfps merged commit d837304 into main Apr 1, 2026
11 checks passed
@mrcfps mrcfps deleted the fix/desktop-controller-readiness-retry branch April 1, 2026 16:43
This was referenced Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants