@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 33 lines 1.23 KB
Raw
1 import * as Context from "effect/Context";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as Ref from "effect/Ref";
5 import * as SubscriptionRef from "effect/SubscriptionRef";
6
7 import type { BackendStartupFailure } from "../backend/DesktopBackendManager.ts";
8
9 /** Startup health of the primary local backend, read by the startup recovery window. */
10 export type PrimaryBackendStartup =
11 | { readonly _tag: "Starting" }
12 | { readonly _tag: "Ready" }
13 | ({ readonly _tag: "Failing" } & BackendStartupFailure);
14
15 export class DesktopState extends Context.Service<
16 DesktopState,
17 {
18 readonly backendReady: Ref.Ref<boolean>;
19 readonly quitting: Ref.Ref<boolean>;
20 // Set by DesktopUpdates.configure, which runs before the first backend start.
21 readonly canInstallUpdates: Ref.Ref<boolean>;
22 readonly primaryBackendStartup: SubscriptionRef.SubscriptionRef<PrimaryBackendStartup>;
23 }
24 >()("@t3tools/desktop/app/DesktopState") {}
25
26 const make = Effect.all({
27 backendReady: Ref.make(false),
28 quitting: Ref.make(false),
29 canInstallUpdates: Ref.make(false),
30 primaryBackendStartup: SubscriptionRef.make<PrimaryBackendStartup>({ _tag: "Starting" }),
31 });
32
33 export const layer = Layer.effect(DesktopState, make);