@locusgraph/loop 0.1.0 → 0.2.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.
Files changed (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,14 +1,328 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { Checkmark as CheckIcon, Locked as LockIcon, Close as XIcon } from "@carbon/icons-react";
3
3
  import { Button, Checkbox, cn } from "@locusgraph/components";
4
4
  import { riskLabels } from "../shared/risk-badge.js";
5
5
  import { formatWaiting, isoOf } from "../shared/time.js";
6
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
6
7
  const riskDot = {
7
- read: "bg-muted-foreground/50",
8
- write: "bg-warn",
9
- destructive: "bg-destructive",
8
+ read: "bg-muted-foreground/50",
9
+ write: "bg-warn",
10
+ destructive: "bg-destructive"
10
11
  };
11
- export function InboxRow({ item, now, selected, onSelect, onApprove, onDeny }) {
12
- const destructive = item.risk === "destructive";
13
- return (_jsxs("li", { "data-slot": "inbox-item", "data-risk": item.risk, "data-selected": selected || undefined, className: cn("group flex items-center gap-3 px-5 py-2.5 motion-safe:transition-colors", selected ? "bg-accent" : "hover:bg-accent/50"), children: [destructive ? (_jsxs("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground", children: [_jsx(LockIcon, { "aria-hidden": true, className: "size-3.5" }), _jsxs("span", { className: "sr-only", children: [item.title, " must be approved on its own"] })] })) : (_jsx(Checkbox, { "aria-label": `Select ${item.title}`, checked: selected, onCheckedChange: (checked) => onSelect(checked === true) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsxs("p", { className: "flex min-w-0 items-baseline gap-2 text-sm", children: [_jsx("span", { className: "truncate font-medium", children: item.title }), _jsx("span", { className: "hidden shrink-0 truncate text-xs text-muted-foreground sm:inline", children: item.runName })] }), _jsxs("p", { className: "flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground", children: [_jsx("span", { "aria-hidden": true, className: cn("size-1.5 shrink-0 rounded-full", riskDot[item.risk]) }), _jsx("span", { className: "shrink-0", children: riskLabels[item.risk] }), item.summary && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx("span", { className: "truncate", children: item.summary })] }))] }), _jsx("p", { className: "truncate text-xs text-muted-foreground sm:hidden", children: item.runName })] }), _jsx("time", { dateTime: isoOf(item.requestedAt), className: "w-12 shrink-0 text-right font-mono text-[11px] text-muted-foreground tabular-nums", children: formatWaiting(item.requestedAt, now) }), _jsxs("span", { className: "flex shrink-0 gap-1", children: [_jsx(Button, { type: "button", size: "icon-xs", variant: "outline", "aria-label": `Approve ${item.title}`, title: "Approve", onClick: onApprove, children: _jsx(CheckIcon, { "aria-hidden": true }) }), _jsx(Button, { type: "button", size: "icon-xs", variant: "ghost", "aria-label": `Deny ${item.title}`, title: "Deny", className: "text-muted-foreground hover:text-foreground", onClick: onDeny, children: _jsx(XIcon, { "aria-hidden": true }) })] })] }));
12
+ export function InboxRow(t0) {
13
+ const $ = _c(70);
14
+ let className;
15
+ let item;
16
+ let now;
17
+ let onApprove;
18
+ let onDeny;
19
+ let onSelect;
20
+ let props;
21
+ let selected;
22
+ if ($[0] !== t0) {
23
+ ({
24
+ item,
25
+ now,
26
+ selected,
27
+ onSelect,
28
+ onApprove,
29
+ onDeny,
30
+ className,
31
+ ...props
32
+ } = t0);
33
+ $[0] = t0;
34
+ $[1] = className;
35
+ $[2] = item;
36
+ $[3] = now;
37
+ $[4] = onApprove;
38
+ $[5] = onDeny;
39
+ $[6] = onSelect;
40
+ $[7] = props;
41
+ $[8] = selected;
42
+ } else {
43
+ className = $[1];
44
+ item = $[2];
45
+ now = $[3];
46
+ onApprove = $[4];
47
+ onDeny = $[5];
48
+ onSelect = $[6];
49
+ props = $[7];
50
+ selected = $[8];
51
+ }
52
+ const destructive = item.risk === "destructive";
53
+ const t1 = item.risk;
54
+ const t2 = selected || undefined;
55
+ const t3 = selected ? "bg-accent" : "hover:bg-accent/50";
56
+ let t4;
57
+ if ($[9] !== className || $[10] !== t3) {
58
+ t4 = cn("group flex items-center gap-3 px-5 py-2.5 motion-safe:transition-colors", t3, className);
59
+ $[9] = className;
60
+ $[10] = t3;
61
+ $[11] = t4;
62
+ } else {
63
+ t4 = $[11];
64
+ }
65
+ let t5;
66
+ if ($[12] !== destructive || $[13] !== item.title || $[14] !== onSelect || $[15] !== selected) {
67
+ t5 = destructive ? /*#__PURE__*/_jsxs("span", {
68
+ className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground",
69
+ children: [/*#__PURE__*/_jsx(LockIcon, {
70
+ "aria-hidden": true,
71
+ className: "size-3.5"
72
+ }), /*#__PURE__*/_jsxs("span", {
73
+ className: "sr-only",
74
+ children: [item.title, " must be approved on its own"]
75
+ })]
76
+ }) : /*#__PURE__*/_jsx(Checkbox, {
77
+ "aria-label": `Select ${item.title}`,
78
+ checked: selected,
79
+ onCheckedChange: checked => onSelect(checked === true)
80
+ });
81
+ $[12] = destructive;
82
+ $[13] = item.title;
83
+ $[14] = onSelect;
84
+ $[15] = selected;
85
+ $[16] = t5;
86
+ } else {
87
+ t5 = $[16];
88
+ }
89
+ let t6;
90
+ if ($[17] !== item.title) {
91
+ t6 = /*#__PURE__*/_jsx("span", {
92
+ className: "truncate font-medium",
93
+ children: item.title
94
+ });
95
+ $[17] = item.title;
96
+ $[18] = t6;
97
+ } else {
98
+ t6 = $[18];
99
+ }
100
+ let t7;
101
+ if ($[19] !== item.runName) {
102
+ t7 = /*#__PURE__*/_jsx("span", {
103
+ className: "hidden shrink-0 truncate text-xs text-muted-foreground sm:inline",
104
+ children: item.runName
105
+ });
106
+ $[19] = item.runName;
107
+ $[20] = t7;
108
+ } else {
109
+ t7 = $[20];
110
+ }
111
+ let t8;
112
+ if ($[21] !== t6 || $[22] !== t7) {
113
+ t8 = /*#__PURE__*/_jsxs("p", {
114
+ className: "flex min-w-0 items-baseline gap-2 text-sm",
115
+ children: [t6, t7]
116
+ });
117
+ $[21] = t6;
118
+ $[22] = t7;
119
+ $[23] = t8;
120
+ } else {
121
+ t8 = $[23];
122
+ }
123
+ const t9 = riskDot[item.risk];
124
+ let t10;
125
+ if ($[24] !== t9) {
126
+ t10 = cn("size-1.5 shrink-0 rounded-full", t9);
127
+ $[24] = t9;
128
+ $[25] = t10;
129
+ } else {
130
+ t10 = $[25];
131
+ }
132
+ let t11;
133
+ if ($[26] !== t10) {
134
+ t11 = /*#__PURE__*/_jsx("span", {
135
+ "aria-hidden": true,
136
+ className: t10
137
+ });
138
+ $[26] = t10;
139
+ $[27] = t11;
140
+ } else {
141
+ t11 = $[27];
142
+ }
143
+ const t12 = riskLabels[item.risk];
144
+ let t13;
145
+ if ($[28] !== t12) {
146
+ t13 = /*#__PURE__*/_jsx("span", {
147
+ className: "shrink-0",
148
+ children: t12
149
+ });
150
+ $[28] = t12;
151
+ $[29] = t13;
152
+ } else {
153
+ t13 = $[29];
154
+ }
155
+ let t14;
156
+ if ($[30] !== item.summary) {
157
+ t14 = item.summary && /*#__PURE__*/_jsxs(_Fragment, {
158
+ children: [/*#__PURE__*/_jsx("span", {
159
+ "aria-hidden": true,
160
+ children: "\xB7"
161
+ }), /*#__PURE__*/_jsx("span", {
162
+ className: "truncate",
163
+ children: item.summary
164
+ })]
165
+ });
166
+ $[30] = item.summary;
167
+ $[31] = t14;
168
+ } else {
169
+ t14 = $[31];
170
+ }
171
+ let t15;
172
+ if ($[32] !== t11 || $[33] !== t13 || $[34] !== t14) {
173
+ t15 = /*#__PURE__*/_jsxs("p", {
174
+ className: "flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
175
+ children: [t11, t13, t14]
176
+ });
177
+ $[32] = t11;
178
+ $[33] = t13;
179
+ $[34] = t14;
180
+ $[35] = t15;
181
+ } else {
182
+ t15 = $[35];
183
+ }
184
+ let t16;
185
+ if ($[36] !== item.runName) {
186
+ t16 = /*#__PURE__*/_jsx("p", {
187
+ className: "truncate text-xs text-muted-foreground sm:hidden",
188
+ children: item.runName
189
+ });
190
+ $[36] = item.runName;
191
+ $[37] = t16;
192
+ } else {
193
+ t16 = $[37];
194
+ }
195
+ let t17;
196
+ if ($[38] !== t15 || $[39] !== t16 || $[40] !== t8) {
197
+ t17 = /*#__PURE__*/_jsxs("div", {
198
+ className: "flex min-w-0 flex-1 flex-col gap-0.5",
199
+ children: [t8, t15, t16]
200
+ });
201
+ $[38] = t15;
202
+ $[39] = t16;
203
+ $[40] = t8;
204
+ $[41] = t17;
205
+ } else {
206
+ t17 = $[41];
207
+ }
208
+ let t18;
209
+ if ($[42] !== item.requestedAt) {
210
+ t18 = isoOf(item.requestedAt);
211
+ $[42] = item.requestedAt;
212
+ $[43] = t18;
213
+ } else {
214
+ t18 = $[43];
215
+ }
216
+ let t19;
217
+ if ($[44] !== item.requestedAt || $[45] !== now) {
218
+ t19 = formatWaiting(item.requestedAt, now);
219
+ $[44] = item.requestedAt;
220
+ $[45] = now;
221
+ $[46] = t19;
222
+ } else {
223
+ t19 = $[46];
224
+ }
225
+ let t20;
226
+ if ($[47] !== t18 || $[48] !== t19) {
227
+ t20 = /*#__PURE__*/_jsx("time", {
228
+ dateTime: t18,
229
+ className: "w-12 shrink-0 text-right font-mono text-[11px] text-muted-foreground tabular-nums",
230
+ children: t19
231
+ });
232
+ $[47] = t18;
233
+ $[48] = t19;
234
+ $[49] = t20;
235
+ } else {
236
+ t20 = $[49];
237
+ }
238
+ const t21 = `Approve ${item.title}`;
239
+ let t22;
240
+ if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
241
+ t22 = /*#__PURE__*/_jsx(CheckIcon, {
242
+ "aria-hidden": true
243
+ });
244
+ $[50] = t22;
245
+ } else {
246
+ t22 = $[50];
247
+ }
248
+ let t23;
249
+ if ($[51] !== onApprove || $[52] !== t21) {
250
+ t23 = /*#__PURE__*/_jsx(Button, {
251
+ type: "button",
252
+ size: "icon-xs",
253
+ variant: "outline",
254
+ "aria-label": t21,
255
+ title: "Approve",
256
+ onClick: onApprove,
257
+ children: t22
258
+ });
259
+ $[51] = onApprove;
260
+ $[52] = t21;
261
+ $[53] = t23;
262
+ } else {
263
+ t23 = $[53];
264
+ }
265
+ const t24 = `Deny ${item.title}`;
266
+ let t25;
267
+ if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
268
+ t25 = /*#__PURE__*/_jsx(XIcon, {
269
+ "aria-hidden": true
270
+ });
271
+ $[54] = t25;
272
+ } else {
273
+ t25 = $[54];
274
+ }
275
+ let t26;
276
+ if ($[55] !== onDeny || $[56] !== t24) {
277
+ t26 = /*#__PURE__*/_jsx(Button, {
278
+ type: "button",
279
+ size: "icon-xs",
280
+ variant: "ghost",
281
+ "aria-label": t24,
282
+ title: "Deny",
283
+ className: "text-muted-foreground hover:text-foreground",
284
+ onClick: onDeny,
285
+ children: t25
286
+ });
287
+ $[55] = onDeny;
288
+ $[56] = t24;
289
+ $[57] = t26;
290
+ } else {
291
+ t26 = $[57];
292
+ }
293
+ let t27;
294
+ if ($[58] !== t23 || $[59] !== t26) {
295
+ t27 = /*#__PURE__*/_jsxs("span", {
296
+ className: "flex shrink-0 gap-1",
297
+ children: [t23, t26]
298
+ });
299
+ $[58] = t23;
300
+ $[59] = t26;
301
+ $[60] = t27;
302
+ } else {
303
+ t27 = $[60];
304
+ }
305
+ let t28;
306
+ if ($[61] !== item.risk || $[62] !== props || $[63] !== t17 || $[64] !== t2 || $[65] !== t20 || $[66] !== t27 || $[67] !== t4 || $[68] !== t5) {
307
+ t28 = /*#__PURE__*/_jsxs("li", {
308
+ "data-slot": "inbox-item",
309
+ "data-risk": t1,
310
+ "data-selected": t2,
311
+ className: t4,
312
+ ...props,
313
+ children: [t5, t17, t20, t27]
314
+ });
315
+ $[61] = item.risk;
316
+ $[62] = props;
317
+ $[63] = t17;
318
+ $[64] = t2;
319
+ $[65] = t20;
320
+ $[66] = t27;
321
+ $[67] = t4;
322
+ $[68] = t5;
323
+ $[69] = t28;
324
+ } else {
325
+ t28 = $[69];
326
+ }
327
+ return t28;
14
328
  }
