pi-daddy 0.55.0 → 0.56.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.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/dist/kernel/dashboard-choice.d.ts +58 -0
- package/dist/kernel/dashboard-choice.d.ts.map +1 -0
- package/dist/kernel/dashboard-choice.js +34 -0
- package/dist/kernel/dashboard-choice.js.map +1 -0
- package/dist/products/dashboard-choice-picker.d.ts +22 -0
- package/dist/products/dashboard-choice-picker.d.ts.map +1 -0
- package/dist/products/dashboard-choice-picker.js +219 -0
- package/dist/products/dashboard-choice-picker.js.map +1 -0
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +16 -4
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-components.d.ts.map +1 -1
- package/dist/products/dashboard-components.js +21 -1
- package/dist/products/dashboard-components.js.map +1 -1
- package/dist/products/dashboard-display-controls.d.ts +1 -1
- package/dist/products/dashboard-display-controls.d.ts.map +1 -1
- package/dist/products/dashboard-display-controls.js +6 -1
- package/dist/products/dashboard-display-controls.js.map +1 -1
- package/dist/products/dashboard-screen.d.ts +5 -1
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +17 -6
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +18 -5
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +92 -14
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/extensions/dashboard-choice-controls.ts +152 -0
- package/extensions/dashboard-session-server.ts +92 -17
- package/extensions/dashboard-sources.ts +12 -0
- package/extensions/runtime-snapshot.ts +1 -0
- package/extensions/session.ts +1 -0
- package/package.json +1 -1
- package/src/kernel/dashboard-choice.ts +73 -0
- package/src/products/dashboard-choice-picker.ts +228 -0
- package/src/products/dashboard-cli.ts +18 -3
- package/src/products/dashboard-components.ts +21 -1
- package/src/products/dashboard-display-controls.ts +7 -1
- package/src/products/dashboard-screen.ts +19 -6
- package/src/products/dashboard-session-client.ts +129 -19
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/** A Bookie question is inspected on Enter. The terminal never infers an option or writes during a redraw. */
|
|
2
|
+
import type { DashboardChoiceDetail, DashboardChoiceTarget } from "../kernel/dashboard-choice.ts";
|
|
3
|
+
import type { DashboardScreenState } from "./dashboard-screen.ts";
|
|
4
|
+
import type { createDashboardConnection } from "./dashboard-session-client.ts";
|
|
5
|
+
|
|
6
|
+
export interface ChoicePicker {
|
|
7
|
+
target: DashboardChoiceTarget;
|
|
8
|
+
phase: "loading" | "unavailable" | "options" | "custom" | "confirm" | "refused" | "saving" | "saved";
|
|
9
|
+
index: number;
|
|
10
|
+
draft: string;
|
|
11
|
+
detail?: DashboardChoiceDetail;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function current(screen: DashboardScreenState, picker: ChoicePicker) {
|
|
16
|
+
const choice = screen.items.find((item) => item.key === screen.selectedKey)?.choice;
|
|
17
|
+
return (
|
|
18
|
+
choice?.choiceId === picker.target.choiceId &&
|
|
19
|
+
choice.sourceGeneration === picker.target.sourceGeneration &&
|
|
20
|
+
choice.expectedOwner.sessionId === picker.target.expectedOwner.sessionId &&
|
|
21
|
+
choice.expectedOwner.cwd === picker.target.expectedOwner.cwd &&
|
|
22
|
+
choice.expectedOwner.generation === picker.target.expectedOwner.generation
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function openChoice(screen: DashboardScreenState): boolean {
|
|
27
|
+
const target = screen.items.find((item) => item.key === screen.selectedKey)?.choice;
|
|
28
|
+
if (!target) return false;
|
|
29
|
+
screen.picker = { target, phase: "loading", index: 0, draft: "" };
|
|
30
|
+
screen.view = "choice";
|
|
31
|
+
screen.offset = 0;
|
|
32
|
+
screen.manualScroll = false;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function close(screen: DashboardScreenState) {
|
|
37
|
+
screen.picker = undefined;
|
|
38
|
+
screen.view = "main";
|
|
39
|
+
screen.offset = 0;
|
|
40
|
+
screen.manualScroll = false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function choiceKey(
|
|
44
|
+
screen: DashboardScreenState,
|
|
45
|
+
key: string,
|
|
46
|
+
text?: string,
|
|
47
|
+
): "answer-choice" | "quit" | undefined {
|
|
48
|
+
const picker = screen.picker;
|
|
49
|
+
if (!picker || key === "ctrl-c" || (key === "q" && picker.phase !== "custom")) return "quit";
|
|
50
|
+
if (key === "pageup" || key === "pagedown") {
|
|
51
|
+
screen.manualScroll = true;
|
|
52
|
+
screen.offset = Math.max(0, screen.offset + (key === "pageup" ? -8 : 8));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (key === "escape") {
|
|
56
|
+
if (picker.phase !== "saving") close(screen);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const detail = picker.detail;
|
|
60
|
+
if (!detail || !current(screen, picker)) return;
|
|
61
|
+
if (picker.phase === "custom") {
|
|
62
|
+
if (key === "return") {
|
|
63
|
+
if (!picker.draft.trim()) {
|
|
64
|
+
picker.error = "Write an answer first.";
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
picker.phase = "confirm";
|
|
68
|
+
screen.offset = 0;
|
|
69
|
+
} else if (key === "backspace") {
|
|
70
|
+
picker.draft = [...picker.draft].slice(0, -1).join("");
|
|
71
|
+
} else if (text && !/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u.test(text)) {
|
|
72
|
+
if ((picker.draft + text).length > 240) {
|
|
73
|
+
picker.error = "Use up to 240 characters.";
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
picker.draft += text;
|
|
77
|
+
}
|
|
78
|
+
picker.error = undefined;
|
|
79
|
+
screen.manualScroll = false;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (picker.phase === "confirm" || picker.phase === "refused") {
|
|
83
|
+
if (picker.phase === "refused" && key === "r") {
|
|
84
|
+
picker.phase = "confirm";
|
|
85
|
+
picker.error = undefined;
|
|
86
|
+
screen.offset = 0;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (picker.phase === "confirm" && key === "return") {
|
|
90
|
+
picker.phase = "saving";
|
|
91
|
+
picker.error = undefined;
|
|
92
|
+
screen.offset = 0;
|
|
93
|
+
return "answer-choice";
|
|
94
|
+
}
|
|
95
|
+
if (key === "backspace" || key === "e") {
|
|
96
|
+
picker.phase = picker.index === detail.options.length ? "custom" : "options";
|
|
97
|
+
picker.error = undefined;
|
|
98
|
+
screen.offset = 0;
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (picker.phase !== "options") return;
|
|
103
|
+
const last = detail.options.length + 1;
|
|
104
|
+
if (["up", "down", "k", "j"].includes(key)) {
|
|
105
|
+
picker.index = Math.max(0, Math.min(last, picker.index + (key === "up" || key === "k" ? -1 : 1)));
|
|
106
|
+
screen.manualScroll = false;
|
|
107
|
+
} else if (key === "return") {
|
|
108
|
+
if (picker.index === last) close(screen);
|
|
109
|
+
else picker.phase = picker.index === last - 1 ? "custom" : "confirm";
|
|
110
|
+
screen.offset = 0;
|
|
111
|
+
screen.manualScroll = false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function choiceKeys(screen: DashboardScreenState): string[] {
|
|
116
|
+
switch (screen.picker?.phase) {
|
|
117
|
+
case "options":
|
|
118
|
+
return ["↑↓ select · Enter choose", "Esc decide later"];
|
|
119
|
+
case "custom":
|
|
120
|
+
return ["Enter review · Esc cancel"];
|
|
121
|
+
case "confirm":
|
|
122
|
+
return ["Enter save to Bookie", "e edit · Esc cancel"];
|
|
123
|
+
case "refused":
|
|
124
|
+
return ["r review again · e edit", "Esc cancel"];
|
|
125
|
+
case "saving":
|
|
126
|
+
return ["Waiting for Bookie…"];
|
|
127
|
+
default:
|
|
128
|
+
return ["Esc back"];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Erase inspected note text and the draft when their source is no longer current. Keep an in-flight save's outcome visible. */
|
|
133
|
+
export function choiceBody(screen: DashboardScreenState): string[] {
|
|
134
|
+
const picker = screen.picker;
|
|
135
|
+
if (!picker) return [];
|
|
136
|
+
if (!current(screen, picker)) {
|
|
137
|
+
picker.detail = undefined;
|
|
138
|
+
picker.draft = "";
|
|
139
|
+
if (picker.phase !== "saving" && picker.phase !== "saved") picker.phase = "unavailable";
|
|
140
|
+
}
|
|
141
|
+
if (picker.phase === "saved") return ["Answer saved in Bookie."];
|
|
142
|
+
if (picker.phase === "saving") return ["Saving your answer in Bookie…"];
|
|
143
|
+
if (picker.phase === "loading") return ["Reading this choice from Bookie…"];
|
|
144
|
+
if (picker.phase === "unavailable" || !picker.detail)
|
|
145
|
+
return [
|
|
146
|
+
...(picker.error ? [picker.error] : []),
|
|
147
|
+
"This choice is unavailable. Return to the list to check its current status.",
|
|
148
|
+
];
|
|
149
|
+
const detail = picker.detail;
|
|
150
|
+
const issues = picker.error ? [picker.error, ""] : [];
|
|
151
|
+
if (picker.phase === "custom") return [...issues, detail.label, "", "Write your own answer", picker.draft + "▏"];
|
|
152
|
+
if (picker.phase === "confirm" || picker.phase === "refused")
|
|
153
|
+
return [
|
|
154
|
+
...issues,
|
|
155
|
+
detail.label,
|
|
156
|
+
"",
|
|
157
|
+
"Save this answer in Bookie?",
|
|
158
|
+
"",
|
|
159
|
+
detail.options[picker.index] ?? picker.draft.trim(),
|
|
160
|
+
];
|
|
161
|
+
return [
|
|
162
|
+
detail.label,
|
|
163
|
+
"From: " + detail.title,
|
|
164
|
+
"",
|
|
165
|
+
...detail.options.map(
|
|
166
|
+
(option, i) =>
|
|
167
|
+
(i === picker.index ? "> " : " ") +
|
|
168
|
+
option +
|
|
169
|
+
(detail.recommendation?.option === option ? " · Recommended" : ""),
|
|
170
|
+
),
|
|
171
|
+
(picker.index === detail.options.length ? "> " : " ") + "Write my own answer",
|
|
172
|
+
(picker.index === detail.options.length + 1 ? "> " : " ") + "Decide later",
|
|
173
|
+
...(detail.recommendation
|
|
174
|
+
? [
|
|
175
|
+
"",
|
|
176
|
+
"Recommended: " + detail.recommendation.option,
|
|
177
|
+
"Why: " + detail.recommendation.reason,
|
|
178
|
+
"Basis: " + detail.recommendation.evidence,
|
|
179
|
+
]
|
|
180
|
+
: []),
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
type ChoiceConnection = Pick<ReturnType<typeof createDashboardConnection>, "inspectChoice" | "change" | "state">;
|
|
185
|
+
|
|
186
|
+
export async function inspectChoice(screen: DashboardScreenState, connection: ChoiceConnection) {
|
|
187
|
+
const picker = screen.picker;
|
|
188
|
+
if (!picker || picker.phase !== "loading") return;
|
|
189
|
+
try {
|
|
190
|
+
const detail = await connection.inspectChoice(picker.target);
|
|
191
|
+
if (screen.picker !== picker || picker.phase !== "loading" || !current(screen, picker)) return;
|
|
192
|
+
picker.detail = detail;
|
|
193
|
+
picker.phase = "options";
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (screen.picker !== picker || picker.phase !== "loading") return;
|
|
196
|
+
picker.phase = "unavailable";
|
|
197
|
+
picker.error = error instanceof Error ? error.message : "Bookie could not open this choice.";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function saveChoice(screen: DashboardScreenState, connection: ChoiceConnection) {
|
|
202
|
+
const picker = screen.picker;
|
|
203
|
+
if (!picker || picker.phase !== "saving" || !picker.detail || !current(screen, picker)) return;
|
|
204
|
+
const option = picker.detail.options[picker.index];
|
|
205
|
+
const saved = await connection.change({
|
|
206
|
+
action: "answer-choice",
|
|
207
|
+
...picker.target,
|
|
208
|
+
revision: picker.detail.revision,
|
|
209
|
+
answer: option === undefined ? { custom: picker.draft.trim() } : { option },
|
|
210
|
+
});
|
|
211
|
+
if (saved) {
|
|
212
|
+
picker.phase = "saved";
|
|
213
|
+
picker.detail = undefined;
|
|
214
|
+
picker.draft = "";
|
|
215
|
+
} else {
|
|
216
|
+
// A lost acknowledgment can follow a committed write. Reopen the live row before any further submission.
|
|
217
|
+
if (!connection.state.snapshot) {
|
|
218
|
+
picker.detail = undefined;
|
|
219
|
+
picker.draft = "";
|
|
220
|
+
}
|
|
221
|
+
picker.phase = picker.detail ? "refused" : "unavailable";
|
|
222
|
+
picker.error =
|
|
223
|
+
connection.state.error ??
|
|
224
|
+
(connection.state.acknowledgment?.state === "refused"
|
|
225
|
+
? connection.state.acknowledgment.effect
|
|
226
|
+
: "Bookie could not save this answer.");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { inspectChoice, saveChoice } from "./dashboard-choice-picker.ts";
|
|
2
3
|
import type { DashboardAcknowledgment } from "./dashboard-session-client.ts";
|
|
3
4
|
import { dashboardFile, dashboardTimeline, dashboardSelectedDetail } from "./dashboard-file-cache.ts";
|
|
4
5
|
/**
|
|
@@ -152,7 +153,7 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
|
|
|
152
153
|
items: [],
|
|
153
154
|
problem: "INCOMPATIBLE dashboard protocol; relink this package.",
|
|
154
155
|
});
|
|
155
|
-
if (options.screen?.view === "recap")
|
|
156
|
+
if (options.screen?.view === "recap" || options.screen?.view === "choice")
|
|
156
157
|
return renderDashboardScreen({
|
|
157
158
|
...options,
|
|
158
159
|
width: options.width ?? 80,
|
|
@@ -371,7 +372,17 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
371
372
|
let stopped = false,
|
|
372
373
|
drawing = false;
|
|
373
374
|
const draw = async (clear: boolean): Promise<void> => {
|
|
374
|
-
|
|
375
|
+
const editingChoice =
|
|
376
|
+
display.screen.view === "choice" &&
|
|
377
|
+
display.screen.picker &&
|
|
378
|
+
["loading", "options", "custom", "confirm", "refused"].includes(display.screen.picker.phase);
|
|
379
|
+
const showsChoices =
|
|
380
|
+
display.screen.view === "main" &&
|
|
381
|
+
display.state.filter === "everything" &&
|
|
382
|
+
["now", "work"].includes(display.screen.destination ?? "now");
|
|
383
|
+
await connection.refresh(
|
|
384
|
+
interactive && editingChoice ? "picker" : interactive && showsChoices ? "list" : undefined,
|
|
385
|
+
);
|
|
375
386
|
const jev = connection.state.snapshot?.settings?.jev;
|
|
376
387
|
if (notice === JEV_CONSENT_NOTICE && jev && !jev.pending) notice = dashboardJevNotice(jev);
|
|
377
388
|
if (notice === JEV_EDITOR_NOTICE && jev && !jev.pending) notice = "";
|
|
@@ -457,6 +468,7 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
457
468
|
stop();
|
|
458
469
|
return;
|
|
459
470
|
}
|
|
471
|
+
connection.requestChoiceRefresh();
|
|
460
472
|
if (command !== undefined) {
|
|
461
473
|
if (key.name === "escape") command = undefined;
|
|
462
474
|
else if (key.name === "return") {
|
|
@@ -472,10 +484,13 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
472
484
|
let action = display.key(
|
|
473
485
|
key.name === "return"
|
|
474
486
|
? "return"
|
|
475
|
-
: ["up", "down", "pageup", "pagedown", "escape", "tab"].includes(key.name || "")
|
|
487
|
+
: ["up", "down", "pageup", "pagedown", "escape", "tab", "backspace"].includes(key.name || "")
|
|
476
488
|
? key.name!
|
|
477
489
|
: text || "",
|
|
490
|
+
!key.ctrl && !key.meta ? text : undefined,
|
|
478
491
|
);
|
|
492
|
+
if (action === "inspect-choice") void inspectChoice(display.screen, connection).then(redraw);
|
|
493
|
+
if (action === "answer-choice") void saveChoice(display.screen, connection).then(redraw);
|
|
479
494
|
if (action === "quit") {
|
|
480
495
|
stop();
|
|
481
496
|
return;
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
DashboardSourceSnapshot,
|
|
6
6
|
} from "../kernel/dashboard-observation.ts";
|
|
7
7
|
import type { DashboardItem, DashboardScreenOptions } from "./dashboard-screen.ts";
|
|
8
|
+
import { validChoiceId } from "../kernel/dashboard-choice.ts";
|
|
8
9
|
import { isBookieChoice } from "../kernel/dashboard-observation.ts";
|
|
9
10
|
import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
|
|
10
11
|
import { safeDashboardSummary } from "./activity-summary.ts";
|
|
@@ -80,14 +81,33 @@ export function bookieOpenChoices(options: DashboardScreenOptions): DashboardIte
|
|
|
80
81
|
!source.items.some((i) => isComponentObservation(source, i) && i.state === "observed")
|
|
81
82
|
)
|
|
82
83
|
return [];
|
|
84
|
+
const owner = options.session.observation;
|
|
85
|
+
const canAnswer = owner && options.session.choiceControls?.sourceGeneration === source.generation;
|
|
83
86
|
return source.items
|
|
84
87
|
.filter((i) => isBookieChoice(source.producer, i) && i.kind === "work" && i.state === "observed")
|
|
85
88
|
.map((i) => ({
|
|
86
89
|
key: `source:${source.producer}:${source.generation}:${i.id}`,
|
|
87
90
|
label: i.label,
|
|
88
91
|
status: "open-choice",
|
|
92
|
+
...(canAnswer && validChoiceId(i.id)
|
|
93
|
+
? {
|
|
94
|
+
choice: {
|
|
95
|
+
choiceId: i.id,
|
|
96
|
+
sourceGeneration: source.generation,
|
|
97
|
+
expectedOwner: {
|
|
98
|
+
sessionId: owner.sessionId,
|
|
99
|
+
cwd: owner.cwd,
|
|
100
|
+
generation: owner.generation,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
: {}),
|
|
89
105
|
elapsed: "",
|
|
90
|
-
briefDetails: [
|
|
106
|
+
briefDetails: [
|
|
107
|
+
"Saved in this project’s notes.",
|
|
108
|
+
...(i.details ?? []),
|
|
109
|
+
...(canAnswer ? [] : ["This Bookie connection offers viewing only."]),
|
|
110
|
+
],
|
|
91
111
|
details: [
|
|
92
112
|
...(i.details ?? []),
|
|
93
113
|
`Source: Bookie ${source.producerVersion}`,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { openChoice, choiceKey } from "./dashboard-choice-picker.ts";
|
|
1
2
|
import { DASHBOARD_DESTINATIONS } from "./dashboard-panels.ts";
|
|
2
3
|
import { DASHBOARD_SETTING_KEYS } from "./dashboard-settings.ts";
|
|
3
4
|
/** Local display controls; these never dispatch actions to an owner or change ledger state. */
|
|
@@ -19,7 +20,11 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
|
|
|
19
20
|
return {
|
|
20
21
|
state,
|
|
21
22
|
screen,
|
|
22
|
-
key(
|
|
23
|
+
key(
|
|
24
|
+
key: string,
|
|
25
|
+
text?: string,
|
|
26
|
+
): "auto" | "quit" | "command" | "setting" | "inspect-choice" | "answer-choice" | undefined {
|
|
27
|
+
if (screen.view === "choice") return choiceKey(screen, key, text);
|
|
23
28
|
if (key === "?" || key === "r") {
|
|
24
29
|
const reading = key === "?" ? "help" : "recap";
|
|
25
30
|
if (screen.view === reading) key = "escape";
|
|
@@ -86,6 +91,7 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
|
|
|
86
91
|
screen.offset = 0;
|
|
87
92
|
} else if (key === "return" || key === "d") {
|
|
88
93
|
if (screen.view !== "versions" && (screen.view !== "main" || !screen.selectedKey)) return;
|
|
94
|
+
if (screen.view === "main" && key === "return" && openChoice(screen)) return "inspect-choice";
|
|
89
95
|
screen.view = screen.view === "versions" ? "version-details" : "details";
|
|
90
96
|
screen.sourceDetails = false;
|
|
91
97
|
screen.offset = 0;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { choiceBody, choiceKeys, type ChoicePicker } from "./dashboard-choice-picker.ts";
|
|
2
|
+
import type { DashboardChoiceTarget } from "../kernel/dashboard-choice.ts";
|
|
1
3
|
import type { DashboardAcknowledgment } from "./dashboard-session-client.ts";
|
|
2
4
|
import {
|
|
3
5
|
needsUserInput,
|
|
@@ -32,12 +34,14 @@ export interface DashboardItem {
|
|
|
32
34
|
observation?: string;
|
|
33
35
|
taskKey?: string;
|
|
34
36
|
timelinePath?: string;
|
|
37
|
+
choice?: DashboardChoiceTarget;
|
|
35
38
|
approval?: boolean;
|
|
36
39
|
skills?: boolean;
|
|
37
40
|
agent?: boolean;
|
|
38
41
|
}
|
|
39
42
|
export interface DashboardScreenState {
|
|
40
|
-
view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings" | "recap";
|
|
43
|
+
view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings" | "recap" | "choice";
|
|
44
|
+
picker?: ChoicePicker;
|
|
41
45
|
destination?: DashboardDestination;
|
|
42
46
|
expanded?: boolean;
|
|
43
47
|
sourceDetails?: boolean;
|
|
@@ -227,6 +231,7 @@ function sessionLocation(screen: DashboardScreenState, width: number): string {
|
|
|
227
231
|
versions: "Versions",
|
|
228
232
|
"version-details": "Version details",
|
|
229
233
|
recap: "Session recap",
|
|
234
|
+
choice: "Answer choice",
|
|
230
235
|
};
|
|
231
236
|
const name = destinationNames[destination];
|
|
232
237
|
if (screen.view in overlays) return `${name} / ${overlays[screen.view as keyof typeof overlays]}`;
|
|
@@ -241,7 +246,9 @@ function sessionLocation(screen: DashboardScreenState, width: number): string {
|
|
|
241
246
|
function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | undefined, width: number): string[] {
|
|
242
247
|
const view = screen.view;
|
|
243
248
|
const brief = width < 34;
|
|
249
|
+
if (view === "choice") return choiceKeys(screen);
|
|
244
250
|
if (view === "main") {
|
|
251
|
+
if (selected?.choice) return ["↑↓ select · Enter answer", "d details · q close"];
|
|
245
252
|
const keys = selected ? (brief ? "↑↓ · Enter details" : "↑↓ select · Enter details") : "1–6 views";
|
|
246
253
|
return [keys + (brief ? " · ?" : " · ? help"), "r recap · q close"];
|
|
247
254
|
}
|
|
@@ -315,7 +322,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
315
322
|
}
|
|
316
323
|
if (
|
|
317
324
|
!screen.items.some((item) => item.key === screen.selectedKey) &&
|
|
318
|
-
!(screen.view === "details" && screen.selectedKey)
|
|
325
|
+
!((screen.view === "details" || screen.view === "choice") && screen.selectedKey)
|
|
319
326
|
)
|
|
320
327
|
screen.selectedKey = screen.items[0]?.key;
|
|
321
328
|
const selectedIndex = screen.items.findIndex((item) => item.key === screen.selectedKey),
|
|
@@ -326,6 +333,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
326
333
|
const mode =
|
|
327
334
|
session && options.connected !== false ? `Auto ${session.auto.enabled ? "ON" : "OFF"}` : "Auto unavailable";
|
|
328
335
|
const header = `PI DADDY | ${mode}${options.pending ? " …" : session && options.connected !== false ? " [a]" : ""}`;
|
|
336
|
+
const choiceLines = screen.view === "choice" ? choiceBody(screen) : [];
|
|
329
337
|
const footer =
|
|
330
338
|
options.command !== undefined
|
|
331
339
|
? [`: ${clean(options.command)}`]
|
|
@@ -355,8 +363,9 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
355
363
|
fixed.push("Disconnected · showing last known status");
|
|
356
364
|
if (screen.view === "main" && (screen.destination ?? "now") === "now")
|
|
357
365
|
fixed.push(...wrapDashboardLines(["In the current Pi chat, run /grants dashboard."], width));
|
|
358
|
-
} else if (
|
|
359
|
-
|
|
366
|
+
} else if (screen.view !== "choice" && (options.notice || options.problem))
|
|
367
|
+
fixed.push(`! ${clean(options.notice || options.problem || "")}`);
|
|
368
|
+
const ack = options.acknowledgment?.action === "answer-choice" ? undefined : options.acknowledgment;
|
|
360
369
|
if (ack?.state === "unconfirmed") {
|
|
361
370
|
const setting =
|
|
362
371
|
(
|
|
@@ -393,7 +402,8 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
393
402
|
if (options.height >= 22) fixed.push("");
|
|
394
403
|
}
|
|
395
404
|
const body: string[] = [];
|
|
396
|
-
if (screen.view === "
|
|
405
|
+
if (screen.view === "choice") body.push(...choiceLines);
|
|
406
|
+
else if (screen.view === "recap") {
|
|
397
407
|
const recap = sessionRecapLines(options);
|
|
398
408
|
const activity = recap.findIndex(
|
|
399
409
|
(line) => line === "Recent activity · newest first" || line === "No recent session events recorded.",
|
|
@@ -409,6 +419,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
409
419
|
body.push(
|
|
410
420
|
"DASHBOARD KEYS",
|
|
411
421
|
"↑/↓ or j/k: select; Enter/d: details",
|
|
422
|
+
"Enter on an open choice: answer in Bookie when available. d: details",
|
|
412
423
|
"a: toggle Daddy permission Auto",
|
|
413
424
|
"m: session models; v: ecosystem versions; s: settings",
|
|
414
425
|
"1 Overview · what needs you and what Pi is doing",
|
|
@@ -597,11 +608,13 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
597
608
|
screen.offset = Math.max(0, Math.min(row, Math.max(screen.offset, last - room + 1)));
|
|
598
609
|
}
|
|
599
610
|
}
|
|
600
|
-
if (modern && screen.view === "main" && room > 0 && !screen.manualScroll) {
|
|
611
|
+
if (modern && (screen.view === "main" || screen.view === "choice") && room > 0 && !screen.manualScroll) {
|
|
601
612
|
const selectedRow = detailBody.findIndex((line) => line.startsWith(">"));
|
|
602
613
|
if (selectedRow >= screen.offset + room) screen.offset = selectedRow - room + 1;
|
|
603
614
|
else if (selectedRow >= 0 && selectedRow < screen.offset) screen.offset = selectedRow;
|
|
604
615
|
}
|
|
616
|
+
if (screen.view === "choice" && screen.picker?.phase === "custom" && !screen.manualScroll && !screen.picker.error)
|
|
617
|
+
screen.offset = Math.max(0, detailBody.length - room);
|
|
605
618
|
const offset =
|
|
606
619
|
screen.view === "main" && !modern ? 0 : Math.max(0, Math.min(screen.offset, Math.max(0, detailBody.length - room)));
|
|
607
620
|
screen.offset = offset;
|