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

Function startWithCurrentSettings

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

Source from the content-addressed store, hash-verified

643};
644
645const startWithCurrentSettings = async (): Promise<SidecarConnection | null> => {
646 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: bind failures surface as a user-facing dialog
647 try {
648 return await startSidecar();
649 } catch (error) {
650 // oxlint-disable-next-line executor/no-instanceof-tagged-error -- boundary: SidecarPortInUseError is a plain Node Error subclass, not an Effect tagged error
651 if (error instanceof SidecarPortInUseError) {
652 await showPortInUseDialog(error.port);
653 return null;
654 }
655 // The data dir is already owned by another local daemon. If it's a healthy
656 // cli-daemon, adopt it instead of failing — the same handoff boot() does up
657 // front, applied here so the fallback and restart paths recover from a
658 // mid-session daemon takeover. Poll briefly to ride out an owner that's
659 // alive but still finishing its own startup (the health-probe vs.
660 // scope-lock race that left the app wedged on the crash screen).
661 if (isScopeOwnershipConflict(error)) {
662 const adopted = await waitForSupervisedAttach(10_000);
663 if (adopted) {
664 log.info(
665 "Adopted the local daemon that owns the data dir instead of spawning a second one",
666 );
667 return adopted;
668 }
669 }
670 lastSidecarStartError = error;
671 log.error("Failed to start executor sidecar", error);
672 return null;
673 }
674};
675
676const restartSidecarAndReload = async (): Promise<DesktopServerConnection> => {
677 // 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