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 thread archive blocked error (#3451)
Julius Marminge0debebafbb7d
diff --git a/apps/web/src/hooks/useThreadActions.test.ts b/apps/web/src/hooks/useThreadActions.test.tsnew file mode 100644index 000000000..c53852115--- /dev/null+++ b/apps/web/src/hooks/useThreadActions.test.ts@@ -0,0 +1,19 @@+import { EnvironmentId, ThreadId } from "@t3tools/contracts";+import { describe, expect, it } from "vite-plus/test";++import { ThreadArchiveBlockedError } from "./useThreadActions";++describe("ThreadArchiveBlockedError", () => {+ it("keeps the blocked thread context with the fixed message", () => {+ const error = new ThreadArchiveBlockedError({+ environmentId: EnvironmentId.make("environment-1"),+ threadId: ThreadId.make("thread-1"),+ });++ expect(error).toMatchObject({+ environmentId: "environment-1",+ threadId: "thread-1",+ });+ expect(error.message).toBe("Cannot archive a running thread.");+ });+});diff --git a/apps/web/src/hooks/useThreadActions.ts b/apps/web/src/hooks/useThreadActions.tsindex 357833480..07655ad30 100644--- a/apps/web/src/hooks/useThreadActions.ts+++ b/apps/web/src/hooks/useThreadActions.ts@@ -4,9 +4,9 @@ import {scopeThreadRef,} from "@t3tools/client-runtime/environment";import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";-import { type ScopedThreadRef, ThreadId } from "@t3tools/contracts";+import { EnvironmentId, type ScopedThreadRef, ThreadId } from "@t3tools/contracts";import * as Cause from "effect/Cause";-import * as Data from "effect/Data";+import * as Schema from "effect/Schema";import { AsyncResult } from "effect/unstable/reactivity";import { useRouter } from "@tanstack/react-router";import { useCallback, useMemo, useRef } from "react";@@ -27,9 +27,17 @@ import { stackedThreadToast, toastManager } from "../components/ui/toast";import { useClientSettings } from "./useSettings";import { useAtomCommand } from "../state/use-atom-command";-export class ThreadArchiveBlockedError extends Data.TaggedError("ThreadArchiveBlockedError")<{- readonly message: string;-}> {}+export class ThreadArchiveBlockedError extends Schema.TaggedErrorClass<ThreadArchiveBlockedError>()(+ "ThreadArchiveBlockedError",+ {+ environmentId: EnvironmentId,+ threadId: ThreadId,+ },+) {+ override get message(): string {+ return "Cannot archive a running thread.";+ }+}export function useThreadActions() {const closeTerminal = useAtomCommand(terminalEnvironment.close);@@ -89,7 +97,8 @@ export function useThreadActions() {return AsyncResult.failure(Cause.fail(new ThreadArchiveBlockedError({- message: "Cannot archive a running thread.",+ environmentId: threadRef.environmentId,+ threadId: threadRef.threadId,}),),);