1- import { createEffect , createSignal , onMount } from 'solid-js' ;
1+ import { createEffect , createSignal , onMount , Show } from 'solid-js' ;
22import { createStore , reconcile } from 'solid-js/store' ;
33import { render } from 'solid-js/web' ;
44import debounce from 'lodash/debounce' ;
@@ -10,6 +10,8 @@ import type { FileTreeNode } from './types';
1010import { RPCController } from './rpc' ;
1111import { Terminal } from './terminal' ;
1212
13+ import { PopoverContainer } from './components/popover-container' ;
14+ import { ProgressPopover } from './components/progress-popover' ;
1315import { PanelContainer } from './components/panel' ;
1416import { TreeView } from './components/tree-view' ;
1517
@@ -80,6 +82,21 @@ const App = () => {
8082 interrupt ( ) ;
8183 } ;
8284
85+ const [ currentlyLoadingTool , setCurrentlyLoadingTool ] = createSignal <
86+ { command : string ; totalLength : number ; doneLength : number } | null
87+ > ( null ) ;
88+
89+ let hideToolLoadProgressTimeout = 0 ;
90+
91+ createEffect ( ( ) => {
92+ let info ;
93+ if ( info = currentlyLoadingTool ( ) ) {
94+ clearTimeout ( hideToolLoadProgressTimeout ) ;
95+ const timeout = info . doneLength === info . totalLength ? 2000 : 10000 ;
96+ hideToolLoadProgressTimeout = setTimeout ( ( ) => setCurrentlyLoadingTool ( null ) , timeout ) ;
97+ }
98+ } ) ;
99+
83100 let [ creatingNewFileNode , setCreatingNewFileNode ] = createSignal <
84101 Parameters < typeof TreeView < FileTreeNode > > [ 0 ] [ 'creatingNewNode' ]
85102 > ( null ) ;
@@ -270,6 +287,11 @@ const App = () => {
270287 updateFileTree ( message . tree ) ;
271288 break ;
272289 }
290+ case 'tool-load-progress' : {
291+ let { command, totalLength, doneLength } = message ;
292+ setCurrentlyLoadingTool ( { command, totalLength, doneLength } ) ;
293+ break ;
294+ }
273295 default : message satisfies never ;
274296 }
275297 } ) ;
@@ -352,9 +374,26 @@ const App = () => {
352374 } ,
353375 ] ) ;
354376 } ,
355- children : (
356- < div ref = { el => xtermContainer = el } class = "panel-content" id = "terminal" />
357- ) ,
377+ get children ( ) {
378+ return < div class = "panel-content" >
379+ < div ref = { el => xtermContainer = el } id = "terminal" />
380+ < PopoverContainer >
381+ < Show when = { currentlyLoadingTool ( ) } >
382+ { ( info ) => {
383+ const fmt = ( n : number ) => ( n / 1048576 ) . toFixed ( 1 ) ;
384+ const done = ( ) => info ( ) . doneLength === info ( ) . totalLength ;
385+ return < ProgressPopover
386+ label = { ! done ( ) ? `Loading ${ info ( ) . command } ...` : `Loaded ${ info ( ) . command } ` }
387+ progressText = { ( ! done ( ) ? `${ fmt ( info ( ) . doneLength ) } / ` : '' ) +
388+ `${ fmt ( info ( ) . totalLength ) } MiB` }
389+ progressValue = { info ( ) . doneLength / info ( ) . totalLength }
390+ done = { done ( ) }
391+ /> ;
392+ } }
393+ </ Show >
394+ </ PopoverContainer >
395+ </ div > ;
396+ } ,
358397 } ,
359398
360399 {
0 commit comments