forge-cw 0.1.27 → 0.1.28

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,4 +1,5 @@
1
1
  // src/banner.tsx
2
+ import { useState as useState2 } from "preact/hooks";
2
3
  import { definePanel } from "@forge-dev/sdk";
3
4
 
4
5
  // src/ops.ts
@@ -33,6 +34,20 @@ function groupProblems(problems) {
33
34
  var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
34
35
  var problemsLabel = (n) => `\u26A0 ${n} account problem${n === 1 ? "" : "s"}`;
35
36
  var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
37
+ function titleFor(i) {
38
+ if (!i.issueKey) return i.title;
39
+ const key = i.issueKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
40
+ const rest = i.title.replace(new RegExp(`^\\s*\\[?${key}\\]?\\s*[:\\-\u2013\u2014]?\\s*`, "i"), "");
41
+ return rest.trim() ? rest : i.title;
42
+ }
43
+ var SOURCE_NAMES = { linear: "Linear", slack: "Slack", github: "GitHub" };
44
+ function whoOf(i) {
45
+ const who = i.who.trim();
46
+ return !who || who.toLowerCase() === SOURCE_NAMES[i.source].toLowerCase() ? null : who;
47
+ }
48
+ var pendingLabel = (p) => p.kind === "ci" ? "CI failing" : p.kind === "review" ? "Review requested" : p.source === "linear" ? p.started ? "In progress" : "To do" : "Assigned";
49
+ var pendingIn = (items, account) => account ? items.filter((p) => p.account === account) : items;
50
+ var FIRST_READING_NOTE = "First reading \u2014 what you have open is under Pending.";
36
51
 
37
52
  // src/rows.tsx
38
53
  import { useCallback, useEffect, useRef, useState } from "preact/hooks";
@@ -131,6 +146,12 @@ function useActing(forge, date, reload, hurry = () => {
131
146
  const act = (item, op, project) => run(async () => {
132
147
  if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
133
148
  });
149
+ const startPending = (item, project) => run(async () => {
150
+ await forge.action("pending-start", { id: item.id, ...project ? { project } : {} });
151
+ });
152
+ const hidePending = (item) => run(async () => {
153
+ await forge.action("pending-hide", { id: item.id });
154
+ });
134
155
  const refresh = async () => {
135
156
  if (reading.current) return;
136
157
  reading.current = true;
@@ -155,7 +176,7 @@ function useActing(forge, date, reload, hurry = () => {
155
176
  const s = await forge.action("reconnect", { account });
156
177
  if (s) forge.openSession(s.project, s.sessionDir);
157
178
  });
158
- return { busy, refreshing, retrying, retry, reconnect, run, act, refresh };
179
+ return { busy, refreshing, retrying, retry, reconnect, run, act, refresh, startPending, hidePending };
159
180
  }
160
181
  function dayOf(date) {
161
182
  const [y, m, d] = date.split("-").map(Number);
@@ -174,12 +195,14 @@ function foldedNow(folded, items) {
174
195
  return folded || !items.some((i) => i.state === "proposed" || i.state === "failed");
175
196
  }
176
197
  var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
198
+ function windowTime(at, read) {
199
+ if (at.toDateString() === read.toDateString()) return clock(at);
200
+ const yesterday = new Date(read.getTime() - 864e5).toDateString() === at.toDateString();
201
+ return `${yesterday ? "yesterday" : at.toLocaleDateString("en-US", { month: "short", day: "numeric" })} ${clock(at)}`;
202
+ }
177
203
  function readLine(d) {
178
204
  const read = new Date(d.readAt);
179
- const since = new Date(d.since);
180
- const same = read.toDateString() === since.toDateString();
181
- const day = new Date(read.getTime() - 864e5).toDateString() === since.toDateString() ? "yesterday " : `${since.toLocaleDateString("en-US", { month: "short", day: "numeric" })} `;
182
- return `Read at ${clock(read)} \xB7 Linear, Slack and GitHub since ${same ? "" : day}${clock(since)}`;
205
+ return `Read at ${clock(read)} \xB7 changes since ${windowTime(new Date(d.windowStart ?? d.since), read)}`;
183
206
  }
184
207
  function ago(iso, now = /* @__PURE__ */ new Date()) {
185
208
  const t = new Date(iso);
@@ -255,17 +278,17 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
255
278
  /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
256
279
  /* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
257
280
  item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
258
- /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item.title })
281
+ /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
259
282
  ] }),
260
283
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
261
- /* @__PURE__ */ jsx(Avatar, { who: item.who }),
262
- /* @__PURE__ */ jsxs("span", { children: [
284
+ whoOf(item) && /* @__PURE__ */ jsx(Avatar, { who: item.who }),
285
+ /* @__PURE__ */ jsx("span", { children: whoOf(item) ? /* @__PURE__ */ jsxs(Fragment, { children: [
263
286
  item.who,
264
287
  " ",
265
288
  where,
266
289
  " ",
267
290
  strong(item.where)
268
- ] }),
291
+ ] }) : strong(item.where) }),
269
292
  /* @__PURE__ */ jsx(Sep, {}),
270
293
  /* @__PURE__ */ jsx("span", { children: ago(item.when) }),
271
294
  item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -311,6 +334,55 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
311
334
  ] })
312
335
  ] });
313
336
  };
