@@ -11,7 +11,7 @@ import { useState, useEffect, useRef, useCallback } from 'preact/hooks';
1111import htm from 'htm' ;
1212import { controllerRpc } from '/static/shared/rpc.js' ;
1313import { formatBytes , formatRelativeTime , stateToName , formatDuration } from '/static/shared/utils.js' ;
14- import { MetricCard , ResourceSection , Gauge , InlineGauge , Field , Section , Sparkline , formatMbPair , formatRate } from '/static/shared/components.js' ;
14+ import { MetricCard , InlineGauge , Field , Section , Sparkline , formatMbPair , formatRate } from '/static/shared/components.js' ;
1515
1616const html = htm . bind ( h ) ;
1717
@@ -175,66 +175,76 @@ function WorkerDetailApp() {
175175 ${ workerHeartbeat && html `< ${ Field } label ="Last Heartbeat" value=${ workerHeartbeat } /> ` }
176176 ${ workerCpu && html `< ${ Field } label ="CPU Cores" value=${ workerCpu } /> ` }
177177 ${ accelDisplay && html `< ${ Field } label ="Accelerator" value=${ accelDisplay } /> ` }
178+ ${ ! liveRes && workerMem > 0 && html `< ${ Field } label ="Memory" value=${ formatBytes ( workerMem ) } /> ` }
179+ ${ ! liveRes && workerDisk > 0 && html `< ${ Field } label ="Disk" value=${ formatBytes ( workerDisk ) } /> ` }
178180 </ dl >
179- ${ liveRes && html `
180- < ${ ResourceSection } title ="Live Utilization">
181- < div style ="display:flex;align-items:center;gap:8px ">
182- < div style ="flex:1 "> < ${ Gauge } label ="CPU" value=${ liveCpuPct || 0 } max=${ 100 } format="percent" /> </ div >
183- ${ resourceHistory . length >= 2 && html `
184- < ${ Sparkline } values =${ resourceHistory . map ( s => s . cpuPercent || 0 ) }
185- max=${ 100 } width=${ 80 } height=${ 24 }
186- color="var(--color-accent)"
187- fillColor="rgba(9,105,218,0.1)" />
188- ` }
181+ </ />
182+ </ div >
183+
184+ ${ liveRes && html `
185+ < div class ="utilization-panel ">
186+ < h2 class ="utilization-panel__title "> Live Utilization</ h2 >
187+ < div class ="utilization-panel__grid ">
188+ < div class ="utilization-metric ">
189+ < div class ="utilization-metric__header ">
190+ < span class ="utilization-metric__label "> CPU</ span >
191+ < span class ="utilization-metric__value utilization-metric__value--accent "> ${ ( liveCpuPct || 0 ) + '%' } </ span >
192+ </ div >
193+ < div class ="utilization-metric__chart ">
194+ < ${ Sparkline } values =${ resourceHistory . map ( s => s . cpuPercent || 0 ) }
195+ max=${ 100 } width=${ 240 } height=${ 40 }
196+ color="var(--color-accent)"
197+ fillColor="rgba(9,105,218,0.10)" />
189198 </ div >
190- ${ liveMemTotal > 0 && html `
191- < div style ="display:flex;align-items:center;gap:8px ">
192- < div style ="flex:1 "> < ${ Gauge } label ="Memory" value=${ liveMemUsed } max=${ liveMemTotal } format="bytes" /> </ div >
193- ${ resourceHistory . length >= 2 && html `
194- < ${ Sparkline } values =${ resourceHistory . map ( s => parseInt ( s . memoryUsedBytes || 0 ) ) }
195- max=${ liveMemTotal } width=${ 80 } height=${ 24 }
196- color="var(--color-success)"
197- fillColor="rgba(26,127,55,0.1)" />
198- ` }
199+ </ div >
200+
201+ ${ liveMemTotal > 0 && html `
202+ < div class ="utilization-metric ">
203+ < div class ="utilization-metric__header ">
204+ < span class ="utilization-metric__label "> Memory</ span >
205+ < span class ="utilization-metric__value utilization-metric__value--success "> ${ formatBytes ( liveMemUsed ) + ' / ' + formatBytes ( liveMemTotal ) } </ span >
206+ </ div >
207+ < div class ="utilization-metric__chart ">
208+ < ${ Sparkline } values =${ resourceHistory . map ( s => parseInt ( s . memoryUsedBytes || 0 ) ) }
209+ max=${ liveMemTotal } width=${ 240 } height=${ 40 }
210+ color="var(--color-success)"
211+ fillColor="rgba(26,127,55,0.10)" />
199212 </ div >
200- ` }
201- ${ liveDiskTotal > 0 && html `
202- < div style ="display:flex;align-items:center;gap:8px ">
203- < div style ="flex:1 "> < ${ Gauge } label ="Disk" value=${ liveDiskUsed } max=${ liveDiskTotal } format="bytes" /> </ div >
204- ${ resourceHistory . length >= 2 && html `
205- < ${ Sparkline } values =${ resourceHistory . map ( s => parseInt ( s . diskUsedBytes || 0 ) ) }
206- max=${ liveDiskTotal } width=${ 80 } height=${ 24 }
207- color="var(--color-warning)"
208- fillColor="rgba(191,135,0,0.1)" />
209- ` }
213+ </ div >
214+ ` }
215+
216+ ${ liveDiskTotal > 0 && html `
217+ < div class ="utilization-metric ">
218+ < div class ="utilization-metric__header ">
219+ < span class ="utilization-metric__label "> Disk</ span >
220+ < span class ="utilization-metric__value utilization-metric__value--warning "> ${ formatBytes ( liveDiskUsed ) + ' / ' + formatBytes ( liveDiskTotal ) } </ span >
210221 </ div >
211- ` }
212- < div style ="display:flex;align-items:center;gap:8px ">
213- < div style ="flex:1 ">
214- < div class ="gauge ">
215- < span class ="gauge-label "> Net</ span >
216- < span class ="gauge-value " style ="flex:1;text-align:right;font-variant-numeric:tabular-nums ">
217- ${ '↓ ' + formatRate ( liveNetRecv ) + ' ↑ ' + formatRate ( liveNetSent ) }
218- </ span >
219- </ div >
222+ < div class ="utilization-metric__chart ">
223+ < ${ Sparkline } values =${ resourceHistory . map ( s => parseInt ( s . diskUsedBytes || 0 ) ) }
224+ max=${ liveDiskTotal } width=${ 240 } height=${ 40 }
225+ color="var(--color-warning)"
226+ fillColor="rgba(154,103,0,0.10)" />
220227 </ div >
221- ${ resourceHistory . length >= 2 && html `
222- < ${ Sparkline } values =${ resourceHistory . map ( s => parseInt ( s . netRecvBps || 0 ) + parseInt ( s . netSentBps || 0 ) ) }
223- width=${ 80 } height=${ 24 }
224- color="var(--color-purple, #8250df)"
225- fillColor="rgba(130,80,223,0.1)" />
226- ` }
227228 </ div >
228- </ />
229- ` }
230- ${ ! liveRes && html `
231- < dl class ="worker-detail-fields ">
232- ${ workerMem > 0 && html `< ${ Field } label ="Memory" value=${ formatBytes ( workerMem ) } /> ` }
233- ${ workerDisk > 0 && html `< ${ Field } label ="Disk" value=${ formatBytes ( workerDisk ) } /> ` }
234- </ dl >
235- ` }
236- </ />
237- </ div >
229+ ` }
230+
231+ < div class ="utilization-metric ">
232+ < div class ="utilization-metric__header ">
233+ < span class ="utilization-metric__label "> Network</ span >
234+ < span class ="utilization-metric__value utilization-metric__value--purple ">
235+ ${ '↓ ' + formatRate ( liveNetRecv ) + ' ↑ ' + formatRate ( liveNetSent ) }
236+ </ span >
237+ </ div >
238+ < div class ="utilization-metric__chart ">
239+ < ${ Sparkline } values =${ resourceHistory . map ( s => parseInt ( s . netRecvBps || 0 ) + parseInt ( s . netSentBps || 0 ) ) }
240+ width=${ 240 } height=${ 40 }
241+ color="var(--color-purple, #8250df)"
242+ fillColor="rgba(130,80,223,0.10)" />
243+ </ div >
244+ </ div >
245+ </ div >
246+ </ div >
247+ ` }
238248
239249 ${ '' /* --- Task History --- */ }
240250 < div class ="worker-detail-logs-section ">
0 commit comments