1+ import { useProjectCloneBanner } from "./chat/useProjectCloneBanner" ;
12import { useAttachmentPreviewHandoff } from "./chat/useAttachmentPreviewHandoff" ;
23import { useTimelineRewind } from "./chat/useTimelineRewind" ;
34import { useThreadLifecycle } from "./chat/useThreadLifecycle" ;
@@ -175,7 +176,7 @@ import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
175176import { isEditableFocused } from "../lib/editableFocus" ;
176177import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings" ;
177178import { shortcutLabelForCommand } from "../keybindings" ;
178- import { PaperclipIcon , ChevronDownIcon , DownloadIcon } from "lucide-react" ;
179+ import { PaperclipIcon , ChevronDownIcon } from "lucide-react" ;
179180import { cn } from "~/lib/utils" ;
180181import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar" ;
181182import { stackedThreadToast , toastManager } from "./ui/toast" ;
@@ -197,7 +198,6 @@ import {
197198import { useNowMinute } from "../hooks/useNowMinute" ;
198199import { usePanelAnimationSettings , usePanelPresence } from "../panelAnimations" ;
199200import { useNewThreadHandler } from "../hooks/useHandleNewThread" ;
200- import { useRemoveClonedProject } from "../hooks/useRemoveClonedProject" ;
201201import { useOpenPanelPullRequestUrl } from "../hooks/useOpenPanelPullRequestUrl" ;
202202import { resolveAppModelSelectionForInstance } from "../modelSelection" ;
203203import { isPreviewFocused } from "../lib/previewFocus" ;
@@ -234,10 +234,6 @@ import {
234234import { threadEnvironment } from "../state/threads" ;
235235import { resolveProviderSkillsForCwd } from "@t3tools/client-runtime/providerSkills" ;
236236import { vcsEnvironment } from "../state/vcs" ;
237- import { sourceControlEnvironment } from "../state/sourceControl" ;
238- import { useProjectClone } from "../state/projectClones" ;
239- import { projectCloneDisplayName , projectCloneProgressSummary } from "@t3tools/contracts" ;
240- import { dismissProjectFileCopy , useProjectFileCopy } from "../lib/addProjectToMachine" ;
241237import {
242238 type EnvironmentPresentation ,
243239 useEnvironmentProviders ,
@@ -1116,110 +1112,8 @@ export default function ChatView(props: ChatViewProps) {
11161112 activeProject ?? undefined ,
11171113 ) ;
11181114 const activeProjectScripts = activeProject ? resolveProjectScripts ( settings , activeProject ) : [ ] ;
1119- const activeProjectClone = useProjectClone ( activeProjectRef ) ;
1120- const cancelProjectClone = useAtomCommand ( sourceControlEnvironment . cancelProjectClone , {
1121- reportFailure : false ,
1122- } ) ;
1123- const retryProjectClone = useAtomCommand ( sourceControlEnvironment . retryProjectClone , {
1124- reportFailure : false ,
1125- } ) ;
1126- const removeClonedProject = useRemoveClonedProject ( ) ;
1127- const runProjectCloneAction = async (
1128- title : string ,
1129- action : ( ) => Promise < AtomCommandResult < unknown , unknown > > ,
1130- ) : Promise < void > => {
1131- const result = await action ( ) ;
1132- if ( result . _tag === "Failure" && ! isAtomCommandInterrupted ( result ) ) {
1133- const error = squashAtomCommandFailure ( result ) ;
1134- toastManager . add (
1135- stackedThreadToast ( {
1136- type : "error" ,
1137- title,
1138- description : error instanceof Error ? error . message : "An error occurred." ,
1139- } ) ,
1140- ) ;
1141- }
1142- } ;
1143- const runProjectCloneActionStable = useStableCallback ( runProjectCloneAction ) ;
1144- const activeProjectFileCopy = useProjectFileCopy ( activeProjectRef ) ;
1145- const projectCloneSendBlockReason =
1146- activeProjectClone ?. phase === "running"
1147- ? "Cloning repository"
1148- : activeProjectClone !== null && activeProjectClone . phase !== "done"
1149- ? "Repository not cloned"
1150- : activeProjectFileCopy ?. phase === "copying"
1151- ? "Copying files"
1152- : null ;
1153- const projectCloneBannerItem = ( ( ) => {
1154- if ( activeProjectFileCopy ?. phase === "failed" && activeProjectRef ) {
1155- return {
1156- id : `project-file-copy:${ activeProjectRef . projectId } ` ,
1157- variant : "error" ,
1158- icon : < DownloadIcon /> ,
1159- title : activeProjectFileCopy . title ,
1160- description : activeProjectFileCopy . failures . join ( "\n" ) ,
1161- onDismiss : ( ) => dismissProjectFileCopy ( activeProjectRef ) ,
1162- } ;
1163- }
1164- if ( ! activeProjectClone || ! activeProjectRef || activeProjectClone . phase === "done" ) {
1165- return null ;
1166- }
1167- const name = projectCloneDisplayName ( activeProjectClone ) ;
1168- const { environmentId, projectId } = activeProjectRef ;
1169- if ( activeProjectClone . phase === "running" ) {
1170- return {
1171- id : `project-clone:${ projectId } ` ,
1172- variant : "info" ,
1173- priority : "activity" ,
1174- icon : < DownloadIcon /> ,
1175- title : `Cloning ${ name } ` ,
1176- description : projectCloneProgressSummary ( activeProjectClone ) ,
1177- actions : (
1178- < Button
1179- size = "xs"
1180- variant = "ghost"
1181- onClick = { ( ) =>
1182- void runProjectCloneActionStable ( "Failed to cancel clone" , ( ) =>
1183- cancelProjectClone ( { environmentId, input : { projectId } } ) ,
1184- )
1185- }
1186- >
1187- Cancel
1188- </ Button >
1189- ) ,
1190- } ;
1191- }
1192- const cancelled = activeProjectClone . phase === "cancelled" ;
1193- return {
1194- id : `project-clone:${ projectId } ` ,
1195- variant : cancelled ? "warning" : "error" ,
1196- icon : < DownloadIcon /> ,
1197- title : cancelled ? `Cancelled cloning ${ name } ` : `Failed to clone ${ name } ` ,
1198- description : cancelled ? "Retry to bring in the repository." : activeProjectClone . error ,
1199- actions : (
1200- < >
1201- < Button
1202- size = "xs"
1203- variant = "ghost"
1204- onClick = { ( ) => void removeClonedProject ( { environmentId, projectId } ) }
1205- >
1206- Remove project
1207- </ Button >
1208- < Button
1209- size = "xs"
1210- variant = "ghost"
1211- onClick = { ( ) =>
1212- void runProjectCloneActionStable ( "Failed to retry clone" , ( ) =>
1213- retryProjectClone ( { environmentId, input : { projectId } } ) ,
1214- )
1215- }
1216- >
1217- Retry
1218- </ Button >
1219- </ >
1220- ) ,
1221- } ;
1222- } ) ( ) as ComposerBannerStackItem | null ;
1115+ const { projectCloneBannerItem, projectCloneSendBlockReason } =
1116+ useProjectCloneBanner ( activeProjectRef ) ;
12231117 const activeProjectDefaultModelSelection = activeProjectSettings . settings . defaultModelSelection ;
12241118 const handleNewThreadInActiveProject = ( ) => {
12251119 startNewThreadForProject ( activeProjectRef , handleNewThread ) ;
0 commit comments