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 = snapshotLoaderLayer.pipe(
34 Layer.provideMerge(
35 Connection.layerWithOptions({
36 environmentThemes: true,
37 usageLimitSources: true,
38 usageLimitsCommand: true,
39 }),
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);