MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / boot

Function boot

apps/desktop/src/main/index.ts:1200–1310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1198};
1199
1200const boot = async () => {
1201 installDockIcon();
1202 installApplicationMenu();
1203 await showStartupWindow();
1204 setupAutoUpdater();
1205 applyFakeUpdateFromEnv();
1206 registerIpcHandlers();
1207 // A sidecar that dies under a live window would leave the web UI failing
1208 // every request with no explanation. Swap in the crash screen — its
1209 // buttons drive the regular preload bridge (restart / export diagnostics).
1210 onUnexpectedSidecarExit((notice) => {
1211 // An expected shutdown (an interrupt aimed at the app) still leaves the web
1212 // UI dead, so the screen is the same — it just must not claim a crash
1213 // report was sent when none was.
1214 showCrashScreen(liveMainWindow(), { reported: notice.reported });
1215 // A crashing sidecar may be a broken release — quietly stage any
1216 // available update so the install prompt appears on its own (same
1217 // self-heal as the fatal startup path).
1218 void runUpdateCheck({ alertOnFail: false, trigger: "boot" });
1219 });
1220 // Prefer an OS-supervised daemon: attach to one that's running, kick one
1221 // that's installed, or offer to install on first run. Quitting the app then
1222 // leaves MCP serving. This is also the clean handoff that replaces the old
1223 // "another server owns the data dir → fatal error" path. Packaged builds only;
1224 // dev and unsupported platforms keep managed-spawn.
1225 if (app.isPackaged) {
1226 const supervised = await ensureSupervisedConnection();
1227 if (supervised) {
1228 connection = supervised;
1229 // createWindow installs the bearer-auth header itself.
1230 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: supervised attach can race with daemon shutdown; fall back to managed spawn
1231 try {
1232 await createWindow(supervised);
1233 armSupervisedMonitor();
1234 void runUpdateCheck({ alertOnFail: false, trigger: "boot" });
1235 return;
1236 } catch (error) {
1237 log.warn("Failed to load supervised daemon; falling back to managed sidecar", error);
1238 stopSupervisedMonitor();
1239 connection = null;
1240 }
1241 }
1242 }
1243 connection = await startWithCurrentSettings();
1244 if (!connection && lastSidecarStartError != null) {
1245 // Port conflicts already showed their dialog inside
1246 // startWithCurrentSettings; every other failure surfaces here so the app
1247 // never silently bounces-and-vanishes. The dialog offers a data reset
1248 // (move-aside, for damaged state) — when taken, retry the boot once
1249 // against the fresh dir.
1250 const retryAfterReset = await handleFatalSidecarFailure(lastSidecarStartError);
1251 if (retryAfterReset) {
1252 lastSidecarStartError = null;
1253 connection = await startWithCurrentSettings();
1254 if (!connection && lastSidecarStartError != null) {
1255 await handleFatalSidecarFailure(lastSidecarStartError);
1256 }
1257 }

Callers 1

claimAndBootFunction · 0.85

Calls 15

onUnexpectedSidecarExitFunction · 0.90
installDockIconFunction · 0.85
installApplicationMenuFunction · 0.85
showStartupWindowFunction · 0.85
setupAutoUpdaterFunction · 0.85
applyFakeUpdateFromEnvFunction · 0.85
registerIpcHandlersFunction · 0.85
showCrashScreenFunction · 0.85
liveMainWindowFunction · 0.85
runUpdateCheckFunction · 0.85
createWindowFunction · 0.85

Tested by

no test coverage detected