File tree Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -439,10 +439,10 @@ const AgentList: React.FC<AgentListProps> = ({
439439 liveStat . cpu_util . current = _ . toFinite (
440440 parsedValue . node . cpu_util . current ,
441441 ) ;
442- liveStat . cpu_util . ratio =
443- liveStat . cpu_util . current /
444- liveStat . cpu_util . capacity /
445- numCores || 0 ;
442+ liveStat . cpu_util . ratio = Math . min (
443+ _ . toFinite ( parsedValue . node . cpu_util . pct ) / 100 / ( numCores || 1 ) ,
444+ 1 ,
445+ ) ;
446446 liveStat . mem_util . capacity = _ . toInteger (
447447 available_slots . mem || parsedValue . node . mem . capacity ,
448448 ) ;
Original file line number Diff line number Diff line change @@ -49,20 +49,19 @@ const SessionSlotCell: React.FC<OccupiedSlotViewProps> = ({
4949 } = JSON . parse ( session . occupied_slots || '{}' ) ;
5050
5151 if ( type === 'cpu' ) {
52- const displayPercent =
53- ( liveStat . cpu_util ?. pct ? parseFloat ( liveStat . cpu_util ?. pct ) : 0 ) /
54- parseFloat ( occupiedSlots . cpu ?? '1' ) ;
55- const cpuUtilPercentNumber = liveStat . cpu_util ?. pct
56- ? parseFloat ( liveStat . cpu_util . pct )
57- : 0 ;
58- const cpuOccupiedSlot = parseFloat ( occupiedSlots . cpu ?? '1' ) * 100 ;
52+ const CPUOccupiedSlot = parseFloat ( occupiedSlots . cpu ?? '1' ) ;
53+ const CPUUtilPercent = Math . min (
54+ parseFloat ( liveStat . cpu_util ?. pct ?? '0' ) ,
55+ CPUOccupiedSlot * 100 ,
56+ ) ;
57+
5958 return occupiedSlots . cpu ? (
6059 < UsageBadge
61- percent = { displayPercent }
62- text = { occupiedSlots . cpu }
60+ percent = { Math . min ( CPUUtilPercent / CPUOccupiedSlot , 100 ) }
61+ text = { CPUOccupiedSlot }
6362 tooltip = { {
6463 title : liveStat . cpu_util
65- ? `${ cpuUtilPercentNumber . toFixed ( 1 ) } % / ${ cpuOccupiedSlot } %`
64+ ? `${ CPUUtilPercent . toFixed ( 1 ) } % / ${ CPUOccupiedSlot * 100 } %`
6665 : undefined ,
6766 placement : 'left' ,
6867 } }
Original file line number Diff line number Diff line change @@ -149,21 +149,25 @@ const SessionUsageMonitor: React.FC<SessionUsageMonitorProps> = ({
149149 const utilItems = filterOutEmpty ( [
150150 sortedLiveStat ?. cpu_util &&
151151 ( ( ) => {
152- const displayPercent =
153- ( liveStat . cpu_util ?. pct ? parseFloat ( liveStat . cpu_util ?. pct ) : 0 ) /
154- parseFloat ( occupiedSlots . cpu ?? '1' ) ;
155-
152+ const CPUOccupiedSlot = parseFloat ( occupiedSlots . cpu ?? '1' ) ;
153+ const CPUUtilPercent = Math . min (
154+ parseFloat ( liveStat . cpu_util ?. pct ?? '0' ) ,
155+ CPUOccupiedSlot * 100 ,
156+ ) ;
156157 return (
157158 < SessionUtilItem
158159 key = { 'cpu' }
159160 size = { size }
160161 title = { mergedResourceSlots ?. [ 'cpu' ] ?. human_readable_name }
161162 percent = {
162163 displayTarget === 'current'
163- ? displayPercent
164- : ( sortedLiveStat ?. cpu_util ?. [ displayTargetName ] ?? '0' )
164+ ? Math . min ( CPUUtilPercent / CPUOccupiedSlot , 100 ) . toString ( )
165+ : Math . min (
166+ sortedLiveStat ?. cpu_util ?. [ displayTargetName ] ?? '0' ,
167+ 100 ,
168+ ) . toString ( )
165169 }
166- description = { `${ liveStat . cpu_util ?. pct } % / ${ parseFloat ( occupiedSlots . cpu ?? '1' ) * 100 } %` }
170+ description = { `${ CPUUtilPercent . toFixed ( 1 ) } % / ${ parseFloat ( occupiedSlots . cpu ?? '1' ) * 100 } %` }
167171 />
168172 ) ;
169173 } ) ( ) ,
You can’t perform that action at this time.
0 commit comments