@@ -1,21 +1,15 @@
1
1
  export function bulkApprovable(items) {
2
- return items.filter((item) => item.risk !== "destructive");
2
+ return items.filter(item => item.risk !== "destructive");
3
3
  }
4
4
  export function selectedIn(items, selected) {
5
- return bulkApprovable(items)
6
- .map((item) => item.id)
7
- .filter((id) => selected.has(id));
5
+ return bulkApprovable(items).map(item => item.id).filter(id => selected.has(id));
8
6
  }
9
7
  export function selectAllState(selectableCount, selectedCount) {
10
- if (selectedCount === 0 || selectableCount === 0)
11
- return false;
12
- return selectedCount === selectableCount ? true : "indeterminate";
8
+ if (selectedCount === 0 || selectableCount === 0) return false;
9
+ return selectedCount === selectableCount ? true : "indeterminate";
13
10
  }
14
11
  export function toggled(selected, id, on) {
15
- const next = new Set(selected);
16
- if (on)
17
- next.add(id);
18
- else
19
- next.delete(id);
20
- return next;
12
+ const next = new Set(selected);
13
+ if (on) next.add(id);else next.delete(id);
14
+ return next;
21
15
  }
@@ -6,6 +6,7 @@ export type InboxProps = {
6
6
  onApprove: (id: string) => void;
7
7
  onDeny: (id: string) => void;
8
8
  onApproveAll: (ids: string[]) => void;
9
+ virtualize?: boolean;
9
10
  className?: string;
10
11
  };
