@@ -6,7 +6,6 @@ import type {
66 ScopedThreadRef ,
77 ThreadId ,
88} from "@t3tools/contracts" ;
9- import { parseScopedThreadKey , scopedThreadKey } from "@t3tools/client-runtime/environment" ;
109import * as Option from "effect/Option" ;
1110import { useEffect , useEffectEvent , useRef } from "react" ;
1211
@@ -43,8 +42,10 @@ export function usePreviewBridge(input: {
4342 const { threadRef, tabId, runtimeTabId, serverDriven = false } = input ;
4443 const clearBrowserPointer = useBrowserPointerStore ( ( state ) => state . clear ) ;
4544 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 } ;
4849 const projectRef = useFaviconProjectRefForThread ( stableThreadRef ) ;
4950 const preparedConnection = usePreparedConnection ( stableThreadRef . environmentId ) ;
5051 const environmentHostname = Option . isSome ( preparedConnection )
@@ -99,14 +100,6 @@ export function usePreviewBridge(input: {
99100 } , [ environmentHostname , projectRef , stableThreadRef ] ) ;
100101}
101102
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-
110103function shouldClearBrowserPointer (
111104 previous : DesktopPreviewTabState [ "navStatus" ] | null ,
112105 current : DesktopPreviewTabState [ "navStatus" ] ,
0 commit comments