@lune_99/pi-shell-inspector 1.3.0 → 1.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.
- package/CHANGELOG.md +10 -1
- package/README.md +3 -3
- package/package.json +5 -5
- package/src/shell/shell-inspector.ts +73 -38
- package/src/shell/shell-manager.ts +7 -7
- package/src/shell/shell-notification-box.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.4.0] - 2026-11-28
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **Running shells first in `/shell`.** The job list puts running shells above settled ones, each in start order, so active work stays at the top. The selection now stays on its shell when a shell starts or settles, and reopening the inspector returns to the same shell instead of the same row.
|
|
10
|
+
|
|
11
|
+
- **Core 0.2 dependency.** Require `@lune_99/pi-lune-extensions-core@^0.2.1`. The earlier `^0.1.0` range excluded Core 0.2, so an installation kept Core 0.1.0 beside the newer Core that other Lune packages load.
|
|
12
|
+
|
|
5
13
|
## [1.3.0] - 2026-11-05
|
|
6
14
|
|
|
7
15
|
### Changed
|
|
@@ -185,7 +193,8 @@
|
|
|
185
193
|
output retention with full-output spill files, terminal-screen rendering of streamed output, and
|
|
186
194
|
persistence/restore of shell state across session lifecycle events.
|
|
187
195
|
|
|
188
|
-
[Unreleased]: https://github.com/Nouvelle-Lune/lune-pi/compare/pi-shell-inspector/v1.
|
|
196
|
+
[Unreleased]: https://github.com/Nouvelle-Lune/lune-pi/compare/pi-shell-inspector/v1.4.0...HEAD
|
|
197
|
+
[1.4.0]: https://github.com/Nouvelle-Lune/lune-pi/releases/tag/pi-shell-inspector/v1.4.0
|
|
189
198
|
[1.3.0]: https://github.com/Nouvelle-Lune/lune-pi/releases/tag/pi-shell-inspector/v1.3.0
|
|
190
199
|
[0.1.0]: https://www.npmjs.com/package/@lune_99/pi-shell-inspector/v/0.1.0
|
|
191
200
|
[1.1.0]: https://github.com/Nouvelle-Lune/lune-shell-inspector/compare/v1.0.3...v1.1.0
|
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ Run:
|
|
|
78
78
|
|
|
79
79
|
to open the shell inspector.
|
|
80
80
|
|
|
81
|
-
The job list stays on the left, showing a job's label when it has one and its command otherwise; the selected shell's command, status, working directory, duration, exit information, and terminal output appear on the right.
|
|
81
|
+
The job list stays on the left, showing a job's label when it has one and its command otherwise; the selected shell's command, status, working directory, duration, exit information, and terminal output appear on the right. Running shells come first, then settled ones, each in start order. The selection stays on its shell when the order changes.
|
|
82
82
|
|
|
83
83
|
Keyboard controls:
|
|
84
84
|
|
|
@@ -94,7 +94,7 @@ Keyboard controls:
|
|
|
94
94
|
|
|
95
95
|
Killing a running shell stops its process tree but keeps it in the list, with its output still readable. Clearing a completed, failed, or killed shell removes it from the list once you are done with it.
|
|
96
96
|
|
|
97
|
-
The inspector remembers which shell you were viewing: close it and reopen `/shell` and the
|
|
97
|
+
The inspector remembers which shell you were viewing: close it and reopen `/shell` and the same shell is selected, also when the list order changed. The selection lives in memory only, so a reloaded or resumed session opens on the first shell again.
|
|
98
98
|
|
|
99
99
|
In pi's fullscreen mode (the default since pi 1.0.0), the mouse works too: the wheel scrolls the output pane or moves the selection over the job list, and clicking a job selects it. Regular mode leaves the mouse to the terminal, so every action keeps its key.
|
|
100
100
|
|
|
@@ -134,7 +134,7 @@ npm run tui:demo
|
|
|
134
134
|
|
|
135
135
|
`@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui`, and `typebox` are supplied by the Pi host at runtime, so the package declares them as `peerDependencies` with a `"*"` range and never bundles them. They are repeated in `devDependencies` so local typecheck and tests resolve the same modules Pi injects.
|
|
136
136
|
|
|
137
|
-
The Dock contribution comes from `@lune_99/pi-lune-extensions-core/dock`. Core is a required runtime dependency (`@lune_99/pi-lune-extensions-core@^0.1
|
|
137
|
+
The Dock contribution comes from `@lune_99/pi-lune-extensions-core/dock`. Core is a required runtime dependency (`@lune_99/pi-lune-extensions-core@^0.2.1` from npm); no sibling checkout or local build is needed. The optional Dock host is separate: without a compatible host, the plugin keeps its independent status bar.
|
|
138
138
|
|
|
139
139
|
## License
|
|
140
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lune_99/pi-shell-inspector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Shell dock and /shell inspector for pi's background bash jobs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"node": ">=22.19.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lune_99/pi-lune-extensions-core": "^0.1
|
|
49
|
+
"@lune_99/pi-lune-extensions-core": "^0.2.1",
|
|
50
50
|
"@xterm/headless": "^6.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@earendil-works/pi-ai": "1.
|
|
70
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
71
|
-
"@earendil-works/pi-tui": "1.
|
|
69
|
+
"@earendil-works/pi-ai": "1.6.0",
|
|
70
|
+
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
71
|
+
"@earendil-works/pi-tui": "1.6.0",
|
|
72
72
|
"@types/node": "^22.20.2",
|
|
73
73
|
"typebox": "1.3.27",
|
|
74
74
|
"typescript": "5.9.3"
|
|
@@ -27,7 +27,7 @@ import { OutputViewport } from "./inspector/output-viewport.ts";
|
|
|
27
27
|
import { renderDetails, renderEmptyList, renderJobList } from "./inspector/panes.ts";
|
|
28
28
|
import { ScrollbarVisibility } from "./inspector/scrollbar.ts";
|
|
29
29
|
import { formatShellCommand } from "./shell-command.ts";
|
|
30
|
-
import type { ShellManager } from "./shell-manager.ts";
|
|
30
|
+
import type { ShellJob, ShellManager } from "./shell-manager.ts";
|
|
31
31
|
|
|
32
32
|
const REFRESH_INTERVAL_MS = 1000;
|
|
33
33
|
|
|
@@ -71,6 +71,8 @@ export async function openShellInspector(
|
|
|
71
71
|
interface FrameLayout {
|
|
72
72
|
geometry: PaneGeometry;
|
|
73
73
|
listStart: number;
|
|
74
|
+
/** Job IDs as the list showed them, so a click selects the shell the user saw in that row. */
|
|
75
|
+
order: readonly string[];
|
|
74
76
|
/** Columns of the back-to-bottom label on the bottom separator, while one is drawn. */
|
|
75
77
|
backToBottom?: { start: number; end: number };
|
|
76
78
|
}
|
|
@@ -83,6 +85,8 @@ export class ShellInspector implements Component {
|
|
|
83
85
|
private readonly terminalRows: () => number;
|
|
84
86
|
private readonly theme: Theme;
|
|
85
87
|
|
|
88
|
+
private selectedId: string | undefined;
|
|
89
|
+
/** Row of the selection in the last frame, which a cleared shell leaves to the next one. */
|
|
86
90
|
private selectedIndex = 0;
|
|
87
91
|
private unsubscribeJobs: (() => void) | undefined;
|
|
88
92
|
private refreshTimer: ReturnType<typeof setInterval> | undefined;
|
|
@@ -113,9 +117,9 @@ export class ShellInspector implements Component {
|
|
|
113
117
|
this.scrollbars = new ScrollbarVisibility(() => this.requestRender());
|
|
114
118
|
this.footerNotice = new FooterNotice(() => this.requestRender());
|
|
115
119
|
|
|
116
|
-
// The
|
|
117
|
-
//
|
|
118
|
-
this.
|
|
120
|
+
// The selection is memory-only state on the manager: reopening the overlay resumes the last
|
|
121
|
+
// shell, while a fresh session starts on the first shell.
|
|
122
|
+
this.selectedId = this.manager.getInspectorJobId();
|
|
119
123
|
|
|
120
124
|
this.unsubscribeJobs = this.manager.subscribe(() => {
|
|
121
125
|
this.syncRefreshTimer();
|
|
@@ -132,26 +136,22 @@ export class ShellInspector implements Component {
|
|
|
132
136
|
return;
|
|
133
137
|
}
|
|
134
138
|
|
|
135
|
-
const
|
|
139
|
+
const selected = this.selectedJob();
|
|
136
140
|
|
|
137
|
-
if (
|
|
141
|
+
if (!selected) {
|
|
138
142
|
return;
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
if (data === "x") {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
type: "killed",
|
|
147
|
-
error: "Shell killed by user",
|
|
148
|
-
});
|
|
149
|
-
}
|
|
146
|
+
this.manager.settleJob(selected.id, {
|
|
147
|
+
type: "killed",
|
|
148
|
+
error: "Shell killed by user",
|
|
149
|
+
});
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (data === "c") {
|
|
154
|
-
this.clearSelectedJob(
|
|
154
|
+
this.clearSelectedJob(selected);
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -228,45 +228,48 @@ export class ShellInspector implements Component {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
const row = event.y - BODY_TOP;
|
|
231
|
-
const index = layout.listStart + row;
|
|
232
|
-
const jobCount = this.manager.getAllJobsList().length;
|
|
233
231
|
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
232
|
+
if (event.x < 1 || event.x >= rightStart - 1 || row < 0 || row >= bodyHeight) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const jobs = this.listedJobs();
|
|
237
|
+
const index = jobs.findIndex((job) => job.id === layout.order[layout.listStart + row]);
|
|
238
|
+
|
|
239
|
+
if (index === -1) {
|
|
241
240
|
return undefined;
|
|
242
241
|
}
|
|
243
242
|
|
|
244
|
-
this.selectJob(
|
|
243
|
+
this.selectJob(jobs, index);
|
|
245
244
|
|
|
246
245
|
return { handled: true };
|
|
247
246
|
}
|
|
248
247
|
|
|
249
248
|
render(width: number): string[] {
|
|
250
|
-
const jobs = this.
|
|
249
|
+
const jobs = this.listedJobs();
|
|
251
250
|
const hasJobs = jobs.length > 0;
|
|
252
251
|
|
|
253
252
|
this.syncRefreshTimer();
|
|
254
253
|
|
|
254
|
+
const index = this.selectionIndex(jobs);
|
|
255
|
+
|
|
255
256
|
if (hasJobs) {
|
|
256
|
-
this.selectedIndex =
|
|
257
|
+
this.selectedIndex = index;
|
|
258
|
+
this.selectedId = jobs[index]!.id;
|
|
257
259
|
} else {
|
|
258
260
|
this.selectedIndex = 0;
|
|
261
|
+
this.selectedId = undefined;
|
|
259
262
|
this.viewport.reset();
|
|
260
263
|
}
|
|
261
264
|
|
|
262
|
-
// The
|
|
263
|
-
this.manager.
|
|
265
|
+
// The shell the user sees is also what a later reopen should restore.
|
|
266
|
+
this.manager.setInspectorJobId(this.selectedId);
|
|
264
267
|
|
|
265
268
|
const geometry = paneGeometry(width, this.terminalRows());
|
|
266
269
|
const { bodyHeight, leftWidth, rightWidth } = geometry;
|
|
267
270
|
const listStart = listWindowStart(this.selectedIndex, jobs.length, bodyHeight);
|
|
268
271
|
|
|
269
|
-
const layout: FrameLayout = { geometry, listStart };
|
|
272
|
+
const layout: FrameLayout = { geometry, listStart, order: jobs.map((job) => job.id) };
|
|
270
273
|
this.layout = layout;
|
|
271
274
|
|
|
272
275
|
const left = hasJobs
|
|
@@ -372,29 +375,61 @@ export class ShellInspector implements Component {
|
|
|
372
375
|
this.requestRender();
|
|
373
376
|
}
|
|
374
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Running shells first. Both parts keep start order, so rows move only as shells start or settle.
|
|
380
|
+
*/
|
|
381
|
+
private listedJobs(): readonly Readonly<ShellJob>[] {
|
|
382
|
+
const jobs = this.manager.getAllJobsList();
|
|
383
|
+
|
|
384
|
+
return [
|
|
385
|
+
...jobs.filter((job) => job.status === "running"),
|
|
386
|
+
...jobs.filter((job) => job.status !== "running"),
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The selected shell's row, or -1 without shells. A cleared shell leaves its row to the next one.
|
|
392
|
+
*/
|
|
393
|
+
private selectionIndex(jobs: readonly Readonly<ShellJob>[]): number {
|
|
394
|
+
const index = jobs.findIndex((job) => job.id === this.selectedId);
|
|
395
|
+
|
|
396
|
+
return index === -1 ? Math.min(this.selectedIndex, jobs.length - 1) : index;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
private selectedJob(): Readonly<ShellJob> | undefined {
|
|
400
|
+
const jobs = this.listedJobs();
|
|
401
|
+
|
|
402
|
+
return jobs[this.selectionIndex(jobs)];
|
|
403
|
+
}
|
|
404
|
+
|
|
375
405
|
private moveSelection(step: number): void {
|
|
376
|
-
const
|
|
406
|
+
const jobs = this.listedJobs();
|
|
377
407
|
|
|
378
|
-
if (
|
|
408
|
+
if (jobs.length === 0 || step === 0) {
|
|
379
409
|
return;
|
|
380
410
|
}
|
|
381
411
|
|
|
382
|
-
|
|
412
|
+
const index = this.selectionIndex(jobs);
|
|
413
|
+
|
|
414
|
+
this.selectJob(jobs, Math.min(jobs.length - 1, Math.max(0, index + step)));
|
|
383
415
|
}
|
|
384
416
|
|
|
385
|
-
private selectJob(
|
|
386
|
-
|
|
417
|
+
private selectJob(jobs: readonly Readonly<ShellJob>[], index: number): void {
|
|
418
|
+
const job = jobs[index];
|
|
419
|
+
|
|
420
|
+
if (!job || job.id === this.selectedId) {
|
|
387
421
|
return;
|
|
388
422
|
}
|
|
389
423
|
|
|
424
|
+
this.selectedId = job.id;
|
|
390
425
|
this.selectedIndex = index;
|
|
391
|
-
this.manager.
|
|
426
|
+
this.manager.setInspectorJobId(job.id);
|
|
392
427
|
|
|
393
428
|
// A different job has a different output; reading it from the middle would be confusing.
|
|
394
429
|
this.viewport.follow();
|
|
395
430
|
this.scrollbars.hide("output");
|
|
396
431
|
|
|
397
|
-
if (this.layout &&
|
|
432
|
+
if (this.layout && jobs.length > this.layout.geometry.bodyHeight) {
|
|
398
433
|
this.scrollbars.show("jobs");
|
|
399
434
|
}
|
|
400
435
|
|
|
@@ -402,7 +437,7 @@ export class ShellInspector implements Component {
|
|
|
402
437
|
}
|
|
403
438
|
|
|
404
439
|
private scrollOutput(step: number): void {
|
|
405
|
-
const job = this.
|
|
440
|
+
const job = this.selectedJob();
|
|
406
441
|
|
|
407
442
|
if (!job) {
|
|
408
443
|
return;
|
|
@@ -118,12 +118,12 @@ export class ShellManager {
|
|
|
118
118
|
readonly jobsStatusStat: JobsStatusStat;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
121
|
+
* ID of the shell the inspector last showed.
|
|
122
122
|
*
|
|
123
123
|
* Memory-only view state: it stays out of the session snapshot, so a reloaded, resumed or
|
|
124
124
|
* tree-restored session opens the inspector on the first shell again.
|
|
125
125
|
*/
|
|
126
|
-
private
|
|
126
|
+
private inspectorJobId: string | undefined;
|
|
127
127
|
|
|
128
128
|
constructor() {
|
|
129
129
|
this.jobsStatusStat = {
|
|
@@ -202,7 +202,7 @@ export class ShellManager {
|
|
|
202
202
|
// clear the manager status before emitting the jobs-cleared event
|
|
203
203
|
this.jobs.clear();
|
|
204
204
|
this.clearManagerstatus();
|
|
205
|
-
this.
|
|
205
|
+
this.inspectorJobId = undefined;
|
|
206
206
|
this.emit({
|
|
207
207
|
type: "jobs-cleared",
|
|
208
208
|
});
|
|
@@ -309,12 +309,12 @@ export class ShellManager {
|
|
|
309
309
|
return Array.from(this.jobs.values());
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
|
|
313
|
-
return this.
|
|
312
|
+
getInspectorJobId(): string | undefined {
|
|
313
|
+
return this.inspectorJobId;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
|
|
317
|
-
this.
|
|
316
|
+
setInspectorJobId(id: string | undefined): void {
|
|
317
|
+
this.inspectorJobId = id;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
getRunningJobsList(): readonly Readonly<ShellJob>[] {
|
|
@@ -146,7 +146,7 @@ class BackgroundShellNotificationBox implements Component {
|
|
|
146
146
|
return this.themed?.component.handleMouse?.(event);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
render(width: number): string[] {
|
|
149
|
+
render(width: number): readonly string[] {
|
|
150
150
|
const renderer = luneThemeRenderer();
|
|
151
151
|
|
|
152
152
|
if (renderer) {
|