()
| 594 | }; |
| 595 | |
| 596 | const startWithCurrentSettings = async (): Promise<SidecarConnection | null> => { |
| 597 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: bind failures surface as a user-facing dialog |
| 598 | try { |
| 599 | return await startSidecar(); |
| 600 | } catch (error) { |
| 601 | // oxlint-disable-next-line executor/no-instanceof-tagged-error -- boundary: SidecarPortInUseError is a plain Node Error subclass, not an Effect tagged error |
| 602 | if (error instanceof SidecarPortInUseError) { |
| 603 | await showPortInUseDialog(error.port); |
| 604 | return null; |
| 605 | } |
| 606 | // The data dir is already owned by another local daemon. If it's a healthy |
| 607 | // cli-daemon, adopt it instead of failing — the same handoff boot() does up |
| 608 | // front, applied here so the fallback and restart paths recover from a |
| 609 | // mid-session daemon takeover. Poll briefly to ride out an owner that's |
| 610 | // alive but still finishing its own startup (the health-probe vs. |
| 611 | // scope-lock race that left the app wedged on the crash screen). |
| 612 | if (isScopeOwnershipConflict(error)) { |
| 613 | const adopted = await waitForSupervisedAttach(10_000); |
| 614 | if (adopted) { |
| 615 | log.info( |
| 616 | "Adopted the local daemon that owns the data dir instead of spawning a second one", |
| 617 | ); |
| 618 | return adopted; |
| 619 | } |
| 620 | } |
| 621 | lastSidecarStartError = error; |
| 622 | log.error("Failed to start executor sidecar", error); |
| 623 | return null; |
| 624 | } |
| 625 | }; |
| 626 | |
| 627 | const restartSidecarAndReload = async (): Promise<DesktopServerConnection> => { |
| 628 | // A supervised daemon owns its own process lifetime. Re-installing the unit |
no test coverage detected