Skip to content

Commit b1092d3

Browse files
committed
fix sorting and gone
1 parent a59cb37 commit b1092d3

2 files changed

Lines changed: 45 additions & 12 deletions

File tree

frontend/app/view/processviewer/processviewer.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,26 @@ const ProcessRow = React.memo(function ProcessRow({
598598
const gridTemplate = getGridTemplate(platform);
599599
const showStatus = platform !== "windows" && platform !== "darwin";
600600
const showThreads = platform !== "windows";
601+
if (proc.gone) {
602+
return (
603+
<div
604+
className={`grid w-full text-xs transition-colors cursor-pointer ${selected ? "bg-accentbg" : "hover:bg-white/5"}`}
605+
style={{ gridTemplateColumns: gridTemplate, height: RowHeight }}
606+
onClick={() => onSelect(proc.pid)}
607+
onContextMenu={(e) => onContextMenu(proc.pid, e)}
608+
>
609+
<div className="px-2 flex items-center truncate justify-end text-secondary font-mono text-[11px]">
610+
{proc.pid}
611+
</div>
612+
<div className="px-2 flex items-center truncate text-muted italic">(gone)</div>
613+
{showStatus && <div className="px-2 flex items-center truncate" />}
614+
<div className="px-2 flex items-center truncate" />
615+
{showThreads && <div className="px-2 flex items-center truncate" />}
616+
<div className="px-2 flex items-center truncate" />
617+
<div className="px-2 flex items-center truncate" />
618+
</div>
619+
);
620+
}
601621
return (
602622
<div
603623
className={`grid w-full text-xs transition-colors cursor-pointer ${selected ? "bg-accentbg" : "hover:bg-white/5"}`}

pkg/wshrpc/wshremote/processviewer.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,12 @@ func sortProcesses(processes []wshrpc.ProcessInfo, sortBy string, sortDesc bool)
396396
sort.Slice(processes, func(i, j int) bool {
397397
ci := processes[i].Cpu
398398
cj := processes[j].Cpu
399-
if ci < 0 {
400-
ci = 0
399+
iNull := ci < 0
400+
jNull := cj < 0
401+
if iNull != jNull {
402+
return !iNull
401403
}
402-
if cj < 0 {
403-
cj = 0
404-
}
405-
if ci != cj {
404+
if !iNull && ci != cj {
406405
if sortDesc {
407406
return ci > cj
408407
}
@@ -412,11 +411,18 @@ func sortProcesses(processes []wshrpc.ProcessInfo, sortBy string, sortDesc bool)
412411
})
413412
case "mem":
414413
sort.Slice(processes, func(i, j int) bool {
415-
if processes[i].Mem != processes[j].Mem {
414+
mi := processes[i].Mem
415+
mj := processes[j].Mem
416+
iNull := mi < 0
417+
jNull := mj < 0
418+
if iNull != jNull {
419+
return !iNull
420+
}
421+
if !iNull && mi != mj {
416422
if sortDesc {
417-
return processes[i].Mem > processes[j].Mem
423+
return mi > mj
418424
}
419-
return processes[i].Mem < processes[j].Mem
425+
return mi < mj
420426
}
421427
return processes[i].Pid < processes[j].Pid
422428
})
@@ -452,11 +458,18 @@ func sortProcesses(processes []wshrpc.ProcessInfo, sortBy string, sortDesc bool)
452458
})
453459
case "threads":
454460
sort.Slice(processes, func(i, j int) bool {
455-
if processes[i].NumThreads != processes[j].NumThreads {
461+
ti := processes[i].NumThreads
462+
tj := processes[j].NumThreads
463+
iNull := ti < 0
464+
jNull := tj < 0
465+
if iNull != jNull {
466+
return !iNull
467+
}
468+
if !iNull && ti != tj {
456469
if sortDesc {
457-
return processes[i].NumThreads > processes[j].NumThreads
470+
return ti > tj
458471
}
459-
return processes[i].NumThreads < processes[j].NumThreads
472+
return ti < tj
460473
}
461474
return processes[i].Pid < processes[j].Pid
462475
})

0 commit comments

Comments
 (0)