@xzzpig/pi-subagents 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/tui/fleet.ts +22 -3
- package/src/tui/mouse-events.ts +42 -0
package/package.json
CHANGED
package/src/tui/fleet.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { DIRS, type AsyncJobState, type Details, type FleetKeybindingAction, typ
|
|
|
10
10
|
import { decodeUtf8Tail } from "../shared/utf8.ts";
|
|
11
11
|
import { readStatus } from "../shared/utils.ts";
|
|
12
12
|
import { formatAsyncRunTranscript } from "../runs/background/fleet-view.ts";
|
|
13
|
+
import { parseMouseWheelEvent } from "./mouse-events.ts";
|
|
13
14
|
import { listAsyncRuns, type AsyncRunSummary } from "../runs/background/async-status.ts";
|
|
14
15
|
import { steerAsyncRun } from "../runs/foreground/async-steering-action.ts";
|
|
15
16
|
import type { SteerDeliveryMode } from "../runs/background/control-channel.ts";
|
|
@@ -22,6 +23,7 @@ import { getLivePromptAudit, type LivePromptAudit, type PromptAuditView } from "
|
|
|
22
23
|
|
|
23
24
|
const REFRESH_MS = 750;
|
|
24
25
|
const MIN_REFRESH_MS = 250;
|
|
26
|
+
const WHEEL_SCROLL_LINES = 3;
|
|
25
27
|
const MAX_RECENT_ASYNC_RUNS = 20;
|
|
26
28
|
const MAX_FLEET_HISTORY_CANDIDATES = 100;
|
|
27
29
|
const TRANSCRIPT_LINES = 200;
|
|
@@ -700,6 +702,7 @@ export class SubagentFleetComponent implements Component {
|
|
|
700
702
|
private detailLineCount = 0;
|
|
701
703
|
private detailViewportHeight = 8;
|
|
702
704
|
private bodyHeight = 8;
|
|
705
|
+
private lastRosterWidth: number | undefined;
|
|
703
706
|
private expandedTools = false;
|
|
704
707
|
private promptAuditOpen = false;
|
|
705
708
|
private promptAuditView: PromptAuditView = "authored";
|
|
@@ -904,6 +907,21 @@ export class SubagentFleetComponent implements Component {
|
|
|
904
907
|
}
|
|
905
908
|
|
|
906
909
|
handleInput(data: string): void {
|
|
910
|
+
const wheel = parseMouseWheelEvent(data);
|
|
911
|
+
if (wheel) {
|
|
912
|
+
// While editing draft text, ignore the wheel to avoid surprising scroll jumps.
|
|
913
|
+
if (this.steerDraft !== undefined || this.redoGuidanceDraft !== undefined) return;
|
|
914
|
+
const overRoster = this.lastRosterWidth !== undefined && wheel.x <= this.lastRosterWidth;
|
|
915
|
+
if (this.promptAuditOpen) {
|
|
916
|
+
if (overRoster) this.movePromptSelection(wheel.direction);
|
|
917
|
+
else this.scrollDetail(wheel.direction * WHEEL_SCROLL_LINES);
|
|
918
|
+
} else if (overRoster) {
|
|
919
|
+
this.moveSelection(wheel.direction);
|
|
920
|
+
} else {
|
|
921
|
+
this.scrollDetail(wheel.direction * WHEEL_SCROLL_LINES);
|
|
922
|
+
}
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
907
925
|
if (this.promptAuditOpen && this.redoGuidanceDraft !== undefined) {
|
|
908
926
|
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
909
927
|
this.resetActionInput();
|
|
@@ -1209,6 +1227,7 @@ export class SubagentFleetComponent implements Component {
|
|
|
1209
1227
|
const rows = this.tui.terminal?.rows ?? 32;
|
|
1210
1228
|
this.bodyHeight = Math.max(2, Math.floor(rows * 0.85) - 6);
|
|
1211
1229
|
const rosterWidth = Math.max(22, Math.min(46, Math.floor((innerWidth - 1) * 0.38)));
|
|
1230
|
+
this.lastRosterWidth = rosterWidth;
|
|
1212
1231
|
const detailWidth = Math.max(1, innerWidth - rosterWidth - 1);
|
|
1213
1232
|
const roster = this.rosterLines(rosterWidth);
|
|
1214
1233
|
const detail = this.wrappedDetail(detailWidth);
|
|
@@ -1244,10 +1263,10 @@ export class SubagentFleetComponent implements Component {
|
|
|
1244
1263
|
lines.push(this.theme.fg("border", `├${"─".repeat(rosterWidth)}┴${"─".repeat(detailWidth)}┤`));
|
|
1245
1264
|
const position = this.snapshot.items.length ? `${this.selected + 1}/${this.snapshot.items.length}` : "0/0";
|
|
1246
1265
|
const footer = this.promptAuditOpen
|
|
1247
|
-
? ` j/k child · 1/2/3 view · g redo with guidance · c copy · Esc close Prompt Audit · ${position}`
|
|
1266
|
+
? ` j/k child · 1/2/3 view · g redo with guidance · c copy · wheel ↑↓ · Esc close Prompt Audit · ${position}`
|
|
1248
1267
|
: selected?.kind === "external"
|
|
1249
|
-
? ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} job · display-only · ${bindingLabel(this.keybindings, "refresh")} refresh · ${bindingLabel(this.keybindings, "close")} close · ${position}`
|
|
1250
|
-
: ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} agent · p Prompt Audit · ${bindingLabel(this.keybindings, "inspect")} Herdr · ${bindingLabel(this.keybindings, "steer")} steer · ${bindingLabel(this.keybindings, "stop")} stop · ${bindingLabel(this.keybindings, "toggleTools")} tools · ${bindingLabel(this.keybindings, "refresh")} refresh · ${bindingLabel(this.keybindings, "close")} close · ${position}`;
|
|
1268
|
+
? ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} job · display-only · ${bindingLabel(this.keybindings, "refresh")} refresh · wheel ↑↓ · ${bindingLabel(this.keybindings, "close")} close · ${position}`
|
|
1269
|
+
: ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} agent · p Prompt Audit · ${bindingLabel(this.keybindings, "inspect")} Herdr · ${bindingLabel(this.keybindings, "steer")} steer · ${bindingLabel(this.keybindings, "stop")} stop · ${bindingLabel(this.keybindings, "toggleTools")} tools · ${bindingLabel(this.keybindings, "refresh")} refresh · wheel ↑↓ · ${bindingLabel(this.keybindings, "close")} close · ${position}`;
|
|
1251
1270
|
lines.push(this.theme.fg("border", "│") + fit(this.theme.fg("dim", footer), innerWidth) + this.theme.fg("border", "│"));
|
|
1252
1271
|
lines.push(this.theme.fg("border", `╰${"─".repeat(innerWidth)}╯`));
|
|
1253
1272
|
return lines.map((line) => truncateToWidth(line, width));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SGR/X10 mouse parsing for the fleet inspector.
|
|
3
|
+
*
|
|
4
|
+
* In fullscreen mode pi-tui owns terminal mouse modes (?1000h ?1002h ?1003h
|
|
5
|
+
* ?1006h) itself and forwards raw wheel events to a focused overlay's
|
|
6
|
+
* `handleInput` (the same mechanism pi-btw relies on). We therefore never
|
|
7
|
+
* write mouse enable/disable sequences here — we only parse the forwarded
|
|
8
|
+
* data. SGR encoding reports `ESC[<b;c;rM` (press) / `m` (release); X10
|
|
9
|
+
* reports `ESC[M` followed by three bytes (button, column + 32, row + 32).
|
|
10
|
+
* Wheel buttons carry the 64 bit; the low bits select the direction
|
|
11
|
+
* (0 = up, 1 = down). The 32 bit marks a button release (SGR wheel releases
|
|
12
|
+
* are 96/97), which we ignore so a motion-tracking terminal cannot
|
|
13
|
+
* double-scroll per notch.
|
|
14
|
+
*/
|
|
15
|
+
export interface MouseWheelEvent {
|
|
16
|
+
/** -1 for wheel up, 1 for wheel down. */
|
|
17
|
+
direction: -1 | 1;
|
|
18
|
+
/** Zero-based terminal column where the wheel event occurred. */
|
|
19
|
+
x: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function parseMouseWheelEvent(data: string): MouseWheelEvent | undefined {
|
|
23
|
+
const sgr = /^\x1b\[<(\d+);(\d+);(\d+)[Mm]$/.exec(data);
|
|
24
|
+
if (sgr) {
|
|
25
|
+
const buttonText = sgr[1];
|
|
26
|
+
const xText = sgr[2];
|
|
27
|
+
if (buttonText === undefined || xText === undefined) return undefined;
|
|
28
|
+
const button = Number.parseInt(buttonText, 10);
|
|
29
|
+
if ((button & 64) === 0 || (button & 32) === 32) return undefined;
|
|
30
|
+
const direction = button & 3;
|
|
31
|
+
if (direction !== 0 && direction !== 1) return undefined;
|
|
32
|
+
return { direction: direction === 0 ? -1 : 1, x: Number.parseInt(xText, 10) - 1 };
|
|
33
|
+
}
|
|
34
|
+
if (data.length === 6 && data.startsWith("\x1b[M")) {
|
|
35
|
+
const button = data.charCodeAt(3) - 32;
|
|
36
|
+
if ((button & 64) === 0 || (button & 32) === 32) return undefined;
|
|
37
|
+
const direction = button & 3;
|
|
38
|
+
if (direction !== 0 && direction !== 1) return undefined;
|
|
39
|
+
return { direction: direction === 0 ? -1 : 1, x: data.charCodeAt(4) - 33 };
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|