1- import React , { useState , useEffect , useRef } from "react" ;
1+ import { createRef , useState , useEffect , useRef , type RefObject , type ReactElement } from "react" ;
22import { useViews } from "@playfast/echoform/server" ;
33import { views } from "../views" ;
44import type { ManagedProcess } from "../process" ;
@@ -25,18 +25,18 @@ function categoryColor(name: string | undefined): string {
2525
2626interface TabDef {
2727 readonly id : string ;
28- readonly description ?: string ;
29- readonly icon ?: string ;
28+ readonly description ?: string | undefined ;
29+ readonly icon ?: string | undefined ;
3030 readonly tabType : "process" | "iframe" ;
31- readonly url ?: string ;
31+ readonly url ?: string | undefined ;
3232}
3333
3434interface CategoryDef {
3535 readonly name : string ;
36- readonly icon ?: string ;
36+ readonly icon ?: string | undefined ;
3737 readonly type : "process" | "files" ;
3838 readonly tabs : readonly TabDef [ ] ;
39- readonly fileRoot ?: string ;
39+ readonly fileRoot ?: string | undefined ;
4040}
4141
4242interface WmuxRootProps {
@@ -46,18 +46,18 @@ interface WmuxRootProps {
4646
4747// ── Component ──
4848
49- export function WmuxRoot ( { processes, categoryDefs } : WmuxRootProps ) : React . ReactElement | null {
49+ export function WmuxRoot ( { processes, categoryDefs } : WmuxRootProps ) : ReactElement | null {
5050 const View = useViews ( views ) ;
5151 const [ activeCategory , setActiveCategory ] = useState ( categoryDefs [ 0 ] ?. name ?? "" ) ;
5252 const [ activeTabId , setActiveTabId ] = useState ( "" ) ;
5353 const [ statuses , setStatuses ] = useState < Record < string , ProcessStatus > > ( { } ) ;
5454 const [ fileStates , setFileStates ] = useState < Record < string , FileViewerState > > ( { } ) ;
5555
5656 // File viewer action refs (one per file category)
57- const fileRefs = useRef < Record < string , React . RefObject < FileViewerActions | null > > > ( { } ) ;
57+ const fileRefs = useRef < Record < string , RefObject < FileViewerActions | null > > > ( { } ) ;
5858 for ( const def of categoryDefs ) {
5959 if ( def . type === "files" && ! fileRefs . current [ def . name ] ) {
60- fileRefs . current [ def . name ] = React . createRef < FileViewerActions | null > ( ) ;
60+ fileRefs . current [ def . name ] = createRef < FileViewerActions | null > ( ) ;
6161 }
6262 }
6363
@@ -118,7 +118,7 @@ export function WmuxRoot({ processes, categoryDefs }: WmuxRootProps): React.Reac
118118 categories = { categories }
119119 activeCategory = { activeCategory }
120120 activeTabId = { activeTabId }
121- onSelectCategory = { ( cat ) => {
121+ onSelectCategory = { ( cat : string ) => {
122122 setActiveCategory ( cat ) ;
123123 const def = categoryDefs . find ( ( d ) => d . name === cat ) ;
124124 if ( ! def ) return ;
@@ -130,12 +130,12 @@ export function WmuxRoot({ processes, categoryDefs }: WmuxRootProps): React.Reac
130130 }
131131 } }
132132 onSelectTab = { setActiveTabId }
133- onStartProcess = { ( id ) => processes . get ( id ) ?. start ( ) }
134- onStopProcess = { ( id ) => processes . get ( id ) ?. stop ( ) }
135- onRestartProcess = { ( id ) => processes . get ( id ) ?. restart ( ) }
136- onToggleDir = { ( path ) => fileRefs . current [ activeCategory ] ?. current ?. toggleDir ( path ) }
137- onOpenFile = { ( path ) => fileRefs . current [ activeCategory ] ?. current ?. openFile ( path ) }
138- onCloseFile = { ( id ) => fileRefs . current [ activeCategory ] ?. current ?. closeFile ( id ) }
133+ onStartProcess = { ( id : string ) => processes . get ( id ) ?. start ( ) }
134+ onStopProcess = { ( id : string ) => processes . get ( id ) ?. stop ( ) }
135+ onRestartProcess = { ( id : string ) => processes . get ( id ) ?. restart ( ) }
136+ onToggleDir = { ( path : string ) => fileRefs . current [ activeCategory ] ?. current ?. toggleDir ( path ) }
137+ onOpenFile = { ( path : string ) => fileRefs . current [ activeCategory ] ?. current ?. openFile ( path ) }
138+ onCloseFile = { ( id : string ) => fileRefs . current [ activeCategory ] ?. current ?. closeFile ( id ) }
139139 >
140140 { [ ...processes . keys ( ) ] . map ( ( id ) => (
141141 < TerminalSession key = { id } proc = { processes . get ( id ) ! } />
0 commit comments