pi-daddy 0.56.3 → 0.58.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 +13 -0
  2. package/README.md +15 -1
  3. package/dist/governance/approval-prompt.d.ts +3 -1
  4. package/dist/governance/approval-prompt.d.ts.map +1 -1
  5. package/dist/governance/approval-prompt.js +7 -3
  6. package/dist/governance/approval-prompt.js.map +1 -1
  7. package/dist/governance/permission-question.d.ts.map +1 -1
  8. package/dist/governance/permission-question.js +15 -5
  9. package/dist/governance/permission-question.js.map +1 -1
  10. package/dist/kernel/child-tools.d.ts +17 -0
  11. package/dist/kernel/child-tools.d.ts.map +1 -0
  12. package/dist/kernel/child-tools.js +46 -0
  13. package/dist/kernel/child-tools.js.map +1 -0
  14. package/dist/kernel/dashboard-observation.d.ts +40 -0
  15. package/dist/kernel/dashboard-observation.d.ts.map +1 -1
  16. package/dist/kernel/dashboard-observation.js +42 -3
  17. package/dist/kernel/dashboard-observation.js.map +1 -1
  18. package/dist/kernel/definitions.d.ts +2 -0
  19. package/dist/kernel/definitions.d.ts.map +1 -1
  20. package/dist/kernel/definitions.js.map +1 -1
  21. package/dist/kernel/delegate-types.d.ts +2 -0
  22. package/dist/kernel/delegate-types.d.ts.map +1 -1
  23. package/dist/kernel/delegate-types.js.map +1 -1
  24. package/dist/kernel/delegate.d.ts.map +1 -1
  25. package/dist/kernel/delegate.js +12 -1
  26. package/dist/kernel/delegate.js.map +1 -1
  27. package/dist/kernel/principal-binding.d.ts.map +1 -1
  28. package/dist/kernel/principal-binding.js +11 -0
  29. package/dist/kernel/principal-binding.js.map +1 -1
  30. package/dist/kernel/selected-definitions.d.ts.map +1 -1
  31. package/dist/kernel/selected-definitions.js +10 -1
  32. package/dist/kernel/selected-definitions.js.map +1 -1
  33. package/dist/kernel/selected-resources.d.ts +21 -0
  34. package/dist/kernel/selected-resources.d.ts.map +1 -0
  35. package/dist/kernel/selected-resources.js +10 -0
  36. package/dist/kernel/selected-resources.js.map +1 -0
  37. package/dist/kernel/spawn.d.ts +2 -0
  38. package/dist/kernel/spawn.d.ts.map +1 -1
  39. package/dist/kernel/spawn.js +3 -1
  40. package/dist/kernel/spawn.js.map +1 -1
  41. package/dist/products/dashboard-cli.d.ts.map +1 -1
  42. package/dist/products/dashboard-cli.js +1 -1
  43. package/dist/products/dashboard-cli.js.map +1 -1
  44. package/dist/products/dashboard-components.d.ts.map +1 -1
  45. package/dist/products/dashboard-components.js +74 -9
  46. package/dist/products/dashboard-components.js.map +1 -1
  47. package/dist/products/dashboard-inventory-view.d.ts +9 -0
  48. package/dist/products/dashboard-inventory-view.d.ts.map +1 -0
  49. package/dist/products/dashboard-inventory-view.js +44 -0
  50. package/dist/products/dashboard-inventory-view.js.map +1 -0
  51. package/dist/products/dashboard-layout.js +4 -3
  52. package/dist/products/dashboard-layout.js.map +1 -1
  53. package/dist/products/dashboard-panels.d.ts.map +1 -1
  54. package/dist/products/dashboard-panels.js +7 -3
  55. package/dist/products/dashboard-panels.js.map +1 -1
  56. package/dist/products/dashboard-screen.d.ts +2 -0
  57. package/dist/products/dashboard-screen.d.ts.map +1 -1
  58. package/dist/products/dashboard-screen.js +10 -5
  59. package/dist/products/dashboard-screen.js.map +1 -1
  60. package/dist/products/dashboard-session-client.d.ts +4 -2
  61. package/dist/products/dashboard-session-client.d.ts.map +1 -1
  62. package/dist/products/dashboard-session-client.js +24 -7
  63. package/dist/products/dashboard-session-client.js.map +1 -1
  64. package/dist/products/dashboard-settings.d.ts +2 -1
  65. package/dist/products/dashboard-settings.d.ts.map +1 -1
  66. package/dist/products/dashboard-settings.js +10 -1
  67. package/dist/products/dashboard-settings.js.map +1 -1
  68. package/extensions/approvals.ts +52 -38
  69. package/extensions/chain-approval-facts.ts +20 -0
  70. package/extensions/dashboard-session-server.ts +4 -0
  71. package/extensions/dashboard-source-refresh.ts +95 -0
  72. package/extensions/dashboard-sources.ts +42 -4
  73. package/extensions/definition-describe.ts +1 -0
  74. package/extensions/delegate-chain.ts +35 -21
  75. package/extensions/grants.ts +2 -0
  76. package/extensions/runtime-snapshot.ts +1 -0
  77. package/extensions/session.ts +4 -0
  78. package/package.json +2 -2
  79. package/src/governance/approval-prompt.ts +10 -4
  80. package/src/governance/permission-question.ts +16 -5
  81. package/src/kernel/child-tools.ts +62 -0
  82. package/src/kernel/dashboard-observation.ts +86 -4
  83. package/src/kernel/definitions.ts +2 -0
  84. package/src/kernel/delegate-types.ts +2 -0
  85. package/src/kernel/delegate.ts +12 -1
  86. package/src/kernel/principal-binding.ts +11 -0
  87. package/src/kernel/selected-definitions.ts +11 -1
  88. package/src/kernel/selected-resources.ts +20 -0
  89. package/src/kernel/spawn.ts +4 -1
  90. package/src/products/dashboard-cli.ts +1 -0
  91. package/src/products/dashboard-components.ts +78 -10
  92. package/src/products/dashboard-inventory-view.ts +44 -0
  93. package/src/products/dashboard-layout.ts +6 -4
  94. package/src/products/dashboard-panels.ts +9 -3
  95. package/src/products/dashboard-screen.ts +12 -4
  96. package/src/products/dashboard-session-client.ts +31 -11
  97. package/src/products/dashboard-settings.ts +11 -0
