forge-cw 0.1.28 → 0.1.30

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.
@@ -1,5 +1,5 @@
1
1
  // src/view.tsx
2
- import { useEffect as useEffect2, useState as useState2 } from "preact/hooks";
2
+ import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "preact/hooks";
3
3
  import { ActionButton, EmptyState } from "@forge-dev/ui";
4
4
  import { definePanel } from "@forge-dev/sdk";
5
5
 
@@ -7,7 +7,6 @@ import { definePanel } from "@forge-dev/sdk";
7
7
  var errorMessage = (e) => e instanceof Error ? e.message : String(e);
8
8
  var STARTS = ["issue", "request", "review"];
9
9
  var startsTask = (kind) => STARTS.includes(kind);
10
- var inAccount = (items, account) => account ? items.filter((i) => i.account === account) : items;
11
10
  function opFor(item, project) {
12
11
  if (item.kind === "to-task") return item.targetSession ? "send" : null;
13
12
  if (item.kind === "research") return "research";
@@ -19,7 +18,10 @@ function projectsFor({ names, owners }, account) {
19
18
  }
20
19
  var failedLine = (error) => `Last reading failed: ${error}`;
21
20
  var loadFailedLine = (error) => `Can't load Today: ${error}`;
22
- var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
21
+ var GH_SIGNED_OUT = "GitHub: gh is not signed in (run gh auth login)";
22
+ function tidyNotes(notes) {
23
+ return [...new Set(notes.map((n) => /^github\b[^:]*:/i.test(n) && /gh auth login|GH_TOKEN/i.test(n) ? GH_SIGNED_OUT : n))];
24
+ }
23
25
  var SOURCE_NAME = { slack: "Slack", linear: "Linear", reader: "Reader" };
24
26
  function sourcesLabel(sources) {
25
27
  const names = ["slack", "linear", "reader"].filter((s) => sources.includes(s)).map((s) => SOURCE_NAME[s]);
@@ -33,25 +35,6 @@ function groupProblems(problems) {
33
35
  });
34
36
  }
35
37
  var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
36
- var GROUPS = [
37
- { title: "In open tasks", pick: (i) => i.kind === "to-task" },
38
- { title: "New", pick: (i) => i.kind === "issue" || i.kind === "request" },
39
- { title: "To review", pick: (i) => i.kind === "review" },
40
- { title: "Researching", pick: (i) => i.kind === "research" }
41
- ];
42
- function sections(all) {
43
- const live = all.filter((i) => i.state !== "dismissed");
44
- const groups = GROUPS.map((g) => ({ title: g.title, items: live.filter(g.pick) }));
45
- return [...groups, { title: "Dismissed", items: all.filter((i) => i.state === "dismissed") }].filter((g) => g.items.length > 0);
46
- }
47
- var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
48
- function byAccount(items) {
49
- const accounts = accountsOf(items);
50
- if (accounts.length < 2) return [{ sections: sections(items) }];
51
- const blocks = accounts.map((account) => ({ account, sections: sections(inAccount(items, account)) }));
52
- const rest = items.filter((i) => !i.account);
53
- return rest.length ? [...blocks, { sections: sections(rest) }] : blocks;
54
- }
55
38
  function titleFor(i) {
56
39
  if (!i.issueKey) return i.title;
57
40
  const key = i.issueKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -63,19 +46,161 @@ function whoOf(i) {
63
46
  const who = i.who.trim();
64
47
  return !who || who.toLowerCase() === SOURCE_NAMES[i.source].toLowerCase() ? null : who;
65
48
  }
66
- var pendingLabel = (p) => p.kind === "ci" ? "CI failing" : p.kind === "review" ? "Review requested" : p.source === "linear" ? p.started ? "In progress" : "To do" : "Assigned";
67
- var pendingIn = (items, account) => account ? items.filter((p) => p.account === account) : items;
68
- function pendingByAccount(items) {
69
- const accounts = [...new Set(items.flatMap((p) => p.account ? [p.account] : []))];
70
- if (accounts.length < 2) return items.length ? [{ items }] : [];
71
- const blocks = accounts.map((account) => ({ account, items: pendingIn(items, account) }));
72
- const rest = items.filter((p) => !p.account);
73
- return rest.length ? [...blocks, { items: rest }] : blocks;
74
- }
75
49
  var CAPPED_NOTE = "showing the latest 20";
76
50
  var GITHUB_SEARCH = "https://github.com/pulls/review-requested";
77
51
  var PENDING_EMPTY = "Nothing open \u2014 nice.";
78
52
  var FIRST_READING_NOTE = "First reading \u2014 what you have open is under Pending.";
53
+ var NO_FILTERS = { account: "", source: "", query: "" };
54
+ var NO_ACCOUNT = "__none__";
55
+ var SOURCE_IDS = ["linear", "slack", "github"];
56
+ function parseFilters(raw) {
57
+ try {
58
+ const v = JSON.parse(raw ?? "");
59
+ if (!isRecord(v)) return NO_FILTERS;
60
+ return {
61
+ account: typeof v.account === "string" ? v.account : "",
62
+ source: SOURCE_IDS.includes(v.source) ? v.source : "",
63
+ query: typeof v.query === "string" ? v.query : ""
64
+ };
65
+ } catch {
66
+ return NO_FILTERS;
67
+ }
68
+ }
69
+ function isRecord(v) {
70
+ return typeof v === "object" && v !== null && !Array.isArray(v);
71
+ }
72
+ function matchesQuery(x, query) {
73
+ const q = query.trim().toLowerCase();
74
+ if (!q) return true;
75
+ return [x.title, x.issueKey, x.who, x.where, x.repo].some((f) => !!f && f.toLowerCase().includes(q));
76
+ }
77
+ function passes(x, f, skip) {
78
+ return (skip === "account" || !f.account || (f.account === NO_ACCOUNT ? !x.account : x.account === f.account)) && (skip === "source" || !f.source || x.source === f.source) && matchesQuery(x, f.query);
79
+ }
80
+ var filterNews = (items, f) => items.filter((i) => passes(i, f));
81
+ var filterPending = (items, f) => items.filter((p) => passes(p, f));
82
+ function newsList(items) {
83
+ const waiting = (i) => i.state === "proposed" || i.state === "failed" ? 0 : 1;
84
+ return items.filter((i) => i.state !== "dismissed").sort((a, b) => waiting(a) - waiting(b) || Date.parse(b.when) - Date.parse(a.when));
85
+ }
86
+ function countFor(news, pending, f) {
87
+ const all = [...news, ...pending];
88
+ const accounts = {};
89
+ let noAccount = 0;
90
+ for (const x of all.filter((x2) => passes(x2, f, "account"))) {
91
+ if (x.account) accounts[x.account] = (accounts[x.account] ?? 0) + 1;
92
+ else noAccount++;
93
+ }
94
+ const sources = { linear: 0, slack: 0, github: 0 };
95
+ for (const x of all.filter((x2) => passes(x2, f, "source"))) sources[x.source]++;
96
+ return { total: all.filter((x) => passes(x, f, "account")).length, accounts, noAccount, sources };
97
+ }
98
+ var GROUPS = [
99
+ { id: "needs", title: "Needs you" },
100
+ { id: "progress", title: "In progress" },
101
+ { id: "todo", title: "To do", folded: true },
102
+ { id: "updates", title: "Updates" }
103
+ ];
104
+ function groupOf(e) {
105
+ if (e.kind === "news") return e.item.state === "proposed" || e.item.state === "failed" ? "needs" : "updates";
106
+ const p = e.item;
107
+ if (p.kind === "ci" || p.kind === "reply") return "needs";
108
+ return p.kind === "review" || p.source === "linear" && p.started ? "progress" : "todo";
109
+ }
110
+ function inboxGroups(news, pending) {
111
+ const entries = [...pending.map((item) => ({ kind: "pending", item })), ...news.map((item) => ({ kind: "news", item }))];
112
+ return GROUPS.map((g) => ({ ...g, folded: !!g.folded, entries: entries.filter((e) => groupOf(e) === g.id) })).filter((g) => g.entries.length > 0);
113
+ }
114
+ var isGroupFolded = (g, saved) => saved[g.id] ?? g.folded;
115
+ function ageShort(iso, now = /* @__PURE__ */ new Date()) {
116
+ const min = Math.max(0, Math.round((now.getTime() - Date.parse(iso)) / 6e4));
117
+ if (Number.isNaN(min)) return "";
118
+ if (min < 1) return "now";
119
+ if (min < 60) return `${min}m`;
120
+ if (min < 48 * 60) return `${Math.round(min / 60)}h`;
121
+ return `${Math.round(min / 1440)}d`;
122
+ }
123
+ var safeHref = (link) => /^https?:\/\//i.test(link) ? link : void 0;
124
+ var acceptable = (news) => news.filter((i) => i.state === "proposed" && opFor(i));
125
+ function visibleEntries(groups, folds, searching) {
126
+ return groups.filter((g) => searching || !isGroupFolded(g, folds)).flatMap((g) => g.entries);
127
+ }
128
+ function initialSelection(visible) {
129
+ return (visible.find((e) => groupOf(e) === "needs") ?? visible[0])?.item.id ?? null;
130
+ }
131
+ function moveSelection(ids, current, delta) {
132
+ if (!ids.length) return null;
133
+ const at = current === null ? -1 : ids.indexOf(current);
134
+ if (at < 0) return ids[0];
135
+ return ids[Math.min(ids.length - 1, Math.max(0, at + delta))];
136
+ }
137
+ function isUnread(when, lastSeen) {
138
+ const t = Date.parse(when);
139
+ return lastSeen !== null && !Number.isNaN(t) && t > lastSeen;
140
+ }
141
+ function parseLastSeen(raw) {
142
+ const n = Number(raw);
143
+ return raw && Number.isFinite(n) && n > 0 ? n : null;
144
+ }
145
+ var VERBS = { "to-task": "Send", issue: "Start", request: "Start", research: "Research", review: "Review" };
146
+ var verbFor = (kind) => VERBS[kind];
147
+ var isOpen = (i) => i.state === "proposed" || i.state === "failed";
148
+ function needsProject(e) {
149
+ if (e.kind === "news") return isOpen(e.item) && startsTask(e.item.kind) && !e.item.project;
150
+ return !e.item.targetSession && !e.item.project;
151
+ }
152
+ function moveFor(e, project) {
153
+ if (e.kind === "pending") {
154
+ const p = e.item;
155
+ if (p.targetSession) return { label: "Open task", kind: "task", ready: true };
156
+ return { label: p.kind === "review" ? "Review" : "Start", kind: "op", ready: !!(p.project ?? project) };
157
+ }
158
+ const i = e.item;
159
+ if (isOpen(i)) return { label: i.state === "failed" ? "Retry" : verbFor(i.kind), kind: "op", ready: !!opFor(i, project) };
160
+ return i.state === "done" && i.startedSession ? { label: "Open session", kind: "session", ready: true } : null;
161
+ }
162
+ var canResearch = (e) => e.kind === "pending" && e.item.kind === "reply" && !e.item.targetSession;
163
+ var canHide = (e) => e.kind === "pending" || isOpen(e.item);
164
+ var INBOX_KEYS = { arrowdown: "next", j: "next", arrowup: "prev", k: "prev", enter: "open", s: "start", h: "hide", r: "research", "/": "search" };
165
+ var TRIAGE_KEYS = { s: "start", o: "open", l: "later", h: "hide" };
166
+ function keyCommand(e, mode, typing) {
167
+ const key = e.key.toLowerCase();
168
+ if (mode === "inbox" && key === "f" && (e.metaKey || e.ctrlKey) && !e.altKey) return "search";
169
+ if (e.metaKey || e.ctrlKey || e.altKey) return null;
170
+ if (key === "escape") return mode === "inbox" ? "clear" : "close";
171
+ if (typing) return null;
172
+ return (mode === "inbox" ? INBOX_KEYS : TRIAGE_KEYS)[key] ?? null;
173
+ }
174
+ function triageDeck(groups, withTodo) {
175
+ const ids = withTodo ? ["needs", "progress", "todo"] : ["needs", "progress"];
176
+ return ids.flatMap((id) => groups.find((g) => g.id === id)?.entries ?? []);
177
+ }
178
+ var triageNext = (deck, done) => deck.find((e) => !done[e.item.id]) ?? null;
179
+ function triageProgress(deck, done) {
180
+ const ids = /* @__PURE__ */ new Set([...deck.map((e) => e.item.id), ...Object.keys(done)]);
181
+ return { sorted: Object.keys(done).length, total: ids.size };
182
+ }
183
+ function triageCounts(groups, done) {
184
+ return groups.filter((g) => g.id !== "updates").map((g) => ({ id: g.id, title: g.title, left: g.entries.filter((e) => !done[e.item.id]).length }));
185
+ }
186
+ function triageSummary(done) {
187
+ const sum = { started: 0, hidden: 0, later: 0 };
188
+ for (const d of Object.values(done)) sum[d]++;
189
+ return sum;
190
+ }
191
+ var DECISIONS = ["started", "hidden", "later"];
192
+ function parseTriage(raw, date) {
193
+ try {
194
+ const v = JSON.parse(raw ?? "");
195
+ if (!isRecord(v) || v.date !== date || !isRecord(v.done)) return {};
196
+ return Object.fromEntries(Object.entries(v.done).filter(([, d]) => DECISIONS.includes(d)));
197
+ } catch {
198
+ return {};
199
+ }
200
+ }
201
+
202
+ // src/inbox.tsx
203
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "preact/hooks";
79
204
 
80
205
  // src/rows.tsx
81
206
  import { useCallback, useEffect, useRef, useState } from "preact/hooks";
@@ -93,6 +218,94 @@ function AccountChip({ account }) {
93
218
  const token = accountToken(account);
94
219
  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 });
