@aliou/pi-processes 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,166 @@
1
+ import type { Theme } from "@mariozechner/pi-coding-agent";
2
+ import { type Component, matchesKey, visibleWidth } from "@mariozechner/pi-tui";
3
+ import type { ProcessInfo } from "../constants";
4
+ import type { ProcessManager } from "../manager";
5
+ import { statusIcon, statusLabel } from "./status-format";
6
+
7
+ /**
8
+ * A simple process picker component. Shows a list of processes and lets the
9
+ * user select one with up/down + Enter, or dismiss with Escape/q.
10
+ */
11
+ export class ProcessPickerComponent implements Component {
12
+ private tui: { requestRender: () => void };
13
+ private theme: Theme;
14
+ private onClose: (processId?: string) => void;
15
+ private manager: ProcessManager;
16
+ private title: string;
17
+ private filter: (proc: ProcessInfo) => boolean;
18
+
19
+ private selectedIndex = 0;
20
+ private cachedLines: string[] = [];
21
+ private cachedWidth = 0;
22
+ private unsubscribe: (() => void) | null = null;
23
+
24
+ constructor(
25
+ tui: { requestRender: () => void },
26
+ theme: Theme,
27
+ onClose: (processId?: string) => void,
28
+ manager: ProcessManager,
29
+ title: string,
30
+ filter?: (proc: ProcessInfo) => boolean,
31
+ ) {
32
+ this.tui = tui;
33
+ this.theme = theme;
34
+ this.onClose = onClose;
35
+ this.manager = manager;
36
+ this.title = title;
37
+ this.filter = filter ?? (() => true);
38
+
39
+ this.unsubscribe = this.manager.onEvent(() => {
40
+ this.invalidate();
41
+ this.tui.requestRender();
42
+ });
43
+ }
44
+
45
+ private getProcesses(): ProcessInfo[] {
46
+ return this.manager.list().filter(this.filter);
47
+ }
48
+
49
+ handleInput(data: string): boolean {
50
+ const processes = this.getProcesses();
51
+
52
+ if (matchesKey(data, "down") || data === "j") {
53
+ if (processes.length > 0) {
54
+ this.selectedIndex = Math.min(
55
+ this.selectedIndex + 1,
56
+ processes.length - 1,
57
+ );
58
+ this.invalidate();
59
+ this.tui.requestRender();
60
+ }
61
+ return true;
62
+ }
63
+
64
+ if (matchesKey(data, "up") || data === "k") {
65
+ if (processes.length > 0) {
66
+ this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
67
+ this.invalidate();
68
+ this.tui.requestRender();
69
+ }
70
+ return true;
71
+ }
72
+
73
+ if (matchesKey(data, "return")) {
74
+ if (processes.length > 0 && this.selectedIndex < processes.length) {
75
+ const proc = processes[this.selectedIndex];
76
+ if (proc) {
77
+ this.unsubscribe?.();
78
+ this.unsubscribe = null;
79
+ this.onClose(proc.id);
80
+ }
81
+ }
82
+ return true;
83
+ }
84
+
85
+ if (matchesKey(data, "escape") || data === "q" || data === "Q") {
86
+ this.unsubscribe?.();
87
+ this.unsubscribe = null;
88
+ this.onClose();
89
+ return true;
90
+ }
91
+
92
+ return true;
93
+ }
94
+
95
+ invalidate(): void {
96
+ this.cachedWidth = 0;
97
+ this.cachedLines = [];
98
+ }
99
+
100
+ render(width: number): string[] {
101
+ if (width === this.cachedWidth && this.cachedLines.length > 0) {
102
+ return this.cachedLines;
103
+ }
104
+
105
+ const theme = this.theme;
106
+ const dim = (s: string) => theme.fg("dim", s);
107
+ const accent = (s: string) => theme.fg("accent", s);
108
+ const bold = (s: string) => theme.bold(s);
109
+ const border = (s: string) => theme.fg("dim", s);
110
+ const innerWidth = width - 2;
111
+
112
+ const padLine = (content: string): string => {
113
+ const len = visibleWidth(content);
114
+ return ` ${content}${" ".repeat(Math.max(0, innerWidth - len))} `;
115
+ };
116
+
117
+ const lines: string[] = [];
118
+ const processes = this.getProcesses();
119
+
120
+ // Header
121
+ const titleText = ` ${this.title} `;
122
+ const titleLen = titleText.length;
123
+ const borderLen = Math.max(0, width - titleLen);
124
+ const leftBorder = Math.floor(borderLen / 2);
125
+ const rightBorder = borderLen - leftBorder;
126
+ lines.push(
127
+ border("─".repeat(leftBorder)) +
128
+ accent(bold(titleText)) +
129
+ border("─".repeat(rightBorder)),
130
+ );
131
+
132
+ if (processes.length === 0) {
133
+ lines.push(padLine(""));
134
+ lines.push(padLine(dim("No processes available")));
135
+ lines.push(padLine(""));
136
+ } else {
137
+ lines.push(padLine(""));
138
+ for (let i = 0; i < processes.length; i++) {
139
+ const proc = processes[i];
140
+ if (!proc) continue;
141
+ const isSelected = i === this.selectedIndex;
142
+ const icon = statusIcon(proc.status, proc.success);
143
+ const label = statusLabel(proc);
144
+ const prefix = isSelected ? accent("> ") : " ";
145
+ const name = isSelected ? accent(proc.name) : proc.name;
146
+ const id = dim(`(${proc.id})`);
147
+ const status = dim(`${icon} ${label}`);
148
+ lines.push(padLine(`${prefix}${name} ${id} ${status}`));
149
+ }
150
+ lines.push(padLine(""));
151
+ }
152
+
153
+ // Footer
154
+ lines.push(border("─".repeat(width)));
155
+ lines.push(
156
+ padLine(
157
+ `${dim("j/k")} select ${dim("enter")} confirm ${dim("q")} cancel`,
158
+ ),
159
+ );
160
+ lines.push(border("─".repeat(width)));
161
+
162
+ this.cachedLines = lines;
163
+ this.cachedWidth = width;
164
+ return this.cachedLines;
165
+ }
166
+ }
@@ -0,0 +1,459 @@
1
+ import type { Theme } from "@mariozechner/pi-coding-agent";
2
+ import { type Component, matchesKey, visibleWidth } from "@mariozechner/pi-tui";
3
+ import { configLoader } from "../config";
4
+ import type { ProcessInfo } from "../constants";
5
+ import type { ProcessManager } from "../manager";
6
+ import { stripAnsi } from "../utils";
7
+ import { statusIcon, statusLabel } from "./status-format";
8
+
9
+ function formatRuntime(startTime: number, endTime: number | null): string {
10
+ const end = endTime ?? Date.now();
11
+ const ms = end - startTime;
12
+ const seconds = Math.floor(ms / 1000);
13
+ const minutes = Math.floor(seconds / 60);
14
+ const hours = Math.floor(minutes / 60);
15
+
16
+ if (hours > 0) {
17
+ return `${hours}h ${minutes % 60}m`;
18
+ }
19
+ if (minutes > 0) {
20
+ return `${minutes}m ${seconds % 60}s`;
21
+ }
22
+ return `${seconds}s`;
23
+ }
24
+
25
+ function formatBytes(bytes: number): string {
26
+ if (bytes >= 1024 * 1024) {
27
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
28
+ }
29
+ if (bytes >= 1024) {
30
+ return `${(bytes / 1024).toFixed(1)}KB`;
31
+ }
32
+ return `${bytes}B`;
33
+ }
34
+
35
+ function truncate(str: string, maxLen: number): string {
36
+ if (maxLen <= 3) return str.slice(0, maxLen);
37
+ if (str.length <= maxLen) return str;
38
+ return `${str.slice(0, maxLen - 3)}...`;
39
+ }
40
+
41
+ export class ProcessesComponent implements Component {
42
+ private tui: { requestRender: () => void };
43
+ private theme: Theme;
44
+ private onClose: (processId?: string) => void;
45
+ private manager: ProcessManager;
46
+
47
+ private selectedIndex = 0;
48
+ private processScrollOffset = 0;
49
+ private logScrollOffset = 0;
50
+ private scrollInfo = { above: 0, below: 0 };
51
+ private cachedLines: string[] = [];
52
+ private cachedWidth = 0;
53
+ private unsubscribe: (() => void) | null = null;
54
+
55
+ constructor(
56
+ tui: { requestRender: () => void },
57
+ theme: Theme,
58
+ onClose: (processId?: string) => void,
59
+ manager: ProcessManager,
60
+ ) {
61
+ this.tui = tui;
62
+ this.theme = theme;
63
+ this.onClose = onClose;
64
+ this.manager = manager;
65
+
66
+ this.unsubscribe = this.manager.onEvent(() => {
67
+ this.invalidate();
68
+ this.tui.requestRender();
69
+ });
70
+ }
71
+
72
+ handleInput(data: string): boolean {
73
+ const processes = this.manager.list();
74
+
75
+ // Navigation
76
+ if (matchesKey(data, "down") || data === "j") {
77
+ if (processes.length > 0) {
78
+ this.selectedIndex = Math.min(
79
+ this.selectedIndex + 1,
80
+ processes.length - 1,
81
+ );
82
+ this.logScrollOffset = 0;
83
+ this.ensureProcessVisible(processes.length);
84
+ this.invalidate();
85
+ this.tui.requestRender();
86
+ }
87
+ return true;
88
+ }
89
+
90
+ if (matchesKey(data, "up") || data === "k") {
91
+ if (processes.length > 0) {
92
+ this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
93
+ this.logScrollOffset = 0;
94
+ this.ensureProcessVisible(processes.length);
95
+ this.invalidate();
96
+ this.tui.requestRender();
97
+ }
98
+ return true;
99
+ }
100
+
101
+ // Scroll logs
102
+ if (data === "J") {
103
+ this.logScrollOffset = Math.max(0, this.logScrollOffset - 5);
104
+ this.invalidate();
105
+ this.tui.requestRender();
106
+ return true;
107
+ }
108
+
109
+ if (data === "K") {
110
+ this.logScrollOffset += 5;
111
+ this.invalidate();
112
+ this.tui.requestRender();
113
+ return true;
114
+ }
115
+
116
+ // Stream logs for selected process
117
+ if (matchesKey(data, "return")) {
118
+ if (processes.length > 0 && this.selectedIndex < processes.length) {
119
+ const proc = processes[this.selectedIndex];
120
+ if (proc) {
121
+ this.unsubscribe?.();
122
+ this.unsubscribe = null;
123
+ this.onClose(proc.id);
124
+ }
125
+ }
126
+ return true;
127
+ }
128
+
129
+ // Kill selected process
130
+ if (data === "x") {
131
+ if (processes.length > 0 && this.selectedIndex < processes.length) {
132
+ const proc = processes[this.selectedIndex];
133
+ if (proc?.status === "running") {
134
+ void this.manager.kill(proc.id, {
135
+ signal: "SIGTERM",
136
+ timeoutMs: 3000,
137
+ });
138
+ } else if (proc?.status === "terminate_timeout") {
139
+ void this.manager.kill(proc.id, {
140
+ signal: "SIGKILL",
141
+ timeoutMs: 200,
142
+ });
143
+ }
144
+ }
145
+ return true;
146
+ }
147
+
148
+ // Clear finished processes
149
+ if (data === "c" || data === "C") {
150
+ const cleared = this.manager.clearFinished();
151
+ if (cleared > 0) {
152
+ const remaining = this.manager.list();
153
+ if (this.selectedIndex >= remaining.length) {
154
+ this.selectedIndex = Math.max(0, remaining.length - 1);
155
+ }
156
+ this.ensureProcessVisible(remaining.length);
157
+ this.invalidate();
158
+ this.tui.requestRender();
159
+ }
160
+ return true;
161
+ }
162
+
163
+ // Close
164
+ if (matchesKey(data, "escape") || data === "q" || data === "Q") {
165
+ this.unsubscribe?.();
166
+ this.unsubscribe = null;
167
+ this.onClose();
168
+ return true;
169
+ }
170
+
171
+ return true;
172
+ }
173
+
174
+ private ensureProcessVisible(totalProcesses: number): void {
175
+ const maxVisibleProcesses =
176
+ configLoader.getConfig().processList.maxVisibleProcesses;
177
+ const visibleCount = Math.min(maxVisibleProcesses, totalProcesses);
178
+ if (this.selectedIndex < this.processScrollOffset) {
179
+ this.processScrollOffset = this.selectedIndex;
180
+ } else if (this.selectedIndex >= this.processScrollOffset + visibleCount) {
181
+ this.processScrollOffset = this.selectedIndex - visibleCount + 1;
182
+ }
183
+ this.processScrollOffset = Math.max(
184
+ 0,
185
+ Math.min(this.processScrollOffset, totalProcesses - visibleCount),
186
+ );
187
+ }
188
+
189
+ invalidate(): void {
190
+ this.cachedWidth = 0;
191
+ this.cachedLines = [];
192
+ }
193
+
194
+ render(width: number): string[] {
195
+ if (width === this.cachedWidth && this.cachedLines.length > 0) {
196
+ return this.cachedLines;
197
+ }
198
+
199
+ const cfg = configLoader.getConfig().processList;
200
+ const maxVisibleProcesses = cfg.maxVisibleProcesses;
201
+ const maxPreviewLines = cfg.maxPreviewLines;
202
+
203
+ const theme = this.theme;
204
+ const dim = (s: string) => theme.fg("dim", s);
205
+ const accent = (s: string) => theme.fg("accent", s);
206
+ const warning = (s: string) => theme.fg("warning", s);
207
+ const bold = (s: string) => theme.bold(s);
208
+ const border = (s: string) => theme.fg("dim", s);
209
+
210
+ const lines: string[] = [];
211
+ const processes = this.manager.list();
212
+ const innerWidth = width - 2;
213
+
214
+ const padLine = (content: string): string => {
215
+ const len = visibleWidth(content);
216
+ return ` ${content}${" ".repeat(Math.max(0, innerWidth - len))} `;
217
+ };
218
+
219
+ const title = " Background Processes ";
220
+ const titleLen = title.length;
221
+ const borderLen = Math.max(0, width - titleLen);
222
+ const leftBorder = Math.floor(borderLen / 2);
223
+ const rightBorder = borderLen - leftBorder;
224
+ lines.push(
225
+ border("─".repeat(leftBorder)) +
226
+ accent(bold(title)) +
227
+ border("─".repeat(rightBorder)),
228
+ );
229
+
230
+ if (processes.length === 0) {
231
+ lines.push(padLine(""));
232
+ lines.push(padLine(dim("No background processes")));
233
+ lines.push(padLine(dim("Use the processes tool to start commands")));
234
+ lines.push(padLine(""));
235
+ } else {
236
+ const prefixWidth = 2;
237
+ const idWidth = 9;
238
+ const nameWidth = 15;
239
+ const statusWidth = 18;
240
+ const timeWidth = 8;
241
+ const sizeWidth = 8;
242
+
243
+ const hasProcessScroll = processes.length > maxVisibleProcesses;
244
+ const headerSuffixText = hasProcessScroll
245
+ ? ` [${this.processScrollOffset + 1}-${Math.min(this.processScrollOffset + maxVisibleProcesses, processes.length)}/${processes.length}]`
246
+ : "";
247
+ const headerSuffixLen = hasProcessScroll ? headerSuffixText.length : 0;
248
+
249
+ // Reserve space for scroll suffix in the command column
250
+ const cmdWidth = Math.max(
251
+ 10,
252
+ innerWidth -
253
+ prefixWidth -
254
+ idWidth -
255
+ nameWidth -
256
+ statusWidth -
257
+ timeWidth -
258
+ sizeWidth -
259
+ headerSuffixLen,
260
+ );
261
+
262
+ lines.push(padLine(""));
263
+ const header =
264
+ " " +
265
+ dim("ID".padEnd(idWidth)) +
266
+ dim("Name".padEnd(nameWidth)) +
267
+ dim("Command".padEnd(cmdWidth)) +
268
+ dim("Status".padEnd(statusWidth)) +
269
+ dim("Time".padEnd(timeWidth)) +
270
+ dim("Size".padStart(sizeWidth)) +
271
+ (hasProcessScroll ? dim(headerSuffixText) : "");
272
+ lines.push(padLine(header));
273
+ lines.push(border("─".repeat(width)));
274
+
275
+ const visibleProcessCount = Math.min(
276
+ maxVisibleProcesses,
277
+ processes.length,
278
+ );
279
+ const startIdx = this.processScrollOffset;
280
+ const endIdx = startIdx + visibleProcessCount;
281
+
282
+ for (let i = startIdx; i < endIdx; i++) {
283
+ const proc = processes[i];
284
+ if (!proc) continue;
285
+ const isSelected = i === this.selectedIndex;
286
+ const sizes = this.manager.getFileSize(proc.id);
287
+ const totalSize = sizes ? sizes.stdout + sizes.stderr : 0;
288
+
289
+ const statusText = this.formatStatus(proc);
290
+ const statusPadding =
291
+ statusWidth + (statusText.length - visibleWidth(statusText));
292
+
293
+ const row =
294
+ (isSelected
295
+ ? accent(proc.id.padEnd(idWidth))
296
+ : proc.id.padEnd(idWidth)) +
297
+ truncate(proc.name, nameWidth - 1).padEnd(nameWidth) +
298
+ truncate(proc.command, cmdWidth - 1).padEnd(cmdWidth) +
299
+ statusText.padEnd(statusPadding) +
300
+ formatRuntime(proc.startTime, proc.endTime).padEnd(timeWidth) +
301
+ formatBytes(totalSize).padStart(sizeWidth);
302
+
303
+ if (isSelected) {
304
+ lines.push(padLine(`${accent(">")} ${row}`));
305
+ } else {
306
+ lines.push(padLine(` ${row}`));
307
+ }
308
+ }
309
+
310
+ for (let i = visibleProcessCount; i < maxVisibleProcesses; i++) {
311
+ lines.push(padLine(""));
312
+ }
313
+
314
+ if (this.selectedIndex < processes.length) {
315
+ const selected = processes[this.selectedIndex];
316
+ if (!selected) {
317
+ this.cachedLines = lines;
318
+ this.cachedWidth = width;
319
+ return this.cachedLines;
320
+ }
321
+ const output = this.manager.getOutput(selected.id, maxPreviewLines * 2);
322
+ const sizes = this.manager.getFileSize(selected.id);
323
+
324
+ lines.push(border("─".repeat(width)));
325
+
326
+ const logTitlePlain = `Output: ${selected.name} (${selected.id})`;
327
+ const sizeInfoPlain = sizes
328
+ ? ` stdout: ${formatBytes(sizes.stdout)}, stderr: ${formatBytes(sizes.stderr)}`
329
+ : "";
330
+ const combinedPlain = logTitlePlain + sizeInfoPlain;
331
+ // Truncate if combined exceeds innerWidth, prioritizing the title
332
+ if (combinedPlain.length <= innerWidth) {
333
+ const logTitle = `Output: ${accent(selected.name)} ${dim(`(${selected.id})`)}`;
334
+ const sizeInfo = sizes ? dim(sizeInfoPlain) : "";
335
+ lines.push(padLine(logTitle + sizeInfo));
336
+ } else {
337
+ const maxNameLen = Math.max(
338
+ 8,
339
+ innerWidth -
340
+ (`Output: (${selected.id})`.length + sizeInfoPlain.length),
341
+ );
342
+ const tName = truncate(selected.name, maxNameLen);
343
+ const logTitle = `Output: ${accent(tName)} ${dim(`(${selected.id})`)}`;
344
+ const sizeInfo = sizes ? dim(sizeInfoPlain) : "";
345
+ lines.push(padLine(logTitle + sizeInfo));
346
+ }
347
+ lines.push(padLine(""));
348
+
349
+ let renderedLines = 0;
350
+
351
+ if (output) {
352
+ const logLines: { type: "stdout" | "stderr"; text: string }[] = [];
353
+ for (const line of output.stdout) {
354
+ logLines.push({ type: "stdout", text: line });
355
+ }
356
+ for (const line of output.stderr) {
357
+ logLines.push({ type: "stderr", text: line });
358
+ }
359
+
360
+ if (logLines.length === 0) {
361
+ lines.push(padLine(dim("(no output yet)")));
362
+ renderedLines = 1;
363
+ } else {
364
+ const startIdx = Math.max(
365
+ 0,
366
+ logLines.length - maxPreviewLines - this.logScrollOffset,
367
+ );
368
+ const endIdx = Math.max(0, logLines.length - this.logScrollOffset);
369
+ const visibleLines = logLines.slice(startIdx, endIdx);
370
+
371
+ this.scrollInfo.above = startIdx;
372
+ this.scrollInfo.below =
373
+ this.logScrollOffset > 0 ? logLines.length - endIdx : 0;
374
+
375
+ for (const line of visibleLines) {
376
+ const displayLine = truncate(
377
+ stripAnsi(line.text),
378
+ innerWidth - 2,
379
+ );
380
+ if (line.type === "stderr") {
381
+ lines.push(padLine(warning(displayLine)));
382
+ } else {
383
+ lines.push(padLine(displayLine));
384
+ }
385
+ renderedLines++;
386
+ }
387
+ }
388
+ }
389
+
390
+ while (renderedLines < maxPreviewLines) {
391
+ lines.push(padLine(""));
392
+ renderedLines++;
393
+ }
394
+ }
395
+ }
396
+
397
+ lines.push(border("─".repeat(width)));
398
+
399
+ const footerLeft =
400
+ `${dim("enter")} stream ` +
401
+ `${dim("j/k")} select ` +
402
+ `${dim("x")} term/kill ` +
403
+ `${dim("c")} clear ` +
404
+ `${dim("q")} quit`;
405
+
406
+ let footerRight = "";
407
+ if (this.scrollInfo.above > 0 || this.scrollInfo.below > 0) {
408
+ const parts: string[] = [];
409
+ if (this.scrollInfo.above > 0) {
410
+ parts.push(`↑${this.scrollInfo.above}`);
411
+ }
412
+ if (this.scrollInfo.below > 0) {
413
+ parts.push(`↓${this.scrollInfo.below}`);
414
+ }
415
+ footerRight = `${dim("J/K")} scroll ${dim(parts.join(" "))}`;
416
+ }
417
+
418
+ const footerLeftLen = visibleWidth(footerLeft);
419
+ const footerRightLen = visibleWidth(footerRight);
420
+ const footerGap = Math.max(2, innerWidth - footerLeftLen - footerRightLen);
421
+ const footer = footerLeft + " ".repeat(footerGap) + footerRight;
422
+
423
+ lines.push(padLine(footer));
424
+ lines.push(border("─".repeat(width)));
425
+
426
+ this.cachedLines = lines;
427
+ this.cachedWidth = width;
428
+
429
+ return this.cachedLines;
430
+ }
431
+
432
+ private formatStatus(proc: ProcessInfo): string {
433
+ const theme = this.theme;
434
+ const dim = (s: string) => theme.fg("dim", s);
435
+ const success = (s: string) => theme.fg("success", s);
436
+ const warning = (s: string) => theme.fg("warning", s);
437
+ const error = (s: string) => theme.fg("error", s);
438
+
439
+ const icon = statusIcon(proc.status, proc.success);
440
+ const label = statusLabel(proc);
441
+
442
+ switch (proc.status) {
443
+ case "running":
444
+ return success(`${icon} ${label}`);
445
+ case "terminating":
446
+ return warning(`${icon} ${label}`);
447
+ case "terminate_timeout":
448
+ return error(`${icon} ${label}`);
449
+ case "killed":
450
+ return warning(`${icon} ${label}`);
451
+ case "exited":
452
+ return proc.success
453
+ ? dim(`${icon} ${label}`)
454
+ : error(`${icon} ${label}`);
455
+ default:
456
+ return dim(`${icon} ${label}`);
457
+ }
458
+ }
459
+ }
@@ -0,0 +1,38 @@
1
+ import type { ProcessInfo, ProcessStatus } from "../constants";
2
+
3
+ export function statusLabel(proc: ProcessInfo): string {
4
+ switch (proc.status) {
5
+ case "running":
6
+ return "running";
7
+ case "terminating":
8
+ return "terminating";
9
+ case "terminate_timeout":
10
+ return "terminate_timeout";
11
+ case "killed":
12
+ return "killed";
13
+ case "exited":
14
+ return proc.success ? "exit(0)" : `exit(${proc.exitCode ?? "?"})`;
15
+ default:
16
+ return proc.status;
17
+ }
18
+ }
19
+
20
+ export function statusIcon(
21
+ status: ProcessStatus,
22
+ success: boolean | null,
23
+ ): string {
24
+ switch (status) {
25
+ case "running":
26
+ return "\u25CF"; // filled circle
27
+ case "terminating":
28
+ return "\u25CF"; // filled circle
29
+ case "terminate_timeout":
30
+ return "\u2717"; // x mark
31
+ case "exited":
32
+ return success ? "\u2713" : "\u2717";
33
+ case "killed":
34
+ return "\u2717";
35
+ default:
36
+ return "?";
37
+ }
38
+ }