@@ -11,7 +11,7 @@ import {
1111 useNavigation ,
1212 type StaticScreenProps ,
1313} from "@react-navigation/native" ;
14- import { useEffect , useLayoutEffect , useRef , useState , type ReactNode } from "react" ;
14+ import { useEffect , useRef , useState , type ReactNode } from "react" ;
1515import * as Option from "effect/Option" ;
1616import {
1717 AuthOrchestrationOperateScope ,
@@ -331,23 +331,20 @@ function ThreadRouteContent(
331331 return ;
332332 }
333333 mergeBackBusyRef . current = true ;
334- return await ( async ( ) => {
335- const result = await mergeBack ( {
336- environmentId : selectedThread . environmentId ,
337- input : {
338- sourceThreadId : selectedThread . id ,
339- targetThreadId : mergeBackTargetThreadId ,
340- runId : mergeBackRun . id ,
341- creationSource : "mobile" ,
342- } ,
343- } ) ;
344- if ( result . _tag !== "Success" ) return ;
345- navigation . navigate ( "Thread" , {
346- environmentId : selectedThread . environmentId ,
347- threadId : mergeBackTargetThreadId ,
348- } ) ;
349- } ) ( ) . finally ( ( ) => {
350- mergeBackBusyRef . current = false ;
334+ const result = await mergeBack ( {
335+ environmentId : selectedThread . environmentId ,
336+ input : {
337+ sourceThreadId : selectedThread . id ,
338+ targetThreadId : mergeBackTargetThreadId ,
339+ runId : mergeBackRun . id ,
340+ creationSource : "mobile" ,
341+ } ,
342+ } ) ;
343+ mergeBackBusyRef . current = false ;
344+ if ( result . _tag !== "Success" ) return ;
345+ navigation . navigate ( "Thread" , {
346+ environmentId : selectedThread . environmentId ,
347+ threadId : mergeBackTargetThreadId ,
351348 } ) ;
352349 } ;
353350 const params = props . route . params ;
@@ -490,25 +487,12 @@ function ThreadRouteContent(
490487 } ) ;
491488 showAuxiliaryPane ( "inspector" ) ;
492489 } ;
493- const inspectorToggleActionRef = useRef ( {
494- inspectorMode,
495- openFilesInspector : handleOpenFilesInspector ,
496- toggleAuxiliaryPane,
497- } ) ;
498- useLayoutEffect ( ( ) => {
499- inspectorToggleActionRef . current = {
500- inspectorMode,
501- openFilesInspector : handleOpenFilesInspector ,
502- toggleAuxiliaryPane,
503- } ;
504- } ) ;
505490 const handleToggleInspector = ( ) => {
506- const action = inspectorToggleActionRef . current ;
507- if ( action . inspectorMode === null ) {
508- action . openFilesInspector ( ) ;
491+ if ( inspectorMode === null ) {
492+ handleOpenFilesInspector ( ) ;
509493 return ;
510494 }
511- action . toggleAuxiliaryPane ( ) ;
495+ toggleAuxiliaryPane ( ) ;
512496 } ;
513497 const handleSelectInspectorFile = ( path : string ) => {
514498 if ( selectedThread === null ) {
@@ -804,44 +788,44 @@ function ThreadRouteContent(
804788 if ( ! selectedThread || ! selectedThreadProject || ! setupMessage || localResendBusy . current )
805789 return ;
806790 localResendBusy . current = true ;
807- return await ( async ( ) => {
808- const result = await cancelWorktreeSetup ( {
809- environmentId : selectedThread . environmentId ,
810- input : { threadId : selectedThread . id } ,
811- } ) ;
812- if ( result . _tag !== "Success" || ! result . value . cancelled ) return ;
813- // V2 accepts the launch before setup runs, so cancellation never rejects
814- // the original outbox delivery. Reuse the server-owned prompt and uploads.
815- const metadata = makeTurnCommandMetadata ( ) ;
816- const launched = await startLocalThread ( {
817- environmentId : selectedThread . environmentId ,
818- input : buildProjectThreadStartTurnInput ( {
819- ...metadata ,
820- projectId : selectedThread . projectId ,
821- projectCwd : selectedThreadProject . workspaceRoot ,
822- text : setupMessage . text ,
823- ...( setupMessage . context ? { context : setupMessage . context } : { } ) ,
824- uploadedAttachments : setupMessage . attachments ,
825- modelSelection : selectedThread . modelSelection ,
826- runtimeMode : selectedThread . runtimeMode ,
827- interactionMode : selectedThread . interactionMode ,
828- workspaceMode : "local" ,
829- branch : null ,
830- worktreePath : null ,
831- startFromOrigin : false ,
832- worktreeBranchName : "" ,
833- } ) ,
834- } ) ;
835- if ( launched . _tag !== "Success" ) return ;
836- navigation . dispatch (
837- StackActions . replace ( "Thread" , {
838- environmentId : String ( selectedThread . environmentId ) ,
839- threadId : metadata . threadId ,
840- } ) ,
841- ) ;
842- } ) ( ) . finally ( ( ) => {
791+ const result = await cancelWorktreeSetup ( {
792+ environmentId : selectedThread . environmentId ,
793+ input : { threadId : selectedThread . id } ,
794+ } ) ;
795+ if ( result . _tag !== "Success" || ! result . value . cancelled ) {
843796 localResendBusy . current = false ;
797+ return ;
798+ }
799+ // V2 accepts the launch before setup runs, so cancellation never rejects
800+ // the original outbox delivery. Reuse the server-owned prompt and uploads.
801+ const metadata = makeTurnCommandMetadata ( ) ;
802+ const launched = await startLocalThread ( {
803+ environmentId : selectedThread . environmentId ,
804+ input : buildProjectThreadStartTurnInput ( {
805+ ...metadata ,
806+ projectId : selectedThread . projectId ,
807+ projectCwd : selectedThreadProject . workspaceRoot ,
808+ text : setupMessage . text ,
809+ ...( setupMessage . context ? { context : setupMessage . context } : { } ) ,
810+ uploadedAttachments : setupMessage . attachments ,
811+ modelSelection : selectedThread . modelSelection ,
812+ runtimeMode : selectedThread . runtimeMode ,
813+ interactionMode : selectedThread . interactionMode ,
814+ workspaceMode : "local" ,
815+ branch : null ,
816+ worktreePath : null ,
817+ startFromOrigin : false ,
818+ worktreeBranchName : "" ,
819+ } ) ,
844820 } ) ;
821+ localResendBusy . current = false ;
822+ if ( launched . _tag !== "Success" ) return ;
823+ navigation . dispatch (
824+ StackActions . replace ( "Thread" , {
825+ environmentId : String ( selectedThread . environmentId ) ,
826+ threadId : metadata . threadId ,
827+ } ) ,
828+ ) ;
845829 } ;
846830 const creationState = ( ( ) : ThreadDetailScreenProps [ "creationState" ] => {
847831 if ( selectedThreadCreation === null ) {
0 commit comments