@oisin-ee/oisinpi 0.5.0 → 0.6.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 +20 -0
- package/README.md +4 -2
- package/node_modules/@oisin-ee/pi-guardrails/package.json +1 -1
- package/node_modules/@oisin-ee/pi-prewalk/package.json +1 -1
- package/node_modules/@oisin-ee/pi-todo/README.md +57 -15
- package/node_modules/@oisin-ee/pi-todo/package.json +1 -1
- package/node_modules/@oisin-ee/pi-todo/src/display.ts +62 -0
- package/node_modules/@oisin-ee/pi-todo/src/embedded.ts +105 -0
- package/node_modules/@oisin-ee/pi-todo/src/generated/todo_core.d.ts +26 -11
- package/node_modules/@oisin-ee/pi-todo/src/generated/todo_core_bg.wasm +0 -0
- package/node_modules/@oisin-ee/pi-todo/src/guidance.ts +8 -0
- package/node_modules/@oisin-ee/pi-todo/src/index.ts +23 -6
- package/node_modules/@oisin-ee/pi-todo/src/plannotator.ts +4 -2
- package/node_modules/@oisin-ee/pi-todo/src/tool.ts +13 -9
- package/node_modules/@oisin-ee/pi-todo/src/wasm.ts +1 -0
- package/node_modules/@oisin-ee/pi-todo/src/widget.ts +23 -3
- package/node_modules/@oisin-ee/pi-todo/src/work.ts +13 -6
- package/node_modules/@oisin-ee/pi-wrangle/README.md +2 -2
- package/node_modules/@oisin-ee/pi-wrangle/package.json +1 -1
- package/node_modules/@oisin-ee/pi-wrangle/pi/board.ts +63 -28
- package/node_modules/@oisin-ee/pi-wrangle/pi/index.ts +107 -43
- package/node_modules/@oisin-ee/pi-wrangle/pi/work-panel.ts +121 -55
- package/node_modules/@oisin-ee/pi-wrangle/pi/work-todo.ts +117 -31
- package/node_modules/@oisin-ee/pi-wrangle/pi/work.ts +27 -26
- package/node_modules/@oisin-ee/pi-wrangle/plugins/wrangle/skills/wrangle/SKILL.md +1 -1
- package/package.json +5 -5
|
@@ -3,6 +3,7 @@ import { ownsTodo, show } from "./lifecycle.ts";
|
|
|
3
3
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { TODO_SHORTCUT } from "./widget.ts";
|
|
5
5
|
import type { TodoPresentation } from "./presentation.ts";
|
|
6
|
+
import { display } from "./display.ts";
|
|
6
7
|
import { latestSnapshot } from "./state.ts";
|
|
7
8
|
import { parse } from "./wasm.ts";
|
|
8
9
|
|
|
@@ -11,7 +12,7 @@ interface WorkHost extends TodoHost {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
type WorkCommands = Readonly<Pick<ExtensionAPI, "registerCommand" | "registerShortcut">>;
|
|
14
|
-
const protocolVersion =
|
|
15
|
+
const protocolVersion = 2,
|
|
15
16
|
initialRevision = 0;
|
|
16
17
|
|
|
17
18
|
interface WorkContext extends TodoContext {
|
|
@@ -129,7 +130,10 @@ class TodoWork {
|
|
|
129
130
|
}
|
|
130
131
|
}),
|
|
131
132
|
];
|
|
132
|
-
this.#host.events.emit("oisin.todo.ready", {
|
|
133
|
+
this.#host.events.emit("oisin.todo.ready", {
|
|
134
|
+
publisher: this.#publisher,
|
|
135
|
+
version: protocolVersion,
|
|
136
|
+
});
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
/**
|
|
@@ -145,13 +149,13 @@ class TodoWork {
|
|
|
145
149
|
const list = parse(latestSnapshot(ctx.sessionManager.getBranch()));
|
|
146
150
|
this.#host.events.emit("oisin.todo.snapshot", {
|
|
147
151
|
branch: ctx.sessionManager.getLeafId(),
|
|
152
|
+
display: display(list),
|
|
148
153
|
presenter: this.#presenter.presenter,
|
|
149
154
|
publisher: this.#publisher,
|
|
150
155
|
request: this.#presenter.request,
|
|
151
156
|
revision: this.#revision,
|
|
152
157
|
session: ctx.sessionManager.getSessionId(),
|
|
153
|
-
|
|
154
|
-
version: 1,
|
|
158
|
+
version: protocolVersion,
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -166,7 +170,7 @@ class TodoWork {
|
|
|
166
170
|
this.#host.events.emit("oisin.work.open", {
|
|
167
171
|
presenter: this.#presenter.presenter,
|
|
168
172
|
request: this.#presenter.request,
|
|
169
|
-
version:
|
|
173
|
+
version: protocolVersion,
|
|
170
174
|
view: "todos",
|
|
171
175
|
});
|
|
172
176
|
return true;
|
|
@@ -179,7 +183,10 @@ class TodoWork {
|
|
|
179
183
|
}
|
|
180
184
|
this.#subscriptions = [];
|
|
181
185
|
if (this.#context !== undefined) {
|
|
182
|
-
this.#host.events.emit("oisin.todo.stop", {
|
|
186
|
+
this.#host.events.emit("oisin.todo.stop", {
|
|
187
|
+
publisher: this.#publisher,
|
|
188
|
+
version: protocolVersion,
|
|
189
|
+
});
|
|
183
190
|
}
|
|
184
191
|
this.#release();
|
|
185
192
|
this.#context = undefined;
|
|
@@ -466,8 +466,8 @@ The caller is the harness's `HERDR_PANE_ID`. Pi registers the server from its ex
|
|
|
466
466
|
|
|
467
467
|
The extension adds host status before each prompt, registers the tools, and draws:
|
|
468
468
|
|
|
469
|
-
- **The
|
|
470
|
-
-
|
|
469
|
+
- **The board widget** above the editor shows host meters, the current task, and agents and jobs grouped TO LAND, ATTENTION, RUNNING, and WAITING. Agent/job data refreshes every ten seconds. Compatible pi-todo snapshots update immediately. Empty providers hide the widget. Unavailable providers show an error.
|
|
470
|
+
- **Alt+W or `/work`** expands or collapses that widget in place, without a popup or editor replacement. Alt+J/K moves selection, Alt+] changes views, and Alt+I shows inline details. Typing stays in the editor. Alt+S stops jobs, Alt+C cancels queued work, and Alt+M sends agent messages. Stop and cancel require confirmation. Completed job history starts collapsed.
|
|
471
471
|
- **`/wrangle`**, the control panel, with four tabs: Status (hosts with their retry state, then your rows; Enter on a host reads it again now), Hosts (reconnect, rename, enable, disable, add), Profiles (Enter edits `prompt.md`), and Inbox. The widget steps aside while the panel is open.
|
|
472
472
|
- **The inbox reader** and a renderer that shows each record's kind, sender, and text, folded past twelve lines.
|
|
473
473
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oisin-ee/pi-wrangle",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "Pi extension for wrangle: the board, the /wrangle panel, the inbox reader, and the wrangle tools. Needs the wrangle binary of the same version.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,9 @@ export interface Paint {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const TITLES: Record<Group, string> = { to_land: "TO LAND", attention: "ATTENTION", running: "RUNNING", waiting: "WAITING" };
|
|
47
|
-
|
|
47
|
+
/** Groups in action order: what the owner must do first comes first. */
|
|
48
|
+
export const GROUPS: readonly Group[] = ["to_land", "attention", "running", "waiting"];
|
|
49
|
+
const ORDER = GROUPS;
|
|
48
50
|
const COUNTS: Record<Group, string> = { to_land: "to land", attention: "need attention", running: "running", waiting: "waiting" };
|
|
49
51
|
|
|
50
52
|
export function parseBoard(value: unknown): Board {
|
|
@@ -90,44 +92,77 @@ function pad(text: string, width: number): string {
|
|
|
90
92
|
return truncateToWidth(text, width, "…", true);
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
/** A row whose transcript text is safe to draw. */
|
|
96
|
+
export function cleanRow(row: Row): Row {
|
|
97
|
+
return { ...row, name: clean(row.name), what: clean(row.what), host: clean(row.host), state: clean(row.state), activity: clean(row.activity || row.state) };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Column widths shared by every row drawn together, so the columns line up. */
|
|
101
|
+
export interface Columns {
|
|
102
|
+
name: number;
|
|
103
|
+
what: number;
|
|
104
|
+
host: number;
|
|
105
|
+
activity: number;
|
|
106
|
+
showHost: boolean;
|
|
107
|
+
showActivity: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function right(row: Row): string {
|
|
111
|
+
return row.group === "to_land" ? `${row.state} ${age(row.age_ms)}` : age(row.age_ms);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Activity goes first on a narrow terminal, then the host column, so the name and the
|
|
115
|
+
* harness stay readable. */
|
|
116
|
+
export function boardColumns(rows: Row[], width: number): Columns {
|
|
117
|
+
if (rows.length === 0) return { name: 0, what: 0, host: 0, activity: 0, showHost: false, showActivity: false };
|
|
118
|
+
const name = Math.min(24, Math.max(...rows.map(r => visibleWidth(r.name))));
|
|
119
|
+
const what = Math.min(22, Math.max(...rows.map(r => visibleWidth(r.what))));
|
|
120
|
+
const host = Math.min(14, Math.max(...rows.map(r => visibleWidth(r.host))));
|
|
121
|
+
const rightW = Math.max(...rows.map(r => visibleWidth(right(r))));
|
|
122
|
+
const fixed = 4 + name + 2 + what + 2 + rightW;
|
|
123
|
+
const showHost = fixed + host + 2 <= width;
|
|
124
|
+
const activity = width - fixed - (showHost ? host + 2 : 0) - 2;
|
|
125
|
+
return { name, what, host, activity, showHost, showActivity: activity >= 16 };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** `wrangle <counts>` on the left and one load meter per host on the right. */
|
|
129
|
+
export function boardHeader(board: Board, width: number, paint: Paint): string {
|
|
97
130
|
const counts = ORDER.map(g => [g, board.rows.filter(r => r.group === g).length] as const)
|
|
98
131
|
.filter(([, n]) => n > 0)
|
|
99
132
|
.map(([g, n]) => `${n} ${COUNTS[g]}`)
|
|
100
133
|
.join(" · ");
|
|
101
|
-
const left = ` ${paint.bold(paint.fg("accent", "wrangle"))} ${counts}`;
|
|
134
|
+
const left = ` ${paint.bold(paint.fg("accent", "wrangle"))}${counts ? ` ${counts}` : ""}`;
|
|
102
135
|
const meters = board.hosts.map(h => meter(h, paint)).join(" ");
|
|
103
136
|
const gap = width - visibleWidth(left) - visibleWidth(meters) - 1;
|
|
104
|
-
|
|
137
|
+
return truncateToWidth(gap >= 2 ? `${left}${" ".repeat(gap)}${meters}` : left, width);
|
|
138
|
+
}
|
|
105
139
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const hostW = Math.min(14, Math.max(...rows.map(r => visibleWidth(r.host))));
|
|
110
|
-
const right = (r: Row) => r.group === "to_land" ? `${r.state} ${age(r.age_ms)}` : age(r.age_ms);
|
|
111
|
-
const rightW = Math.max(...rows.map(r => visibleWidth(right(r))));
|
|
112
|
-
const fixed = 4 + nameW + 2 + whatW + 2 + rightW;
|
|
113
|
-
const showHost = fixed + hostW + 2 <= width;
|
|
114
|
-
const activityW = width - fixed - (showHost ? hostW + 2 : 0) - 2;
|
|
115
|
-
const showActivity = activityW >= 16;
|
|
140
|
+
export function groupTitle(group: Group, paint: Paint): string {
|
|
141
|
+
return ` ${paint.fg(group === "attention" ? "warning" : "muted", TITLES[group])}`;
|
|
142
|
+
}
|
|
116
143
|
|
|
144
|
+
/** One cleaned row. `prefix` is two columns wide: blank, or a selection marker. */
|
|
145
|
+
export function boardRow(row: Row, columns: Columns, width: number, paint: Paint, prefix = " "): string {
|
|
146
|
+
const [glyph, color] = icon(row);
|
|
147
|
+
let line = `${prefix}${paint.fg(color, glyph)} ${pad(row.name, columns.name)} ${paint.fg("muted", pad(row.what, columns.what))}`;
|
|
148
|
+
if (columns.showHost) line += ` ${pad(row.host, columns.host)}`;
|
|
149
|
+
if (columns.showActivity) line += ` ${paint.fg("dim", pad(row.activity, columns.activity))}`;
|
|
150
|
+
const tail = right(row);
|
|
151
|
+
line += " ".repeat(Math.max(2, width - visibleWidth(line) - visibleWidth(tail))) + paint.fg("dim", tail);
|
|
152
|
+
return truncateToWidth(line, width);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The board as lines no wider than `width`. */
|
|
156
|
+
export function renderBoard(board: Board, width: number, paint: Paint): string[] {
|
|
157
|
+
if (board.rows.length === 0) return [];
|
|
158
|
+
const rows = board.rows.map(cleanRow);
|
|
159
|
+
const columns = boardColumns(rows, width);
|
|
160
|
+
const lines = [boardHeader(board, width, paint)];
|
|
117
161
|
for (const group of ORDER) {
|
|
118
162
|
const members = rows.filter(r => r.group === group);
|
|
119
163
|
if (members.length === 0) continue;
|
|
120
|
-
lines.push(
|
|
121
|
-
for (const row of members)
|
|
122
|
-
const [glyph, color] = icon(row);
|
|
123
|
-
let line = ` ${paint.fg(color, glyph)} ${pad(row.name, nameW)} ${paint.fg("muted", pad(row.what, whatW))}`;
|
|
124
|
-
if (showHost) line += ` ${pad(row.host, hostW)}`;
|
|
125
|
-
if (showActivity) line += ` ${paint.fg("dim", pad(row.activity, activityW))}`;
|
|
126
|
-
const used = visibleWidth(line);
|
|
127
|
-
const tail = right(row);
|
|
128
|
-
line += " ".repeat(Math.max(2, width - used - visibleWidth(tail))) + paint.fg("dim", tail);
|
|
129
|
-
lines.push(line);
|
|
130
|
-
}
|
|
164
|
+
lines.push(groupTitle(group, paint));
|
|
165
|
+
for (const row of members) lines.push(boardRow(row, columns, width, paint));
|
|
131
166
|
}
|
|
132
167
|
return lines.map(line => truncateToWidth(line, width));
|
|
133
168
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { Box, Text } from "@earendil-works/pi-tui";
|
|
3
|
+
import { Box, Text, Key } from "@earendil-works/pi-tui";
|
|
4
4
|
import { type Board, clean, parseBoard } from "./board.ts";
|
|
5
5
|
import { WorkTodo } from "./work-todo.ts";
|
|
6
|
-
import {
|
|
6
|
+
import { workBoard, workText, type WorkState } from "./work.ts";
|
|
7
7
|
import { type Details, InboxReader, MESSAGE_TYPE } from "./inbox.ts";
|
|
8
8
|
import { openPanel } from "./panel.ts";
|
|
9
9
|
import { loadJobHistory, type JobHistory } from "./work-history.ts";
|
|
10
|
-
import { WorkPanel,
|
|
10
|
+
import { WorkPanel, WorkDetail, runWorkAction, type WorkAction, type WorkCursor, type WorkData, type WorkTab } from "./work-panel.ts";
|
|
11
11
|
|
|
12
12
|
const REFRESH_MS = 10_000;
|
|
13
13
|
|
|
@@ -64,9 +64,12 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
64
64
|
let workOpen = false;
|
|
65
65
|
let history: JobHistory = { jobs: [] };
|
|
66
66
|
let workPanel: WorkPanel | undefined;
|
|
67
|
-
let
|
|
67
|
+
let workDetail: WorkDetail | undefined;
|
|
68
|
+
let detail: { title: string; body: string } | undefined;
|
|
69
|
+
let cursor: WorkCursor = { tab: "all", selected: undefined, history: false };
|
|
68
70
|
let workAbort: AbortController | undefined;
|
|
69
71
|
let context: ExtensionContext | undefined;
|
|
72
|
+
let requestWorkRender: (() => void) | undefined;
|
|
70
73
|
const todos = new WorkTodo(pi.events, () => { if (context) draw(context); }, () => {
|
|
71
74
|
if (context) void openWork(context, "todos").catch(error => context?.ui.notify(String(error), "error"));
|
|
72
75
|
});
|
|
@@ -77,44 +80,54 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
77
80
|
|
|
78
81
|
function workData(): WorkData { return { ...state(), history }; }
|
|
79
82
|
|
|
83
|
+
function collapseWork(ctx: ExtensionContext): void {
|
|
84
|
+
workAbort?.abort();
|
|
85
|
+
workAbort = undefined;
|
|
86
|
+
workOpen = false;
|
|
87
|
+
workPanel?.dispose();
|
|
88
|
+
workPanel = undefined;
|
|
89
|
+
workDetail = undefined;
|
|
90
|
+
detail = undefined;
|
|
91
|
+
history = { jobs: [] };
|
|
92
|
+
draw(ctx);
|
|
93
|
+
}
|
|
94
|
+
|
|
80
95
|
async function openWork(ctx: ExtensionContext, tab: WorkTab): Promise<void> {
|
|
81
96
|
if (ctx.mode !== "tui") { ctx.ui.notify(workText(state()), "info"); return; }
|
|
82
|
-
if (
|
|
97
|
+
if (panelOpen) return;
|
|
83
98
|
workOpen = true;
|
|
99
|
+
detail = undefined;
|
|
100
|
+
workDetail = undefined;
|
|
101
|
+
cursor = { tab, selected: undefined, history: false };
|
|
102
|
+
workPanel?.dispose();
|
|
103
|
+
workPanel = undefined;
|
|
104
|
+
const current = generation;
|
|
105
|
+
draw(ctx);
|
|
106
|
+
// Draw immediately; remote history must not delay expansion or typing.
|
|
107
|
+
if (refresh) await refresh;
|
|
108
|
+
if (current === generation && workOpen) await update(ctx);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function act(ctx: ExtensionContext, action: WorkAction | undefined): Promise<void> {
|
|
112
|
+
if (!action) { collapseWork(ctx); return; }
|
|
113
|
+
if (workAbort) return;
|
|
84
114
|
const interaction = new AbortController();
|
|
85
115
|
workAbort = interaction;
|
|
86
116
|
const current = generation;
|
|
87
|
-
let cursor: WorkCursor = { tab, selected: undefined, history: false };
|
|
88
117
|
try {
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
if (
|
|
118
|
+
const body = await runWorkAction(action, ctx, exec, interaction.signal);
|
|
119
|
+
if (current !== generation || interaction.signal.aborted) return;
|
|
120
|
+
if (body !== undefined) { detail = { title: action.entry.label, body }; workDetail = undefined; }
|
|
121
|
+
draw(ctx);
|
|
92
122
|
await update(ctx);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}, { overlay: true, overlayOptions: { width: "90%", maxHeight: "85%", anchor: "center" } });
|
|
99
|
-
workPanel = undefined;
|
|
100
|
-
closeWork = undefined;
|
|
101
|
-
if (!action || current !== generation) break;
|
|
102
|
-
cursor = action.cursor;
|
|
103
|
-
try {
|
|
104
|
-
const detail = await runWorkAction(action, ctx, exec, interaction.signal);
|
|
105
|
-
if (detail !== undefined && current === generation) await showWorkDetail(ctx, action.entry.label, detail, interaction.signal);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
if (current === generation) await showWorkDetail(ctx, "Work action unavailable", String(error), interaction.signal);
|
|
108
|
-
}
|
|
109
|
-
if (current === generation) await update(ctx);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (current === generation && !interaction.signal.aborted) {
|
|
125
|
+
detail = { title: "Work action unavailable", body: String(error) };
|
|
126
|
+
workDetail = undefined;
|
|
127
|
+
draw(ctx);
|
|
110
128
|
}
|
|
111
129
|
} finally {
|
|
112
|
-
interaction.abort();
|
|
113
130
|
if (workAbort === interaction) workAbort = undefined;
|
|
114
|
-
workPanel = undefined;
|
|
115
|
-
closeWork = undefined;
|
|
116
|
-
workOpen = false;
|
|
117
|
-
history = { jobs: [] };
|
|
118
131
|
}
|
|
119
132
|
}
|
|
120
133
|
|
|
@@ -122,10 +135,31 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
122
135
|
if (ctx.mode !== "tui") return;
|
|
123
136
|
workPanel?.update(workData());
|
|
124
137
|
const data = state();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
138
|
+
if (panelOpen || (!workOpen && !data.board.rows.length && (!data.todo || data.todo.display.empty) && !data.error)) {
|
|
139
|
+
ctx.ui.setWidget("wrangle", undefined);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (requestWorkRender) { requestWorkRender(); return; }
|
|
143
|
+
ctx.ui.setWidget("wrangle", tui => {
|
|
144
|
+
requestWorkRender = () => tui.requestRender();
|
|
145
|
+
return {
|
|
146
|
+
render(width: number): string[] {
|
|
147
|
+
const theme = ctx.ui.theme;
|
|
148
|
+
if (!workOpen) return workBoard(state(), width, theme);
|
|
149
|
+
if (detail) {
|
|
150
|
+
workDetail ??= new WorkDetail(detail.title, detail.body, theme, () => tui.terminal.rows, () => tui.requestRender());
|
|
151
|
+
workDetail.setTheme(theme);
|
|
152
|
+
return workDetail.render(width);
|
|
153
|
+
}
|
|
154
|
+
workDetail = undefined;
|
|
155
|
+
workPanel ??= new WorkPanel(workData(), cursor, theme, action => { void act(ctx, action); }, () => tui.requestRender(), () => tui.terminal.rows, todos);
|
|
156
|
+
workPanel.setTheme(theme);
|
|
157
|
+
return workPanel.render(width);
|
|
158
|
+
},
|
|
159
|
+
invalidate() { workPanel?.invalidate(); workDetail?.invalidate(); },
|
|
160
|
+
dispose() { workPanel?.dispose(); workPanel = undefined; requestWorkRender = undefined; },
|
|
161
|
+
};
|
|
162
|
+
}, { placement: "aboveEditor" });
|
|
129
163
|
}
|
|
130
164
|
|
|
131
165
|
function update(ctx: ExtensionContext): Promise<void> {
|
|
@@ -143,7 +177,7 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
143
177
|
if (workOpen) {
|
|
144
178
|
const loaded = await loadJobHistory(exec, owner);
|
|
145
179
|
if (current !== generation) return;
|
|
146
|
-
history = loaded;
|
|
180
|
+
if (workOpen) history = loaded;
|
|
147
181
|
}
|
|
148
182
|
draw(ctx);
|
|
149
183
|
} catch (error) {
|
|
@@ -159,10 +193,18 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
159
193
|
}
|
|
160
194
|
|
|
161
195
|
pi.on("session_start", async (_event, ctx) => {
|
|
196
|
+
if (ctx.mode === "tui") ctx.ui.setWidget("wrangle", undefined);
|
|
197
|
+
requestWorkRender = undefined;
|
|
198
|
+
workPanel?.dispose();
|
|
162
199
|
if (timer) clearInterval(timer);
|
|
163
200
|
generation++;
|
|
164
201
|
workAbort?.abort();
|
|
165
|
-
|
|
202
|
+
workAbort = undefined;
|
|
203
|
+
workOpen = false;
|
|
204
|
+
workPanel = undefined;
|
|
205
|
+
workDetail = undefined;
|
|
206
|
+
detail = undefined;
|
|
207
|
+
history = { jobs: [] };
|
|
166
208
|
context = ctx;
|
|
167
209
|
board = { hosts: [], rows: [] };
|
|
168
210
|
failure = owner ? undefined : "Wrangle needs a Herdr owner pane";
|
|
@@ -180,9 +222,14 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
180
222
|
await update(ctx);
|
|
181
223
|
});
|
|
182
224
|
pi.on("session_shutdown", (_event, ctx) => {
|
|
225
|
+
workPanel?.dispose();
|
|
183
226
|
generation++;
|
|
184
227
|
workAbort?.abort();
|
|
185
|
-
|
|
228
|
+
workAbort = undefined;
|
|
229
|
+
workOpen = false;
|
|
230
|
+
workPanel = undefined;
|
|
231
|
+
workDetail = undefined;
|
|
232
|
+
detail = undefined;
|
|
186
233
|
if (timer) clearInterval(timer);
|
|
187
234
|
timer = undefined;
|
|
188
235
|
inbox.stop();
|
|
@@ -203,12 +250,29 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
203
250
|
return;
|
|
204
251
|
}
|
|
205
252
|
});
|
|
253
|
+
async function toggleWork(ctx: ExtensionContext): Promise<void> {
|
|
254
|
+
if (workOpen) collapseWork(ctx);
|
|
255
|
+
else await openWork(ctx, "all");
|
|
256
|
+
}
|
|
206
257
|
pi.registerCommand("work", {
|
|
207
|
-
description: "
|
|
208
|
-
handler: async (_args, ctx) => {
|
|
209
|
-
await openWork(ctx, "all");
|
|
210
|
-
},
|
|
258
|
+
description: "Expand or collapse work above the editor (Alt+W)",
|
|
259
|
+
handler: async (_args, ctx) => { await toggleWork(ctx); },
|
|
211
260
|
});
|
|
261
|
+
pi.registerShortcut(Key.alt("w"), { description: "Expand or collapse work above the editor", handler: toggleWork });
|
|
262
|
+
for (const [key, input, description] of [
|
|
263
|
+
["j", "\u001b[B", "Next work item / scroll down"], ["k", "\u001b[A", "Previous work item / scroll up"],
|
|
264
|
+
["]", "\t", "Next work view"], ["i", "\r", "Inspect work / return to list"],
|
|
265
|
+
["s", "s", "Stop selected job"], ["c", "c", "Cancel selected queued work"],
|
|
266
|
+
["m", "m", "Message selected agent"], ["r", "r", "Refresh work"],
|
|
267
|
+
] as const) {
|
|
268
|
+
pi.registerShortcut(Key.alt(key), { description, handler: async (_ctx) => {
|
|
269
|
+
if (!workOpen || panelOpen || workAbort || !context) return;
|
|
270
|
+
if (detail) {
|
|
271
|
+
if (key === "i") { detail = undefined; draw(context); }
|
|
272
|
+
else if (key === "j" || key === "k") workDetail?.handleInput(input);
|
|
273
|
+
} else workPanel?.handleInput(input);
|
|
274
|
+
} });
|
|
275
|
+
}
|
|
212
276
|
pi.registerCommand("wrangle", {
|
|
213
277
|
description: "Hosts, your children and jobs, profiles, and messages",
|
|
214
278
|
handler: async (_args, ctx) => {
|
|
@@ -216,7 +280,7 @@ export default function wrangle(pi: ExtensionAPI) {
|
|
|
216
280
|
ctx.ui.notify(await exec(["board"]), "info");
|
|
217
281
|
return;
|
|
218
282
|
}
|
|
219
|
-
if (
|
|
283
|
+
if (panelOpen || workAbort) return;
|
|
220
284
|
panelOpen = true;
|
|
221
285
|
draw(ctx);
|
|
222
286
|
try {
|