@devries-cameron20 / t3code Mirror · read-only / commits / 8dbfd927f9
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 23, 05:30 UTC

refactor(web): the preview bridge keeps its stable thread ref without "use memo" hooks (#20746)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 23:25 UTC 8dbfd927f9c46502472d5a62199d0f2f7f8b0a49
1 file changed +4 -11
apps/web/src/components/preview/usePreviewBridge.ts
+4 -11
@@ -6,7 +6,6 @@ import type {
6 ScopedThreadRef,
7 ThreadId,
8 } from "@t3tools/contracts";
9 -import { parseScopedThreadKey, scopedThreadKey } from "@t3tools/client-runtime/environment";
9 import * as Option from "effect/Option";
10 import { useEffect, useEffectEvent, useRef } from "react";
11
@@ -43,8 +42,10 @@ export function usePreviewBridge(input: {
42 const { threadRef, tabId, runtimeTabId, serverDriven = false } = input;
43 const clearBrowserPointer = useBrowserPointerStore((state) => state.clear);
44 const reportStatus = useAtomCommand(previewEnvironment.reportStatus, "preview status report");
46 - const threadKey = scopedThreadKey(threadRef);
47 - const stableThreadRef = useThreadRefForKey(threadKey);
45 + // Callers pass a fresh threadRef each render; rebuilding it from its ids keeps the ref
46 + // stable for the effects.
47 + const { environmentId, threadId } = threadRef;
48 + const stableThreadRef: ScopedThreadRef = { environmentId, threadId };
49 const projectRef = useFaviconProjectRefForThread(stableThreadRef);
50 const preparedConnection = usePreparedConnection(stableThreadRef.environmentId);
51 const environmentHostname = Option.isSome(preparedConnection)
@@ -99,14 +100,6 @@ export function usePreviewBridge(input: {
100 }, [environmentHostname, projectRef, stableThreadRef]);
101 }
102
102 -// Callers pass a fresh threadRef each render; the key keeps the ref stable for the effects.
103 -function useThreadRefForKey(threadKey: string): ScopedThreadRef {
104 - "use memo";
105 - const parsed = parseScopedThreadKey(threadKey);
106 - if (!parsed) throw new Error(`Invalid scoped thread key: ${threadKey}`);
107 - return parsed;
108 -}
109 -
103 function shouldClearBrowserPointer(
104 previous: DesktopPreviewTabState["navStatus"] | null,
105 current: DesktopPreviewTabState["navStatus"],