Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
import { EnvironmentId, type OrchestrationShellSnapshot } from "@akeru/contracts";
import * as Cause from "effect/Cause";
import { AsyncResult, Atom, AtomRegistry } from "effect/unstable/reactivity";
import { expect, it } from "vite-plus/test";
import {
createArchivedThreadSnapshotsAtomFamily,
makeArchivedThreadsEnvironmentKey,
parseArchivedThreadsEnvironmentKey,
} from "./archivedThreads.ts";
it("round-trips environment keys in sorted order", () => {
const envA = EnvironmentId.make("env-a");
const envB = EnvironmentId.make("env-b");
const key = makeArchivedThreadsEnvironmentKey([envB, envA]);
expect(parseArchivedThreadsEnvironmentKey(key)).toEqual([envA, envB]);
});
it("does not expose an archived snapshot failure message", () => {
const environmentId = EnvironmentId.make("env-sensitive");
const snapshotsAtom = createArchivedThreadSnapshotsAtomFamily<Error>({
getSnapshotAtom: () =>
Atom.make(
AsyncResult.failure<OrchestrationShellSnapshot, Error>(
Cause.fail(new Error("credential=secret-value")),
),
),
labelPrefix: "test:archived-thread-snapshots",
});
const registry = AtomRegistry.make();
expect(registry.get(snapshotsAtom(makeArchivedThreadsEnvironmentKey([environmentId])))).toEqual({
snapshots: [],
error: "Failed to load archived chats.",
isLoading: false,
});
registry.dispose();
});