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