The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { EnvironmentId } from "@t3tools/contracts"; |
| 2 | import { Atom } from "effect/reactivity"; |
| 3 | |
| 4 | export const environmentIdsKey = (environmentIds: ReadonlyArray<EnvironmentId>) => |
| 5 | environmentIds.join("\n"); |
| 6 | |
| 7 | /** Key by environment ids so equal input lists reuse the atom and snapshot. */ |
| 8 | export function environmentAtomList<A>( |
| 9 | label: string, |
| 10 | atom: (environmentId: EnvironmentId) => Atom.Atom<A>, |
| 11 | ) { |
| 12 | return Atom.family((key: string) => |
| 13 | Atom.make((get) => |
| 14 | key === "" ? [] : (key.split("\n") as EnvironmentId[]).map((id) => get(atom(id))), |
| 15 | ).pipe(Atom.withLabel(`${label}:${key}`)), |
| 16 | ); |
| 17 | } |