forge-cw 0.1.24 → 0.1.26
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/dist/index.js +3 -2
- package/modules/mod-today/dist/banner.js +121 -9
- package/modules/mod-today/dist/server.js +118 -23
- package/modules/mod-today/dist/view.js +105 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8656,7 +8656,7 @@ function runAgent(input, o) {
|
|
|
8656
8656
|
const cwd = mkdtempSync2(join19(tmpdir2(), "forge-agent-"));
|
|
8657
8657
|
const cleanup = () => rmSync4(cwd, { recursive: true, force: true });
|
|
8658
8658
|
return new Promise((resolve11, reject) => {
|
|
8659
|
-
const child = spawn9("claude", args, { cwd, env: { ...envWithoutHarness(), CLAUDE_CONFIG_DIR: configDir }, stdio: ["pipe", "pipe", "pipe"] });
|
|
8659
|
+
const child = spawn9("claude", args, { cwd, env: { ...envWithoutHarness(), CLAUDE_CONFIG_DIR: configDir, ...CONNECTOR_ENV }, stdio: ["pipe", "pipe", "pipe"] });
|
|
8660
8660
|
child.stdin?.on("error", () => {
|
|
8661
8661
|
});
|
|
8662
8662
|
child.stdin?.end(input.prompt);
|
|
@@ -8698,7 +8698,7 @@ function runAgent(input, o) {
|
|
|
8698
8698
|
}));
|
|
8699
8699
|
}).finally(cleanup);
|
|
8700
8700
|
}
|
|
8701
|
-
var DEFAULT_TIMEOUT_MS;
|
|
8701
|
+
var DEFAULT_TIMEOUT_MS, CONNECTOR_ENV;
|
|
8702
8702
|
var init_agent_runner = __esm({
|
|
8703
8703
|
"../core/dist/agent-runner.js"() {
|
|
8704
8704
|
"use strict";
|
|
@@ -8706,6 +8706,7 @@ var init_agent_runner = __esm({
|
|
|
8706
8706
|
init_cw_types();
|
|
8707
8707
|
init_cw_doctor();
|
|
8708
8708
|
DEFAULT_TIMEOUT_MS = 18e4;
|
|
8709
|
+
CONNECTOR_ENV = { MCP_CONNECTION_NONBLOCKING: "false", MCP_TIMEOUT: "60000" };
|
|
8709
8710
|
}
|
|
8710
8711
|
});
|
|
8711
8712
|
|
|
@@ -18,6 +18,20 @@ function projectsFor({ names, owners }, account) {
|
|
|
18
18
|
var failedLine = (error) => `Last reading failed: ${error}`;
|
|
19
19
|
var loadFailedLine = (error) => `Can't load Today: ${error}`;
|
|
20
20
|
var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
|
|
21
|
+
var SOURCE_NAME = { slack: "Slack", linear: "Linear", reader: "Reader" };
|
|
22
|
+
function sourcesLabel(sources) {
|
|
23
|
+
const names = ["slack", "linear", "reader"].filter((s) => sources.includes(s)).map((s) => SOURCE_NAME[s]);
|
|
24
|
+
return names.join(" and ");
|
|
25
|
+
}
|
|
26
|
+
function groupProblems(problems) {
|
|
27
|
+
const accounts = [...new Set(problems.map((p) => p.account))];
|
|
28
|
+
return accounts.map((account) => {
|
|
29
|
+
const mine = problems.filter((p) => p.account === account);
|
|
30
|
+
return { account, label: sourcesLabel(mine.map((p) => p.source)), reasons: mine.map((p) => `${SOURCE_NAME[p.source]}: ${p.reason}`) };
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
|
|
34
|
+
var problemsLabel = (n) => `\u26A0 ${n} account problem${n === 1 ? "" : "s"}`;
|
|
21
35
|
var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
|
|
22
36
|
|
|
23
37
|
// src/rows.tsx
|
|
@@ -58,6 +72,7 @@ function useAccountFilter() {
|
|
|
58
72
|
function useDigest(forge, path = "/digest") {
|
|
59
73
|
const [reply, setReply] = useState(null);
|
|
60
74
|
const [error, setError] = useState(null);
|
|
75
|
+
const [hurried, hurry] = useState(false);
|
|
61
76
|
const latest = useRef(0);
|
|
62
77
|
const load = useCallback(async () => {
|
|
63
78
|
const mine = ++latest.current;
|
|
@@ -70,19 +85,20 @@ function useDigest(forge, path = "/digest") {
|
|
|
70
85
|
if (mine === latest.current) setError(errorMessage(e));
|
|
71
86
|
}
|
|
72
87
|
}, [forge, path]);
|
|
88
|
+
const fast = hurried || !!reply?.reading;
|
|
73
89
|
useEffect(() => {
|
|
74
90
|
void load();
|
|
75
91
|
const poll = () => {
|
|
76
92
|
if (!document.hidden) void load();
|
|
77
93
|
};
|
|
78
|
-
const t = setInterval(poll, 6e4);
|
|
94
|
+
const t = setInterval(poll, fast ? 3e3 : 6e4);
|
|
79
95
|
document.addEventListener("visibilitychange", poll);
|
|
80
96
|
return () => {
|
|
81
97
|
clearInterval(t);
|
|
82
98
|
document.removeEventListener("visibilitychange", poll);
|
|
83
99
|
};
|
|
84
|
-
}, [load]);
|
|
85
|
-
return { reply, error, reload: load };
|
|
100
|
+
}, [load, fast]);
|
|
101
|
+
return { reply, error, reload: load, hurry };
|
|
86
102
|
}
|
|
87
103
|
function useProjects(forge) {
|
|
88
104
|
const [projects, setProjects] = useState(EMPTY_PROJECTS);
|
|
@@ -92,9 +108,11 @@ function useProjects(forge) {
|
|
|
92
108
|
}, [forge]);
|
|
93
109
|
return projects;
|
|
94
110
|
}
|
|
95
|
-
function useActing(forge, date, reload) {
|
|
111
|
+
function useActing(forge, date, reload, hurry = () => {
|
|
112
|
+
}) {
|
|
96
113
|
const [busy, setBusy] = useState(false);
|
|
97
114
|
const [refreshing, setRefreshing] = useState(false);
|
|
115
|
+
const [retrying, setRetrying] = useState(null);
|
|
98
116
|
const reading = useRef(false);
|
|
99
117
|
const guarded = async (fn) => {
|
|
100
118
|
try {
|
|
@@ -117,11 +135,27 @@ function useActing(forge, date, reload) {
|
|
|
117
135
|
if (reading.current) return;
|
|
118
136
|
reading.current = true;
|
|
119
137
|
setRefreshing(true);
|
|
138
|
+
hurry(true);
|
|
120
139
|
await guarded(() => forge.action("refresh"));
|
|
140
|
+
hurry(false);
|
|
121
141
|
reading.current = false;
|
|
122
142
|
setRefreshing(false);
|
|
123
143
|
};
|
|
124
|
-
|
|
144
|
+
const retry = async (account) => {
|
|
145
|
+
if (busy) return;
|
|
146
|
+
setBusy(true);
|
|
147
|
+
setRetrying(account);
|
|
148
|
+
hurry(true);
|
|
149
|
+
await guarded(() => forge.action("retry-account", { account }));
|
|
150
|
+
hurry(false);
|
|
151
|
+
setRetrying(null);
|
|
152
|
+
setBusy(false);
|
|
153
|
+
};
|
|
154
|
+
const reconnect = (account) => run(async () => {
|
|
155
|
+
const s = await forge.action("reconnect", { account });
|
|
156
|
+
if (s) forge.openSession(s.project, s.sessionDir);
|
|
157
|
+
});
|
|
158
|
+
return { busy, refreshing, retrying, retry, reconnect, run, act, refresh };
|
|
125
159
|
}
|
|
126
160
|
function dayOf(date) {
|
|
127
161
|
const [y, m, d] = date.split("-").map(Number);
|
|
@@ -277,6 +311,60 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
277
311
|
] })
|
|
278
312
|
] });
|
|
279
313
|
};
|
|
314
|
+
var READING_CSS = `
|
|
315
|
+
@keyframes today-spin { to { transform: rotate(360deg) } }
|
|
316
|
+
@keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
|
|
317
|
+
.today-spin { animation: today-spin .8s linear infinite }
|
|
318
|
+
.today-pulse { animation: today-pulse 1.4s ease-in-out infinite }
|
|
319
|
+
@media (prefers-reduced-motion: reduce) { .today-spin, .today-pulse { animation: none } }`;
|
|
320
|
+
function useReadingStyles() {
|
|
321
|
+
if (typeof document !== "undefined" && !document.getElementById("today-reading-css")) {
|
|
322
|
+
const el = document.createElement("style");
|
|
323
|
+
el.id = "today-reading-css";
|
|
324
|
+
el.textContent = READING_CSS;
|
|
325
|
+
document.head.appendChild(el);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function Spinner() {
|
|
329
|
+
return /* @__PURE__ */ jsx("i", { class: "today-spin", style: { display: "inline-block", width: "10px", height: "10px", borderRadius: "50%", border: "2px solid var(--hair-2)", borderTopColor: "var(--blue)", boxSizing: "border-box" } });
|
|
330
|
+
}
|
|
331
|
+
function ReadingLine({ reading }) {
|
|
332
|
+
useReadingStyles();
|
|
333
|
+
const accounts = Object.entries(reading?.accounts ?? {});
|
|
334
|
+
return /* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "12px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
335
|
+
/* @__PURE__ */ jsx("b", { class: "today-pulse", style: { fontWeight: 600, color: "var(--ink)" }, children: accounts.length ? "Reading" : "Reading\u2026" }),
|
|
336
|
+
accounts.map(([account, state], n) => /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px" }, children: [
|
|
337
|
+
n > 0 && /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" }),
|
|
338
|
+
state === "reading" ? /* @__PURE__ */ jsx(Spinner, {}) : state === "done" ? /* @__PURE__ */ jsx("span", { style: { color: "var(--green)" }, children: "\u2713" }) : /* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
339
|
+
account
|
|
340
|
+
] }, account)),
|
|
341
|
+
accounts.length > 0 && /* @__PURE__ */ jsx("span", { children: "\u2026" })
|
|
342
|
+
] });
|
|
343
|
+
}
|
|
344
|
+
function SkeletonRows() {
|
|
345
|
+
useReadingStyles();
|
|
346
|
+
return /* @__PURE__ */ jsx("div", { "aria-hidden": "true", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [0, 1, 2].map((n) => /* @__PURE__ */ jsxs("div", { class: "today-pulse", style: { display: "flex", alignItems: "center", gap: "12px", padding: "10px 12px", borderRadius: "10px", background: "var(--elev)", border: "1px solid var(--hair)", animationDelay: `${n * 0.15}s` }, children: [
|
|
347
|
+
/* @__PURE__ */ jsx("div", { style: { width: "30px", height: "30px", borderRadius: "8px", background: "var(--hair)" } }),
|
|
348
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
349
|
+
/* @__PURE__ */ jsx("div", { style: { height: "9px", width: `${70 - n * 12}%`, borderRadius: "5px", background: "var(--hair)" } }),
|
|
350
|
+
/* @__PURE__ */ jsx("div", { style: { height: "8px", width: "35%", borderRadius: "5px", background: "var(--hair)" } })
|
|
351
|
+
] })
|
|
352
|
+
] }, n)) });
|
|
353
|
+
}
|
|
354
|
+
function ProblemRow({ group, acting, details = false }) {
|
|
355
|
+
const mine = acting.retrying === group.account;
|
|
356
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", title: group.reasons.join("\n"), style: { padding: "7px 10px", borderRadius: "10px", fontSize: "12px", color: "var(--ink-2)", background: soft("--orange", 10), border: `1px solid ${soft("--orange", 35)}` }, children: [
|
|
357
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
358
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
359
|
+
/* @__PURE__ */ jsx("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: groupLine(group) }),
|
|
360
|
+
/* @__PURE__ */ jsxs("span", { style: { marginLeft: "auto", display: "flex", gap: "8px", flexShrink: 0 }, children: [
|
|
361
|
+
/* @__PURE__ */ jsx(Btn, { label: mine ? "Reading\u2026" : "Retry", disabled: acting.busy, onClick: () => acting.retry(group.account) }),
|
|
362
|
+
/* @__PURE__ */ jsx(Btn, { label: "Reconnect", style: ghostStyle, disabled: acting.busy, onClick: () => acting.reconnect(group.account) })
|
|
363
|
+
] })
|
|
364
|
+
] }),
|
|
365
|
+
details && /* @__PURE__ */ jsx("ul", { style: { margin: "6px 0 0 22px", padding: 0, color: "var(--ink-3)", fontSize: "11.5px" }, children: group.reasons.map((r) => /* @__PURE__ */ jsx("li", { children: r }, r)) })
|
|
366
|
+
] });
|
|
367
|
+
}
|
|
280
368
|
|
|
281
369
|
// src/banner.tsx
|
|
282
370
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
@@ -315,12 +403,14 @@ function Strip({ title, children, actions }) {
|
|
|
315
403
|
);
|
|
316
404
|
}
|
|
317
405
|
function Banner({ forge }) {
|
|
318
|
-
const { reply, error, reload } = useDigest(forge);
|
|
406
|
+
const { reply, error, reload, hurry } = useDigest(forge);
|
|
319
407
|
const projects = useProjects(forge);
|
|
320
408
|
const [chosen, choose] = useAccountFilter();
|
|
321
409
|
const digest = reply?.digest;
|
|
322
|
-
const acting = useActing(forge, digest?.date, reload);
|
|
323
|
-
const
|
|
410
|
+
const acting = useActing(forge, digest?.date, reload, hurry);
|
|
411
|
+
const reading = reply?.reading;
|
|
412
|
+
const isReading = acting.refreshing || !!reading;
|
|
413
|
+
const refreshBtn = /* @__PURE__ */ jsx2(Btn, { label: isReading ? "Reading\u2026" : "Refresh", style: ghostStyle, disabled: isReading, onClick: acting.refresh });
|
|
324
414
|
const failure = (text) => /* @__PURE__ */ jsxs2("span", { style: { color: "var(--red)" }, children: [
|
|
325
415
|
"\xB7 ",
|
|
326
416
|
text
|
|
@@ -330,16 +420,36 @@ function Banner({ forge }) {
|
|
|
330
420
|
"\xB7 ",
|
|
331
421
|
notes
|
|
332
422
|
] });
|
|
423
|
+
const problems = groupProblems(digest?.problems ?? []);
|
|
424
|
+
const problemRows = problems.length > 0 && /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "6px", marginBottom: "8px" }, children: problems.map((g) => /* @__PURE__ */ jsx2(ProblemRow, { group: g, acting }, g.account)) });
|
|
425
|
+
const problemsLink = problems.length > 0 && /* @__PURE__ */ jsxs2("button", { type: "button", onClick: () => forge.openPage(), style: { font: "inherit", fontSize: "inherit", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--orange)" }, children: [
|
|
426
|
+
"\xB7 ",
|
|
427
|
+
problemsLabel(problems.length)
|
|
428
|
+
] });
|
|
333
429
|
if (!reply && !error) return null;
|
|
334
430
|
if (reply && !reply.enabled) {
|
|
335
431
|
return /* @__PURE__ */ jsx2(Strip, { title: "Today", actions: /* @__PURE__ */ jsx2(Btn, { label: "Turn on", style: primaryStyle, disabled: acting.busy, onClick: () => acting.run(() => forge.action("enable")) }), children: /* @__PURE__ */ jsx2("span", { children: "\xB7 Linear, Slack and GitHub each morning" }) });
|
|
336
432
|
}
|
|
433
|
+
if (reply && isReading && (!digest || digest.items.length === 0)) {
|
|
434
|
+
return shell(
|
|
435
|
+
/* @__PURE__ */ jsxs2("div", { style: { padding: "14px 18px", display: "flex", flexDirection: "column", gap: "12px" }, children: [
|
|
436
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
437
|
+
/* @__PURE__ */ jsx2("span", { style: { color: "var(--orange)" }, children: "\u2600\uFE0E" }),
|
|
438
|
+
/* @__PURE__ */ jsx2(ReadingLine, { reading }),
|
|
439
|
+
/* @__PURE__ */ jsx2("span", { style: { marginLeft: "auto" }, children: refreshBtn })
|
|
440
|
+
] }),
|
|
441
|
+
!digest && /* @__PURE__ */ jsx2(SkeletonRows, {}),
|
|
442
|
+
problemRows
|
|
443
|
+
] })
|
|
444
|
+
);
|
|
445
|
+
}
|
|
337
446
|
if (!reply || !digest || digest.items.length === 0) {
|
|
338
447
|
return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, children: [
|
|
339
448
|
!reply ? failure(loadFailedLine(error)) : digest?.error ? failure(failedLine(digest.error)) : digest && /* @__PURE__ */ jsxs2("span", { children: [
|
|
340
449
|
"\xB7 nothing new since ",
|
|
341
450
|
clock(new Date(digest.readAt))
|
|
342
451
|
] }),
|
|
452
|
+
problemsLink,
|
|
343
453
|
note
|
|
344
454
|
] });
|
|
345
455
|
}
|
|
@@ -365,6 +475,7 @@ function Banner({ forge }) {
|
|
|
365
475
|
" sent"
|
|
366
476
|
] }),
|
|
367
477
|
digest.error && failure(failedLine(digest.error)),
|
|
478
|
+
problemsLink,
|
|
368
479
|
note
|
|
369
480
|
] });
|
|
370
481
|
}
|
|
@@ -377,7 +488,7 @@ function Banner({ forge }) {
|
|
|
377
488
|
/* @__PURE__ */ jsx2("div", { style: { width: "34px", height: "34px", borderRadius: "10px", display: "grid", placeItems: "center", background: "linear-gradient(160deg, #ffb340, #ff7a1a)", boxShadow: "0 4px 14px rgba(255, 140, 30, .35)", fontSize: "17px" }, children: "\u2600\uFE0E" }),
|
|
378
489
|
/* @__PURE__ */ jsxs2("div", { children: [
|
|
379
490
|
/* @__PURE__ */ jsx2("h3", { style: { margin: 0, fontSize: "15px", fontWeight: 650, letterSpacing: "-.01em" }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
|
|
380
|
-
/* @__PURE__ */ jsx2("div", { style: { color: "var(--ink-2)", fontSize: "12px", marginTop: "1px" }, children: readLine(digest) })
|
|
491
|
+
/* @__PURE__ */ jsx2("div", { style: { color: "var(--ink-2)", fontSize: "12px", marginTop: "1px" }, children: isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : readLine(digest) })
|
|
381
492
|
] }),
|
|
382
493
|
/* @__PURE__ */ jsxs2("div", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
383
494
|
refreshBtn,
|
|
@@ -403,6 +514,7 @@ function Banner({ forge }) {
|
|
|
403
514
|
] }),
|
|
404
515
|
digest.error && /* @__PURE__ */ jsx2("div", { style: { marginBottom: "8px", fontSize: "11.5px", color: "var(--red)" }, children: failedLine(digest.error) }),
|
|
405
516
|
notes && /* @__PURE__ */ jsx2("div", { style: { marginBottom: "8px", fontSize: "11.5px", color: "var(--ink-3)" }, children: notes }),
|
|
517
|
+
problemRows,
|
|
406
518
|
/* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: shown.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id)) }),
|
|
407
519
|
/* @__PURE__ */ jsx2("div", { style: { marginTop: "10px", fontSize: "11.5px", color: "var(--ink-3)" }, children: "Research starts on its own (limited per day). The rest waits for your ok." })
|
|
408
520
|
] })
|
|
@@ -87,6 +87,22 @@ function extractJson(out) {
|
|
|
87
87
|
throw new Error("reader output is not valid JSON");
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
function parseReaderProblems(out) {
|
|
91
|
+
let root;
|
|
92
|
+
try {
|
|
93
|
+
root = extractJson(out);
|
|
94
|
+
} catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
if (!isRecord(root) || !Array.isArray(root.problems)) return [];
|
|
98
|
+
return root.problems.filter((p) => typeof p === "string" && /\b(slack|linear)\b/i.test(p) && !/^\s*github/i.test(p)).slice(0, 5).map((p) => p.replace(/\s+/g, " ").trim().slice(0, 160));
|
|
99
|
+
}
|
|
100
|
+
function toProblem(account, text2) {
|
|
101
|
+
const m = /^(slack|linear|reader)\s*:\s*(.+)$/i.exec(text2);
|
|
102
|
+
if (m) return { account, source: m[1].toLowerCase(), reason: m[2] };
|
|
103
|
+
const named = /\b(slack|linear)\b/i.exec(text2);
|
|
104
|
+
return { account, source: named ? named[1].toLowerCase() : "reader", reason: text2 };
|
|
105
|
+
}
|
|
90
106
|
function parseReaderOutput(out, known) {
|
|
91
107
|
const root = extractJson(out);
|
|
92
108
|
if (!isRecord(root) || !Array.isArray(root.items)) throw new Error("reader output needs an items array");
|
|
@@ -198,8 +214,9 @@ Item kinds (to-task | issue | request | research | review), exactly one per item
|
|
|
198
214
|
- GitHub events with no matching session: a ci-failure becomes an issue (link is the pull request url, quote lists the failing checks); a mention or assigned event becomes a request or an issue; a comment or review on my pull request with no session becomes a request. Skip events that need nothing from me.
|
|
199
215
|
|
|
200
216
|
Answer with ONLY a JSON object, no prose and no code fence:
|
|
201
|
-
{ "items": [ { "source": "linear" | "slack" | "github", "kind": "to-task" | "issue" | "request" | "research" | "review", "title": string, "who": string, "where": string, "when": ISO time of the latest activity, "quote"?: string, "link": string (permalink, issue URL or pull request URL), "issueKey"?: string, "targetSession"?: { "project": string, "sessionDir": string }, "project"?: string } ] }
|
|
202
|
-
Every item needs a link. Use an empty items array when there is nothing new
|
|
217
|
+
{ "items": [ { "source": "linear" | "slack" | "github", "kind": "to-task" | "issue" | "request" | "research" | "review", "title": string, "who": string, "where": string, "when": ISO time of the latest activity, "quote"?: string, "link": string (permalink, issue URL or pull request URL), "issueKey"?: string, "targetSession"?: { "project": string, "sessionDir": string }, "project"?: string } ], "problems"?: [ string ] }
|
|
218
|
+
Every item needs a link. Use an empty items array when there is nothing new.
|
|
219
|
+
Problems are only for the Slack and Linear tools: if one is missing, still connecting or fails, do not report "nothing new" for it, add "slack: <short reason>" or "linear: <short reason>" to problems. Never put anything else in problems (GitHub is given to you as data, not a tool).`;
|
|
203
220
|
}
|
|
204
221
|
|
|
205
222
|
// src/github.ts
|
|
@@ -259,7 +276,8 @@ async function fetchGithub(ctx, since, deadlineMs = DEADLINE_MS) {
|
|
|
259
276
|
const [user, mine, asked, issues, notes] = await Promise.all([
|
|
260
277
|
gh(ctx, ["api", "user"]),
|
|
261
278
|
search("--author=@me"),
|
|
262
|
-
|
|
279
|
+
// reviews asked of me, not of a team I belong to
|
|
280
|
+
search("user-review-requested:@me"),
|
|
263
281
|
search("--assignee=@me", "issues"),
|
|
264
282
|
gh(ctx, ["api", `notifications?since=${encodeURIComponent(since)}`, "--paginate"])
|
|
265
283
|
]);
|
|
@@ -298,7 +316,8 @@ async function fetchGithub(ctx, since, deadlineMs = DEADLINE_MS) {
|
|
|
298
316
|
items.push({ type: "mention", repo: n.repository.full_name, number: page.number, title: n.subject.title, url: page.url, pr: page.url, when: n.updated_at });
|
|
299
317
|
}
|
|
300
318
|
}
|
|
301
|
-
|
|
319
|
+
const requested = asked.length >= MAX_PRS ? void 0 : asked.map((pr) => pr.url);
|
|
320
|
+
return unread ? { items, requested, error: `${unread} pull request${unread === 1 ? "" : "s"} could not be read` } : { items, requested };
|
|
302
321
|
} catch (e) {
|
|
303
322
|
return { items: [], error: errorMessage(e) };
|
|
304
323
|
}
|
|
@@ -311,6 +330,9 @@ function localDate(d) {
|
|
|
311
330
|
const p = (n) => String(n).padStart(2, "0");
|
|
312
331
|
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`;
|
|
313
332
|
}
|
|
333
|
+
var timing = { retryMs: 15e3 };
|
|
334
|
+
var progress;
|
|
335
|
+
var readingNow = () => progress ? { startedAt: progress.startedAt, accounts: { ...progress.accounts } } : void 0;
|
|
314
336
|
var chain = Promise.resolve();
|
|
315
337
|
function locked(fn) {
|
|
316
338
|
const next = chain.then(fn, fn);
|
|
@@ -342,7 +364,7 @@ async function readAccounts(ctx) {
|
|
|
342
364
|
const set = typeof ctx.settings.accounts === "string" ? ctx.settings.accounts : "";
|
|
343
365
|
const wanted = set.split(",").map((n) => n.trim()).filter(Boolean);
|
|
344
366
|
const names = wanted.length ? claude.filter((n) => wanted.includes(n)) : claude;
|
|
345
|
-
if (!names.length) throw new
|
|
367
|
+
if (!names.length) throw new ModuleError("bad_request", wanted.length ? `none of ${wanted.join(", ")} is a Claude account` : "no CW account to read with");
|
|
346
368
|
return names;
|
|
347
369
|
}
|
|
348
370
|
function checkGithub(items, fetched, toReview) {
|
|
@@ -367,13 +389,31 @@ async function readAccount(ctx, account, o) {
|
|
|
367
389
|
const github = (await o.github)?.items ?? [];
|
|
368
390
|
const prompt = buildPrompt({ since: o.since, sessions, projects, github });
|
|
369
391
|
const model = typeof ctx.settings.model === "string" && ctx.settings.model ? ctx.settings.model : void 0;
|
|
370
|
-
const
|
|
392
|
+
const ask = () => ctx.agent.run({ account, prompt, model, allowedTools: READER_TOOLS, timeoutMs: 10 * 60 * 1e3 });
|
|
393
|
+
let out = await ask();
|
|
394
|
+
if (parseReaderProblems(out.text).length) {
|
|
395
|
+
await new Promise((r) => setTimeout(r, timing.retryMs));
|
|
396
|
+
out = await ask();
|
|
397
|
+
}
|
|
398
|
+
const problems = parseReaderProblems(out.text).map((p) => toProblem(account, p));
|
|
371
399
|
const fetched = new Set(github.map((e) => e.pr));
|
|
372
400
|
const toReview = new Set(github.filter((e) => e.type === "review-request").map((e) => e.pr));
|
|
373
401
|
const items = parseReaderOutput(out.text, { projects, sessions: sessions.map((s) => `${s.project}::${s.sessionDir}`), account });
|
|
374
402
|
const placed = checkGithub(items, fetched, toReview).map((i) => i.source === "github" ? { ...i, account: o.owners[i.project ?? i.targetSession?.project ?? ""] } : i);
|
|
375
403
|
const fresh = dedupe(collapse(placed), o.handled);
|
|
376
|
-
return github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh;
|
|
404
|
+
return { items: github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh, problems };
|
|
405
|
+
}
|
|
406
|
+
async function readOne(ctx, account, o) {
|
|
407
|
+
const finish = (r) => {
|
|
408
|
+
if (progress) progress.accounts[account] = r.problems.length ? "problem" : "done";
|
|
409
|
+
return r;
|
|
410
|
+
};
|
|
411
|
+
try {
|
|
412
|
+
return finish({ account, ...await readAccount(ctx, account, o) });
|
|
413
|
+
} catch (e) {
|
|
414
|
+
const error = errorMessage(e);
|
|
415
|
+
return finish({ account, items: [], problems: [{ account, source: "reader", reason: error.replace(/\s+/g, " ").trim().slice(0, 160) }], error });
|
|
416
|
+
}
|
|
377
417
|
}
|
|
378
418
|
async function reread(ctx, now, notes) {
|
|
379
419
|
const lastReadAt = await ctx.storage.get("lastReadAt");
|
|
@@ -386,20 +426,15 @@ async function reread(ctx, now, notes) {
|
|
|
386
426
|
readAccounts(ctx)
|
|
387
427
|
]);
|
|
388
428
|
const owners = ownersOf(projects);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
return { account, items: await readAccount(ctx, account, { since, sessions, projects, owners, github: n === 0 ? github : void 0, handled: handled ?? {} }) };
|
|
392
|
-
} catch (e) {
|
|
393
|
-
return { account, items: [], error: errorMessage(e) };
|
|
394
|
-
}
|
|
395
|
-
}));
|
|
429
|
+
if (progress) progress.accounts = Object.fromEntries(accounts.map((a) => [a, "reading"]));
|
|
430
|
+
const results = await Promise.all(accounts.map((account, n) => readOne(ctx, account, { since, sessions, projects, owners, github: n === 0 ? github : void 0, handled: handled ?? {} })));
|
|
396
431
|
const gh2 = await github;
|
|
397
432
|
if (gh2.error) notes.push(`GitHub: ${gh2.error}`);
|
|
398
433
|
if (results[0].error && gh2.items.length) notes.push("GitHub: not read");
|
|
399
434
|
const failed = results.filter((r) => r.error);
|
|
400
435
|
if (failed.length === results.length) throw new Error(failed.length === 1 ? failed[0].error : failed.map((f) => `${f.account}: ${f.error}`).join("; "));
|
|
401
|
-
|
|
402
|
-
return collapse(results.flatMap((r) => r.items));
|
|
436
|
+
const requested = gh2.error ? void 0 : new Set(gh2.requested ?? gh2.items.filter((e) => e.type === "review-request").map((e) => e.pr));
|
|
437
|
+
return { items: collapse(results.flatMap((r) => r.items)), problems: results.flatMap((r) => r.problems), requested };
|
|
403
438
|
}
|
|
404
439
|
async function rememberHandled(ctx, items, now) {
|
|
405
440
|
const old = await ctx.storage.get("handled") ?? {};
|
|
@@ -408,6 +443,10 @@ async function rememberHandled(ctx, items, now) {
|
|
|
408
443
|
for (const i of items) next[i.id] = i.when;
|
|
409
444
|
await ctx.storage.set("handled", next);
|
|
410
445
|
}
|
|
446
|
+
function dropStaleReviews(items, requested) {
|
|
447
|
+
if (!requested) return items;
|
|
448
|
+
return items.filter((i) => !(i.kind === "review" && i.state === "proposed" && !requested.has(githubPage(i.link) ?? i.link)));
|
|
449
|
+
}
|
|
411
450
|
function merge(existing, fresh) {
|
|
412
451
|
const byId = new Map(existing.map((i) => [i.id, i]));
|
|
413
452
|
const out = [...existing];
|
|
@@ -426,20 +465,24 @@ var reading;
|
|
|
426
465
|
var OFF_MESSAGE = "Today is off";
|
|
427
466
|
async function readNow(ctx, now) {
|
|
428
467
|
if (!await isEnabled(ctx)) throw new ModuleError("bad_request", OFF_MESSAGE);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
468
|
+
if (!reading) {
|
|
469
|
+
progress = { startedAt: (/* @__PURE__ */ new Date()).toISOString(), accounts: {} };
|
|
470
|
+
reading = doRead(ctx, now).finally(() => {
|
|
471
|
+
reading = void 0;
|
|
472
|
+
progress = void 0;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
432
475
|
return reading;
|
|
433
476
|
}
|
|
434
477
|
async function doRead(ctx, now) {
|
|
435
478
|
const date = localDate(now);
|
|
436
479
|
const notes = [];
|
|
437
480
|
try {
|
|
438
|
-
const fresh = await reread(ctx, now, notes);
|
|
481
|
+
const { items: fresh, problems, requested } = await reread(ctx, now, notes);
|
|
439
482
|
const lastReadAt = await ctx.storage.get("lastReadAt");
|
|
440
483
|
await locked(async () => {
|
|
441
484
|
const prev = await loadDigest(ctx, date);
|
|
442
|
-
const items = merge(prev?.items ?? [], fresh);
|
|
485
|
+
const items = dropStaleReviews(merge(prev?.items ?? [], fresh), requested);
|
|
443
486
|
const known = new Set((prev?.items ?? []).map((i) => i.id));
|
|
444
487
|
if (items.some((i) => i.state === "proposed" && !known.has(i.id))) await ctx.storage.delete(`folded/${date}`);
|
|
445
488
|
await saveDigest(ctx, {
|
|
@@ -448,7 +491,8 @@ async function doRead(ctx, now) {
|
|
|
448
491
|
since: prev?.since ?? lastReadAt ?? new Date(now.getTime() - DAY).toISOString(),
|
|
449
492
|
items,
|
|
450
493
|
autoStarted: prev?.autoStarted ?? {},
|
|
451
|
-
...notes.length ? { notes } : {}
|
|
494
|
+
...notes.length ? { notes } : {},
|
|
495
|
+
...problems.length ? { problems } : {}
|
|
452
496
|
});
|
|
453
497
|
await rememberHandled(ctx, fresh, now);
|
|
454
498
|
await ctx.storage.set("lastReadAt", now.toISOString());
|
|
@@ -460,6 +504,42 @@ async function doRead(ctx, now) {
|
|
|
460
504
|
return keepWithError(ctx, now, errorMessage(e), notes);
|
|
461
505
|
}
|
|
462
506
|
}
|
|
507
|
+
async function retryAccount(ctx, account, now) {
|
|
508
|
+
if (!await isEnabled(ctx)) throw new ModuleError("bad_request", OFF_MESSAGE);
|
|
509
|
+
if (!(await readAccounts(ctx)).includes(account)) throw new ModuleError("bad_request", `${account} is not an account Today reads`);
|
|
510
|
+
if (reading) throw new ModuleError("bad_request", "a reading is running");
|
|
511
|
+
const date = localDate(now);
|
|
512
|
+
const prev = await loadDigest(ctx, date);
|
|
513
|
+
if (!prev) throw new ModuleError("not_found", `no digest for ${date}`);
|
|
514
|
+
progress ??= { startedAt: (/* @__PURE__ */ new Date()).toISOString(), accounts: {} };
|
|
515
|
+
progress.accounts[account] = "reading";
|
|
516
|
+
const mine = progress;
|
|
517
|
+
let result;
|
|
518
|
+
try {
|
|
519
|
+
const [sessions, projects, handled] = await Promise.all([ctx.sessions.list(), ctx.projects.list(), ctx.storage.get("handled")]);
|
|
520
|
+
result = await readOne(ctx, account, { since: prev.since, sessions, projects, owners: ownersOf(projects), handled: handled ?? {} });
|
|
521
|
+
} finally {
|
|
522
|
+
if (progress === mine && !Object.values(mine.accounts).includes("reading")) progress = void 0;
|
|
523
|
+
}
|
|
524
|
+
await locked(async () => {
|
|
525
|
+
const digest = await loadDigest(ctx, date) ?? prev;
|
|
526
|
+
const items = merge(digest.items, result.items);
|
|
527
|
+
const known = new Set(digest.items.map((i) => i.id));
|
|
528
|
+
if (items.some((i) => i.state === "proposed" && !known.has(i.id))) await ctx.storage.delete(`folded/${date}`);
|
|
529
|
+
const problems = [...(digest.problems ?? []).filter((p) => p.account !== account), ...result.problems];
|
|
530
|
+
const next = { ...digest, items };
|
|
531
|
+
if (problems.length) next.problems = problems;
|
|
532
|
+
else delete next.problems;
|
|
533
|
+
await saveDigest(ctx, next);
|
|
534
|
+
await rememberHandled(ctx, result.items, now);
|
|
535
|
+
});
|
|
536
|
+
await autoResearch(ctx, date);
|
|
537
|
+
return await loadDigest(ctx, date);
|
|
538
|
+
}
|
|
539
|
+
async function reconnectAccount(ctx, account) {
|
|
540
|
+
if (!(await readAccounts(ctx)).includes(account)) throw new ModuleError("bad_request", `${account} is not an account Today reads`);
|
|
541
|
+
return ctx.cw.start({ type: "general", account, task: `Reconnect connectors (${account})`, prompt: "/mcp" });
|
|
542
|
+
}
|
|
463
543
|
function keepWithError(ctx, now, error, notes) {
|
|
464
544
|
return locked(async () => {
|
|
465
545
|
const date = localDate(now);
|
|
@@ -673,7 +753,8 @@ async function digestFor(ctx, date) {
|
|
|
673
753
|
if (latest) [digest, folded] = await read(wanted = latest);
|
|
674
754
|
}
|
|
675
755
|
const enabled = await isEnabled(ctx);
|
|
676
|
-
|
|
756
|
+
const reading2 = readingNow();
|
|
757
|
+
return { ...digest ? { digest, folded, enabled } : { digest: null, folded: false, enabled }, ...reading2 ? { reading: reading2 } : {} };
|
|
677
758
|
}
|
|
678
759
|
var server_default = defineModule({
|
|
679
760
|
routes: [
|
|
@@ -703,6 +784,20 @@ var server_default = defineModule({
|
|
|
703
784
|
effect: "local",
|
|
704
785
|
run: (_input, ctx) => readNow(ctx, /* @__PURE__ */ new Date())
|
|
705
786
|
}),
|
|
787
|
+
defineAction({
|
|
788
|
+
id: "retry-account",
|
|
789
|
+
label: "Retry",
|
|
790
|
+
effect: "local",
|
|
791
|
+
input: { account: { type: "string", required: true } },
|
|
792
|
+
run: (input, ctx) => retryAccount(ctx, input.account, /* @__PURE__ */ new Date())
|
|
793
|
+
}),
|
|
794
|
+
defineAction({
|
|
795
|
+
id: "reconnect",
|
|
796
|
+
label: "Reconnect",
|
|
797
|
+
effect: "local",
|
|
798
|
+
input: { account: { type: "string", required: true } },
|
|
799
|
+
run: (input, ctx) => reconnectAccount(ctx, input.account)
|
|
800
|
+
}),
|
|
706
801
|
defineAction({
|
|
707
802
|
id: "enable",
|
|
708
803
|
label: "Turn on",
|
|
@@ -20,6 +20,19 @@ function projectsFor({ names, owners }, account) {
|
|
|
20
20
|
var failedLine = (error) => `Last reading failed: ${error}`;
|
|
21
21
|
var loadFailedLine = (error) => `Can't load Today: ${error}`;
|
|
22
22
|
var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
|
|
23
|
+
var SOURCE_NAME = { slack: "Slack", linear: "Linear", reader: "Reader" };
|
|
24
|
+
function sourcesLabel(sources) {
|
|
25
|
+
const names = ["slack", "linear", "reader"].filter((s) => sources.includes(s)).map((s) => SOURCE_NAME[s]);
|
|
26
|
+
return names.join(" and ");
|
|
27
|
+
}
|
|
28
|
+
function groupProblems(problems) {
|
|
29
|
+
const accounts = [...new Set(problems.map((p) => p.account))];
|
|
30
|
+
return accounts.map((account) => {
|
|
31
|
+
const mine = problems.filter((p) => p.account === account);
|
|
32
|
+
return { account, label: sourcesLabel(mine.map((p) => p.source)), reasons: mine.map((p) => `${SOURCE_NAME[p.source]}: ${p.reason}`) };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
|
|
23
36
|
var GROUPS = [
|
|
24
37
|
{ title: "In open tasks", pick: (i) => i.kind === "to-task" },
|
|
25
38
|
{ title: "New", pick: (i) => i.kind === "issue" || i.kind === "request" },
|
|
@@ -59,6 +72,7 @@ function AccountChip({ account }) {
|
|
|
59
72
|
function useDigest(forge, path = "/digest") {
|
|
60
73
|
const [reply, setReply] = useState(null);
|
|
61
74
|
const [error, setError] = useState(null);
|
|
75
|
+
const [hurried, hurry] = useState(false);
|
|
62
76
|
const latest = useRef(0);
|
|
63
77
|
const load = useCallback(async () => {
|
|
64
78
|
const mine = ++latest.current;
|
|
@@ -71,19 +85,20 @@ function useDigest(forge, path = "/digest") {
|
|
|
71
85
|
if (mine === latest.current) setError(errorMessage(e));
|
|
72
86
|
}
|
|
73
87
|
}, [forge, path]);
|
|
88
|
+
const fast = hurried || !!reply?.reading;
|
|
74
89
|
useEffect(() => {
|
|
75
90
|
void load();
|
|
76
91
|
const poll = () => {
|
|
77
92
|
if (!document.hidden) void load();
|
|
78
93
|
};
|
|
79
|
-
const t = setInterval(poll, 6e4);
|
|
94
|
+
const t = setInterval(poll, fast ? 3e3 : 6e4);
|
|
80
95
|
document.addEventListener("visibilitychange", poll);
|
|
81
96
|
return () => {
|
|
82
97
|
clearInterval(t);
|
|
83
98
|
document.removeEventListener("visibilitychange", poll);
|
|
84
99
|
};
|
|
85
|
-
}, [load]);
|
|
86
|
-
return { reply, error, reload: load };
|
|
100
|
+
}, [load, fast]);
|
|
101
|
+
return { reply, error, reload: load, hurry };
|
|
87
102
|
}
|
|
88
103
|
function useProjects(forge) {
|
|
89
104
|
const [projects, setProjects] = useState(EMPTY_PROJECTS);
|
|
@@ -93,9 +108,11 @@ function useProjects(forge) {
|
|
|
93
108
|
}, [forge]);
|
|
94
109
|
return projects;
|
|
95
110
|
}
|
|
96
|
-
function useActing(forge, date, reload) {
|
|
111
|
+
function useActing(forge, date, reload, hurry = () => {
|
|
112
|
+
}) {
|
|
97
113
|
const [busy, setBusy] = useState(false);
|
|
98
114
|
const [refreshing, setRefreshing] = useState(false);
|
|
115
|
+
const [retrying, setRetrying] = useState(null);
|
|
99
116
|
const reading = useRef(false);
|
|
100
117
|
const guarded = async (fn) => {
|
|
101
118
|
try {
|
|
@@ -118,11 +135,27 @@ function useActing(forge, date, reload) {
|
|
|
118
135
|
if (reading.current) return;
|
|
119
136
|
reading.current = true;
|
|
120
137
|
setRefreshing(true);
|
|
138
|
+
hurry(true);
|
|
121
139
|
await guarded(() => forge.action("refresh"));
|
|
140
|
+
hurry(false);
|
|
122
141
|
reading.current = false;
|
|
123
142
|
setRefreshing(false);
|
|
124
143
|
};
|
|
125
|
-
|
|
144
|
+
const retry = async (account) => {
|
|
145
|
+
if (busy) return;
|
|
146
|
+
setBusy(true);
|
|
147
|
+
setRetrying(account);
|
|
148
|
+
hurry(true);
|
|
149
|
+
await guarded(() => forge.action("retry-account", { account }));
|
|
150
|
+
hurry(false);
|
|
151
|
+
setRetrying(null);
|
|
152
|
+
setBusy(false);
|
|
153
|
+
};
|
|
154
|
+
const reconnect = (account) => run(async () => {
|
|
155
|
+
const s = await forge.action("reconnect", { account });
|
|
156
|
+
if (s) forge.openSession(s.project, s.sessionDir);
|
|
157
|
+
});
|
|
158
|
+
return { busy, refreshing, retrying, retry, reconnect, run, act, refresh };
|
|
126
159
|
}
|
|
127
160
|
function dayOf(date) {
|
|
128
161
|
const [y, m, d] = date.split("-").map(Number);
|
|
@@ -274,16 +307,74 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
274
307
|
] })
|
|
275
308
|
] });
|
|
276
309
|
};
|
|
310
|
+
var READING_CSS = `
|
|
311
|
+
@keyframes today-spin { to { transform: rotate(360deg) } }
|
|
312
|
+
@keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
|
|
313
|
+
.today-spin { animation: today-spin .8s linear infinite }
|
|
314
|
+
.today-pulse { animation: today-pulse 1.4s ease-in-out infinite }
|
|
315
|
+
@media (prefers-reduced-motion: reduce) { .today-spin, .today-pulse { animation: none } }`;
|
|
316
|
+
function useReadingStyles() {
|
|
317
|
+
if (typeof document !== "undefined" && !document.getElementById("today-reading-css")) {
|
|
318
|
+
const el = document.createElement("style");
|
|
319
|
+
el.id = "today-reading-css";
|
|
320
|
+
el.textContent = READING_CSS;
|
|
321
|
+
document.head.appendChild(el);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function Spinner() {
|
|
325
|
+
return /* @__PURE__ */ jsx("i", { class: "today-spin", style: { display: "inline-block", width: "10px", height: "10px", borderRadius: "50%", border: "2px solid var(--hair-2)", borderTopColor: "var(--blue)", boxSizing: "border-box" } });
|
|
326
|
+
}
|
|
327
|
+
function ReadingLine({ reading }) {
|
|
328
|
+
useReadingStyles();
|
|
329
|
+
const accounts = Object.entries(reading?.accounts ?? {});
|
|
330
|
+
return /* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "12px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
331
|
+
/* @__PURE__ */ jsx("b", { class: "today-pulse", style: { fontWeight: 600, color: "var(--ink)" }, children: accounts.length ? "Reading" : "Reading\u2026" }),
|
|
332
|
+
accounts.map(([account, state], n) => /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px" }, children: [
|
|
333
|
+
n > 0 && /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" }),
|
|
334
|
+
state === "reading" ? /* @__PURE__ */ jsx(Spinner, {}) : state === "done" ? /* @__PURE__ */ jsx("span", { style: { color: "var(--green)" }, children: "\u2713" }) : /* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
335
|
+
account
|
|
336
|
+
] }, account)),
|
|
337
|
+
accounts.length > 0 && /* @__PURE__ */ jsx("span", { children: "\u2026" })
|
|
338
|
+
] });
|
|
339
|
+
}
|
|
340
|
+
function SkeletonRows() {
|
|
341
|
+
useReadingStyles();
|
|
342
|
+
return /* @__PURE__ */ jsx("div", { "aria-hidden": "true", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [0, 1, 2].map((n) => /* @__PURE__ */ jsxs("div", { class: "today-pulse", style: { display: "flex", alignItems: "center", gap: "12px", padding: "10px 12px", borderRadius: "10px", background: "var(--elev)", border: "1px solid var(--hair)", animationDelay: `${n * 0.15}s` }, children: [
|
|
343
|
+
/* @__PURE__ */ jsx("div", { style: { width: "30px", height: "30px", borderRadius: "8px", background: "var(--hair)" } }),
|
|
344
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
345
|
+
/* @__PURE__ */ jsx("div", { style: { height: "9px", width: `${70 - n * 12}%`, borderRadius: "5px", background: "var(--hair)" } }),
|
|
346
|
+
/* @__PURE__ */ jsx("div", { style: { height: "8px", width: "35%", borderRadius: "5px", background: "var(--hair)" } })
|
|
347
|
+
] })
|
|
348
|
+
] }, n)) });
|
|
349
|
+
}
|
|
350
|
+
function ProblemRow({ group, acting, details = false }) {
|
|
351
|
+
const mine = acting.retrying === group.account;
|
|
352
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", title: group.reasons.join("\n"), style: { padding: "7px 10px", borderRadius: "10px", fontSize: "12px", color: "var(--ink-2)", background: soft("--orange", 10), border: `1px solid ${soft("--orange", 35)}` }, children: [
|
|
353
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
354
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
355
|
+
/* @__PURE__ */ jsx("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: groupLine(group) }),
|
|
356
|
+
/* @__PURE__ */ jsxs("span", { style: { marginLeft: "auto", display: "flex", gap: "8px", flexShrink: 0 }, children: [
|
|
357
|
+
/* @__PURE__ */ jsx(Btn, { label: mine ? "Reading\u2026" : "Retry", disabled: acting.busy, onClick: () => acting.retry(group.account) }),
|
|
358
|
+
/* @__PURE__ */ jsx(Btn, { label: "Reconnect", style: ghostStyle, disabled: acting.busy, onClick: () => acting.reconnect(group.account) })
|
|
359
|
+
] })
|
|
360
|
+
] }),
|
|
361
|
+
details && /* @__PURE__ */ jsx("ul", { style: { margin: "6px 0 0 22px", padding: 0, color: "var(--ink-3)", fontSize: "11.5px" }, children: group.reasons.map((r) => /* @__PURE__ */ jsx("li", { children: r }, r)) })
|
|
362
|
+
] });
|
|
363
|
+
}
|
|
277
364
|
|
|
278
365
|
// src/view.tsx
|
|
279
366
|
import { jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
280
367
|
function View({ forge }) {
|
|
281
368
|
const [days, setDays] = useState2([]);
|
|
282
369
|
const [day, setDay] = useState2(null);
|
|
283
|
-
const { reply, error, reload } = useDigest(forge, day ? `/digest/${day}` : "/digest");
|
|
370
|
+
const { reply, error, reload, hurry } = useDigest(forge, day ? `/digest/${day}` : "/digest");
|
|
284
371
|
const projects = useProjects(forge);
|
|
285
372
|
const digest = reply?.digest;
|
|
286
|
-
const acting = useActing(forge, digest?.date, reload);
|
|
373
|
+
const acting = useActing(forge, digest?.date, reload, hurry);
|
|
374
|
+
const reading = reply?.reading;
|
|
375
|
+
const isReading = acting.refreshing || !!reading;
|
|
376
|
+
const [details, setDetails] = useState2(false);
|
|
377
|
+
const problems = groupProblems(digest?.problems ?? []);
|
|
287
378
|
const notes = notesLine(digest?.notes);
|
|
288
379
|
const enabled = reply?.enabled === true;
|
|
289
380
|
useEffect2(() => {
|
|
@@ -294,16 +385,20 @@ function View({ forge }) {
|
|
|
294
385
|
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
|
|
295
386
|
days.length > 0 && /* @__PURE__ */ jsx2("select", { "aria-label": "Day", value: digest?.date ?? "", onChange: (e) => setDay(e.target.value), style: { font: "inherit", fontSize: "12.5px", padding: "5px 8px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: days.map((d) => /* @__PURE__ */ jsx2("option", { value: d, children: d }, d)) }),
|
|
296
387
|
digest && /* @__PURE__ */ jsx2("b", { style: { fontSize: "13px", fontWeight: 600 }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
|
|
297
|
-
/* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
|
|
388
|
+
isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : /* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
|
|
298
389
|
/* @__PURE__ */ jsxs2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
299
|
-
enabled && /* @__PURE__ */ jsx2(ActionButton, { label: "Read now", variant: "primary", size: "sm", loading:
|
|
390
|
+
enabled && /* @__PURE__ */ jsx2(ActionButton, { label: isReading ? "Reading\u2026" : "Read now", variant: "primary", size: "sm", disabled: isReading, loading: isReading, onClick: acting.refresh }),
|
|
300
391
|
reply && /* @__PURE__ */ jsx2(ActionButton, { label: enabled ? "Turn off" : "Turn on", variant: enabled ? "secondary" : "primary", size: "sm", disabled: acting.busy, onClick: () => acting.run(() => forge.action(enabled ? "disable" : "enable")) })
|
|
301
392
|
] })
|
|
302
393
|
] }),
|
|
303
394
|
reply && !enabled && /* @__PURE__ */ jsx2("div", { style: { padding: "12px 14px", borderRadius: "10px", fontSize: "12.5px", lineHeight: 1.5, color: "var(--ink-2)", background: "var(--card)", border: "1px solid var(--hair)", maxWidth: "640px" }, children: "Today is off. Turned on, it reads your Linear, Slack and GitHub each morning and whenever you press Read now. Each reading spends your account's usage. Research it proposes can start sessions on its own, a few a day." }),
|
|
304
395
|
(error || digest?.error) && /* @__PURE__ */ jsx2("div", { style: { padding: "10px 12px", borderRadius: "10px", fontSize: "12px", color: "var(--red)", background: "var(--card)", border: "1px solid color-mix(in srgb, var(--red) 45%, var(--hair))" }, children: error ? loadFailedLine(error) : failedLine(digest.error) }),
|
|
396
|
+
problems.length > 0 && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
397
|
+
problems.map((g) => /* @__PURE__ */ jsx2(ProblemRow, { group: g, acting, details }, g.account)),
|
|
398
|
+
/* @__PURE__ */ jsx2("button", { type: "button", "aria-expanded": details, onClick: () => setDetails(!details), style: { alignSelf: "flex-start", font: "inherit", fontSize: "11.5px", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--ink-3)" }, children: details ? "Hide details" : "Details" })
|
|
399
|
+
] }),
|
|
305
400
|
notes && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12px", color: "var(--ink-3)" }, children: notes }),
|
|
306
|
-
!digest || digest.items.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Read now to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
401
|
+
!digest && isReading ? /* @__PURE__ */ jsx2(SkeletonRows, {}) : !digest || digest.items.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Read now to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
307
402
|
account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
|
|
308
403
|
sections2.map(({ title, items }) => /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
309
404
|
/* @__PURE__ */ jsxs2("h4", { style: { margin: "4px 0", fontSize: "11px", fontWeight: 600, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" }, children: [
|