strom-research 1.13.2-beta.12 → 1.13.2-beta.13
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/assets/lang/cs.json +112 -23
- package/assets/lang/de.json +112 -23
- package/assets/method/core.md +9 -0
- package/assets/method/locate.md +3 -2
- package/assets/method/reading.md +8 -0
- package/assets/method/request.md +12 -3
- package/assets/method/waiting.md +66 -0
- package/dist/agents/files.js +8 -2
- package/dist/brief/brief.js +23 -3
- package/dist/brief/sheet.js +3 -1
- package/dist/cli/human.js +28 -3
- package/dist/cli/menu-archives.js +73 -76
- package/dist/cli/menu-links.js +90 -1
- package/dist/cli/menu-research.js +1 -1
- package/dist/cli/menu-waiting.js +487 -112
- package/dist/cli/menu.js +6 -8
- package/dist/cli/ui.js +102 -20
- package/dist/commands/archives.js +9 -2
- package/dist/commands/guide.js +8 -2
- package/dist/commands/intake.js +45 -11
- package/dist/commands/links.js +11 -0
- package/dist/commands/media.js +20 -3
- package/dist/commands/meta.js +15 -1
- package/dist/commands/read.js +6 -3
- package/dist/commands/readings.js +25 -5
- package/dist/commands/session.js +18 -1
- package/dist/commands/start.js +37 -5
- package/dist/commands/tasks.js +199 -13
- package/dist/core/archivewait.js +4 -2
- package/dist/core/changelog.js +7 -0
- package/dist/core/conflicts.js +1 -1
- package/dist/core/impersonal.js +69 -0
- package/dist/core/links.js +6 -2
- package/dist/core/live.js +191 -146
- package/dist/core/media.js +2 -0
- package/dist/core/model.js +2 -0
- package/dist/core/originals.js +5 -5
- package/dist/core/phrases.js +9 -2
- package/dist/core/reader.js +19 -2
- package/dist/core/schema.js +4 -1
- package/dist/core/stromapp.js +2 -1
- package/dist/core/taskfiles.js +64 -0
- package/dist/core/tree.js +1 -1
- package/dist/core/waiting.js +350 -0
- package/dist/core/waitkind.js +276 -0
- package/package.json +1 -1
package/dist/cli/menu-waiting.js
CHANGED
|
@@ -1,26 +1,454 @@
|
|
|
1
|
-
// The menu's "What waits for you":
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// The menu's "What waits for you": everything that waits for the person (core/waiting.ts — the same items, kinds,
|
|
2
|
+
// places, order and counts the Strom app gets), by the place where it is dealt with: one archive's site, one e-mail to
|
|
3
|
+
// an office, one message to the family. What is to do apart from what waits for a reply from outside (sent).
|
|
4
|
+
//
|
|
5
|
+
// the overview the places of what is to do, a page of 15 at a time (next, previous, a range, all), filtered by
|
|
6
|
+
// section, "?" for what waits for a reply; a number opens a place — a place of one thing that thing
|
|
7
|
+
// a place its things, then for all of them at once: the request texts joined, sent, a conversation
|
|
8
|
+
// a thing what it is and waits for, then only what makes sense for its kind: the archive or the site, the
|
|
9
|
+
// folder for images saved by hand, the request's text, sent (or back among what is to do), an answer
|
|
10
|
+
// in words or a file, a conversation; a decision (an archive, a story, the app's send, the reading of
|
|
11
|
+
// scans, a site to check) its own screen
|
|
12
|
+
//
|
|
13
|
+
// The answer is kept with the task, nothing more: the agent takes it up in its next work (strom task wake --answer).
|
|
14
|
+
// An archive: only what an archive has — no agent, no conversation.
|
|
5
15
|
import path from "node:path";
|
|
6
|
-
import {
|
|
7
|
-
import { decideSent
|
|
16
|
+
import { agentReady, claudeHere, guarded, outOfAnswers, pause, translator } from "./menu-parts.js";
|
|
17
|
+
import { decideSent } from "./menu-research.js";
|
|
18
|
+
import { decideArchive, decideMilder, decideTakeover } from "./menu-archives.js";
|
|
19
|
+
import { waitingDo } from "./menu-links.js";
|
|
8
20
|
import { truncate } from "./format.js";
|
|
21
|
+
import { ui } from "./ui.js";
|
|
9
22
|
import { Tree } from "../core/tree.js";
|
|
10
|
-
import {
|
|
11
|
-
import { receivedPending } from "../core/sync.js";
|
|
12
|
-
import { humanDay } from "./human.js";
|
|
23
|
+
import { humanDay, humanTask } from "./human.js";
|
|
13
24
|
import { displayName, lifespan } from "../core/people.js";
|
|
14
|
-
/** A person for the person reading: "Jan Novák (*1905) [P0001]". */
|
|
15
|
-
const label = (p) => `${displayName(p)}${lifespan(p) ? ` (${lifespan(p)})` : ""} [${p.id}]`;
|
|
16
25
|
import { openForUser } from "../core/open.js";
|
|
17
26
|
import { isArchive } from "../core/mode.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
import { listConnectors } from "../core/connector.js";
|
|
28
|
+
import { requestFile, requestTexts, waitingFor } from "../core/waiting.js";
|
|
29
|
+
import { SENDABLE } from "../core/waitkind.js";
|
|
30
|
+
/** A person for the person reading: "Jan Novák (*1905) [P0001]". */
|
|
31
|
+
const label = (p) => `${displayName(p)}${lifespan(p) ? ` (${lifespan(p)})` : ""} [${p.id}]`;
|
|
22
32
|
/** An answer is a note on the task (500 characters, with what it asked). */
|
|
23
33
|
const ANSWER_MAX = 300;
|
|
34
|
+
/** The places on one page of the overview. */
|
|
35
|
+
const PAGE = 15;
|
|
36
|
+
/** A request sent this many days ago with no reply yet: marked. */
|
|
37
|
+
const NO_REPLY_DAYS = 30;
|
|
38
|
+
/** The sections, in the order of the app's chips. */
|
|
39
|
+
const SECTIONS = ["decide", "images", "letter", "family", "web", "other"];
|
|
40
|
+
/** The kinds a word is said for (anything else: "other"). */
|
|
41
|
+
const KINDS = ["images", "letter", "family", "web", "check", "permission", "takeover", "milder", "story", "send", "tune", "other"];
|
|
42
|
+
/** Everything that waits for the person here, in the order of What waits: the app's items and the terminal's own. */
|
|
43
|
+
export function waitingHere(ctx, tree) {
|
|
44
|
+
return waitingFor(tree, {
|
|
45
|
+
shared: ctx.settings.shared()?.value,
|
|
46
|
+
claude: () => claudeHere(ctx, tree.config),
|
|
47
|
+
sends: true,
|
|
48
|
+
milder: true,
|
|
49
|
+
// the questions about the reading of scans: an archive asks none
|
|
50
|
+
...(isArchive(tree) ? {} : { tune: ctx.settings }),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** The keys of the overview in the person's language: next, previous, all, and a letter per section. */
|
|
54
|
+
export function waitKeys(lang) {
|
|
55
|
+
const t = translator(lang);
|
|
56
|
+
const low = (s) => s.toLocaleLowerCase(lang);
|
|
57
|
+
return {
|
|
58
|
+
next: low(t("ui.wait.key.next")),
|
|
59
|
+
prev: low(t("ui.wait.key.prev")),
|
|
60
|
+
all: low(t("ui.wait.key.all")),
|
|
61
|
+
section: Object.fromEntries(SECTIONS.map((s) => [s, low(t(`ui.wait.key.${s}`))])),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** A kind of what waits in the person's words. */
|
|
65
|
+
function kindWord(t, kind) {
|
|
66
|
+
return t(`ui.wait.kind.${KINDS.includes(kind) ? kind : "other"}`);
|
|
67
|
+
}
|
|
68
|
+
/** How long ago, in days: "today", "1 day ago", "8 days ago". */
|
|
69
|
+
function ago(t, iso, now = Date.now()) {
|
|
70
|
+
const days = daysSince(iso, now);
|
|
71
|
+
return days === 0 ? t("ui.wait.ago.today") : days === 1 ? t("ui.wait.ago.one") : t("ui.wait.ago", { n: days });
|
|
72
|
+
}
|
|
73
|
+
function daysSince(iso, now = Date.now()) {
|
|
74
|
+
const at = Date.parse(iso);
|
|
75
|
+
return Number.isNaN(at) ? 0 : Math.max(0, Math.floor((now - at) / 86_400_000));
|
|
76
|
+
}
|
|
77
|
+
/** Sent when, how long ago, and the mark of a request with no reply for long. */
|
|
78
|
+
function sentWords(t, lang, iso) {
|
|
79
|
+
return `${t("ui.wait.sentline", { day: humanDay(iso, lang), ago: ago(t, iso) })}${daysSince(iso) > NO_REPLY_DAYS ? ` · ${t("ui.wait.noreply", { days: NO_REPLY_DAYS })}` : ""}`;
|
|
80
|
+
}
|
|
81
|
+
/** What a thing is, short: a task's words as written, its records named (a person's ID after their name only bracketed). */
|
|
82
|
+
function short(tree, lang, w) {
|
|
83
|
+
return w.task ? humanTask(tree, w.item.what, lang, { asWritten: true }) : w.item.what;
|
|
84
|
+
}
|
|
85
|
+
const sentAtOf = (w) => String(w.item.sentAt ?? w.item.at);
|
|
86
|
+
/** The places of a list, in its order (the items of one place stand together). */
|
|
87
|
+
function placesOf(items) {
|
|
88
|
+
const by = new Map();
|
|
89
|
+
for (const w of items) {
|
|
90
|
+
let p = by.get(w.item.group.key);
|
|
91
|
+
if (!p)
|
|
92
|
+
by.set(w.item.group.key, (p = { key: w.item.group.key, name: w.item.group.name, items: [] }));
|
|
93
|
+
p.items.push(w);
|
|
94
|
+
}
|
|
95
|
+
return [...by.values()];
|
|
96
|
+
}
|
|
97
|
+
/** A place's line on the overview: the thing itself when it is one, else what is there by kind. */
|
|
98
|
+
function placeDetail(t, lang, tree, p, phase) {
|
|
99
|
+
const one = p.items.length === 1 ? truncate(short(tree, lang, p.items[0]), 60) : undefined;
|
|
100
|
+
if (phase === "sent") {
|
|
101
|
+
const oldest = p.items.map(sentAtOf).sort()[0];
|
|
102
|
+
return `${one ? `${one} · ` : ""}${sentWords(t, lang, oldest)}`;
|
|
103
|
+
}
|
|
104
|
+
if (one)
|
|
105
|
+
return one;
|
|
106
|
+
const kinds = [...new Set(p.items.map((w) => w.item.kind))];
|
|
107
|
+
// the letters to one office, the questions to the family: one message
|
|
108
|
+
if (kinds.length === 1 && kinds[0] === "letter")
|
|
109
|
+
return t("ui.wait.letter.todo");
|
|
110
|
+
if (kinds.length === 1 && kinds[0] === "family")
|
|
111
|
+
return t("ui.wait.family.todo");
|
|
112
|
+
return kinds.map((k) => `${kindWord(t, k)} ${p.items.filter((w) => w.item.kind === k).length}`).join(" · ");
|
|
113
|
+
}
|
|
114
|
+
/** Whether a conversation with the agent can be offered: never in an archive, nor without an agent here. */
|
|
115
|
+
function canChat(ctx, tree) {
|
|
116
|
+
return !isArchive(tree) && agentReady(ctx, tree.config);
|
|
117
|
+
}
|
|
118
|
+
/** The menu's What waits: the overview (see the top of this file). */
|
|
119
|
+
export async function waitingForYou(ctx, run, lang, root) {
|
|
120
|
+
const t = translator(lang);
|
|
121
|
+
const out = (line = "") => ctx.io.stdout(line + "\n");
|
|
122
|
+
const keys = waitKeys(lang);
|
|
123
|
+
let phase = "todo";
|
|
124
|
+
let filter;
|
|
125
|
+
let page = 0;
|
|
126
|
+
let view;
|
|
127
|
+
for (;;) {
|
|
128
|
+
if (outOfAnswers(ctx))
|
|
129
|
+
return;
|
|
130
|
+
const tree = Tree.open(root, ctx.env);
|
|
131
|
+
const all = waitingHere(ctx, tree);
|
|
132
|
+
if (!all.length)
|
|
133
|
+
return void out(t("ui.waiting.none"));
|
|
134
|
+
const todo = all.filter((w) => w.item.phase === "todo");
|
|
135
|
+
const sent = all.filter((w) => w.item.phase === "sent");
|
|
136
|
+
if (phase === "sent" && !sent.length)
|
|
137
|
+
phase = "todo";
|
|
138
|
+
const here = phase === "todo" ? todo : sent;
|
|
139
|
+
const counts = new Map();
|
|
140
|
+
for (const w of here)
|
|
141
|
+
counts.set(w.item.section, (counts.get(w.item.section) ?? 0) + 1);
|
|
142
|
+
if (filter && !counts.get(filter))
|
|
143
|
+
filter = undefined;
|
|
144
|
+
const places = placesOf(filter ? here.filter((w) => w.item.section === filter) : here);
|
|
145
|
+
const pages = Math.max(1, Math.ceil(places.length / PAGE));
|
|
146
|
+
page = Math.min(page, pages - 1);
|
|
147
|
+
const [from, to] = view === "all" ? [0, places.length] : view ? [view.from, Math.min(view.to, places.length)] : [page * PAGE, Math.min(places.length, (page + 1) * PAGE)];
|
|
148
|
+
const present = SECTIONS.filter((s) => counts.get(s));
|
|
149
|
+
const sectionName = (s) => t(`ui.wait.sec.${s}`);
|
|
150
|
+
// the heading: how many to do and how many wait for a reply (the app's numbers), the sections with their letters
|
|
151
|
+
const head = phase === "todo"
|
|
152
|
+
? [t("ui.menu.waitlist"), t("ui.wait.todo.n", { n: todo.length }), ...(sent.length ? [t("ui.wait.sent.n", { n: sent.length })] : [])]
|
|
153
|
+
: [t("ui.wait.sent.title"), String(sent.length), ...(todo.length ? [t("ui.wait.todo.n", { n: todo.length })] : [])];
|
|
154
|
+
if (filter)
|
|
155
|
+
head.push(t("ui.wait.filter", { section: sectionName(filter) }));
|
|
156
|
+
const screen = ["", head.join(" · ")];
|
|
157
|
+
if (present.length)
|
|
158
|
+
screen.push(` ${present.map((s) => `${keys.section[s]} ${sectionName(s)} ${counts.get(s)}`).join(" · ")}`);
|
|
159
|
+
if (!here.length)
|
|
160
|
+
screen.push(` ${t("ui.wait.none.todo")}`);
|
|
161
|
+
const shown = places.slice(from, to);
|
|
162
|
+
const names = shown.map((p) => `${truncate(p.name, 34)} · ${p.items.length}`);
|
|
163
|
+
const width = Math.max(0, ...names.map((n) => [...n].length));
|
|
164
|
+
for (const [k, p] of shown.entries()) {
|
|
165
|
+
const name = names[k];
|
|
166
|
+
screen.push(`${String(from + k + 1).padStart(2)} ${name}${" ".repeat(width - [...name].length)} ${placeDetail(t, lang, tree, p, phase)}`);
|
|
167
|
+
}
|
|
168
|
+
// what can be typed here, only what does something now
|
|
169
|
+
const controls = [];
|
|
170
|
+
if (places.length > PAGE) {
|
|
171
|
+
controls.push(view === undefined ? t("ui.wait.c.page", { page: page + 1, pages }) : t("ui.wait.c.shown", { from: from + 1, to, n: places.length }));
|
|
172
|
+
}
|
|
173
|
+
if (places.length)
|
|
174
|
+
controls.push(t("ui.wait.c.number"));
|
|
175
|
+
if (places.length > PAGE)
|
|
176
|
+
controls.push(t("ui.wait.c.next", { key: keys.next }), t("ui.wait.c.prev", { key: keys.prev }), "10-20", t("ui.wait.c.all", { key: keys.all }));
|
|
177
|
+
if (present.length > 1 || filter)
|
|
178
|
+
controls.push(t("ui.wait.c.filter", { keys: present.map((s) => keys.section[s]).join("/") }));
|
|
179
|
+
if (phase === "todo" && sent.length)
|
|
180
|
+
controls.push(t("ui.wait.c.sent"));
|
|
181
|
+
if (phase === "sent" && todo.length)
|
|
182
|
+
controls.push(t("ui.wait.c.todo"));
|
|
183
|
+
controls.push(t(filter ? "ui.wait.c.unfilter" : "ui.wait.c.back"));
|
|
184
|
+
const controlLine = ` ${controls.join(" · ")}`;
|
|
185
|
+
screen.push(controlLine);
|
|
186
|
+
out(screen.join("\n"));
|
|
187
|
+
// the answer: Enter goes back; anything unknown shows what can be typed again, nothing happens
|
|
188
|
+
for (;;) {
|
|
189
|
+
if (outOfAnswers(ctx))
|
|
190
|
+
return;
|
|
191
|
+
const a = (await ctx.ask(t("ui.choose"))).trim().toLocaleLowerCase(lang);
|
|
192
|
+
if (a === "") {
|
|
193
|
+
if (phase === "sent") {
|
|
194
|
+
phase = "todo";
|
|
195
|
+
filter = undefined;
|
|
196
|
+
view = undefined;
|
|
197
|
+
page = 0;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (a === "0") {
|
|
203
|
+
if (filter)
|
|
204
|
+
filter = undefined;
|
|
205
|
+
else if (phase === "sent")
|
|
206
|
+
phase = "todo";
|
|
207
|
+
else
|
|
208
|
+
return;
|
|
209
|
+
view = undefined;
|
|
210
|
+
page = 0;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
if (a === "?" && (phase === "todo" ? sent.length : todo.length)) {
|
|
214
|
+
phase = phase === "todo" ? "sent" : "todo";
|
|
215
|
+
filter = undefined;
|
|
216
|
+
view = undefined;
|
|
217
|
+
page = 0;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
if ((a === keys.next || a === keys.prev) && places.length > PAGE) {
|
|
221
|
+
page = view === undefined ? Math.max(0, Math.min(pages - 1, page + (a === keys.next ? 1 : -1))) : Math.floor(from / PAGE);
|
|
222
|
+
view = undefined;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (a === keys.all && places.length > PAGE) {
|
|
226
|
+
view = "all";
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
const section = present.find((s) => keys.section[s] === a);
|
|
230
|
+
if (section) {
|
|
231
|
+
filter = filter === section ? undefined : section;
|
|
232
|
+
view = undefined;
|
|
233
|
+
page = 0;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
const range = /^(\d+)\s*[-–]\s*(\d+)$/u.exec(a);
|
|
237
|
+
if (range) {
|
|
238
|
+
const [f, l] = [Number(range[1]), Number(range[2])];
|
|
239
|
+
if (f >= 1 && f <= l && f <= places.length) {
|
|
240
|
+
view = { from: f - 1, to: Math.min(l, places.length) };
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (/^\d+$/u.test(a) && Number(a) >= 1 && Number(a) <= places.length) {
|
|
245
|
+
const p = places[Number(a) - 1];
|
|
246
|
+
// a place of one: that thing at once
|
|
247
|
+
await guarded(ctx, lang, async () => (p.items.length === 1 ? thing(ctx, run, lang, root, p.items[0]) : place(ctx, run, lang, root, p.key, phase, filter)));
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
out(controlLine);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** One place: its things, then for all of them at once — the request texts joined, sent, a conversation. */
|
|
255
|
+
async function place(ctx, run, lang, root, key, phase, filter) {
|
|
256
|
+
const t = translator(lang);
|
|
257
|
+
const out = (line = "") => ctx.io.stdout(line + "\n");
|
|
258
|
+
for (;;) {
|
|
259
|
+
if (outOfAnswers(ctx))
|
|
260
|
+
return;
|
|
261
|
+
const tree = Tree.open(root, ctx.env);
|
|
262
|
+
const items = waitingHere(ctx, tree).filter((w) => w.item.group.key === key && w.item.phase === phase && (!filter || w.item.section === filter));
|
|
263
|
+
if (!items.length)
|
|
264
|
+
return;
|
|
265
|
+
const name = items[0].item.group.name;
|
|
266
|
+
const tasks = items.filter((w) => w.task).map((w) => w.task);
|
|
267
|
+
const choices = [];
|
|
268
|
+
const acts = [];
|
|
269
|
+
for (const w of items) {
|
|
270
|
+
choices.push({ label: thingLine(t, lang, tree, w) });
|
|
271
|
+
acts.push(() => thing(ctx, run, lang, root, w));
|
|
272
|
+
}
|
|
273
|
+
if (tasks.some((x) => requestFile(tree, x))) {
|
|
274
|
+
choices.push({ label: t("ui.wait.group.text") });
|
|
275
|
+
acts.push(() => requestText(ctx, lang, root, tasks.map((x) => x.id)));
|
|
276
|
+
}
|
|
277
|
+
// sent for the whole group: a request that goes out at once — to an office, to the family, or a place with a letter
|
|
278
|
+
// or a question to the family to do; never an archive's site whose only request is something else
|
|
279
|
+
const group = items[0].item.group;
|
|
280
|
+
const sends = group.kind === "office" || group.kind === "family" || items.some((w) => w.task && w.item.phase === "todo" && (w.item.kind === "letter" || w.item.kind === "family"));
|
|
281
|
+
const sendable = phase === "todo" && sends ? items.filter((w) => w.task && SENDABLE.includes(w.item.kind)).map((w) => w.task) : [];
|
|
282
|
+
if (sendable.length) {
|
|
283
|
+
choices.push({ label: t("ui.wait.group.sent") });
|
|
284
|
+
acts.push(async () => {
|
|
285
|
+
out("");
|
|
286
|
+
out(t("ui.wait.group.sent.list", { place: name }));
|
|
287
|
+
for (const x of sendable)
|
|
288
|
+
out(` • ${x.id} ${truncate(humanTask(tree, x.what, lang, { asWritten: true }), 70)}`);
|
|
289
|
+
if (!(await ctx.confirm(t("ui.wait.group.sent.sure"), false)))
|
|
290
|
+
return;
|
|
291
|
+
const ids = sendable.map((x) => x.id);
|
|
292
|
+
if ((await run(["task", "sent", ...ids], true)) !== 0)
|
|
293
|
+
return;
|
|
294
|
+
out(t("ui.wait.group.sent.done", { ids: ids.join(", ") }));
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (tasks.length && canChat(ctx, tree)) {
|
|
298
|
+
choices.push({ label: t("ui.wait.group.chat") });
|
|
299
|
+
acts.push(() => run(["chat", "--task", tasks[0].id]));
|
|
300
|
+
}
|
|
301
|
+
ctx.io.stdout("\n");
|
|
302
|
+
const i = await ctx.choose(`${name} · ${t(phase === "todo" ? "ui.wait.todo.n" : "ui.wait.sent.n", { n: items.length })}`, choices, choices.length, { back: t("ui.browse.back") });
|
|
303
|
+
if (i === undefined)
|
|
304
|
+
return;
|
|
305
|
+
await guarded(ctx, lang, async () => void (await acts[i]()));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/** A thing's line in its place: what, its kind, its priority — since when a decision waits, when a request went out. */
|
|
309
|
+
function thingLine(t, lang, tree, w) {
|
|
310
|
+
const what = `${truncate(short(tree, lang, w), 60)} · ${kindWord(t, w.item.kind)}`;
|
|
311
|
+
if (w.item.phase === "sent")
|
|
312
|
+
return `${what} · ${sentWords(t, lang, sentAtOf(w))}`;
|
|
313
|
+
if (w.task)
|
|
314
|
+
return `${what} · ${t("ui.wait.prio", { n: w.task.priority })}`;
|
|
315
|
+
return `${what} · ${t("ui.wait.since", { day: humanDay(w.item.at, lang) })}`;
|
|
316
|
+
}
|
|
317
|
+
/** The request texts of tasks, joined to be copied (each file once); Enter after it. */
|
|
318
|
+
async function requestText(ctx, lang, root, ids) {
|
|
319
|
+
const t = translator(lang);
|
|
320
|
+
const tree = Tree.open(root, ctx.env);
|
|
321
|
+
const r = requestTexts(tree, ids.map((id) => tree.get(id)).filter((x) => !!x));
|
|
322
|
+
if (!r.notes.length)
|
|
323
|
+
return void ctx.io.stdout(t("ui.wait.text.none") + "\n");
|
|
324
|
+
ctx.io.stdout(`\n${t("ui.wait.text.head", { files: r.notes.join(", ") })}\n\n${r.text}\n\n`);
|
|
325
|
+
await pause(ctx, lang);
|
|
326
|
+
}
|
|
327
|
+
/** One thing: a decision its own screen; a task what it is and waits for, then what makes sense for its kind. */
|
|
328
|
+
async function thing(ctx, run, lang, root, w) {
|
|
329
|
+
if (!w.task || w.task.awaitsCheck)
|
|
330
|
+
return decide(ctx, run, lang, root, w);
|
|
331
|
+
const t = translator(lang);
|
|
332
|
+
const out = (line = "") => ctx.io.stdout(line + "\n");
|
|
333
|
+
const id = w.task.id;
|
|
334
|
+
for (;;) {
|
|
335
|
+
if (outOfAnswers(ctx))
|
|
336
|
+
return;
|
|
337
|
+
const tree = Tree.open(root, ctx.env);
|
|
338
|
+
// as it is now: meanwhile taken up by an agent, sent, its images saved
|
|
339
|
+
const cur = waitingHere(ctx, tree).find((v) => v.task?.id === id);
|
|
340
|
+
if (!cur?.task)
|
|
341
|
+
return void out(t("ui.waiting.gone"));
|
|
342
|
+
const x = cur.task;
|
|
343
|
+
const it = cur.item;
|
|
344
|
+
const kind = it.kind;
|
|
345
|
+
const sent = it.phase === "sent";
|
|
346
|
+
const inbox = it.inbox;
|
|
347
|
+
const url = typeof it.url === "string" ? it.url : undefined;
|
|
348
|
+
const lines = ["", ` ${x.id} · ${kindWord(t, kind)} · ${t("ui.wait.prio", { n: x.priority })}`, ` ${humanTask(tree, x.what, lang, { asWritten: true })}`];
|
|
349
|
+
if (x.waitingOn)
|
|
350
|
+
lines.push(` ${t("ui.wait.d.on", { on: x.waitingOn })}`);
|
|
351
|
+
if (typeof it.to === "string" && it.to !== it.group.name)
|
|
352
|
+
lines.push(` ${t("ui.wait.d.to", { to: it.to })}`);
|
|
353
|
+
lines.push(` ${t("ui.wait.d.place", { place: it.group.name })}`);
|
|
354
|
+
lines.push(` ${t("ui.wait.d.since", { day: humanDay(it.at, lang) })}${sent ? ` · ${sentWords(t, lang, sentAtOf(cur))}` : ""}`);
|
|
355
|
+
if (x.awaits)
|
|
356
|
+
lines.push(...imagesToSave(ctx, lang, tree, x), "", ` ${t("ui.wait.how1")}`, ` ${t("ui.wait.how2")}`);
|
|
357
|
+
out(lines.join("\n"));
|
|
358
|
+
// what makes sense for its kind: true leaves (it waits no more here), else it is shown again
|
|
359
|
+
const choices = [];
|
|
360
|
+
const open = (key, target) => choices.push({
|
|
361
|
+
label: t(key),
|
|
362
|
+
act: async () => {
|
|
363
|
+
openForUser(target, ctx.env);
|
|
364
|
+
out(t("ui.wait.url", { url: target }));
|
|
365
|
+
return false;
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
const answer = (key = "ui.wait.a.answer", prompt = "ui.waiting.write") => choices.push({ label: t(key), act: () => answerTask(ctx, run, lang, root, x, prompt) });
|
|
369
|
+
const file = () => choices.push({ label: t("ui.wait.a.file"), act: () => waitingDo(ctx, run, lang, root, x.id, "file", "", true) });
|
|
370
|
+
if (kind === "images" && !sent) {
|
|
371
|
+
if (url)
|
|
372
|
+
open("ui.wait.a.archive", url);
|
|
373
|
+
if (inbox)
|
|
374
|
+
choices.push({
|
|
375
|
+
label: t("ui.wait.a.folder", { have: inbox.have, want: inbox.want || "?" }),
|
|
376
|
+
act: async () => {
|
|
377
|
+
openForUser(inbox.dir, ctx.env);
|
|
378
|
+
out(t("ui.waiting.opened", { dir: ctx.display(inbox.dir) }));
|
|
379
|
+
return false;
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
answer("ui.wait.a.cannot", "ui.wait.cannot.write");
|
|
383
|
+
}
|
|
384
|
+
else if (sent) {
|
|
385
|
+
answer();
|
|
386
|
+
file();
|
|
387
|
+
choices.push({
|
|
388
|
+
label: t("ui.wait.a.unsent"),
|
|
389
|
+
act: async () => {
|
|
390
|
+
if ((await run(["task", "sent", x.id, "--undo"], true)) !== 0)
|
|
391
|
+
return false;
|
|
392
|
+
out(t("ui.wait.unsent.done"));
|
|
393
|
+
return true;
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
else if (SENDABLE.includes(kind)) {
|
|
398
|
+
if (requestFile(tree, x))
|
|
399
|
+
choices.push({ label: t("ui.wait.a.note"), act: async () => (await requestText(ctx, lang, root, [x.id]), false) });
|
|
400
|
+
choices.push({ label: t("ui.wait.a.sent"), act: () => waitingDo(ctx, run, lang, root, x.id, "sent", "", true) });
|
|
401
|
+
answer();
|
|
402
|
+
file();
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
if (url)
|
|
406
|
+
open(kind === "web" ? "ui.wait.a.web" : "ui.wait.a.link", url);
|
|
407
|
+
answer();
|
|
408
|
+
}
|
|
409
|
+
if (canChat(ctx, tree))
|
|
410
|
+
choices.push({ label: t("ui.wait.a.chat"), act: () => waitingDo(ctx, run, lang, root, x.id, "chat", "", true) });
|
|
411
|
+
const i = await ctx.choose("", choices, choices.length, { back: t("ui.browse.back") });
|
|
412
|
+
if (i === undefined)
|
|
413
|
+
return;
|
|
414
|
+
if ((await guarded(ctx, lang, choices[i].act)) === true)
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/** A decision: its own screen — an archive's question, a story's new version, the app's send, the reading of scans, a site to check. */
|
|
419
|
+
async function decide(ctx, run, lang, root, w) {
|
|
420
|
+
if (w.send)
|
|
421
|
+
return void (await decideSent(ctx, run, lang, root, w.send));
|
|
422
|
+
if (w.tune)
|
|
423
|
+
return decideTune(ctx, run, lang, w.tune);
|
|
424
|
+
const tree = Tree.open(root, ctx.env);
|
|
425
|
+
if (w.story)
|
|
426
|
+
return void (await decideStory(ctx, run, lang, root, w.story, storyOf(tree, w.story)));
|
|
427
|
+
const q = w.question;
|
|
428
|
+
if (q?.kind === "permission" && q.host)
|
|
429
|
+
return void (await decideArchive(ctx, run, lang, root, q.host, q));
|
|
430
|
+
if (q?.kind === "takeover")
|
|
431
|
+
return decideTakeover(ctx, run, lang, q);
|
|
432
|
+
if (q?.kind === "milder" && q.connector) {
|
|
433
|
+
const c = listConnectors(ctx.settings.shared()?.value, ctx.env).find((x) => x.name === q.connector);
|
|
434
|
+
return decideMilder(ctx, run, lang, q, c?.manifest.title ?? q.title ?? q.connector);
|
|
435
|
+
}
|
|
436
|
+
if (w.task?.awaitsCheck) {
|
|
437
|
+
ctx.io.stdout(`\n ${humanTask(tree, w.task.what, lang)}\n`);
|
|
438
|
+
return checkSite(ctx, run, lang, root, w.task, true);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/** The images to save by hand and where (a task waiting for an archive's images). */
|
|
442
|
+
function imagesToSave(ctx, lang, tree, x) {
|
|
443
|
+
const t = translator(lang);
|
|
444
|
+
if (!x.awaits)
|
|
445
|
+
return [];
|
|
446
|
+
const b = tree.get(x.awaits.recordset);
|
|
447
|
+
return [
|
|
448
|
+
` ${t("ui.waiting.images", { images: x.awaits.images, book: b?.title ?? x.awaits.recordset })}${b?.url ? ` · ${b.url}` : ""}`,
|
|
449
|
+
` ${t("ui.wait.save", { dir: `${ctx.display(inbox(ctx, x) ?? `inbox/${x.awaits.folder}`)}${path.sep}` })}`,
|
|
450
|
+
];
|
|
451
|
+
}
|
|
24
452
|
/** What to do for a task that waits: the images to save and where, or what it asks. */
|
|
25
453
|
function whatToDo(ctx, lang, tree, x) {
|
|
26
454
|
const t = translator(lang);
|
|
@@ -29,58 +457,71 @@ function whatToDo(ctx, lang, tree, x) {
|
|
|
29
457
|
return [` ${t("ui.waiting.check", { ask: x.awaitsCheck.ask })}`, ` ${x.awaitsCheck.url}`, ` ${t("ui.waiting.check.why")}`];
|
|
30
458
|
if (!x.awaits)
|
|
31
459
|
return [` ${t("ui.waiting.do", { what: x.waitingOn || t("ui.waiting.ask") })}`];
|
|
32
|
-
|
|
33
|
-
return [
|
|
34
|
-
` ${t("ui.waiting.images", { images: x.awaits.images, book: b?.title ?? x.awaits.recordset })}${b?.url ? ` · ${b.url}` : ""}`,
|
|
35
|
-
` ${t("ui.wait.save", { dir: `${ctx.display(inbox(ctx, x) ?? `inbox/${x.awaits.folder}`)}${path.sep}` })}`,
|
|
36
|
-
];
|
|
460
|
+
return imagesToSave(ctx, lang, tree, x);
|
|
37
461
|
}
|
|
38
462
|
function inbox(ctx, x) {
|
|
39
463
|
const shared = ctx.settings.shared()?.value;
|
|
40
464
|
return shared && x.awaits ? path.join(shared, "inbox", x.awaits.folder) : undefined;
|
|
41
465
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
466
|
+
/**
|
|
467
|
+
* The person's answer in words, kept with the task and the task back in the queue — no conversation offered: the agent
|
|
468
|
+
* takes the answer up in its next work. True: kept.
|
|
469
|
+
*/
|
|
470
|
+
async function answerTask(ctx, run, lang, root, x, prompt = "ui.waiting.write") {
|
|
44
471
|
const t = translator(lang);
|
|
45
472
|
const out = (line) => ctx.io.stdout(line + "\n");
|
|
46
|
-
|
|
47
|
-
const dir = inbox(ctx, x);
|
|
48
|
-
if (dir)
|
|
49
|
-
openForUser(dir, ctx.env);
|
|
50
|
-
return void out(t("ui.waiting.opened", { dir: dir ? ctx.display(dir) : `inbox/${x.awaits.folder}` }));
|
|
51
|
-
}
|
|
52
|
-
if (x.awaitsCheck)
|
|
53
|
-
return checkSite(ctx, run, lang, root, x);
|
|
473
|
+
out(t("ui.waiting.later"));
|
|
54
474
|
let answer = "";
|
|
55
475
|
for (;;) {
|
|
56
|
-
answer = (await ctx.ask(t(
|
|
476
|
+
answer = (await ctx.ask(t(prompt))).trim();
|
|
57
477
|
if (!answer || answer === "0")
|
|
58
|
-
return;
|
|
478
|
+
return false;
|
|
59
479
|
// kept as a note on the task, with what it asked: short — a longer story is for a conversation
|
|
60
480
|
if (answer.length <= ANSWER_MAX)
|
|
61
481
|
break;
|
|
62
482
|
out(t("ui.waiting.long", { n: ANSWER_MAX }));
|
|
63
|
-
if (ctx
|
|
64
|
-
return;
|
|
483
|
+
if (outOfAnswers(ctx))
|
|
484
|
+
return false;
|
|
65
485
|
}
|
|
66
486
|
// meanwhile taken up by an agent (done, dropped, back in the queue): said, nothing written
|
|
67
|
-
if (Tree.open(root, ctx.env).get(x.id)?.state !== "waiting")
|
|
68
|
-
|
|
487
|
+
if (Tree.open(root, ctx.env).get(x.id)?.state !== "waiting") {
|
|
488
|
+
out(t("ui.waiting.gone"));
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
69
491
|
if ((await run(["task", "wake", x.id, `--answer=${answer}`], true)) !== 0)
|
|
70
|
-
return;
|
|
71
|
-
out(t("ui.waiting.
|
|
72
|
-
|
|
492
|
+
return false;
|
|
493
|
+
out(`✓ ${t("ui.waiting.later")}`);
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* One task that waits, taken up: its folder opened for the images, a site checked, or the person's answer kept with the
|
|
498
|
+
* task and the task back in the queue.
|
|
499
|
+
*/
|
|
500
|
+
async function takeUp(ctx, run, lang, root, x) {
|
|
501
|
+
const t = translator(lang);
|
|
502
|
+
if (x.awaits) {
|
|
503
|
+
const dir = inbox(ctx, x);
|
|
504
|
+
if (dir)
|
|
505
|
+
openForUser(dir, ctx.env);
|
|
506
|
+
return void ctx.io.stdout(t("ui.waiting.opened", { dir: dir ? ctx.display(dir) : `inbox/${x.awaits.folder}` }) + "\n");
|
|
507
|
+
}
|
|
508
|
+
if (x.awaitsCheck)
|
|
509
|
+
return checkSite(ctx, run, lang, root, x);
|
|
510
|
+
await answerTask(ctx, run, lang, root, x);
|
|
73
511
|
}
|
|
74
512
|
/**
|
|
75
513
|
* A check of a site only a person sees (strom task wait --check): the link, what is there — the book and its images,
|
|
76
514
|
* only to be viewed there, nothing — and a note if any, 0 back with nothing changed; the task back with the answer.
|
|
515
|
+
* What is there is picked by its number only: Enter goes back (a group of one check opens here at once, and two Enters
|
|
516
|
+
* wrote an answer nobody gave).
|
|
517
|
+
* `why`: said why only a person can (What waits; a link said it before).
|
|
77
518
|
*/
|
|
78
|
-
async function checkSite(ctx, run, lang, root, x) {
|
|
519
|
+
async function checkSite(ctx, run, lang, root, x, why = false) {
|
|
79
520
|
const t = translator(lang);
|
|
80
521
|
const out = (line) => ctx.io.stdout(line + "\n");
|
|
81
522
|
const c = x.awaitsCheck;
|
|
82
|
-
out(`\n ${t("ui.waiting.check", { ask: c.ask })}\n ${c.url}`);
|
|
83
|
-
const pick = await ctx.choose(t("ui.waiting.check.pick"), [{ label: t("ui.waiting.check.works") }, { label: t("ui.waiting.check.view") }, { label: t("ui.waiting.check.no") }],
|
|
523
|
+
out(`\n ${t("ui.waiting.check", { ask: c.ask })}\n ${c.url}${why ? `\n ${t("ui.waiting.check.why")}` : ""}`);
|
|
524
|
+
const pick = await ctx.choose(t("ui.waiting.check.pick"), [{ label: t("ui.waiting.check.works") }, { label: t("ui.waiting.check.view") }, { label: t("ui.waiting.check.no") }], 3, { back: t("ui.browse.back") });
|
|
84
525
|
if (pick === undefined)
|
|
85
526
|
return;
|
|
86
527
|
const check = ["works", "view", "no"][pick];
|
|
@@ -92,7 +533,7 @@ async function checkSite(ctx, run, lang, root, x) {
|
|
|
92
533
|
if (note.length <= ANSWER_MAX)
|
|
93
534
|
break;
|
|
94
535
|
out(t("ui.waiting.long", { n: ANSWER_MAX }));
|
|
95
|
-
if (ctx
|
|
536
|
+
if (outOfAnswers(ctx))
|
|
96
537
|
return;
|
|
97
538
|
}
|
|
98
539
|
// meanwhile taken up (done, dropped, back in the queue): said, nothing written
|
|
@@ -100,8 +541,7 @@ async function checkSite(ctx, run, lang, root, x) {
|
|
|
100
541
|
return void out(t("ui.waiting.gone"));
|
|
101
542
|
if ((await run(["task", "wake", x.id, `--check=${check}`, ...(note ? [`--answer=${note}`] : [])], true)) !== 0)
|
|
102
543
|
return;
|
|
103
|
-
out(t("ui.waiting.
|
|
104
|
-
await offerChat(ctx, run, lang, root, t("ui.waiting.chat"), t("ui.waiting.say", { what: truncate(x.what, 80) }));
|
|
544
|
+
out(`✓ ${t("ui.waiting.later")}`);
|
|
105
545
|
}
|
|
106
546
|
/** One task that waits, named by a link of the Strom app: what it asks, then taken up as in the menu. False: it waits no more. */
|
|
107
547
|
export async function waitingTask(ctx, run, lang, root, id) {
|
|
@@ -109,7 +549,7 @@ export async function waitingTask(ctx, run, lang, root, id) {
|
|
|
109
549
|
const x = tree.get(id);
|
|
110
550
|
if (!x || x.state !== "waiting")
|
|
111
551
|
return false;
|
|
112
|
-
ctx.io.stdout([` ${x.what}`, ...whatToDo(ctx, lang, tree, x), ...(x.awaits ? ["",
|
|
552
|
+
ctx.io.stdout([` ${x.what}`, ...whatToDo(ctx, lang, tree, x), ...(x.awaits ? ["", ui(lang, "ui.wait.how1"), ui(lang, "ui.wait.how2")] : []), ""].join("\n") + "\n");
|
|
113
553
|
await takeUp(ctx, run, lang, root, x);
|
|
114
554
|
return true;
|
|
115
555
|
}
|
|
@@ -161,7 +601,7 @@ export async function decideStory(ctx, run, lang, root, id, who, how) {
|
|
|
161
601
|
*/
|
|
162
602
|
async function decideTune(ctx, run, lang, q) {
|
|
163
603
|
const t = translator(lang);
|
|
164
|
-
ctx.io.stdout(`\n ${q.text}\n ${q.why}\n`);
|
|
604
|
+
ctx.io.stdout(`\n ${t("ui.waiting.tune", { text: q.text })}\n ${q.why}\n`);
|
|
165
605
|
const pick = await ctx.choose("", q.choices.map((c) => ({ label: `${c.label}${c.id === q.recommended ? ` ${t("ui.tune.q.recommended")}` : ""}` })), Math.max(0, q.choices.findIndex((c) => c.id === q.recommended)), { back: t("ui.browse.back") });
|
|
166
606
|
if (pick === undefined)
|
|
167
607
|
return;
|
|
@@ -171,68 +611,3 @@ async function decideTune(ctx, run, lang, q) {
|
|
|
171
611
|
if (q.kind === "views.smaller" && choice === "calibrate")
|
|
172
612
|
await run(["media", "calibrate"]);
|
|
173
613
|
}
|
|
174
|
-
export async function waitingForYou(ctx, run, lang, root) {
|
|
175
|
-
const t = translator(lang);
|
|
176
|
-
await subMenu(ctx, lang, () => {
|
|
177
|
-
const tree = Tree.open(root, ctx.env);
|
|
178
|
-
const waiting = isArchive(tree) ? [] : tree.list("task").filter((x) => x.state === "waiting");
|
|
179
|
-
const stories = storiesToApprove(tree);
|
|
180
|
-
// what the Strom app sent on its own: first, the person's own edits
|
|
181
|
-
const sent = receivedPending(root);
|
|
182
|
-
// the questions about the reading of scans only a person answers: last, after the research's own
|
|
183
|
-
const tune = isArchive(tree) ? [] : tuneQuestions(tree, ctx.settings).due;
|
|
184
|
-
// the questions about archives' terms (none in an archive): right after the app's sends — they hold work up
|
|
185
|
-
const shownSent = sent.slice(0, SHOWN);
|
|
186
|
-
const asked = archiveItems(ctx, run, lang, root, shownSent.length, SHOWN - shownSent.length);
|
|
187
|
-
if (!waiting.length && !stories.length && !sent.length && !tune.length && !asked.count)
|
|
188
|
-
return { title: t("ui.waiting.none"), items: [] };
|
|
189
|
-
// the trees from the app first, the archives, then the tasks, then the stories: at most the menu's nine together
|
|
190
|
-
const ka = shownSent.length + asked.items.length;
|
|
191
|
-
const shown = waiting.slice(0, SHOWN - ka);
|
|
192
|
-
const shownStories = stories.slice(0, SHOWN - ka - shown.length);
|
|
193
|
-
const shownTune = tune.slice(0, SHOWN - ka - shown.length - shownStories.length);
|
|
194
|
-
const k0 = ka;
|
|
195
|
-
const k1 = k0 + shown.length + shownStories.length;
|
|
196
|
-
const total = waiting.length + stories.length + sent.length + tune.length + asked.count;
|
|
197
|
-
const text = [t(sent.length && !waiting.length && !stories.length && !tune.length && !asked.count ? "ui.waiting.title.sent" : "ui.waiting.title", { n: total })];
|
|
198
|
-
for (const [k, r] of shownSent.entries())
|
|
199
|
-
text.push("", ` ${k + 1}. ${t("ui.waiting.sent", { day: humanDay(r.at, lang), time: r.at.slice(11, 16), n: r.changes })}`);
|
|
200
|
-
text.push(...asked.text);
|
|
201
|
-
for (const [k, x] of shown.entries()) {
|
|
202
|
-
text.push("", ` ${k0 + k + 1}. ${x.what}`, ...whatToDo(ctx, lang, tree, x));
|
|
203
|
-
}
|
|
204
|
-
for (const [k, s] of shownStories.entries())
|
|
205
|
-
text.push("", ` ${k0 + shown.length + k + 1}. ${t("ui.waiting.story", { who: storyOf(tree, s.id) })}`);
|
|
206
|
-
for (const [k, q] of shownTune.entries())
|
|
207
|
-
text.push("", ` ${k1 + k + 1}. ${t("ui.waiting.tune", { text: q.text })}`);
|
|
208
|
-
if (shown.some((x) => x.awaits))
|
|
209
|
-
text.push("", t("ui.wait.how1"), t("ui.wait.how2"));
|
|
210
|
-
const hidden = total - shownSent.length - asked.items.length - shown.length - shownStories.length - shownTune.length;
|
|
211
|
-
if (hidden > 0)
|
|
212
|
-
text.push("", t("ui.waiting.more", { n: hidden }));
|
|
213
|
-
const items = [
|
|
214
|
-
...shownSent.map((r, k) => ({
|
|
215
|
-
key: String(k + 1),
|
|
216
|
-
label: t("ui.waiting.sent.read", { k: k + 1 }),
|
|
217
|
-
act: async () => void (await decideSent(ctx, run, lang, root, r)),
|
|
218
|
-
})),
|
|
219
|
-
...asked.items,
|
|
220
|
-
...shown.map((x, k) => ({
|
|
221
|
-
key: String(k0 + k + 1),
|
|
222
|
-
label: x.awaits ? t("ui.waiting.folder", { k: k0 + k + 1 }) : t("ui.waiting.answer", { k: k0 + k + 1, what: truncate(x.what, 60) }),
|
|
223
|
-
act: () => takeUp(ctx, run, lang, root, x),
|
|
224
|
-
})),
|
|
225
|
-
...shownStories.map((s, k) => ({
|
|
226
|
-
key: String(k0 + shown.length + k + 1),
|
|
227
|
-
label: t("ui.waiting.story.read", { k: k0 + shown.length + k + 1, who: storyOf(tree, s.id) }),
|
|
228
|
-
act: async () => void (await decideStory(ctx, run, lang, root, s.id, storyOf(tree, s.id))),
|
|
229
|
-
})),
|
|
230
|
-
...shownTune.map((q, k) => ({
|
|
231
|
-
key: String(k1 + k + 1),
|
|
232
|
-
label: t("ui.waiting.tune.read", { k: k1 + k + 1 }),
|
|
233
|
-
act: () => decideTune(ctx, run, lang, q),
|
|
234
|
-
})),
|
|
235
|
-
];
|
|
236
|
-
return { title: `${text.join("\n")}\n\n${t(shown.length || shownSent.length ? "ui.waiting.pick" : "ui.waiting.pick.story")}`, items };
|
|
237
|
-
});
|
|
238
|
-
}
|