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