support PRs
Browse filesFiles changed (2)
21 unmodified lines222324252627313 unmodified lines34134234334434534670 unmodified lines417418419420421422290 unmodified lines71371471571671771871972072172272372421 unmodified linesconst [isAuthenticated, setIsAuthenticated] = useState(false);const [currentRepoId, setCurrentRepoId] = useState<string | null>(null); // Track imported/deployed spaceconst [username, setUsername] = useState<string | null>(null); // Track current user// Landing page state - show landing page if no messages existconst [showLandingPage, setShowLandingPage] = useState(true);313 unmodified lines};return newMessages;});},// onError(error: string) => {70 unmodified lines}};const handleDeploy = async () => {console.log('[Deploy] π¬ handleDeploy called');console.log('[Deploy] generatedCode exists?', !!generatedCode);290 unmodified lines};// Handle landing page prompt submissionconst handleLandingPageStart = async (prompt: string, language: Language, modelId: string, repoId?: string) => {// Hide landing page immediately for smooth transitionsetShowLandingPage(false);// Send the message with the selected language and model// Pass repoId if provided (for imported/duplicated spaces)await handleSendMessage(prompt, language, modelId, repoId);};// Resize handlers for chat sidebar (desktop only)21 unmodified lines22232425262728313 unmodified lines34234334434534634734834935035135235335470 unmodified lines425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485290 unmodified lines77677777877978078178278378478578678778878979079179279379421 unmodified linesconst [isAuthenticated, setIsAuthenticated] = useState(false);const [currentRepoId, setCurrentRepoId] = useState<string | null>(null); // Track imported/deployed spaceconst [username, setUsername] = useState<string | null>(null); // Track current userconst [pendingPR, setPendingPR] = useState<{ repoId: string; language: Language } | null>(null); // Track pending PR after redesign// Landing page state - show landing page if no messages existconst [showLandingPage, setShowLandingPage] = useState(true);313 unmodified lines};return newMessages;});// Check if we need to create a PR (redesign with PR option)if (pendingPR) {console.log('[PR] Creating pull request for:', pendingPR.repoId);createPullRequestAfterGeneration(pendingPR.repoId, code, pendingPR.language);setPendingPR(null); // Clear pending PR}},// onError(error: string) => {70 unmodified lines}};const createPullRequestAfterGeneration = async (repoId: string, code: string, language: Language) => {try {console.log('[PR] Creating PR on:', repoId);// Update message to show PR creation in progresssetMessages((prev) => {const newMessages = [...prev];newMessages[newMessages.length - 1] = {...newMessages[newMessages.length - 1],content: 'β Code generated successfully!\n\nπ Creating Pull Request...',};return newMessages;});const prResult = await apiClient.createPullRequest(repoId,code,language,'π¨ Redesign from AnyCoder',undefined);if (prResult.success && prResult.pr_url) {console.log('[PR] Pull Request created:', prResult.pr_url);// Update message with PR linksetMessages((prev) => {const newMessages = [...prev];newMessages[newMessages.length - 1] = {...newMessages[newMessages.length - 1],content: `β Code generated successfully!\n\nβ Pull Request created! [View PR](${prResult.pr_url})`,};return newMessages;});// Open PR in new tabwindow.open(prResult.pr_url, '_blank');} else {throw new Error(prResult.message || 'Failed to create Pull Request');}} catch (error: any) {console.error('[PR] Failed to create Pull Request:', error);// Update message with errorsetMessages((prev) => {const newMessages = [...prev];newMessages[newMessages.length - 1] = {...newMessages[newMessages.length - 1],content: `β Code generated successfully!\n\nβ Failed to create Pull Request: ${error.message || 'Unknown error'}`,};return newMessages;});}};const handleDeploy = async () => {console.log('[Deploy] π¬ handleDeploy called');console.log('[Deploy] generatedCode exists?', !!generatedCode);290 unmodified lines};// Handle landing page prompt submissionconst handleLandingPageStart = async (prompt: string, language: Language, modelId: string, repoId?: string, shouldCreatePR?: boolean) => {// Hide landing page immediately for smooth transitionsetShowLandingPage(false);// If shouldCreatePR is true, set pending PR stateif (shouldCreatePR && repoId) {console.log('[PR] Setting pending PR for:', repoId);setPendingPR({ repoId, language });}// Send the message with the selected language and model// Don't pass repoId to handleSendMessage when creating PR (we want to generate code first, then create PR)await handleSendMessage(prompt, language, modelId, shouldCreatePR ? undefined : repoId);};// Resize handlers for chat sidebar (desktop only)
14 unmodified lines15161718192021414 unmodified lines43643743843944044144214 unmodified linesimport type { OAuthUserInfo } from '@/lib/auth';interface LandingPageProps {onStart: (prompt: string, language: Language, modelId: string, repoId?: string) => void;onImport?: (code: string, language: Language, importUrl?: string) => void;isAuthenticated: boolean;initialLanguage?: Language;414 unmodified linesif (onStart) {console.log('[Redesign] Will create PR - not passing repo ID');console.log('[Redesign] Using Claude-Sonnet-4.5 for redesign');onStart(redesignPrompt, result.language || 'html', 'claude-sonnet-4.5', undefined);}console.log('[Redesign] Will create PR after code generation completes');14 unmodified lines15161718192021414 unmodified lines43643743843944044144214 unmodified linesimport type { OAuthUserInfo } from '@/lib/auth';interface LandingPageProps {onStart: (prompt: string, language: Language, modelId: string, repoId?: string, shouldCreatePR?: boolean) => void;onImport?: (code: string, language: Language, importUrl?: string) => void;isAuthenticated: boolean;initialLanguage?: Language;414 unmodified linesif (onStart) {console.log('[Redesign] Will create PR - not passing repo ID');console.log('[Redesign] Using Claude-Sonnet-4.5 for redesign');onStart(redesignPrompt, result.language || 'html', 'claude-sonnet-4.5', repoId, true); // Pass true for shouldCreatePR}console.log('[Redesign] Will create PR after code generation completes');
frontend/src/app/page.tsx+73-3
frontend/src/components/LandingPage.tsx+2-2