Skip to content

fix(desktop): wait out a held engine lock in the launch and setup installs - #1105

Merged
sosidudku1 merged 1 commit into
rel/xp-buildfrom
fix/engine-install-waits-for-lock
Nov 9, 2026
Merged

sosidudku1 merged 1 commit into
rel/xp-buildfrom
fix/engine-install-waits-for-lock

Conversation

@sosidudku1

Copy link
Copy Markdown
Collaborator

What

At launch, a profile on Atomic Core with no engine installed yet could show a red "Download failed · Local engine · Another engine operation is running" card a few seconds after the window opened. It stayed until someone pressed Retry, and the model did not start.

Now the install the app runs by itself (the launch's and the setup's) tries again every 3 seconds while the engine lock is held, for up to 5 minutes. A real failure, a stop, or the end of the wait are returned as before. The install from Settings still says at once that the engine is taken.

Why

models update never waits for the engine lock (installCoreBackend, waitMs: 0). That is the right answer for someone who asked for it, and it stays as it is. At launch nobody asked: the Studio shell's load-time refreshDirs reaches ensureStudioCore, which takes the same lock and starts Core, downloading it first when there is no copy on disk. The launch install then lost that race.

The race is widest on a build with no bundled Core. In a packaged app it is narrower, and it needs a managed local route with the model on disk and no backend (a migrated config, a removed backend).

Agent code in src/ is not touched.

How it was verified

  • Reproduced twice out of twice on a real run before the fix, on a throwaway profile with no core/ folder. agent.log carried the refusal, and one Retry cleared it.
  • New unit tests in desktop/test/engine-busy-retry.test.mjs: retry until success, a real failure returned at once, the wait limit, a stop during the wait. One test reads the refusals from core-operation.ts, so a rewording there fails it. One test pins which installs wait.
  • An adversarial read of the diff for deadlocks with the daemon's turn, the abort path, per-attempt analytics and pinned tests found no defect.
  • Not yet checked on the second Mac: build, lint, unit tests and the live launch still have to run there. This is why the PR is a draft.

Left out

  • refreshDirs still starts Core on every window load, also for people on a cloud route who never open Studio.
  • A refused models update still tries to retire an idle Core, so a retry can close the Core Studio just started. The next call starts it again.
  • A wait past 5 minutes ends in the same red card, and its Retry takes the Settings path.

…talls

models update never waits for the engine operation lock. At launch the
Studio shell's first call can hold it while starting or installing Core,
so the launch install failed within seconds and left a red Download
failed card until Retry, with the model not started.

The launch's and the setup's install now retry while the refusal is the
lock, for up to five minutes. Settings still answers at once.
@sosidudku1
sosidudku1 merged commit a5b3dd7 into rel/xp-build Nov 9, 2026
2 checks passed
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