@devries-cameron20 / t3code Mirror · read-only / commits / 0debebafbb
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, 21:30 UTC

[codex] Structure thread archive blocked error (#3451)

Julius Marminge committed Jun 20, 2026 at 20:41 UTC 0debebafbb7d98a3c77d3e636fa54616a98d26da
2 files changed +34 -6
apps/web/src/hooks/useThreadActions.test.ts new
+19
@@ -0,0 +1,19 @@
1 +import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2 +import { describe, expect, it } from "vite-plus/test";
3 +
4 +import { ThreadArchiveBlockedError } from "./useThreadActions";
5 +
6 +describe("ThreadArchiveBlockedError", () => {
7 + it("keeps the blocked thread context with the fixed message", () => {
8 + const error = new ThreadArchiveBlockedError({
9 + environmentId: EnvironmentId.make("environment-1"),
10 + threadId: ThreadId.make("thread-1"),
11 + });
12 +
13 + expect(error).toMatchObject({
14 + environmentId: "environment-1",
15 + threadId: "thread-1",
16 + });
17 + expect(error.message).toBe("Cannot archive a running thread.");
18 + });
19 +});
apps/web/src/hooks/useThreadActions.ts
+15 -6
@@ -4,9 +4,9 @@ import {
4 scopeThreadRef,
5 } from "@t3tools/client-runtime/environment";
6 import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
7 -import { type ScopedThreadRef, ThreadId } from "@t3tools/contracts";
7 +import { EnvironmentId, type ScopedThreadRef, ThreadId } from "@t3tools/contracts";
8 import * as Cause from "effect/Cause";
9 -import * as Data from "effect/Data";
9 +import * as Schema from "effect/Schema";
10 import { AsyncResult } from "effect/unstable/reactivity";
11 import { useRouter } from "@tanstack/react-router";
12 import { useCallback, useMemo, useRef } from "react";
@@ -27,9 +27,17 @@ import { stackedThreadToast, toastManager } from "../components/ui/toast";
27 import { useClientSettings } from "./useSettings";
28 import { useAtomCommand } from "../state/use-atom-command";
29
30 -export class ThreadArchiveBlockedError extends Data.TaggedError("ThreadArchiveBlockedError")<{
31 - readonly message: string;
32 -}> {}
30 +export class ThreadArchiveBlockedError extends Schema.TaggedErrorClass<ThreadArchiveBlockedError>()(
31 + "ThreadArchiveBlockedError",
32 + {
33 + environmentId: EnvironmentId,
34 + threadId: ThreadId,
35 + },
36 +) {
37 + override get message(): string {
38 + return "Cannot archive a running thread.";
39 + }
40 +}
41
42 export function useThreadActions() {
43 const closeTerminal = useAtomCommand(terminalEnvironment.close);
@@ -89,7 +97,8 @@ export function useThreadActions() {
97 return AsyncResult.failure(
98 Cause.fail(
99 new ThreadArchiveBlockedError({
92 - message: "Cannot archive a running thread.",
100 + environmentId: threadRef.environmentId,
101 + threadId: threadRef.threadId,
102 }),
103 ),
104 );