authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-20 10:54:56-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-20 10:54:56-07:00
loge55dd0067dde55770a4f7f7d1720615fcfd56389
tree5b744fc89b0073169cc561b9616b1fa61ec054e4
parent8c3755aeccd5fc90fe66f6ca4d776c0e370fe46e
signature Signed by PGP key B5690EEEBB952194

[codex] Structure preview session key errors (#3388)

Co-authored-by: codex <codex@users.noreply.github.com>

1 files changed, 12 insertions(+), 2 deletions(-)

apps/web/src/components/preview/usePreviewSession.ts+12-2
......@@ -4,6 +4,7 @@ import { useAtomValue } from "@effect/atom-react";
44import { parseScopedThreadKey, scopedThreadKey } from "@t3tools/client-runtime/environment";
55import { runAtomCommand } from "@t3tools/client-runtime/state/runtime";
66import type { ScopedThreadRef } from "@t3tools/contracts";
7import * as Schema from "effect/Schema";
78import { AsyncResult, Atom } from "effect/unstable/reactivity";
89
910import {
......@@ -13,10 +14,19 @@ import {
1314} from "~/previewStateStore";
1415import { previewEnvironment } from "~/state/preview";
1516
17class 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
1626const previewSessionSyncAtom = Atom.family((threadKey: string) => {
1727 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 });
2030 }
2131
2232 const sessionsAtom = previewEnvironment.list({