95
220
  }
221
+ var FILTERS_KEY = "today.filters";
222
+ var FOLDS_KEY = "today.folds";
223
+ var LAST_SEEN_KEY = "today.lastSeen";
224
+ var TRIAGE_KEY = "today.triage";
225
+ var START_DAY_KEY = "today.startDay";
226
+ function useStored(key, read, empty) {
227
+ const [value, setValue] = useState(() => {
228
+ try {
229
+ return read(localStorage.getItem(key));
230
+ } catch {
231
+ return empty;
232
+ }
233
+ });
234
+ const set = (next) => {
235
+ setValue(next);
236
+ try {
237
+ localStorage.setItem(key, JSON.stringify(next));
238
+ } catch {
239
+ }
240
+ };
241
+ return [value, set];
242
+ }
243
+ var useFilters = () => useStored(FILTERS_KEY, parseFilters, NO_FILTERS);
244
+ function useFolds() {
245
+ const [folds, set] = useStored(FOLDS_KEY, (raw) => {
246
+ const v = JSON.parse(raw ?? "{}");
247
+ return typeof v === "object" && v !== null && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).filter(([, f]) => typeof f === "boolean")) : {};
248
+ }, {});
249
+ return [folds, (id, folded) => set({ ...folds, [id]: folded })];
250
+ }
251
+ function useLastSeen() {
252
+ const [seen] = useState(() => {
253
+ try {
254
+ return parseLastSeen(localStorage.getItem(LAST_SEEN_KEY));
255
+ } catch {
256
+ return null;
257
+ }
258
+ });
259
+ useEffect(() => {
260
+ const stamp = () => {
261
+ try {
262
+ localStorage.setItem(LAST_SEEN_KEY, String(Date.now()));
263
+ } catch {
264
+ }
265
+ };
266
+ const hidden = () => {
267
+ if (document.hidden) stamp();
268
+ };
269
+ window.addEventListener("pagehide", stamp);
270
+ document.addEventListener("visibilitychange", hidden);
271
+ return () => {
272
+ window.removeEventListener("pagehide", stamp);
273
+ document.removeEventListener("visibilitychange", hidden);
274
+ stamp();
275
+ };
276
+ }, []);
277
+ return seen;
278
+ }
279
+ function useTriage(date) {
280
+ const [stored, setStored] = useState(null);
281
+ const day = date ?? "";
282
+ const base = (prev) => {
283
+ if (prev?.date === day) return prev.done;
284
+ try {
285
+ return parseTriage(localStorage.getItem(TRIAGE_KEY), day);
286
+ } catch {
287
+ return {};
288
+ }
289
+ };
290
+ const save = (change) => setStored((prev) => {
291
+ const next = { date: day, done: change(base(prev)) };
292
+ try {
293
+ localStorage.setItem(TRIAGE_KEY, JSON.stringify(next));
294
+ } catch {
295
+ }
296
+ return next;
297
+ });
298
+ return [base(stored), (id, d) => save((done) => ({ ...done, [id]: d })), () => save(() => ({}))];
299
+ }
300
+ function takeStartDay() {
301
+ try {
302
+ const at = Number(localStorage.getItem(START_DAY_KEY));
303
+ localStorage.removeItem(START_DAY_KEY);
304
+ return at > 0 && Date.now() - at < 6e4;
305
+ } catch {
306
+ return false;
307
+ }
308
+ }
96
309
  function useDigest(forge, path = "/digest") {
97
310
  const [reply, setReply] = useState(null);
98
311
  const [error, setError] = useState(null);
@@ -139,18 +352,22 @@ function useActing(forge, date, reload, hurry = () => {
139
352
  const [retrying, setRetrying] = useState(null);
140
353
  const reading = useRef(false);
141
354
  const guarded = async (fn) => {
355
+ let ok = true;
142
356
  try {
143
357
  await fn();
144
358
  } catch (e) {
359
+ ok = false;
145
360
  showToast(errorMessage(e), "error");
146
361
  }
147
362
  await reload();
363
+ return ok;
148
364
  };
149
365
  const run = async (fn) => {
150
- if (busy) return;
366
+ if (busy) return false;
151
367
  setBusy(true);
152
- await guarded(fn);
368
+ const ok = await guarded(fn);
153
369
  setBusy(false);
370
+ return ok;
154
371
  };
155
372
  const act = (item, op, project) => run(async () => {
156
373
  if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
@@ -158,6 +375,9 @@ function useActing(forge, date, reload, hurry = () => {
158
375
  const startPending = (item, project) => run(async () => {
159
376
  await forge.action("pending-start", { id: item.id, ...project ? { project } : {} });
160
377
  });
378
+ const researchPending = (item) => run(async () => {
379
+ await forge.action("pending-research", { id: item.id });
380
+ });
161
381
  const hidePending = (item) => run(async () => {
162
382
  await forge.action("pending-hide", { id: item.id });
163
383
  });
@@ -185,20 +405,13 @@ function useActing(forge, date, reload, hurry = () => {
185
405
  const s = await forge.action("reconnect", { account });
186
406
  if (s) forge.openSession(s.project, s.sessionDir);
187
407
  });
188
- return { busy, refreshing, retrying, retry, reconnect, run, act, refresh, startPending, hidePending };
408
+ return { busy, refreshing, retrying, retry, reconnect, run, act, refresh, startPending, researchPending, hidePending };
189
409
  }
190
410
  function dayOf(date) {
191
411
  const [y, m, d] = date.split("-").map(Number);
192
412
  return new Date(y, m - 1, d);
193
413
  }
194
414
  var isToday = (date, now) => dayOf(date).toDateString() === now.toDateString();
195
- function dayLabel(now, date) {
196
- const day = dayOf(date);
197
- if (!isToday(date, now)) return `From ${day.toLocaleDateString("en-US", { weekday: "long" })} ${day.getDate()}`;
198
- const hour = now.getHours();
199
- const part = hour < 12 ? "Good morning" : hour < 19 ? "Good afternoon" : "Good evening";
200
- return `${part} \xB7 your ${now.toLocaleDateString("en-US", { weekday: "long" })} ${now.getDate()}`;
201
- }
202
415
  var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
203
416
  function windowTime(at, read) {
204
417
  if (at.toDateString() === read.toDateString()) return clock(at);
@@ -224,7 +437,7 @@ function ago(iso, now = /* @__PURE__ */ new Date()) {
224
437
  var SOURCE_LABEL = { linear: "Linear", slack: "Slack", github: "GitHub" };
225
438
  var SOURCE_TINT = { linear: "#5e6ad2 22%", slack: "#e01e5a 18%", github: "#8b949e 24%" };
226
439
  function SourceIcon({ source }) {
227
- 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: [
440
+ return /* @__PURE__ */ jsx("div", { title: SOURCE_LABEL[source], style: { width: "22px", height: "22px", borderRadius: "6px", display: "grid", placeItems: "center", flexShrink: 0, background: `color-mix(in srgb, ${SOURCE_TINT[source]}, transparent)` }, children: source === "github" ? /* @__PURE__ */ jsx("svg", { width: "12", height: "12", 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: "12", height: "12", 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: "12", height: "12", viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("g", { fill: "none", "stroke-width": "2.6", "stroke-linecap": "round", children: [
228
441
  /* @__PURE__ */ jsx("path", { stroke: "#36c5f0", d: "M9 3.5v6" }),
229
442
  /* @__PURE__ */ jsx("path", { stroke: "#2eb67d", d: "M20.5 9h-6" }),
230
443
  /* @__PURE__ */ jsx("path", { stroke: "#ecb22e", d: "M15 20.5v-6" }),
@@ -232,11 +445,11 @@ function SourceIcon({ source }) {
232
445
  ] }) }) });
233
446
  }
234
447
  var KIND = {
235
- "to-task": { label: "Send to the task", token: "--orange", verb: "Send" },
236
- issue: { label: "New task", token: "--green", verb: "Start" },
237
- request: { label: "New task", token: "--green", verb: "Start" },
238
- research: { label: "Research", token: "--purple", verb: "Research" },
239
- review: { label: "Review", token: "--blue", verb: "Review" }
448
+ "to-task": { label: "Send to the task", token: "--orange" },
449
+ issue: { label: "New task", token: "--green" },
450
+ request: { label: "New task", token: "--green" },
451
+ research: { label: "Research", token: "--purple" },
452
+ review: { label: "Review", token: "--blue" }
240
453
  };
241
454
  function KindPill({ kind }) {
242
455
  const k = KIND[kind];
@@ -250,16 +463,16 @@ function Avatar({ who }) {
250
463
  }
251
464
  var Sep = () => /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" });
252
465
  var strong = (t) => /* @__PURE__ */ jsx("b", { style: { color: "var(--ink)", fontWeight: 550 }, children: t });
253
- function LiveChip({ label }) {
466
+ function LiveChip({ label: label2 }) {
254
467
  return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px", fontSize: "11px", color: "var(--teal)" }, children: [
255
468
  /* @__PURE__ */ jsx("i", { style: { width: "6px", height: "6px", borderRadius: "50%", background: "var(--teal)", boxShadow: `0 0 0 3px ${soft("--teal", 25)}` } }),
256
- label
469
+ label2
257
470
  ] });
258
471
  }
259
472
  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" };
260
473
  var ghostStyle = { ...buttonStyle, border: "1px solid transparent", background: "transparent", color: "var(--ink-2)" };
261
474
  var primaryStyle = { ...buttonStyle, background: "var(--blue)", borderColor: "transparent", color: "#fff", boxShadow: `0 2px 8px ${soft("--blue", 35)}` };
262
- 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 });
475
+ var Btn = ({ label: label2, 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: label2 });
263
476
  function ProjectPicker({ projects, value, onChange }) {
264
477
  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: [
265
478
  /* @__PURE__ */ jsx("option", { value: "", children: "Project\u2026" }),
@@ -276,128 +489,41 @@ function outcome(item) {
276
489
  where ? ` \xB7 ${where}` : ""
277
490
  ] });
278
491
  }
279
- var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
280
- const [project, setProject] = useState(item.project ?? "");
281
- const open = item.state === "proposed" || item.state === "failed";
282
- const needsProject = startsTask(item.kind) && !item.project;
283
- const op = opFor(item, project);
284
- const where = item.source === "slack" ? "in" : "on";
285
- 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: [
286
- /* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
287
- /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
288
- /* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
289
- item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
290
- /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
291
- ] }),
292
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
293
- whoOf(item) && /* @__PURE__ */ jsx(Avatar, { who: item.who }),
294
- /* @__PURE__ */ jsx("span", { children: whoOf(item) ? /* @__PURE__ */ jsxs(Fragment, { children: [
295
- item.who,
296
- " ",
297
- where,
298
- " ",
299
- strong(item.where)
300
- ] }) : strong(item.where) }),
301
- /* @__PURE__ */ jsx(Sep, {}),
302
- /* @__PURE__ */ jsx("span", { children: ago(item.when) }),
303
- item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
304
- /* @__PURE__ */ jsx(Sep, {}),
305
- /* @__PURE__ */ jsx(AccountChip, { account: item.account })
306
- ] }),
307
- /* @__PURE__ */ jsx(Sep, {}),
308
- /* @__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: [
309
- "View in ",
310
- SOURCE_LABEL[item.source],
311
- " \u2197"
312
- ] }),
313
- item.kind === "to-task" && item.targetSession && /* @__PURE__ */ jsxs(Fragment, { children: [
314
- /* @__PURE__ */ jsx(Sep, {}),
315
- /* @__PURE__ */ jsxs("span", { children: [
316
- "goes to ",
317
- strong(item.targetSession.sessionDir)
318
- ] })
319
- ] }),
320
- item.project && item.kind !== "to-task" && /* @__PURE__ */ jsxs(Fragment, { children: [
321
- /* @__PURE__ */ jsx(Sep, {}),
322
- /* @__PURE__ */ jsxs("span", { children: [
323
- "project ",
324
- strong(item.project)
325
- ] })
326
- ] })
327
- ] }),
328
- 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: [
329
- "\u201C",
330
- item.quote,
331
- "\u201D"
332
- ] }),
333
- item.error && /* @__PURE__ */ jsx("div", { style: { marginTop: "6px", fontSize: "11.5px", color: "var(--red)" }, children: item.error })
334
- ] }),
335
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
336
- /* @__PURE__ */ jsx(KindPill, { kind: item.kind }),
337
- open && needsProject && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
338
- 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) }),
339
- open && /* @__PURE__ */ jsx(Btn, { label: "Dismiss", style: ghostStyle, disabled: acting.busy, onClick: () => acting.act(item, "dismiss") }),
340
- item.state === "done" && outcome(item),
341
- item.state === "done" && item.startedSession && /* @__PURE__ */ jsx(Btn, { label: "Open session", onClick: () => forge.openSession(item.startedSession.project, item.startedSession.sessionDir) }),
342
- item.state === "dismissed" && /* @__PURE__ */ jsx("span", { style: { fontSize: "11.5px", color: "var(--ink-3)" }, children: "Dismissed" })
343
- ] })
344
- ] });
345
- };
346
- var PENDING_TOKEN = { ci: "--red", review: "--blue", issue: "--green" };
347
- var PendingRow = ({ item, projects = EMPTY_PROJECTS, acting, forge, compact }) => {
348
- const [project, setProject] = useState(item.project ?? "");
349
- const token = PENDING_TOKEN[item.kind];
350
- const target = item.project ?? project;
351
- return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "30px 1fr auto", gap: "12px", alignItems: "center", padding: compact ? "7px 10px" : "10px 12px", borderRadius: "11px", background: soft("--ink", 3), border: "1px solid var(--hair)" }, children: [
352
- /* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
353
- /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
354
- /* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
355
- item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
356
- /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
357
- ] }),
358
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
359
- /* @__PURE__ */ jsxs("span", { children: [
360
- item.repo ? strong(item.repo) : null,
361
- item.repo && item.state ? " \xB7 " : "",
362
- item.state
363
- ] }),
364
- (item.repo || item.state) && /* @__PURE__ */ jsx(Sep, {}),
365
- /* @__PURE__ */ jsx("span", { children: ago(item.when) }),
366
- item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
367
- /* @__PURE__ */ jsx(Sep, {}),
368
- /* @__PURE__ */ jsx(AccountChip, { account: item.account })
369
- ] }),
370
- /* @__PURE__ */ jsx(Sep, {}),
371
- /* @__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: [
372
- "View in ",
373
- SOURCE_LABEL[item.source],
374
- " \u2197"
375
- ] }),
376
- item.project && /* @__PURE__ */ jsxs(Fragment, { children: [
377
- /* @__PURE__ */ jsx(Sep, {}),
378
- /* @__PURE__ */ jsxs("span", { children: [
379
- "project ",
380
- strong(item.project)
381
- ] })
382
- ] })
383
- ] })
384
- ] }),
385
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
386
- /* @__PURE__ */ jsx("span", { style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${token})`, background: soft(token, 15) }, children: pendingLabel(item) }),
387
- item.targetSession ? /* @__PURE__ */ jsx(Btn, { label: "Open task", onClick: () => forge.openSession(item.targetSession.project, item.targetSession.sessionDir) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
388
- !item.project && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
389
- /* @__PURE__ */ jsx(Btn, { label: item.kind === "review" ? "Review" : "Start", disabled: acting.busy || !target, onClick: () => acting.startPending(item, item.project ? void 0 : project) })
390
- ] }),
391
- /* @__PURE__ */ jsx(Btn, { label: "Hide", style: ghostStyle, disabled: acting.busy, onClick: () => acting.hidePending(item) })
392
- ] })
492
+ var sourceOf = (p) => SOURCE_LABEL[p.source];
493
+ var Quote = ({ text }) => /* @__PURE__ */ jsxs("div", { style: { fontSize: "12px", borderLeft: "2px solid var(--hair-2)", paddingLeft: "8px", fontStyle: "italic" }, children: [
494
+ "\u201C",
495
+ text,
496
+ "\u201D"
497
+ ] });
498
+ var PENDING_TOKEN = { ci: "--red", review: "--blue", issue: "--green", reply: "--purple" };
499
+ function Pill({ label: label2, n, on, token, onClick }) {
500
+ const tint = token ?? "--blue";
501
+ return /* @__PURE__ */ jsxs("button", { type: "button", "aria-pressed": on, onClick, style: { display: "inline-flex", alignItems: "center", gap: "6px", font: "inherit", fontSize: "11.5px", cursor: "pointer", padding: "3px 9px", borderRadius: "20px", color: on ? "var(--ink)" : "var(--ink-2)", border: `1px solid ${on ? `var(${tint})` : "var(--hair)"}`, background: on ? soft(tint, 15) : "var(--elev)" }, children: [
502
+ token && /* @__PURE__ */ jsx("i", { style: { width: "7px", height: "7px", borderRadius: "50%", background: `var(${token})` } }),
503
+ label2,
504
+ " \xB7 ",
505
+ n
393
506
  ] });
394
- };
507
+ }
395
508
  var READING_CSS = `
396
509
  @keyframes today-spin { to { transform: rotate(360deg) } }
397
510
  @keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
398
511
  .today-spin { animation: today-spin .8s linear infinite }
399
512
  .today-pulse { animation: today-pulse 1.4s ease-in-out infinite }
400
- @media (prefers-reduced-motion: reduce) { .today-spin, .today-pulse { animation: none } }`;
513
+ .today-inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - 250px); min-height: 440px; border: 1px solid var(--hair); border-radius: 12px; overflow: hidden }
514
+ .today-list { display: flex; flex-direction: column; min-height: 0; background: var(--card); border-right: 1px solid var(--hair) }
515
+ .today-detail { overflow-y: auto; min-width: 0; background: var(--elev) }
516
+ .today-back { display: none }
517
+ @media (max-width: 900px) {
518
+ .today-inbox { grid-template-columns: minmax(0, 1fr) }
519
+ .today-list { border-right: 0 }
520
+ .today-inbox[data-open="true"] .today-list, .today-inbox[data-open="false"] .today-detail { display: none }
521
+ .today-back { display: inline-block }
522
+ .today-triage { grid-template-columns: minmax(0, 1fr) !important }
523
+ }
524
+ @keyframes today-slide { from { opacity: 0; transform: translateX(28px) } to { opacity: 1; transform: none } }
525
+ .today-slide { animation: today-slide .22s var(--ease) }
526
+ @media (prefers-reduced-motion: reduce) { .today-spin, .today-pulse, .today-slide { animation: none } }`;
401
527
  function useReadingStyles() {
402
528
  if (typeof document !== "undefined" && !document.getElementById("today-reading-css")) {
403
529
  const el = document.createElement("style");
@@ -446,84 +572,523 @@ function ProblemRow({ group, acting, details = false }) {
446
572
  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)) })
