@@ -659,11 +659,11 @@ export function AddProjectSourceScreen(props: { readonly environmentId?: string
659659 ) ;
660660}
661661
662- function getActiveRouteKey ( navigation : {
662+ function getActiveRoute ( navigation : {
663663 getState : ( ) => NavigationState < ParamListBase > | undefined ;
664- } ) : string | undefined {
664+ } ) {
665665 const state = navigation . getState ( ) ;
666- return state ?. routes [ state . index ] ?. key ;
666+ return state ?. routes [ state . index ] ;
667667}
668668
669669function openNewTaskDraft (
@@ -678,11 +678,19 @@ function openNewTaskDraft(
678678 cloning ?: "1" ;
679679 draftId ?: string ;
680680 } ,
681- originRouteKey : string | undefined ,
681+ originRoute : NavigationState < ParamListBase > [ "routes" ] [ number ] | undefined ,
682682) {
683683 const state = navigation . getState ( ) ;
684- // Async creation can finish after this flow was dismissed or another route opened.
685- if ( ! state || state . routes [ state . index ] ?. key !== originRouteKey ) return ;
684+ // Warm links can replace route params without changing the native controller key.
685+ const activeRoute = state ?. routes [ state . index ] ;
686+ if (
687+ ! state ||
688+ ! originRoute ||
689+ activeRoute ?. key !== originRoute . key ||
690+ activeRoute . name !== originRoute . name ||
691+ activeRoute . params !== originRoute . params
692+ )
693+ return ;
686694 const activeRoutes = state . routes . slice ( 0 , state . index + 1 ) ;
687695 const threadIndex = activeRoutes . findLastIndex ( ( route ) => route . name === "Thread" ) ;
688696 const flowIndex = activeRoutes . findIndex (
@@ -714,7 +722,7 @@ function useCreateProject(environment: EnvironmentOption | null) {
714722 const createProject = useAtomCommand ( projectEnvironment . create , { reportFailure : false } ) ;
715723 const projects = useProjects ( ) ;
716724
717- return async ( workspaceRoot : string , originRouteKey = getActiveRouteKey ( navigation ) ) => {
725+ return async ( workspaceRoot : string , originRoute = getActiveRoute ( navigation ) ) => {
718726 if (
719727 ! environment ||
720728 ! canCreateProjectInEnvironment ( environment . connectionState ) ||
@@ -741,7 +749,7 @@ function useCreateProject(environment: EnvironmentOption | null) {
741749 projectId : existing . id ,
742750 title : existing . title ,
743751 } ,
744- originRouteKey ,
752+ originRoute ,
745753 ) ;
746754 return ;
747755 }
@@ -779,7 +787,7 @@ function useCreateProject(environment: EnvironmentOption | null) {
779787 projectId,
780788 title : inferProjectTitleFromPath ( workspaceRoot ) ,
781789 } ,
782- originRouteKey ,
790+ originRoute ,
783791 ) ;
784792 return result ;
785793 } ;
@@ -1063,7 +1071,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
10631071 const submittingRef = useRef ( false ) ;
10641072 const submit = async ( ) => {
10651073 if ( ! environment || trimmedName . length === 0 || submittingRef . current ) return ;
1066- const originRouteKey = getActiveRouteKey ( navigation ) ;
1074+ const originRoute = getActiveRoute ( navigation ) ;
10671075 submittingRef . current = true ;
10681076 setError ( null ) ;
10691077 setIsSubmitting ( true ) ;
@@ -1121,7 +1129,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
11211129 projectId,
11221130 title : trimmedName ,
11231131 } ,
1124- originRouteKey ,
1132+ originRoute ,
11251133 ) ;
11261134 } ;
11271135
@@ -1364,7 +1372,7 @@ export function AddProjectDestinationScreen(props: {
13641372 return ;
13651373 }
13661374
1367- const originRouteKey = getActiveRouteKey ( navigation ) ;
1375+ const originRoute = getActiveRoute ( navigation ) ;
13681376 setIsSubmitting ( true ) ;
13691377 if ( environment . supportsCloneTracking ) {
13701378 const projectId = ProjectId . make ( uuidv4 ( ) ) ;
@@ -1406,7 +1414,7 @@ export function AddProjectDestinationScreen(props: {
14061414 )
14071415 : { } ) ,
14081416 } ,
1409- originRouteKey ,
1417+ originRoute ,
14101418 ) ;
14111419 }
14121420 }
@@ -1423,7 +1431,7 @@ export function AddProjectDestinationScreen(props: {
14231431 if ( AsyncResult . isFailure ( cloneResult ) ) {
14241432 setError ( errorMessage ( Cause . squash ( cloneResult . cause ) ) ) ;
14251433 } else {
1426- const createResult = await createProject ( cloneResult . value . cwd , originRouteKey ) ;
1434+ const createResult = await createProject ( cloneResult . value . cwd , originRoute ) ;
14271435 if ( createResult && AsyncResult . isFailure ( createResult ) ) {
14281436 setError ( errorMessage ( Cause . squash ( createResult . cause ) ) ) ;
14291437 }
0 commit comments