@@ -9,12 +9,15 @@ import { validChoiceId } from "../kernel/dashboard-choice.ts";
9
9
  import { isBookieChoice } from "../kernel/dashboard-observation.ts";
10
10
  import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
11
11
  import { safeDashboardSummary } from "./activity-summary.ts";
12
+ import { inventoryPresentation, observationAge } from "./dashboard-inventory-view.ts";
12
13
 
13
14
  const BOOKIE_LIMIT_MESSAGE = "Only a bounded selection of saved open choices could be displayed.";
14
15
 
15
16
  type KnownSource = "bookie" | "scout-local" | "scout-worker";
16
17
 
17
18
  export function isComponentObservation(source: DashboardSourceSnapshot, item: DashboardContribution): boolean {
19
+ if (["bookie-memory", "scout-local", "scout-worker"].includes(source.producer) && item.id === "availability")
20
+ return item.kind === "status";
18
21
  if (source.producer === "bookie-memory") return item.id === "project-memory" && item.kind === "work";
19
22
  return (
20
23
  (source.producer === "scout-local" || source.producer === "scout-worker") &&
@@ -71,6 +74,15 @@ function scoutDescription(worker: boolean, item: DashboardContribution): [string
71
74
  }
72
75
  }
73
76
 
77
+ function memoryDescription(item: DashboardContribution | undefined, partial: boolean): [string, string] {
78
+ if (item?.state === "observed")
79
+ return ["Ready in this folder", "Bookie can save and recall routine notes for this workspace."];
80
+ return [
81
+ item?.state === "unavailable" ? "Memory unavailable" : partial ? "Notes partially checked" : "Cannot check notes",
82
+ item?.details?.[0] ?? "The current project notes could not be checked. Previous history is not confirmed empty.",
83
+ ];
84
+ }
85
+
74
86
  /** Choices are current project observations; a saved question never creates a live input request. */
75
87
  export function bookieOpenChoices(options: DashboardScreenOptions): DashboardItem[] {
76
88
  const source = options.session?.observation?.sources.find((s) => s.producer === "bookie-memory");
@@ -125,8 +137,7 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
125
137
  const workSource = sources?.find((s) => s.producer === producer);
126
138
  const memory = bookie
127
139
  ? sources?.find(
128
- (s) =>
129
- s.producer === "bookie-memory" && s.items.some((i) => isComponentObservation(s, i) && i.state === "observed"),
140
+ (s) => s.producer === "bookie-memory" && s.items.some((i) => isComponentObservation(s, i) && i.kind === "work"),
130
141
  )
131
142
  : undefined;
132
143
  const source =
@@ -134,28 +145,73 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
134
145
 
135
146
  const pkg = options.session?.versions?.rows.find((r) => r.id === (bookie ? "bookie-pi-skills" : "pi-scout-research"));
136
147
  if (!source && !(pkg?.source || pkg?.loadedVersion || pkg?.installedVersion || pkg?.state === "multiple")) return;
137
- const item = source?.items.find((i) => isComponentObservation(source, i));
148
+ const item = source?.items.find((i) => isComponentObservation(source, i) && i.kind === "work");
149
+ const availability = source?.items.find((i) => i.id === "availability" && i.kind === "status");
138
150
  let state = "observed",
139
151
  status: string,
140
152
  explanation: string;
141
- if (options.connected === false || (source && !current(source, options))) {
153
+ if (
154
+ options.connected === false ||
155
+ source?.refresh?.state === "failed" ||
156
+ (source &&
157
+ !current(source, options) &&
158
+ !(source.producer === "bookie-memory" && options.session?.auto.enabled === false))
159
+ ) {
142
160
  state = "last-observed";
143
- status = "Live status unknown";
161
+ status =
162
+ options.connected === false
163
+ ? "Disconnected"
164
+ : source?.availability === "closed"
165
+ ? "Status connection ended"
166
+ : source?.refresh?.state === "checking"
167
+ ? "Checking status"
168
+ : source?.refresh?.state === "failed"
169
+ ? "Status check unavailable"
170
+ : "Status update overdue";
144
171
  const lastReport =
145
172
  source?.producer === "bookie-memory"
146
- ? "Ready in this folder"
173
+ ? memoryDescription(item, source.inventory?.state === "available")[0]
147
174
  : item
148
175
  ? scoutDescription(worker, item)[0]
149
176
  : bookie && source?.items.some((i) => i.kind === "goal" && i.id === "scope")
150
177
  ? "Project connected"
151
178
  : undefined;
152
- explanation = (lastReport ? `Last report: ${lastReport}. ` : "") + "Check the main Pi chat for current status.";
179
+ explanation =
180
+ (lastReport ? `Last report: ${lastReport}. ` : "") +
181
+ (options.connected === false
182
+ ? "Reconnect to Pi to check current availability."
183
+ : source?.availability === "closed"
184
+ ? "The producer's status connection is no longer active."
185
+ : source?.refresh?.state === "checking"
186
+ ? "A fresh status check is in progress."
187
+ : source?.refresh?.state === "failed"
188
+ ? "The producer could not return a current report; a later refresh can try again."
189
+ : "The previous report expired. Current availability has not yet been rechecked.");
190
+ } else if (
191
+ bookie &&
192
+ options.session &&
193
+ !options.session.auto.enabled &&
194
+ (source?.producer === "bookie-memory" || pkg?.commandAvailable || pkg?.loadedVersion) &&
195
+ !(source?.producer === "bookie" && current(source, options) && source.items.length)
196
+ ) {
197
+ status = "Automatic memory paused · Auto OFF";
198
+ const origin =
199
+ options.session.auto.source === "session"
200
+ ? "Auto was turned off for this session."
201
+ : options.session.auto.source === "environment"
202
+ ? "Pi started with Auto off."
203
+ : "Auto starts off by default.";
204
+ explanation = `${origin} Turn Auto on in Settings for automatic notes in this folder, or use /bookie-context to select memory manually. A session toggle does not change the startup setting.`;
153
205
  } else if (source?.producer === "bookie-memory") {
154
- status = "Ready in this folder";
155
- explanation = "Bookie can save and recall routine notes for this workspace.";
206
+ state = item?.state ?? "unknown";
207
+ [status, explanation] = memoryDescription(item, source.inventory?.state === "available");
156
208
  } else if (bookie && source?.items.length) {
157
209
  status = "Project connected";
158
210
  explanation = "Bookie is sharing the selected project’s work with Pi.";
211
+ } else if (availability) {
212
+ state = availability.state;
213
+ status = availability.label;
214
+ explanation = availability.details?.[0] ?? "Current availability reported by Scout.";
159
215
  } else if (item) {
160
216
  state = item.state;
161
217
  [status, explanation] = scoutDescription(worker, item);
@@ -177,17 +233,29 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
177
233
  const isMemory = source?.producer === "bookie-memory";
178
234
  const limited =
179
235
  isMemory && state === "observed" && options.session?.auto.enabled && sourceDetails.includes(BOOKIE_LIMIT_MESSAGE);
180
- const briefDetails = limited
236
+ const explanationLines = limited
181
237
  ? [explanation, "Bookie could only show part of this project’s open choices."]
182
238
  : [explanation];
239
+ const canShowInventory = source && current(source, options) && (!bookie || options.session?.auto.enabled);
240
+ const showInventory = canShowInventory && source.refresh?.state !== "failed";
241
+ const inventory = inventoryPresentation(showInventory ? source.inventory : undefined);
242
+ const age = observationAge(source, options.now?.getTime() ?? Date.now());
243
+ const briefDetails = [
244
+ ...explanationLines,
245
+ ...(source?.inventory || state === "last-observed" ? [age] : []),
246
+ ...inventory.content,
247
+ ];
183
248
  return {
184
249
  key: `component:${producer}`,
185
250
  label: `${title} · ${status}`,
186
251
  status: state,
187
252
  elapsed: "",
188
253
  briefDetails,
254
+ ...(source?.inventory && showInventory ? { browse: true, previewLines: inventory.preview } : {}),
189
255
  details: [
190
256
  ...briefDetails,
257
+ age,
258
+ ...inventory.references,
191
259
  ...(source
192
260
  ? [`Source: ${source.producer} · ${source.producerVersion}`, `Last update: ${source.observedAt}`]
193
261
  : []),
@@ -0,0 +1,44 @@
1
+ /** Human content previews from an authorized, current producer snapshot; rendering performs no reads. */
2
+ import type { DashboardInventory, DashboardSourceSnapshot } from "../kernel/dashboard-observation.ts";
3
+ import { dashboardText } from "./dashboard-screen.ts";
4
+ import { truncate } from "./dashboard-render.ts";
5
+
6
+ const clean = (text: string) => dashboardText(text).replace(/\s+/g, " ").trim();
7
+
8
+ export function inventoryPresentation(inventory: DashboardInventory | undefined) {
9
+ if (!inventory) return { preview: [] as string[], content: [] as string[], references: [] as string[] };
10
+ const entries = inventory.state === "available" ? inventory.entries : [];
11
+ const summary = clean(inventory.summary);
12
+ const coverage = inventory.limited
13
+ ? inventory.count === undefined
14
+ ? "Showing a bounded selection; this is not the full inventory."
15
+ : `Showing ${entries.length} of ${inventory.count} saved items.`
16
+ : undefined;
17
+ return {
18
+ preview: [truncate(summary, 110), ...entries.slice(0, 2).map((entry) => `• ${truncate(clean(entry.title), 90)}`)],
19
+ content: [
20
+ `Scope: ${clean(inventory.scope)}`,
21
+ summary,
22
+ ...(coverage ? [coverage] : []),
23
+ ...entries.flatMap((entry, index) => [
24
+ "",
25
+ `${index + 1}. ${clean(entry.title)}`,
26
+ ` ${clean(entry.summary)}`,
27
+ ...(entry.details ?? []).map((line) => ` ${clean(line)}`),
28
+ ]),
29
+ ],
30
+ references: entries.flatMap((entry) =>
31
+ entry.reference ? [`${clean(entry.title)}: ${clean(entry.reference)}`] : [],
32
+ ),
33
+ };
34
+ }
35
+
36
+ export function observationAge(source: DashboardSourceSnapshot | undefined, now: number): string {
37
+ if (!source) return "No status report received yet.";
38
+ const age = now - Date.parse(source.observedAt);
39
+ if (!Number.isFinite(age) || age < 0) return "The last update time could not be verified.";
40
+ if (age < 10_000) return "Updated just now.";
41
+ if (age < 60_000) return `Updated ${Math.floor(age / 1000)}s ago.`;
42
+ if (age < 3_600_000) return `Updated ${Math.floor(age / 60_000)}m ago.`;
43
+ return `Updated ${Math.floor(age / 3_600_000)}h ago.`;
44
+ }
@@ -50,17 +50,19 @@ function paintCell(cell: string): string {
50
50
  );
51
51
  }
52
52
  if (/^ /.test(text)) {
53
- const status =
54
- /( · )(Failed|Blocked|Run failed|Last attempt failed|Unavailable|Awaiting decision|Needs you|Live status unknown|Running|Finished|Saved|Available)(?= |$| ·)/;
53
+ const status = new RegExp(
54
+ "( · )(Failed|Blocked|Run failed|Last attempt failed|Unavailable|Awaiting decision|Needs you|" +
55
+ "Disconnected|Checking status|Status update overdue|Status check unavailable|Running|Finished|Saved|Available|Ready[^·]*)(?= |$| ·)",
56
+ );
55
57
  return (
56
58
  text.replace(status, (_, separator, state) => {
57
59
  const color = /^(Failed|Blocked|Last attempt failed|Run failed)$/.test(state)
58
60
  ? "90"
59
61
  : state === "Unavailable"
60
62
  ? "1;31"
61
- : /Awaiting|Needs you|unknown/.test(state)
63
+ : /Awaiting|Needs you|Disconnected|overdue|unavailable/.test(state)
62
64
  ? "33"
63
- : state === "Running"
65
+ : /Running|Checking/.test(state)
64
66
  ? "36"
65
67
  : "32";
66
68
  return separator + sgr(state, color);
@@ -367,13 +367,15 @@ const workGroups = [
367
367
  "Other tasks",
368
368
  "Recently finished",
369
369
  "Last known",
370
- "Tools",
370
+ "Memory",
371
+ "Research",
371
372
  ];
372
373
  export function needsUserInput(item: DashboardItem): boolean {
373
374
  return !item.reviewSummary && ["needs-you", "approval-wait"].includes(item.status);
374
375
  }
375
376
  function workGroup(item: DashboardItem): string {
376
- if (item.key.startsWith("component:")) return needsUserInput(item) ? "Needs your decision" : "Tools";
377
+ if (item.key.startsWith("component:"))
378
+ return needsUserInput(item) ? "Needs your decision" : item.key === "component:bookie" ? "Memory" : "Research";
377
379
  if (item.key.startsWith("activity:")) return "Latest activity";
378
380
  if (["last-observed", "historical"].includes(item.status)) return "Last known";
379
381
  if (needsUserInput(item)) {
@@ -449,7 +451,11 @@ export function sessionPanelLines(options: DashboardScreenOptions, items: Dashbo
449
451
  if (roomy && (rows.length || lines.length)) rows.push("");
450
452
  const count = destination === "now" ? "" : ` · ${end - start}`;
451
453
  rows.push(sectionHeading(group + count, left ?? width));
452
- for (const item of items.slice(start, end)) rows.push(rowText(item, destination, item.key === screen.selectedKey));
454
+ for (const item of items.slice(start, end)) {
455
+ rows.push(rowText(item, destination, item.key === screen.selectedKey));
456
+ for (const line of (item.previewLines ?? []).slice(0, options.height >= 28 ? 3 : 2))
457
+ rows.push(` ${clean(line)}`);
458
+ }
453
459
  start = end;
454
460
  }
455
461
  lines.push(...rows);
@@ -29,6 +29,8 @@ export interface DashboardItem {
29
29
  updatedAt?: string;
30
30
  details: string[];
31
31
  briefDetails?: string[];
32
+ previewLines?: string[];
33
+ browse?: boolean;
32
34
  reviewSummary?: boolean;
33
35
  relatedReviewKey?: string;
34
36
  observation?: string;
@@ -249,7 +251,8 @@ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | und
249
251
  if (view === "choice") return choiceKeys(screen);
250
252
  if (view === "main") {
251
253
  if (selected?.choice) return ["↑↓ select · Enter answer", "d details · q close"];
252
- const keys = selected ? (brief ? "↑↓ · Enter details" : "↑↓ select · Enter details") : "1–6 views";
254
+ const action = selected?.browse ? "browse" : "details";
255
+ const keys = selected ? (brief ? `↑↓ · Enter ${action}` : `↑↓ select · Enter ${action}`) : "1–6 views";
253
256
  return [keys + (brief ? " · ?" : " · ? help"), "r recap · q close"];
254
257
  }
255
258
  if (view === "versions" || view === "settings")
@@ -461,6 +464,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
461
464
  session?.auto.enabled,
462
465
  screen.settingKey ?? "auto",
463
466
  width,
467
+ session?.auto.source,
464
468
  ),
465
469
  );
466
470
  if (session?.observation)
@@ -521,9 +525,13 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
521
525
  sectionHeading(
522
526
  screen.sourceDetails
523
527
  ? "SOURCE RECORD"
524
- : (selected.briefDetails && selected.status === "approval-wait") || selected.approval
525
- ? "NEXT ACTION"
526
- : "DETAILS",
528
+ : selected.browse
529
+ ? selected.key === "component:bookie"
530
+ ? "SAVED NOTES"
531
+ : "SAVED RESEARCH"
532
+ : (selected.briefDetails && selected.status === "approval-wait") || selected.approval
533
+ ? "NEXT ACTION"
534
+ : "DETAILS",
527
535
  width,
528
536
  ),
529
537
  ]
@@ -4,7 +4,7 @@ import {
4
4
  type DashboardChoiceDetail,
5
5
  type DashboardChoiceTarget,
6
6
  } from "../kernel/dashboard-choice.ts";
7
- import type { DashboardOwnerObservation } from "../kernel/dashboard-observation.ts";
7
+ import { DASHBOARD_RESPONSE_BYTES, type DashboardOwnerObservation } from "../kernel/dashboard-observation.ts";
8
8
  import type { DashboardSettingsSnapshot, JevEditAction } from "./dashboard-settings.ts";
9
9
  import type { EcosystemVersions } from "./ecosystem-versions.ts";
10
10
  import { createConnection } from "node:net";
@@ -25,6 +25,7 @@ interface DashboardSessionReply extends DashboardSessionSnapshot {
25
25
  choiceDetail?: DashboardChoiceDetail;
26
26
  choiceSaved?: true;
27
27
  choiceRefreshRequested?: true;
28
+ sourceRefreshRequested?: true;
28
29
  }
29
30
  class ChoiceDeclined extends Error {
30
31
  readonly stale: boolean;
@@ -39,7 +40,7 @@ class ChoiceDeclined extends Error {
39
40
  }
40
41
  export type DashboardSessionAction = (
41
42
  | DashboardChoiceAction
42
- | { action: "get"; refreshChoices?: true }
43
+ | { action: "get"; refreshChoices?: true; refreshSources?: true }
43
44
  | { action: "set"; edits: string }
44
45
  | { action: "set-auto"; enabled: boolean }
45
46
  | { action: "set-jev"; enabled: boolean }
@@ -63,7 +64,8 @@ export async function dashboardSessionRequest(
63
64
  socket.once("error", reject);
64
65
  socket.on("data", (chunk) => {
65
66
  output += chunk;
66
- if (output.length > 64 * 1024) socket.destroy(new Error("dashboard session response too large"));
67
+ if (Buffer.byteLength(output) > DASHBOARD_RESPONSE_BYTES)
68
+ socket.destroy(new Error("dashboard session response too large"));
67
69
  });
68
70
  socket.once("end", () => {
69
71
  try {
@@ -127,6 +129,18 @@ export function createDashboardConnection(
127
129
  let choiceInterest = 0,
128
130
  consumedInterest = 0;
129
131
  const retired = new Set<string>();
132
+ const disconnect = () => {
133
+ state.snapshot = undefined;
134
+ const previous = state.lastObserved;
135
+ if (previous?.observation)
136
+ state.lastObserved = {
137
+ ...previous,
138
+ observation: {
139
+ ...previous.observation,
140
+ sources: previous.observation.sources.map(({ inventory: _inventory, ...source }) => source),
141
+ },
142
+ };
143
+ };
130
144
  const accept = (snapshot: DashboardSessionSnapshot) => {
131
145
  const previous = state.lastObserved?.observation,
132
146
  next = snapshot.observation;
@@ -187,24 +201,30 @@ export function createDashboardConnection(
187
201
  requestChoiceRefresh() {
188
202
  choiceInterest++;
189
203
  },
190
- async refresh(visibleChoices?: "picker" | "list") {
204
+ async refresh(visibleChoices?: "picker" | "list", visibleSources = false) {
191
205
  if (!request || state.pending) return;
192
206
  const observed = generation,
193
207
  order = ++poll;
194
208
  try {
195
209
  const interest = choiceInterest;
196
210
  const wanted = visibleChoices === "picker" || (visibleChoices === "list" && interest !== consumedInterest);
197
- const { choiceRefreshRequested, ...snapshot } = await request(
198
- wanted ? { action: "get", refreshChoices: true } : { action: "get" },
199
- );
211
+ const {
212
+ choiceRefreshRequested,
213
+ sourceRefreshRequested: _sourceRefreshRequested,
214
+ ...snapshot
215
+ } = await request({
216
+ action: "get",
217
+ ...(wanted ? { refreshChoices: true } : {}),
218
+ ...(visibleSources ? { refreshSources: true } : {}),
219
+ });
200
220
  if (choiceRefreshRequested) consumedInterest = Math.max(consumedInterest, interest);
201
221
  if (generation === observed && order === poll && !accept(snapshot)) {
202
- state.snapshot = undefined;
222
+ disconnect();
203
223
  state.error = "Owner observation is stale or unavailable; controls disabled until a fresh reply.";
204
224
  }
205
225
  } catch (error) {
206
226
  if (generation === observed && order === poll) {
207
- state.snapshot = undefined;
227
+ disconnect();
208
228
  state.error = `Controls unavailable; showing last observation: ${error instanceof Error ? error.message : String(error)}`;
209
229
  }
210
230
  }
@@ -264,12 +284,12 @@ export function createDashboardConnection(
264
284
  return true;
265
285
  } catch (error) {
266
286
  if (action.action === "answer-choice" && error instanceof ChoiceDeclined) {
267
- if (error.stale) state.snapshot = undefined;
287
+ if (error.stale) disconnect();
268
288
  state.acknowledgment.state = "refused";
269
289
  state.error = error.message;
270
290
  return false;
271
291
  }
272
- state.snapshot = undefined;
292
+ disconnect();
273
293
  state.acknowledgment.state = "unconfirmed";
274
294
  state.error =
275
295
  action.action === "answer-choice"
@@ -1,3 +1,4 @@
1
+ import type { AutoModeSource } from "../kernel/auto-mode.ts";
1
2
  import { sectionHeading } from "./dashboard-layout.ts";
2
3
 
3
4
  /** Settings are owner observations; rendering never grants consent or changes execution. */
@@ -63,6 +64,7 @@ export function dashboardSettingsLines(
63
64
  auto: boolean | undefined,
64
65
  selected: DashboardSettingKey,
65
66
  width: number,
67
+ autoSource?: AutoModeSource,
66
68
  ): string[] {
67
69
  if (!settings) return ["Owner settings unavailable. Reconnect from /grants dashboard."];
68
70
  const row = (key: DashboardSettingKey, label: string, nested = false) =>
@@ -84,6 +86,15 @@ export function dashboardSettingsLines(
84
86
  return [
85
87
  sectionHeading("PERMISSIONS", width),
86
88
  row("auto", `Permission Auto: ${auto ? "ON" : "OFF"}`),
89
+ ...(autoSource
90
+ ? [
91
+ autoSource === "session"
92
+ ? " Session choice; /new uses the startup setting."
93
+ : autoSource === "environment"
94
+ ? " From the startup environment."
95
+ : " Startup default: OFF.",
96
+ ]
97
+ : []),
87
98
  "",
88
99
  sectionHeading("JEV · optional advice", width),
89
100
  row(