Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { Connection } from "@t3tools/client-runtime/connection";
|
|
import { ShellSnapshotLoader } from "@t3tools/client-runtime/state/shell";
|
|
import {
|
|
BoundedThreadSnapshotLoader,
|
|
ThreadHistoryController,
|
|
} from "@t3tools/client-runtime/state/threads";
|
|
import { PullRequestDiffLoader } from "@t3tools/client-runtime/state/pull-requests";
|
|
import * as Layer from "effect/Layer";
|
|
import { Atom } from "effect/reactivity";
|
|
|
|
import * as Runtime from "../lib/runtime";
|
|
import * as BackgroundActivityReporter from "../lib/backgroundActivityReporter";
|
|
import * as ConnectionPlatform from "./platform";
|
|
|
|
const layerProvidedConnectionPlatform = ConnectionPlatform.layer.pipe(Layer.provide(Runtime.layer));
|
|
|
|
const layerSnapshotLoader = Layer.mergeAll(
|
|
BoundedThreadSnapshotLoader.layer,
|
|
ShellSnapshotLoader.layer,
|
|
ThreadHistoryController.layer,
|
|
PullRequestDiffLoader.layer,
|
|
);
|
|
|
|
type ConnectionLayerSource =
|
|
| typeof Connection.layer
|
|
| typeof layerSnapshotLoader
|
|
| typeof Runtime.layer
|
|
| typeof ConnectionPlatform.layer
|
|
| typeof BackgroundActivityReporter.layerObserver
|
|
| typeof BackgroundActivityReporter.layer;
|
|
|
|
const layerProvidedClientConnection = layerSnapshotLoader.pipe(
|
|
Layer.provideMerge(
|
|
Connection.layerWithOptions({
|
|
environmentThemes: true,
|
|
usageLimitSources: true,
|
|
usageLimitsCommand: true,
|
|
}),
|
|
),
|
|
Layer.provideMerge(
|
|
Layer.mergeAll(
|
|
Runtime.layer,
|
|
layerProvidedConnectionPlatform,
|
|
BackgroundActivityReporter.layerObserver,
|
|
),
|
|
),
|
|
);
|
|
|
|
const layerConnection = BackgroundActivityReporter.layer.pipe(
|
|
Layer.provideMerge(layerProvidedClientConnection),
|
|
);
|
|
|
|
export const connectionAtomRuntime: Atom.AtomRuntime<
|
|
Layer.Success<ConnectionLayerSource>,
|
|
Layer.Error<ConnectionLayerSource>
|
|
> = Atom.runtime(layerConnection);
|