Skip to content

Commit 74aaf92

Browse files
committed
checkpoint, removed darwin status field, cpu status
1 parent 5cdced2 commit 74aaf92

5 files changed

Lines changed: 39 additions & 47 deletions

File tree

frontend/app/view/processviewer/processviewer.tsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2026, Command Line Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
import { Tooltip } from "@/app/element/tooltip";
45
import { globalStore } from "@/app/store/jotaiStore";
56
import { TabRpcClient } from "@/app/store/wshrpcutil";
67
import { MetaKeyAtomFnType, WaveEnv, WaveEnvSubset } from "@/app/waveenv/waveenv";
@@ -212,26 +213,25 @@ type ColDef = {
212213
tooltip?: string;
213214
width: string;
214215
align?: "right";
215-
hideOnWindows?: boolean;
216+
hideOnPlatform?: string[];
216217
};
217218

218219
const Columns: ColDef[] = [
219220
{ key: "pid", label: "PID", width: "70px", align: "right" },
220221
{ key: "command", label: "Command", width: "minmax(120px, 4fr)" },
221-
{ key: "status", label: "Status", width: "75px", hideOnWindows: true },
222+
{ key: "status", label: "Status", width: "75px", hideOnPlatform: ["windows", "darwin"] },
222223
{ key: "user", label: "User", width: "80px" },
223-
{ key: "threads", label: "NT", tooltip: "Num Threads", width: "55px", align: "right", hideOnWindows: true },
224+
{ key: "threads", label: "NT", tooltip: "Num Threads", width: "55px", align: "right", hideOnPlatform: ["windows"] },
224225
{ key: "cpu", label: "CPU%", width: "70px", align: "right" },
225226
{ key: "mem", label: "Memory", width: "90px", align: "right" },
226227
];
227228