11
- export declare function Inbox({ items, now, title, onApprove, onDeny, onApproveAll, className, }: InboxProps): import("react").JSX.Element;
12
+ export declare function Inbox({ items, now, title, onApprove, onDeny, onApproveAll, virtualize, className, }: InboxProps): import("react").JSX.Element;
@@ -1,26 +1,258 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { MailAll as InboxIcon } from "@carbon/icons-react";
3
3
  import { Button, Checkbox, Label } from "@locusgraph/components";
4
4
  import { pluralize } from "@locusgraph/utils";
5
5
  import { useId, useState } from "react";
6
- import { ApprovalPanel, LiveStatus, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
6
+ import { ApprovalPanel, LiveStatus, PanelFooter, PanelHeader, PanelTitle } from "../../shared/panel.js";
7
7
  import { PanelEmpty } from "../../shared/panel-empty.js";
8
+ import { shouldVirtualize } from "../../shared/virtual/use-list-virtualizer.js";
8
9
  import { InboxRow } from "./inbox-row.js";
9
10
  import { bulkApprovable, selectAllState, selectedIn, toggled } from "./inbox-selection.js";
10
- export function Inbox({ items, now = Date.now(), title = "Waiting for approval", onApprove, onDeny, onApproveAll, className, }) {
11
- const selectAllId = useId();
12
- const [selected, setSelected] = useState(() => new Set());
13
- const selectable = bulkApprovable(items);
14
- const selectedIds = selectedIn(items, selected);
15
- const allState = selectAllState(selectable.length, selectedIds.length);
16
- const hasDestructive = selectable.length < items.length;
17
- const empty = items.length === 0;
18
- return (_jsxs(ApprovalPanel, { "data-slot": "inbox", "aria-label": title, className: className, children: [_jsx(PanelHeader, { icon: _jsx(InboxIcon, { "aria-hidden": true }), eyebrow: "Approvals", status: empty ? "All clear" : `${items.length} waiting`, tone: empty ? "done" : "waiting" }), _jsx(PanelTitle, { children: title }), empty ? (_jsx(PanelEmpty, { "data-slot": "inbox-empty", icon: _jsx(InboxIcon, { "aria-hidden": true }), title: "Nothing waiting for you", description: "When an agent needs approval to write, pay, send or delete, it shows up here." })) : (_jsxs(_Fragment, { children: [_jsx("ul", { className: "mt-4 flex flex-col divide-y border-t", children: items.map((item) => (_jsx(InboxRow, { item: item, now: now, selected: selected.has(item.id), onSelect: (on) => setSelected((current) => toggled(current, item.id, on)), onApprove: () => onApprove(item.id), onDeny: () => onDeny(item.id) }, item.id))) }), _jsxs(PanelFooter, { className: "justify-between gap-3", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-3", children: [selectable.length > 0 && (_jsx(Checkbox, { id: selectAllId, checked: allState, onCheckedChange: (checked) => setSelected(checked === true ? new Set(selectable.map((item) => item.id)) : new Set()) })), _jsxs(Label, { htmlFor: selectAllId, className: "flex min-w-0 flex-col items-start gap-0 font-normal", children: [_jsxs("span", { className: "text-sm tabular-nums", children: [_jsx("span", { className: "sr-only", children: "Select all that can be approved together. " }), selectedIds.length > 0 ? `${selectedIds.length} selected` : "Select all"] }), hasDestructive && (_jsx("span", { className: "text-xs text-muted-foreground", children: "Destructive requests are approved one at a time." }))] })] }), _jsx(Button, { type: "button", size: "sm", disabled: selectedIds.length === 0, onClick: () => {
19
- onApproveAll(selectedIds);
20
- setSelected(new Set());
21
- }, children: selectedIds.length > 0
22
- ? `Approve ${selectedIds.length} selected`
23
- : "Approve selected" })] })] })), _jsx(LiveStatus, { message: empty
24
- ? "No approvals waiting"
25
- : `${pluralize(items.length, "approval")} waiting, ${selectedIds.length} selected` })] }));
11
+ import { VirtualInboxList } from "./virtual-inbox-list.js";
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ export function Inbox(t0) {
14
+ const $ = _c(53);
15
+ const {
16
+ items,
17
+ now: t1,
18
+ title: t2,
19
+ onApprove,
20
+ onDeny,
21
+ onApproveAll,
22
+ virtualize: t3,
23
+ className
24
+ } = t0;
25
+ let t4;
26
+ if ($[0] !== t1) {
27
+ t4 = t1 === undefined ? Date.now() : t1;
28
+ $[0] = t1;
29
+ $[1] = t4;
30
+ } else {
31
+ t4 = $[1];
32
+ }
33
+ const now = t4;
34
+ const title = t2 === undefined ? "Waiting for approval" : t2;
35
+ const virtualize = t3 === undefined ? true : t3;
36
+ const selectAllId = useId();
37
+ const [selected, setSelected] = useState(_temp);
38
+ let selectable;
39
+ let selectedIds;
40
+ let t5;
41
+ if ($[2] !== items || $[3] !== selected) {
42
+ selectable = bulkApprovable(items);
43
+ selectedIds = selectedIn(items, selected);
44
+ t5 = selectAllState(selectable.length, selectedIds.length);
45
+ $[2] = items;
46
+ $[3] = selected;
47
+ $[4] = selectable;
48
+ $[5] = selectedIds;
49
+ $[6] = t5;
50
+ } else {
51
+ selectable = $[4];
52
+ selectedIds = $[5];
53
+ t5 = $[6];
54
+ }
55
+ const allState = t5;
56
+ const hasDestructive = selectable.length < items.length;
57
+ const empty = items.length === 0;
58
+ let t6;
59
+ if ($[7] !== selected) {
60
+ t6 = id => selected.has(id);
61
+ $[7] = selected;
62
+ $[8] = t6;
63
+ } else {
64
+ t6 = $[8];
65
+ }
66
+ let t7;
67
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
68
+ t7 = (id_0, on) => setSelected(current => toggled(current, id_0, on));
69
+ $[9] = t7;
70
+ } else {
71
+ t7 = $[9];
72
+ }
73
+ let T0;
74
+ let t10;
75
+ let t11;
76
+ let t12;
77
+ let t13;
78
+ let t8;
79
+ let t9;
80
+ if ($[10] !== allState || $[11] !== className || $[12] !== empty || $[13] !== hasDestructive || $[14] !== items || $[15] !== now || $[16] !== onApprove || $[17] !== onApproveAll || $[18] !== onDeny || $[19] !== selectAllId || $[20] !== selectable || $[21] !== selectedIds || $[22] !== t6 || $[23] !== title || $[24] !== virtualize) {
81
+ const rowHandlers = {
82
+ isSelected: t6,
83
+ onSelect: t7,
84
+ onApprove,
85
+ onDeny
86
+ };
87
+ T0 = ApprovalPanel;
88
+ t8 = "inbox";
89
+ t9 = title;
90
+ t10 = className;
91
+ let t14;
92
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
93
+ t14 = /*#__PURE__*/_jsx(InboxIcon, {
94
+ "aria-hidden": true
95
+ });
96
+ $[32] = t14;
97
+ } else {
98
+ t14 = $[32];
99
+ }
100
+ const t15 = empty ? "All clear" : `${items.length} waiting`;
101
+ const t16 = empty ? "done" : "waiting";
102
+ if ($[33] !== t15 || $[34] !== t16) {
103
+ t11 = /*#__PURE__*/_jsx(PanelHeader, {
104
+ icon: t14,
105
+ eyebrow: "Approvals",
106
+ status: t15,
107
+ tone: t16
108
+ });
109
+ $[33] = t15;
110
+ $[34] = t16;
111
+ $[35] = t11;
112
+ } else {
113
+ t11 = $[35];
114
+ }
115
+ if ($[36] !== title) {
116
+ t12 = /*#__PURE__*/_jsx(PanelTitle, {
117
+ children: title
118
+ });
119
+ $[36] = title;
120
+ $[37] = t12;
121
+ } else {
122
+ t12 = $[37];
123
+ }
124
+ t13 = empty ? /*#__PURE__*/_jsx(PanelEmpty, {
125
+ "data-slot": "inbox-empty",
126
+ icon: /*#__PURE__*/_jsx(InboxIcon, {
127
+ "aria-hidden": true
128
+ }),
129
+ title: "Nothing waiting for you",
130
+ description: "When an agent needs approval to write, pay, send or delete, it shows up here."
131
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
132
+ children: [shouldVirtualize(items.length, virtualize) ? /*#__PURE__*/_jsx(VirtualInboxList, {
133
+ items: items,
134
+ now: now,
135
+ ...rowHandlers
136
+ }) : /*#__PURE__*/_jsx("ul", {
137
+ className: "mt-4 flex flex-col divide-y border-t",
138
+ children: items.map(item => /*#__PURE__*/_jsx(InboxRow, {
139
+ item: item,
140
+ now: now,
141
+ selected: rowHandlers.isSelected(item.id),
142
+ onSelect: on_0 => rowHandlers.onSelect(item.id, on_0),
143
+ onApprove: () => onApprove(item.id),
144
+ onDeny: () => onDeny(item.id)
145
+ }, item.id))
146
+ }), /*#__PURE__*/_jsxs(PanelFooter, {
147
+ className: "justify-between gap-3",
148
+ children: [/*#__PURE__*/_jsxs("span", {
149
+ className: "flex min-w-0 items-center gap-3",
150
+ children: [selectable.length > 0 && /*#__PURE__*/_jsx(Checkbox, {
151
+ id: selectAllId,
152
+ checked: allState,
153
+ onCheckedChange: checked => setSelected(checked === true ? new Set(selectable.map(_temp2)) : new Set())
154
+ }), /*#__PURE__*/_jsxs(Label, {
155
+ htmlFor: selectAllId,
156
+ className: "flex min-w-0 flex-col items-start gap-0 font-normal",
157
+ children: [/*#__PURE__*/_jsxs("span", {
158
+ className: "text-sm tabular-nums",
159
+ children: [/*#__PURE__*/_jsx("span", {
160
+ className: "sr-only",
161
+ children: "Select all that can be approved together. "
162
+ }), selectedIds.length > 0 ? `${selectedIds.length} selected` : "Select all"]
163
+ }), hasDestructive && /*#__PURE__*/_jsx("span", {
164
+ className: "text-xs text-muted-foreground",
165
+ children: "Destructive requests are approved one at a time."
166
+ })]
167
+ })]
168
+ }), /*#__PURE__*/_jsx(Button, {
169
+ type: "button",
170
+ size: "sm",
171
+ disabled: selectedIds.length === 0,
172
+ onClick: () => {
173
+ onApproveAll(selectedIds);
174
+ setSelected(new Set());
175
+ },
176
+ children: selectedIds.length > 0 ? `Approve ${selectedIds.length} selected` : "Approve selected"
177
+ })]
178
+ })]
179
+ });
180
+ $[10] = allState;
181
+ $[11] = className;
182
+ $[12] = empty;
183
+ $[13] = hasDestructive;
184
+ $[14] = items;
185
+ $[15] = now;
186
+ $[16] = onApprove;
187
+ $[17] = onApproveAll;
188
+ $[18] = onDeny;
189
+ $[19] = selectAllId;
190
+ $[20] = selectable;
191
+ $[21] = selectedIds;
192
+ $[22] = t6;
193
+ $[23] = title;
194
+ $[24] = virtualize;
195
+ $[25] = T0;
196
+ $[26] = t10;
197
+ $[27] = t11;
198
+ $[28] = t12;
199
+ $[29] = t13;
200
+ $[30] = t8;
201
+ $[31] = t9;
202
+ } else {
203
+ T0 = $[25];
204
+ t10 = $[26];
205
+ t11 = $[27];
206
+ t12 = $[28];
207
+ t13 = $[29];
208
+ t8 = $[30];
209
+ t9 = $[31];
210
+ }
211
+ let t14;
212
+ if ($[38] !== empty || $[39] !== items.length || $[40] !== selectedIds) {
213
+ t14 = empty ? "No approvals waiting" : `${pluralize(items.length, "approval")} waiting, ${selectedIds.length} selected`;
214
+ $[38] = empty;
215
+ $[39] = items.length;
216
+ $[40] = selectedIds;
217
+ $[41] = t14;
218
+ } else {
219
+ t14 = $[41];
220
+ }
221
+ let t15;
222
+ if ($[42] !== t14) {
223
+ t15 = /*#__PURE__*/_jsx(LiveStatus, {
224
+ message: t14
225
+ });
226
+ $[42] = t14;
227
+ $[43] = t15;
228
+ } else {
229
+ t15 = $[43];
230
+ }
231
+ let t16;
232
+ if ($[44] !== T0 || $[45] !== t10 || $[46] !== t11 || $[47] !== t12 || $[48] !== t13 || $[49] !== t15 || $[50] !== t8 || $[51] !== t9) {
233
+ t16 = /*#__PURE__*/_jsxs(T0, {
234
+ "data-slot": t8,
235
+ "aria-label": t9,
236
+ className: t10,
237
+ children: [t11, t12, t13, t15]
238
+ });
239
+ $[44] = T0;
240
+ $[45] = t10;
241
+ $[46] = t11;
242
+ $[47] = t12;
243
+ $[48] = t13;
244
+ $[49] = t15;
245
+ $[50] = t8;
246
+ $[51] = t9;
247
+ $[52] = t16;
248
+ } else {
249
+ t16 = $[52];
250
+ }
251
+ return t16;
252
+ }
253
+ function _temp2(item_0) {
254
+ return item_0.id;
255
+ }
256
+ function _temp() {
257
+ return new Set();
26
258
  }
@@ -0,0 +1,13 @@
1
+ import type { PendingApproval } from "../types.js";
2
+ export type InboxRowHandlers = {
3
+ isSelected: (id: string) => boolean;
4
+ onSelect: (id: string, selected: boolean) => void;
5
+ onApprove: (id: string) => void;
6
+ onDeny: (id: string) => void;
7
+ };
8
+ type VirtualInboxListProps = InboxRowHandlers & {
9
+ items: PendingApproval[];
10
+ now: number;
11
+ };
12
+ export declare function VirtualInboxList({ items, now, isSelected, onSelect, onApprove, onDeny, }: VirtualInboxListProps): import("react").JSX.Element;
13
+ export {};