@devries-cameron20 / t3code Mirror · read-only / commits / e55dd0067d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 22:45 UTC

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

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

Julius Marminge committed Jun 20, 2026 at 10:54 UTC e55dd0067dde55770a4f7f7d1720615fcfd56389
1 file changed +12 -2
apps/web/src/components/preview/usePreviewSession.ts
+12 -2
@@ -4,6 +4,7 @@ import { useAtomValue } from "@effect/atom-react";
4 import { parseScopedThreadKey, scopedThreadKey } from "@t3tools/client-runtime/environment";
5 import { runAtomCommand } from "@t3tools/client-runtime/state/runtime";
6 import type { ScopedThreadRef } from "@t3tools/contracts";
7 +import * as Schema from "effect/Schema";
8 import { AsyncResult, Atom } from "effect/unstable/reactivity";
9
10 import {
@@ -13,10 +14,19 @@ import {
14 } from "~/previewStateStore";
15 import { previewEnvironment } from "~/state/preview";
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 +
26 const previewSessionSyncAtom = Atom.family((threadKey: string) => {
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 });
30 }
31
32 const sessionsAtom = previewEnvironment.list({