pi-daddy 0.50.0 → 0.52.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 (97) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +13 -20
  3. package/dist/governance/approval-prompt.d.ts +4 -0
  4. package/dist/governance/approval-prompt.d.ts.map +1 -1
  5. package/dist/governance/approval-prompt.js +4 -5
  6. package/dist/governance/approval-prompt.js.map +1 -1
  7. package/dist/governance/initiative-coordinator.d.ts +5 -0
  8. package/dist/governance/initiative-coordinator.d.ts.map +1 -1
  9. package/dist/governance/initiative-coordinator.js +16 -0
  10. package/dist/governance/initiative-coordinator.js.map +1 -1
  11. package/dist/governance/permission-question.d.ts +4 -0
  12. package/dist/governance/permission-question.d.ts.map +1 -0
  13. package/dist/governance/permission-question.js +102 -0
  14. package/dist/governance/permission-question.js.map +1 -0
  15. package/dist/kernel/chain.d.ts +1 -0
  16. package/dist/kernel/chain.d.ts.map +1 -1
  17. package/dist/kernel/chain.js.map +1 -1
  18. package/dist/kernel/dashboard-observation.d.ts +15 -5
  19. package/dist/kernel/dashboard-observation.d.ts.map +1 -1
  20. package/dist/kernel/dashboard-observation.js.map +1 -1
  21. package/dist/products/activity-summary.d.ts +8 -0
  22. package/dist/products/activity-summary.d.ts.map +1 -0
  23. package/dist/products/activity-summary.js +101 -0
  24. package/dist/products/activity-summary.js.map +1 -0
  25. package/dist/products/activity-timeline.d.ts +4 -1
  26. package/dist/products/activity-timeline.d.ts.map +1 -1
  27. package/dist/products/activity-timeline.js +9 -1
  28. package/dist/products/activity-timeline.js.map +1 -1
  29. package/dist/products/dashboard-activity.d.ts +9 -0
  30. package/dist/products/dashboard-activity.d.ts.map +1 -0
  31. package/dist/products/dashboard-activity.js +119 -0
  32. package/dist/products/dashboard-activity.js.map +1 -0
  33. package/dist/products/dashboard-cli.d.ts +2 -1
  34. package/dist/products/dashboard-cli.d.ts.map +1 -1
  35. package/dist/products/dashboard-cli.js +17 -6
  36. package/dist/products/dashboard-cli.js.map +1 -1
  37. package/dist/products/dashboard-components.d.ts +10 -0
  38. package/dist/products/dashboard-components.d.ts.map +1 -0
  39. package/dist/products/dashboard-components.js +196 -0
  40. package/dist/products/dashboard-components.js.map +1 -0
  41. package/dist/products/dashboard-display-controls.d.ts.map +1 -1
  42. package/dist/products/dashboard-display-controls.js +43 -3
  43. package/dist/products/dashboard-display-controls.js.map +1 -1
  44. package/dist/products/dashboard-layout.d.ts +6 -0
  45. package/dist/products/dashboard-layout.d.ts.map +1 -0
  46. package/dist/products/dashboard-layout.js +61 -0
  47. package/dist/products/dashboard-layout.js.map +1 -0
  48. package/dist/products/dashboard-panels.d.ts +4 -0
  49. package/dist/products/dashboard-panels.d.ts.map +1 -1
  50. package/dist/products/dashboard-panels.js +321 -120
  51. package/dist/products/dashboard-panels.js.map +1 -1
  52. package/dist/products/dashboard-recap.d.ts +4 -0
  53. package/dist/products/dashboard-recap.d.ts.map +1 -0
  54. package/dist/products/dashboard-recap.js +43 -0
  55. package/dist/products/dashboard-recap.js.map +1 -0
  56. package/dist/products/dashboard-screen.d.ts +11 -3
  57. package/dist/products/dashboard-screen.d.ts.map +1 -1
  58. package/dist/products/dashboard-screen.js +224 -62
  59. package/dist/products/dashboard-screen.js.map +1 -1
  60. package/dist/products/dashboard-session-client.d.ts +6 -5
  61. package/dist/products/dashboard-session-client.d.ts.map +1 -1
  62. package/dist/products/dashboard-session-client.js.map +1 -1
  63. package/dist/products/ecosystem-versions.d.ts +2 -0
  64. package/dist/products/ecosystem-versions.d.ts.map +1 -1
  65. package/extensions/activity-timeline.ts +7 -1
  66. package/extensions/approvals.ts +7 -0
  67. package/extensions/dashboard-live.ts +45 -5
  68. package/extensions/dashboard-observation.ts +1 -3
  69. package/extensions/delegate-chain.ts +2 -0
  70. package/extensions/delegation-artifacts.ts +34 -4
  71. package/extensions/delegation-operations.ts +12 -4
  72. package/extensions/delegation.ts +4 -0
  73. package/extensions/ecosystem-versions.ts +25 -3
  74. package/extensions/execute-child.ts +4 -0
  75. package/extensions/initiative-handoff.ts +59 -0
  76. package/extensions/initiative-runtime.ts +39 -1
  77. package/extensions/run-delegation.ts +2 -0
  78. package/extensions/runtime-snapshot.ts +8 -4
  79. package/extensions/session.ts +2 -2
  80. package/package.json +1 -1
  81. package/src/governance/approval-prompt.ts +7 -6
  82. package/src/governance/initiative-coordinator.ts +16 -0
  83. package/src/governance/permission-question.ts +108 -0
  84. package/src/kernel/chain.ts +1 -0
  85. package/src/kernel/dashboard-observation.ts +15 -1
  86. package/src/products/activity-summary.ts +101 -0
  87. package/src/products/activity-timeline.ts +11 -0
  88. package/src/products/dashboard-activity.ts +136 -0
  89. package/src/products/dashboard-cli.ts +29 -7
  90. package/src/products/dashboard-components.ts +219 -0
  91. package/src/products/dashboard-display-controls.ts +37 -3
  92. package/src/products/dashboard-layout.ts +71 -0
  93. package/src/products/dashboard-panels.ts +359 -145
  94. package/src/products/dashboard-recap.ts +48 -0
  95. package/src/products/dashboard-screen.ts +264 -68
  96. package/src/products/dashboard-session-client.ts +7 -1
  97. package/src/products/ecosystem-versions.ts +2 -0
