| 1 | export type StartupLifecycle = "starting" | "ready" | "failed"; |
| 2 | export type StartupPresentation = "none" | "focus" | "diagnostic"; |
| 3 | export type StartupPresentReason = "boot" | "second-instance" | "activate"; |
| 4 | |
| 5 | // Starting stays hidden, including a second icon click. Failed startups still |
| 6 | // need the recovery page; an existing window is focused, not replaced. |
| 7 | export function startupPresentation(input: { |
| 8 | serviceReady: boolean; |
| 9 | hasWindow: boolean; |
| 10 | lifecycle: StartupLifecycle; |
| 11 | }): StartupPresentation { |
| 12 | if (input.serviceReady || input.lifecycle === "ready") return "focus"; |
| 13 | if (input.lifecycle === "failed") return "diagnostic"; |
| 14 | return input.hasWindow ? "focus" : "none"; |
| 15 | } |
| 16 | |
| 17 | export function startupLifecycle(lifecycle: string): StartupLifecycle { |
| 18 | if (lifecycle === "failed" || lifecycle === "ready") return lifecycle; |
| 19 | return "starting"; |
| 20 | } |
| 21 |