@@ -27,6 +27,10 @@ type NewTaskDraftRouteParams = {
2727
2828export function NewTaskDraftRouteScreen ( { route } : StaticScreenProps < NewTaskDraftRouteParams > ) {
2929 const params = useMemo ( ( ) => route . params ?? { } , [ route . params ] ) ;
30+ const pendingTaskId = Array . isArray ( params . pendingTaskId )
31+ ? params . pendingTaskId [ 0 ]
32+ : params . pendingTaskId ;
33+ const draftId = Array . isArray ( params . draftId ) ? params . draftId [ 0 ] : params . draftId ;
3034 const projects = useProjects ( ) ;
3135 const navigation = useNavigation ( ) ;
3236 const switchRef = useAtomCommand ( vcsEnvironment . switchRef , { reportFailure : false } ) ;
@@ -49,7 +53,7 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf
4953 const [ preparedProject , setPreparedProject ] = useState < {
5054 request : typeof initialProjectRef ;
5155 projectRef : typeof initialProjectRef ;
52- workspaceRoot : string ;
56+ workspaceRoot : string | undefined ;
5357 } | null > ( null ) ;
5458 const project = projects . find (
5559 ( candidate ) =>
@@ -58,12 +62,10 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf
5862 ) ;
5963 const environmentId = project ?. environmentId ;
6064 const workspaceRoot = project ?. workspaceRoot ;
61- const needsPreparation = Boolean (
62- initialProjectRef . branch && ! params . pendingTaskId && ! params . draftId ,
63- ) ;
65+ const needsPreparation = Boolean ( initialProjectRef . branch && ! pendingTaskId && ! draftId ) ;
6466
6567 useEffect ( ( ) => {
66- if ( ! needsPreparation || ! initialProjectRef . branch || ! environmentId || ! workspaceRoot ) return ;
68+ if ( ! needsPreparation || ! initialProjectRef . branch ) return ;
6769 let active = true ;
6870 void checkoutNewTaskBranch ( {
6971 // A thread's branch is historical; only switchRef can establish that
@@ -74,7 +76,7 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf
7476 isDefault : false ,
7577 worktreePath : initialProjectRef . worktreePath ?? null ,
7678 } ,
77- project : { environmentId, workspaceRoot } ,
79+ project : environmentId && workspaceRoot ? { environmentId, workspaceRoot } : null ,
7880 workspaceMode : "local" ,
7981 switchRef,
8082 } ) . then ( ( result ) => {
@@ -127,10 +129,8 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf
127129 ? params . incomingShareId [ 0 ]
128130 : params . incomingShareId
129131 }
130- pendingTaskId = {
131- Array . isArray ( params . pendingTaskId ) ? params . pendingTaskId [ 0 ] : params . pendingTaskId
132- }
133- draftId = { Array . isArray ( params . draftId ) ? params . draftId [ 0 ] : params . draftId }
132+ pendingTaskId = { pendingTaskId }
133+ draftId = { draftId }
134134 />
135135 ) }
136136 </ >
0 commit comments