@parallelworks/tandem-web 0.171.2 → 0.172.0

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.
@@ -4,24 +4,25 @@ import { DecisionCard as a } from "../../components/AgentWork.js";
4
4
  import { Editor as o } from "../../components/Editor.js";
5
5
  import { ArchiveIcon as s, ArrowRightIcon as c, CheckIcon as l, CommentIcon as u, FileTextIcon as d, InboxIcon as f, PriorityIcon as p, ProjectIcon as m, StatusIcon as h, UserIcon as g, usePriorityNames as _ } from "../../components/icons.js";
6
6
  import { PersonHoverCard as v } from "../../components/PersonHoverCard.js";
7
- import { parseApproval as y } from "../../lib/approval.js";
8
- import { copyItem as b, useLinkItems as x } from "../../lib/menus.js";
9
- import { useArchiveNotifications as ee, useReadNotifications as S, useUnreadNotifications as te } from "../../lib/notifications.js";
10
- import { usePageTitle as C } from "../../lib/pageTitle.js";
7
+ import { TriageButtons as y } from "../../components/TriageButtons.js";
8
+ import { parseApproval as b } from "../../lib/approval.js";
9
+ import { copyItem as x, useLinkItems as S } from "../../lib/menus.js";
10
+ import { useArchiveNotifications as ee, useReadNotifications as te, useUnreadNotifications as C } from "../../lib/notifications.js";
11
+ import { usePageTitle as ne } from "../../lib/pageTitle.js";
11
12
  import { usePeople as w } from "../../lib/people.js";
12
13
  import { plainText as T } from "../../lib/plainText.js";
13
- import { Link as E, useNavigate as ne } from "../../lib/router.js";
14
- import { useShortcuts as re } from "../../lib/shortcuts.js";
14
+ import { Link as E, useNavigate as re } from "../../lib/router.js";
15
+ import { useShortcuts as ie } from "../../lib/shortcuts.js";
15
16
  import { Route as D } from "./notifications.js";
16
17
  import { Avatar as O, Button as k, Card as A, EmptyState as j, IconButton as M, RelativeTime as N, buttonClasses as P, menuDivider as F, useOpenMenu as I } from "@parallelworks/ui";
17
- import { useEffect as ie, useMemo as L, useRef as ae, useState as oe } from "react";
18
+ import { useEffect as ae, useMemo as L, useRef as oe, useState as se } from "react";
18
19
  import { useTranslations as R } from "use-intl";
19
20
  import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
20
- import { useQuery as H, useSuspenseQuery as U } from "@tanstack/react-query";
21
- import { ListFilterMenu as se, useListView as W } from "@parallelworks/ui/list";
21
+ import { useQuery as H, useQueryClient as U, useSuspenseQuery as ce } from "@tanstack/react-query";
22
+ import { ListFilterMenu as le, useListView as W } from "@parallelworks/ui/list";
22
23
  // src/routes/$workspace/notifications.tsx?tsr-split=component
23
24
  var G = (...e) => e.filter(Boolean).join(" ");
