@@ -8,6 +8,7 @@ import type { PendingNewThreadSeed } from "@threads/utils/threadCodexParamsSeed"
88import {
99 useThreadCodexSyncOrchestration ,
1010 useThreadSelectionHandlersOrchestration ,
11+ useThreadUiOrchestration ,
1112} from "./useThreadOrchestration" ;
1213
1314vi . mock ( "@/services/toasts" , ( ) => ( {
@@ -267,3 +268,45 @@ describe("useThreadCodexSyncOrchestration seed behavior", () => {
267268 expect ( params . patchThreadCodexParams ) . not . toHaveBeenCalled ( ) ;
268269 } ) ;
269270} ) ;
271+
272+ describe ( "useThreadUiOrchestration" , ( ) => {
273+ it ( "opens thread links in their source workspace" , ( ) => {
274+ const setActiveTab = vi . fn ( ) as unknown as Dispatch <
275+ SetStateAction < "home" | "projects" | "codex" | "git" | "log" >
276+ > ;
277+ const params = {
278+ activeWorkspaceId : "ws-1" ,
279+ activeThreadId : "thread-1" ,
280+ accessMode : "current" as const ,
281+ selectedCollaborationModeId : null ,
282+ selectedCodexArgsOverride : null ,
283+ pendingNewThreadSeedRef : {
284+ current : null ,
285+ } as MutableRefObject < PendingNewThreadSeed | null > ,
286+ runWithDraftStart : vi . fn ( async ( runner : ( ) => Promise < void > ) => runner ( ) ) ,
287+ handleComposerSend : vi . fn ( async ( ) => undefined ) ,
288+ clearDraftState : vi . fn ( ) ,
289+ exitDiffView : vi . fn ( ) ,
290+ resetPullRequestSelection : vi . fn ( ) ,
291+ selectWorkspace : vi . fn ( ) ,
292+ setActiveThreadId : vi . fn ( ) ,
293+ setActiveTab,
294+ isCompact : false ,
295+ removeThread : vi . fn ( ) ,
296+ clearDraftForThread : vi . fn ( ) ,
297+ removeImagesForThread : vi . fn ( ) ,
298+ } ;
299+
300+ const { result } = renderHook ( ( ) => useThreadUiOrchestration ( params ) ) ;
301+
302+ act ( ( ) => {
303+ result . current . handleOpenThreadLink ( "thread-review-1" , "ws-2" ) ;
304+ } ) ;
305+
306+ expect ( params . exitDiffView ) . toHaveBeenCalledTimes ( 1 ) ;
307+ expect ( params . resetPullRequestSelection ) . toHaveBeenCalledTimes ( 1 ) ;
308+ expect ( params . clearDraftState ) . toHaveBeenCalledTimes ( 1 ) ;
309+ expect ( params . selectWorkspace ) . toHaveBeenCalledWith ( "ws-2" ) ;
310+ expect ( params . setActiveThreadId ) . toHaveBeenCalledWith ( "thread-review-1" , "ws-2" ) ;
311+ } ) ;
312+ } ) ;
0 commit comments