fix(dashboard): start the engine on project creation so it isn't reported unavailable

POST /api/projects registered a project but only started its engine lazily on the first scoped
store access, so a freshly-created project — especially the operator's FIRST project on the
desktop, where no other engine is running — left engineManager with no running engine. The
dashboard's project view then showed "AI engine is not running" (EngineUnavailableBanner keys off
/api/health engine.available). Proactively warm the engine via getOrCreateProjectStore (fires the
onProjectFirstAccessed hook -> engineManager.onProjectAccessed -> ensureEngine) right after the
project is activated, fire-and-forget so it never blocks/fails the registration response.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-07-02 21:53:05 -07:00
parent 0c43ed42cf
commit c976d75d8d

View File

@@ -426,6 +426,19 @@ export const registerProjectRoutes: ApiRouteRegistrar = (ctx) => {
return { activeProject, outcome: ensured.outcome };
});
/*
* FNXC:Onboarding 2026-07-03-05:40:
* Proactively warm the new project's engine on creation. getOrCreateProjectStore fires the
* onProjectFirstAccessed hook (engineManager.onProjectAccessed -> ensureEngine), so the
* project's engine starts immediately instead of waiting for the first lazy store access.
* Without this, a freshly-created project (especially the operator's FIRST project on the
* desktop, where no other engine is running) leaves engineManager with no running engine, so
* /api/health reports engine.available=false and the dashboard shows "AI engine is not
* running" right after project creation. Fire-and-forget: engine startup is async and must not
* block or fail the registration response.
*/
void getOrCreateProjectStore(activeProjectWithOutcome.activeProject.id).catch(() => undefined);
// Bootstrap memory files (non-blocking, non-fatal)
ensureMemoryFileWithBackend(normalizedPath).catch(() => {
// Memory bootstrap failure is non-fatal - project registration succeeded