@@ -46,7 +46,8 @@ import {
4646 RefreshCw ,
4747 Search ,
4848 Settings ,
49- ListTree
49+ ListTree ,
50+ X
5051} from "lucide-react"
5152import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"
5253import { atomDark } from "react-syntax-highlighter/dist/esm/styles/prism"
@@ -373,7 +374,16 @@ export default function RepoProjectStructure() {
373374 } )
374375 }
375376
376- const noStructureMessage = `No structure generated yet. Enter a ${ repoType === "github" ? "GitHub" : "GitLab" } URL and click Generate.`
377+ const getDisplayMessage = useCallback ( ( ) => {
378+ if ( validation . isError && validation . message ) {
379+ return { text : validation . message , isError : true }
380+ }
381+ if ( searchTerm && structureMap . size > 0 ) {
382+ return { text : `No files or folders found matching "${ searchTerm } ".\n\nTips:\n- Check the spelling\n- Try searching for partial names\n- Include file extensions (.js, .ts, .json)` , isError : false }
383+ }
384+ return { text : `No structure generated yet. Enter a ${ repoType === "github" ? "GitHub" : "GitLab" } URL and click Generate.` , isError : false }
385+ } , [ validation , searchTerm , structureMap . size , repoType ] )
386+
377387 const noResultsMessage = useCallback (
378388 ( searchTerm : string ) =>
379389 `No files or folders found matching "${ searchTerm } ".\n\nTips:\n- Check the spelling\n- Try searching for partial names\n- Include file extensions (.js, .ts, .json)` ,
@@ -571,8 +581,6 @@ export default function RepoProjectStructure() {
571581 </ div >
572582 </ div >
573583
574- { validation . isError && < p className = "text-red-500 text-sm mt-2" > { validation . message } </ p > }
575-
576584 < div >
577585 { /* Menu Bar*/ }
578586 < div className = "border border-gray-300 dark:border-gray-600 rounded-t-lg bg-gray-50 dark:bg-gray-800" >
@@ -738,43 +746,52 @@ export default function RepoProjectStructure() {
738746 < div className = "relative border border-gray-300 dark:border-gray-600 border-t-0 rounded-b-lg overflow-hidden" ref = { treeRef } >
739747 { viewMode === "ascii" ? (
740748 < div style = { { contain : "layout style paint" } } > { /* CSS containment for performance */ }
741- < SyntaxHighlighter
742- language = "plaintext"
743- style = { atomDark }
744- className = { `${ expanded ? "max-h-[none]" : "max-h-96" } overflow-y-auto min-h-[200px]` }
745- showLineNumbers = { customizationOptions . showLineNumbers }
746- wrapLines = { true }
747- customStyle = { {
748- margin : 0 ,
749- borderRadius : 0 ,
750- border : 'none'
751- } }
752- >
753- { customizedStructure
754- ? customizedStructure
755- : searchTerm
756- ? noResultsMessage ( searchTerm )
757- : noStructureMessage }
758- </ SyntaxHighlighter >
749+ { customizedStructure ? (
750+ < SyntaxHighlighter
751+ language = "plaintext"
752+ style = { atomDark }
753+ className = { `${ expanded ? "max-h-[none]" : "max-h-96" } overflow-y-auto min-h-[200px]` }
754+ showLineNumbers = { customizationOptions . showLineNumbers }
755+ wrapLines = { true }
756+ customStyle = { {
757+ margin : 0 ,
758+ borderRadius : 0 ,
759+ border : 'none'
760+ } }
761+ >
762+ { customizedStructure }
763+ </ SyntaxHighlighter >
764+ ) : (
765+ < div className = "bg-[#1d1f21] min-h-[200px] p-4 flex items-start" >
766+ { getDisplayMessage ( ) . isError ? (
767+ < div className = "flex items-start gap-2 text-red-500" >
768+ < X className = "h-5 w-5 flex-shrink-0 mt-0.5" />
769+ < span className = "font-mono text-sm" > Error: { getDisplayMessage ( ) . text } </ span >
770+ </ div >
771+ ) : (
772+ < span className = "font-mono text-sm text-gray-400" > { getDisplayMessage ( ) . text } </ span >
773+ ) }
774+ </ div >
775+ ) }
759776 </ div >
760777 ) : viewMode === "interactive" ? (
761778 filteredStructureMap . size > 0 ? (
762779 < div className = "bg-gray-900 min-h-[200px] p-4" style = { { contain : "layout style paint" } } >
763780 < InteractiveTreeView structure = { filteredStructureMap } customizationOptions = { customizationOptions } />
764781 </ div >
765782 ) : (
766- < SyntaxHighlighter
767- language = "plaintext"
768- style = { atomDark }
769- className = "max-h-96 overflow-y-auto min-h-[200px]"
770- customStyle = { {
771- margin : 0 ,
772- borderRadius : 0 ,
773- border : 'none'
774- } }
775- >
776- { searchTerm ? noResultsMessage ( searchTerm ) : noStructureMessage }
777- </ SyntaxHighlighter >
783+ < div className = "bg-[#1d1f21] min-h-[200px] p-4 flex items-start" >
784+ { searchTerm ? (
785+ < span className = "font-mono text-sm text-gray-400" > { noResultsMessage ( searchTerm ) } </ span >
786+ ) : getDisplayMessage ( ) . isError ? (
787+ < div className = "flex items-start gap-2 text-red-500" >
788+ < X className = "h-5 w-5 flex-shrink-0 mt-0.5" />
789+ < span className = "font-mono text-sm" > Error: { getDisplayMessage ( ) . text } </ span >
790+ </ div >
791+ ) : (
792+ < span className = "font-mono text-sm text-gray-400" > { getDisplayMessage ( ) . text } </ span >
793+ ) }
794+ </ div >
778795 )
779796 ) : viewMode === "analysis" && structureMap . size > 0 ? (
780797 < div className = "bg-white dark:bg-gray-900 min-h-[400px] p-6" >
@@ -785,18 +802,16 @@ export default function RepoProjectStructure() {
785802 < RepoGraphs fileTypeData = { fileTypeData } languageData = { languageData } />
786803 </ div >
787804 ) : (
788- < SyntaxHighlighter
789- language = "plaintext"
790- style = { atomDark }
791- className = "max-h-96 overflow-y-auto min-h-[200px]"
792- customStyle = { {
793- margin : 0 ,
794- borderRadius : 0 ,
795- border : 'none'
796- } }
797- >
798- { noStructureMessage }
799- </ SyntaxHighlighter >
805+ < div className = "bg-[#1d1f21] min-h-[200px] p-4 flex items-start" >
806+ { getDisplayMessage ( ) . isError ? (
807+ < div className = "flex items-start gap-2 text-red-500" >
808+ < X className = "h-5 w-5 flex-shrink-0 mt-0.5" />
809+ < span className = "font-mono text-sm" > Error: { getDisplayMessage ( ) . text } </ span >
810+ </ div >
811+ ) : (
812+ < span className = "font-mono text-sm text-gray-400" > { getDisplayMessage ( ) . text } </ span >
813+ ) }
814+ </ div >
800815 ) }
801816 </ div >
802817
0 commit comments