24
- function ce(e, t) {
25
+ function ue(e, t) {
25
26
  let n = /* @__PURE__ */ new Map();
26
27
  for (let r of t) {
27
28
  let t = r.projectId ? "project" : r.documentId ? "doc" : "issue", i = r.projectId ? `project:${r.projectId}` : r.documentId ? `doc:${r.documentId}` : r.identifier, a = n.get(i);
@@ -51,7 +52,7 @@ var K = {
51
52
  reminders: ["reminder"],
52
53
  mentions: ["mentioned"]
53
54
  }, q = (e) => e.reason === "reminder" && e.excerpt ? /* @__PURE__ */ new Date(`${e.excerpt}T00:00:00`) : /* @__PURE__ */ new Date(0), J = (e) => e.slice(0, e.lastIndexOf("-"));
54
- function le(e, t) {
55
+ function de(e, t) {
55
56
  let n = R("notifications"), r = L(() => {
56
57
  let e = [{
57
58
  key: "state",
@@ -87,11 +88,11 @@ function le(e, t) {
87
88
  });
88
89
  }
89
90
  function Y() {
90
- let { workspace: e } = D.useParams(), { issue: t } = D.useSearch(), i = R("notifications"), a = ne(), { data: { notifications: o, unread: c } } = U(n(e));
91
- C(c > 0 ? `${i("title")} (${c})` : i("title"));
92
- let u = S(e), d = te(e), p = ee(e), { data: m = [] } = H(r(e)), h = le(e, m), g = h.activeFilterCount > 0, _ = (h.filters.state ?? []).includes("unread"), v = h.filters.kind ?? [], y = h.filters.team ?? [], b = L(() => {
91
+ let { workspace: e } = D.useParams(), { issue: t } = D.useSearch(), i = R("notifications"), a = re(), { data: { notifications: o, unread: c } } = ce(n(e));
92
+ ne(c > 0 ? `${i("title")} (${c})` : i("title"));
93
+ let u = te(e), d = C(e), p = ee(e), { data: m = [] } = H(r(e)), h = de(e, m), g = h.activeFilterCount > 0, _ = (h.filters.state ?? []).includes("unread"), v = h.filters.kind ?? [], y = h.filters.team ?? [], b = L(() => {
93
94
  let n = o.filter((e) => (v.length === 0 || v.some((t) => K[t]?.includes(e.reason))) && (y.length === 0 || !!e.identifier && y.includes(J(e.identifier))));
94
- return ce(e, n).filter((e) => !_ || e.unread.length > 0 || e.key === t);
95
+ return ue(e, n).filter((e) => !_ || e.unread.length > 0 || e.key === t);
95
96
  }, [
96
97
  e,
97
98
  o,
@@ -99,58 +100,58 @@ function Y() {
99
100
  v,
100
101
  y,
101
102
  t
102
- ]), x = b.findIndex((e) => e.key === t), w = x >= 0 ? b[x] : void 0, [T, E] = oe(/* @__PURE__ */ new Set()), O = ae(null), A = L(() => b.filter((e) => T.has(e.key)), [b, T]), N = (t) => {
103
+ ]), x = b.findIndex((e) => e.key === t), S = x >= 0 ? b[x] : void 0, [w, T] = se(/* @__PURE__ */ new Set()), E = oe(null), O = L(() => b.filter((e) => w.has(e.key)), [b, w]), A = (t) => {
103
104
  a({
104
105
  to: "/$workspace/notifications",
105
106
  params: { workspace: e },
106
107
  search: t ? { issue: t.key } : {},
107
108
  replace: !0
108
109
  }), t && t.unread.length > 0 && u.mutate(t.unread);
109
- }, P = (e) => {
110
+ }, N = (e) => {
110
111
  let t = e.flatMap((e) => e.unread);
111
112
  t.length > 0 ? u.mutate(t) : d.mutate(e.flatMap((e) => e.items.map((e) => e.id)));
112
- }, F = (e) => {
113
- if (p.mutate(e.flatMap((e) => e.items.map((e) => e.id))), E(/* @__PURE__ */ new Set()), w && e.includes(w)) {
113
+ }, P = (e) => {
114
+ if (p.mutate(e.flatMap((e) => e.items.map((e) => e.id))), T(/* @__PURE__ */ new Set()), S && e.includes(S)) {
114
115
  let t = b.filter((t) => !e.includes(t));
115
- N(t[t.findIndex((e) => b.indexOf(e) > x)] ?? t.at(-1));
116
+ A(t[t.findIndex((e) => b.indexOf(e) > x)] ?? t.at(-1));
116
117
  }
117
- }, I = (e) => a({ to: e.href }), W = A.length > 0 ? A : w ? [w] : [], q = (e) => E((t) => {
118
+ }, F = (e) => a({ to: e.href }), I = O.length > 0 ? O : S ? [S] : [], U = (e) => T((t) => {
118
119
  let n = new Set(t);
119
120
  return n.has(e.key) ? n.delete(e.key) : n.add(e.key), n;
120
- }), Y = (e, t) => {
121
+ }), W = (e, t) => {
121
122
  let [n, r] = e < t ? [e, t] : [t, e];
122
- E(new Set(b.slice(n, r + 1).map((e) => e.key)));
123
- }, X = (e, t) => {
123
+ T(new Set(b.slice(n, r + 1).map((e) => e.key)));
124
+ }, q = (e, t) => {
124
125
  let n = b.indexOf(t);
125
- e.metaKey || e.ctrlKey ? (q(t), O.current = n) : e.shiftKey ? Y(O.current ?? (x >= 0 ? x : n), n) : (E(/* @__PURE__ */ new Set()), O.current = n, N(t));
126
- }, Z = (e, t) => {
126
+ e.metaKey || e.ctrlKey ? (U(t), E.current = n) : e.shiftKey ? W(E.current ?? (x >= 0 ? x : n), n) : (T(/* @__PURE__ */ new Set()), E.current = n, A(t));
127
+ }, Y = (e, t) => {
127
128
  let n = Math.min(Math.max(x + e, 0), b.length - 1);
128
- t && ((O.current === null || T.size === 0) && (O.current = Math.max(x, 0)), Y(O.current, n)), N(b[n]);
129
+ t && ((E.current === null || w.size === 0) && (E.current = Math.max(x, 0)), W(E.current, n)), A(b[n]);
129
130
  };
130
- re({
131
- j: () => Z(1, !1),
132
- k: () => Z(-1, !1),
133
- J: () => Z(1, !0),
134
- K: () => Z(-1, !0),
135
- ArrowDown: (e) => Z(1, e.shiftKey),
136
- ArrowUp: (e) => Z(-1, e.shiftKey),
131
+ ie({
132
+ j: () => Y(1, !1),
133
+ k: () => Y(-1, !1),
134
+ J: () => Y(1, !0),
135
+ K: () => Y(-1, !0),
136
+ ArrowDown: (e) => Y(1, e.shiftKey),
137
+ ArrowUp: (e) => Y(-1, e.shiftKey),
137
138
  x: () => {
138
- w && (q(w), O.current = x);
139
+ S && (U(S), E.current = x);
139
140
  },
140
- Enter: () => w && I(w),
141
- e: () => W.length > 0 && F(W),
142
- u: () => W.length > 0 && P(W),
143
- Escape: () => T.size > 0 ? E(/* @__PURE__ */ new Set()) : N(void 0)
144
- }), ie(() => {
145
- document.getElementById(`inbox-${w?.key}`)?.scrollIntoView({ block: "nearest" });
146
- }, [w]);
147
- let Q = {
148
- select: N,
149
- toggleRead: P,
150
- archiveGroups: F,
151
- openIssue: I,
152
- clickRow: X,
153
- targetsOf: (e) => T.has(e.key) ? A : (E(/* @__PURE__ */ new Set()), [e])
141
+ Enter: () => S && F(S),
142
+ e: () => I.length > 0 && P(I),
143
+ u: () => I.length > 0 && N(I),
144
+ Escape: () => w.size > 0 ? T(/* @__PURE__ */ new Set()) : A(void 0)
145
+ }), ae(() => {
146
+ document.getElementById(`inbox-${S?.key}`)?.scrollIntoView({ block: "nearest" });
147
+ }, [S]);
148
+ let X = {
149
+ select: A,
150
+ toggleRead: N,
151
+ archiveGroups: P,
152
+ openIssue: F,
153
+ clickRow: q,
154
+ targetsOf: (e) => w.has(e.key) ? O : (T(/* @__PURE__ */ new Set()), [e])
154
155
  };
155
156
  return /* @__PURE__ */ V("div", {
156
157
  className: "flex h-full flex-col",
@@ -166,7 +167,7 @@ function Y() {
166
167
  className: "min-w-0 flex-1 truncate text-xs text-muted-foreground",
167
168
  children: i("unreadCount", { count: c })
168
169
  }),
169
- /* @__PURE__ */ B(se, { view: h }),
170
+ /* @__PURE__ */ B(le, { view: h }),
170
171
  c > 0 && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B(k, {
171
172
  type: "button",
172
173
  size: "sm",
@@ -199,16 +200,16 @@ function Y() {
199
200
  })] })
200
201
  ]
201
202
  }),
202
- A.length > 0 && /* @__PURE__ */ V("div", {
203
+ O.length > 0 && /* @__PURE__ */ V("div", {
203
204
  className: "flex min-h-9 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border bg-human-soft px-4 py-1 text-xs md:px-5",
204
205
  children: [
205
206
  /* @__PURE__ */ B("span", {
206
207
  className: "font-medium text-human",
207
- children: i("selected", { count: A.length })
208
+ children: i("selected", { count: O.length })
208
209
  }),
209
- A.length < b.length && /* @__PURE__ */ B("button", {
210
+ O.length < b.length && /* @__PURE__ */ B("button", {
210
211
  type: "button",
211
- onClick: () => E(new Set(b.map((e) => e.key))),
212
+ onClick: () => T(new Set(b.map((e) => e.key))),
212
213
  className: "hover:underline",
213
214
  children: i("selectAll", { count: b.length })
214
215
  }),
@@ -218,25 +219,25 @@ function Y() {
218
219
  /* @__PURE__ */ B(k, {
219
220
  type: "button",
220
221
  size: "sm",
221
- onClick: () => u.mutate(A.flatMap((e) => e.unread)),
222
- disabled: A.every((e) => e.unread.length === 0),
222
+ onClick: () => u.mutate(O.flatMap((e) => e.unread)),
223
+ disabled: O.every((e) => e.unread.length === 0),
223
224
  children: i("markRead")
224
225
  }),
225
226
  /* @__PURE__ */ B(k, {
226
227
  type: "button",
227
228
  size: "sm",
228
- onClick: () => d.mutate(A.flatMap((e) => e.items.map((e) => e.id))),
229
+ onClick: () => d.mutate(O.flatMap((e) => e.items.map((e) => e.id))),
229
230
  children: i("markUnread")
230
231
  }),
231
232
  /* @__PURE__ */ B(k, {
232
233
  type: "button",
233
234
  size: "sm",
234
- onClick: () => F(A),
235
+ onClick: () => P(O),
235
236
  children: i("archive")
236
237
  }),
237
238
  /* @__PURE__ */ B("button", {
238
239
  type: "button",
239
- onClick: () => E(/* @__PURE__ */ new Set()),
240
+ onClick: () => T(/* @__PURE__ */ new Set()),
240
241
  className: "shrink-0 px-1 hover:underline",
241
242
  children: i("clear")
242
243
  })
@@ -264,20 +265,20 @@ function Y() {
264
265
  className: "flex min-h-0 flex-1",
265
266
  children: [/* @__PURE__ */ B("ul", {
266
267
  "aria-label": i("title"),
267
- className: G("min-h-0 min-w-0 flex-1 flex-col overflow-y-auto px-2 py-2 md:flex md:max-w-md md:border-r md:border-border", w ? "hidden" : "flex"),
268
- children: b.map((t) => /* @__PURE__ */ B(ue, {
268
+ className: G("min-h-0 min-w-0 flex-1 flex-col overflow-y-auto px-2 py-2 md:flex md:max-w-md md:border-r md:border-border", S ? "hidden" : "flex"),
269
+ children: b.map((t) => /* @__PURE__ */ B(fe, {
269
270
  workspace: e,
270
271
  group: t,
271
- selected: t === w,
272
- picked: T.has(t.key),
273
- actions: Q
272
+ selected: t === S,
273
+ picked: w.has(t.key),
274
+ actions: X
274
275
  }, t.key))
275
276
  }), /* @__PURE__ */ B("div", {
276
- className: G("min-w-0 flex-1 overflow-y-auto md:block", w ? "block" : "hidden"),
277
- children: w ? /* @__PURE__ */ B(fe, {
277
+ className: G("min-w-0 flex-1 overflow-y-auto md:block", S ? "block" : "hidden"),
278
+ children: S ? /* @__PURE__ */ B(he, {
278
279
  workspace: e,
279
- group: w,
280
- actions: Q
280
+ group: S,
281
+ actions: X
281
282
  }) : /* @__PURE__ */ B("div", {
282
283
  className: "px-6 py-24",
283
284
  children: /* @__PURE__ */ B(j, {
@@ -291,7 +292,7 @@ function Y() {
291
292
  });
292
293
  }
293
294
  function X(e) {
294
- let t = R("notifications"), n = x();
295
+ let t = R("notifications"), n = S();
295
296
  return (r) => {
296
297
  let [i] = r;
297
298
  return [
@@ -308,7 +309,7 @@ function X(e) {
308
309
  ...r.length === 1 && i ? [
309
310
  F,
310
311
  ...n(i.href),
311
- ...i.identifier ? [b(t("copyId"), i.identifier)] : []
312
+ ...i.identifier ? [x(t("copyId"), i.identifier)] : []
312
313
  ] : []
313
314
  ];
314
315
  };
@@ -317,7 +318,7 @@ function Z(e) {
317
318
  let { actorName: t } = w(e);
318
319
  return (e) => e.actor.kind === "agent" && e.agentName ? e.agentName : t(e.actor);
319
320
  }
320
- function ue({ workspace: e, group: t, selected: n, picked: r, actions: a }) {
321
+ function fe({ workspace: e, group: t, selected: n, picked: r, actions: a }) {
321
322
  let o = R("notifications"), { avatarOf: s } = w(e), c = Z(e), l = I(), u = X(a), d = t.items[0], f = c(d), p = t.unread.length > 0;
322
323
  return /* @__PURE__ */ B("li", {
323
324
  id: `inbox-${t.key}`,
@@ -376,7 +377,7 @@ function ue({ workspace: e, group: t, selected: n, picked: r, actions: a }) {
376
377
  actor: f,
377
378
  agent: d.agentName ?? f,
378
379
  date: q(d)
379
- }), d.excerpt && d.reason !== "reminder" && /* @__PURE__ */ V(z, { children: [": ", /* @__PURE__ */ B(me, { text: d.excerpt })] })]
380
+ }), d.excerpt && d.reason !== "reminder" && /* @__PURE__ */ V(z, { children: [": ", /* @__PURE__ */ B(_e, { text: d.excerpt })] })]
380
381
  }), t.items.length > 1 && /* @__PURE__ */ B("span", {
381
382
  className: "shrink-0",
382
383
  children: o("more", { count: t.items.length - 1 })
@@ -414,7 +415,7 @@ function Q(e) {
414
415
  default: return null;
415
416
  }
416
417
  }
417
- function de({ workspace: e, identifier: n }) {
418
+ function pe({ workspace: e, identifier: n }) {
418
419
  let { data: r } = H(t(e, n)), i = _(), { nameOf: a, avatarOf: s } = w(e);
419
420
  return r ? /* @__PURE__ */ V("section", {
420
421
  className: "mt-5 rounded-lg border border-border px-4 py-3",
@@ -451,7 +452,15 @@ function de({ workspace: e, identifier: n }) {
451
452
  })]
452
453
  }) : null;
453
454
  }
454
- function fe({ workspace: e, group: t, actions: n }) {
455
+ function me({ workspace: e, identifier: r }) {
456
+ let i = U(), { data: a } = H(t(e, r));
457
+ return a ? /* @__PURE__ */ B(y, {
458
+ workspace: e,
459
+ issue: a,
460
+ onDecided: () => i.invalidateQueries({ queryKey: n(e).queryKey })
461
+ }) : null;
462
+ }
463
+ function he({ workspace: e, group: t, actions: n }) {
455
464
  let r = R("notifications"), { avatarOf: i } = w(e), a = Z(e), o = I(), s = X(n);
456
465
  return /* @__PURE__ */ V("article", {
457
466
  className: "w-full px-4 py-5 md:px-8",
@@ -497,13 +506,17 @@ function fe({ workspace: e, group: t, actions: n }) {
497
506
  size: "sm",
498
507
  onClick: () => n.archiveGroups([t]),
499
508
  children: r("archive")
509
+ }),
510
+ t.identifier && /* @__PURE__ */ B(me, {
511
+ workspace: e,
512
+ identifier: t.identifier
500
513
  })
501
514
  ]
502
515
  }),
503
- t.identifier && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B(de, {
516
+ t.identifier && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B(pe, {
504
517
  workspace: e,
505
518
  identifier: t.identifier
506
- }), /* @__PURE__ */ B(he, {
519
+ }), /* @__PURE__ */ B(ve, {
507
520
  workspace: e,
508
521
  identifier: t.identifier
509
522
  })] }),
@@ -545,7 +558,7 @@ function fe({ workspace: e, group: t, actions: n }) {
545
558
  exact: "medium",
546
559
  className: "text-xs text-muted-foreground"
547
560
  })]
548
- }), t.excerpt && t.reason !== "reminder" && /* @__PURE__ */ B(pe, { text: t.excerpt })]
561
+ }), t.excerpt && t.reason !== "reminder" && /* @__PURE__ */ B(ge, { text: t.excerpt })]
549
562
  })]
550
563
  }, t.id);
551
564
  })
@@ -553,8 +566,8 @@ function fe({ workspace: e, group: t, actions: n }) {
553
566
  ]
554
567
  });
555
568
  }
556
- function pe({ text: e }) {
557
- let t = R("agentWork"), n = y(e);
569
+ function ge({ text: e }) {
570
+ let t = R("agentWork"), n = b(e);
558
571
  return n ? /* @__PURE__ */ V("div", {
559
572
  className: "mt-1 min-w-0 text-sm text-muted-foreground",
560
573
  children: [
@@ -576,14 +589,14 @@ function pe({ text: e }) {
576
589
  })
577
590
  });
578
591
  }
579
- function me({ text: e }) {
580
- let t = y(e);
592
+ function _e({ text: e }) {
593
+ let t = b(e);
581
594
  return t ? /* @__PURE__ */ B("code", {
582
595
  className: "font-mono",
583
596
  children: t.command
584
597
  }) : T(e);
585
598
  }
586
- function he({ workspace: t, identifier: n }) {
599
+ function ve({ workspace: t, identifier: n }) {
587
600
  let r = R("notifications"), { data: i = [] } = H(e(t, n)), o = i.filter((e) => !e.answer && !e.canceled);
588
601
  return o.length === 0 ? null : /* @__PURE__ */ V("section", {
589
602
  "aria-label": r("waitingOnYou"),