337
+ var PENDING_TOKEN = { ci: "--red", review: "--blue", issue: "--green" };
338
+ var PendingRow = ({ item, projects = EMPTY_PROJECTS, acting, forge, compact }) => {
339
+ const [project, setProject] = useState(item.project ?? "");
340
+ const token = PENDING_TOKEN[item.kind];
341
+ const target = item.project ?? project;
342
+ 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: [
343
+ /* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
344
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
345
+ /* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
346
+ item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
347
+ /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
348
+ ] }),
349
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
350
+ /* @__PURE__ */ jsxs("span", { children: [
351
+ item.repo ? strong(item.repo) : null,
352
+ item.repo && item.state ? " \xB7 " : "",
353
+ item.state
354
+ ] }),
355
+ (item.repo || item.state) && /* @__PURE__ */ jsx(Sep, {}),
356
+ /* @__PURE__ */ jsx("span", { children: ago(item.when) }),
357
+ item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
358
+ /* @__PURE__ */ jsx(Sep, {}),
359
+ /* @__PURE__ */ jsx(AccountChip, { account: item.account })
360
+ ] }),
361
+ /* @__PURE__ */ jsx(Sep, {}),
362
+ /* @__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: [
363
+ "View in ",
364
+ SOURCE_LABEL[item.source],
365
+ " \u2197"
366
+ ] }),
367
+ item.project && /* @__PURE__ */ jsxs(Fragment, { children: [
368
+ /* @__PURE__ */ jsx(Sep, {}),
369
+ /* @__PURE__ */ jsxs("span", { children: [
370
+ "project ",
371
+ strong(item.project)
372
+ ] })
373
+ ] })
374
+ ] })
375
+ ] }),
376
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
377
+ /* @__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) }),
378
+ item.targetSession ? /* @__PURE__ */ jsx(Btn, { label: "Open task", onClick: () => forge.openSession(item.targetSession.project, item.targetSession.sessionDir) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
379
+ !item.project && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
380
+ /* @__PURE__ */ jsx(Btn, { label: item.kind === "review" ? "Review" : "Start", disabled: acting.busy || !target, onClick: () => acting.startPending(item, item.project ? void 0 : project) })
381
+ ] }),
382
+ /* @__PURE__ */ jsx(Btn, { label: "Hide", style: ghostStyle, disabled: acting.busy, onClick: () => acting.hidePending(item) })
383
+ ] })
384
+ ] });
385
+ };
314
386
  var READING_CSS = `
315
387
  @keyframes today-spin { to { transform: rotate(360deg) } }
316
388
  @keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
@@ -392,13 +464,32 @@ var done = (items, pick) => items.filter((i) => i.state === "done" && pick(i.kin
392
464
  function shell(children) {
393
465
  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 }) });
394
466
  }
395
- function Strip({ title, children, actions }) {
467
+ var PENDING_SHOWN = 5;
468
+ function PendingFold({ pending, projects, acting, forge }) {
469
+ const [open, setOpen] = useState2(false);
470
+ if (pending.length === 0) return null;
471
+ return /* @__PURE__ */ jsxs2("div", { style: { marginTop: "10px" }, children: [
472
+ /* @__PURE__ */ jsxs2("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), style: { font: "inherit", fontSize: "12px", fontWeight: 600, padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--ink-2)" }, children: [
473
+ open ? "\u25BE" : "\u25B8",
474
+ " Pending \xB7 ",
475
+ pending.length
476
+ ] }),
477
+ open && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px", marginTop: "8px" }, children: [
478
+ pending.slice(0, PENDING_SHOWN).map((p) => /* @__PURE__ */ jsx2(PendingRow, { item: p, projects, acting, forge, compact: true }, p.id)),
479
+ /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(Btn, { label: "See all \u2192", style: ghostStyle, onClick: () => forge.openPage() }) })
480
+ ] })
481
+ ] });
482
+ }
483
+ function Strip({ title, children, actions, below }) {
396
484
  return shell(
397
- /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "10px", padding: "9px 16px", fontSize: "12.5px", color: "var(--ink-2)" }, children: [
398
- /* @__PURE__ */ jsx2("span", { style: { color: "var(--orange)" }, children: "\u2600\uFE0E" }),
399
- /* @__PURE__ */ jsx2("b", { style: { color: "var(--ink)", fontWeight: 600 }, children: title }),
400
- children,
401
- /* @__PURE__ */ jsx2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: actions })
485
+ /* @__PURE__ */ jsxs2(Fragment2, { children: [
486
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "10px", padding: "9px 16px", fontSize: "12.5px", color: "var(--ink-2)" }, children: [
487
+ /* @__PURE__ */ jsx2("span", { style: { color: "var(--orange)" }, children: "\u2600\uFE0E" }),
488
+ /* @__PURE__ */ jsx2("b", { style: { color: "var(--ink)", fontWeight: 600 }, children: title }),
489
+ children,
490
+ /* @__PURE__ */ jsx2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: actions })
491
+ ] }),
492
+ below && /* @__PURE__ */ jsx2("div", { style: { padding: "0 16px 10px" }, children: below })
402
493
  ] })
403
494
  );
404
495
  }
@@ -407,6 +498,8 @@ function Banner({ forge }) {
407
498
  const projects = useProjects(forge);
408
499
  const [chosen, choose] = useAccountFilter();
409
500
  const digest = reply?.digest;
501
+ const allPending = reply?.pending ?? [];
502
+ const pendingText = (list) => list.length ? ` \xB7 ${list.length} pending` : "";
410
503
  const acting = useActing(forge, digest?.date, reload, hurry);
411
504
  const reading = reply?.reading;
412
505
  const isReading = acting.refreshing || !!reading;
@@ -444,10 +537,11 @@ function Banner({ forge }) {
444
537
  );
445
538
  }
446
539
  if (!reply || !digest || digest.items.length === 0) {
447
- return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, children: [
540
+ return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, below: reply && /* @__PURE__ */ jsx2(PendingFold, { pending: allPending, projects, acting, forge }), children: [
448
541
  !reply ? failure(loadFailedLine(error)) : digest?.error ? failure(failedLine(digest.error)) : digest && /* @__PURE__ */ jsxs2("span", { children: [
449
- "\xB7 nothing new since ",
450
- clock(new Date(digest.readAt))
542
+ "\xB7 ",
543
+ reply.firstReading ? FIRST_READING_NOTE : `nothing new since ${clock(new Date(digest.readAt))}`,
544
+ pendingText(allPending)
451
545
  ] }),
452
546
  problemsLink,
453
547
  note
@@ -464,7 +558,7 @@ function Banner({ forge }) {
464
558
  return /* @__PURE__ */ jsxs2(Strip, { title: shortDay(/* @__PURE__ */ new Date(), digest.date), actions: /* @__PURE__ */ jsxs2(Fragment2, { children: [
465
559
  refreshBtn,
466
560
  /* @__PURE__ */ jsx2(Btn, { label: "See all \u2192", style: ghostStyle, onClick: () => forge.openPage() })
467
- ] }), children: [
561
+ ] }), below: /* @__PURE__ */ jsx2(PendingFold, { pending: pendingIn(allPending, account), projects, acting, forge }), children: [
468
562
  /* @__PURE__ */ jsxs2("span", { children: [
469
563
  "\xB7 ",
470
564
  done(items, startsTask),
@@ -472,7 +566,8 @@ function Banner({ forge }) {
472
566
  done(items, (k) => k === "research"),
473
567
  " researching \xB7 ",
474
568
  done(items, (k) => k === "to-task"),
475
- " sent"
569
+ " sent",
570
+ pendingText(pendingIn(allPending, account))
476
571
  ] }),
477
572
  digest.error && failure(failedLine(digest.error)),
478
573
  problemsLink,
@@ -516,6 +611,7 @@ function Banner({ forge }) {
516
611
  notes && /* @__PURE__ */ jsx2("div", { style: { marginBottom: "8px", fontSize: "11.5px", color: "var(--ink-3)" }, children: notes }),
517
612
  problemRows,
518
613
  /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: shown.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id)) }),
614
+ /* @__PURE__ */ jsx2(PendingFold, { pending: pendingIn(allPending, account), projects, acting, forge }),
519
615
  /* @__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." })
520
616
  ] })
521
617
  );
@@ -168,6 +168,62 @@ function shouldRead(now, time, lastReadAt) {
168
168
  function pendingCount(d) {
169
169
  return d.items.filter((i) => i.state === "proposed").length;
170
170
  }
171
+ var PENDING_MAX_AGE = 30 * 24 * 60 * 60 * 1e3;
172
+ var isRecent = (when, now) => {
173
+ const t = Date.parse(when);
174
+ return !Number.isNaN(t) && now.getTime() - t <= PENDING_MAX_AGE;
175
+ };
176
+ function pendingId(source, kind, link, account) {
177
+ return createHash("sha1").update(`pending
178
+ ${source}
179
+ ${kind}
180
+ ${link}
181
+ ${account ?? ""}`).digest("hex").slice(0, 16);
182
+ }
183
+ var rank = (p) => p.kind === "ci" ? 0 : p.kind === "review" ? 1 : p.source === "linear" ? p.started ? 2 : 3 : 4;
184
+ var sortPending = (items) => [...items].sort((a, b) => rank(a) - rank(b) || Date.parse(b.when) - Date.parse(a.when));
185
+ function parseReaderPending(out, known, now) {
186
+ let root;
187
+ try {
188
+ root = extractJson(out);
189
+ } catch {
190
+ return void 0;
191
+ }
192
+ if (!isRecord(root) || !Array.isArray(root.pending)) return void 0;
193
+ const seen = /* @__PURE__ */ new Set();
194
+ const list = [];
195
+ for (const raw of root.pending) {
196
+ if (!isRecord(raw)) continue;
197
+ const str = (k) => typeof raw[k] === "string" && raw[k].trim() ? raw[k] : void 0;
198
+ const link = str("link");
199
+ const title = str("title");
200
+ const when = str("when");
201
+ if (!link || !title || !when || !isRecent(when, now)) continue;
202
+ let url;
203
+ try {
204
+ url = new URL(link);
205
+ } catch {
206
+ continue;
207
+ }
208
+ if (url.protocol !== "http:" && url.protocol !== "https:" || /(^|\.)github\.com$/i.test(url.hostname)) continue;
209
+ const id = pendingId("linear", "issue", link, known.account);
210
+ if (seen.has(id)) continue;
211
+ seen.add(id);
212
+ const item = { id, source: "linear", kind: "issue", title, link, when };
213
+ if (known.account) item.account = known.account;
214
+ const state = str("state");
215
+ if (state) item.state = state.slice(0, 40);
216
+ if (raw.started === true) item.started = true;
217
+ const key = str("issueKey");
218
+ if (key) item.issueKey = key;
219
+ const project = str("project");
220
+ if (project && known.projects.includes(project)) item.project = project;
221
+ const t = raw.targetSession;
222
+ if (isRecord(t) && typeof t.project === "string" && typeof t.sessionDir === "string" && known.sessions.includes(`${t.project}::${t.sessionDir}`)) item.targetSession = { project: t.project, sessionDir: t.sessionDir };
223
+ list.push(item);
224
+ }
225
+ return list;
226
+ }
171
227
 
172
228
  // src/run.ts
173
229
  import { homedir } from "node:os";
@@ -213,9 +269,11 @@ Item kinds (to-task | issue | request | research | review), exactly one per item
213
269
  - review: a GitHub review-request event, a pull request someone asked me to review; link is the pull request url, set project when the repo clearly belongs to a known project.
214
270
  - GitHub events with no matching session: a ci-failure becomes an issue (link is the pull request url, quote lists the failing checks); a mention or assigned event becomes a request or an issue; a comment or review on my pull request with no session becomes a request. Skip events that need nothing from me.
215
271
 
272
+ Pending (a snapshot of what is open now, whatever the date window): from Linear only, the issues assigned to me whose state is started or unstarted and that were updated in the last 30 days, following every page of list_issues. Never list Slack or GitHub there.
273
+
216
274
  Answer with ONLY a JSON object, no prose and no code fence:
217
- { "items": [ { "source": "linear" | "slack" | "github", "kind": "to-task" | "issue" | "request" | "research" | "review", "title": string, "who": string, "where": string, "when": ISO time of the latest activity, "quote"?: string, "link": string (permalink, issue URL or pull request URL), "issueKey"?: string, "targetSession"?: { "project": string, "sessionDir": string }, "project"?: string } ], "problems"?: [ string ] }
218
- Every item needs a link. Use an empty items array when there is nothing new.
275
+ { "items": [ { "source": "linear" | "slack" | "github", "kind": "to-task" | "issue" | "request" | "research" | "review", "title": string, "who": string, "where": string, "when": ISO time of the latest activity, "quote"?: string, "link": string (permalink, issue URL or pull request URL), "issueKey"?: string, "targetSession"?: { "project": string, "sessionDir": string }, "project"?: string } ], "pending": [ { "issueKey": string, "title": string (without the key), "state": string (the Linear state name), "started": boolean (true for a started state, false for unstarted), "link": string (issue URL), "when": ISO time of its last update, "project"?: string, "targetSession"?: { "project": string, "sessionDir": string } (an open session listed above that works on it) } ], "problems"?: [ string ] }
276
+ Every item needs a link. Use an empty items array when there is nothing new, and an empty pending array when nothing is open. If Linear could not be read, leave pending out.
219
277
  Problems are only for the Slack and Linear tools: if one is missing, still connecting or fails, do not report "nothing new" for it, add "slack: <short reason>" or "linear: <short reason>" to problems. Never put anything else in problems (GitHub is given to you as data, not a tool).`;
