Open History to see the last commit
1import { Connection } from "@t3tools/client-runtime/connection";
2import { shellSnapshotLoaderLayer } from "@t3tools/client-runtime/state/shell";
3import { threadSnapshotLoaderLayer } from "@t3tools/client-runtime/state/threads";
4import { pullRequestDiffLoaderLayer } from "@t3tools/client-runtime/state/pull-requests";
5import * as Layer from "effect/Layer";
6import { Atom } from "effect/unstable/reactivity";
7
8import { runtimeContextLayer } from "../lib/runtime";
9import {
10 backgroundActivityObserverLayer,
11 backgroundActivityReporterLayer,
12} from "../lib/backgroundActivityReporter";
13import { connectionPlatformLayer } from "./platform";
14
15const providedConnectionPlatformLayer = connectionPlatformLayer.pipe(
16 Layer.provide(runtimeContextLayer),
17);
18
19const snapshotLoaderLayer = Layer.mergeAll(
20 threadSnapshotLoaderLayer,
21 shellSnapshotLoaderLayer,
22 pullRequestDiffLoaderLayer,
23);
24
25type ConnectionLayerSource =
26 | typeof Connection.layer
27 | typeof snapshotLoaderLayer
28 | typeof runtimeContextLayer
29 | typeof connectionPlatformLayer
30 | typeof backgroundActivityObserverLayer
31 | typeof backgroundActivityReporterLayer;
32
33const providedClientConnectionLayer = Layer.merge(
34 Connection.layerWithOptions({ environmentThemes: true, usageLimitSources: true }),
35 snapshotLoaderLayer,
36).pipe(
37 Layer.provideMerge(
38 Layer.mergeAll(
39 runtimeContextLayer,
40 providedConnectionPlatformLayer,
41 backgroundActivityObserverLayer,
42 ),
43 ),
44);
45
46const connectionLayer = backgroundActivityReporterLayer.pipe(
47 Layer.provideMerge(providedClientConnectionLayer),
48);
49
50export const connectionAtomRuntime: Atom.AtomRuntime<
51 Layer.Success<ConnectionLayerSource>,
52 Layer.Error<ConnectionLayerSource>
53> = Atom.runtime(connectionLayer);