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