220
278
  }
221
279
 
@@ -322,6 +380,45 @@ async function fetchGithub(ctx, since, deadlineMs = DEADLINE_MS) {
322
380
  return { items: [], error: errorMessage(e) };
323
381
  }
324
382
  }
383
+ async function fetchPending(ctx, now, deadlineMs = DEADLINE_MS) {
384
+ try {
385
+ const search = (flag, kind = "prs") => gh(ctx, ["search", kind, flag, "--state=open", "--sort=updated", `--limit=${MAX_PRS}`, "--json", SEARCH_FIELDS]);
386
+ const [mine, asked, issues] = await Promise.all([search("--author=@me"), search("user-review-requested:@me"), search("--assignee=@me", "issues")]);
387
+ const items = [];
388
+ const add = (kind, f, state) => {
389
+ if (!isRecent(f.updatedAt, now)) return;
390
+ items.push({ id: pendingId("github", kind, f.url), source: "github", kind, title: f.title, link: f.url, when: f.updatedAt, repo: repoOf(f), ...state ? { state } : {} });
391
+ };
392
+ for (const pr of asked) add("review", pr);
393
+ for (const i of issues) add("issue", i);
394
+ const prs = mine.slice(0, MAX_PRS).filter((pr) => isRecent(pr.updatedAt, now));
395
+ const deadline = Date.now() + deadlineMs;
396
+ let next = 0;
397
+ let unread = 0;
398
+ const worker = async () => {
399
+ while (next < prs.length) {
400
+ const pr = prs[next++];
401
+ if (Date.now() >= deadline) {
402
+ unread++;
403
+ continue;
404
+ }
405
+ try {
406
+ const view = await gh(ctx, ["pr", "view", pr.url, "--json", "statusCheckRollup"]);
407
+ const failed = (view.statusCheckRollup ?? []).filter((c) => FAILED.has(c.conclusion ?? c.state ?? ""));
408
+ if (failed.length) add("ci", pr, `failing: ${[...new Set(failed.map((c) => c.name ?? c.context ?? "check"))].join(", ").slice(0, 80)}`);
409
+ } catch {
410
+ unread++;
411
+ }
412
+ }
413
+ };
414
+ await Promise.all(Array.from({ length: Math.min(CONCURRENCY, prs.length) }, worker));
415
+ if (unread) return { items: [], error: `${unread} pull request${unread === 1 ? "" : "s"} could not be checked` };
416
+ const capped = mine.length >= MAX_PRS || asked.length >= MAX_PRS || issues.length >= MAX_PRS;
417
+ return { items, ...capped ? { capped: true } : {} };
418
+ } catch (e) {
419
+ return { items: [], error: errorMessage(e) };
420
+ }
421
+ }
325
422
 
