@deathbeam/pi-delegate 0.0.3 → 0.0.5
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/index.ts +8 -17
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -191,7 +191,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
191
191
|
const running = new Map<string, DelegateJob>();
|
|
192
192
|
const recent: InspectJob[] = [];
|
|
193
193
|
let viewing: (() => void) | undefined;
|
|
194
|
-
let finished = 0;
|
|
195
194
|
let ticker: ReturnType<typeof setInterval> | undefined;
|
|
196
195
|
|
|
197
196
|
const addActivity = (job: DelegateJob, activity: ChildActivity) => {
|
|
@@ -226,10 +225,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
226
225
|
const now = Date.now();
|
|
227
226
|
const { shown, hidden, detail } = widgetJobs([...running.values()]);
|
|
228
227
|
const lines: string[] = [];
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
lines.push(`${statusText(theme, "running", now)} ${theme.fg("muted", counts)}`);
|
|
232
|
-
}
|
|
228
|
+
const counts = `${running.size} running · ${running.size + recent.length} total`;
|
|
229
|
+
lines.push(`${statusText(theme, "running", now)} ${theme.fg("muted", counts)}`);
|
|
233
230
|
for (const job of shown) {
|
|
234
231
|
lines.push(
|
|
235
232
|
`${statusText(theme, "running", now)} ${theme.fg("toolTitle", theme.bold(job.agent))} ${theme.fg("muted", jobLine(job, now - job.startedAt))}`,
|
|
@@ -255,7 +252,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
255
252
|
if (job.controller.signal.aborted) return;
|
|
256
253
|
running.delete(job.id);
|
|
257
254
|
remember(job, error ? "failed" : "done", error ? `Error: ${error}` : undefined);
|
|
258
|
-
finished += 1;
|
|
259
255
|
if (running.size === 0) stopTicker();
|
|
260
256
|
refreshWidget(ctx);
|
|
261
257
|
const report: DelegateReport = {
|
|
@@ -284,7 +280,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
284
280
|
running.clear();
|
|
285
281
|
recent.length = 0;
|
|
286
282
|
viewing = undefined;
|
|
287
|
-
finished = 0;
|
|
288
283
|
});
|
|
289
284
|
|
|
290
285
|
pi.on("before_agent_start", (event, ctx) => {
|
|
@@ -355,7 +350,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
355
350
|
const renderJobs = (width: number, items: InspectJob[], selectedIndex: number): string[] => {
|
|
356
351
|
const row = (text: string) =>
|
|
357
352
|
truncateToWidth(text, Math.max(0, width - 1), "…", true) + theme.fg("borderMuted", "│");
|
|
358
|
-
const visible = Math.max(1, Math.floor((bodyHeight() -
|
|
353
|
+
const visible = Math.max(1, Math.floor((bodyHeight() - 1) / 2));
|
|
359
354
|
const start = Math.max(
|
|
360
355
|
0,
|
|
361
356
|
Math.min(selectedIndex - Math.floor(visible / 2), items.length - visible),
|
|
@@ -365,18 +360,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
365
360
|
.flatMap((item, index) => [
|
|
366
361
|
row(
|
|
367
362
|
theme.fg(
|
|
368
|
-
start + index === selectedIndex ? "accent" : "text",
|
|
363
|
+
start + index === selectedIndex && focus === "list" ? "accent" : "text",
|
|
369
364
|
`${start + index === selectedIndex ? "›" : " "} ${statusText(theme, item.status)} ${item.agent} ${item.id}`,
|
|
370
365
|
),
|
|
371
366
|
),
|
|
372
367
|
row(theme.fg("muted", ` ${item.description}`)),
|
|
373
368
|
]);
|
|
374
|
-
const heading = row(theme.fg(focus === "list" ? "accent" : "muted", `Jobs (${items.length})`));
|
|
375
369
|
return [
|
|
376
|
-
heading,
|
|
377
|
-
row(theme.fg("borderMuted", "─".repeat(Math.max(0, width - 1)))),
|
|
378
370
|
...lines,
|
|
379
|
-
...Array(Math.max(0, bodyHeight() -
|
|
371
|
+
...Array(Math.max(0, bodyHeight() - 1 - lines.length)).fill(row("")),
|
|
380
372
|
row(theme.fg("dim", ` ${selectedIndex + 1}/${items.length}`)),
|
|
381
373
|
].slice(0, bodyHeight());
|
|
382
374
|
};
|
|
@@ -447,10 +439,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
447
439
|
);
|
|
448
440
|
const selected = items[selectedIndex];
|
|
449
441
|
const title = truncateToWidth(
|
|
450
|
-
theme.fg(
|
|
451
|
-
"accent",
|
|
452
|
-
theme.
|
|
453
|
-
),
|
|
442
|
+
`${theme.fg(focus === "list" ? "accent" : "muted", focus === "list" ? "[Jobs]" : "Jobs")} ` +
|
|
443
|
+
`${theme.fg(focus === "history" ? "accent" : "muted", focus === "history" ? "[Activity]" : "Activity")}` +
|
|
444
|
+
theme.fg("dim", ` · ${running.size} running · ${items.length} total`),
|
|
454
445
|
width,
|
|
455
446
|
);
|
|
456
447
|
const footer = truncateToWidth(
|