447
573
  ] });
448
574
  }
575
+ function Notes({ notes }) {
576
+ const [open, setOpen] = useState(false);
577
+ if (!notes?.length) return null;
578
+ const short = tidyNotes(notes);
579
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "12px", color: "var(--ink-3)" }, children: [
580
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "baseline", gap: "8px", minWidth: 0 }, children: [
581
+ /* @__PURE__ */ jsx("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: short.join(" \xB7 ") }),
582
+ /* @__PURE__ */ jsx("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), style: { font: "inherit", fontSize: "11.5px", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--ink-3)", flexShrink: 0 }, children: open ? "Hide details" : "Details" })
583
+ ] }),
584
+ open && /* @__PURE__ */ jsx("ul", { style: { margin: 0, paddingLeft: "18px" }, children: notes.map((n) => /* @__PURE__ */ jsx("li", { style: { overflowWrap: "anywhere" }, children: n }, n)) })
585
+ ] });
586
+ }
449
587
 
450
- // src/view.tsx
588
+ // src/inbox.tsx
451
589
  import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
452
- var heading = { margin: "4px 0 0", fontSize: "13px", fontWeight: 650, letterSpacing: "-.01em" };
453
- var subheading = { margin: "4px 0", fontSize: "11px", fontWeight: 600, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" };
590
+ var mono = { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 };
591
+ var label = { fontSize: "10px", fontWeight: 650, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" };
592
+ function entryApi(acting, forge) {
593
+ return {
594
+ async primary(e, project) {
595
+ const move = moveFor(e, project);
596
+ if (!move?.ready) return false;
597
+ if (e.kind === "pending") {
598
+ const t = e.item.targetSession;
599
+ if (move.kind === "task" && t) {
600
+ forge.openSession(t.project, t.sessionDir);
601
+ return true;
602
+ }
603
+ return acting.startPending(e.item, e.item.project ? void 0 : project);
604
+ }
605
+ const s = e.item.startedSession;
606
+ if (move.kind === "session" && s) {
607
+ forge.openSession(s.project, s.sessionDir);
608
+ return true;
609
+ }
610
+ const op = opFor(e.item, project);
611
+ return op ? acting.act(e.item, op, needsProject(e) ? project : void 0) : false;
612
+ },
613
+ hide: async (e) => !canHide(e) ? false : e.kind === "pending" ? acting.hidePending(e.item) : acting.act(e.item, "dismiss"),
614
+ research: async (e) => e.kind === "pending" && canResearch(e) ? acting.researchPending(e.item) : false,
615
+ open(e) {
616
+ const href = safeHref(e.item.link);
617
+ if (href) window.open(href, "_blank", "noopener,noreferrer");
618
+ }
619
+ };
620
+ }
621
+ function typingIn(target) {
622
+ const el = target;
623
+ return !!el && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName));
624
+ }
625
+ function Where({ e }) {
626
+ const i = e.item;
627
+ const age = /* @__PURE__ */ jsx2("span", { title: i.when, children: ago(i.when) });
628
+ const account = i.account ? /* @__PURE__ */ jsx2(AccountChip, { account: i.account }) : null;
629
+ let place;
630
+ if (e.kind === "news") {
631
+ const who = whoOf(e.item);
632
+ place = /* @__PURE__ */ jsxs2(Fragment2, { children: [
633
+ who && /* @__PURE__ */ jsx2(Avatar, { who }),
634
+ /* @__PURE__ */ jsx2("span", { children: who ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
635
+ who,
636
+ " ",
637
+ e.item.source === "slack" ? "in" : "on",
638
+ " ",
639
+ strong(e.item.where)
640
+ ] }) : strong(e.item.where) })
641
+ ] });
642
+ } else if (e.item.kind === "reply") {
643
+ place = /* @__PURE__ */ jsxs2("span", { children: [
644
+ e.item.who,
645
+ " in ",
646
+ strong(e.item.where ?? "")
647
+ ] });
648
+ } else {
649
+ place = /* @__PURE__ */ jsxs2("span", { children: [
650
+ e.item.repo ? strong(e.item.repo) : e.item.issueKey ? strong(e.item.issueKey) : null,
651
+ (e.item.repo || e.item.issueKey) && e.item.state ? " \xB7 " : "",
652
+ e.item.kind === "ci" ? "" : e.item.state
653
+ ] });
654
+ }
655
+ return /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap", color: "var(--ink-2)", fontSize: "12px" }, children: [
656
+ /* @__PURE__ */ jsx2(SourceIcon, { source: i.source }),
657
+ /* @__PURE__ */ jsx2("b", { style: { fontWeight: 600, color: "var(--ink)" }, children: sourceOf(i) }),
658
+ /* @__PURE__ */ jsx2(Sep, {}),
659
+ place,
660
+ /* @__PURE__ */ jsx2(Sep, {}),
661
+ age,
662
+ account
663
+ ] });
664
+ }
665
+ function ContextBlock({ e }) {
666
+ const i = e.item;
667
+ const slack = i.source === "slack";
668
+ if (i.context) {
669
+ return /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
670
+ /* @__PURE__ */ jsx2("span", { style: label, children: slack ? "Thread" : "Details" }),
671
+ /* @__PURE__ */ jsx2("div", { style: { whiteSpace: "pre-wrap", overflowWrap: "anywhere", fontSize: "12.5px", lineHeight: 1.55, color: "var(--ink-2)", padding: "10px 12px", borderRadius: "10px", background: "var(--card)", border: "1px solid var(--hair)" }, children: i.context })
672
+ ] });
673
+ }
674
+ if (e.kind === "pending" && e.item.source === "github") {
675
+ const p = e.item;
676
+ const checks = p.kind === "ci" ? p.state?.replace(/^failing:\s*/, "") : "";
677
+ const rows = [["Repository", p.repo], [p.kind === "ci" ? "Failing checks" : "State", p.kind === "ci" ? checks : p.state], ["Updated", ago(p.when)]];
678
+ return /* @__PURE__ */ jsx2("div", { style: { display: "grid", gridTemplateColumns: "auto 1fr", gap: "4px 14px", fontSize: "12.5px", padding: "10px 12px", borderRadius: "10px", background: "var(--card)", border: "1px solid var(--hair)" }, children: rows.filter(([, v]) => v).map(([k, v]) => /* @__PURE__ */ jsxs2(Fragment2, { children: [
679
+ /* @__PURE__ */ jsx2("span", { style: { color: "var(--ink-3)" }, children: k }),
680
+ /* @__PURE__ */ jsx2("span", { style: { overflowWrap: "anywhere" }, children: v })
681
+ ] })) });
682
+ }
683
+ return i.quote ? /* @__PURE__ */ jsx2(Quote, { text: i.quote }) : null;
684
+ }
685
+ var pillStyle = (token) => ({ fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${token})`, background: soft(token, 15) });
686
+ function KindTag({ e }) {
687
+ if (e.kind === "news") return /* @__PURE__ */ jsx2(KindPill, { kind: e.item.kind });
688
+ const p = e.item;
689
+ const text = p.kind === "reply" ? "Waiting on you" : p.kind === "ci" ? "CI failing" : p.kind === "review" ? "Review requested" : p.source === "linear" ? p.started ? "In progress" : "To do" : "Assigned";
690
+ return /* @__PURE__ */ jsx2("span", { style: pillStyle(PENDING_TOKEN[p.kind]), children: text });
691
+ }
692
+ function EntryBody({ e, big }) {
693
+ const i = e.item;
694
+ return /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "12px", minWidth: 0 }, children: [
695
+ /* @__PURE__ */ jsx2(Where, { e }),
696
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "baseline", gap: "8px", flexWrap: "wrap" }, children: [
697
+ /* @__PURE__ */ jsx2(KindTag, { e }),
698
+ i.issueKey && /* @__PURE__ */ jsx2("span", { style: mono, children: i.issueKey })
699
+ ] }),
700
+ /* @__PURE__ */ jsx2("h3", { style: { margin: 0, fontSize: big ? "20px" : "17px", lineHeight: 1.3, fontWeight: 650, letterSpacing: "-.01em", overflowWrap: "anywhere" }, children: titleFor(i) }),
701
+ e.kind === "news" && e.item.project && e.item.kind !== "to-task" && /* @__PURE__ */ jsxs2("div", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: [
702
+ "project ",
703
+ strong(e.item.project)
704
+ ] }),
705
+ e.kind === "news" && e.item.kind === "to-task" && e.item.targetSession && /* @__PURE__ */ jsxs2("div", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: [
706
+ "goes to ",
707
+ strong(e.item.targetSession.sessionDir)
708
+ ] }),
709
+ e.kind === "pending" && e.item.project && /* @__PURE__ */ jsxs2("div", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: [
710
+ "project ",
711
+ strong(e.item.project)
712
+ ] }),
713
+ /* @__PURE__ */ jsx2(ContextBlock, { e }),
714
+ e.kind === "news" && e.item.error && /* @__PURE__ */ jsx2("div", { style: { color: "var(--red)", fontSize: "12px" }, children: e.item.error }),
715
+ e.kind === "news" && e.item.state === "done" && outcome(e.item)
716
+ ] });
717
+ }
718
+ var hintFor = (e) => {
719
+ const move = moveFor(e);
720
+ return ["\u2191\u2193 move", "\u21B5 open link", ...move ? [`S ${move.label.toLowerCase()}`] : [], ...canHide(e) ? ["H hide"] : [], ...canResearch(e) ? ["R research"] : [], "/ search"];
721
+ };
722
+ var Kbd = ({ children }) => /* @__PURE__ */ jsx2("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "10.5px", padding: "1px 5px", borderRadius: "4px", border: "1px solid var(--hair-2)", color: "var(--ink-2)" }, children });
723
+ function Hint({ e }) {
724
+ return /* @__PURE__ */ jsx2("div", { style: { display: "flex", gap: "12px", flexWrap: "wrap", color: "var(--ink-3)", fontSize: "11px" }, children: hintFor(e).map((h) => /* @__PURE__ */ jsxs2("span", { children: [
725
+ /* @__PURE__ */ jsx2(Kbd, { children: h.split(" ")[0] }),
726
+ " ",
727
+ h.slice(h.indexOf(" ") + 1)
728
+ ] }, h)) });
729
+ }
730
+ function EntryActions({ e, project, setProject, projects, acting, api }) {
731
+ const move = moveFor(e, project);
732
+ const link = safeHref(e.item.link);
733
+ return /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
734
+ needsProject(e) && /* @__PURE__ */ jsx2(ProjectPicker, { projects: projectsFor(projects, e.item.account), value: project, onChange: setProject }),
735
+ move && /* @__PURE__ */ jsx2(Btn, { label: move.label, style: primaryStyle, disabled: acting.busy || !move.ready, onClick: () => void api.primary(e, project) }),
736
+ link && /* @__PURE__ */ jsxs2("a", { href: link, target: "_blank", rel: "noopener noreferrer", style: { 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)", textDecoration: "none", whiteSpace: "nowrap" }, children: [
737
+ "Open in ",
738
+ sourceOf(e.item),
739
+ " \u2197"
740
+ ] }),
741
+ canResearch(e) && /* @__PURE__ */ jsx2(Btn, { label: "Research", disabled: acting.busy, onClick: () => void api.research(e) }),
742
+ canHide(e) && /* @__PURE__ */ jsx2(Btn, { label: "Hide", style: ghostStyle, disabled: acting.busy, onClick: () => void api.hide(e) })
743
+ ] });
744
+ }
745
+ function ListRow({ e, selected, unread, onSelect }) {
746
+ const i = e.item;
747
+ return /* @__PURE__ */ jsxs2("button", { type: "button", role: "option", "aria-selected": selected, "data-id": i.id, onClick: onSelect, style: { display: "flex", alignItems: "center", gap: "9px", width: "100%", textAlign: "left", font: "inherit", fontSize: "12.5px", padding: "7px 12px 7px 10px", border: 0, borderLeft: `2px solid ${selected ? "var(--blue)" : "transparent"}`, background: selected ? soft("--blue", 14) : "transparent", color: "var(--ink)", cursor: "pointer" }, children: [
748
+ /* @__PURE__ */ jsx2("i", { "aria-label": unread ? "New" : void 0, style: { width: "6px", height: "6px", borderRadius: "50%", flexShrink: 0, background: unread ? "var(--blue)" : "transparent" } }),
749
+ /* @__PURE__ */ jsx2(SourceIcon, { source: i.source }),
750
+ /* @__PURE__ */ jsx2("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: unread ? 650 : 530 }, children: titleFor(i) }),
751
+ i.account && /* @__PURE__ */ jsx2("span", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx2(AccountChip, { account: i.account }) }),
752
+ /* @__PURE__ */ jsx2("span", { title: i.when, style: { fontSize: "11px", color: "var(--ink-3)", minWidth: "26px", textAlign: "right", flexShrink: 0 }, children: ageShort(i.when) })
753
+ ] });
754
+ }
755
+ function Inbox(p) {
756
+ const { groups, folds, searching, acting, projects } = p;
757
+ const base = entryApi(acting, p.forge);
758
+ const visible = visibleEntries(groups, folds, searching);
759
+ const [selected, select] = useState2(null);
760
+ const [open, setOpen] = useState2(false);
761
+ const [picks, setPicks] = useState2({});
762
+ const currentId = visible.some((e) => e.item.id === selected) ? selected : initialSelection(visible);
763
+ const current = visible.find((e) => e.item.id === currentId) ?? null;
764
+ const api = {
765
+ ...base,
766
+ hide: async (e) => {
767
+ const ids = visible.map((v) => v.item.id);
768
+ const at = ids.indexOf(e.item.id);
769
+ const next = ids[at + 1] ?? ids[at - 1] ?? null;
770
+ const ok = await base.hide(e);
771
+ if (ok) select(next);
772
+ return ok;
773
+ }
774
+ };
775
+ const pick = (id, project2) => setPicks((prev) => ({ ...prev, [id]: project2 }));
776
+ const project = current ? picks[current.item.id] ?? current.item.project ?? "" : "";
777
+ const latest = useRef2(() => {
778
+ });
779
+ latest.current = (c) => {
780
+ const ids = visible.map((e) => e.item.id);
781
+ if (c === "next" || c === "prev") return select(moveSelection(ids, currentId, c === "next" ? 1 : -1));
782
+ if (c === "search") return p.focusSearch();
783
+ if (c === "clear") return p.clearSearch();
784
+ if (!current) return;
785
+ if (c === "open") return api.open(current);
786
+ if (c === "start") return void api.primary(current, project);
787
+ if (c === "research") return void api.research(current);
788
+ if (c === "hide" && canHide(current)) void api.hide(current);
789
+ };
790
+ useEffect2(() => {
791
+ if (!p.keys) return;
792
+ const onKey = (ev) => {
793
+ const t = ev.target;
794
+ if (ev.defaultPrevented || t !== document.body && !t?.closest?.(".today-inbox")) return;
795
+ const c = keyCommand(ev, "inbox", typingIn(ev.target));
796
+ if (!c) return;
797
+ if (ev.repeat && c !== "next" && c !== "prev") return;
798
+ if (c === "open" && /^(BUTTON|A)$/.test(t?.tagName ?? "")) return;
799
+ ev.preventDefault();
800
+ latest.current(c);
801
+ };
802
+ window.addEventListener("keydown", onKey);
803
+ return () => window.removeEventListener("keydown", onKey);
804
+ }, [p.keys]);
805
+ useEffect2(() => {
806
+ if (currentId) document.querySelector(`.today-list [data-id="${currentId}"]`)?.scrollIntoView({ block: "nearest" });
807
+ }, [currentId]);
808
+ return /* @__PURE__ */ jsxs2("div", { class: "today-inbox", "data-open": open ? "true" : "false", children: [
809
+ /* @__PURE__ */ jsxs2("div", { class: "today-list", children: [
810
+ /* @__PURE__ */ jsx2("div", { style: { padding: "10px 12px", display: "flex", flexDirection: "column", gap: "8px", borderBottom: "1px solid var(--hair)", flexShrink: 0 }, children: p.header }),
811
+ /* @__PURE__ */ jsxs2("div", { role: "listbox", "aria-label": "Today", style: { overflowY: "auto", flex: 1, paddingBottom: "8px" }, children: [
812
+ groups.length === 0 && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12.5px", color: "var(--ink-2)", padding: "12px" }, children: p.empty }),
813
+ groups.map((g) => {
814
+ const folded = !searching && isGroupFolded(g, folds);
815
+ return /* @__PURE__ */ jsxs2("div", { children: [
816
+ /* @__PURE__ */ jsxs2("button", { type: "button", "aria-expanded": !folded, onClick: () => p.setFold(g.id, !folded), style: { display: "block", width: "100%", textAlign: "left", font: "inherit", fontSize: "10px", fontWeight: 650, letterSpacing: ".06em", textTransform: "uppercase", padding: "10px 12px 4px", border: 0, background: "none", cursor: "pointer", color: "var(--ink-3)" }, children: [
817
+ folded ? "\u25B8" : "\u25BE",
818
+ " ",
819
+ g.title,
820
+ " \xB7 ",
821
+ g.entries.length
822
+ ] }),
823
+ !folded && g.entries.map((e) => /* @__PURE__ */ jsx2(ListRow, { e, selected: e.item.id === currentId, unread: isUnread(e.item.when, p.lastSeen), onSelect: () => {
824
+ select(e.item.id);
825
+ setOpen(true);
826
+ } }, e.item.id))
827
+ ] }, g.id);
828
+ }),
829
+ p.footer
830
+ ] })
831
+ ] }),
832
+ /* @__PURE__ */ jsx2("div", { class: "today-detail", children: current ? /* @__PURE__ */ jsxs2("div", { style: { padding: "18px 22px", display: "flex", flexDirection: "column", gap: "16px" }, children: [
833
+ /* @__PURE__ */ jsx2("button", { type: "button", class: "today-back", onClick: () => setOpen(false), style: { alignSelf: "flex-start", font: "inherit", fontSize: "12px", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--blue)" }, children: "\u2190 Back" }),
834
+ /* @__PURE__ */ jsx2(EntryBody, { e: current }),
835
+ /* @__PURE__ */ jsx2(EntryActions, { e: current, project, setProject: (v) => pick(current.item.id, v), projects: projects ?? EMPTY_PROJECTS, acting, api }),
836
+ /* @__PURE__ */ jsx2(Hint, { e: current })
837
+ ] }) : /* @__PURE__ */ jsx2("div", { style: { padding: "22px", fontSize: "12.5px", color: "var(--ink-3)" }, children: "Nothing selected." }) })
838
+ ] });
839
+ }
840
+
841
+ // src/triage.tsx
842
+ import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "preact/hooks";
843
+ import { jsx as jsx3, jsxs as jsxs3 } from "preact/jsx-runtime";
844
+ var keyTile = (key, label2, disabled, onClick, primary = false) => /* @__PURE__ */ jsxs3("button", { type: "button", disabled, onClick, style: { font: "inherit", textAlign: "center", padding: "9px 6px", borderRadius: "10px", border: `1px solid ${primary && !disabled ? "transparent" : "var(--hair)"}`, background: primary && !disabled ? "var(--blue)" : "var(--elev)", color: primary && !disabled ? "#fff" : "var(--ink-2)", fontSize: "11.5px", cursor: disabled ? "default" : "pointer", opacity: disabled ? 0.5 : 1 }, children: [
845
+ /* @__PURE__ */ jsx3("b", { style: { display: "block", fontSize: "13px", color: primary && !disabled ? "#fff" : "var(--ink)", marginBottom: "2px" }, children: key }),
846
+ label2
847
+ ] });
848
+ function Triage({ forge, groups, done, decide, reset, projects, acting, onClose }) {
849
+ useReadingStyles();
850
+ const [withTodo, setWithTodo] = useState3(false);
851
+ const [skipTodo, setSkipTodo] = useState3(false);
852
+ const [picks, setPicks] = useState3({});
853
+ const deck = triageDeck(groups, withTodo);
854
+ const current = triageNext(deck, done);
855
+ const { sorted, total } = triageProgress(deck, done);
856
+ const counts = triageCounts(groups, done);
857
+ const todoLeft = counts.find((c) => c.id === "todo")?.left ?? 0;
858
+ const api = entryApi(acting, forge);
859
+ const project = current ? picks[current.item.id] ?? current.item.project ?? "" : "";
860
+ const move = current ? moveFor(current, project) : null;
861
+ const summary = triageSummary(done);
862
+ const finished = !current && (withTodo || skipTodo || todoLeft === 0);
863
+ const dialog = useRef3(null);
864
+ const flying = useRef3(false);
865
+ const take = async (e, what) => {
866
+ if (acting.busy || flying.current) return;
867
+ flying.current = true;
868
+ try {
869
+ const ok = what === "start" ? await api.primary(e, picks[e.item.id] ?? e.item.project ?? "") : await api.hide(e);
870
+ if (ok) decide(e.item.id, what === "start" ? "started" : "hidden");
871
+ } finally {
872
+ flying.current = false;
873
+ }
874
+ };
875
+ const latest = useRef3(() => {
876
+ });
877
+ latest.current = (c) => {
878
+ if (c === "close") return onClose();
879
+ if (!current || acting.busy || flying.current) return;
880
+ if (c === "start" && move?.ready) void take(current, "start");
881
+ else if (c === "open") api.open(current);
882
+ else if (c === "later") decide(current.item.id, "later");
883
+ else if (c === "hide" && canHide(current)) void take(current, "hide");
884
+ };
885
+ useEffect3(() => {
886
+ const onKey = (ev) => {
887
+ const c = keyCommand(ev, "triage", typingIn(ev.target));
888
+ if (!c) return;
889
+ if (ev.repeat) return;
890
+ ev.preventDefault();
891
+ latest.current(c);
892
+ };
893
+ const trap = (ev) => {
894
+ if (ev.key !== "Tab" || !dialog.current) return;
895
+ const items = Array.from(dialog.current.querySelectorAll("button:not([disabled]), select, a[href]"));
896
+ if (!items.length) return ev.preventDefault();
897
+ const first = items[0];
898
+ const last = items[items.length - 1];
899
+ const at = document.activeElement;
900
+ if (ev.shiftKey && (at === first || at === dialog.current)) {
901
+ ev.preventDefault();
902
+ last.focus();
903
+ } else if (!ev.shiftKey && at === last) {
904
+ ev.preventDefault();
905
+ first.focus();
906
+ } else if (!dialog.current.contains(at)) {
907
+ ev.preventDefault();
908
+ first.focus();
909
+ }
910
+ };
911
+ const before = document.activeElement;
912
+ window.addEventListener("keydown", onKey);
913
+ window.addEventListener("keydown", trap);
914
+ dialog.current?.focus();
915
+ return () => {
916
+ window.removeEventListener("keydown", onKey);
917
+ window.removeEventListener("keydown", trap);
918
+ before?.focus?.();
919
+ };
920
+ }, []);
921
+ const pct = total ? Math.round(sorted / total * 100) : 0;
922
+ return /* @__PURE__ */ jsx3("div", { role: "dialog", "aria-modal": "true", "aria-label": "Start the day", ref: dialog, tabIndex: -1, style: { position: "fixed", inset: 0, zIndex: 50, display: "flex", alignItems: "center", justifyContent: "center", padding: "24px", background: "color-mix(in srgb, var(--bg, #000) 82%, transparent)", backdropFilter: "blur(6px)", outline: "none" }, children: /* @__PURE__ */ jsxs3("div", { style: { width: "min(960px, 100%)", maxHeight: "100%", overflowY: "auto", display: "grid", gridTemplateColumns: "minmax(0, 1fr) 240px", gap: "18px", alignItems: "start" }, class: "today-triage", children: [
923
+ /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: "12px", minWidth: 0 }, children: [
924
+ /* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", gap: "10px", fontSize: "12px", color: "var(--ink-2)" }, children: [
925
+ /* @__PURE__ */ jsx3("b", { style: { color: "var(--ink)", fontSize: "13px" }, children: "Start the day" }),
926
+ /* @__PURE__ */ jsxs3("span", { children: [
927
+ sorted,
928
+ " of ",
929
+ total,
930
+ " sorted"
931
+ ] }),
932
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: onClose, style: { marginLeft: "auto", font: "inherit", fontSize: "12px", padding: "2px 8px", borderRadius: "7px", border: "1px solid var(--hair-2)", background: "transparent", color: "var(--ink-2)", cursor: "pointer" }, children: "Close \xB7 Esc" })
933
+ ] }),
934
+ /* @__PURE__ */ jsx3("div", { role: "progressbar", "aria-valuemin": 0, "aria-valuemax": total, "aria-valuenow": sorted, style: { height: "6px", borderRadius: "4px", background: soft("--ink", 8), overflow: "hidden" }, children: /* @__PURE__ */ jsx3("i", { style: { display: "block", height: "100%", width: `${pct}%`, background: "linear-gradient(90deg, var(--blue), var(--purple))", transition: "width .3s var(--ease)" } }) }),
935
+ current ? /* @__PURE__ */ jsxs3("div", { class: "today-slide", style: { padding: "20px 22px", borderRadius: "16px", background: "var(--card)", border: "1px solid var(--hair-2)", boxShadow: "0 20px 50px rgba(0,0,0,.35)", display: "flex", flexDirection: "column", gap: "16px" }, children: [
936
+ /* @__PURE__ */ jsx3(EntryBody, { e: current, big: true }),
937
+ needsProject(current) && /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3(ProjectPicker, { projects: projectsFor(projects, current.item.account), value: project, onChange: (v) => setPicks({ ...picks, [current.item.id]: v }) }) }),
938
+ /* @__PURE__ */ jsxs3("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, minmax(0, 1fr))", gap: "8px" }, children: [
939
+ keyTile("S", move?.label ?? "Start", acting.busy || !move?.ready, () => void take(current, "start"), true),
940
+ keyTile("O", "Open link", acting.busy, () => api.open(current)),
941
+ keyTile("L", "Later", acting.busy, () => decide(current.item.id, "later")),
942
+ keyTile("H", "Hide", acting.busy || !canHide(current), () => void take(current, "hide"))
943
+ ] })
944
+ ] }, current.item.id) : finished ? /* @__PURE__ */ jsxs3("div", { class: "today-slide", style: { padding: "26px 22px", borderRadius: "16px", background: "var(--card)", border: "1px solid var(--hair-2)", display: "flex", flexDirection: "column", gap: "14px" }, children: [
945
+ /* @__PURE__ */ jsxs3("h3", { style: { margin: 0, fontSize: "20px", fontWeight: 650 }, children: [
946
+ "All sorted \u2014 ",
947
+ summary.started,
948
+ " started, ",
949
+ summary.hidden,
950
+ " hidden, ",
951
+ summary.later,
952
+ " for later"
953
+ ] }),
954
+ /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
955
+ /* @__PURE__ */ jsx3(Btn, { label: "Close", style: primaryStyle, onClick: onClose }),
956
+ summary.later > 0 && /* @__PURE__ */ jsx3(Btn, { label: "Start over", style: ghostStyle, onClick: reset })
957
+ ] })
958
+ ] }) : /* @__PURE__ */ jsxs3("div", { class: "today-slide", style: { padding: "26px 22px", borderRadius: "16px", background: "var(--card)", border: "1px solid var(--hair-2)", display: "flex", flexDirection: "column", gap: "14px" }, children: [
959
+ /* @__PURE__ */ jsx3("h3", { style: { margin: 0, fontSize: "18px", fontWeight: 650 }, children: "Needs you and In progress are sorted" }),
960
+ /* @__PURE__ */ jsxs3("div", { style: { fontSize: "13px", color: "var(--ink-2)" }, children: [
961
+ "Continue with To do (",
962
+ todoLeft,
963
+ ")?"
964
+ ] }),
965
+ /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
966
+ /* @__PURE__ */ jsx3(Btn, { label: "Continue", style: primaryStyle, onClick: () => setWithTodo(true) }),
967
+ /* @__PURE__ */ jsx3(Btn, { label: "Finish", style: ghostStyle, onClick: () => setSkipTodo(true) })
968
+ ] })
969
+ ] })
970
+ ] }),
971
+ /* @__PURE__ */ jsxs3("div", { style: { padding: "14px", borderRadius: "12px", background: "var(--card)", border: "1px solid var(--hair)", display: "flex", flexDirection: "column", gap: "4px", fontSize: "12.5px", color: "var(--ink-2)" }, children: [
972
+ /* @__PURE__ */ jsx3("div", { style: { width: "96px", height: "96px", borderRadius: "50%", margin: "4px auto 10px", display: "grid", placeItems: "center", background: `conic-gradient(var(--green) 0 ${pct}%, ${soft("--ink", 8)} ${pct}% 100%)` }, children: /* @__PURE__ */ jsxs3("span", { style: { width: "72px", height: "72px", borderRadius: "50%", background: "var(--card)", display: "grid", placeItems: "center", fontSize: "18px", fontWeight: 700, color: "var(--ink)" }, children: [
973
+ pct,
974
+ "%"
975
+ ] }) }),
976
+ counts.map((c) => /* @__PURE__ */ jsxs3("div", { style: { display: "flex", justifyContent: "space-between", padding: "3px 0" }, children: [
977
+ /* @__PURE__ */ jsx3("span", { children: c.title }),
978
+ /* @__PURE__ */ jsx3("b", { style: { color: "var(--ink)" }, children: c.left })
979
+ ] }, c.id))
980
+ ] })
981
+ ] }) });
982
+ }
983
+
984
+ // src/view.tsx
985
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "preact/jsx-runtime";
986
+ var SOURCES = [{ id: "linear", label: "Linear" }, { id: "slack", label: "Slack" }, { id: "github", label: "GitHub" }];
454
987
  function View({ forge }) {
455
- const [days, setDays] = useState2([]);
456
- const [day, setDay] = useState2(null);
988
+ useReadingStyles();
989
+ const [days, setDays] = useState4([]);
990
+ const [day, setDay] = useState4(null);
457
991
  const { reply, error, reload, hurry } = useDigest(forge, day ? `/digest/${day}` : "/digest");
458
992
  const projects = useProjects(forge);
993
+ const [filters, setFilters] = useFilters();
994
+ const [folds, setFold] = useFolds();
459
995
  const digest = reply?.digest;
460
996
  const acting = useActing(forge, digest?.date, reload, hurry);
461
997
  const reading = reply?.reading;
462
998
  const isReading = acting.refreshing || !!reading;
463
- const [details, setDetails] = useState2(false);
999
+ const [details, setDetails] = useState4(false);
464
1000
  const problems = groupProblems(digest?.problems ?? []);
465
- const notes = notesLine(digest?.notes);
466
1001
  const enabled = reply?.enabled === true;
467
- const pending = reply?.pending ?? [];
468
- const liveNews = (digest?.items ?? []).filter((i) => i.state !== "dismissed").length;
469
- useEffect2(() => {
1002
+ const allNews = newsList(digest?.items ?? []);
1003
+ const allPending = reply?.pending ?? [];
1004
+ const everything = [...allNews, ...allPending];
1005
+ const accounts = [...new Set(everything.flatMap((x) => x.account ? [x.account] : []))];
1006
+ const present = SOURCES.filter((s) => everything.some((x) => x.source === s.id));
1007
+ const hasNone = everything.some((x) => !x.account);
1008
+ const active = { ...filters, account: accounts.includes(filters.account) || hasNone && filters.account === NO_ACCOUNT ? filters.account : "", source: present.some((s) => s.id === filters.source) ? filters.source : "" };
1009
+ const counts = countFor(allNews, allPending, active);
1010
+ const news = filterNews(allNews, active);
1011
+ const ready = acceptable(news);
1012
+ const pending = filterPending(allPending, active);
1013
+ const searching = active.query.trim() !== "";
1014
+ const filtered = active.account !== "" || active.source !== "" || searching;
1015
+ const set = (next) => setFilters({ ...filters, ...next });
1016
+ const groups = inboxGroups(news, pending);
1017
+ const lastSeen = useLastSeen();
1018
+ const search = useRef4(null);
1019
+ const allGroups = inboxGroups(allNews, allPending);
1020
+ const [triage, setTriage] = useState4(() => takeStartDay());
1021
+ const [decided, decide, resetDecisions] = useTriage(digest?.date);
1022
+ const toSort = allGroups.filter((g) => g.id === "needs" || g.id === "progress").reduce((n, g) => n + g.entries.length, 0);
1023
+ useEffect4(() => {
470
1024
  forge.route("/days").then((r) => setDays(r.days), () => {
471
1025
  });
472
1026
  }, [forge, digest?.readAt]);
473
- return /* @__PURE__ */ jsxs2("div", { style: { padding: "22px", display: "flex", flexDirection: "column", gap: "16px", maxWidth: "1180px" }, children: [
474
- /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
475
- 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: dayName(d) }, d)) }),
476
- digest && /* @__PURE__ */ jsx2("b", { style: { fontSize: "13px", fontWeight: 600 }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
477
- isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : /* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
478
- /* @__PURE__ */ jsxs2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
479
- enabled && /* @__PURE__ */ jsx2(ActionButton, { label: isReading ? "Reading\u2026" : "Read now", variant: "primary", size: "sm", disabled: isReading, loading: isReading, onClick: acting.refresh }),
480
- 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")) })
1027
+ return /* @__PURE__ */ jsxs4("div", { style: { padding: "22px", display: "flex", flexDirection: "column", gap: "14px", maxWidth: "1280px" }, children: [
1028
+ /* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
1029
+ /* @__PURE__ */ jsxs4("b", { style: { fontSize: "14px", fontWeight: 650, display: "flex", alignItems: "center", gap: "8px" }, children: [
1030
+ "Today",
1031
+ digest && days.length > 0 ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
1032
+ /* @__PURE__ */ jsx4("span", { style: { color: "var(--ink-3)", fontWeight: 400 }, children: "\xB7" }),
1033
+ /* @__PURE__ */ jsx4("select", { "aria-label": "Day", value: digest.date, onChange: (e) => setDay(e.target.value), style: { font: "inherit", fontSize: "13px", fontWeight: 600, padding: "4px 8px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: days.map((d) => /* @__PURE__ */ jsx4("option", { value: d, children: dayName(d) }, d)) })
1034
+ ] }) : digest ? ` \xB7 ${dayName(digest.date)}` : null
1035
+ ] }),
1036
+ /* @__PURE__ */ jsxs4("span", { style: { display: "flex", gap: "8px", marginLeft: "auto" }, children: [
1037
+ enabled && digest && toSort > 0 && isToday(digest.date, /* @__PURE__ */ new Date()) && /* @__PURE__ */ jsx4(ActionButton, { label: "Start the day", variant: "secondary", size: "sm", onClick: () => setTriage(true) }),
1038
+ enabled && /* @__PURE__ */ jsx4(ActionButton, { label: isReading ? "Reading\u2026" : "Refresh", variant: "primary", size: "sm", disabled: isReading, loading: isReading, onClick: acting.refresh }),
1039
+ reply && /* @__PURE__ */ jsx4(ActionButton, { label: enabled ? "Turn off" : "Turn on", variant: enabled ? "secondary" : "primary", size: "sm", disabled: acting.busy, onClick: async () => {
1040
+ await acting.run(() => forge.action(enabled ? "disable" : "enable"));
1041
+ } })
481
1042
  ] })
482
1043
  ] }),
483
- 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." }),
484
- (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) }),
485
- problems.length > 0 && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
486
- problems.map((g) => /* @__PURE__ */ jsx2(ProblemRow, { group: g, acting, details }, g.account)),
487
- /* @__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" })
1044
+ /* @__PURE__ */ jsx4("div", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: isReading ? /* @__PURE__ */ jsx4(ReadingLine, { reading }) : digest ? readLine(digest) : "Not read yet" }),
1045
+ reply && !enabled && /* @__PURE__ */ jsx4("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 Refresh. Each reading spends your account's usage. Research it proposes can start sessions on its own, a few a day." }),
1046
+ (error || digest?.error) && /* @__PURE__ */ jsx4("div", { style: { padding: "8px 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) }),
1047
+ problems.length > 0 && /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
1048
+ problems.map((g) => /* @__PURE__ */ jsx4(ProblemRow, { group: g, acting, details }, g.account)),
1049
+ /* @__PURE__ */ jsx4("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" })
488
1050
  ] }),
489
- notes && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12px", color: "var(--ink-3)" }, children: notes }),
490
- !digest && isReading ? /* @__PURE__ */ jsx2(SkeletonRows, {}) : !digest ? /* @__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." }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
491
- /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
492
- /* @__PURE__ */ jsxs2("h3", { style: heading, children: [
493
- "News \xB7 ",
494
- liveNews
495
- ] }),
496
- digest.items.length === 0 && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12.5px", color: "var(--ink-2)" }, children: reply?.firstReading ? FIRST_READING_NOTE : "Nothing new." }),
497
- byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
498
- account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
499
- sections2.map(({ title, items }) => /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
500
- /* @__PURE__ */ jsxs2("h4", { style: subheading, children: [
501
- title,
502
- " \xB7 ",
503
- items.length
504
- ] }),
505
- items.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id))
506
- ] }, title))
507
- ] }, account ?? ""))
508
- ] }),
509
- /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
510
- /* @__PURE__ */ jsxs2("h3", { style: heading, children: [
511
- "Pending \xB7 ",
512
- pending.length,
513
- reply?.pendingCapped && /* @__PURE__ */ jsxs2("span", { style: { fontWeight: 400, fontSize: "11.5px", color: "var(--ink-3)" }, children: [
514
- " \xB7 ",
515
- CAPPED_NOTE,
516
- " \u2014 ",
517
- /* @__PURE__ */ jsx2("a", { href: GITHUB_SEARCH, target: "_blank", rel: "noopener noreferrer", style: { color: "inherit" }, children: "see GitHub" })
518
- ] })
519
- ] }),
520
- pending.length === 0 && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12.5px", color: "var(--ink-2)" }, children: PENDING_EMPTY }),
521
- pendingByAccount(pending).map(({ account, items }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
522
- account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
523
- items.map((p) => /* @__PURE__ */ jsx2(PendingRow, { item: p, projects, acting, forge }, p.id))
524
- ] }, account ?? ""))
525
- ] })
526
- ] })
1051
+ /* @__PURE__ */ jsx4(Notes, { notes: digest?.notes }),
1052
+ !digest && isReading ? /* @__PURE__ */ jsx4(SkeletonRows, {}) : !digest ? /* @__PURE__ */ jsx4(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Refresh to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : /* @__PURE__ */ jsx4(Fragment3, { children: /* @__PURE__ */ jsx4(
1053
+ Inbox,
1054
+ {
1055
+ forge,
1056
+ groups,
1057
+ folds,
1058
+ setFold,
1059
+ searching,
1060
+ projects,
1061
+ acting,
1062
+ lastSeen,
1063
+ keys: !triage,
1064
+ focusSearch: () => search.current?.focus(),
1065
+ clearSearch: () => {
1066
+ set({ query: "" });
1067
+ search.current?.blur();
1068
+ },
1069
+ empty: filtered && everything.length > 0 ? "Nothing matches." : reply?.firstReading ? FIRST_READING_NOTE : PENDING_EMPTY,
1070
+ footer: reply?.pendingCapped ? /* @__PURE__ */ jsxs4("div", { style: { fontSize: "11.5px", color: "var(--ink-3)", padding: "8px 12px" }, children: [
1071
+ CAPPED_NOTE,
1072
+ " \u2014 ",
1073
+ /* @__PURE__ */ jsx4("a", { href: GITHUB_SEARCH, target: "_blank", rel: "noopener noreferrer", style: { color: "inherit" }, children: "see GitHub" })
1074
+ ] }) : null,
1075
+ header: /* @__PURE__ */ jsxs4(Fragment3, { children: [
1076
+ /* @__PURE__ */ jsx4("input", { ref: search, type: "search", "aria-label": "Search", placeholder: "Search\u2026 \u2318F", value: filters.query, onInput: (e) => set({ query: e.target.value }), style: { font: "inherit", fontSize: "12.5px", padding: "5px 10px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--elev)", color: "var(--ink)", width: "100%", boxSizing: "border-box" } }),
1077
+ (accounts.length > 1 || accounts.length > 0 && hasNone) && /* @__PURE__ */ jsxs4("div", { role: "group", "aria-label": "Account", style: { display: "flex", alignItems: "center", gap: "5px", flexWrap: "wrap" }, children: [
1078
+ /* @__PURE__ */ jsx4(Pill, { label: "All", n: counts.total, on: !active.account, onClick: () => set({ account: "" }) }),
1079
+ accounts.map((a) => /* @__PURE__ */ jsx4(Pill, { label: a, token: accountToken(a), n: counts.accounts[a] ?? 0, on: active.account === a, onClick: () => set({ account: a }) }, a)),
1080
+ hasNone && /* @__PURE__ */ jsx4(Pill, { label: "No account", n: counts.noAccount, on: active.account === NO_ACCOUNT, onClick: () => set({ account: NO_ACCOUNT }) })
1081
+ ] }),
1082
+ /* @__PURE__ */ jsxs4("div", { role: "group", "aria-label": "Source", style: { display: "flex", alignItems: "center", gap: "5px", flexWrap: "wrap" }, children: [
1083
+ /* @__PURE__ */ jsx4(Pill, { label: "All", n: counts.sources.linear + counts.sources.slack + counts.sources.github, on: !active.source, onClick: () => set({ source: "" }) }),
1084
+ present.map((s) => /* @__PURE__ */ jsx4(Pill, { label: s.label, n: counts.sources[s.id], on: active.source === s.id, onClick: () => set({ source: s.id }) }, s.id)),
1085
+ filtered && /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => setFilters(NO_FILTERS), style: { font: "inherit", fontSize: "11.5px", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--ink-3)" }, children: "Clear" })
1086
+ ] }),
1087
+ ready.length > 0 && digest && /* @__PURE__ */ jsx4(Btn, { label: `Accept ${ready.length === 1 ? "it" : `the ${ready.length}`}`, style: primaryStyle, disabled: acting.busy, onClick: () => acting.run(() => forge.action("accept-all", { date: digest.date, ids: ready.map((i) => i.id).join(",") })) })
1088
+ ] })
1089
+ }
1090
+ ) }),
1091
+ triage && digest && /* @__PURE__ */ jsx4(Triage, { forge, groups: allGroups, done: decided, decide, reset: resetDecisions, projects, acting, onClose: () => setTriage(false) })
527
1092
  ] });
528
1093
  }
529
1094
  var view_default = definePanel({ id: "main", title: "Today", component: View });