pi-daddy 0.53.3 → 0.54.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.
@@ -1,5 +1,6 @@
1
1
  import type { DashboardAcknowledgment } from "./dashboard-session-client.ts";
2
2
  import {
3
+ needsUserInput,
3
4
  sessionDashboardItems,
4
5
  sessionNextLines,
5
6
  sessionPanelLines,
@@ -123,8 +124,7 @@ const versionStatus = (row: EcosystemVersionRow): string => {
123
124
  return "Up to date on disk";
124
125
  return "Unavailable";
125
126
  };
126
- const attention = (status: string) => ["failed", "refused", "incomplete"].includes(status);
127
- const active = (status: string) => ["active", "running", "starting", "authorised", "needs-you"].includes(status);
127
+ const active = (status: string) => ["active", "running", "starting", "authorised", "cancel-requested"].includes(status);
128
128
  export function ledgerDashboardItems(projection: DashboardProjection): DashboardItem[] {
129
129
  return projection.nodes.map((node) => ({
130
130
  key: node.executionId,
@@ -288,9 +288,13 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
288
288
  "Respond to the permission request in the parent Pi session.",
289
289
  ],
290
290
  }));
291
+ const legacyItems =
292
+ options.connected === false && !modern
293
+ ? options.items.map((item) => (needsUserInput(item) ? { ...item, status: "last-observed" } : item))
294
+ : options.items;
291
295
  const allItems = [
292
296
  ...(!modern || ["now", "work"].includes(screen.destination ?? "now") ? approvals : []),
293
- ...(modern ? sessionDashboardItems(options) : options.items),
297
+ ...(modern ? sessionDashboardItems(options) : legacyItems),
294
298
  ];
295
299
  const items = allItems.filter((item) =>
296
300
  options.filter === "agents"
@@ -298,13 +302,12 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
298
302
  : options.filter === "skills"
299
303
  ? item.skills
300
304
  : options.filter === "needs-you"
301
- ? ["needs-you", "approval-wait"].includes(item.status)
305
+ ? needsUserInput(item)
302
306
  : true,
303
307
  );
304
- const live = items.filter((item) => active(item.status)),
305
- needsAttention = items.filter((item) => attention(item.status)),
306
- past = items.filter((item) => !active(item.status) && !attention(item.status)).reverse();
307
- screen.items = modern ? items : [...live, ...needsAttention, ...(options.history ? past : [])];
308
+ const live = items.filter((item) => active(item.status));
309
+ const past = items.filter((item) => !active(item.status) && !needsUserInput(item)).reverse();
310
+ screen.items = modern ? items : [...items.filter(needsUserInput), ...live, ...(options.history ? past : [])];
308
311
  if (screen.view === "details" && !screen.items.some((item) => item.key === screen.selectedKey)) {
309
312
  const detail = items.find((item) => item.key === screen.selectedKey);
310
313
  if (detail) screen.items.push(detail);
@@ -347,8 +350,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
347
350
  ...(modern ? [sessionLocation(screen, width)] : []),
348
351
  ];
349
352
  const disconnected = modern && options.connected === false;
350
- if (disconnected) fixed.push("Disconnected · showing last known status");
351
- else if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
353
+ if (disconnected) {
354
+ fixed.push("Disconnected · showing last known status");
355
+ if (screen.view === "main" && (screen.destination ?? "now") === "now")
356
+ fixed.push(...wrapDashboardLines(["In the current Pi chat, run /grants dashboard."], width));
357
+ } else if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
352
358
  const ack = options.acknowledgment;
353
359
  if (ack?.state === "unconfirmed") {
354
360
  const setting =
@@ -380,8 +386,8 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
380
386
  if (recommendation) {
381
387
  const title = heading.includes("[3]") ? "Next step · [3] Reviews" : "Next step";
382
388
  fixed.push(sectionHeading(title, width), ...wrapDashboardLines([action], width).slice(0, 2));
383
- } else if (!allItems.some((i) => i.approval || ["needs-you", "approval-wait"].includes(i.status))) {
384
- fixed.push("No decision requested from you.");
389
+ } else if (!allItems.some(needsUserInput)) {
390
+ fixed.push("No pending dashboard requests.");
385
391
  }
386
392
  if (options.height >= 22) fixed.push("");
387
393
  }
@@ -518,26 +524,27 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
518
524
  body.push("No items match this filter. Press Tab to change it.");
519
525
  else body.push(...sessionPanelLines(options, screen.items, width));
520
526
  } else {
521
- const requestFinished = options.currentStatus && !active(options.currentStatus);
527
+ const requestFinished =
528
+ options.currentStatus &&
529
+ !active(options.currentStatus) &&
530
+ !["needs-you", "approval-wait"].includes(options.currentStatus);
522
531
  body.push(
523
532
  options.current
524
533
  ? requestFinished
525
534
  ? `LATEST REQUEST · ${friendlyStatus(options.currentStatus!)}`
526
535
  : "CURRENT REQUEST"
527
536
  : "CURRENT WORK",
528
- clean(options.current ?? live.find((item) => !item.approval)?.label ?? "No active work"),
537
+ clean(options.current ?? live[0]?.label ?? "No active work"),
529
538
  "",
530
539
  );
531
540
  const rows: { text: string; key?: string }[] = [];
532
541
  let group: string | undefined;
533
542
  for (const item of screen.items) {
534
- const next = item.approval
543
+ const next = needsUserInput(item)
535
544
  ? "NEEDS YOU"
536
- : attention(item.status)
537
- ? "NEEDS ATTENTION"
538
- : active(item.status)
539
- ? `WORK IN PROGRESS · ${live.filter((value) => !value.approval).length} active`
540
- : "HISTORY";
545
+ : active(item.status)
546
+ ? `WORK IN PROGRESS · ${live.length} active`
547
+ : "HISTORY";
541
548
  if (next !== group) {
542
549
  rows.push({ text: next });
543
550
  group = next;
@@ -552,7 +559,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
552
559
  });
553
560
  }
554
561
  const hidden = !options.history ? past.length : 0;
555
- const history = hidden ? `${hidden} finished · h shows history` : options.history ? "h hides history" : "";
562
+ const history = hidden ? `${hidden} earlier · h shows history` : options.history ? "h hides history" : "";
556
563
  const available = Math.max(0, height - fixed.length - footer.length - body.length - (history ? 1 : 0));
557
564
  const rowIndex = rows.findIndex((row) => row.key === selected?.key);
558
565
  const start = Math.max(0, rowIndex - available + 1);