From 3959c7a486789ad7439c0ae9093cf80824489fc2 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:11:59 +0100 Subject: [PATCH 1/7] test(web): cover clone failure after dismissing progress Co-authored-by: GPT 6.2 Sol --- ...e-failure-after-dismissing-progress.e2e.ts | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts diff --git a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts new file mode 100644 index 0000000000000..fa1ac6f2e53a2 --- /dev/null +++ b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts @@ -0,0 +1,93 @@ +// @effect-diagnostics-next-line nodeBuiltinImport:off -- The fixture holds Git's HTTP request open. +import * as NodeHttp from "node:http"; +import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; +import { ProjectId } from "@t3tools/contracts"; +import { expect } from "e2e"; +import * as DateTime from "effect/DateTime"; +import * as Effect from "effect/Effect"; +import * as SecureRandom from "effect/crypto/SecureRandom"; +import * as Stream from "effect/Stream"; + +import { T3_HOME } from "../e2e.config.ts"; +import { rpcClient, runPromise, test, WEB } from "./t3.ts"; + +test( + "Dismissing clone progress leaves the later failure notification visible", + WEB, + async ({ t3, app, screen, browser }) => { + const project = await t3.project("demo"); + const thread = await t3.thread({ project, title: "Other work", messages: ["Start"] }); + const gitRequest = Promise.withResolvers(); + const remote = NodeHttp.createServer((_request, response) => { + gitRequest.resolve(response); + }); + + try { + await new Promise((resolve) => remote.listen(0, "127.0.0.1", resolve)); + const address = remote.address(); + if (!address || typeof address === "string") throw new Error("No Git fixture port"); + const projectId = ProjectId.make( + await runPromise( + SecureRandom.SecureRandom.pipe( + Effect.flatMap((random) => random.uuidV4()), + Effect.provide(NodeCrypto.layer), + ), + ), + ); + const name = "pending-clone"; + const origin = app.baseUrl ?? ""; + await t3.open(thread); + await screen.getByText("Start", { exact: true }).waitFor(); + + await runPromise( + Effect.gen(function* () { + const client = yield* rpcClient(T3_HOME, origin); + const createdAt = DateTime.formatIso(yield* DateTime.now); + yield* client["projectClone.start"]({ + projectId, + title: name, + createdAt, + remoteUrl: `http://127.0.0.1:${address.port}/${name}.git`, + destinationPath: `${project}/../${name}`, + }); + }).pipe(Effect.scoped), + ); + const response = await gitRequest.promise; + + const progress = browser.locator(`[data-slot="toast-title"]:text-is("Cloning ${name}")`); + await progress.waitFor(); + await browser + .locator( + `[data-position]:has(> div > [data-slot="toast-close"]):has([data-slot="toast-title"]:text-is("Cloning ${name}"))`, + ) + .getByRole("button", "Dismiss notification", { exact: true }) + .tap(); + await progress.waitFor({ state: "detached" }); + + response.writeHead(404).end(); + await runPromise( + Effect.gen(function* () { + const client = yield* rpcClient(T3_HOME, origin); + yield* client.subscribeProjectClones({}).pipe( + Stream.filter((clones) => + clones.some((clone) => clone.projectId === projectId && clone.phase === "failed"), + ), + Stream.runHead, + ); + }).pipe(Effect.scoped, Effect.timeout("10 seconds")), + ); + + try { + const failure = browser.locator( + `[data-slot="toast-title"]:text-is("Failed to clone ${name}")`, + ); + await expect(failure).toBeVisible(); + } finally { + await app.screenshot("after-background-clone-fails"); + } + } finally { + remote.close(); + remote.closeAllConnections(); + } + }, +); From 332af238b02c1254a5bfce484066ab31ed9edece Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:12:49 +0100 Subject: [PATCH 2/7] fix(web): show clone failure after progress is dismissed Co-authored-by: GPT 6.2 Sol --- .../ProjectCloneToastCoordinator.tsx | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/apps/web/src/components/ProjectCloneToastCoordinator.tsx b/apps/web/src/components/ProjectCloneToastCoordinator.tsx index 846644c537a12..91bfdee781558 100644 --- a/apps/web/src/components/ProjectCloneToastCoordinator.tsx +++ b/apps/web/src/components/ProjectCloneToastCoordinator.tsx @@ -45,6 +45,7 @@ interface TrackedToast { readonly toastId: ReturnType; readonly renderedKey: string; readonly phase: ProjectCloneSnapshot["phase"]; + readonly progressDismissed?: true; } function renderKey(clone: ProjectCloneSnapshot): string { @@ -119,6 +120,27 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI closeToast(); continue; } + if (tracked?.progressDismissed && clone.phase !== "failed") continue; + + const showToast = (options: ReturnType) => { + if (tracked && !tracked.progressDismissed) { + toastManager.update(tracked.toastId, options); + toasts.current.set(clone.projectId, { ...tracked, renderedKey: key, phase: clone.phase }); + return; + } + + const toastId = toastManager.add({ + ...options, + // Updates to a closing toast are ignored, even before it has been removed. + onClose: () => { + const current = toasts.current.get(clone.projectId); + if (current?.toastId === toastId && current.phase === "running") { + toasts.current.set(clone.projectId, { ...current, progressDismissed: true }); + } + }, + }); + toasts.current.set(clone.projectId, { toastId, renderedKey: key, phase: clone.phase }); + }; if (clone.phase === "running") { const options = stackedThreadToast({ @@ -136,13 +158,7 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI }, data: { hideCopyButton: true }, }); - if (tracked) { - toastManager.update(tracked.toastId, options); - toasts.current.set(clone.projectId, { ...tracked, renderedKey: key, phase: "running" }); - } else { - const toastId = toastManager.add(options); - toasts.current.set(clone.projectId, { toastId, renderedKey: key, phase: "running" }); - } + showToast(options); continue; } @@ -161,13 +177,7 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI }, data: { hideCopyButton: true }, }); - if (tracked) { - toastManager.update(tracked.toastId, options); - toasts.current.set(clone.projectId, { ...tracked, renderedKey: key, phase: "done" }); - } else { - const toastId = toastManager.add(options); - toasts.current.set(clone.projectId, { toastId, renderedKey: key, phase: "done" }); - } + showToast(options); continue; } @@ -199,13 +209,7 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI }, }, }); - if (tracked) { - toastManager.update(tracked.toastId, options); - toasts.current.set(clone.projectId, { ...tracked, renderedKey: key, phase: clone.phase }); - } else { - const toastId = toastManager.add(options); - toasts.current.set(clone.projectId, { toastId, renderedKey: key, phase: clone.phase }); - } + showToast(options); } for (const [projectId, tracked] of toasts.current) { From b9337a960bdf1c9a4ca21c358ca281759a2261ac Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:23:58 +0100 Subject: [PATCH 3/7] fix(web): show clone retries after their previous toast closes Co-authored-by: GPT 6.2 Sol --- .../ProjectCloneToastCoordinator.tsx | 25 +++++++++++++------ ...e-failure-after-dismissing-progress.e2e.ts | 25 +++++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/apps/web/src/components/ProjectCloneToastCoordinator.tsx b/apps/web/src/components/ProjectCloneToastCoordinator.tsx index 91bfdee781558..778c195e2d29e 100644 --- a/apps/web/src/components/ProjectCloneToastCoordinator.tsx +++ b/apps/web/src/components/ProjectCloneToastCoordinator.tsx @@ -45,7 +45,8 @@ interface TrackedToast { readonly toastId: ReturnType; readonly renderedKey: string; readonly phase: ProjectCloneSnapshot["phase"]; - readonly progressDismissed?: true; + readonly startedAt: ProjectCloneSnapshot["startedAt"]; + readonly closed?: true; } function renderKey(clone: ProjectCloneSnapshot): string { @@ -99,6 +100,7 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI seen.add(clone.projectId); const key = renderKey(clone); const tracked = toasts.current.get(clone.projectId); + const sameAttempt = tracked?.startedAt === clone.startedAt; const name = projectCloneDisplayName(clone); const closeToast = () => { const current = toasts.current.get(clone.projectId); @@ -112,7 +114,7 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI closeToast(); continue; } - if (tracked?.renderedKey === key) continue; + if (sameAttempt && tracked.renderedKey === key) continue; if ( isProjectCloneToastSilenced(ref) && (clone.phase === "running" || clone.phase === "done") @@ -120,12 +122,19 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI closeToast(); continue; } - if (tracked?.progressDismissed && clone.phase !== "failed") continue; + if ( + sameAttempt && + tracked.closed && + (tracked.phase !== "running" || clone.phase !== "failed") + ) { + continue; + } const showToast = (options: ReturnType) => { - if (tracked && !tracked.progressDismissed) { + const rendered = { renderedKey: key, phase: clone.phase, startedAt: clone.startedAt }; + if (tracked && !tracked.closed) { toastManager.update(tracked.toastId, options); - toasts.current.set(clone.projectId, { ...tracked, renderedKey: key, phase: clone.phase }); + toasts.current.set(clone.projectId, { toastId: tracked.toastId, ...rendered }); return; } @@ -134,12 +143,12 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI // Updates to a closing toast are ignored, even before it has been removed. onClose: () => { const current = toasts.current.get(clone.projectId); - if (current?.toastId === toastId && current.phase === "running") { - toasts.current.set(clone.projectId, { ...current, progressDismissed: true }); + if (current?.toastId === toastId) { + toasts.current.set(clone.projectId, { ...current, closed: true }); } }, }); - toasts.current.set(clone.projectId, { toastId, renderedKey: key, phase: clone.phase }); + toasts.current.set(clone.projectId, { toastId, ...rendered }); }; if (clone.phase === "running") { diff --git a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts index fa1ac6f2e53a2..ecd8b59588cb9 100644 --- a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts +++ b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts @@ -85,6 +85,31 @@ test( } finally { await app.screenshot("after-background-clone-fails"); } + + const failure = browser.locator( + `[data-slot="toast-title"]:text-is("Failed to clone ${name}")`, + ); + await browser + .locator( + `[data-position]:has(> div > [data-slot="toast-close"]):has([data-slot="toast-title"]:text-is("Failed to clone ${name}"))`, + ) + .getByRole("button", "Dismiss notification", { exact: true }) + .tap(); + await failure.waitFor({ state: "detached" }); + + const retryRequest = Promise.withResolvers(); + remote.once("request", (_request, response) => retryRequest.resolve(response)); + const retry = await runPromise( + Effect.gen(function* () { + const client = yield* rpcClient(T3_HOME, origin); + return yield* client["projectClone.retry"]({ projectId }); + }).pipe(Effect.scoped), + ); + await expect(retry.applied).toBe(true); + const retryResponse = await retryRequest.promise; + await expect(progress).toBeVisible(); + retryResponse.writeHead(404).end(); + await expect(failure).toBeVisible(); } finally { remote.close(); remote.closeAllConnections(); From 7af396d35095b6ef2cdaf81365a431e6156951b0 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:30:56 +0100 Subject: [PATCH 4/7] refactor(test): share project ID generation in web scenarios Co-authored-by: GPT 6.2 Sol --- .../clone-failure-after-dismissing-progress.e2e.ts | 14 ++------------ scripts/scenarios/t3.ts | 4 +++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts index ecd8b59588cb9..7af535ce92451 100644 --- a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts +++ b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts @@ -1,15 +1,12 @@ // @effect-diagnostics-next-line nodeBuiltinImport:off -- The fixture holds Git's HTTP request open. import * as NodeHttp from "node:http"; -import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; -import { ProjectId } from "@t3tools/contracts"; import { expect } from "e2e"; import * as DateTime from "effect/DateTime"; import * as Effect from "effect/Effect"; -import * as SecureRandom from "effect/crypto/SecureRandom"; import * as Stream from "effect/Stream"; import { T3_HOME } from "../e2e.config.ts"; -import { rpcClient, runPromise, test, WEB } from "./t3.ts"; +import { newProjectId, rpcClient, runPromise, test, WEB } from "./t3.ts"; test( "Dismissing clone progress leaves the later failure notification visible", @@ -26,14 +23,7 @@ test( await new Promise((resolve) => remote.listen(0, "127.0.0.1", resolve)); const address = remote.address(); if (!address || typeof address === "string") throw new Error("No Git fixture port"); - const projectId = ProjectId.make( - await runPromise( - SecureRandom.SecureRandom.pipe( - Effect.flatMap((random) => random.uuidV4()), - Effect.provide(NodeCrypto.layer), - ), - ), - ); + const projectId = await runPromise(newProjectId); const name = "pending-clone"; const origin = app.baseUrl ?? ""; await t3.open(thread); diff --git a/scripts/scenarios/t3.ts b/scripts/scenarios/t3.ts index fab377de1028b..f03067edf305a 100644 --- a/scripts/scenarios/t3.ts +++ b/scripts/scenarios/t3.ts @@ -89,6 +89,8 @@ const uuid = SecureRandom.SecureRandom.pipe( Effect.provide(NodeCrypto.layer), ); +export const newProjectId = uuid.pipe(Effect.map(ProjectId.make)); + /** State for the server on `home`, made through the app's own CLI and API: real events, not inserted rows. */ export function makeState(home: string, env: NodeJS.ProcessEnv = {}) { const cli = Effect.fn("scenario.cli")(function* ( @@ -180,7 +182,7 @@ export function makeState(home: string, env: NodeJS.ProcessEnv = {}) { const created = yield* mutate({ type: "project.create", commandId: CommandId.make(yield* uuid), - projectId: ProjectId.make(yield* uuid), + projectId: yield* newProjectId, title, workspaceRoot: workspace, }); From 5d7643ecb42827faa443ea0fa0dec2a43cf99193 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:33:22 +0100 Subject: [PATCH 5/7] test(web): preserve the clone regression scenario fixture Co-authored-by: GPT 6.2 Sol --- .../clone-failure-after-dismissing-progress.e2e.ts | 14 ++++++++++++-- scripts/scenarios/t3.ts | 4 +--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts index 7af535ce92451..ecd8b59588cb9 100644 --- a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts +++ b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts @@ -1,12 +1,15 @@ // @effect-diagnostics-next-line nodeBuiltinImport:off -- The fixture holds Git's HTTP request open. import * as NodeHttp from "node:http"; +import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; +import { ProjectId } from "@t3tools/contracts"; import { expect } from "e2e"; import * as DateTime from "effect/DateTime"; import * as Effect from "effect/Effect"; +import * as SecureRandom from "effect/crypto/SecureRandom"; import * as Stream from "effect/Stream"; import { T3_HOME } from "../e2e.config.ts"; -import { newProjectId, rpcClient, runPromise, test, WEB } from "./t3.ts"; +import { rpcClient, runPromise, test, WEB } from "./t3.ts"; test( "Dismissing clone progress leaves the later failure notification visible", @@ -23,7 +26,14 @@ test( await new Promise((resolve) => remote.listen(0, "127.0.0.1", resolve)); const address = remote.address(); if (!address || typeof address === "string") throw new Error("No Git fixture port"); - const projectId = await runPromise(newProjectId); + const projectId = ProjectId.make( + await runPromise( + SecureRandom.SecureRandom.pipe( + Effect.flatMap((random) => random.uuidV4()), + Effect.provide(NodeCrypto.layer), + ), + ), + ); const name = "pending-clone"; const origin = app.baseUrl ?? ""; await t3.open(thread); diff --git a/scripts/scenarios/t3.ts b/scripts/scenarios/t3.ts index f03067edf305a..fab377de1028b 100644 --- a/scripts/scenarios/t3.ts +++ b/scripts/scenarios/t3.ts @@ -89,8 +89,6 @@ const uuid = SecureRandom.SecureRandom.pipe( Effect.provide(NodeCrypto.layer), ); -export const newProjectId = uuid.pipe(Effect.map(ProjectId.make)); - /** State for the server on `home`, made through the app's own CLI and API: real events, not inserted rows. */ export function makeState(home: string, env: NodeJS.ProcessEnv = {}) { const cli = Effect.fn("scenario.cli")(function* ( @@ -182,7 +180,7 @@ export function makeState(home: string, env: NodeJS.ProcessEnv = {}) { const created = yield* mutate({ type: "project.create", commandId: CommandId.make(yield* uuid), - projectId: yield* newProjectId, + projectId: ProjectId.make(yield* uuid), title, workspaceRoot: workspace, }); From ee6762f19881d48a3dcab64da0f689ecacd8062f Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:35:29 +0100 Subject: [PATCH 6/7] chore: credit the models that worked on this change Co-authored-by: Claude Opus 5.5 From e81130abafbeca593a35c5dfa063a5bae68054bd Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 22 Nov 2026 17:48:03 +0000 Subject: [PATCH 7/7] test(web): share toast locators in the clone failure scenario Co-Authored-By: Claude Opus 5.5 --- ...e-failure-after-dismissing-progress.e2e.ts | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts index ecd8b59588cb9..739497a827757 100644 --- a/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts +++ b/scripts/scenarios/clone-failure-after-dismissing-progress.e2e.ts @@ -54,15 +54,22 @@ test( ); const response = await gitRequest.promise; - const progress = browser.locator(`[data-slot="toast-title"]:text-is("Cloning ${name}")`); + const toastTitle = (title: string) => + browser.locator(`[data-slot="toast-title"]:text-is("${title}")`); + const dismiss = async (title: string) => { + await browser + .locator( + `[data-position]:has(> div > [data-slot="toast-close"]):has([data-slot="toast-title"]:text-is("${title}"))`, + ) + .getByRole("button", "Dismiss notification", { exact: true }) + .tap(); + await toastTitle(title).waitFor({ state: "detached" }); + }; + const progress = toastTitle(`Cloning ${name}`); + const failure = toastTitle(`Failed to clone ${name}`); + await progress.waitFor(); - await browser - .locator( - `[data-position]:has(> div > [data-slot="toast-close"]):has([data-slot="toast-title"]:text-is("Cloning ${name}"))`, - ) - .getByRole("button", "Dismiss notification", { exact: true }) - .tap(); - await progress.waitFor({ state: "detached" }); + await dismiss(`Cloning ${name}`); response.writeHead(404).end(); await runPromise( @@ -78,24 +85,12 @@ test( ); try { - const failure = browser.locator( - `[data-slot="toast-title"]:text-is("Failed to clone ${name}")`, - ); await expect(failure).toBeVisible(); } finally { await app.screenshot("after-background-clone-fails"); } - const failure = browser.locator( - `[data-slot="toast-title"]:text-is("Failed to clone ${name}")`, - ); - await browser - .locator( - `[data-position]:has(> div > [data-slot="toast-close"]):has([data-slot="toast-title"]:text-is("Failed to clone ${name}"))`, - ) - .getByRole("button", "Dismiss notification", { exact: true }) - .tap(); - await failure.waitFor({ state: "detached" }); + await dismiss(`Failed to clone ${name}`); const retryRequest = Promise.withResolvers(); remote.once("request", (_request, response) => retryRequest.resolve(response));