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