1- import { useState , useMemo , useCallback , memo , startTransition , useRef , useEffect } from 'react' ;
1+ import { useState , useMemo , useCallback , memo , useTransition , useRef , useEffect } from 'react' ;
22import Box from '@mui/material/Box' ;
33import List from '@mui/material/List' ;
44import ListItemButton from '@mui/material/ListItemButton' ;
@@ -26,6 +26,7 @@ import SearchRounded from '@mui/icons-material/SearchRounded';
2626import UnfoldMoreRounded from '@mui/icons-material/UnfoldMoreRounded' ;
2727import UnfoldLessRounded from '@mui/icons-material/UnfoldLessRounded' ;
2828import Tooltip from '@mui/material/Tooltip' ;
29+ import CircularProgress from '@mui/material/CircularProgress' ;
2930import { alpha } from '@mui/material/styles' ;
3031import { useStore } from '../../state/store.ts' ;
3132import { DEFAULT_PARAM_TYPE } from '../../schemas/constants.ts' ;
@@ -184,6 +185,7 @@ export default function FileTree() {
184185 const [ editValue , setEditValue ] = useState ( '' ) ;
185186
186187 // Track expanded nodes — default ALL COLLAPSED for performance
188+ const [ isPending , startTransition ] = useTransition ( ) ;
187189 const [ expanded , setExpanded ] = useState < Set < string > > ( new Set ( ) ) ;
188190 const [ addFileOpen , setAddFileOpen ] = useState ( false ) ;
189191 const [ addDomainFor , setAddDomainFor ] = useState < number | null > ( null ) ;
@@ -193,7 +195,7 @@ export default function FileTree() {
193195 const [ addMenuAnchor , setAddMenuAnchor ] = useState < HTMLElement | null > ( null ) ;
194196 const [ confirmDelete , setConfirmDelete ] = useState < { title : string ; message : string ; action : ( ) => void } | null > ( null ) ;
195197 // Pagination: track visible limit per parent key, default PAGE_SIZE
196- const PAGE_SIZE = 20 ;
198+ const PAGE_SIZE = 10 ;
197199 const [ visibleLimits , setVisibleLimits ] = useState < Record < string , number > > ( { } ) ;
198200 const getLimit = ( key : string ) => visibleLimits [ key ] ?? PAGE_SIZE ;
199201 const showMore = useCallback ( ( key : string , total : number ) => {
@@ -359,7 +361,18 @@ export default function FileTree() {
359361 </ Box >
360362 ) }
361363
362- < List dense disablePadding sx = { { px : 0.5 , pb : 1 } } >
364+ < Box sx = { { position : 'relative' } } >
365+ { isPending && (
366+ < Box sx = { {
367+ position : 'absolute' , inset : 0 , zIndex : 2 ,
368+ display : 'flex' , justifyContent : 'center' , pt : 4 ,
369+ bgcolor : 'rgba(var(--mui-palette-background-paperChannel) / 0.6)' ,
370+ backdropFilter : 'blur(1px)' ,
371+ } } >
372+ < CircularProgress size = { 20 } sx = { { color : '#DF4926' } } />
373+ </ Box >
374+ ) }
375+ < List dense disablePadding sx = { { px : 0.5 , pb : 1 , ...( isPending && { opacity : 0.4 , pointerEvents : 'none' } ) } } >
363376 { files . map ( ( file , fi ) => {
364377 if ( ! fileMatchesSearch ( fi ) ) return null ;
365378 const fk = `f${ fi } ` ;
@@ -515,6 +528,7 @@ export default function FileTree() {
515528 ) ;
516529 } ) }
517530 </ List >
531+ </ Box >
518532
519533 { q && files . length > 0 && files . every ( ( _ , fi ) => ! fileMatchesSearch ( fi ) ) && (
520534 < Typography sx = { { px : 2 , py : 3 , textAlign : 'center' , fontSize : '0.78rem' , color : 'text.disabled' } } >
0 commit comments