Fix state issues navigating between projects

This commit is contained in:
Alex Gleason committed 2025-09-23 16:14:51 -05:00
1 parent db697d0a85
commit 9ea9a4ac4b
2 files changed
+17

No files matched your search

@@ -377,6 +377,13 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
}
}, [selectedFile, loadFileContent]);
// Reset selected file when projectId changes
useEffect(() => {
setSelectedFile(null);
setFileContent('');
setMobileCodeView('explorer');
}, [projectId]);
useEffect(() => {
checkForBuiltProject();
}, [checkForBuiltProject]);
+10
View File
@@ -71,6 +71,16 @@ export function ProjectView() {
loadProject();
}, [loadProject]);
// Reset view state when projectId changes
useEffect(() => {
if (projectId) {
// Reset to preview tab if the new project is previewable, otherwise code
setActiveTab(isPreviewable ? 'preview' : 'code');
// Reset mobile view to chat when switching projects
setMobileView('chat');
}
}, [projectId, isPreviewable]);
// Switch away from preview mode if project is not previewable
useEffect(() => {
if (mobileView === 'preview' && !isPreviewable) {