@zhuxixi/pi-agent-board 0.12.1 → 0.13.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +7 -7
  3. package/docs/superpowers/plans/2026-10-21-issue-221-ask-user-question.md +198 -0
  4. package/docs/superpowers/plans/2026-10-23-issue-225-monotonic-foreground-state.md +450 -0
  5. package/docs/superpowers/plans/2026-10-23-issue-229-vim-jkl.md +449 -0
  6. package/docs/superpowers/plans/2026-10-23-issue-232-attach-bg-only-cells.md +153 -0
  7. package/docs/superpowers/plans/2026-10-23-lease-heartbeat-staleness.md +537 -0
  8. package/docs/superpowers/plans/2026-10-23-selected-row-highlight.md +405 -0
  9. package/docs/superpowers/plans/2026-10-24-issue-217-windows-pid-reuse-stopping.md +367 -0
  10. package/docs/superpowers/plans/2026-10-24-issue-230-warm-host-background-runs.md +806 -0
  11. package/docs/superpowers/plans/2026-10-24-issue-238-windows-process-identity-token.md +490 -0
  12. package/docs/superpowers/plans/2026-10-24-issue-241-coordinator-root-exit.md +461 -0
  13. package/docs/superpowers/plans/2026-10-25-issue-239-coordinator-replacement-identity.md +504 -0
  14. package/docs/superpowers/specs/2026-10-20-issue-221-ask-user-question-design.md +270 -0
  15. package/docs/superpowers/specs/2026-10-22-issue-225-monotonic-foreground-state-design.md +225 -0
  16. package/docs/superpowers/specs/2026-10-23-issue-229-vim-jkl-design.md +90 -0
  17. package/docs/superpowers/specs/2026-10-23-issue-232-attach-bg-only-cells-design.md +146 -0
  18. package/docs/superpowers/specs/2026-10-23-lease-heartbeat-staleness-design.md +271 -0
  19. package/docs/superpowers/specs/2026-10-23-selected-row-highlight-design.md +191 -0
  20. package/docs/superpowers/specs/2026-10-24-issue-217-windows-pid-reuse-stopping-design.md +334 -0
  21. package/docs/superpowers/specs/2026-10-24-issue-230-warm-host-background-runs-design.md +283 -0
  22. package/docs/superpowers/specs/2026-10-24-issue-238-windows-process-identity-token-design.md +286 -0
  23. package/docs/superpowers/specs/2026-10-24-issue-241-coordinator-root-exit-design.md +381 -0
  24. package/docs/superpowers/specs/2026-10-25-issue-239-coordinator-replacement-identity-design.md +331 -0
  25. package/package.json +3 -3
  26. package/runner/pty-runner.mjs +18 -22
  27. package/runner/state-coordinator.mjs +213 -26
  28. package/scripts/run-tests.mjs +375 -0
  29. package/src/core/background-runs.mjs +273 -0
  30. package/src/core/coordinator-client.mjs +346 -26
  31. package/src/core/diagnostics.mjs +24 -0
  32. package/src/core/events.mjs +16 -3
  33. package/src/core/foreground-projection-cache.mjs +99 -0
  34. package/src/core/host-coordination.mjs +69 -1
  35. package/src/core/launch.mjs +21 -1
  36. package/src/core/locks.mjs +176 -31
  37. package/src/core/pid.mjs +4 -2
  38. package/src/core/process-identity-probe.mjs +228 -0
  39. package/src/core/state-commands.mjs +5 -1
  40. package/src/core/types.mjs +1 -0
  41. package/src/core/warm-host-sweeper.mjs +7 -2
  42. package/src/runtime/service.mjs +385 -73
  43. package/src/ui/dashboard.ts +48 -25
  44. package/src/ui/pty-attach.ts +14 -6