@@ -1,4 +1,15 @@
1
- import { sessionDashboardItems, sessionPanelLines, type DashboardDestination } from "./dashboard-panels.ts";
1
+ import type { DashboardAcknowledgment } from "./dashboard-session-client.ts";
2
+ import {
3
+ sessionDashboardItems,
4
+ sessionNextLines,
5
+ sessionPanelLines,
6
+ DASHBOARD_DESTINATIONS,
7
+ type DashboardDestination,
8
+ } from "./dashboard-panels.ts";
9
+ import { activityTaskTitle } from "./dashboard-activity.ts";
10
+ import { versionLines } from "./dashboard-components.ts";
11
+ import { sessionRecapLines } from "./dashboard-recap.ts";
12
+ import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
2
13
  import { dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
3
14
  /** Height-bounded, task-first view. Permission state is always supplied by the owner. */
4
15
  import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
@@ -12,7 +23,11 @@ export interface DashboardItem {
12
23
  label: string;
13
24
  status: string;
14
25
  elapsed: string;
26
+ updatedAt?: string;
15
27
  details: string[];
28
+ briefDetails?: string[];
29
+ reviewSummary?: boolean;
30
+ relatedReviewKey?: string;
16
31
  observation?: string;
17
32
  taskKey?: string;
18
33
  timelinePath?: string;
@@ -21,9 +36,10 @@ export interface DashboardItem {
21
36
  agent?: boolean;
22
37
  }
23
38
  export interface DashboardScreenState {
24
- view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings";
39
+ view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings" | "recap";
25
40
  destination?: DashboardDestination;
26
41
  expanded?: boolean;
42
+ sourceDetails?: boolean;
27
43
  manualScroll?: boolean;
28
44
  selections?: Record<string, string>;
29
45
  settingKey?: DashboardSettingKey;
@@ -40,18 +56,22 @@ export const dashboardText = (value: string) =>
40
56
  .replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "")
41
57
  .replace(/[\p{Cc}\p{Cf}]/gu, " ");
42
58
  const clean = (value: string) => dashboardText(value).replace(/\s+/g, " ").trim();
43
- function wrapped(lines: string[], width: number): string[] {
59
+ export function wrapDashboardLines(lines: string[], width: number): string[] {
44
60
  return lines.flatMap((line) => {
61
+ const safe = dashboardText(line);
62
+ if (cellWidth(safe) <= width) return [safe];
63
+ const indent = width >= 12 && (safe.startsWith("> ") || safe.startsWith(" ")) ? safe.slice(0, 2) : "";
64
+ const available = width - indent.length;
45
65
  const result: string[] = [];
46
66
  let row = "";
47
- for (const word of dashboardText(line).split(/\s+/)) {
48
- if (row && cellWidth(row + " " + word) > width) {
67
+ for (const word of safe.slice(indent.length).split(/\s+/)) {
68
+ if (row && cellWidth(row + " " + word) > available) {
49
69
  result.push(row);
50
70
  row = "";
51
71
  }
52
- if (cellWidth(word) > width) {
72
+ if (cellWidth(word) > available) {
53
73
  for (const character of word) {
54
- if (row && cellWidth(row + character) > width) {
74
+ if (row && cellWidth(row + character) > available) {
55
75
  result.push(row);
56
76
  row = "";
57
77
  }
@@ -60,7 +80,7 @@ function wrapped(lines: string[], width: number): string[] {
60
80
  } else row += (row ? " " : "") + word;
61
81
  }
62
82
  result.push(row);
63
- return result;
83
+ return result.map((part, i) => (i === 0 ? indent : " ".repeat(indent.length)) + part);
64
84
  });
65
85
  }
66
86
 
@@ -71,13 +91,21 @@ function elapsed(ms: number): string {
71
91
  ? `${Math.floor(minutes / 60)}:${String(minutes % 60).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`
72
92
  : `${minutes}:${String(seconds % 60).padStart(2, "0")}`;
73
93
  }
74
- const friendlyStatus = (status: string) =>
94
+ export const friendlyStatus = (status: string) =>
75
95
  ({
76
96
  active: "Running",
77
97
  running: "Running",
78
98
  starting: "Starting",
79
- authorised: "Approved",
99
+ authorised: "Authorized",
100
+ observed: "Reported",
101
+ "cancel-requested": "Cancel requested",
102
+ unknown: "Unknown",
103
+ unavailable: "Unavailable",
80
104
  "needs-you": "Needs you",
105
+ "approval-wait": "Awaiting decision",
106
+ "dependency-wait": "Waiting on dependency",
107
+ "last-observed": "Last seen",
108
+ settled: "Finished",
81
109
  completed: "Finished",
82
110
  finished: "Finished",
83
111
  failed: "Failed",
@@ -102,6 +130,7 @@ export function ledgerDashboardItems(projection: DashboardProjection): Dashboard
102
130
  label: node.agentName || "Governed execution",
103
131
  status: node.state,
104
132
  elapsed: elapsed(node.durationMs),
133
+ updatedAt: node.updatedAt,
105
134
  agent: true,
106
135
  details: [
107
136
  `Execution: ${node.executionId}`,
@@ -121,12 +150,16 @@ export function activityDashboardItems(
121
150
  timeline: ActivityTimeline,
122
151
  aliases: ActivityTimelineAliases,
123
152
  now: Date,
153
+ human = false,
124
154
  ): DashboardItem[] {
125
155
  return timeline.tasks.map((task) => ({
126
156
  key: activityTaskKey(task.rootId, task.id),
127
157
  taskKey: activityTaskKey(task.rootId, task.id),
128
- label: `${task.agent || (task.trigger?.type === "custom" ? "Extension turn" : "User turn")} [${aliases.selector(task)}]`,
158
+ label: human
159
+ ? activityTaskTitle(task)
160
+ : `${task.agent || (task.trigger?.type === "custom" ? "Extension turn" : "User turn")} [${aliases.selector(task)}]`,
129
161
  status: task.status,
162
+ updatedAt: task.endedAt ?? task.lastEvent?.at ?? task.startedAt,
130
163
  elapsed: elapsed(Date.parse(task.endedAt ?? now.toISOString()) - Date.parse(task.startedAt)),
131
164
  observation: task.lastEvent
132
165
  ? `${task.lastEvent.tool ? `${task.lastEvent.tool} ` : ""}${task.lastEvent.kind.replaceAll("_", " ")} · ${elapsed(Date.parse(now.toISOString()) - Date.parse(task.lastEvent.at))} ago`
@@ -172,18 +205,77 @@ export interface DashboardScreenOptions {
172
205
  content?: { title: string; text: string };
173
206
  command?: string;
174
207
  connected?: boolean;
175
- acknowledgment?: string;
208
+ acknowledgment?: DashboardAcknowledgment;
176
209
  now?: Date;
177
210
  }
211
+ const destinationNames: Record<DashboardDestination, string> = {
212
+ now: "Overview",
213
+ work: "Tasks",
214
+ reviews: "Reviews",
215
+ activity: "Activity",
216
+ evidence: "Evidence",
217
+ settings: "Settings",
218
+ };
219
+ function sessionLocation(screen: DashboardScreenState, width: number): string {
220
+ const destination = screen.destination ?? "now";
221
+ const overlays = {
222
+ details: "Details",
223
+ models: "Models",
224
+ help: "Help",
225
+ versions: "Versions",
226
+ "version-details": "Version details",
227
+ recap: "Session recap",
228
+ };
229
+ const name = destinationNames[destination];
230
+ if (screen.view in overlays) return `${name} / ${overlays[screen.view as keyof typeof overlays]}`;
231
+ const nav = DASHBOARD_DESTINATIONS.map((view, i) =>
232
+ view === destination ? `[${i + 1} ${name}]` : `${i + 1} ${destinationNames[view]}`,
233
+ ).join(" ");
234
+ return cellWidth(nav) <= width
235
+ ? nav
236
+ : `[${DASHBOARD_DESTINATIONS.indexOf(destination) + 1} ${name}] · 1–6 views · ? help`;
237
+ }
238
+
239
+ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | undefined, width: number): string[] {
240
+ const view = screen.view;
241
+ const brief = width < 34;
242
+ if (view === "main") {
243
+ const keys = selected ? (brief ? "↑↓ · Enter details" : "↑↓ select · Enter details") : "1–6 views";
244
+ return [keys + (brief ? " · ?" : " · ? help"), "r recap · q close"];
245
+ }
246
+ if (view === "versions" || view === "settings")
247
+ return [view === "settings" ? "↑↓ select · Enter edit" : "↑↓ select · Enter details", "Esc back · ? help"];
248
+ return [
249
+ brief ? "↑↓ scroll · Esc back" : "↑↓ scroll · Esc back · q close",
250
+ ...(view === "details" && selected?.taskKey ? ["p prompt · f final · ? help"] : []),
251
+ ...(view === "details" && selected?.briefDetails ? [screen.sourceDetails ? "x hide source" : "x show source"] : []),
252
+ ];
253
+ }
254
+ const permissionDescriptions: Record<string, string> = {
255
+ "tool:bash": "shell access",
256
+ "tool:write": "permission to write files",
257
+ "tool:edit": "permission to edit files",
258
+ };
178
259
  /** Selection follows stable identity through refresh, never an unrelated task at the old row index. */
179
260
  export function renderDashboardScreen(options: DashboardScreenOptions): string {
180
261
  const width = Math.max(1, Math.floor(options.width)),
181
262
  height = Math.max(1, Math.floor(options.height));
182
263
  const { screen, session } = options,
183
264
  pending = session?.pendingApprovals ?? [];
184
- const approvals: DashboardItem[] = pending.map((approval) => ({
265
+ const modern = Boolean(session?.observation);
266
+ const approvals: DashboardItem[] = (options.connected === false ? [] : pending).map((approval) => ({
185
267
  key: `approval:${approval.id}`,
186
- label: `${approval.subject} · ${approval.capability.replace(/^tool:/, "")}`,
268
+ label: modern
269
+ ? `${clean(approval.subject)} needs ${permissionDescriptions[approval.capability] ?? approval.capability}`
270
+ : `${approval.subject} · ${approval.capability.replace(/^tool:/, "")}`,
271
+ ...(modern
272
+ ? {
273
+ briefDetails: [
274
+ "Open the permission request in your main Pi chat.",
275
+ "Choose whether to grant this access for the task.",
276
+ ],
277
+ }
278
+ : {}),
187
279
  status: "needs-you",
188
280
  elapsed: "",
189
281
  approval: true,
@@ -192,10 +284,9 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
192
284
  `Subject: ${approval.subject}`,
193
285
  `Capability: ${approval.capability}`,
194
286
  "Waiting for Daddy permission in the owner session.",
195
- "Use the owner's prompt, or a to enable Auto.",
287
+ "Respond to the permission request in the parent Pi session.",
196
288
  ],
197
289
  }));
198
- const modern = Boolean(session?.observation);
199
290
  const allItems = [
200
291
  ...(!modern || ["now", "work"].includes(screen.destination ?? "now") ? approvals : []),
201
292
  ...(modern ? sessionDashboardItems(options) : options.items),
@@ -206,7 +297,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
206
297
  : options.filter === "skills"
207
298
  ? item.skills
208
299
  : options.filter === "needs-you"
209
- ? item.status === "needs-you"
300
+ ? ["needs-you", "approval-wait"].includes(item.status)
210
301
  : true,
211
302
  );
212
303
  const live = items.filter((item) => active(item.status)),
@@ -217,7 +308,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
217
308
  const detail = items.find((item) => item.key === screen.selectedKey);
218
309
  if (detail) screen.items.push(detail);
219
310
  }
220
- if (!screen.items.some((item) => item.key === screen.selectedKey)) screen.selectedKey = screen.items[0]?.key;
311
+ if (
312
+ !screen.items.some((item) => item.key === screen.selectedKey) &&
313
+ !(screen.view === "details" && screen.selectedKey)
314
+ )
315
+ screen.selectedKey = screen.items[0]?.key;
221
316
  const selectedIndex = screen.items.findIndex((item) => item.key === screen.selectedKey),
222
317
  selected = screen.items[selectedIndex];
223
318
  screen.versionRows = session?.versions?.rows ?? [];
@@ -225,47 +320,85 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
225
320
  const selectedVersion = screen.versionRows.find((row) => row.id === screen.versionId);
226
321
  const mode =
227
322
  session && options.connected !== false ? `Auto ${session.auto.enabled ? "ON" : "OFF"}` : "Auto unavailable";
228
- const header = `PI DADDY | ${mode}${options.pending ? " …" : session ? " [a]" : ""}`;
323
+ const header = `PI DADDY | ${mode}${options.pending ? " …" : session && options.connected !== false ? " [a]" : ""}`;
229
324
  const footer =
230
325
  options.command !== undefined
231
326
  ? [`: ${clean(options.command)}`]
232
- : screen.view === "settings"
233
- ? ["↑↓ select · Enter toggle/edit · Esc back", "0 default limit · PgUp/PgDn scroll · s settings"]
234
- : screen.view === "main" || screen.view === "versions"
235
- ? [
236
- modern ? "↑↓ select · PgUp/PgDn scroll · Enter details" : "↑↓ select · Enter details · a Auto",
237
- "m models · v versions · s settings · ?",
238
- ]
239
- : [
240
- "↑↓ scroll · Esc back · a Auto",
241
- screen.view === "details" ? "p prompt · f final · : command · ? help" : ": command · ? help",
242
- ];
327
+ : modern
328
+ ? sessionKeys(screen, selected, width)
329
+ : screen.view === "settings"
330
+ ? ["↑↓ select · Enter toggle/edit · Esc back", "0 default limit · PgUp/PgDn scroll · s settings"]
331
+ : screen.view === "main" || screen.view === "versions"
332
+ ? ["↑↓ select · Enter details · a Auto", "m models · v versions · s settings · ?"]
333
+ : [
334
+ "↑↓ scroll · Esc back · a Auto",
335
+ screen.view === "details" ? "p prompt · f final · : command · ? help" : ": command · ? help",
336
+ ];
243
337
  const fixed = [
244
- header,
245
- session && options.connected !== false
246
- ? `Permissions connected${pending.length ? ` · ${pending.length} needs you` : ""}`
247
- : "Permission controls disconnected",
248
- ...(modern
338
+ modern && options.connected !== false ? `${header} · Connected` : header,
339
+ ...(!modern
249
340
  ? [
250
- width >= 74
251
- ? "1 Now · 2 Work · 3 Reviews · 4 Activity · 5 Evidence · 6 Settings"
252
- : `${(screen.destination ?? "now").toUpperCase()} · 1–6 views · x expand`,
341
+ session && options.connected !== false
342
+ ? `Permissions connected${pending.length ? ` · ${pending.length} needs you` : ""}`
343
+ : "Permission controls disconnected",
253
344
  ]
254
345
  : []),
346
+ ...(modern ? [sessionLocation(screen, width)] : []),
255
347
  ];
256
- if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
257
- if (options.acknowledgment) fixed.push(clean(options.acknowledgment));
258
- if (modern && options.connected === false)
259
- fixed.push(`LAST OBSERVED: ${session!.observation!.observedAt}; live state unknown`);
348
+ const disconnected = modern && options.connected === false;
349
+ if (disconnected) fixed.push("Disconnected · showing last known status");
350
+ else if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
351
+ const ack = options.acknowledgment;
352
+ if (ack?.state === "unconfirmed") {
353
+ const setting =
354
+ ({ "set-auto": "Auto", "set-jev": "JEV", set: "model", "set-limit": "limit" } as Record<string, string>)[
355
+ ack.action
356
+ ] ?? "setting";
357
+ fixed.push(
358
+ ...wrapDashboardLines([`Unconfirmed ${setting} change. Check the main Pi chat before trying again.`], width),
359
+ );
360
+ } else if (ack && (!disconnected || !modern) && (!modern || screen.view === "settings" || ack.state === "refused")) {
361
+ fixed.push(clean(`${ack.action}: ${ack.state} · ${ack.effect}`));
362
+ }
363
+ if (modern && options.filter && options.filter !== "everything" && screen.view === "main")
364
+ fixed.push(`Filter: ${options.filter} · Tab to change`);
365
+ if (modern && options.height >= 22) fixed.push("");
366
+ if (modern && screen.view === "main" && (screen.destination ?? "now") === "now" && !disconnected) {
367
+ const [heading, action] = sessionNextLines(options);
368
+ const recommendation = action !== "No current next step reported.";
369
+ if (recommendation) {
370
+ const title = heading.includes("[3]") ? "Next step · [3] Reviews" : "Next step";
371
+ fixed.push(sectionHeading(title, width), ...wrapDashboardLines([action], width).slice(0, 2));
372
+ } else if (!allItems.some((i) => i.approval || ["needs-you", "approval-wait"].includes(i.status))) {
373
+ fixed.push("No decision requested from you.");
374
+ }
375
+ if (options.height >= 22) fixed.push("");
376
+ }
260
377
  const body: string[] = [];
261
- if (screen.view === "help")
378
+ if (screen.view === "recap") {
379
+ const recap = sessionRecapLines(options);
380
+ const activity = recap.findIndex(
381
+ (line) => line === "Recent activity · newest first" || line === "No recent session events recorded.",
382
+ );
383
+ const summary = activity < 0 ? recap : recap.slice(0, activity);
384
+ if (summary.length) body.push(sectionHeading("SESSION STATUS", width), ...summary);
385
+ if (activity >= 0)
386
+ body.push(
387
+ sectionHeading("RECENT ACTIVITY", width),
388
+ ...recap.slice(activity + Number(recap[activity] === "Recent activity · newest first")),
389
+ );
390
+ } else if (screen.view === "help")
262
391
  body.push(
263
392
  "DASHBOARD KEYS",
264
393
  "↑/↓ or j/k: select; Enter/d: details",
265
394
  "a: toggle Daddy permission Auto",
266
395
  "m: session models; v: ecosystem versions; s: settings",
267
- "1–6: Now / Work / Reviews / Activity / Evidence / Settings",
268
- "x: compact/expanded (96 columns); selection is preserved",
396
+ "1 Overview · what needs you and what Pi is doing",
397
+ "2 Tasks · full session task list, including finished work",
398
+ "3 Reviews · 4 Activity · 5 Evidence · 6 Settings",
399
+ "r: recent session activity and review counts",
400
+ "Wide terminals preview the selected item. x shows more session information.",
401
+ "x in a review detail: show or hide its source and exact reference",
269
402
  "No cancellation shortcut: request it in the owning Pi session.",
270
403
  "Goals/next steps are owner recommendations, not execution authority.",
271
404
  "Reviews apply only to their exact subject; completed is not accepted.",
@@ -283,30 +416,45 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
283
416
  );
284
417
  else if (screen.view === "settings") {
285
418
  body.push(
419
+ ...(disconnected
420
+ ? [
421
+ sectionHeading("Connection details", width),
422
+ `Last contact: ${session!.observation!.observedAt}`,
423
+ ...(options.notice || options.problem ? [clean(options.notice || options.problem || "")] : []),
424
+ "",
425
+ ]
426
+ : []),
286
427
  ...dashboardSettingsLines(
287
428
  options.connected === false && session?.settings ? { ...session.settings, editable: false } : session?.settings,
288
429
  session?.auto.enabled,
289
430
  screen.settingKey ?? "auto",
290
- ),
431
+ ).map((line) => {
432
+ if (modern && (line === "SETTINGS" || line === "SETTINGS · current session"))
433
+ return sectionHeading("SESSION CONTROLS", width);
434
+ if (modern && line.startsWith("STARTUP LIMITS")) return sectionHeading(line, width);
435
+ return line;
436
+ }),
291
437
  );
292
438
  if (session?.observation)
293
439
  body.push(
294
- "CAPTURE · startup configuration (not a retention receipt)",
440
+ sectionHeading("CAPTURE · startup configuration", width),
295
441
  `Transcripts: ${session.observation.capture.transcripts ? "configured" : "off"}`,
296
442
  `Diagnostics: ${session.observation.capture.diagnostics ? "configured" : "off"}`,
297
443
  "Capture changes require a new parent launch.",
298
444
  "m models · v versions",
299
445
  );
300
446
  } else if (screen.view === "versions" || screen.view === "version-details") {
301
- body.push("VERSIONS");
447
+ body.push(modern ? sectionHeading("VERSIONS", width) : "VERSIONS");
302
448
  if (!session?.versions) body.push("Owner has not reported versions.");
303
449
  else if (screen.view === "versions") {
304
- body.push("Loaded -> on disk");
450
+ body.push(modern ? "Packages in this Pi session" : "Loaded -> on disk");
305
451
  for (const row of screen.versionRows)
306
- body.push(
307
- `${row.id === screen.versionId ? ">" : " "} ${row.label}: ${row.loadedVersion ?? "?"} -> ${row.installedVersion ?? "?"}`,
308
- ` ${versionStatus(row)}`,
309
- );
452
+ if (modern) body.push(...versionLines(row, row.id === screen.versionId, options));
453
+ else
454
+ body.push(
455
+ `${row.id === screen.versionId ? ">" : " "} ${row.label}: ${row.loadedVersion ?? "?"} -> ${row.installedVersion ?? "?"}`,
456
+ ` ${versionStatus(row)}`,
457
+ );
310
458
  if (session.versions.note) body.push(session.versions.note);
311
459
  } else if (selectedVersion) {
312
460
  body.push(
@@ -323,19 +471,42 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
323
471
  if (session.versions.note) body.push(session.versions.note);
324
472
  }
325
473
  } else if (screen.view === "models") {
326
- body.push("SESSION MODELS");
474
+ body.push(modern ? sectionHeading("SESSION MODELS", width) : "SESSION MODELS");
327
475
  if (!session) body.push("Connect from /grants dashboard to edit models.");
328
476
  for (const row of session?.rows ?? [])
329
477
  body.push(`${row.definition}: ${row.model}`, ` ${row.thinking} · ${row.source}`);
330
478
  body.push(": m <definition|all> <provider:model> <thinking>");
331
479
  } else if (screen.view === "details") {
480
+ const title =
481
+ selected &&
482
+ (selected.key.startsWith("component:") ||
483
+ (selected.status === "approval-wait" && /\bready for review\b/i.test(selected.label))
484
+ ? selected.label
485
+ : selected.status === "last-observed"
486
+ ? `Last seen · ${selected.label}`
487
+ : `${selected.label} · ${friendlyStatus(selected.status)}`);
332
488
  body.push(
333
- selected ? `${selected.label} · ${friendlyStatus(selected.status)}` : "No selected task",
334
- ...(selected?.details ?? []),
489
+ title ??
490
+ (screen.selectedKey ? "This item is no longer visible. Press Esc to return to the list." : "No selected task"),
491
+ ...(modern && selected
492
+ ? [
493
+ sectionHeading(
494
+ screen.sourceDetails
495
+ ? "SOURCE RECORD"
496
+ : (selected.briefDetails && selected.status === "approval-wait") || selected.approval
497
+ ? "NEXT ACTION"
498
+ : "DETAILS",
499
+ width,
500
+ ),
501
+ ]
502
+ : []),
503
+ ...((screen.sourceDetails ? selected?.details : (selected?.briefDetails ?? selected?.details)) ?? []),
335
504
  );
336
- if (options.content) body.push("", options.content.title, ...options.content.text.split(/\r?\n/));
505
+ if (selected && options.content) body.push("", options.content.title, ...options.content.text.split(/\r?\n/));
337
506
  } else if (modern) {
338
- body.push(...sessionPanelLines(options, screen.items, width));
507
+ if (!screen.items.length && options.filter && options.filter !== "everything")
508
+ body.push("No items match this filter. Press Tab to change it.");
509
+ else body.push(...sessionPanelLines(options, screen.items, width));
339
510
  } else {
340
511
  const requestFinished = options.currentStatus && !active(options.currentStatus);
341
512
  body.push(
@@ -381,15 +552,20 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
381
552
  if (history) body.push(history);
382
553
  }
383
554
 
555
+ const left =
556
+ modern && screen.view === "main" && selected
557
+ ? previewWidth(screen.destination ?? "now", Boolean(screen.expanded), width)
558
+ : undefined;
384
559
  const detailBody =
385
- (screen.view === "main" && (!modern || (screen.expanded && width >= 96))) || screen.view === "versions"
386
- ? body
387
- : wrapped(body, width);
388
- const clipped = modern && detailBody.length > Math.max(0, height - fixed.length - footer.length);
560
+ !modern && (screen.view === "main" || screen.view === "versions") ? body : wrapDashboardLines(body, left ?? width);
561
+ if (modern && height >= 16 && height - fixed.length - footer.length > detailBody.length)
562
+ footer.unshift("─".repeat(Math.min(width, 100)));
563
+ const bodyRoom = height - fixed.length - footer.length;
564
+ const clipped = modern && bodyRoom >= 2 && detailBody.length > bodyRoom;
389
565
  if (clipped) footer.push("");
390
566
  const room = Math.max(0, height - fixed.length - footer.length);
391
567
  if (screen.view === "versions" && selectedVersion && room > 0) {
392
- const row = 2 + screen.versionRows.findIndex((value) => value.id === screen.versionId) * 2;
568
+ const row = detailBody.findIndex((line) => line.startsWith(">"));
393
569
  if (row < screen.offset) screen.offset = row;
394
570
  else if (row + 1 >= screen.offset + room) screen.offset = Math.max(0, row + 2 - room);
395
571
  }
@@ -409,16 +585,36 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
409
585
  if (clipped)
410
586
  footer[footer.length - 1] =
411
587
  `Rows ${offset + 1}–${Math.min(offset + room, detailBody.length)}/${detailBody.length} · PgUp/PgDn`;
412
- const lines = [...fixed, ...detailBody.slice(offset, offset + room)];
588
+ const page = detailBody.slice(offset, offset + room);
589
+ if (left !== undefined && selected) {
590
+ const right = Math.min(width - left - 3, 72);
591
+ const preview = wrapDashboardLines(
592
+ [
593
+ sectionHeading("Selected item", right),
594
+ clean(selected.label),
595
+ "",
596
+ ...(selected.briefDetails ?? [friendlyStatus(selected.status), "Press Enter for details."]),
597
+ ],
598
+ right,
599
+ );
600
+ const count = Math.min(room, Math.max(page.length, preview.length));
601
+ for (let i = 0; i < count; i++) {
602
+ const cell = page[i] ?? "";
603
+ page[i] = cell + " ".repeat(Math.max(0, left - cellWidth(cell))) + " │ " + (preview[i] ?? "");
604
+ }
605
+ }
606
+ const lines = [...fixed, ...page];
413
607
  while (lines.length < height - footer.length) lines.push("");
414
- const output =
415
- height < fixed.length + footer.length
416
- ? fixed.slice(0, height)
417
- : [...lines.slice(0, Math.max(0, height - footer.length)), ...footer].slice(0, height);
608
+ const output = [...lines, ...footer].slice(0, height);
418
609
  return output
419
610
  .map((line, index) => {
420
611
  const safe = truncate(dashboardText(line), width);
421
612
  if (!options.color) return safe;
613
+ if (modern)
614
+ return colorSessionLine(
615
+ safe,
616
+ index === 0 ? "header" : index === 1 ? "navigation" : index >= height - footer.length ? "footer" : "body",
617
+ );
422
618
  const section = [
423
619
  "NOW",
424
620
  "WORK",
@@ -58,6 +58,12 @@ export async function dashboardSessionRequest(
58
58
  });
59
59
  }
60
60
 
61
+ export type DashboardAcknowledgment = {
62
+ action: string;
63
+ state: "pending" | "applied" | "refused" | "unconfirmed";
64
+ effect: string;
65
+ };
66
+
61
67
  /** Controls use only a connected owner; last observations remain explicitly disconnected evidence. */
62
68
  export function createDashboardConnection(
63
69
  request?: (action: DashboardSessionAction) => Promise<DashboardSessionSnapshot>,
@@ -67,7 +73,7 @@ export function createDashboardConnection(
67
73
  lastObserved?: DashboardSessionSnapshot;
68
74
  pending: boolean;
69
75
  error?: string;
70
- acknowledgment?: { action: string; state: "pending" | "applied" | "refused" | "unconfirmed"; effect: string };
76
+ acknowledgment?: DashboardAcknowledgment;
71
77
  } = { pending: false };
72
78
  let generation = 0,
73
79
  poll = 0,
@@ -11,6 +11,8 @@ export interface EcosystemVersionRow {
11
11
  state: "current" | "reload-required" | "not-reported" | "unavailable" | "multiple";
12
12
  commands: string[];
13
13
  note?: string;
14
+ /** Pi reports the Bookie command from this installed package in the current session. */
15
+ commandAvailable?: boolean;
14
16
  }
15
17
  export interface EcosystemVersions {
16
18
  rows: EcosystemVersionRow[];