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

Function startWithCurrentSettings

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

Source from the content-addressed store, hash-verified

529};
530
531const startWithCurrentSettings = async (): Promise<SidecarConnection | null> => {
532 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: bind failures surface as a user-facing dialog
533 try {
534 return await startSidecar();
535 } catch (error) {
536 // oxlint-disable-next-line executor/no-instanceof-tagged-error -- boundary: SidecarPortInUseError is a plain Node Error subclass, not an Effect tagged error
537 if (error instanceof SidecarPortInUseError) {
538 await showPortInUseDialog(error.port);
539 return null;
540 }
541 // The data dir is already owned by another local daemon. If it's a healthy
542 // cli-daemon, adopt it instead of failing — the same handoff boot() does up
543 // front, applied here so the fallback and restart paths recover from a
544 // mid-session daemon takeover. Poll briefly to ride out an owner that's
545 // alive but still finishing its own startup (the health-probe vs.
546 // scope-lock race that left the app wedged on the crash screen).
547 if (isScopeOwnershipConflict(error)) {
548 const adopted = await waitForSupervisedAttach(10_000);
549 if (adopted) {
550 log.info(
551 "Adopted the local daemon that owns the data dir instead of spawning a second one",
552 );
553 return adopted;
554 }
555 }
556 lastSidecarStartError = error;
557 log.error("Failed to start executor sidecar", error);
558 return null;
559 }
560};
561
562const restartSidecarAndReload = async (): Promise<DesktopServerConnection> => {
563 // A supervised daemon owns its own process lifetime. Re-installing the unit

Callers 2

restartSidecarAndReloadFunction · 0.85
bootFunction · 0.85

Calls 6

startSidecarFunction · 0.90
showPortInUseDialogFunction · 0.85
isScopeOwnershipConflictFunction · 0.85
waitForSupervisedAttachFunction · 0.85
errorMethod · 0.80
infoMethod · 0.65

Tested by

no test coverage detected