Skip to content

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.

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

Julius Marmingee55dd0067dde
diff --git a/apps/web/src/components/preview/usePreviewSession.ts b/apps/web/src/components/preview/usePreviewSession.ts
index e5444bdd2..2a82f6275 100644
--- a/apps/web/src/components/preview/usePreviewSession.ts
+++ b/apps/web/src/components/preview/usePreviewSession.ts
@@ -4,6 +4,7 @@ import { useAtomValue } from "@effect/atom-react";
import { parseScopedThreadKey, scopedThreadKey } from "@t3tools/client-runtime/environment";
import { runAtomCommand } from "@t3tools/client-runtime/state/runtime";
import type { ScopedThreadRef } from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
import { AsyncResult, Atom } from "effect/unstable/reactivity";
import {
@@ -13,10 +14,19 @@ import {
} from "~/previewStateStore";
import { previewEnvironment } from "~/state/preview";
+class PreviewSessionThreadKeyParseError extends Schema.TaggedErrorClass<PreviewSessionThreadKeyParseError>()(
+ "PreviewSessionThreadKeyParseError",
+ { threadKey: Schema.String },
+) {
+ override get message(): string {
+ return `Invalid scoped preview thread key: ${this.threadKey}`;
+ }
+}
+
const previewSessionSyncAtom = Atom.family((threadKey: string) => {
const threadRef = parseScopedThreadKey(threadKey);
- if (!threadRef) {
- throw new Error(`Invalid scoped preview thread key: ${threadKey}`);
+ if (threadRef === null) {
+ throw new PreviewSessionThreadKeyParseError({ threadKey });
}
const sessionsAtom = previewEnvironment.list({