Skip to content

Commit 90aa9d7

Browse files
fix(mobile): open the cloned project's draft only once the project has arrived
Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent e767719 commit 90aa9d7

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -972,16 +972,26 @@ export function AddProjectDestinationScreen(props: {
972972
if (AsyncResult.isFailure(startResult)) {
973973
setError(errorMessage(Cause.squash(startResult.cause)));
974974
} else {
975-
// The create event usually lands before the RPC returns; give the
976-
// shell stream a moment so the draft opens on the new project rather
977-
// than falling back to its picker.
978-
await waitForProject({ environmentId: environment.environmentId, projectId }, 3_000);
979-
openNewTaskDraft(navigation, {
980-
environmentId: environment.environmentId,
981-
projectId,
982-
title,
983-
cloning: "1",
984-
});
975+
// The draft screen resolves its project from the client store, so it
976+
// must not open before the create event has arrived (it would fall
977+
// back to the project picker and lose the clone controls). Stay in
978+
// the submitting state until then; the clone keeps running either way.
979+
const project = await waitForProject(
980+
{ environmentId: environment.environmentId, projectId },
981+
15_000,
982+
);
983+
if (project === null) {
984+
setError(
985+
"The project was created but has not reached this device yet. It will appear in the project list once the connection catches up.",
986+
);
987+
} else {
988+
openNewTaskDraft(navigation, {
989+
environmentId: environment.environmentId,
990+
projectId,
991+
title,
992+
cloning: "1",
993+
});
994+
}
985995
}
986996
setIsSubmitting(false);
987997
return;

0 commit comments

Comments
 (0)