The best way to control Claude Code, Codex and more from any computer or phone
refactor(web): ChatView's project clone banner lives in useProjectCloneBanner (#23068)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 13:40 UTC
7be791c675347ac75eb32e89cf28370db2b08341
2 files changed
+138
-110
apps/web/src/components/ChatView.tsx
+4
-110
@@ -1,3 +1,4 @@
1
+import { useProjectCloneBanner } from "./chat/useProjectCloneBanner";
2
import { useAttachmentPreviewHandoff } from "./chat/useAttachmentPreviewHandoff";
3
import { useTimelineRewind } from "./chat/useTimelineRewind";
4
import { useThreadLifecycle } from "./chat/useThreadLifecycle";
@@ -176,7 +177,7 @@ import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
177
import { isEditableFocused } from "../lib/editableFocus";
178
import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
179
import { shortcutLabelForCommand } from "../keybindings";
179
-import { PaperclipIcon, ChevronDownIcon, DownloadIcon } from "lucide-react";
180
+import { PaperclipIcon, ChevronDownIcon } from "lucide-react";
181
import { cn } from "~/lib/utils";
182
import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar";
183
import { stackedThreadToast, toastManager } from "./ui/toast";
@@ -198,7 +199,6 @@ import {
199
import { useNowMinute } from "../hooks/useNowMinute";
200
import { usePanelAnimationSettings, usePanelPresence } from "../panelAnimations";
201
import { useNewThreadHandler } from "../hooks/useHandleNewThread";
201
-import { useRemoveClonedProject } from "../hooks/useRemoveClonedProject";
202
import { useOpenPanelPullRequestUrl } from "../hooks/useOpenPanelPullRequestUrl";
203
import { resolveAppModelSelectionForInstance } from "../modelSelection";
204
import { isPreviewFocused } from "../lib/previewFocus";
@@ -235,10 +235,6 @@ import {
235
import { threadEnvironment } from "../state/threads";
236
import { resolveProviderSkillsForCwd } from "@t3tools/client-runtime/providerSkills";
237
import { vcsEnvironment } from "../state/vcs";
238
-import { sourceControlEnvironment } from "../state/sourceControl";
239
-import { useProjectClone } from "../state/projectClones";
240
-import { projectCloneDisplayName, projectCloneProgressSummary } from "@t3tools/contracts";
241
-import { dismissProjectFileCopy, useProjectFileCopy } from "../lib/addProjectToMachine";
238
import {
239
type EnvironmentPresentation,
240
useEnvironmentProviders,
@@ -1117,110 +1113,8 @@ export default function ChatView(props: ChatViewProps) {
1113
activeProject ?? undefined,
1114
);
1115
const activeProjectScripts = activeProject ? resolveProjectScripts(settings, activeProject) : [];
1120
- const activeProjectClone = useProjectClone(activeProjectRef);
1121
- const cancelProjectClone = useAtomCommand(sourceControlEnvironment.cancelProjectClone, {
1122
- reportFailure: false,
1123
- });
1124
- const retryProjectClone = useAtomCommand(sourceControlEnvironment.retryProjectClone, {
1125
- reportFailure: false,
1126
- });
1127
- const removeClonedProject = useRemoveClonedProject();
1128
- const runProjectCloneAction = async (
1129
- title: string,
1130
- action: () => Promise<AtomCommandResult<unknown, unknown>>,
1131
- ): Promise<void> => {
1132
- const result = await action();
1133
- if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
1134
- const error = squashAtomCommandFailure(result);
1135
- toastManager.add(
1136
- stackedThreadToast({
1137
- type: "error",
1138
- title,
1139
- description: error instanceof Error ? error.message : "An error occurred.",
1140
- }),
1141
- );
1142
- }
1143
- };
1144
- const runProjectCloneActionStable = useStableCallback(runProjectCloneAction);
1145
- const activeProjectFileCopy = useProjectFileCopy(activeProjectRef);
1146
- const projectCloneSendBlockReason =
1147
- activeProjectClone?.phase === "running"
1148
- ? "Cloning repository"
1149
- : activeProjectClone !== null && activeProjectClone.phase !== "done"
1150
- ? "Repository not cloned"
1151
- : activeProjectFileCopy?.phase === "copying"
1152
- ? "Copying files"
1153
- : null;
1154
- const projectCloneBannerItem = (() => {
1155
- if (activeProjectFileCopy?.phase === "failed" && activeProjectRef) {
1156
- return {
1157
- id: `project-file-copy:${activeProjectRef.projectId}`,
1158
- variant: "error",
1159
- icon: <DownloadIcon />,
1160
- title: activeProjectFileCopy.title,
1161
- description: activeProjectFileCopy.failures.join("\n"),
1162
- onDismiss: () => dismissProjectFileCopy(activeProjectRef),
1163
- };
1164
- }
1165
- if (!activeProjectClone || !activeProjectRef || activeProjectClone.phase === "done") {
1166
- return null;
1167
- }
1168
- const name = projectCloneDisplayName(activeProjectClone);
1169
- const { environmentId, projectId } = activeProjectRef;
1170
- if (activeProjectClone.phase === "running") {
1171
- return {
1172
- id: `project-clone:${projectId}`,
1173
- variant: "info",
1174
- priority: "activity",
1175
- icon: <DownloadIcon />,
1176
- title: `Cloning ${name}`,
1177
- description: projectCloneProgressSummary(activeProjectClone),
1178
- actions: (
1179
- <Button
1180
- size="xs"
1181
- variant="ghost"
1182
- onClick={() =>
1183
- void runProjectCloneActionStable("Failed to cancel clone", () =>
1184
- cancelProjectClone({ environmentId, input: { projectId } }),
1185
- )
1186
- }
1187
- >
1188
- Cancel
1189
- </Button>
1190
- ),
1191
- };
1192
- }
1193
- const cancelled = activeProjectClone.phase === "cancelled";
1194
- return {
1195
- id: `project-clone:${projectId}`,
1196
- variant: cancelled ? "warning" : "error",
1197
- icon: <DownloadIcon />,
1198
- title: cancelled ? `Cancelled cloning ${name}` : `Failed to clone ${name}`,
1199
- description: cancelled ? "Retry to bring in the repository." : activeProjectClone.error,
1200
- actions: (
1201
- <>
1202
- <Button
1203
- size="xs"
1204
- variant="ghost"
1205
- onClick={() => void removeClonedProject({ environmentId, projectId })}
1206
- >
1207
- Remove project
1208
- </Button>
1209
- <Button
1210
- size="xs"
1211
- variant="ghost"
1212
- onClick={() =>
1213
- void runProjectCloneActionStable("Failed to retry clone", () =>
1214
- retryProjectClone({ environmentId, input: { projectId } }),
1215
- )
1216
- }
1217
- >
1218
- Retry
1219
- </Button>
1220
- </>
1221
- ),
1222
- };
1223
- })() as ComposerBannerStackItem | null;
1116
+ const { projectCloneBannerItem, projectCloneSendBlockReason } =
1117
+ useProjectCloneBanner(activeProjectRef);
1118
const activeProjectDefaultModelSelection = activeProjectSettings.settings.defaultModelSelection;
1119
const handleNewThreadInActiveProject = () => {
1120
startNewThreadForProject(activeProjectRef, handleNewThread);
apps/web/src/components/chat/useProjectCloneBanner.tsx
new
+134
@@ -0,0 +1,134 @@
1
+import { useStableCallback } from "../../hooks/useStableCallback";
2
+import {
3
+ isAtomCommandInterrupted,
4
+ squashAtomCommandFailure,
5
+ type AtomCommandResult,
6
+} from "@t3tools/client-runtime/state/runtime";
7
+import { DownloadIcon } from "lucide-react";
8
+import { stackedThreadToast, toastManager } from "../ui/toast";
9
+import { useRemoveClonedProject } from "../../hooks/useRemoveClonedProject";
10
+import { sourceControlEnvironment } from "../../state/sourceControl";
11
+import { useProjectClone } from "../../state/projectClones";
12
+import {
13
+ projectCloneDisplayName,
14
+ projectCloneProgressSummary,
15
+ type ScopedProjectRef,
16
+} from "@t3tools/contracts";
17
+import { dismissProjectFileCopy, useProjectFileCopy } from "../../lib/addProjectToMachine";
18
+import { type ComposerBannerStackItem } from "./ComposerBannerStack";
19
+import { useAtomCommand } from "../../state/use-atom-command";
20
+import { Button } from "../ui/button";
21
+/**
22
+ * A project still being cloned or copied into place: the composer banner with its cancel,
23
+ * retry, and remove actions, and the reason sending waits until it is done.
24
+ */
25
+export function useProjectCloneBanner(activeProjectRef: ScopedProjectRef | null) {
26
+ const activeProjectClone = useProjectClone(activeProjectRef);
27
+ const cancelProjectClone = useAtomCommand(sourceControlEnvironment.cancelProjectClone, {
28
+ reportFailure: false,
29
+ });
30
+ const retryProjectClone = useAtomCommand(sourceControlEnvironment.retryProjectClone, {
31
+ reportFailure: false,
32
+ });
33
+ const removeClonedProject = useRemoveClonedProject();
34
+ const runProjectCloneAction = async (
35
+ title: string,
36
+ action: () => Promise<AtomCommandResult<unknown, unknown>>,
37
+ ): Promise<void> => {
38
+ const result = await action();
39
+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
40
+ const error = squashAtomCommandFailure(result);
41
+ toastManager.add(
42
+ stackedThreadToast({
43
+ type: "error",
44
+ title,
45
+ description: error instanceof Error ? error.message : "An error occurred.",
46
+ }),
47
+ );
48
+ }
49
+ };
50
+ const runProjectCloneActionStable = useStableCallback(runProjectCloneAction);
51
+ const activeProjectFileCopy = useProjectFileCopy(activeProjectRef);
52
+ const projectCloneSendBlockReason =
53
+ activeProjectClone?.phase === "running"
54
+ ? "Cloning repository"
55
+ : activeProjectClone !== null && activeProjectClone.phase !== "done"
56
+ ? "Repository not cloned"
57
+ : activeProjectFileCopy?.phase === "copying"
58
+ ? "Copying files"
59
+ : null;
60
+ const projectCloneBannerItem = (() => {
61
+ if (activeProjectFileCopy?.phase === "failed" && activeProjectRef) {
62
+ return {
63
+ id: `project-file-copy:${activeProjectRef.projectId}`,
64
+ variant: "error",
65
+ icon: <DownloadIcon />,
66
+ title: activeProjectFileCopy.title,
67
+ description: activeProjectFileCopy.failures.join("\n"),
68
+ onDismiss: () => dismissProjectFileCopy(activeProjectRef),
69
+ };
70
+ }
71
+ if (!activeProjectClone || !activeProjectRef || activeProjectClone.phase === "done") {
72
+ return null;
73
+ }
74
+ const name = projectCloneDisplayName(activeProjectClone);
75
+ const { environmentId, projectId } = activeProjectRef;
76
+ if (activeProjectClone.phase === "running") {
77
+ return {
78
+ id: `project-clone:${projectId}`,
79
+ variant: "info",
80
+ priority: "activity",
81
+ icon: <DownloadIcon />,
82
+ title: `Cloning ${name}`,
83
+ description: projectCloneProgressSummary(activeProjectClone),
84
+ actions: (
85
+ <Button
86
+ size="xs"
87
+ variant="ghost"
88
+ onClick={() =>
89
+ void runProjectCloneActionStable("Failed to cancel clone", () =>
90
+ cancelProjectClone({ environmentId, input: { projectId } }),
91
+ )
92
+ }
93
+ >
94
+ Cancel
95
+ </Button>
96
+ ),
97
+ };
98
+ }
99
+ const cancelled = activeProjectClone.phase === "cancelled";
100
+ return {
101
+ id: `project-clone:${projectId}`,
102
+ variant: cancelled ? "warning" : "error",
103
+ icon: <DownloadIcon />,
104
+ title: cancelled ? `Cancelled cloning ${name}` : `Failed to clone ${name}`,
105
+ description: cancelled ? "Retry to bring in the repository." : activeProjectClone.error,
106
+ actions: (
107
+ <>
108
+ <Button
109
+ size="xs"
110
+ variant="ghost"
111
+ onClick={() => void removeClonedProject({ environmentId, projectId })}
112
+ >
113
+ Remove project
114
+ </Button>
115
+ <Button
116
+ size="xs"
117
+ variant="ghost"
118
+ onClick={() =>
119
+ void runProjectCloneActionStable("Failed to retry clone", () =>
120
+ retryProjectClone({ environmentId, input: { projectId } }),
121
+ )
122
+ }
123
+ >
124
+ Retry
125
+ </Button>
126
+ </>
127
+ ),
128
+ };
129
+ })() as ComposerBannerStackItem | null;
130
+ return {
131
+ projectCloneBannerItem,
132
+ projectCloneSendBlockReason,
133
+ };
134
+}