326
423
  // src/run.ts
327
424
  var DAY = 24 * 60 * 60 * 1e3;
@@ -398,10 +495,12 @@ async function readAccount(ctx, account, o) {
398
495
  const problems = parseReaderProblems(out.text).map((p) => toProblem(account, p));
399
496
  const fetched = new Set(github.map((e) => e.pr));
400
497
  const toReview = new Set(github.filter((e) => e.type === "review-request").map((e) => e.pr));
401
- const items = parseReaderOutput(out.text, { projects, sessions: sessions.map((s) => `${s.project}::${s.sessionDir}`), account });
498
+ const known = { projects, sessions: sessions.map((s) => `${s.project}::${s.sessionDir}`), account };
499
+ const items = parseReaderOutput(out.text, known);
500
+ const pending = problems.some((p) => p.source === "linear") ? void 0 : parseReaderPending(out.text, known, o.now);
402
501
  const placed = checkGithub(items, fetched, toReview).map((i) => i.source === "github" ? { ...i, account: o.owners[i.project ?? i.targetSession?.project ?? ""] } : i);
403
502
  const fresh = dedupe(collapse(placed), o.handled);
404
- return { items: github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh, problems };
503
+ return { items: github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh, problems, pending };
405
504
  }
406
505
  async function readOne(ctx, account, o) {
407
506
  const finish = (r) => {
@@ -415,10 +514,17 @@ async function readOne(ctx, account, o) {
415
514
  return finish({ account, items: [], problems: [{ account, source: "reader", reason: error.replace(/\s+/g, " ").trim().slice(0, 160) }], error });
416
515
  }
417
516
  }
517
+ function placeGithub(items, projects, owners) {
518
+ return items.map((i) => {
519
+ const name = projects.find((p) => p.name.toLowerCase() === i.repo?.split("/")[1]?.toLowerCase())?.name;
520
+ return name ? { ...i, project: name, ...owners[name] ? { account: owners[name] } : {} } : i;
521
+ });
522
+ }
418
523
  async function reread(ctx, now, notes) {
419
524
  const lastReadAt = await ctx.storage.get("lastReadAt");
420
525
  const since = lastReadAt ?? new Date(now.getTime() - DAY).toISOString();
421
526
  const github = fetchGithub(ctx, since);
527
+ const githubPending = fetchPending(ctx, now);
422
528
  const [sessions, projects, handled, accounts] = await Promise.all([
423
529
  ctx.sessions.list(),
424
530
  ctx.projects.list(),
@@ -427,14 +533,18 @@ async function reread(ctx, now, notes) {
427
533
  ]);
428
534
  const owners = ownersOf(projects);
429
535
  if (progress) progress.accounts = Object.fromEntries(accounts.map((a) => [a, "reading"]));
430
- const results = await Promise.all(accounts.map((account, n) => readOne(ctx, account, { since, sessions, projects, owners, github: n === 0 ? github : void 0, handled: handled ?? {} })));
536
+ const results = await Promise.all(accounts.map((account, n) => readOne(ctx, account, { since, sessions, projects, owners, github: n === 0 ? github : void 0, handled: handled ?? {}, now })));
431
537
  const gh2 = await github;
538
+ const gp = await githubPending;
432
539
  if (gh2.error) notes.push(`GitHub: ${gh2.error}`);
433
540
  if (results[0].error && gh2.items.length) notes.push("GitHub: not read");
434
541
  const failed = results.filter((r) => r.error);
435
542
  if (failed.length === results.length) throw new Error(failed.length === 1 ? failed[0].error : failed.map((f) => `${f.account}: ${f.error}`).join("; "));
436
543
  const requested = gh2.error ? void 0 : new Set(gh2.requested ?? gh2.items.filter((e) => e.type === "review-request").map((e) => e.pr));
437
- return { items: collapse(results.flatMap((r) => r.items)), problems: results.flatMap((r) => r.problems), requested };
544
+ const pending = Object.fromEntries(results.map((r) => [r.account, r.pending]));
545
+ pending.github = gp.error ? void 0 : placeGithub(gp.items, projects, owners);
546
+ if (gp.error) notes.push(`GitHub pending: ${gp.error}`);
547
+ return { items: collapse(results.flatMap((r) => r.items)), problems: results.flatMap((r) => r.problems), requested, accounts, pending, githubCapped: gp.error ? void 0 : !!gp.capped };
438
548
  }
439
549
  async function rememberHandled(ctx, items, now) {
440
550
  const old = await ctx.storage.get("handled") ?? {};
@@ -443,6 +553,34 @@ async function rememberHandled(ctx, items, now) {
443
553
  for (const i of items) next[i.id] = i.when;
444
554
  await ctx.storage.set("handled", next);
445
555
  }
556
+ var PENDING = "pending/";
557
+ async function savePending(ctx, pending, accounts) {
558
+ for (const [source, items] of Object.entries(pending)) if (items) await ctx.storage.set(PENDING + source, items);
559
+ if (!accounts) return;
560
+ for (const key of await ctx.storage.list(PENDING)) {
561
+ const source = key.slice(key.lastIndexOf(PENDING) + PENDING.length);
562
+ if (source !== "github" && !accounts.includes(source)) await ctx.storage.delete(key);
563
+ }
564
+ }
565
+ var hiddenOf = async (ctx) => await ctx.storage.get("pendingHidden") ?? {};
566
+ async function allPending(ctx) {
567
+ const lists = await Promise.all((await ctx.storage.list(PENDING)).map((k) => ctx.storage.get(k)));
568
+ return lists.flatMap((l) => l ?? []);
569
+ }
570
+ async function pendingNow(ctx) {
571
+ const [all, hidden, started] = await Promise.all([allPending(ctx), hiddenOf(ctx), startedOf(ctx)]);
572
+ return sortPending(all.filter((p) => hidden[p.id] !== p.when).map((p) => started[p.id] && !p.targetSession ? { ...p, targetSession: started[p.id] } : p));
573
+ }
574
+ var startedOf = async (ctx) => await ctx.storage.get("pendingStarted") ?? {};
575
+ async function pruneHidden(ctx) {
576
+ const [all, hidden] = await Promise.all([allPending(ctx), hiddenOf(ctx)]);
577
+ const ids = new Set(all.map((p) => p.id));
578
+ const next = Object.fromEntries(Object.entries(hidden).filter(([id]) => ids.has(id)));
579
+ if (Object.keys(next).length !== Object.keys(hidden).length) await ctx.storage.set("pendingHidden", next);
580
+ const started = await startedOf(ctx);
581
+ const keep = Object.fromEntries(Object.entries(started).filter(([id]) => ids.has(id)));
582
+ if (Object.keys(keep).length !== Object.keys(started).length) await ctx.storage.set("pendingStarted", keep);
583
+ }
446
584
  function dropStaleReviews(items, requested) {
447
585
  if (!requested) return items;
448
586
  return items.filter((i) => !(i.kind === "review" && i.state === "proposed" && !requested.has(githubPage(i.link) ?? i.link)));
@@ -478,7 +616,7 @@ async function doRead(ctx, now) {
478
616
  const date = localDate(now);
479
617
  const notes = [];
480
618
  try {
481
- const { items: fresh, problems, requested } = await reread(ctx, now, notes);
619
+ const { items: fresh, problems, requested, accounts, pending, githubCapped } = await reread(ctx, now, notes);
482
620
  const lastReadAt = await ctx.storage.get("lastReadAt");
483
621
  await locked(async () => {
484
622
  const prev = await loadDigest(ctx, date);
@@ -489,11 +627,16 @@ async function doRead(ctx, now) {
489
627
  date,
490
628
  readAt: now.toISOString(),
491
629
  since: prev?.since ?? lastReadAt ?? new Date(now.getTime() - DAY).toISOString(),
630
+ windowStart: lastReadAt ?? new Date(now.getTime() - DAY).toISOString(),
631
+ ...prev?.firstReading ?? !lastReadAt ? { firstReading: true } : {},
492
632
  items,
493
633
  autoStarted: prev?.autoStarted ?? {},
494
634
  ...notes.length ? { notes } : {},
495
635
  ...problems.length ? { problems } : {}
496
636
  });
637
+ await savePending(ctx, pending, accounts);
638
+ if (githubCapped !== void 0) await ctx.storage.set("pendingCapped", githubCapped);
639
+ await pruneHidden(ctx);
497
640
  await rememberHandled(ctx, fresh, now);
498
641
  await ctx.storage.set("lastReadAt", now.toISOString());
499
642
  await ctx.storage.delete("lastFailedAt");
@@ -517,7 +660,7 @@ async function retryAccount(ctx, account, now) {
517
660
  let result;
518
661
  try {
519
662
  const [sessions, projects, handled] = await Promise.all([ctx.sessions.list(), ctx.projects.list(), ctx.storage.get("handled")]);
520
- result = await readOne(ctx, account, { since: prev.since, sessions, projects, owners: ownersOf(projects), handled: handled ?? {} });
663
+ result = await readOne(ctx, account, { since: prev.since, sessions, projects, owners: ownersOf(projects), handled: handled ?? {}, now });
521
664
  } finally {
522
665
  if (progress === mine && !Object.values(mine.accounts).includes("reading")) progress = void 0;
523
666
  }
@@ -531,6 +674,7 @@ async function retryAccount(ctx, account, now) {
531
674
  if (problems.length) next.problems = problems;
532
675
  else delete next.problems;
533
676
  await saveDigest(ctx, next);
677
+ await savePending(ctx, { [account]: result.pending });
534
678
  await rememberHandled(ctx, result.items, now);
535
679
  });
536
680
  await autoResearch(ctx, date);
@@ -717,6 +861,42 @@ async function acceptAll(ctx, date, id, project, account) {
717
861
  }
718
862
  return requireDigest(ctx, date);
719
863
  }
864
+ async function requirePending(ctx, id) {
865
+ const item = (await pendingNow(ctx)).find((p) => p.id === id);
866
+ if (!item) throw new ModuleError("not_found", "no such pending item");
867
+ return item;
868
+ }
869
+ function hidePending(ctx, id) {
870
+ return locked(async () => {
871
+ const item = await requirePending(ctx, id);
872
+ await ctx.storage.set("pendingHidden", { ...await hiddenOf(ctx), [id]: item.when });
873
+ return pendingNow(ctx);
874
+ });
875
+ }
876
+ var pendingInFlight = /* @__PURE__ */ new Set();
877
+ async function startPending(ctx, id, project) {
878
+ if (!await isEnabled(ctx)) throw new ModuleError("bad_request", OFF_MESSAGE);
879
+ const item = await locked(async () => {
880
+ const found = await requirePending(ctx, id);
881
+ if (pendingInFlight.has(id)) throw new ModuleError("bad_request", "item is already being handled");
882
+ pendingInFlight.add(id);
883
+ return found;
884
+ });
885
+ try {
886
+ const target = project ?? item.project;
887
+ if (!target) throw new ModuleError("bad_request", "pick a project");
888
+ const owner = (await ownersOf(await ctx.projects.list()))[target];
889
+ if (item.account && owner && owner !== item.account) throw new ModuleError("bad_request", "project belongs to another account");
890
+ const account = item.account ?? owner;
891
+ const url = githubPage(item.link) ?? item.link;
892
+ const input = { type: item.kind === "review" ? "review" : "work", project: target, task: url, ...account ? { account } : {} };
893
+ const session = await ctx.cw.start(input);
894
+ await locked(async () => ctx.storage.set("pendingStarted", { ...await startedOf(ctx), [id]: session }));
895
+ return { session };
896
+ } finally {
897
+ pendingInFlight.delete(id);
898
+ }
899
+ }
720
900
  function setFolded(ctx, date, folded) {
721
901
  return locked(async () => {
722
902
  if (folded) await ctx.storage.set(`folded/${date}`, true);
@@ -754,7 +934,9 @@ async function digestFor(ctx, date) {
754
934
  }
755
935
  const enabled = await isEnabled(ctx);
756
936
  const reading2 = readingNow();
757
- return { ...digest ? { digest, folded, enabled } : { digest: null, folded: false, enabled }, ...reading2 ? { reading: reading2 } : {} };
937
+ const pending = await pendingNow(ctx);
938
+ const pendingCapped = await ctx.storage.get("pendingCapped") === true;
939
+ return { ...digest ? { digest, folded, enabled } : { digest: null, folded: false, enabled }, pending, pendingCapped, firstReading: digest?.firstReading === true, ...reading2 ? { reading: reading2 } : {} };
758
940
  }
759
941
  var server_default = defineModule({
760
942
  routes: [
@@ -817,6 +999,20 @@ var server_default = defineModule({
817
999
  return { enabled: false };
818
1000
  }
819
1001
  }),
1002
+ defineAction({
1003
+ id: "pending-start",
1004
+ label: "Start",
1005
+ effect: "local",
1006
+ input: { id: { type: "string", required: true }, project: { type: "string" } },
1007
+ run: (input, ctx) => startPending(ctx, input.id, input.project)
1008
+ }),
1009
+ defineAction({
1010
+ id: "pending-hide",
1011
+ label: "Hide",
1012
+ effect: "local",
1013
+ input: { id: { type: "string", required: true } },
1014
+ run: async (input, ctx) => ({ pending: await hidePending(ctx, input.id) })
1015
+ }),
820
1016
  itemAction("send", "Send"),
821
1017
  itemAction("start", "Start"),
822
1018
  itemAction("research", "Research"),
@@ -52,6 +52,30 @@ function byAccount(items) {
52
52
  const rest = items.filter((i) => !i.account);
53
53
  return rest.length ? [...blocks, { sections: sections(rest) }] : blocks;
54
54
  }
55
+ function titleFor(i) {
56
+ if (!i.issueKey) return i.title;
57
+ const key = i.issueKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
58
+ const rest = i.title.replace(new RegExp(`^\\s*\\[?${key}\\]?\\s*[:\\-\u2013\u2014]?\\s*`, "i"), "");
59
+ return rest.trim() ? rest : i.title;
60
+ }
61
+ var SOURCE_NAMES = { linear: "Linear", slack: "Slack", github: "GitHub" };
62
+ function whoOf(i) {
63
+ const who = i.who.trim();
64
+ return !who || who.toLowerCase() === SOURCE_NAMES[i.source].toLowerCase() ? null : who;
65
+ }
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
+ var CAPPED_NOTE = "showing the latest 20";
76
+ var GITHUB_SEARCH = "https://github.com/pulls/review-requested";
77
+ var PENDING_EMPTY = "Nothing open \u2014 nice.";
78
+ var FIRST_READING_NOTE = "First reading \u2014 what you have open is under Pending.";
55
79
 
56
80
  // src/rows.tsx
57
81
  import { useCallback, useEffect, useRef, useState } from "preact/hooks";
@@ -131,6 +155,12 @@ function useActing(forge, date, reload, hurry = () => {
131
155
  const act = (item, op, project) => run(async () => {
132
156
  if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
133
157
  });
158
+ const startPending = (item, project) => run(async () => {
159
+ await forge.action("pending-start", { id: item.id, ...project ? { project } : {} });
160
+ });
161
+ const hidePending = (item) => run(async () => {
162
+ await forge.action("pending-hide", { id: item.id });
163
+ });
134
164
  const refresh = async () => {
135
165
  if (reading.current) return;
136
166
  reading.current = true;
@@ -155,7 +185,7 @@ function useActing(forge, date, reload, hurry = () => {
155
185
  const s = await forge.action("reconnect", { account });
156
186
  if (s) forge.openSession(s.project, s.sessionDir);
157
187
  });
158
- return { busy, refreshing, retrying, retry, reconnect, run, act, refresh };
188
+ return { busy, refreshing, retrying, retry, reconnect, run, act, refresh, startPending, hidePending };
159
189
  }
160
190
  function dayOf(date) {
161
191
  const [y, m, d] = date.split("-").map(Number);
@@ -170,12 +200,18 @@ function dayLabel(now, date) {
170
200
  return `${part} \xB7 your ${now.toLocaleDateString("en-US", { weekday: "long" })} ${now.getDate()}`;
171
201
  }
172
202
  var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
203
+ function windowTime(at, read) {
204
+ if (at.toDateString() === read.toDateString()) return clock(at);
205
+ const yesterday = new Date(read.getTime() - 864e5).toDateString() === at.toDateString();
206
+ return `${yesterday ? "yesterday" : at.toLocaleDateString("en-US", { month: "short", day: "numeric" })} ${clock(at)}`;
207
+ }
173
208
  function readLine(d) {
174
209
  const read = new Date(d.readAt);
175
- const since = new Date(d.since);
176
- const same = read.toDateString() === since.toDateString();
177
- const day = new Date(read.getTime() - 864e5).toDateString() === since.toDateString() ? "yesterday " : `${since.toLocaleDateString("en-US", { month: "short", day: "numeric" })} `;
178
- return `Read at ${clock(read)} \xB7 Linear, Slack and GitHub since ${same ? "" : day}${clock(since)}`;
210
+ return `Read at ${clock(read)} \xB7 changes since ${windowTime(new Date(d.windowStart ?? d.since), read)}`;
211
+ }
212
+ function dayName(date) {
213
+ const day = dayOf(date);
214
+ return `${day.toLocaleDateString("en-US", { weekday: "long" })} ${day.getDate()}`;
179
215
  }
180
216
  function ago(iso, now = /* @__PURE__ */ new Date()) {
181
217
  const t = new Date(iso);
@@ -251,17 +287,17 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
251
287
  /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
252
288
  /* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
253
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 }),
254
- /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item.title })
290
+ /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
255
291
  ] }),
256
292
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
257
- /* @__PURE__ */ jsx(Avatar, { who: item.who }),
258
- /* @__PURE__ */ jsxs("span", { children: [
293
+ whoOf(item) && /* @__PURE__ */ jsx(Avatar, { who: item.who }),
294
+ /* @__PURE__ */ jsx("span", { children: whoOf(item) ? /* @__PURE__ */ jsxs(Fragment, { children: [
259
295
  item.who,
260
296
  " ",
261
297
  where,
262
298
  " ",
263
299
  strong(item.where)
264
- ] }),
300
+ ] }) : strong(item.where) }),
265
301
  /* @__PURE__ */ jsx(Sep, {}),
266
302
  /* @__PURE__ */ jsx("span", { children: ago(item.when) }),
267
303
  item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -307,6 +343,55 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
307
343
  ] })
308
344
  ] });
309
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
+ ] })
393
+ ] });
394
+ };
310
395
  var READING_CSS = `
311
396
  @keyframes today-spin { to { transform: rotate(360deg) } }
312
397
  @keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
@@ -363,7 +448,9 @@ function ProblemRow({ group, acting, details = false }) {
363
448
  }
364
449
 
365
450
  // src/view.tsx
366
- import { jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
451
+ 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)" };
367
454
  function View({ forge }) {
368
455
  const [days, setDays] = useState2([]);
369
456
  const [day, setDay] = useState2(null);
@@ -377,13 +464,15 @@ function View({ forge }) {
377
464
  const problems = groupProblems(digest?.problems ?? []);
378
465
  const notes = notesLine(digest?.notes);
379
466
  const enabled = reply?.enabled === true;
467
+ const pending = reply?.pending ?? [];
468
+ const liveNews = (digest?.items ?? []).filter((i) => i.state !== "dismissed").length;
380
469
  useEffect2(() => {
381
470
  forge.route("/days").then((r) => setDays(r.days), () => {
382
471
  });
383
472
  }, [forge, digest?.readAt]);
384
473
  return /* @__PURE__ */ jsxs2("div", { style: { padding: "22px", display: "flex", flexDirection: "column", gap: "16px", maxWidth: "1180px" }, children: [
385
474
  /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
386
- days.length > 0 && /* @__PURE__ */ jsx2("select", { "aria-label": "Day", value: digest?.date ?? "", onChange: (e) => setDay(e.target.value), style: { font: "inherit", fontSize: "12.5px", padding: "5px 8px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: days.map((d) => /* @__PURE__ */ jsx2("option", { value: d, children: d }, d)) }),
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)) }),
387
476
  digest && /* @__PURE__ */ jsx2("b", { style: { fontSize: "13px", fontWeight: 600 }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
388
477
  isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : /* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
389
478
  /* @__PURE__ */ jsxs2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
@@ -398,17 +487,43 @@ function View({ forge }) {
398
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" })
399
488
  ] }),
400
489
  notes && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12px", color: "var(--ink-3)" }, children: notes }),
401
- !digest && isReading ? /* @__PURE__ */ jsx2(SkeletonRows, {}) : !digest || digest.items.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Read now to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
402
- account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
403
- sections2.map(({ title, items }) => /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
404
- /* @__PURE__ */ jsxs2("h4", { style: { margin: "4px 0", fontSize: "11px", fontWeight: 600, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" }, children: [
405
- title,
406
- " \xB7 ",
407
- items.length
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
+ ] })
408
519
  ] }),
409
- items.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id))
410
- ] }, title))
411
- ] }, account ?? ""))
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
+ ] })
412
527
  ] });
413
528
  }
414
529
  var view_default = definePanel({ id: "main", title: "Today", component: View });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-cw",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "A visual dashboard for your coding agents on Claude Code, Codex, Pi or OpenCode. Installs CW for you.",
5
5
  "license": "MIT",
6
6
  "type": "module",