228-
function getColumns(isWindows: boolean): ColDef[] {
229-
if (!isWindows) return Columns;
230-
return Columns.filter((c) => !c.hideOnWindows);
229+
function getColumns(platform: string): ColDef[] {
230+
return Columns.filter((c) => !c.hideOnPlatform?.includes(platform));
231231
}
232232

233-
function getGridTemplate(isWindows: boolean): string {
234-
return getColumns(isWindows)
233+
function getGridTemplate(platform: string): string {
234+
return getColumns(platform)
235235
.map((c) => c.width)
236236
.join(" ");
237237
}
@@ -248,30 +248,31 @@ const TableHeader = React.memo(function TableHeader({
248248
model,
249249
sortBy,
250250
sortDesc,
251-
isWindows,
251+
platform,
252252
}: {
253253
model: ProcessViewerViewModel;
254254
sortBy: SortCol;
255255
sortDesc: boolean;
256-
isWindows: boolean;
256+
platform: string;
257257
}) {
258-
const cols = getColumns(isWindows);
259-
const gridTemplate = getGridTemplate(isWindows);
258+
const cols = getColumns(platform);
259+
const gridTemplate = getGridTemplate(platform);
260260
return (
261261
<div
262262
className="grid w-full shrink-0 border-b border-white/10 bg-panel text-xs text-secondary font-medium select-none"
263263
style={{ gridTemplateColumns: gridTemplate }}
264264
>
265265
{cols.map((col) => (
266-
<div
266+
<Tooltip
267267
key={col.key}
268-
title={col.tooltip}
269-
className={`px-2 py-1 cursor-pointer hover:text-primary hover:bg-white/5 transition-colors truncate flex items-center${col.align === "right" ? " justify-end" : ""}`}
270-
onClick={() => model.setSort(col.key)}
268+
content={col.tooltip}
269+
disable={!col.tooltip}
270+
divClassName={`px-2 py-1 cursor-pointer hover:text-primary hover:bg-white/5 transition-colors truncate flex items-center${col.align === "right" ? " justify-end" : ""}`}
271+
divOnClick={() => model.setSort(col.key)}
271272
>
272273
<span className="truncate">{col.label}</span>
273274
<SortIndicator active={sortBy === col.key} desc={sortDesc} />
274-
</div>
275+
</Tooltip>
275276
))}
276277
</div>
277278
);
@@ -281,23 +282,25 @@ TableHeader.displayName = "TableHeader";
281282
const ProcessRow = React.memo(function ProcessRow({
282283
proc,
283284
hasCpu,
284-
isWindows,
285+
platform,
285286
}: {
286287
proc: ProcessInfo;
287288
hasCpu: boolean;
288-
isWindows: boolean;
289+
platform: string;
289290
}) {
290-
const gridTemplate = getGridTemplate(isWindows);
291+
const gridTemplate = getGridTemplate(platform);
292+
const showStatus = platform !== "windows" && platform !== "darwin";
293+
const showThreads = platform !== "windows";
291294
return (
292295
<div
293296
className="grid w-full text-xs hover:bg-white/5 transition-colors"
294297
style={{ gridTemplateColumns: gridTemplate, height: RowHeight }}
295298
>
296299
<div className="px-2 py-[3px] truncate text-right text-secondary font-mono text-[11px]">{proc.pid}</div>
297300
<div className="px-2 py-[3px] truncate">{proc.command}</div>
298-
{!isWindows && <div className="px-2 py-[3px] truncate text-secondary text-[11px]">{proc.status}</div>}
301+
{showStatus && <div className="px-2 py-[3px] truncate text-secondary text-[11px]">{proc.status}</div>}
299302
<div className="px-2 py-[3px] truncate text-secondary">{proc.user}</div>
300-
{!isWindows && (
303+
{showThreads && (
301304
<div className="px-2 py-[3px] truncate text-right text-secondary font-mono text-[11px]">
302305
{proc.numthreads > 1 ? proc.numthreads : ""}
303306
</div>
@@ -326,7 +329,7 @@ export const ProcessViewerView: React.FC<ViewComponentProps<ProcessViewerViewMod
326329
const filteredCount = data?.filteredcount ?? 0;
327330
const processes = data?.processes ?? [];
328331
const hasCpu = data?.hascpu ?? false;
329-
const isWindows = data?.iswindows ?? false;
332+
const platform = data?.platform ?? "";
330333
const startIdx = Math.max(0, Math.floor(scrollTop / RowHeight) - OverscanRows);
331334

332335
// track container height
@@ -355,6 +358,7 @@ export const ProcessViewerView: React.FC<ViewComponentProps<ProcessViewerViewMod
355358
const summary = data?.summary;
356359
const memUsedGb = summary?.memused != null ? (summary.memused / 1024 / 1024 / 1024).toFixed(1) : null;
357360
const memTotalGb = summary?.memtotal != null ? (summary.memtotal / 1024 / 1024 / 1024).toFixed(1) : null;
361+
const cpuPct = summary?.cpusum != null && summary?.numcpu != null && summary.numcpu > 0 ? (summary.cpusum / summary.numcpu).toFixed(1) : null;
358362

359363
return (
360364
<div className="flex flex-col w-full h-full overflow-hidden" ref={containerRef}>
@@ -373,6 +377,11 @@ export const ProcessViewerView: React.FC<ViewComponentProps<ProcessViewerViewMod
373377
Mem: {memUsedGb}G / {memTotalGb}G
374378
</span>
375379
)}
380+
{cpuPct != null && (
381+
<span>
382+
CPU: {cpuPct}% ({summary.numcpu} cores)
383+
</span>
384+
)}
376385
</>
377386
)}
378387
<span className="ml-auto">
@@ -392,14 +401,14 @@ export const ProcessViewerView: React.FC<ViewComponentProps<ProcessViewerViewMod
392401
{error != null && <div className="px-3 py-2 text-xs text-error shrink-0">{error}</div>}
393402

394403
{/* header */}
395-
<TableHeader model={model} sortBy={sortBy} sortDesc={sortDesc} isWindows={isWindows} />
404+
<TableHeader model={model} sortBy={sortBy} sortDesc={sortDesc} platform={platform} />
396405

397406
{/* virtualized rows */}
398407
<div ref={scrollRef} className="flex-1 overflow-y-auto overflow-x-auto" onScroll={handleScroll}>
399408
<div style={{ height: totalHeight, position: "relative", minWidth: "100%" }}>
400409
<div style={{ position: "absolute", top: paddingTop, left: 0, right: 0, minWidth: "100%" }}>
401410
{processes.map((proc) => (
402-
<ProcessRow key={proc.pid} proc={proc} hasCpu={hasCpu} isWindows={isWindows} />
411+
<ProcessRow key={proc.pid} proc={proc} hasCpu={hasCpu} platform={platform} />
403412
))}
404413
</div>
405414
</div>

frontend/types/gotypes.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ declare global {
12791279
summary: ProcessSummary;
12801280
ts: number;
12811281
hascpu?: boolean;
1282-
iswindows?: boolean;
1282+
platform?: string;
12831283
totalcount?: number;
12841284
filteredcount?: number;
12851285
};

pkg/util/procinfo/procinfo_darwin.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ import (
1515
"golang.org/x/sys/unix"
1616
)
1717

18-
// darwinStatStatus maps P_stat from ExternProc to a human-readable name.
19-
// Values from sys/proc.h: SIDL=1, SRUN=2, SSLEEP=3, SSTOP=4, SZOMB=5, SDEAD=6.
20-
var darwinStatStatus = map[int8]string{
21-
1: "idle",
22-
2: "running",
23-
3: "sleeping",
24-
4: "stopped",
25-
5: "zombie",
26-
6: "dead",
27-
}
28-
2918
const (
3019
systemLibPath = "/usr/lib/libSystem.B.dylib"
3120
procPidInfoSym = "proc_pidinfo"
@@ -92,16 +81,10 @@ func GetProcInfo(ctx context.Context, _ any, pid int32) (*ProcInfo, error) {
9281
return nil, fmt.Errorf("procinfo: SysctlKinfoProc pid %d: %w", pid, err)
9382
}
9483

95-
status, ok := darwinStatStatus[k.Proc.P_stat]
96-
if !ok {
97-
status = "unknown"
98-
}
99-
10084
info := &ProcInfo{
10185
Pid: int32(k.Proc.P_pid),
10286
Ppid: k.Eproc.Ppid,
10387
Command: unix.ByteSliceToString(k.Proc.P_comm[:]),
104-
Status: status,
10588
Uid: k.Eproc.Ucred.Uid,
10689
}
10790

pkg/wshrpc/wshremote/processviewer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func (s *procCacheState) collectSnapshot(numCPU int) *wshrpc.ProcessListResponse
275275
Summary: summary,
276276
Ts: time.Now().UnixMilli(),
277277
HasCPU: hasCPU,
278-
IsWindows: runtime.GOOS == "windows",
278+
Platform: runtime.GOOS,
279279
}
280280
}
281281

@@ -415,7 +415,7 @@ func (impl *ServerImpl) RemoteProcessListCommand(ctx context.Context, data wshrp
415415
Summary: raw.Summary,
416416
Ts: raw.Ts,
417417
HasCPU: raw.HasCPU,
418-
IsWindows: raw.IsWindows,
418+
Platform: raw.Platform,
419419
}, nil
420420
}
421421

@@ -442,7 +442,7 @@ func (impl *ServerImpl) RemoteProcessListCommand(ctx context.Context, data wshrp
442442
Summary: raw.Summary,
443443
Ts: raw.Ts,
444444
HasCPU: raw.HasCPU,
445-
IsWindows: raw.IsWindows,
445+
Platform: raw.Platform,
446446
TotalCount: totalCount,
447447
FilteredCount: filteredCount,
448448
}, nil

pkg/wshrpc/wshrpctypes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ type ProcessListResponse struct {
940940
Summary ProcessSummary `json:"summary"`
941941
Ts int64 `json:"ts"`
942942
HasCPU bool `json:"hascpu,omitempty"`
943-
IsWindows bool `json:"iswindows,omitempty"`
943+
Platform string `json:"platform,omitempty"`
944944
TotalCount int `json:"totalcount,omitempty"`
945945
FilteredCount int `json:"filteredcount,omitempty"`
946946
}

0 commit comments

Comments
 (0)