Start fixing loading state of ProjectView

This commit is contained in:
Alex Gleason committed 2025-09-13 18:30:19 -05:00
1 parent 022efa74c3
commit 0edef42bf2
1 file changed
+162 -102
+162 -102
View File
@@ -8,6 +8,7 @@ import { ProjectSidebar } from '@/components/ProjectSidebar';
import { ProjectInfoDialog } from '@/components/ProjectInfoDialog'; import { ProjectInfoDialog } from '@/components/ProjectInfoDialog';
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable'; import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { ArrowLeft, MessageSquare, Eye, Code, Menu, Columns2 } from 'lucide-react'; import { ArrowLeft, MessageSquare, Eye, Code, Menu, Columns2 } from 'lucide-react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { ActionsMenu } from '@/components/ActionsMenu'; import { ActionsMenu } from '@/components/ActionsMenu';
@@ -175,15 +176,7 @@ export function ProjectView() {
navigate('/'); navigate('/');
}; };
if (isLoading) { if (!project && !isLoading) {
return (
<div className="min-h-screen bg-background flex items-center justify-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
</div>
);
}
if (!project) {
return ( return (
<div className="min-h-screen bg-background flex items-center justify-center"> <div className="min-h-screen bg-background flex items-center justify-center">
<div className="text-center"> <div className="text-center">
@@ -210,34 +203,47 @@ export function ProjectView() {
<Menu className="h-4 w-4" /> <Menu className="h-4 w-4" />
</Button> </Button>
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">
<Button {project ? (
variant="ghost" <Button
className="p-0 h-auto text-sm font-semibold truncate hover:bg-transparent hover:text-primary" variant="ghost"
onClick={() => setIsProjectInfoOpen(true)} className="p-0 h-auto text-sm font-semibold truncate hover:bg-transparent hover:text-primary"
> onClick={() => setIsProjectInfoOpen(true)}
{project.name} >
</Button> {project.name}
</Button>
) : (
<Skeleton className="h-5 w-32" />
)}
</div> </div>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<StarButton {project ? (
projectId={project.id} <>
projectName={project.name} <StarButton
className="h-8 w-8" projectId={project.id}
/> projectName={project.name}
<ActionsMenu className="h-8 w-8"
projectId={project.id} />
projectName={project.name} <ActionsMenu
onNewChat={handleNewChat} projectId={project.id}
onBuild={runBuild} projectName={project.name}
onDeploy={runDeploy} onNewChat={handleNewChat}
isLoading={isAILoading} onBuild={runBuild}
isBuildLoading={isBuildLoading} onDeploy={runDeploy}
isDeployLoading={isDeployLoading} isLoading={isAILoading}
onFirstInteraction={handleFirstInteraction} isBuildLoading={isBuildLoading}
onProjectDeleted={handleProjectDeleted} isDeployLoading={isDeployLoading}
/> onFirstInteraction={handleFirstInteraction}
onProjectDeleted={handleProjectDeleted}
/>
</>
) : (
<>
<Skeleton className="h-8 w-8 rounded" />
<Skeleton className="h-8 w-8 rounded" />
</>
)}
</div> </div>
</header> </header>
@@ -270,24 +276,40 @@ export function ProjectView() {
<div className="flex-1 overflow-hidden"> <div className="flex-1 overflow-hidden">
{mobileView === 'chat' && ( {mobileView === 'chat' && (
<ChatPane project ? (
ref={chatPaneRef} <ChatPane
projectId={project.id} ref={chatPaneRef}
onNewChat={handleNewChat} projectId={project.id}
onBuild={runBuild} onNewChat={handleNewChat}
onDeploy={runDeploy} onBuild={runBuild}
onFirstInteraction={handleFirstInteraction} onDeploy={runDeploy}
onLoadingChange={handleAILoadingChange} onFirstInteraction={handleFirstInteraction}
isLoading={isAILoading} onLoadingChange={handleAILoadingChange}
isBuildLoading={isBuildLoading} isLoading={isAILoading}
isDeployLoading={isDeployLoading} isBuildLoading={isBuildLoading}
/> isDeployLoading={isDeployLoading}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-12 w-full" />
<Skeleton className="h-8 w-3/4" />
<Skeleton className="h-8 w-1/2" />
<Skeleton className="h-32 w-full" />
</div>
)
)} )}
{(mobileView === 'preview' || mobileView === 'code') && ( {(mobileView === 'preview' || mobileView === 'code') && (
<PreviewPane project ? (
projectId={project.id} <PreviewPane
activeTab={mobileView} projectId={project.id}
/> activeTab={mobileView}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-8 w-32" />
<Skeleton className="h-full w-full" />
</div>
)
)} )}
</div> </div>
@@ -298,6 +320,7 @@ export function ProjectView() {
size="sm" size="sm"
onClick={() => setMobileView('chat')} onClick={() => setMobileView('chat')}
className="flex-1 rounded-none" className="flex-1 rounded-none"
disabled={!project}
> >
<MessageSquare className="h-4 w-4 mr-1" /> <MessageSquare className="h-4 w-4 mr-1" />
Chat Chat
@@ -307,6 +330,7 @@ export function ProjectView() {
size="sm" size="sm"
onClick={() => setMobileView('preview')} onClick={() => setMobileView('preview')}
className="flex-1 rounded-none" className="flex-1 rounded-none"
disabled={!project}
> >
<Eye className="h-4 w-4 mr-1" /> <Eye className="h-4 w-4 mr-1" />
Preview Preview
@@ -316,10 +340,11 @@ export function ProjectView() {
size="sm" size="sm"
onClick={() => setMobileView('code')} onClick={() => setMobileView('code')}
className="flex-1 rounded-none" className="flex-1 rounded-none"
disabled={!project}
> >
<Code className="h-4 w-4 mr-1" /> <Code className="h-4 w-4 mr-1" />
Code Code
{mobileView !== 'code' && ( {mobileView !== 'code' && project && (
<GitStatusIndicator projectId={project.id} className="ml-1" /> <GitStatusIndicator projectId={project.id} className="ml-1" />
)} )}
</Button> </Button>
@@ -327,11 +352,13 @@ export function ProjectView() {
</div> </div>
{/* Project Info Dialog */} {/* Project Info Dialog */}
<ProjectInfoDialog {project && (
project={project} <ProjectInfoDialog
open={isProjectInfoOpen} project={project}
onOpenChange={setIsProjectInfoOpen} open={isProjectInfoOpen}
/> onOpenChange={setIsProjectInfoOpen}
/>
)}
</div> </div>
); );
} }
@@ -339,7 +366,7 @@ export function ProjectView() {
return ( return (
<div className="h-screen flex bg-background"> <div className="h-screen flex bg-background">
{/* Fixed Sidebar */} {/* Fixed Sidebar */}
<div className={`w-80 border-r bg-sidebar transition-all duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}> <div className={`w-80 border-r bg-sidebar duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
<ProjectSidebar <ProjectSidebar
selectedProject={project} selectedProject={project}
onSelectProject={(selectedProject) => { onSelectProject={(selectedProject) => {
@@ -380,53 +407,75 @@ export function ProjectView() {
{/* Center - Project title */} {/* Center - Project title */}
<div className="flex-1 min-w-0 ml-2 px-4"> <div className="flex-1 min-w-0 ml-2 px-4">
<div className="flex items-center justify-center md:justify-start"> <div className="flex items-center justify-center md:justify-start">
<Button {project ? (
variant="ghost" <Button
className="p-0 h-auto font-semibold text-lg truncate hover:bg-transparent hover:text-primary" variant="ghost"
onClick={() => setIsProjectInfoOpen(true)} className="p-0 h-auto font-semibold text-lg truncate hover:bg-transparent hover:text-primary"
> onClick={() => setIsProjectInfoOpen(true)}
{project.name} >
</Button> {project.name}
</Button>
) : (
<Skeleton className="h-6 w-40" />
)}
</div> </div>
</div> </div>
{/* Right side - Star and Actions Menu */} {/* Right side - Star and Actions Menu */}
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<StarButton {project ? (
projectId={project.id} <>
projectName={project.name} <StarButton
className="h-8 w-8" projectId={project.id}
/> projectName={project.name}
<ActionsMenu className="h-8 w-8"
projectId={project.id} />
projectName={project.name} <ActionsMenu
onNewChat={handleNewChat} projectId={project.id}
onBuild={runBuild} projectName={project.name}
onDeploy={runDeploy} onNewChat={handleNewChat}
isLoading={isAILoading} onBuild={runBuild}
isBuildLoading={isBuildLoading} onDeploy={runDeploy}
isDeployLoading={isDeployLoading} isLoading={isAILoading}
onFirstInteraction={handleFirstInteraction} isBuildLoading={isBuildLoading}
onProjectDeleted={handleProjectDeleted} isDeployLoading={isDeployLoading}
/> onFirstInteraction={handleFirstInteraction}
onProjectDeleted={handleProjectDeleted}
/>
</>
) : (
<>
<Skeleton className="h-8 w-8 rounded" />
<Skeleton className="h-8 w-8 rounded" />
</>
)}
</div> </div>
</div> </div>
</div> </div>
{/* Chat Content */} {/* Chat Content */}
<div className="flex-1 overflow-hidden"> <div className="flex-1 overflow-hidden">
<ChatPane {project ? (
ref={chatPaneRef} <ChatPane
projectId={project.id} ref={chatPaneRef}
onNewChat={handleNewChat} projectId={project.id}
onBuild={runBuild} onNewChat={handleNewChat}
onDeploy={runDeploy} onBuild={runBuild}
onFirstInteraction={handleFirstInteraction} onDeploy={runDeploy}
onLoadingChange={handleAILoadingChange} onFirstInteraction={handleFirstInteraction}
isLoading={isAILoading} onLoadingChange={handleAILoadingChange}
isBuildLoading={isBuildLoading} isLoading={isAILoading}
isDeployLoading={isDeployLoading} isBuildLoading={isBuildLoading}
/> isDeployLoading={isDeployLoading}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-12 w-full" />
<Skeleton className="h-8 w-3/4" />
<Skeleton className="h-8 w-1/2" />
<Skeleton className="h-32 w-full" />
</div>
)}
</div> </div>
</div> </div>
</ResizablePanel> </ResizablePanel>
@@ -445,6 +494,7 @@ export function ProjectView() {
variant={activeTab === 'preview' ? 'default' : 'ghost'} variant={activeTab === 'preview' ? 'default' : 'ghost'}
size="sm" size="sm"
onClick={() => setActiveTab('preview')} onClick={() => setActiveTab('preview')}
disabled={!project}
> >
Preview Preview
</Button> </Button>
@@ -453,9 +503,10 @@ export function ProjectView() {
size="sm" size="sm"
onClick={() => setActiveTab('code')} onClick={() => setActiveTab('code')}
className="gap-2" className="gap-2"
disabled={!project}
> >
Code Code
{activeTab !== 'code' && ( {activeTab !== 'code' && project && (
<GitStatusIndicator projectId={project.id} /> <GitStatusIndicator projectId={project.id} />
)} )}
</Button> </Button>
@@ -465,10 +516,17 @@ export function ProjectView() {
{/* Preview Content */} {/* Preview Content */}
<div className="flex-1 overflow-hidden"> <div className="flex-1 overflow-hidden">
<PreviewPane {project ? (
projectId={project.id} <PreviewPane
activeTab={activeTab} projectId={project.id}
/> activeTab={activeTab}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-8 w-32" />
<Skeleton className="h-full w-full" />
</div>
)}
</div> </div>
</div> </div>
</ResizablePanel> </ResizablePanel>
@@ -477,11 +535,13 @@ export function ProjectView() {
</div> </div>
{/* Project Info Dialog */} {/* Project Info Dialog */}
<ProjectInfoDialog {project && (
project={project} <ProjectInfoDialog
open={isProjectInfoOpen} project={project}
onOpenChange={setIsProjectInfoOpen} open={isProjectInfoOpen}
/> onOpenChange={setIsProjectInfoOpen}
/>
)}
</div> </div>
); );
} }