| ... | ... | @@ -4,6 +4,7 @@ import { useAtomValue } from "@effect/atom-react"; |
| 4 | 4 | import { parseScopedThreadKey, scopedThreadKey } from "@t3tools/client-runtime/environment"; |
| 5 | 5 | import { runAtomCommand } from "@t3tools/client-runtime/state/runtime"; |
| 6 | 6 | import type { ScopedThreadRef } from "@t3tools/contracts"; |
| 7 | import * as Schema from "effect/Schema"; |
| 7 | 8 | import { AsyncResult, Atom } from "effect/unstable/reactivity"; |
| 8 | 9 | |
| 9 | 10 | import { |
| ... | ... | @@ -13,10 +14,19 @@ import { |
| 13 | 14 | } from "~/previewStateStore"; |
| 14 | 15 | import { previewEnvironment } from "~/state/preview"; |
| 15 | 16 | |
| 17 | class PreviewSessionThreadKeyParseError extends Schema.TaggedErrorClass<PreviewSessionThreadKeyParseError>()( |
| 18 | "PreviewSessionThreadKeyParseError", |
| 19 | { threadKey: Schema.String }, |
| 20 | ) { |
| 21 | override get message(): string { |
| 22 | return `Invalid scoped preview thread key: ${this.threadKey}`; |
| 23 | } |
| 24 | } |
| 25 | |
| 16 | 26 | const previewSessionSyncAtom = Atom.family((threadKey: string) => { |
| 17 | 27 | const threadRef = parseScopedThreadKey(threadKey); |
| 18 | | if (!threadRef) { |
| 19 | | throw new Error(`Invalid scoped preview thread key: ${threadKey}`); |
| 28 | if (threadRef === null) { |
| 29 | throw new PreviewSessionThreadKeyParseError({ threadKey }); |
| 20 | 30 | } |
| 21 | 31 | |
| 22 | 32 | const sessionsAtom = previewEnvironment.list({ |