Skip to content

Commit 0a4ef11

Browse files
authored
Merge pull request #597 from thecodacus/add-loading-on-git-import-from-url
feat:Added backdrop and loading screen in Git clone from Url
2 parents 0a2e0f2 + bf7e500 commit 0a4ef11

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

app/commit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "commit": "43e1f436f57fc4adb43b5481b403967803d4786d" , "version": "0.0.1" }
1+
{ "commit": "43e1f436f57fc4adb43b5481b403967803d4786d" , "version": "0.0.1" }

app/components/git/GitUrlImport.client.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { Chat } from '~/components/chat/Chat.client';
88
import { useGit } from '~/lib/hooks/useGit';
99
import { useChatHistory } from '~/lib/persistence';
1010
import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
11+
import { LoadingOverlay } from '~/components/ui/LoadingOverlay';
12+
import { toast } from 'react-toastify';
1113

1214
const IGNORE_PATTERNS = [
1315
'node_modules/**',
@@ -38,6 +40,7 @@ export function GitUrlImport() {
3840
const { ready: historyReady, importChat } = useChatHistory();
3941
const { ready: gitReady, gitClone } = useGit();
4042
const [imported, setImported] = useState(false);
43+
const [loading, setLoading] = useState(true);
4144

4245
const importRepo = async (repoUrl?: string) => {
4346
if (!gitReady && !historyReady) {
@@ -109,9 +112,23 @@ ${file.content}
109112
return;
110113
}
111114

112-
importRepo(url);
115+
importRepo(url).catch((error) => {
116+
console.error('Error importing repo:', error);
117+
toast.error('Failed to import repository');
118+
setLoading(false);
119+
window.location.href = '/';
120+
});
113121
setImported(true);
114122
}, [searchParams, historyReady, gitReady, imported]);
115123

116-
return <ClientOnly fallback={<BaseChat />}>{() => <Chat />}</ClientOnly>;
124+
return (
125+
<ClientOnly fallback={<BaseChat />}>
126+
{() => (
127+
<>
128+
<Chat />
129+
{loading && <LoadingOverlay message="Please wait while we clone the repository..." />}
130+
</>
131+
)}
132+
</ClientOnly>
133+
);
117134
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const LoadingOverlay = ({ message = 'Loading...' }) => {
2+
return (
3+
<div className="fixed inset-0 flex items-center justify-center bg-black/80 z-50 backdrop-blur-sm">
4+
{/* Loading content */}
5+
<div className="relative flex flex-col items-center gap-4 p-8 rounded-lg bg-bolt-elements-background-depth-2 shadow-lg">
6+
<div
7+
className={'i-svg-spinners:90-ring-with-bg text-bolt-elements-loader-progress'}
8+
style={{ fontSize: '2rem' }}
9+
></div>
10+
<p className="text-lg text-bolt-elements-textTertiary">{message}</p>
11+
</div>
12+
</div>
13+
);
14+
};

app/routes/git.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ClientOnly } from 'remix-utils/client-only';
44
import { BaseChat } from '~/components/chat/BaseChat';
55
import { GitUrlImport } from '~/components/git/GitUrlImport.client';
66
import { Header } from '~/components/header/Header';
7+
import BackgroundRays from '~/components/ui/BackgroundRays';
78

89
export const meta: MetaFunction = () => {
910
return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
@@ -15,7 +16,8 @@ export async function loader(args: LoaderFunctionArgs) {
1516

1617
export default function Index() {
1718
return (
18-
<div className="flex flex-col h-full w-full">
19+
<div className="flex flex-col h-full w-full bg-bolt-elements-background-depth-1">
20+
<BackgroundRays />
1921
<Header />
2022
<ClientOnly fallback={<BaseChat />}>{() => <GitUrlImport />}</ClientOnly>
2123
</div>

0 commit comments

Comments
 (0)