@@ -358,9 +358,9 @@ export class DashboardComponent implements Component {
358
358
 
359
359
  private handleListKey(data: string): void {
360
360
  if (!matchesKey(data, Key.ctrl("x"))) this.deleteArm = null;
361
- if (matchesKey(data, Key.up)) return void this.moveSelection(-1);
362
- if (matchesKey(data, Key.down)) return void this.moveSelection(1);
363
- if (matchesKey(data, Key.right) || data === ">") return this.attachSelected();
361
+ if (matchesKey(data, Key.up) || data === "k") return void this.moveSelection(-1);
362
+ if (matchesKey(data, Key.down) || data === "j") return void this.moveSelection(1);
363
+ if (matchesKey(data, Key.right) || data === ">" || data === "l") return this.attachSelected();
364
364
  if (data === "v") return this.openSessionView();
365
365
  if (data === "e") return this.openEvidenceView();
366
366
  if (matchesKey(data, Key.enter)) {
@@ -378,11 +378,9 @@ export class DashboardComponent implements Component {
378
378
  if (matchesKey(data, Key.ctrl("t"))) return this.togglePin();
379
379
  if (matchesKey(data, Key.ctrl("s"))) return this.stopSelected();
380
380
  if (data === "d") return this.confirmDone();
381
- if (data === "d") return this.confirmDone();
382
381
  if (data === "x") return this.confirmDelete();
383
382
  if (data === "h") return this.toggleHold();
384
383
  if (matchesKey(data, Key.ctrl("x"))) return this.handleDeleteKey();
385
- if (matchesKey(data, Key.ctrl("x"))) return this.handleDeleteKey();
386
384
  if (data === "X") return this.confirmDeleteState();
387
385
  if (matchesKey(data, Key.escape) || matchesKey(data, Key.ctrl("c"))) {
388
386
  if (this.input.length > 0) {
@@ -398,8 +396,8 @@ export class DashboardComponent implements Component {
398
396
  }
399
397
 
400
398
  private handleSelectKey(data: string): void {
401
- if (matchesKey(data, Key.up)) return void this.moveSelection(-1);
402
- if (matchesKey(data, Key.down)) return void this.moveSelection(1);
399
+ if (matchesKey(data, Key.up) || data === "k") return void this.moveSelection(-1);
400
+ if (matchesKey(data, Key.down) || data === "j") return void this.moveSelection(1);
403
401
  if (matchesKey(data, Key.space)) {
404
402
  this.toggleSelectedCurrent();
405
403
  return;
@@ -426,13 +424,13 @@ export class DashboardComponent implements Component {
426
424
 
427
425
  private handlePeekKey(data: string): void {
428
426
  if (matchesKey(data, Key.escape)) return void (this.mode = "list");
429
- if (matchesKey(data, Key.right) || data === ">") return this.attachPeek();
427
+ if (matchesKey(data, Key.right) || data === ">" || data === "l") return this.attachPeek();
430
428
  if (data === "v") return this.openSessionView();
431
- if (matchesKey(data, Key.up)) {
429
+ if (matchesKey(data, Key.up) || data === "k") {
432
430
  this.peekStep(-1);
433
431
  return;
434
432
  }
435
- if (matchesKey(data, Key.down)) {
433
+ if (matchesKey(data, Key.down) || data === "j") {
436
434
  this.peekStep(1);
437
435
  return;
438
436
  }
@@ -506,7 +504,7 @@ export class DashboardComponent implements Component {
506
504
  }
507
505
  if (data === "r") return this.startReply();
508
506
  if (data === "v") return this.openSessionView();
509
- if (data === "a" || matchesKey(data, Key.enter) || matchesKey(data, Key.right)) return this.attachSelected();
507
+ if (data === "a" || matchesKey(data, Key.enter) || matchesKey(data, Key.right) || data === "l") return this.attachSelected();
510
508
  if (data === "x") return this.confirmClearDiagnostics();
511
509
  }
512
510
 
@@ -1350,6 +1348,7 @@ export class DashboardComponent implements Component {
1350
1348
  return this.hintLine("SELECT", "accent", [
1351
1349
  `${this.selectionCount()} selected`,
1352
1350
  ...(unread > 0 ? [`•${unread} unread`] : []),
1351
+ "↑↓/j/k move",
1353
1352
  "space toggle",
1354
1353
  "a all visible",
1355
1354
  "u clear",
@@ -1359,7 +1358,7 @@ export class DashboardComponent implements Component {
1359
1358
  ]);
1360
1359
  }
1361
1360
  const primary = this.input.trim() ? "enter launch" : live ? "enter attach live" : "enter resume";
1362
- const hints = ["i insert", primary, "→ attach", "m multi-select", ...(unread > 0 ? [`•${unread} unread`] : []), "d done", "h hold", "space peek", "v transcript", "e evidence", "ctrl+n new session", "ctrl+r rename", "x delete (y/N)", "ctrl+x x2 quick", "X delete state", "/ filter", "! pty", "? help"];
1361
+ const hints = ["i insert", primary, "→/l attach", "m multi-select", ...(unread > 0 ? [`•${unread} unread`] : []), "d done", "h hold", "space peek", "v transcript", "e evidence", "ctrl+n new session", "ctrl+r rename", "x delete (y/N)", "ctrl+x x2 quick", "X delete state", "/ filter", "! pty", "? help"];
1363
1362
  if (this.input.trim()) hints.splice(1, 0, "esc clear");
1364
1363
  return this.hintLine("NORMAL", "muted", hints);
1365
1364
  }
@@ -1478,7 +1477,12 @@ export class DashboardComponent implements Component {
1478
1477
  let line = `${marker} ${t.fg(selected ? "text" : "muted", selected ? t.bold(nameText) : nameText)}${folder} ${t.fg(selected ? "text" : "muted", summary)}`;
1479
1478
  line = padTo(line, contentWidth - visibleWidth(ageRaw));
1480
1479
  line += t.fg("dim", ageRaw);
1481
- return clip(`${" ".repeat(indent)}${clip(line, contentWidth)}`, width);
1480
+ // Issue #231: paint `indent + body` so the background opens at column 0 and
1481
+ // covers the trailing pad and the age column. `bg` closes inside the string,
1482
+ // so a clipped row cannot leak into the next line.
1483
+ const body = clip(line, contentWidth);
1484
+ const painted = applyRowHighlight(t, selected, `${" ".repeat(indent)}${body}`);
1485
+ return clip(painted, width);
1482
1486
  }
1483
1487
 
1484
1488
  private renderPeek(width: number): string[] {
@@ -1558,7 +1562,7 @@ export class DashboardComponent implements Component {
1558
1562
  const capacity = Math.max(3, (this.tui.terminal?.rows ?? 24) - 5);
1559
1563
  out.push(...panel.slice(this.evidenceScrollTop, this.evidenceScrollTop + capacity).map((line: string) => clip(line, width)));
1560
1564
  out.push(t.fg("dim", "─".repeat(width)));
1561
- out.push(clip(t.fg("dim", "←/< back · ↑↓ scroll · pgup/pgdn page · enter attach · r reply · v transcript · x clear diagnostics"), width));
1565
+ out.push(clip(t.fg("dim", "←/< back · ↑↓/j/k scroll · pgup/pgdn page · enter attach · r reply · v transcript · x clear diagnostics"), width));
1562
1566
  return out;
1563
1567
  }
1564
1568
 
@@ -1593,7 +1597,7 @@ export class DashboardComponent implements Component {
1593
1597
  const capacity = Math.max(3, (this.tui.terminal?.rows ?? 24) - out.length - 3);
1594
1598
  out.push(...this.windowSession(body, capacity));
1595
1599
  out.push(t.fg("dim", "─".repeat(width)));
1596
- out.push(clip(t.fg("dim", "←/< back · ↑↓ scroll · pgup/pgdn page · enter attach · d done · r reply · space peek"), width));
1600
+ out.push(clip(t.fg("dim", "←/< back · ↑↓/j/k scroll · pgup/pgdn page · enter attach · d done · r reply · space peek"), width));
1597
1601
  return out;
1598
1602
  }
1599
1603
 
@@ -1701,9 +1705,9 @@ export class DashboardComponent implements Component {
1701
1705
  ["enter", "Normal/insert with draft: open start-session dialog; empty: attach/resume"],
1702
1706
  ["shift+enter", "Insert a newline while in insert/reply"],
1703
1707
  ["esc", "Insert → normal; Normal with draft clears; empty quits standalone dashboard"],
1704
- ["↑/↓", "Normal: move selection; Insert: move cursor"],
1708
+ ["↑/↓ or j/k", "Normal: move selection; Insert: move cursor"],
1705
1709
  ["ctrl/alt+←/→", "Jump by word in insert mode"],
1706
- ["→ or >", "Attach to the selected real Pi session"],
1710
+ ["→ / > / l", "Attach to the selected real Pi session"],
1707
1711
  ["d", "Confirm and mark selected inactive session done"],
1708
1712
  ["h", "Hold / unhold the selected inactive session (on-hold state)"],
1709
1713
  ["space", "Peek when input is empty; in multi-select: toggle current row"],
@@ -1716,10 +1720,10 @@ export class DashboardComponent implements Component {
1716
1720
  ["ctrl+x x2", "Delete selected session (quick double-press, no confirm)"],
1717
1721
  ["X", "Delete all inactive sessions in selected state"],
1718
1722
  ["v", "Open read-only transcript view"],
1719
- ["In select", "a select all visible · u clear · d move done · ctrl+x delete done · esc cancel"],
1720
- ["In peek", "→ attach · v transcript · e evidence · r reply · ↑↓ adjacent"],
1721
- ["In session", "← back · ↑↓ scroll · e evidence · enter attach · r reply"],
1722
- ["In evidence", "← back · ↑↓ scroll · r reply · v transcript · x clear diagnostics"],
1723
+ ["In select", "j/k move · a select all · u clear · d move done · ctrl+x delete · esc cancel"],
1724
+ ["In peek", "→/l attach · v transcript · e evidence · r reply · ↑↓/j/k adjacent"],
1725
+ ["In session", "← back · ↑↓/j/k scroll · e evidence · enter attach · r reply"],
1726
+ ["In evidence", "← back · ↑↓/j/k scroll · →/l attach · r reply · v transcript · x clear diag"],
1723
1727
  ];
1724
1728
  const dialog = [t.fg("accent", t.bold("Hotkeys / keybindings")), ""];
1725
1729
  for (const [k, v] of rows) dialog.push(` ${t.fg("accent", k.padEnd(14))} ${t.fg("muted", v)}`);
@@ -1777,13 +1781,19 @@ export class DashboardComponent implements Component {
1777
1781
  const idx = body.findIndex((l) => l.includes("›"));
1778
1782
  selLine = idx >= 0 ? idx : 0;
1779
1783
  }
1780
- if (selLine < this.scrollTop) this.scrollTop = selLine;
1781
- if (selLine >= this.scrollTop + capacity - 1) this.scrollTop = selLine - capacity + 2;
1784
+ // The boundary lines can become scroll markers, so keep selection inside
1785
+ // them. On tiny viewports, prioritize the selected row over markers.
1786
+ const margin = capacity >= 3 ? 1 : 0;
1787
+ if (selLine < this.scrollTop + margin) this.scrollTop = selLine - margin;
1788
+ if (selLine >= this.scrollTop + capacity - margin) this.scrollTop = selLine - capacity + margin + 1;
1782
1789
  this.scrollTop = Math.max(0, Math.min(this.scrollTop, body.length - capacity));
1790
+ // The first session can follow both a stage and a folder header. Those
1791
+ // lines aren't selectable, so reveal them when the first session fits.
1792
+ if (this.selectedId === this.orderedIds[0] && selLine < capacity) this.scrollTop = 0;
1783
1793
  const slice = body.slice(this.scrollTop, this.scrollTop + capacity);
1784
1794
  const more = body.length - this.scrollTop - capacity;
1785
- if (this.scrollTop > 0) slice[0] = this.theme.fg("dim", ` ↑ ${this.scrollTop} more`);
1786
- if (more > 0) slice[slice.length - 1] = this.theme.fg("dim", ` ↓ ${more} more`);
1795
+ if (this.scrollTop > 0 && selLine !== this.scrollTop) slice[0] = this.theme.fg("dim", ` ↑ ${this.scrollTop + 1} more`);
1796
+ if (more > 0 && selLine !== this.scrollTop + capacity - 1) slice[slice.length - 1] = this.theme.fg("dim", ` ↓ ${more + 1} more`);
1787
1797
  return { lines: slice };
1788
1798
  }
1789
1799
 
@@ -1981,6 +1991,19 @@ function stageFg(state: keyof typeof GROUP_LABELS, text: string): string {
1981
1991
  return ansiFg(r, g, b, text);
1982
1992
  }
1983
1993
 
1994
+ /**
1995
+ * Issue #231: the selected row's full-line background. Pure (the theme is
1996
+ * injected) so the wrap/close contract is unit-testable, and an unselected row
1997
+ * is returned byte-identical.
1998
+ */
1999
+ export function applyRowHighlight(
2000
+ theme: Pick<ThemeLike, "bg">,
2001
+ selected: boolean,
2002
+ text: string,
2003
+ ): string {
2004
+ return selected ? theme.bg("selectedBg", text) : text;
2005
+ }
2006
+
1984
2007
  function renderPiIconLine(theme: ThemeLike, line: string): string {
1985
2008
  return theme.fg("accent", line);
1986
2009
  }
@@ -1976,12 +1976,19 @@ function lineToAnsi(
1976
1976
  if (isCursorRow && cursor!.col >= 0) return cursorHidden ? CURSOR_MARKER : CURSOR_MARKER + "\x1b[7m \x1b[0m";
1977
1977
  return "";
1978
1978
  }
1979
+ let lastBg = -1;
1979
1980
  for (let x = 0; x < line.length; x++) {
1980
1981
  const cell = line.getCell(x, reusable);
1981
1982
  if (!cell || cell.getWidth() === 0) continue;
1982
1983
  if (cell.getChars()) last = x;
1983
- }
1984
- if (last < 0) {
1984
+ if (!cell.isBgDefault()) lastBg = x;
1985
+ }
1986
+ // Issue #232: full-screen TUIs paint an explicit theme bg over otherwise empty
1987
+ // regions. Trimming at the last character drops that paint and lets the host
1988
+ // terminal's default bg show through, so the render bound covers the last
1989
+ // painted cell too. Default-bg lines keep the old bound, byte for byte.
1990
+ const renderEnd = Math.max(last, lastBg);
1991
+ if (renderEnd < 0) {
1985
1992
  // Empty line: same split as above.
1986
1993
  if (isCursorRow && cursor!.col >= 0) return cursorHidden ? CURSOR_MARKER : CURSOR_MARKER + "\x1b[7m \x1b[0m";
1987
1994
  return "";
@@ -1990,7 +1997,7 @@ function lineToAnsi(
1990
1997
  let out = "";
1991
1998
  let prevAttr = "";
1992
1999
  let prevUri = "";
1993
- for (let x = 0; x <= last; x++) {
2000
+ for (let x = 0; x <= renderEnd; x++) {
1994
2001
  const cell = line.getCell(x, reusable);
1995
2002
  if (!cell || cell.getWidth() === 0) continue;
1996
2003
  const uri = osc8UriForCell(term, cell);
@@ -2017,9 +2024,10 @@ function lineToAnsi(
2017
2024
  out += cell.getChars() || " ";
2018
2025
  }
2019
2026
  if (prevUri) out += closeOsc8();
2020
- // Cursor past the end of the line content (cursorX == cols or beyond last cell):
2021
- // append an inverse space so a VISIBLE position shows, keeping the marker either way.
2022
- if (isCursorRow && cursor!.col > last) {
2027
+ // Cursor past the end of the painted region (cursorX == cols or beyond the last
2028
+ // rendered cell): append an inverse space so a VISIBLE position shows, keeping the
2029
+ // marker either way.
2030
+ if (isCursorRow && cursor!.col > renderEnd) {
2023
2031
  out += CURSOR_MARKER + (cursorHidden ? "" : "\x1b[7m \x1b[0m");
2024
2032
  }
2025
2033
  return out + "\x1b[0m";