@devries-cameron20 / t3code Mirror · read-only / commits / 6515be7f4b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 06:45 UTC

perf(web): the project clone toasts compile without manual memoization (#20593)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 22:03 UTC 6515be7f4bd34a6d69e4f40b7f615e438aa235d0
1 file changed +26 -32
apps/web/src/components/ProjectCloneToastCoordinator.tsx
+26 -32
@@ -12,7 +12,7 @@ import {
12 type ProjectCloneSnapshot,
13 type ProjectId,
14 } from "@t3tools/contracts";
15 -import { useCallback, useEffect, useRef } from "react";
15 +import { useEffect, useRef } from "react";
16
17 import { useNewThreadHandler } from "../hooks/useHandleNewThread";
18 import { useRemoveClonedProject } from "../hooks/useRemoveClonedProject";
@@ -44,6 +44,23 @@ function renderKey(clone: ProjectCloneSnapshot): string {
44 return `${clone.phase}:${clone.stage}:${clone.percent ?? ""}:${clone.detail ?? ""}:${clone.error ?? ""}`;
45 }
46
47 +async function runCloneAction(
48 + title: string,
49 + action: () => Promise<AtomCommandResult<unknown, unknown>>,
50 +) {
51 + const result = await action();
52 + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
53 + const error = squashAtomCommandFailure(result);
54 + toastManager.add(
55 + stackedThreadToast({
56 + type: "error",
57 + title,
58 + description: error instanceof Error ? error.message : "An error occurred.",
59 + }),
60 + );
61 + }
62 +}
63 +
64 function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentId }) {
65 const clones = useEnvironmentProjectClones(environmentId);
66 const handleNewThread = useNewThreadHandler();
@@ -54,40 +71,18 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI
71 const retryClone = useAtomCommand(sourceControlEnvironment.retryProjectClone, {
72 reportFailure: false,
73 });
57 - const runCloneAction = useCallback(
58 - async (title: string, action: () => Promise<AtomCommandResult<unknown, unknown>>) => {
59 - const result = await action();
60 - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
61 - const error = squashAtomCommandFailure(result);
62 - toastManager.add(
63 - stackedThreadToast({
64 - type: "error",
65 - title,
66 - description: error instanceof Error ? error.message : "An error occurred.",
67 - }),
68 - );
69 - }
70 - },
71 - [],
72 - );
74 const removeClonedProject = useRemoveClonedProject();
75 const toasts = useRef(new Map<ProjectId, TrackedToast>());
76
76 - const isViewingProjectDraft = useCallback(
77 - (projectId: ProjectId) => {
78 - if (!routeDraftId) return false;
79 - const draft = useComposerDraftStore.getState().getDraftSession(routeDraftId as DraftId);
80 - return draft?.environmentId === environmentId && draft.projectId === projectId;
81 - },
82 - [environmentId, routeDraftId],
83 - );
77 + const isViewingProjectDraft = (projectId: ProjectId) => {
78 + if (!routeDraftId) return false;
79 + const draft = useComposerDraftStore.getState().getDraftSession(routeDraftId as DraftId);
80 + return draft?.environmentId === environmentId && draft.projectId === projectId;
81 + };
82
85 - const openProject = useCallback(
86 - (projectId: ProjectId) => {
87 - void handleNewThread(scopeProjectRef(environmentId, projectId));
88 - },
89 - [environmentId, handleNewThread],
90 - );
83 + const openProject = (projectId: ProjectId) => {
84 + void handleNewThread(scopeProjectRef(environmentId, projectId));
85 + };
86
87 useEffect(() => {
88 const seen = new Set<ProjectId>();
@@ -205,7 +200,6 @@ function EnvironmentCloneToasts({ environmentId }: { environmentId: EnvironmentI
200 openProject,
201 removeClonedProject,
202 retryClone,
208 - runCloneAction,
203 ]);
204
205 useEffect(