codacus commited on
Commit
0a4ef11
·
unverified ·
2 Parent(s): 0a2e0f2 bf7e500

Merge pull request #597 from thecodacus/add-loading-on-git-import-from-url

Browse files
app/commit.json CHANGED
@@ -1 +1 @@
1
- { "commit": "43e1f436f57fc4adb43b5481b403967803d4786d" , "version": "0.0.1" }
 
1
+ { "commit": "43e1f436f57fc4adb43b5481b403967803d4786d" , "version": "0.0.1" }
app/components/git/GitUrlImport.client.tsx CHANGED
@@ -8,6 +8,8 @@ import { Chat } from '~/components/chat/Chat.client';
8
  import { useGit } from '~/lib/hooks/useGit';
9
  import { useChatHistory } from '~/lib/persistence';
10
  import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
 
 
11
 
12
  const IGNORE_PATTERNS = [
13
  'node_modules/**',
@@ -38,6 +40,7 @@ export function GitUrlImport() {
38
  const { ready: historyReady, importChat } = useChatHistory();
39
  const { ready: gitReady, gitClone } = useGit();
40
  const [imported, setImported] = useState(false);
 
41
 
42
  const importRepo = async (repoUrl?: string) => {
43
  if (!gitReady && !historyReady) {
@@ -109,9 +112,23 @@ ${file.content}
109
  return;
110
  }
111
 
112
- importRepo(url);
 
 
 
 
 
113
  setImported(true);
114
  }, [searchParams, historyReady, gitReady, imported]);
115
 
116
- return <ClientOnly fallback={<BaseChat />}>{() => <Chat />}</ClientOnly>;
 
 
 
 
 
 
 
 
 
117
  }
 
8
  import { useGit } from '~/lib/hooks/useGit';
9
  import { useChatHistory } from '~/lib/persistence';
10
  import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
11
+ import { LoadingOverlay } from '~/components/ui/LoadingOverlay';
12
+ import { toast } from 'react-toastify';
13
 
14
  const IGNORE_PATTERNS = [
15
  'node_modules/**',
 
40
  const { ready: historyReady, importChat } = useChatHistory();
41
  const { ready: gitReady, gitClone } = useGit();
42
  const [imported, setImported] = useState(false);
43
+ const [loading, setLoading] = useState(true);
44
 
45
  const importRepo = async (repoUrl?: string) => {
46
  if (!gitReady && !historyReady) {
 
112
  return;
113
  }
114
 
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
+ });
121
  setImported(true);
122
  }, [searchParams, historyReady, gitReady, imported]);
123
 
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
+ );
134
  }
app/components/ui/LoadingOverlay.tsx ADDED
@@ -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 CHANGED
@@ -4,6 +4,7 @@ import { ClientOnly } from 'remix-utils/client-only';
4
  import { BaseChat } from '~/components/chat/BaseChat';
5
  import { GitUrlImport } from '~/components/git/GitUrlImport.client';
6
  import { Header } from '~/components/header/Header';
 
7
 
8
  export const meta: MetaFunction = () => {
9
  return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
@@ -15,7 +16,8 @@ export async function loader(args: LoaderFunctionArgs) {
15
 
16
  export default function Index() {
17
  return (
18
- <div className="flex flex-col h-full w-full">
 
19
  <Header />
20
  <ClientOnly fallback={<BaseChat />}>{() => <GitUrlImport />}</ClientOnly>
21
  </div>
 
4
  import { BaseChat } from '~/components/chat/BaseChat';
5
  import { GitUrlImport } from '~/components/git/GitUrlImport.client';
6
  import { Header } from '~/components/header/Header';
7
+ import BackgroundRays from '~/components/ui/BackgroundRays';
8
 
9
  export const meta: MetaFunction = () => {
10
  return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
 
16
 
17
  export default function Index() {
18
  return (
19
+ <div className="flex flex-col h-full w-full bg-bolt-elements-background-depth-1">
20
+ <BackgroundRays />
21
  <Header />
22
  <ClientOnly fallback={<BaseChat />}>{() => <GitUrlImport />}</ClientOnly>
23
  </div>