@aliou/pi-processes 0.3.2 → 0.3.4
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.
- package/commands/index.ts +50 -8
- package/manager.ts +3 -3
- package/package.json +3 -5
package/commands/index.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { LogStreamComponent } from "../components/log-stream-component";
|
|
2
3
|
import { ProcessesComponent } from "../components/processes-component";
|
|
3
4
|
import type { ProcessManager } from "../manager";
|
|
4
5
|
|
|
6
|
+
const LOG_STREAM_WIDGET_ID = "processes-log-stream";
|
|
7
|
+
|
|
5
8
|
export function setupProcessesCommands(
|
|
6
9
|
pi: ExtensionAPI,
|
|
7
10
|
manager: ProcessManager,
|
|
8
11
|
) {
|
|
12
|
+
// Track whether we're currently streaming logs.
|
|
13
|
+
let isStreaming = false;
|
|
14
|
+
|
|
9
15
|
pi.registerCommand("processes", {
|
|
10
16
|
description: "View and manage background processes",
|
|
11
17
|
handler: async (_args, ctx) => {
|
|
@@ -13,14 +19,50 @@ export function setupProcessesCommands(
|
|
|
13
19
|
ctx.ui.notify("/processes requires interactive mode", "error");
|
|
14
20
|
return;
|
|
15
21
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
// If currently streaming, dismiss the stream widget and show the list.
|
|
24
|
+
if (isStreaming) {
|
|
25
|
+
ctx.ui.setWidget(LOG_STREAM_WIDGET_ID, undefined);
|
|
26
|
+
isStreaming = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const result = await ctx.ui.custom<string | null>(
|
|
30
|
+
(tui, theme, _keybindings, done) => {
|
|
31
|
+
return new ProcessesComponent(
|
|
32
|
+
tui,
|
|
33
|
+
theme,
|
|
34
|
+
(processId?: string) => {
|
|
35
|
+
if (processId) {
|
|
36
|
+
done(processId);
|
|
37
|
+
} else {
|
|
38
|
+
done(null);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
manager,
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// RPC fallback.
|
|
47
|
+
if (result === undefined) {
|
|
48
|
+
ctx.ui.notify("/processes requires interactive mode", "info");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// User dismissed with Escape/q.
|
|
53
|
+
if (result === null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// User selected a process — start streaming its logs.
|
|
58
|
+
isStreaming = true;
|
|
59
|
+
ctx.ui.setWidget(
|
|
60
|
+
LOG_STREAM_WIDGET_ID,
|
|
61
|
+
(tui, theme) => {
|
|
62
|
+
return new LogStreamComponent(tui, theme, manager, result);
|
|
63
|
+
},
|
|
64
|
+
{ placement: "aboveEditor" },
|
|
65
|
+
);
|
|
24
66
|
},
|
|
25
67
|
});
|
|
26
68
|
}
|
package/manager.ts
CHANGED
|
@@ -222,9 +222,9 @@ export class ProcessManager {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
list(): ProcessInfo[] {
|
|
225
|
-
return Array.from(this.processes.values())
|
|
226
|
-
this.toProcessInfo(p)
|
|
227
|
-
|
|
225
|
+
return Array.from(this.processes.values())
|
|
226
|
+
.map((p) => this.toProcessInfo(p))
|
|
227
|
+
.reverse();
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
get(id: string): ProcessInfo | null {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-processes",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"extensions": [
|
|
18
18
|
"./index.ts"
|
|
19
19
|
],
|
|
20
|
-
"video": "https://assets.aliou.me/pi-extensions/
|
|
20
|
+
"video": "https://assets.aliou.me/pi-extensions/demos/pi-processes.mp4"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
@@ -33,8 +33,6 @@
|
|
|
33
33
|
"@sinclair/typebox": "^0.34.41"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@mariozechner/pi-
|
|
37
|
-
"@mariozechner/pi-coding-agent": "0.51.0",
|
|
38
|
-
"@mariozechner/pi-tui": "0.51.0"
|
|
36
|
+
"@mariozechner/pi-coding-agent": ">=0.51.0"
|
|
39
37
|
}
|
|
40
38
|
}
|