Skip to content

fix(desktop): restart a stuck background service from the error page - #57134

Open
neriousy wants to merge 5 commits into
devfrom
desktop-update-lock
Open

neriousy wants to merge 5 commits into
devfrom
desktop-update-lock

Conversation

@neriousy

@neriousy neriousy commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When the background service fails to boot (seen on Windows after an auto-update as SQLiteError: database is locked), it stays alive and registered in a failed state by design. Every later launch of the same Desktop version reuses it and shows "Background service failed to start" again, so the existing Restart button can't recover. Users currently have to kill opencode-cli.exe by hand.

This makes the error page's existing Restart button recover from it. For local server startup failures, Restart now stops the registered service before relaunching:

  • BackgroundService.stop in the main process calls Service.stop from the client with the same registration file ensure() uses. That stops the process and removes service.json.
  • The new AppRestartService RPC stops the service and then relaunches the app, so the next startup spawns a fresh service. If no service is registered, stopping does nothing and it just relaunches. If stopping fails, the app does not relaunch and the error is shown on the page.
  • Platform.restartService is optional. The error page uses it only when the platform provides it and the error is marked localServerStartup. Every other error keeps the plain relaunch, so a healthy shared service (for example one serving TUI clients) is never killed after a renderer crash. Web is unchanged.
  • The button is disabled while restarting. No layout or copy changes.

Persistent terminals are cleared, not handed off. A service that failed to boot can't hand them off, and opencode service restart behaves the same way.

This PR doesn't fix the root cause of the lock: journal_mode = WAL runs before busy_timeout is set, so it has a 0 ms busy wait. That will be a separate PR.

How did you verify your code works?

  • bun typecheck in packages/app and packages/desktop
  • bun test src in packages/desktop; bun test src/shell/errors in packages/app
  • Not yet exercised end to end in a packaged Desktop build with a stuck service

Screenshots / recordings

No visual change; the Restart button behaves differently for local server startup failures.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@neriousy neriousy changed the title feat(desktop): restart a stuck background service from the error page fix(desktop): restart a stuck background service from the error page Oct 19, 2026
Base automatically changed from beta to dev October 26, 2026 03:56
@neriousy
neriousy force-pushed the desktop-update-lock branch from 706f379 to 6928334 Compare November 4, 2026 16:22

This branch has not been deployed

No deployments
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.

1 participant