@@ -205,7 +205,7 @@ function FileExplorerContent() {
205205 // Deliberately not including forceReloadContent or currentPath in deps to avoid loops.
206206 // forceReloadContent is called explicitly or when project data changes.
207207 // currentPath changes trigger URL navigation, which leads to this effect running again via param changes.
208- } , [ project , authLoading , isLoadingProject ] ) ;
208+ } , [ project , authLoading , isLoadingProject , currentPath ] ) ; // Removed forceReloadContent from here
209209
210210
211211 const handleSaveFile = async ( ) => {
@@ -345,7 +345,7 @@ function FileExplorerContent() {
345345 < div className = "flex items-center gap-2 flex-wrap" >
346346 < Dialog open = { isCreateFileModalOpen } onOpenChange = { setIsCreateFileModalOpen } >
347347 < DialogTrigger asChild >
348- < Button variant = "outline" size = "sm" disabled = { isViewingFile } >
348+ < Button variant = "outline" size = "sm" disabled = { isViewingFile || ! project ?. githubRepoName } >
349349 < FilePlus className = "mr-2 h-4 w-4" /> Create File
350350 </ Button >
351351 </ DialogTrigger >
@@ -372,7 +372,7 @@ function FileExplorerContent() {
372372 </ Dialog >
373373 < Dialog open = { isCreateFolderModalOpen } onOpenChange = { setIsCreateFolderModalOpen } >
374374 < DialogTrigger asChild >
375- < Button variant = "outline" size = "sm" disabled = { isViewingFile } >
375+ < Button variant = "outline" size = "sm" disabled = { isViewingFile || ! project ?. githubRepoName } >
376376 < FolderPlus className = "mr-2 h-4 w-4" /> Create Folder
377377 </ Button >
378378 </ DialogTrigger >
@@ -396,7 +396,7 @@ function FileExplorerContent() {
396396 </ Dialog >
397397 < Dialog open = { isAiScaffoldModalOpen } onOpenChange = { setIsAiScaffoldModalOpen } >
398398 < DialogTrigger asChild >
399- < Button variant = "outline" size = "sm" disabled = { isViewingFile } >
399+ < Button variant = "outline" size = "sm" disabled = { isViewingFile || ! project ?. githubRepoName } >
400400 < Sparkles className = "mr-2 h-4 w-4 text-primary" /> Scaffold with AI
401401 </ Button >
402402 </ DialogTrigger >
@@ -420,7 +420,7 @@ function FileExplorerContent() {
420420 </ form >
421421 </ DialogContent >
422422 </ Dialog >
423- < Button variant = "outline" size = "sm" onClick = { ( ) => forceReloadContent ( ) } title = "Refresh content" disabled = { isLoadingPathContent } >
423+ < Button variant = "outline" size = "sm" onClick = { ( ) => forceReloadContent ( ) } title = "Refresh content" disabled = { isLoadingPathContent || ! project ?. githubRepoName } >
424424 { isLoadingPathContent ? < Loader2 className = "mr-2 h-4 w-4 animate-spin" /> : < RefreshCw className = "mr-2 h-4 w-4" /> } Refresh
425425 </ Button >
426426 </ div >
@@ -432,30 +432,32 @@ function FileExplorerContent() {
432432 < div >
433433 < CardTitle className = "flex items-center gap-2" >
434434 < FileCode className = "h-6 w-6 text-primary" />
435- Repository: { project ?. githubRepoName || 'N/A' }
435+ Repository: { project ?. githubRepoName || < span className = "text-muted-foreground italic" > Not Linked </ span > }
436436 </ CardTitle >
437437 < CardDescription >
438438 { isViewingFile ? `Viewing: ${ fileData ?. name } ` : `Path: /${ currentPath || '' } ` }
439439 </ CardDescription >
440440 </ div >
441441 </ div >
442- < div className = "flex items-center space-x-1 text-sm text-muted-foreground mt-2 overflow-x-auto whitespace-nowrap pb-1 border-t pt-2" >
443- { breadcrumbs . map ( ( crumb , index ) => (
444- < span key = { index } className = "inline-flex items-center" >
445- { index > 0 && < ChevronRight className = "h-4 w-4 inline-block mx-1 flex-shrink-0" /> }
446- { ( index === breadcrumbs . length - 1 && ( isViewingFile || currentPath === crumb . path ) ) ? (
447- < span className = "font-medium text-foreground flex items-center" >
448- { crumb . isRoot && index === 0 && < Home className = "h-4 w-4 mr-1 inline-block flex-shrink-0" /> }
449- { crumb . name }
450- </ span >
451- ) : (
452- < Link href = { `/projects/${ projectUuid } /codespace/files${ crumb . path ? '/' + crumb . path : '' } ` } className = "hover:underline flex items-center" >
453- { crumb . isRoot && index === 0 && < Home className = "h-4 w-4 mr-1 inline-block flex-shrink-0" /> } { crumb . name }
454- </ Link >
455- ) }
456- </ span >
457- ) ) }
458- </ div >
442+ { project ?. githubRepoName && (
443+ < div className = "flex items-center space-x-1 text-sm text-muted-foreground mt-2 overflow-x-auto whitespace-nowrap pb-1 border-t pt-2" >
444+ { breadcrumbs . map ( ( crumb , index ) => (
445+ < span key = { index } className = "inline-flex items-center" >
446+ { index > 0 && < ChevronRight className = "h-4 w-4 inline-block mx-1 flex-shrink-0" /> }
447+ { ( index === breadcrumbs . length - 1 && ( isViewingFile || currentPath === crumb . path ) ) ? (
448+ < span className = "font-medium text-foreground flex items-center" >
449+ { crumb . isRoot && index === 0 && < Home className = "h-4 w-4 mr-1 inline-block flex-shrink-0" /> }
450+ { crumb . name }
451+ </ span >
452+ ) : (
453+ < Link href = { `/projects/${ projectUuid } /codespace/files${ crumb . path ? '/' + crumb . path : '' } ` } className = "hover:underline flex items-center" >
454+ { crumb . isRoot && index === 0 && < Home className = "h-4 w-4 mr-1 inline-block flex-shrink-0" /> } { crumb . name }
455+ </ Link >
456+ ) }
457+ </ span >
458+ ) ) }
459+ </ div >
460+ ) }
459461 </ CardHeader >
460462 < CardContent >
461463 { error && (
@@ -465,7 +467,19 @@ function FileExplorerContent() {
465467 < AlertDescription > { error } </ AlertDescription >
466468 </ Alert >
467469 ) }
468- { ! error && isViewingFile && fileData && (
470+ { ! error && ! project ?. githubRepoName && (
471+ < Alert >
472+ < AlertTriangle className = "h-4 w-4" />
473+ < AlertTitle > Repository Not Linked</ AlertTitle >
474+ < AlertDescription >
475+ This project is not linked to a GitHub repository. Please link it first from the main CodeSpace tab.
476+ < Button asChild variant = "link" className = "ml-1 p-0 h-auto" >
477+ < Link href = { `/projects/${ projectUuid } ?tab=codespace` } > Go to CodeSpace Setup</ Link >
478+ </ Button >
479+ </ AlertDescription >
480+ </ Alert >
481+ ) }
482+ { ! error && project ?. githubRepoName && isViewingFile && fileData && (
469483 < div >
470484 < div className = "flex justify-between items-center mb-4" >
471485 < h3 className = "text-xl font-semibold" > { fileData . name } </ h3 >
@@ -516,7 +530,7 @@ function FileExplorerContent() {
516530 srcDoc = { fileData . content }
517531 title = { `Preview of ${ fileData . name } ` }
518532 className = "w-full h-[50vh] border rounded-md bg-white"
519- sandbox = "allow-scripts" // Be careful with scripts from untrusted sources
533+ sandbox = "allow-scripts"
520534 />
521535 </ div >
522536 ) }
@@ -543,7 +557,7 @@ function FileExplorerContent() {
543557 ) }
544558 </ div >
545559 ) }
546- { ! error && ! isViewingFile && contents . length > 0 && (
560+ { ! error && project ?. githubRepoName && ! isViewingFile && contents . length > 0 && (
547561 < Table >
548562 < TableHeader >
549563 < TableRow >
@@ -568,7 +582,7 @@ function FileExplorerContent() {
568582 </ TableRow >
569583 ) }
570584 { contents . map ( ( item ) => (
571- < TableRow key = { item . sha } >
585+ < TableRow key = { item . path } >
572586 < TableCell >
573587 < Link
574588 href = { `/projects/${ projectUuid } /codespace/files/${ item . path } ` }
@@ -622,14 +636,14 @@ function FileExplorerContent() {
622636 </ TableBody >
623637 </ Table >
624638 ) }
625- { ! error && ! isViewingFile && contents . length === 0 && ! currentPath && project && project . githubRepoName && (
639+ { ! error && project ?. githubRepoName && ! isViewingFile && contents . length === 0 && ! currentPath && (
626640 < Alert >
627641 < FileCode className = "h-4 w-4" />
628642 < AlertTitle > Empty Repository</ AlertTitle >
629643 < AlertDescription > This repository ('{ project . githubRepoName } ') appears to be empty. You can create files or folders using the buttons above.</ AlertDescription >
630644 </ Alert >
631645 ) }
632- { ! error && ! isViewingFile && contents . length === 0 && currentPath && project && project . githubRepoName && (
646+ { ! error && project ?. githubRepoName && ! isViewingFile && contents . length === 0 && currentPath && (
633647 < Alert >
634648 < Folder className = "h-4 w-4" />
635649 < AlertTitle > Empty Directory</ AlertTitle >
0 commit comments