From 4b1c3ee381169e9c459baf4362f5ce83d1165007 Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Mon, 15 Sep 2025 21:54:14 -0700 Subject: [PATCH 1/2] allow direct clone from url --- src/pages/Clone.tsx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/pages/Clone.tsx b/src/pages/Clone.tsx index b606cce8..02fdce39 100644 --- a/src/pages/Clone.tsx +++ b/src/pages/Clone.tsx @@ -1,5 +1,5 @@ -import { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useState, useEffect } from 'react'; +import { useNavigate, useSearchParams } from 'react-router-dom'; import { AppLayout } from '@/components/AppLayout'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; @@ -26,6 +26,7 @@ export default function Clone() { const [isCloning, setIsCloning] = useState(false); const [error, setError] = useState(null); const navigate = useNavigate(); + const [searchParams] = useSearchParams(); const projectsManager = useProjectsManager(); const { toast } = useToast(); const { nostr } = useNostr(); @@ -35,6 +36,18 @@ export default function Clone() { description: 'Import a Git repository into your Shakespeare workspace', }); + // Initialize repoUrl from URL parameters and auto-import if URL is provided + useEffect(() => { + const urlParam = searchParams.get('url'); + if (urlParam) { + const decodedUrl = decodeURIComponent(urlParam); + setRepoUrl(decodedUrl); + + // Automatically start the clone process with the URL directly + handleClone(decodedUrl); + } + }, [searchParams]); + const extractRepoName = (url: string): string => { try { // Handle different URL formats @@ -200,13 +213,15 @@ export default function Clone() { throw lastError || new Error('All clone attempts failed'); }; - const handleClone = async () => { - if (!repoUrl.trim()) { + const handleClone = async (url?: string) => { + const targetUrl = url || repoUrl; + + if (!targetUrl.trim()) { setError('Please enter a repository URL'); return; } - if (!validateGitUrl(repoUrl)) { + if (!validateGitUrl(targetUrl)) { setError('Please enter a valid Git repository URL or Nostr clone URI (e.g., nostr://npub.../repo-name)'); return; } @@ -218,7 +233,7 @@ export default function Clone() { await projectsManager.init(); // Check if it's a Nostr clone URI - const nostrUri = await parseNostrCloneUri(repoUrl.trim()); + const nostrUri = await parseNostrCloneUri(targetUrl.trim()); if (nostrUri) { // Handle Nostr clone URI @@ -243,8 +258,8 @@ export default function Clone() { navigate(`/project/${project.id}`); } else { // Handle regular Git URL - const repoName = extractRepoName(repoUrl); - const project = await projectsManager.cloneProject(repoName, repoUrl.trim()); + const repoName = extractRepoName(targetUrl); + const project = await projectsManager.cloneProject(repoName, targetUrl.trim()); toast({ title: "Repository imported successfully", From dd5c7b22be0fcee8702495f056b37fd1f9e3e646 Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Tue, 16 Sep 2025 23:09:28 -0700 Subject: [PATCH 2/2] address pipline onClick handler error --- src/pages/Clone.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Clone.tsx b/src/pages/Clone.tsx index 02fdce39..947b5fe7 100644 --- a/src/pages/Clone.tsx +++ b/src/pages/Clone.tsx @@ -351,7 +351,7 @@ export default function Clone() { )}