forge-cw 0.1.21 → 0.1.23
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/console/assets/index-_CULM3sT.js +31 -0
- package/console/index.html +1 -1
- package/console/shared/forge-dev-sdk.js +1 -1
- package/dist/index.js +860 -503
- package/modules/mod-today/dist/banner.js +414 -0
- package/modules/mod-today/dist/server.js +776 -0
- package/modules/mod-today/dist/view.js +322 -0
- package/modules/mod-today/forge-module.json +70 -0
- package/modules/mod-today/package.json +26 -0
- package/package.json +1 -1
- package/console/assets/index-WdL2WXjO.js +0 -31
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
// src/banner.tsx
|
|
2
|
+
import { definePanel } from "@forge-dev/sdk";
|
|
3
|
+
|
|
4
|
+
// src/ops.ts
|
|
5
|
+
var errorMessage = (e) => e instanceof Error ? e.message : String(e);
|
|
6
|
+
var STARTS = ["issue", "request", "review"];
|
|
7
|
+
var startsTask = (kind) => STARTS.includes(kind);
|
|
8
|
+
var inAccount = (items, account) => account ? items.filter((i) => i.account === account) : items;
|
|
9
|
+
function opFor(item, project) {
|
|
10
|
+
if (item.kind === "to-task") return item.targetSession ? "send" : null;
|
|
11
|
+
if (item.kind === "research") return "research";
|
|
12
|
+
return project ?? item.project ? "start" : null;
|
|
13
|
+
}
|
|
14
|
+
var EMPTY_PROJECTS = { names: [], owners: {} };
|
|
15
|
+
function projectsFor({ names, owners }, account) {
|
|
16
|
+
return account ? names.filter((n) => !owners[n] || owners[n] === account) : names;
|
|
17
|
+
}
|
|
18
|
+
var failedLine = (error) => `Last reading failed: ${error}`;
|
|
19
|
+
var loadFailedLine = (error) => `Can't load Today: ${error}`;
|
|
20
|
+
var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
|
|
21
|
+
var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
|
|
22
|
+
|
|
23
|
+
// src/rows.tsx
|
|
24
|
+
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
|
|
25
|
+
import { showToast } from "@forge-dev/ui";
|
|
26
|
+
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
27
|
+
var soft = (token, pct) => `color-mix(in srgb, var(${token}) ${pct}%, transparent)`;
|
|
28
|
+
var AVATARS = ["--blue", "--purple", "--orange", "--green", "--teal", "--red"];
|
|
29
|
+
var ACCOUNT_TOKENS = ["--blue", "--purple", "--orange", "--green", "--teal"];
|
|
30
|
+
function accountToken(name) {
|
|
31
|
+
let h = 0;
|
|
32
|
+
for (const c of name) h = h * 31 + c.charCodeAt(0) >>> 0;
|
|
33
|
+
return ACCOUNT_TOKENS[h % ACCOUNT_TOKENS.length];
|
|
34
|
+
}
|
|
35
|
+
function AccountChip({ account }) {
|
|
36
|
+
const token = accountToken(account);
|
|
37
|
+
return /* @__PURE__ */ jsx("span", { title: `Account ${account}`, style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${token})`, background: soft(token, 15) }, children: account });
|
|
38
|
+
}
|
|
39
|
+
var FILTER_KEY = "today.account";
|
|
40
|
+
function useAccountFilter() {
|
|
41
|
+
const [account, setAccount] = useState(() => {
|
|
42
|
+
try {
|
|
43
|
+
return localStorage.getItem(FILTER_KEY) ?? "";
|
|
44
|
+
} catch {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const choose = (a) => {
|
|
49
|
+
setAccount(a);
|
|
50
|
+
try {
|
|
51
|
+
if (a) localStorage.setItem(FILTER_KEY, a);
|
|
52
|
+
else localStorage.removeItem(FILTER_KEY);
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return [account, choose];
|
|
57
|
+
}
|
|
58
|
+
function useDigest(forge, path = "/digest") {
|
|
59
|
+
const [reply, setReply] = useState(null);
|
|
60
|
+
const [error, setError] = useState(null);
|
|
61
|
+
const latest = useRef(0);
|
|
62
|
+
const load = useCallback(async () => {
|
|
63
|
+
const mine = ++latest.current;
|
|
64
|
+
try {
|
|
65
|
+
const next = await forge.route(path);
|
|
66
|
+
if (mine !== latest.current) return;
|
|
67
|
+
setReply(next);
|
|
68
|
+
setError(null);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (mine === latest.current) setError(errorMessage(e));
|
|
71
|
+
}
|
|
72
|
+
}, [forge, path]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
void load();
|
|
75
|
+
const poll = () => {
|
|
76
|
+
if (!document.hidden) void load();
|
|
77
|
+
};
|
|
78
|
+
const t = setInterval(poll, 6e4);
|
|
79
|
+
document.addEventListener("visibilitychange", poll);
|
|
80
|
+
return () => {
|
|
81
|
+
clearInterval(t);
|
|
82
|
+
document.removeEventListener("visibilitychange", poll);
|
|
83
|
+
};
|
|
84
|
+
}, [load]);
|
|
85
|
+
return { reply, error, reload: load };
|
|
86
|
+
}
|
|
87
|
+
function useProjects(forge) {
|
|
88
|
+
const [projects, setProjects] = useState(EMPTY_PROJECTS);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
forge.route("/projects").then((r) => setProjects({ names: r.projects, owners: r.owners ?? {} }), () => {
|
|
91
|
+
});
|
|
92
|
+
}, [forge]);
|
|
93
|
+
return projects;
|
|
94
|
+
}
|
|
95
|
+
function useActing(forge, date, reload) {
|
|
96
|
+
const [busy, setBusy] = useState(false);
|
|
97
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
98
|
+
const reading = useRef(false);
|
|
99
|
+
const guarded = async (fn) => {
|
|
100
|
+
try {
|
|
101
|
+
await fn();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
showToast(errorMessage(e), "error");
|
|
104
|
+
}
|
|
105
|
+
await reload();
|
|
106
|
+
};
|
|
107
|
+
const run = async (fn) => {
|
|
108
|
+
if (busy) return;
|
|
109
|
+
setBusy(true);
|
|
110
|
+
await guarded(fn);
|
|
111
|
+
setBusy(false);
|
|
112
|
+
};
|
|
113
|
+
const act = (item, op, project) => run(async () => {
|
|
114
|
+
if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
|
|
115
|
+
});
|
|
116
|
+
const refresh = async () => {
|
|
117
|
+
if (reading.current) return;
|
|
118
|
+
reading.current = true;
|
|
119
|
+
setRefreshing(true);
|
|
120
|
+
await guarded(() => forge.action("refresh"));
|
|
121
|
+
reading.current = false;
|
|
122
|
+
setRefreshing(false);
|
|
123
|
+
};
|
|
124
|
+
return { busy, refreshing, run, act, refresh };
|
|
125
|
+
}
|
|
126
|
+
function dayOf(date) {
|
|
127
|
+
const [y, m, d] = date.split("-").map(Number);
|
|
128
|
+
return new Date(y, m - 1, d);
|
|
129
|
+
}
|
|
130
|
+
var isToday = (date, now) => dayOf(date).toDateString() === now.toDateString();
|
|
131
|
+
function dayLabel(now, date) {
|
|
132
|
+
const day = dayOf(date);
|
|
133
|
+
if (!isToday(date, now)) return `From ${day.toLocaleDateString("en-US", { weekday: "long" })} ${day.getDate()}`;
|
|
134
|
+
const hour = now.getHours();
|
|
135
|
+
const part = hour < 12 ? "Good morning" : hour < 19 ? "Good afternoon" : "Good evening";
|
|
136
|
+
return `${part} \xB7 your ${now.toLocaleDateString("en-US", { weekday: "long" })} ${now.getDate()}`;
|
|
137
|
+
}
|
|
138
|
+
var shortDay = (now, date) => !date || isToday(date, now) ? "Today" : dayLabel(now, date);
|
|
139
|
+
function foldedNow(folded, items) {
|
|
140
|
+
return folded || !items.some((i) => i.state === "proposed" || i.state === "failed");
|
|
141
|
+
}
|
|
142
|
+
var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
143
|
+
function readLine(d) {
|
|
144
|
+
const read = new Date(d.readAt);
|
|
145
|
+
const since = new Date(d.since);
|
|
146
|
+
const same = read.toDateString() === since.toDateString();
|
|
147
|
+
const day = new Date(read.getTime() - 864e5).toDateString() === since.toDateString() ? "yesterday " : `${since.toLocaleDateString("en-US", { month: "short", day: "numeric" })} `;
|
|
148
|
+
return `Read at ${clock(read)} \xB7 Linear, Slack and GitHub since ${same ? "" : day}${clock(since)}`;
|
|
149
|
+
}
|
|
150
|
+
function ago(iso, now = /* @__PURE__ */ new Date()) {
|
|
151
|
+
const t = new Date(iso);
|
|
152
|
+
const min = Math.round((now.getTime() - t.getTime()) / 6e4);
|
|
153
|
+
if (min < 1) return "just now";
|
|
154
|
+
if (min < 60) return `${min} min ago`;
|
|
155
|
+
if (min < 24 * 60) return `${Math.round(min / 60)} h ago`;
|
|
156
|
+
return t.toLocaleDateString("en-US", { month: "short", day: "numeric" }) + " " + clock(t);
|
|
157
|
+
}
|
|
158
|
+
var SOURCE_LABEL = { linear: "Linear", slack: "Slack", github: "GitHub" };
|
|
159
|
+
var SOURCE_TINT = { linear: "#5e6ad2 22%", slack: "#e01e5a 18%", github: "#8b949e 24%" };
|
|
160
|
+
function SourceIcon({ source }) {
|
|
161
|
+
return /* @__PURE__ */ jsx("div", { title: SOURCE_LABEL[source], style: { width: "30px", height: "30px", borderRadius: "8px", display: "grid", placeItems: "center", flexShrink: 0, background: `color-mix(in srgb, ${SOURCE_TINT[source]}, transparent)` }, children: source === "github" ? /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { fill: "currentColor", style: { color: "var(--ink)" }, d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z" }) }) : source === "linear" ? /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 100 100", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { fill: "#8c94f0", d: "M1.2 61.5 38.5 98.8C19.8 95.6 4.4 80.2 1.2 61.5zM0 46.9 53.1 100c3.4-.2 6.8-.8 10-1.6L1.6 36.9C.8 40.1.2 43.5 0 46.9zM4.9 27 73 95.1c2.6-1.1 5.1-2.5 7.4-4L8.9 19.6c-1.5 2.3-2.9 4.8-4 7.4zM14.4 13.8C23.4 5.3 35.5 0 48.9 0 76 0 100 24 100 51.1c0 13.4-5.3 25.5-13.8 34.5z" }) }) : /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("g", { fill: "none", "stroke-width": "2.6", "stroke-linecap": "round", children: [
|
|
162
|
+
/* @__PURE__ */ jsx("path", { stroke: "#36c5f0", d: "M9 3.5v6" }),
|
|
163
|
+
/* @__PURE__ */ jsx("path", { stroke: "#2eb67d", d: "M20.5 9h-6" }),
|
|
164
|
+
/* @__PURE__ */ jsx("path", { stroke: "#ecb22e", d: "M15 20.5v-6" }),
|
|
165
|
+
/* @__PURE__ */ jsx("path", { stroke: "#e01e5a", d: "M3.5 15h6" })
|
|
166
|
+
] }) }) });
|
|
167
|
+
}
|
|
168
|
+
var KIND = {
|
|
169
|
+
"to-task": { label: "Send to the task", token: "--orange", verb: "Send" },
|
|
170
|
+
issue: { label: "New task", token: "--green", verb: "Start" },
|
|
171
|
+
request: { label: "New task", token: "--green", verb: "Start" },
|
|
172
|
+
research: { label: "Research", token: "--purple", verb: "Research" },
|
|
173
|
+
review: { label: "Review", token: "--blue", verb: "Review" }
|
|
174
|
+
};
|
|
175
|
+
function KindPill({ kind }) {
|
|
176
|
+
const k = KIND[kind];
|
|
177
|
+
return /* @__PURE__ */ jsx("span", { style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${k.token})`, background: soft(k.token, 15) }, children: k.label });
|
|
178
|
+
}
|
|
179
|
+
function Avatar({ who }) {
|
|
180
|
+
const initials = who.split(/\s+/).filter(Boolean).slice(0, 2).map((w) => w[0].toUpperCase()).join("") || "?";
|
|
181
|
+
let h = 0;
|
|
182
|
+
for (const c of who) h = h * 31 + c.charCodeAt(0) >>> 0;
|
|
183
|
+
return /* @__PURE__ */ jsx("span", { style: { width: "16px", height: "16px", borderRadius: "50%", display: "inline-grid", placeItems: "center", fontSize: "8.5px", fontWeight: 700, color: "#fff", background: `var(${AVATARS[h % AVATARS.length]})` }, children: initials });
|
|
184
|
+
}
|
|
185
|
+
var Sep = () => /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" });
|
|
186
|
+
var strong = (t) => /* @__PURE__ */ jsx("b", { style: { color: "var(--ink)", fontWeight: 550 }, children: t });
|
|
187
|
+
function LiveChip({ label }) {
|
|
188
|
+
return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px", fontSize: "11px", color: "var(--teal)" }, children: [
|
|
189
|
+
/* @__PURE__ */ jsx("i", { style: { width: "6px", height: "6px", borderRadius: "50%", background: "var(--teal)", boxShadow: `0 0 0 3px ${soft("--teal", 25)}` } }),
|
|
190
|
+
label
|
|
191
|
+
] });
|
|
192
|
+
}
|
|
193
|
+
var buttonStyle = { font: "inherit", fontSize: "12px", fontWeight: 550, borderRadius: "8px", padding: "5px 11px", border: "1px solid var(--hair-2)", background: "var(--card-2, var(--elev))", color: "var(--ink)", cursor: "pointer", whiteSpace: "nowrap" };
|
|
194
|
+
var ghostStyle = { ...buttonStyle, border: "1px solid transparent", background: "transparent", color: "var(--ink-2)" };
|
|
195
|
+
var primaryStyle = { ...buttonStyle, background: "var(--blue)", borderColor: "transparent", color: "#fff", boxShadow: `0 2px 8px ${soft("--blue", 35)}` };
|
|
196
|
+
var Btn = ({ label, style = buttonStyle, disabled, title, onClick }) => /* @__PURE__ */ jsx("button", { type: "button", title, disabled, style: { ...style, opacity: disabled ? 0.55 : 1, cursor: disabled ? "default" : "pointer", transition: "opacity .2s var(--ease)" }, onClick, children: label });
|
|
197
|
+
function ProjectPicker({ projects, value, onChange }) {
|
|
198
|
+
return /* @__PURE__ */ jsxs("select", { "aria-label": "Project", value, onChange: (e) => onChange(e.target.value), style: { font: "inherit", fontSize: "12px", padding: "4px 6px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: [
|
|
199
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Project\u2026" }),
|
|
200
|
+
projects.map((p) => /* @__PURE__ */ jsx("option", { value: p, children: p }, p))
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
function outcome(item) {
|
|
204
|
+
const s = item.startedSession;
|
|
205
|
+
const where = s ? `${s.project} / ${s.sessionDir}` : "";
|
|
206
|
+
if (item.kind === "research") return /* @__PURE__ */ jsx(LiveChip, { label: `Researching${where ? ` \xB7 ${where}` : ""}` });
|
|
207
|
+
if (item.kind === "to-task") return /* @__PURE__ */ jsx("span", { style: { fontSize: "11.5px", color: "var(--green)" }, children: "Sent" });
|
|
208
|
+
return /* @__PURE__ */ jsxs("span", { style: { fontSize: "11.5px", color: "var(--green)" }, children: [
|
|
209
|
+
"Started",
|
|
210
|
+
where ? ` \xB7 ${where}` : ""
|
|
211
|
+
] });
|
|
212
|
+
}
|
|
213
|
+
var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
214
|
+
const [project, setProject] = useState(item.project ?? "");
|
|
215
|
+
const open = item.state === "proposed" || item.state === "failed";
|
|
216
|
+
const needsProject = startsTask(item.kind) && !item.project;
|
|
217
|
+
const op = opFor(item, project);
|
|
218
|
+
const where = item.source === "slack" ? "in" : "on";
|
|
219
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "30px 1fr auto", gap: "12px", alignItems: "center", padding: "10px 12px", borderRadius: "11px", background: soft("--ink", 3), border: "1px solid var(--hair)", opacity: item.state === "dismissed" ? 0.55 : 1, transition: "background .2s var(--ease)" }, children: [
|
|
220
|
+
/* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
|
|
221
|
+
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
222
|
+
/* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
|
|
223
|
+
item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
|
|
224
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item.title })
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
227
|
+
/* @__PURE__ */ jsx(Avatar, { who: item.who }),
|
|
228
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
229
|
+
item.who,
|
|
230
|
+
" ",
|
|
231
|
+
where,
|
|
232
|
+
" ",
|
|
233
|
+
strong(item.where)
|
|
234
|
+
] }),
|
|
235
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
236
|
+
/* @__PURE__ */ jsx("span", { children: ago(item.when) }),
|
|
237
|
+
item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
238
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
239
|
+
/* @__PURE__ */ jsx(AccountChip, { account: item.account })
|
|
240
|
+
] }),
|
|
241
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
242
|
+
/* @__PURE__ */ jsxs("a", { href: item.link, target: "_blank", rel: "noopener noreferrer", style: { color: "var(--ink-2)", textDecoration: "none", borderBottom: "1px dotted var(--ink-3)" }, children: [
|
|
243
|
+
"View in ",
|
|
244
|
+
SOURCE_LABEL[item.source],
|
|
245
|
+
" \u2197"
|
|
246
|
+
] }),
|
|
247
|
+
item.kind === "to-task" && item.targetSession && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
248
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
249
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
250
|
+
"goes to ",
|
|
251
|
+
strong(item.targetSession.sessionDir)
|
|
252
|
+
] })
|
|
253
|
+
] }),
|
|
254
|
+
item.project && item.kind !== "to-task" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
255
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
256
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
257
|
+
"project ",
|
|
258
|
+
strong(item.project)
|
|
259
|
+
] })
|
|
260
|
+
] })
|
|
261
|
+
] }),
|
|
262
|
+
item.quote && /* @__PURE__ */ jsxs("div", { style: { marginTop: "6px", fontSize: "12px", color: "var(--ink-2)", borderLeft: "2px solid var(--hair-2)", paddingLeft: "8px", fontStyle: "italic" }, children: [
|
|
263
|
+
"\u201C",
|
|
264
|
+
item.quote,
|
|
265
|
+
"\u201D"
|
|
266
|
+
] }),
|
|
267
|
+
item.error && /* @__PURE__ */ jsx("div", { style: { marginTop: "6px", fontSize: "11.5px", color: "var(--red)" }, children: item.error })
|
|
268
|
+
] }),
|
|
269
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
270
|
+
/* @__PURE__ */ jsx(KindPill, { kind: item.kind }),
|
|
271
|
+
open && needsProject && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
|
|
272
|
+
open && /* @__PURE__ */ jsx(Btn, { label: item.state === "failed" ? "Retry" : KIND[item.kind].verb, disabled: acting.busy || !op, onClick: () => op && acting.act(item, op, needsProject ? project : void 0) }),
|
|
273
|
+
open && /* @__PURE__ */ jsx(Btn, { label: "Dismiss", style: ghostStyle, disabled: acting.busy, onClick: () => acting.act(item, "dismiss") }),
|
|
274
|
+
item.state === "done" && outcome(item),
|
|
275
|
+
item.state === "done" && item.startedSession && /* @__PURE__ */ jsx(Btn, { label: "Open session", onClick: () => forge.openSession(item.startedSession.project, item.startedSession.sessionDir) }),
|
|
276
|
+
item.state === "dismissed" && /* @__PURE__ */ jsx("span", { style: { fontSize: "11.5px", color: "var(--ink-3)" }, children: "Dismissed" })
|
|
277
|
+
] })
|
|
278
|
+
] });
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// src/banner.tsx
|
|
282
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
283
|
+
var pill = { display: "flex", alignItems: "center", gap: "6px", fontSize: "11.5px", color: "var(--ink-2)", padding: "3px 9px", borderRadius: "20px", background: "var(--elev)", border: "1px solid var(--hair)" };
|
|
284
|
+
function Count({ token, n, label }) {
|
|
285
|
+
if (n === 0) return null;
|
|
286
|
+
return /* @__PURE__ */ jsxs2("span", { style: pill, children: [
|
|
287
|
+
/* @__PURE__ */ jsx2("i", { style: { width: "7px", height: "7px", borderRadius: "50%", background: `var(${token})` } }),
|
|
288
|
+
n,
|
|
289
|
+
" ",
|
|
290
|
+
label
|
|
291
|
+
] });
|
|
292
|
+
}
|
|
293
|
+
function FilterChip({ label, n, on, token, onClick }) {
|
|
294
|
+
const tint = token ?? "--blue";
|
|
295
|
+
return /* @__PURE__ */ jsxs2("button", { type: "button", "aria-pressed": on, onClick, style: { ...pill, font: "inherit", fontSize: "11.5px", cursor: "pointer", color: on ? "var(--ink)" : "var(--ink-2)", borderColor: on ? `var(${tint})` : "var(--hair)", background: on ? soft(tint, 15) : "var(--elev)" }, children: [
|
|
296
|
+
token && /* @__PURE__ */ jsx2("i", { style: { width: "7px", height: "7px", borderRadius: "50%", background: `var(${token})` } }),
|
|
297
|
+
label,
|
|
298
|
+
" \xB7 ",
|
|
299
|
+
n
|
|
300
|
+
] });
|
|
301
|
+
}
|
|
302
|
+
var live = (items) => items.filter((i) => i.state !== "dismissed");
|
|
303
|
+
var done = (items, pick) => items.filter((i) => i.state === "done" && pick(i.kind)).length;
|
|
304
|
+
function shell(children) {
|
|
305
|
+
return /* @__PURE__ */ jsx2("div", { style: { position: "relative", borderRadius: "16px", padding: "1px", background: `linear-gradient(135deg, ${soft("--blue", 55)}, ${soft("--purple", 40)} 45%, var(--hair) 80%)`, boxShadow: `0 10px 40px ${soft("--blue", 10)}` }, children: /* @__PURE__ */ jsx2("div", { style: { borderRadius: "15px", background: "radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--blue) 14%, var(--card)) 0%, var(--card) 55%)" }, children }) });
|
|
306
|
+
}
|
|
307
|
+
function Strip({ title, children, actions }) {
|
|
308
|
+
return shell(
|
|
309
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "10px", padding: "9px 16px", fontSize: "12.5px", color: "var(--ink-2)" }, children: [
|
|
310
|
+
/* @__PURE__ */ jsx2("span", { style: { color: "var(--orange)" }, children: "\u2600\uFE0E" }),
|
|
311
|
+
/* @__PURE__ */ jsx2("b", { style: { color: "var(--ink)", fontWeight: 600 }, children: title }),
|
|
312
|
+
children,
|
|
313
|
+
/* @__PURE__ */ jsx2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: actions })
|
|
314
|
+
] })
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
function Banner({ forge }) {
|
|
318
|
+
const { reply, error, reload } = useDigest(forge);
|
|
319
|
+
const projects = useProjects(forge);
|
|
320
|
+
const [chosen, choose] = useAccountFilter();
|
|
321
|
+
const digest = reply?.digest;
|
|
322
|
+
const acting = useActing(forge, digest?.date, reload);
|
|
323
|
+
const refreshBtn = /* @__PURE__ */ jsx2(Btn, { label: acting.refreshing ? "Reading\u2026" : "Refresh", style: ghostStyle, disabled: acting.refreshing, onClick: acting.refresh });
|
|
324
|
+
const failure = (text) => /* @__PURE__ */ jsxs2("span", { style: { color: "var(--red)" }, children: [
|
|
325
|
+
"\xB7 ",
|
|
326
|
+
text
|
|
327
|
+
] });
|
|
328
|
+
const notes = notesLine(digest?.notes);
|
|
329
|
+
const note = notes && /* @__PURE__ */ jsxs2("span", { style: { color: "var(--ink-3)" }, children: [
|
|
330
|
+
"\xB7 ",
|
|
331
|
+
notes
|
|
332
|
+
] });
|
|
333
|
+
if (!reply && !error) return null;
|
|
334
|
+
if (reply && !reply.enabled) {
|
|
335
|
+
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
|
+
}
|
|
337
|
+
if (!reply || !digest || digest.items.length === 0) {
|
|
338
|
+
return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, children: [
|
|
339
|
+
!reply ? failure(loadFailedLine(error)) : digest?.error ? failure(failedLine(digest.error)) : digest && /* @__PURE__ */ jsxs2("span", { children: [
|
|
340
|
+
"\xB7 nothing new since ",
|
|
341
|
+
clock(new Date(digest.readAt))
|
|
342
|
+
] }),
|
|
343
|
+
note
|
|
344
|
+
] });
|
|
345
|
+
}
|
|
346
|
+
const items = digest.items;
|
|
347
|
+
const accounts = accountsOf(items);
|
|
348
|
+
const account = accounts.includes(chosen) ? chosen : "";
|
|
349
|
+
const seen = (list) => inAccount(list, account);
|
|
350
|
+
const shown = seen(live(items));
|
|
351
|
+
const folded = foldedNow(reply.folded, items);
|
|
352
|
+
const fold = (value) => acting.run(() => forge.action("fold", { date: digest.date, folded: value }));
|
|
353
|
+
if (folded) {
|
|
354
|
+
return /* @__PURE__ */ jsxs2(Strip, { title: shortDay(/* @__PURE__ */ new Date(), digest.date), actions: /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
355
|
+
refreshBtn,
|
|
356
|
+
/* @__PURE__ */ jsx2(Btn, { label: "See all \u2192", style: ghostStyle, onClick: () => forge.openPage() })
|
|
357
|
+
] }), children: [
|
|
358
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
359
|
+
"\xB7 ",
|
|
360
|
+
done(items, startsTask),
|
|
361
|
+
" started \xB7 ",
|
|
362
|
+
done(items, (k) => k === "research"),
|
|
363
|
+
" researching \xB7 ",
|
|
364
|
+
done(items, (k) => k === "to-task"),
|
|
365
|
+
" sent"
|
|
366
|
+
] }),
|
|
367
|
+
digest.error && failure(failedLine(digest.error)),
|
|
368
|
+
note
|
|
369
|
+
] });
|
|
370
|
+
}
|
|
371
|
+
const waiting = seen(items).filter((i) => i.state === "proposed" || i.state === "failed");
|
|
372
|
+
const ready = waiting.filter((i) => opFor(i)).length;
|
|
373
|
+
const acceptAll = () => acting.run(() => forge.action("accept-all", { date: digest.date, ...account ? { account } : {} }));
|
|
374
|
+
return shell(
|
|
375
|
+
/* @__PURE__ */ jsxs2("div", { style: { padding: "16px 18px 12px" }, children: [
|
|
376
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
|
|
377
|
+
/* @__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
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
379
|
+
/* @__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) })
|
|
381
|
+
] }),
|
|
382
|
+
/* @__PURE__ */ jsxs2("div", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
383
|
+
refreshBtn,
|
|
384
|
+
/* @__PURE__ */ jsx2(Btn, { label: "Fold \u2303", style: ghostStyle, disabled: acting.busy, onClick: () => fold(true) }),
|
|
385
|
+
ready > 0 && /* @__PURE__ */ jsx2(Btn, { label: `Accept ${ready === 1 ? "it" : `the ${ready}`}`, style: primaryStyle, disabled: acting.busy, onClick: acceptAll })
|
|
386
|
+
] })
|
|
387
|
+
] }),
|
|
388
|
+
accounts.length > 1 && /* @__PURE__ */ jsxs2("div", { role: "group", "aria-label": "Account", style: { display: "flex", gap: "6px", marginTop: "12px", flexWrap: "wrap" }, children: [
|
|
389
|
+
/* @__PURE__ */ jsx2(FilterChip, { label: "All", n: live(items).length, on: !account, onClick: () => choose("") }),
|
|
390
|
+
accounts.map((a) => /* @__PURE__ */ jsx2(FilterChip, { label: a, token: accountToken(a), n: inAccount(live(items), a).length, on: account === a, onClick: () => choose(a) }, a))
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: "6px", margin: "14px 0 10px", flexWrap: "wrap" }, children: [
|
|
393
|
+
/* @__PURE__ */ jsx2(Count, { token: "--orange", n: shown.filter((i) => i.kind === "to-task").length, label: "for open tasks" }),
|
|
394
|
+
/* @__PURE__ */ jsx2(Count, { token: "--green", n: shown.filter((i) => i.kind === "issue" || i.kind === "request").length, label: "new tasks" }),
|
|
395
|
+
/* @__PURE__ */ jsx2(Count, { token: "--blue", n: shown.filter((i) => i.kind === "review").length, label: "to review" }),
|
|
396
|
+
/* @__PURE__ */ jsx2(Count, { token: "--purple", n: shown.filter((i) => i.kind === "research").length, label: "researching" }),
|
|
397
|
+
/* @__PURE__ */ jsxs2("span", { style: { ...pill, marginLeft: "auto", borderColor: "transparent", background: "none", color: "var(--ink-3)" }, children: [
|
|
398
|
+
seen(items).length,
|
|
399
|
+
" read \xB7 ",
|
|
400
|
+
seen(items).length - shown.length,
|
|
401
|
+
" dismissed"
|
|
402
|
+
] })
|
|
403
|
+
] }),
|
|
404
|
+
digest.error && /* @__PURE__ */ jsx2("div", { style: { marginBottom: "8px", fontSize: "11.5px", color: "var(--red)" }, children: failedLine(digest.error) }),
|
|
405
|
+
notes && /* @__PURE__ */ jsx2("div", { style: { marginBottom: "8px", fontSize: "11.5px", color: "var(--ink-3)" }, children: notes }),
|
|
406
|
+
/* @__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
|
+
/* @__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
|
+
] })
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
var banner_default = definePanel({ id: "banner", title: "Today", component: Banner });
|
|
412
|
+
export {
|
|
413
|
+
banner_default as default
|
|
414
|
+
};
|