Skip to content

Commit 2369d30

Browse files
t3dotggclaude
andcommitted
fix(web): keep file copies through a cancelled clone, wait for the file list
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1782f70 commit 2369d30

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎apps/web/src/components/AddProjectToMachineDialog.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
111111
const [submitting, setSubmitting] = useState(false);
112112
const [error, setError] = useState<string | null>(null);
113113

114-
// The project or every target can vanish while the dialog is open.
115-
const unavailable = project === null || target === null;
114+
// The project or every target can vanish while the dialog is open. Submitting
115+
// before the file list loads would silently skip the default .env copies.
116+
const unavailable =
117+
project === null ||
118+
target === null ||
119+
(canListFiles && ignoredFiles.data === null && ignoredFiles.error === null);
116120
useEffect(() => {
117121
if (project === null) close();
118122
}, [project]);

‎apps/web/src/lib/addProjectToMachine.ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ function failureMessage(result: Parameters<typeof squashAtomCommandFailure>[0]):
7878
}
7979

8080
/**
81-
* Resolves when the clone finishes. Null means it was cancelled or removed. A
82-
* failed clone keeps waiting, since its toast offers a retry.
81+
* Resolves when the clone finishes, or null once it is removed. A failed or
82+
* cancelled clone keeps waiting, since its toast offers a retry.
8383
*/
8484
function waitForClone(environmentId: EnvironmentId, projectId: ProjectId) {
8585
return new Promise<ProjectCloneSnapshot | null>((resolve) => {
@@ -91,12 +91,7 @@ function waitForClone(environmentId: EnvironmentId, projectId: ProjectId) {
9191
if (settled) return;
9292
const clone = clones.find((candidate) => candidate.projectId === projectId);
9393
if (clone) seen = true;
94-
const result =
95-
clone?.phase === "done"
96-
? clone
97-
: clone?.phase === "cancelled" || (!clone && seen)
98-
? null
99-
: undefined;
94+
const result = clone?.phase === "done" ? clone : !clone && seen ? null : undefined;
10095
if (result === undefined) return;
10196
settled = true;
10297
unsubscribe?.();

0 commit comments

Comments
 (0)