Spaces:
Running
Running
fix
Browse files- frontend/src/app/page.tsx +15 -6
frontend/src/app/page.tsx
CHANGED
|
@@ -23,6 +23,7 @@ export default function Home() {
|
|
| 23 |
const [currentRepoId, setCurrentRepoId] = useState<string | null>(null); // Track imported/deployed space
|
| 24 |
const [username, setUsername] = useState<string | null>(null); // Track current user
|
| 25 |
const [pendingPR, setPendingPR] = useState<{ repoId: string; language: Language } | null>(null); // Track pending PR after redesign
|
|
|
|
| 26 |
|
| 27 |
// Landing page state - show landing page if no messages exist
|
| 28 |
const [showLandingPage, setShowLandingPage] = useState(true);
|
|
@@ -345,10 +346,16 @@ export default function Home() {
|
|
| 345 |
});
|
| 346 |
|
| 347 |
// Check if we need to create a PR (redesign with PR option)
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
}
|
| 353 |
},
|
| 354 |
// onError
|
|
@@ -781,10 +788,12 @@ export default function Home() {
|
|
| 781 |
// Hide landing page immediately for smooth transition
|
| 782 |
setShowLandingPage(false);
|
| 783 |
|
| 784 |
-
// If shouldCreatePR is true, set pending PR state
|
| 785 |
if (shouldCreatePR && repoId) {
|
| 786 |
console.log('[PR] Setting pending PR for:', repoId);
|
| 787 |
-
|
|
|
|
|
|
|
| 788 |
}
|
| 789 |
|
| 790 |
// Send the message with the selected language and model
|
|
|
|
| 23 |
const [currentRepoId, setCurrentRepoId] = useState<string | null>(null); // Track imported/deployed space
|
| 24 |
const [username, setUsername] = useState<string | null>(null); // Track current user
|
| 25 |
const [pendingPR, setPendingPR] = useState<{ repoId: string; language: Language } | null>(null); // Track pending PR after redesign
|
| 26 |
+
const pendingPRRef = useRef<{ repoId: string; language: Language } | null>(null); // Ref for immediate access
|
| 27 |
|
| 28 |
// Landing page state - show landing page if no messages exist
|
| 29 |
const [showLandingPage, setShowLandingPage] = useState(true);
|
|
|
|
| 346 |
});
|
| 347 |
|
| 348 |
// Check if we need to create a PR (redesign with PR option)
|
| 349 |
+
console.log('[PR] onComplete - Checking pendingPR ref:', pendingPRRef.current);
|
| 350 |
+
console.log('[PR] onComplete - Checking pendingPR state:', pendingPR);
|
| 351 |
+
const prInfo = pendingPRRef.current;
|
| 352 |
+
if (prInfo) {
|
| 353 |
+
console.log('[PR] Creating pull request for:', prInfo.repoId);
|
| 354 |
+
createPullRequestAfterGeneration(prInfo.repoId, code, prInfo.language);
|
| 355 |
+
setPendingPR(null); // Clear state
|
| 356 |
+
pendingPRRef.current = null; // Clear ref
|
| 357 |
+
} else {
|
| 358 |
+
console.log('[PR] No pending PR - skipping PR creation');
|
| 359 |
}
|
| 360 |
},
|
| 361 |
// onError
|
|
|
|
| 788 |
// Hide landing page immediately for smooth transition
|
| 789 |
setShowLandingPage(false);
|
| 790 |
|
| 791 |
+
// If shouldCreatePR is true, set pending PR state and ref
|
| 792 |
if (shouldCreatePR && repoId) {
|
| 793 |
console.log('[PR] Setting pending PR for:', repoId);
|
| 794 |
+
const prInfo = { repoId, language };
|
| 795 |
+
setPendingPR(prInfo);
|
| 796 |
+
pendingPRRef.current = prInfo; // Set ref immediately for synchronous access
|
| 797 |
}
|
| 798 |
|
| 799 |
// Send the message with the selected language and model
|