@lune_99/pi-shell-inspector 0.1.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 +33 -4
- package/README.md +15 -14
- package/package.json +5 -5
- package/src/index.ts +36 -25
- package/src/shell/dock-alert.ts +78 -0
- package/src/shell/dock-line.ts +42 -0
- package/src/shell/inspector/frame.ts +7 -7
- package/src/shell/inspector/geometry.ts +1 -4
- package/src/shell/inspector/job-format.ts +4 -1
- package/src/shell/inspector/output-rows.ts +3 -1
- package/src/shell/inspector/panes.ts +4 -1
- package/src/shell/shell-dock-contribution.ts +89 -55
- package/src/shell/shell-dock.ts +92 -35
- package/src/shell/shell-inspector.ts +100 -48
- package/src/shell/shell-manager.ts +49 -74
- package/src/shell/shell-notification-box.ts +33 -10
- package/src/shell/shell-notification.ts +51 -34
- package/src/tools/background-bash.ts +10 -9
- package/src/tools/bash-tool.ts +16 -16
- package/src/utils/get-agent-tool-result.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,36 @@
|
|
|
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
|
+
|
|
13
|
+
## [1.3.0] - 2026-11-05
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Quieter idle Dock item.** All display levels show only `○ Shell` when no jobs are tracked, matching Agents without the `· idle` suffix. Job summaries, status markers and inspector behavior are unchanged.
|
|
18
|
+
|
|
19
|
+
- **Dock lines drop whole parts instead of cutting them.** A short Lune Dock cell leaves out the runtime, then the latest command, then the counts, with failures kept longest, then `Shell`, down to the marker alone, as the Agents item does. The row below the editor no longer cuts the running command at 20 columns: it shows the whole command or leaves it out, after the `/shell to open` hint.
|
|
20
|
+
|
|
21
|
+
- **The Dock failure marker clears by itself.** A failed or killed job turns the Lune Dock marker into a red `✕` for 10 seconds, or until you open the inspector. After that, a gray `●` shows while failed jobs are listed and nothing runs, so an item that holds only failures no longer stays red after you have seen it.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- **Package and changelog versions agree.** Resume the existing 1.x version sequence after the scoped npm package's 0.1.0 release. Pi can now record a version newer than the retained history, so old changelog entries stop appearing on every new session after upgrading.
|
|
26
|
+
|
|
27
|
+
- **Each session owns its background shells.** A Lune Subagents run that selected `background_shell` killed the main session's jobs and cleared its shell view, because Pi reuses the loaded module for sessions in the same working directory and the job table lived in that module. Each extension load now has its own shell manager, so a run or a second session cannot see, kill or clear another session's jobs.
|
|
28
|
+
|
|
29
|
+
## [0.1.0] - 2026-10-16
|
|
30
|
+
|
|
5
31
|
### Added
|
|
6
32
|
|
|
7
33
|
- **Optional Lune Dock integration.** When Lune Dock is active, shell state joins its single status row and Enter opens the existing inspector. Viewing the inspector acknowledges current failure reminders without changing job outcomes; without the host, the standalone dock remains available.
|
|
8
|
-
- **Notifications follow the Lune theme.** While
|
|
34
|
+
- **Notifications follow the Lune theme.** While Lune Core Theme is on, settled background shells render as its call tree, with killed jobs marked as cancelled. With the theme off or not installed, the existing band remains, and notifications already on screen switch with the theme.
|
|
9
35
|
- **Clickable themed notifications.** With the Lune theme on, a settled background-shell card opens
|
|
10
36
|
from its `click to show more` hint or its hidden-output row and closes with another click, like
|
|
11
37
|
a tool card. This needs a theme version that accepts the card key; older themes keep the
|
|
@@ -14,10 +40,10 @@
|
|
|
14
40
|
|
|
15
41
|
### Changed
|
|
16
42
|
|
|
17
|
-
- **Published Core dependency.** Require `@lune_99/pi-lune-core@^0.1.0` from npm instead of a sibling checkout. Core remains a mandatory runtime dependency for shared infrastructure and settings.
|
|
43
|
+
- **Published Core dependency.** Require `@lune_99/pi-lune-extensions-core@^0.1.0` from npm instead of a sibling checkout. Core remains a mandatory runtime dependency for shared infrastructure and settings.
|
|
18
44
|
|
|
19
45
|
- **Dock protocol from Core.** Use `createDockContribution` and its types from
|
|
20
|
-
`@lune_99/pi-lune-core/dock` to join the optional shared Dock. Core supplies the
|
|
46
|
+
`@lune_99/pi-lune-extensions-core/dock` to join the optional shared Dock. Core supplies the
|
|
21
47
|
scoped registry and contributor lifecycle.
|
|
22
48
|
|
|
23
49
|
- **BREAKING: Lune Protocol v1 Draft 3 snapshots.** Publish plugin-styled, single-line base/detail/full Components instead of business summary fields. Idle providers stay registered; Dock owns density, visibility and order, while Enter opens the existing plugin UI. Update the host and both plugins together.
|
|
@@ -167,7 +193,10 @@
|
|
|
167
193
|
output retention with full-output spill files, terminal-screen rendering of streamed output, and
|
|
168
194
|
persistence/restore of shell state across session lifecycle events.
|
|
169
195
|
|
|
170
|
-
[Unreleased]: https://github.com/Nouvelle-Lune/lune-shell-inspector/
|
|
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
|
|
198
|
+
[1.3.0]: https://github.com/Nouvelle-Lune/lune-pi/releases/tag/pi-shell-inspector/v1.3.0
|
|
199
|
+
[0.1.0]: https://www.npmjs.com/package/@lune_99/pi-shell-inspector/v/0.1.0
|
|
171
200
|
[1.1.0]: https://github.com/Nouvelle-Lune/lune-shell-inspector/compare/v1.0.3...v1.1.0
|
|
172
201
|
[1.0.3]: https://github.com/Nouvelle-Lune/lune-shell-inspector/compare/v1.0.2...v1.0.3
|
|
173
202
|
[1.0.2]: https://github.com/Nouvelle-Lune/lune-shell-inspector/compare/v1.0.1...v1.0.2
|
package/README.md
CHANGED
|
@@ -16,7 +16,6 @@ Install from npm:
|
|
|
16
16
|
pi install npm:@lune_99/pi-shell-inspector
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
Then start Pi normally:
|
|
21
20
|
|
|
22
21
|
```bash
|
|
@@ -63,10 +62,12 @@ Examples:
|
|
|
63
62
|
5 shells · 3 running · 1 completed · 1 failed · /shell to open
|
|
64
63
|
```
|
|
65
64
|
|
|
66
|
-
The dock updates while jobs are running and disappears when there are no shell jobs to show.
|
|
65
|
+
The dock updates while jobs are running and disappears when there are no shell jobs to show. It never cuts a part: on a narrow terminal it leaves out the hint, the runtime and the command first.
|
|
67
66
|
|
|
68
67
|
With the optional **Lune Dock** host active, this independent row is replaced by a shared one-line dock. Press Down in an empty main editor, select a module with Left/Right, and press Enter to open its panel directly. Closing the panel returns to dock focus. The plugin publishes its own single-line `base`, `detail`, and `full` Components through the Dock protocol in `@lune_99/pi-lune-extensions-core/dock`; `/dock` controls density, visibility and order. Idle state remains available in the shared Dock, and hiding the plugin keeps its snapshots current. Removing the host restores the independent row.
|
|
69
68
|
|
|
69
|
+
The shared dock's marker shows the jobs' state: `◐` yellow while a job runs, `●` green when all jobs completed, `●` gray when some failed or were killed, and `○` without jobs. A new failure shows a red `✕` for 10 seconds, or until you open the inspector.
|
|
70
|
+
|
|
70
71
|
## `/shell` inspector
|
|
71
72
|
|
|
72
73
|
Run:
|
|
@@ -77,23 +78,23 @@ Run:
|
|
|
77
78
|
|
|
78
79
|
to open the shell inspector.
|
|
79
80
|
|
|
80
|
-
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.
|
|
81
82
|
|
|
82
83
|
Keyboard controls:
|
|
83
84
|
|
|
84
|
-
| Action
|
|
85
|
-
|
|
|
86
|
-
| Select shell
|
|
87
|
-
| Scroll output
|
|
88
|
-
| Jump to oldest output | `Home`
|
|
89
|
-
| Follow newest output
|
|
90
|
-
| Kill selected shell
|
|
91
|
-
| Clear selected shell
|
|
92
|
-
| Close inspector
|
|
85
|
+
| Action | Keys |
|
|
86
|
+
| --------------------- | ---------------------------------------------- |
|
|
87
|
+
| Select shell | `↑` / `↓` or `k` / `j` |
|
|
88
|
+
| Scroll output | `Shift+↑` / `Shift+↓` or `Shift+k` / `Shift+j` |
|
|
89
|
+
| Jump to oldest output | `Home` |
|
|
90
|
+
| Follow newest output | `End` |
|
|
91
|
+
| Kill selected shell | `x` |
|
|
92
|
+
| Clear selected shell | `c` |
|
|
93
|
+
| Close inspector | `Esc` |
|
|
93
94
|
|
|
94
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.
|
|
95
96
|
|
|
96
|
-
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.
|
|
97
98
|
|
|
98
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.
|
|
99
100
|
|
|
@@ -133,7 +134,7 @@ npm run tui:demo
|
|
|
133
134
|
|
|
134
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.
|
|
135
136
|
|
|
136
|
-
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.
|
|
137
138
|
|
|
138
139
|
## License
|
|
139
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lune_99/pi-shell-inspector",
|
|
3
|
-
"version": "
|
|
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"
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
|
|
3
3
|
import { ShellDockContribution } from "./shell/shell-dock-contribution.ts";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { ShellManager } from "./shell/shell-manager.ts";
|
|
6
6
|
|
|
7
7
|
import { BashTool, BackgroundShellTool, KillBackgroundShellTool } from "./tools/bash-tool.ts";
|
|
8
8
|
import {
|
|
@@ -13,7 +13,18 @@ import {
|
|
|
13
13
|
import { renderBackgroundShellNotificationBox } from "./shell/shell-notification-box.ts";
|
|
14
14
|
|
|
15
15
|
export default function (pi: ExtensionAPI): void {
|
|
16
|
-
|
|
16
|
+
installShellInspector(pi);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Register the extension on `pi` and return the shell manager of this load.
|
|
21
|
+
*
|
|
22
|
+
* The manager belongs to the load, not to the module: Pi reuses a loaded module for the sessions it
|
|
23
|
+
* starts in the same working directory, subagent runs included, and each of them owns its jobs.
|
|
24
|
+
*/
|
|
25
|
+
export function installShellInspector(pi: ExtensionAPI): ShellManager {
|
|
26
|
+
const shellManager = new ShellManager();
|
|
27
|
+
const dock = new ShellDockContribution(shellManager);
|
|
17
28
|
|
|
18
29
|
// Registered once per load: the transcript looks the renderer up by custom type when it draws
|
|
19
30
|
// the message, so a session-scoped registration would only re-register the same function.
|
|
@@ -22,40 +33,35 @@ export default function (pi: ExtensionAPI): void {
|
|
|
22
33
|
renderBackgroundShellNotificationBox,
|
|
23
34
|
);
|
|
24
35
|
|
|
25
|
-
let unsubscribeShellManager:
|
|
26
|
-
| (() => void)
|
|
27
|
-
| undefined;
|
|
36
|
+
let unsubscribeShellManager: (() => void) | undefined;
|
|
28
37
|
|
|
29
|
-
let unsubscribeBackgroundShellNotifications:
|
|
30
|
-
| (() => void)
|
|
31
|
-
| undefined;
|
|
38
|
+
let unsubscribeBackgroundShellNotifications: (() => void) | undefined;
|
|
32
39
|
|
|
33
40
|
pi.on("session_start", (_event, ctx) => {
|
|
34
41
|
// Release the old context before manager resets can notify its subscribers.
|
|
35
42
|
unsubscribeShellManager?.();
|
|
36
43
|
unsubscribeShellManager = undefined;
|
|
37
44
|
dock.detach({ retired: true });
|
|
38
|
-
// Module state may survive extension reloads, so a new session starts
|
|
39
|
-
// with an explicitly empty shell view.
|
|
40
|
-
shellManager.clearAllJobs();
|
|
41
45
|
// Restore the shell manager state from the session context.
|
|
42
46
|
shellManager.restoreShellManager(ctx);
|
|
43
47
|
|
|
44
48
|
dock.attach(ctx);
|
|
45
49
|
|
|
46
|
-
unsubscribeShellManager =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
+
unsubscribeShellManager = shellManager.subscribe((event) => {
|
|
51
|
+
dock.onManagerEvent(event);
|
|
52
|
+
});
|
|
50
53
|
|
|
51
54
|
unsubscribeBackgroundShellNotifications?.();
|
|
52
55
|
|
|
53
56
|
// Register background shell notifications
|
|
54
|
-
unsubscribeBackgroundShellNotifications = registerBackgroundShellNotifications(
|
|
55
|
-
|
|
57
|
+
unsubscribeBackgroundShellNotifications = registerBackgroundShellNotifications(
|
|
58
|
+
pi,
|
|
59
|
+
shellManager,
|
|
60
|
+
ctx,
|
|
61
|
+
);
|
|
56
62
|
});
|
|
57
63
|
|
|
58
|
-
pi.on("session_shutdown", (
|
|
64
|
+
pi.on("session_shutdown", () => {
|
|
59
65
|
// Unsubscribe before clearing: clearAllJobs() emits, and a live
|
|
60
66
|
// listener would re-render the dock after it was removed.
|
|
61
67
|
unsubscribeShellManager?.();
|
|
@@ -72,9 +78,12 @@ export default function (pi: ExtensionAPI): void {
|
|
|
72
78
|
try {
|
|
73
79
|
shellManager.clearAllJobs(pi);
|
|
74
80
|
} finally {
|
|
75
|
-
unsubscribeBackgroundShellNotifications = registerBackgroundShellNotifications(
|
|
81
|
+
unsubscribeBackgroundShellNotifications = registerBackgroundShellNotifications(
|
|
82
|
+
pi,
|
|
83
|
+
shellManager,
|
|
84
|
+
ctx,
|
|
85
|
+
);
|
|
76
86
|
}
|
|
77
|
-
|
|
78
87
|
});
|
|
79
88
|
|
|
80
89
|
pi.on("session_tree", (_event, ctx) => {
|
|
@@ -84,11 +93,11 @@ export default function (pi: ExtensionAPI): void {
|
|
|
84
93
|
});
|
|
85
94
|
|
|
86
95
|
// Register tools
|
|
87
|
-
// The background tools only read the
|
|
88
|
-
// starts
|
|
89
|
-
pi.registerTool(BashTool());
|
|
90
|
-
pi.registerTool(BackgroundShellTool());
|
|
91
|
-
pi.registerTool(KillBackgroundShellTool());
|
|
96
|
+
// The background tools only read the jobs of this load's shell manager, so they ship with the
|
|
97
|
+
// wrapper that starts them; a separate extension could not see them.
|
|
98
|
+
pi.registerTool(BashTool(shellManager));
|
|
99
|
+
pi.registerTool(BackgroundShellTool(shellManager));
|
|
100
|
+
pi.registerTool(KillBackgroundShellTool(shellManager));
|
|
92
101
|
|
|
93
102
|
// Register commands
|
|
94
103
|
pi.registerCommand("shell", {
|
|
@@ -100,4 +109,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
100
109
|
await dock.open(ctx);
|
|
101
110
|
},
|
|
102
111
|
});
|
|
112
|
+
|
|
113
|
+
return shellManager;
|
|
103
114
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** How long a failure keeps a Dock item's error marker when nobody opens the item's panel. */
|
|
2
|
+
export const ALERT_DURATION_MS = 10_000;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The lifetime of a Dock item's error marker. A failure shows from the time it happened until
|
|
6
|
+
* `ALERT_DURATION_MS` later, or until the user sees it in the item's panel. A check that finds a
|
|
7
|
+
* failure still showing also schedules the redraw that ends it, so a quiet screen does not keep
|
|
8
|
+
* the marker.
|
|
9
|
+
*/
|
|
10
|
+
export class DockAlerts {
|
|
11
|
+
private readonly seen = new Set<string>();
|
|
12
|
+
/** A failure without a known time starts its window when it is first checked. */
|
|
13
|
+
private readonly firstChecked = new Map<string, number>();
|
|
14
|
+
private timer: ReturnType<typeof setTimeout> | undefined;
|
|
15
|
+
private dueAt = Infinity;
|
|
16
|
+
private readonly redraw: () => void;
|
|
17
|
+
|
|
18
|
+
constructor(redraw: () => void) {
|
|
19
|
+
this.redraw = redraw;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Whether the failure `key`, which happened at `at`, still shows the marker. */
|
|
23
|
+
shows(key: string, at: number | undefined): boolean {
|
|
24
|
+
if (this.seen.has(key)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
const since = at ?? this.firstChecked.get(key) ?? now;
|
|
30
|
+
|
|
31
|
+
if (at === undefined) {
|
|
32
|
+
this.firstChecked.set(key, since);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const endsAt = since + ALERT_DURATION_MS;
|
|
36
|
+
|
|
37
|
+
if (endsAt <= now) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (endsAt < this.dueAt) {
|
|
42
|
+
clearTimeout(this.timer);
|
|
43
|
+
this.dueAt = endsAt;
|
|
44
|
+
this.timer = setTimeout(() => {
|
|
45
|
+
this.timer = undefined;
|
|
46
|
+
this.dueAt = Infinity;
|
|
47
|
+
this.redraw();
|
|
48
|
+
}, endsAt - now);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The user saw the failure in the item's panel. False when it was seen before. */
|
|
55
|
+
acknowledge(key: string): boolean {
|
|
56
|
+
if (this.seen.has(key)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.seen.add(key);
|
|
61
|
+
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
forget(key: string): void {
|
|
66
|
+
this.seen.delete(key);
|
|
67
|
+
this.firstChecked.delete(key);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Forgets every failure and stops the pending redraw, so a detached item draws nothing late. */
|
|
71
|
+
clear(): void {
|
|
72
|
+
clearTimeout(this.timer);
|
|
73
|
+
this.timer = undefined;
|
|
74
|
+
this.dueAt = Infinity;
|
|
75
|
+
this.seen.clear();
|
|
76
|
+
this.firstChecked.clear();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
/** A part of a one-line summary; parts with a lower rank give way first when the line is too long. */
|
|
4
|
+
export interface RankedPart {
|
|
5
|
+
text: string;
|
|
6
|
+
rank: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The richest line that fits in `width`. `compose` gets the kept parts in their original order;
|
|
11
|
+
* the lowest-ranked part, the last one among equals, is left out until the line fits. So a narrow
|
|
12
|
+
* row shows fewer complete parts instead of a cut one. Undefined when not even `compose([])` fits.
|
|
13
|
+
*/
|
|
14
|
+
export function fitRanked(
|
|
15
|
+
parts: readonly RankedPart[],
|
|
16
|
+
width: number,
|
|
17
|
+
compose: (texts: readonly string[]) => string,
|
|
18
|
+
): string | undefined {
|
|
19
|
+
const kept = [...parts];
|
|
20
|
+
|
|
21
|
+
for (;;) {
|
|
22
|
+
const line = compose(kept.map((part) => part.text));
|
|
23
|
+
|
|
24
|
+
if (visibleWidth(line) <= width) {
|
|
25
|
+
return line;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (kept.length === 0) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let lowest = 0;
|
|
33
|
+
|
|
34
|
+
for (let index = 1; index < kept.length; index++) {
|
|
35
|
+
if (kept[index]!.rank <= kept[lowest]!.rank) {
|
|
36
|
+
lowest = index;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
kept.splice(lowest, 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -8,8 +8,7 @@ import type { Notice } from "./footer-notice.ts";
|
|
|
8
8
|
const BACK_TO_BOTTOM_LABEL = "[ ↓ Back to bottom · End ]";
|
|
9
9
|
const BACK_TO_BOTTOM_LABEL_WIDTH = visibleWidth(BACK_TO_BOTTOM_LABEL);
|
|
10
10
|
|
|
11
|
-
const KEY_HINTS =
|
|
12
|
-
"↑↓/jk shell · ⇧↑↓/jk scroll · Home/End · x to kill · c to clear · Esc to close";
|
|
11
|
+
const KEY_HINTS = "↑↓/jk shell · ⇧↑↓/jk scroll · Home/End · x to kill · c to clear · Esc to close";
|
|
13
12
|
|
|
14
13
|
function border(theme: Theme, text: string): string {
|
|
15
14
|
return theme.fg("border", text);
|
|
@@ -42,10 +41,7 @@ export function renderHeader(
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
export function renderFooter(theme: Theme, width: number, notice: Notice | undefined): string {
|
|
45
|
-
return cell(
|
|
46
|
-
notice ? theme.fg(notice.color, notice.text) : theme.fg("dim", KEY_HINTS),
|
|
47
|
-
width,
|
|
48
|
-
);
|
|
44
|
+
return cell(notice ? theme.fg(notice.color, notice.text) : theme.fg("dim", KEY_HINTS), width);
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
export interface BottomSeparator {
|
|
@@ -111,7 +107,11 @@ export function assembleFrame(theme: Theme, geometry: PaneGeometry, parts: Frame
|
|
|
111
107
|
);
|
|
112
108
|
}
|
|
113
109
|
|
|
114
|
-
lines.push(
|
|
110
|
+
lines.push(
|
|
111
|
+
parts.separator,
|
|
112
|
+
edge + parts.footer + edge,
|
|
113
|
+
border(theme, `└${"─".repeat(innerWidth)}┘`),
|
|
114
|
+
);
|
|
115
115
|
|
|
116
116
|
return lines;
|
|
117
117
|
}
|
|
@@ -27,10 +27,7 @@ export interface PaneGeometry {
|
|
|
27
27
|
export function paneGeometry(width: number, terminalRows: number): PaneGeometry {
|
|
28
28
|
const bodyHeight = Math.min(
|
|
29
29
|
BODY_MAX_HEIGHT,
|
|
30
|
-
Math.max(
|
|
31
|
-
BODY_MIN_HEIGHT,
|
|
32
|
-
Math.floor(terminalRows * OVERLAY_HEIGHT_RATIO) - FRAME_HEIGHT,
|
|
33
|
-
),
|
|
30
|
+
Math.max(BODY_MIN_HEIGHT, Math.floor(terminalRows * OVERLAY_HEIGHT_RATIO) - FRAME_HEIGHT),
|
|
34
31
|
);
|
|
35
32
|
|
|
36
33
|
const innerWidth = Math.max(
|
|
@@ -14,7 +14,10 @@ const MAX_CACHED_COMMANDS = 64;
|
|
|
14
14
|
* kilobytes; the same few commands are previewed again on every frame, so they are done once.
|
|
15
15
|
*/
|
|
16
16
|
export class CommandPreviews {
|
|
17
|
-
private readonly byCommand = new Map<
|
|
17
|
+
private readonly byCommand = new Map<
|
|
18
|
+
string,
|
|
19
|
+
{ collapsed: string; fitted: Map<number, string> }
|
|
20
|
+
>();
|
|
18
21
|
|
|
19
22
|
fit(command: string, maxWidth: number): string {
|
|
20
23
|
let entry = this.byCommand.get(command);
|
|
@@ -123,7 +123,9 @@ export class WrappedOutput {
|
|
|
123
123
|
*/
|
|
124
124
|
export class OutputRowsCache {
|
|
125
125
|
private readonly wraps = new LineWrapCache();
|
|
126
|
-
private entry:
|
|
126
|
+
private entry:
|
|
127
|
+
| { jobId: string; revision: number; width: number; output: WrappedOutput }
|
|
128
|
+
| undefined;
|
|
127
129
|
|
|
128
130
|
get(source: ScreenSource, jobId: string, width: number): WrappedOutput {
|
|
129
131
|
const revision = source.getScreenRevision(jobId);
|
|
@@ -113,7 +113,10 @@ export function renderDetails(
|
|
|
113
113
|
|
|
114
114
|
if (output.lineCount === 0) {
|
|
115
115
|
rows.push(
|
|
116
|
-
cell(
|
|
116
|
+
cell(
|
|
117
|
+
theme.fg("muted", job.status === "running" ? "no output yet" : "no output"),
|
|
118
|
+
width,
|
|
119
|
+
),
|
|
117
120
|
);
|
|
118
121
|
} else {
|
|
119
122
|
rows.push(
|