@adecore/agents-react 0.61.0 → 0.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +1 -0
- package/dist/chat/ui/ChatActivity.js +43 -2
- package/dist/chat/ui/ReferenceChip.js +127 -71
- package/dist/chat/ui/reference-lookup.d.ts +2 -0
- package/dist/chat/ui/thread-references.js +30 -16
- package/dist/chat/waiting-on.d.ts +34 -0
- package/dist/chat/waiting-on.js +78 -0
- package/dist/host.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +12 -0
- package/dist/locales/en/agent-chat.js +12 -0
- package/dist/locales/nl/agent-chat.d.ts +12 -0
- package/dist/locales/nl/agent-chat.js +12 -0
- package/package.json +9 -9
- package/src/chat/index.ts +1 -0
- package/src/chat/ui/ChatActivity.tsx +13 -3
- package/src/chat/ui/ReferenceChip.tsx +16 -1
- package/src/chat/ui/reference-lookup.ts +3 -0
- package/src/chat/ui/thread-references.ts +2 -1
- package/src/chat/waiting-on.ts +101 -0
- package/src/host.ts +11 -0
- package/src/index.ts +1 -0
- package/src/locales/en/agent-chat.ts +12 -0
- package/src/locales/nl/agent-chat.ts +12 -0
package/dist/chat/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { RUNTIME_MODES, runtimeModeLabel, runtimeModeHint } from './runtime-mode
|
|
|
28
28
|
export { CHAT_SEND_KEYS, SEND_AND_NEW_SHORTCUT, sendKeyLabel, sendKeyHint, type ChatSendKey } from './send-key.js';
|
|
29
29
|
export type { StashedAttachment, StashedPrompt, StashedQuote } from './stash.js';
|
|
30
30
|
export { subagentTitle, summaryWordOf, stopOf, type SubagentStop } from './subagent-list.js';
|
|
31
|
+
export { waitingOnOf, waitingOnLabel, type WaitingChild, type WaitingOn, type WaitingOnInput } from './waiting-on.js';
|
|
31
32
|
export { useSubagentSupport } from './subagent-support.js';
|
|
32
33
|
export { crumbOf, openFromMain, composerWrites, canOpenSubagent, useSubagentView, useSubagentTrail, useSubagentItem, type SubagentStep, type SubagentTrail } from './subagent-view.js';
|
|
33
34
|
export { stepTimelineMessage, jumpToTimelineItem, type TurnTarget, registerTurnJumper, jumpToTimelineTurn, type ItemJumpOptions } from './timeline-scroll.js';
|
package/dist/chat/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { recentChatMessages, recentSubagentMessages } from './recent-messages.js
|
|
|
24
24
|
export { RUNTIME_MODES, runtimeModeLabel, runtimeModeHint } from './runtime-modes.js';
|
|
25
25
|
export { CHAT_SEND_KEYS, SEND_AND_NEW_SHORTCUT, sendKeyLabel, sendKeyHint } from './send-key.js';
|
|
26
26
|
export { subagentTitle, summaryWordOf, stopOf } from './subagent-list.js';
|
|
27
|
+
export { waitingOnOf, waitingOnLabel } from './waiting-on.js';
|
|
27
28
|
export { useSubagentSupport } from './subagent-support.js';
|
|
28
29
|
export { crumbOf, openFromMain, composerWrites, canOpenSubagent, useSubagentView, useSubagentTrail, useSubagentItem } from './subagent-view.js';
|
|
29
30
|
export { stepTimelineMessage, jumpToTimelineItem, registerTurnJumper, jumpToTimelineTurn } from './timeline-scroll.js';
|
|
@@ -16,6 +16,7 @@ import { backgroundCounts } from '../activity.js';
|
|
|
16
16
|
import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskIdOf, taskRowStateOf } from '../subagent-list.js';
|
|
17
17
|
import { useSubagentSupport } from '../subagent-support.js';
|
|
18
18
|
import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail } from '../subagent-view.js';
|
|
19
|
+
import { waitingOnLabel, waitingOnOf } from '../waiting-on.js';
|
|
19
20
|
import { flyoutWorkflows, workflowPillOf } from '../workflow-list.js';
|
|
20
21
|
import { WorkflowRow } from './rows/WorkflowRow.js';
|
|
21
22
|
import { SubagentStopButton } from './SubagentStopButton.js';
|
|
@@ -162,7 +163,10 @@ export function ChatActivity(t0) {
|
|
|
162
163
|
icon: shells > 0 ? SquareTerminal : Activity,
|
|
163
164
|
size: 14
|
|
164
165
|
}),
|
|
165
|
-
label:
|
|
166
|
+
label: /*#__PURE__*/_jsx(BackgroundLabel, {
|
|
167
|
+
tasks: background
|
|
168
|
+
}),
|
|
169
|
+
heading: [shells > 0 && t("activity.shells", {
|
|
166
170
|
count: shells
|
|
167
171
|
}), monitors > 0 && t("activity.monitors", {
|
|
168
172
|
count: monitors
|
|
@@ -275,7 +279,7 @@ function Flyout(t0) {
|
|
|
275
279
|
if ($[1] !== icon || $[2] !== label) {
|
|
276
280
|
t3 = /*#__PURE__*/_jsxs(Surface, {
|
|
277
281
|
render: t2,
|
|
278
|
-
className: "pointer-events-auto inline-flex h-7.5 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text",
|
|
282
|
+
className: "pointer-events-auto inline-flex h-7.5 max-w-full min-w-0 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text",
|
|
279
283
|
children: [icon, label]
|
|
280
284
|
});
|
|
281
285
|
$[1] = icon;
|
|
@@ -321,6 +325,43 @@ function Flyout(t0) {
|
|
|
321
325
|
}
|
|
322
326
|
return t6;
|
|
323
327
|
}
|
|
328
|
+
/* What the background chip says: the oldest command or monitor and how long it has run, on a clock of its own. */
|
|
329
|
+
function BackgroundLabel(t0) {
|
|
330
|
+
const $ = _c(7);
|
|
331
|
+
const {
|
|
332
|
+
tasks
|
|
333
|
+
} = t0;
|
|
334
|
+
const now = useNow(1000);
|
|
335
|
+
let t1;
|
|
336
|
+
let t2;
|
|
337
|
+
if ($[0] !== now || $[1] !== tasks) {
|
|
338
|
+
const waiting = waitingOnOf({
|
|
339
|
+
background: tasks
|
|
340
|
+
});
|
|
341
|
+
t1 = "truncate";
|
|
342
|
+
t2 = waiting === null ? null : waitingOnLabel(waiting, now);
|
|
343
|
+
$[0] = now;
|
|
344
|
+
$[1] = tasks;
|
|
345
|
+
$[2] = t1;
|
|
346
|
+
$[3] = t2;
|
|
347
|
+
} else {
|
|
348
|
+
t1 = $[2];
|
|
349
|
+
t2 = $[3];
|
|
350
|
+
}
|
|
351
|
+
let t3;
|
|
352
|
+
if ($[4] !== t1 || $[5] !== t2) {
|
|
353
|
+
t3 = /*#__PURE__*/_jsx("span", {
|
|
354
|
+
className: t1,
|
|
355
|
+
children: t2
|
|
356
|
+
});
|
|
357
|
+
$[4] = t1;
|
|
358
|
+
$[5] = t2;
|
|
359
|
+
$[6] = t3;
|
|
360
|
+
} else {
|
|
361
|
+
t3 = $[6];
|
|
362
|
+
}
|
|
363
|
+
return t3;
|
|
364
|
+
}
|
|
324
365
|
function WorkflowIcon(t0) {
|
|
325
366
|
const $ = _c(2);
|
|
326
367
|
const {
|
|
@@ -154,7 +154,7 @@ export function TokenChip(t0) {
|
|
|
154
154
|
* `lastName` when the message knows what it was called, with `goneHint` on its tooltip when there is one.
|
|
155
155
|
*/
|
|
156
156
|
export function ReferenceChip(t0) {
|
|
157
|
-
const $ = _c(
|
|
157
|
+
const $ = _c(58);
|
|
158
158
|
const {
|
|
159
159
|
id,
|
|
160
160
|
lastName,
|
|
@@ -165,7 +165,8 @@ export function ReferenceChip(t0) {
|
|
|
165
165
|
} = useTranslation("agent-chat");
|
|
166
166
|
const {
|
|
167
167
|
items,
|
|
168
|
-
open
|
|
168
|
+
open,
|
|
169
|
+
outside
|
|
169
170
|
} = useContext(ReferenceLookupContext);
|
|
170
171
|
const {
|
|
171
172
|
ReferenceIcon
|
|
@@ -178,55 +179,109 @@ export function ReferenceChip(t0) {
|
|
|
178
179
|
let t4;
|
|
179
180
|
let t5;
|
|
180
181
|
let t6;
|
|
181
|
-
if ($[0] !== ReferenceIcon || $[1] !== goneHint || $[2] !== id || $[3] !== items || $[4] !== lastName || $[5] !== t) {
|
|
182
|
+
if ($[0] !== ReferenceIcon || $[1] !== goneHint || $[2] !== id || $[3] !== items || $[4] !== lastName || $[5] !== outside || $[6] !== t) {
|
|
182
183
|
t6 = Symbol.for("react.early_return_sentinel");
|
|
183
184
|
bb0: {
|
|
184
185
|
let t7;
|
|
185
|
-
if ($[
|
|
186
|
+
if ($[15] !== id) {
|
|
186
187
|
t7 = candidate => candidate.id === id;
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
188
|
+
$[15] = id;
|
|
189
|
+
$[16] = t7;
|
|
189
190
|
} else {
|
|
190
|
-
t7 = $[
|
|
191
|
+
t7 = $[16];
|
|
191
192
|
}
|
|
192
193
|
item = items.find(t7);
|
|
194
|
+
const elsewhere = item === undefined ? outside?.(id) ?? null : null;
|
|
195
|
+
if (elsewhere !== null) {
|
|
196
|
+
const opens = elsewhere.open;
|
|
197
|
+
let t8;
|
|
198
|
+
if ($[17] !== elsewhere.icon) {
|
|
199
|
+
t8 = /*#__PURE__*/_jsx(Icon, {
|
|
200
|
+
icon: elsewhere.icon,
|
|
201
|
+
size: 14,
|
|
202
|
+
className: TOKEN_ICON
|
|
203
|
+
});
|
|
204
|
+
$[17] = elsewhere.icon;
|
|
205
|
+
$[18] = t8;
|
|
206
|
+
} else {
|
|
207
|
+
t8 = $[18];
|
|
208
|
+
}
|
|
209
|
+
let t9;
|
|
210
|
+
if ($[19] !== lastName || $[20] !== t) {
|
|
211
|
+
t9 = lastName || t("references.gone");
|
|
212
|
+
$[19] = lastName;
|
|
213
|
+
$[20] = t;
|
|
214
|
+
$[21] = t9;
|
|
215
|
+
} else {
|
|
216
|
+
t9 = $[21];
|
|
217
|
+
}
|
|
218
|
+
const t10 = opens !== null && "hover:bg-text/12";
|
|
219
|
+
let t11;
|
|
220
|
+
if ($[22] !== t10) {
|
|
221
|
+
t11 = clsx(REFERENCE_TONE, t10);
|
|
222
|
+
$[22] = t10;
|
|
223
|
+
$[23] = t11;
|
|
224
|
+
} else {
|
|
225
|
+
t11 = $[23];
|
|
226
|
+
}
|
|
227
|
+
const t12 = opens ?? undefined;
|
|
228
|
+
let t13;
|
|
229
|
+
if ($[24] !== t11 || $[25] !== t12 || $[26] !== t8 || $[27] !== t9) {
|
|
230
|
+
t13 = /*#__PURE__*/_jsx(TokenChip, {
|
|
231
|
+
kind: "gone",
|
|
232
|
+
icon: t8,
|
|
233
|
+
label: t9,
|
|
234
|
+
tone: t11,
|
|
235
|
+
onOpen: t12
|
|
236
|
+
});
|
|
237
|
+
$[24] = t11;
|
|
238
|
+
$[25] = t12;
|
|
239
|
+
$[26] = t8;
|
|
240
|
+
$[27] = t9;
|
|
241
|
+
$[28] = t13;
|
|
242
|
+
} else {
|
|
243
|
+
t13 = $[28];
|
|
244
|
+
}
|
|
245
|
+
t6 = t13;
|
|
246
|
+
break bb0;
|
|
247
|
+
}
|
|
193
248
|
if (item === undefined) {
|
|
194
249
|
let t8;
|
|
195
|
-
if ($[
|
|
250
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
196
251
|
t8 = /*#__PURE__*/_jsx(Icon, {
|
|
197
252
|
icon: CircleOff,
|
|
198
253
|
size: 14,
|
|
199
254
|
className: TOKEN_ICON
|
|
200
255
|
});
|
|
201
|
-
$[
|
|
256
|
+
$[29] = t8;
|
|
202
257
|
} else {
|
|
203
|
-
t8 = $[
|
|
258
|
+
t8 = $[29];
|
|
204
259
|
}
|
|
205
260
|
let t9;
|
|
206
|
-
if ($[
|
|
261
|
+
if ($[30] !== lastName || $[31] !== t) {
|
|
207
262
|
t9 = lastName || t("references.gone");
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
263
|
+
$[30] = lastName;
|
|
264
|
+
$[31] = t;
|
|
265
|
+
$[32] = t9;
|
|
211
266
|
} else {
|
|
212
|
-
t9 = $[
|
|
267
|
+
t9 = $[32];
|
|
213
268
|
}
|
|
214
269
|
let t10;
|
|
215
|
-
if ($[
|
|
270
|
+
if ($[33] !== t9) {
|
|
216
271
|
t10 = /*#__PURE__*/_jsx(TokenChip, {
|
|
217
272
|
kind: "gone",
|
|
218
273
|
icon: t8,
|
|
219
274
|
label: t9,
|
|
220
275
|
tone: REFERENCE_GONE_TONE
|
|
221
276
|
});
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
277
|
+
$[33] = t9;
|
|
278
|
+
$[34] = t10;
|
|
224
279
|
} else {
|
|
225
|
-
t10 = $[
|
|
280
|
+
t10 = $[34];
|
|
226
281
|
}
|
|
227
282
|
const chip = t10;
|
|
228
283
|
let t11;
|
|
229
|
-
if ($[
|
|
284
|
+
if ($[35] !== chip || $[36] !== goneHint) {
|
|
230
285
|
t11 = goneHint === undefined ? chip : /*#__PURE__*/_jsx(Tooltip, {
|
|
231
286
|
label: goneHint,
|
|
232
287
|
children: /*#__PURE__*/_jsx("span", {
|
|
@@ -234,11 +289,11 @@ export function ReferenceChip(t0) {
|
|
|
234
289
|
children: chip
|
|
235
290
|
})
|
|
236
291
|
});
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
292
|
+
$[35] = chip;
|
|
293
|
+
$[36] = goneHint;
|
|
294
|
+
$[37] = t11;
|
|
240
295
|
} else {
|
|
241
|
-
t11 = $[
|
|
296
|
+
t11 = $[37];
|
|
242
297
|
}
|
|
243
298
|
t6 = t11;
|
|
244
299
|
break bb0;
|
|
@@ -265,68 +320,69 @@ export function ReferenceChip(t0) {
|
|
|
265
320
|
$[2] = id;
|
|
266
321
|
$[3] = items;
|
|
267
322
|
$[4] = lastName;
|
|
268
|
-
$[5] =
|
|
269
|
-
$[6] =
|
|
270
|
-
$[7] =
|
|
271
|
-
$[8] =
|
|
272
|
-
$[9] =
|
|
273
|
-
$[10] =
|
|
274
|
-
$[11] =
|
|
275
|
-
$[12] =
|
|
276
|
-
$[13] =
|
|
323
|
+
$[5] = outside;
|
|
324
|
+
$[6] = t;
|
|
325
|
+
$[7] = T0;
|
|
326
|
+
$[8] = item;
|
|
327
|
+
$[9] = t1;
|
|
328
|
+
$[10] = t2;
|
|
329
|
+
$[11] = t3;
|
|
330
|
+
$[12] = t4;
|
|
331
|
+
$[13] = t5;
|
|
332
|
+
$[14] = t6;
|
|
277
333
|
} else {
|
|
278
|
-
T0 = $[
|
|
279
|
-
item = $[
|
|
280
|
-
t1 = $[
|
|
281
|
-
t2 = $[
|
|
282
|
-
t3 = $[
|
|
283
|
-
t4 = $[
|
|
284
|
-
t5 = $[
|
|
285
|
-
t6 = $[
|
|
334
|
+
T0 = $[7];
|
|
335
|
+
item = $[8];
|
|
336
|
+
t1 = $[9];
|
|
337
|
+
t2 = $[10];
|
|
338
|
+
t3 = $[11];
|
|
339
|
+
t4 = $[12];
|
|
340
|
+
t5 = $[13];
|
|
341
|
+
t6 = $[14];
|
|
286
342
|
}
|
|
287
343
|
if (t6 !== Symbol.for("react.early_return_sentinel")) {
|
|
288
344
|
return t6;
|
|
289
345
|
}
|
|
290
346
|
let t7;
|
|
291
|
-
if ($[
|
|
347
|
+
if ($[38] !== t1 || $[39] !== t2) {
|
|
292
348
|
t7 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
293
349
|
children: [t1, t2]
|
|
294
350
|
});
|
|
295
|
-
$[
|
|
296
|
-
$[
|
|
297
|
-
$[
|
|
351
|
+
$[38] = t1;
|
|
352
|
+
$[39] = t2;
|
|
353
|
+
$[40] = t7;
|
|
298
354
|
} else {
|
|
299
|
-
t7 = $[
|
|
355
|
+
t7 = $[40];
|
|
300
356
|
}
|
|
301
357
|
let t8;
|
|
302
|
-
if ($[
|
|
358
|
+
if ($[41] !== item.name || $[42] !== t) {
|
|
303
359
|
t8 = item.name || t("references.untitled");
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
360
|
+
$[41] = item.name;
|
|
361
|
+
$[42] = t;
|
|
362
|
+
$[43] = t8;
|
|
307
363
|
} else {
|
|
308
|
-
t8 = $[
|
|
364
|
+
t8 = $[43];
|
|
309
365
|
}
|
|
310
366
|
const t9 = open !== null && "hover:bg-text/12";
|
|
311
367
|
let t10;
|
|
312
|
-
if ($[
|
|
368
|
+
if ($[44] !== t9) {
|
|
313
369
|
t10 = clsx(REFERENCE_TONE, t9);
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
370
|
+
$[44] = t9;
|
|
371
|
+
$[45] = t10;
|
|
316
372
|
} else {
|
|
317
|
-
t10 = $[
|
|
373
|
+
t10 = $[45];
|
|
318
374
|
}
|
|
319
375
|
let t11;
|
|
320
|
-
if ($[
|
|
376
|
+
if ($[46] !== item.id || $[47] !== open) {
|
|
321
377
|
t11 = open === null ? undefined : () => open(item.id);
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
$[
|
|
378
|
+
$[46] = item.id;
|
|
379
|
+
$[47] = open;
|
|
380
|
+
$[48] = t11;
|
|
325
381
|
} else {
|
|
326
|
-
t11 = $[
|
|
382
|
+
t11 = $[48];
|
|
327
383
|
}
|
|
328
384
|
let t12;
|
|
329
|
-
if ($[
|
|
385
|
+
if ($[49] !== T0 || $[50] !== t10 || $[51] !== t11 || $[52] !== t3 || $[53] !== t4 || $[54] !== t5 || $[55] !== t7 || $[56] !== t8) {
|
|
330
386
|
t12 = /*#__PURE__*/_jsx(T0, {
|
|
331
387
|
kind: t3,
|
|
332
388
|
value: t4,
|
|
@@ -336,17 +392,17 @@ export function ReferenceChip(t0) {
|
|
|
336
392
|
tone: t10,
|
|
337
393
|
onOpen: t11
|
|
338
394
|
});
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
$[
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[
|
|
395
|
+
$[49] = T0;
|
|
396
|
+
$[50] = t10;
|
|
397
|
+
$[51] = t11;
|
|
398
|
+
$[52] = t3;
|
|
399
|
+
$[53] = t4;
|
|
400
|
+
$[54] = t5;
|
|
401
|
+
$[55] = t7;
|
|
402
|
+
$[56] = t8;
|
|
403
|
+
$[57] = t12;
|
|
348
404
|
} else {
|
|
349
|
-
t12 = $[
|
|
405
|
+
t12 = $[57];
|
|
350
406
|
}
|
|
351
407
|
return t12;
|
|
352
408
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { OutsideReference } from '../../host.js';
|
|
1
2
|
import type { Referable } from '../chat-references.js';
|
|
2
3
|
export interface ReferenceLookup {
|
|
3
4
|
items: readonly Referable[];
|
|
4
5
|
open: ((id: string) => void) | null;
|
|
6
|
+
outside?(id: string): OutsideReference | null;
|
|
5
7
|
referenced?: readonly string[];
|
|
6
8
|
}
|
|
7
9
|
export declare const ReferenceLookupContext: import("react").Context<ReferenceLookup>;
|
|
@@ -35,9 +35,10 @@ export function useReferenceLookup(chatId) {
|
|
|
35
35
|
}
|
|
36
36
|
/* The same for a row that may stand outside a scope. */
|
|
37
37
|
export function useReferenceLookupIn(scopeId, chatId) {
|
|
38
|
-
const $ = _c(
|
|
38
|
+
const $ = _c(13);
|
|
39
39
|
const {
|
|
40
|
-
openReference
|
|
40
|
+
openReference,
|
|
41
|
+
outsideReference
|
|
41
42
|
} = useChatHost();
|
|
42
43
|
const referables = useHostReferables(scopeId, chatId);
|
|
43
44
|
const key = useChatRow(chatId, _temp);
|
|
@@ -51,28 +52,41 @@ export function useReferenceLookupIn(scopeId, chatId) {
|
|
|
51
52
|
t0 = $[2];
|
|
52
53
|
}
|
|
53
54
|
let t1;
|
|
54
|
-
if ($[3] !==
|
|
55
|
-
t1 =
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if ($[3] !== outsideReference || $[4] !== scopeId) {
|
|
56
|
+
t1 = outsideReference ? {
|
|
57
|
+
outside: id_0 => outsideReference(scopeId, id_0)
|
|
58
|
+
} : {};
|
|
59
|
+
$[3] = outsideReference;
|
|
60
|
+
$[4] = scopeId;
|
|
61
|
+
$[5] = t1;
|
|
58
62
|
} else {
|
|
59
|
-
t1 = $[
|
|
63
|
+
t1 = $[5];
|
|
60
64
|
}
|
|
61
65
|
let t2;
|
|
62
|
-
if ($[
|
|
63
|
-
t2 =
|
|
66
|
+
if ($[6] !== key) {
|
|
67
|
+
t2 = key === "" ? [] : key.split("\n");
|
|
68
|
+
$[6] = key;
|
|
69
|
+
$[7] = t2;
|
|
70
|
+
} else {
|
|
71
|
+
t2 = $[7];
|
|
72
|
+
}
|
|
73
|
+
let t3;
|
|
74
|
+
if ($[8] !== referables.items || $[9] !== t0 || $[10] !== t1 || $[11] !== t2) {
|
|
75
|
+
t3 = {
|
|
64
76
|
items: referables.items,
|
|
65
77
|
open: t0,
|
|
66
|
-
|
|
78
|
+
...t1,
|
|
79
|
+
referenced: t2
|
|
67
80
|
};
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
81
|
+
$[8] = referables.items;
|
|
82
|
+
$[9] = t0;
|
|
83
|
+
$[10] = t1;
|
|
84
|
+
$[11] = t2;
|
|
85
|
+
$[12] = t3;
|
|
72
86
|
} else {
|
|
73
|
-
|
|
87
|
+
t3 = $[12];
|
|
74
88
|
}
|
|
75
|
-
return
|
|
89
|
+
return t3;
|
|
76
90
|
}
|
|
77
91
|
function _temp(chat) {
|
|
78
92
|
return threadReferencedKey(chat?.structure);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ChatBackgroundTask, ChatInfo } from '@adecore/agent-contracts';
|
|
2
|
+
export interface WaitingChild {
|
|
3
|
+
paused?: {
|
|
4
|
+
until?: number;
|
|
5
|
+
};
|
|
6
|
+
child?: Pick<ChatInfo, 'status' | 'requests'>;
|
|
7
|
+
}
|
|
8
|
+
export interface WaitingOnInput {
|
|
9
|
+
children?: readonly WaitingChild[];
|
|
10
|
+
background?: readonly ChatBackgroundTask[];
|
|
11
|
+
subagents?: number;
|
|
12
|
+
workflows?: number;
|
|
13
|
+
delegating?: boolean;
|
|
14
|
+
planStatus?: string;
|
|
15
|
+
}
|
|
16
|
+
export type WaitingOn = {
|
|
17
|
+
kind: 'needs-you';
|
|
18
|
+
count: number;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'paused';
|
|
21
|
+
until?: number;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'command';
|
|
24
|
+
task: ChatBackgroundTask;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'background';
|
|
27
|
+
subagents: number;
|
|
28
|
+
workflows: number;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'plan';
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function waitingOnOf(input: WaitingOnInput): WaitingOn | null;
|
|
34
|
+
export declare function waitingOnLabel(waiting: WaitingOn, now: number): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { formatElapsedShort, formatMoment } from '@adecore/ui/format';
|
|
2
|
+
import i18next from 'i18next';
|
|
3
|
+
/*
|
|
4
|
+
* The one thing a chat waits on, most pressing first: a child that needs the person, a child paused
|
|
5
|
+
* until a time, the oldest command or monitor in the background, background subagents and workflows,
|
|
6
|
+
* and the plan's status line. Null when it waits on none of them.
|
|
7
|
+
*/
|
|
8
|
+
export function waitingOnOf(input) {
|
|
9
|
+
const children = input.children ?? [];
|
|
10
|
+
const needsYou = children.filter(entry => entry.child?.status === 'needs-you' || (entry.child?.requests?.length ?? 0) > 0).length;
|
|
11
|
+
if (needsYou > 0) {
|
|
12
|
+
return {
|
|
13
|
+
kind: 'needs-you',
|
|
14
|
+
count: needsYou
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const paused = children.filter(entry => entry.paused !== undefined);
|
|
18
|
+
if (paused.length > 0) {
|
|
19
|
+
const times = paused.flatMap(entry => entry.paused?.until === undefined ? [] : [entry.paused.until]);
|
|
20
|
+
return times.length === 0 ? {
|
|
21
|
+
kind: 'paused'
|
|
22
|
+
} : {
|
|
23
|
+
kind: 'paused',
|
|
24
|
+
until: Math.min(...times)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const oldest = (input.background ?? []).reduce((found, task) => found === null || task.startedAt < found.startedAt ? task : found, null);
|
|
28
|
+
if (oldest !== null) {
|
|
29
|
+
return {
|
|
30
|
+
kind: 'command',
|
|
31
|
+
task: oldest
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const subagents = input.subagents ?? 0;
|
|
35
|
+
const workflows = input.workflows ?? 0;
|
|
36
|
+
if (subagents > 0 || workflows > 0 || input.delegating === true) {
|
|
37
|
+
return {
|
|
38
|
+
kind: 'background',
|
|
39
|
+
subagents,
|
|
40
|
+
workflows
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const status = input.planStatus?.trim();
|
|
44
|
+
return status ? {
|
|
45
|
+
kind: 'plan',
|
|
46
|
+
text: status
|
|
47
|
+
} : null;
|
|
48
|
+
}
|
|
49
|
+
/* The line a person reads for it, in the words of the `agent-chat` namespace; `now` ages a command. */
|
|
50
|
+
export function waitingOnLabel(waiting, now) {
|
|
51
|
+
const t = (key, options) => i18next.t(`agent-chat:${key}`, options ?? {});
|
|
52
|
+
switch (waiting.kind) {
|
|
53
|
+
case 'needs-you':
|
|
54
|
+
return t('waitingOn.needsYou', {
|
|
55
|
+
count: waiting.count
|
|
56
|
+
});
|
|
57
|
+
case 'paused':
|
|
58
|
+
return waiting.until === undefined ? t('waitingOn.paused') : t('waitingOn.pausedUntil', {
|
|
59
|
+
time: formatMoment(waiting.until, now)
|
|
60
|
+
});
|
|
61
|
+
case 'command':
|
|
62
|
+
return t('waitingOn.command', {
|
|
63
|
+
command: waiting.task.command || waiting.task.description || t(`activity.${waiting.task.kind}`),
|
|
64
|
+
age: formatElapsedShort(Math.max(0, now - waiting.task.startedAt))
|
|
65
|
+
});
|
|
66
|
+
case 'background':
|
|
67
|
+
if (waiting.subagents === 0 && waiting.workflows === 0) {
|
|
68
|
+
return t('waitingOn.background');
|
|
69
|
+
}
|
|
70
|
+
return [waiting.subagents > 0 && t('waitingOn.subagents', {
|
|
71
|
+
count: waiting.subagents
|
|
72
|
+
}), waiting.workflows > 0 && t('waitingOn.workflows', {
|
|
73
|
+
count: waiting.workflows
|
|
74
|
+
})].filter(Boolean).join(' · ');
|
|
75
|
+
case 'plan':
|
|
76
|
+
return waiting.text;
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/host.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ export interface ReferenceIconProps {
|
|
|
118
118
|
size: number;
|
|
119
119
|
className?: string;
|
|
120
120
|
}
|
|
121
|
+
export interface OutsideReference {
|
|
122
|
+
icon: LucideIcon;
|
|
123
|
+
open: (() => void) | null;
|
|
124
|
+
}
|
|
121
125
|
export interface ComposerHeaderSlotProps {
|
|
122
126
|
scopeId: string;
|
|
123
127
|
chatId: string;
|
|
@@ -374,6 +378,7 @@ export interface ChatHost {
|
|
|
374
378
|
useReferables?(scopeId: string, chatId: string): Referables;
|
|
375
379
|
ReferenceIcon?: ComponentType<ReferenceIconProps> | null;
|
|
376
380
|
openReference?(scopeId: string, id: string): void;
|
|
381
|
+
outsideReference?(scopeId: string, id: string): OutsideReference | null;
|
|
377
382
|
openLogin: ((scopeId: string, kind: AgentKind, accountId: string, name: string) => Promise<void>) | null;
|
|
378
383
|
useLoginBlocked(scopeId: string): string | null;
|
|
379
384
|
useCanReorderAccounts?(scopeId: string): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type ComposerSendAction, type ComposerSendDraft, type ComposerStatusDetail, type ComposerStatusItem, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, useChatHost, type AccentChoice, type ChatToast, type TextareaProps, type ResourceUrl } from './host.js';
|
|
1
|
+
export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type OutsideReference, type ComposerSendAction, type ComposerSendDraft, type ComposerStatusDetail, type ComposerStatusItem, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, useChatHost, type AccentChoice, type ChatToast, type TextareaProps, type ResourceUrl } from './host.js';
|
|
2
2
|
export { type ChatScope, ChatScopeContext, useChatScope } from './scope.js';
|
|
3
3
|
export { type ChatRequestMap, type ChatEventMap, type ChatTransportStatus, type ChatTransport, ChatTransportError, errorCode, isConnectionError } from './transport.js';
|
|
4
4
|
export { portTransport, type PortTransport } from './port-transport.js';
|
|
@@ -479,6 +479,18 @@ declare const _default: {
|
|
|
479
479
|
stop: string;
|
|
480
480
|
stopFailed: string;
|
|
481
481
|
};
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: string;
|
|
484
|
+
needsYou_other: string;
|
|
485
|
+
paused: string;
|
|
486
|
+
pausedUntil: string;
|
|
487
|
+
command: string;
|
|
488
|
+
background: string;
|
|
489
|
+
subagents_one: string;
|
|
490
|
+
subagents_other: string;
|
|
491
|
+
workflows_one: string;
|
|
492
|
+
workflows_other: string;
|
|
493
|
+
};
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: string;
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stop',
|
|
480
480
|
stopFailed: 'Could not stop task'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'A sub-agent needs you',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents need you',
|
|
485
|
+
paused: 'A sub-agent is paused',
|
|
486
|
+
pausedUntil: 'A sub-agent is paused until {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Working in the background',
|
|
489
|
+
subagents_one: '{{count}} sub-agent in the background',
|
|
490
|
+
subagents_other: '{{count}} sub-agents in the background',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Stop task',
|
|
@@ -479,6 +479,18 @@ declare const _default: {
|
|
|
479
479
|
stop: string;
|
|
480
480
|
stopFailed: string;
|
|
481
481
|
};
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: string;
|
|
484
|
+
needsYou_other: string;
|
|
485
|
+
paused: string;
|
|
486
|
+
pausedUntil: string;
|
|
487
|
+
command: string;
|
|
488
|
+
background: string;
|
|
489
|
+
subagents_one: string;
|
|
490
|
+
subagents_other: string;
|
|
491
|
+
workflows_one: string;
|
|
492
|
+
workflows_other: string;
|
|
493
|
+
};
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: string;
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stoppen',
|
|
480
480
|
stopFailed: 'Kon de taak niet stoppen'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'Een sub-agent vraagt aandacht',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents vragen aandacht',
|
|
485
|
+
paused: 'Een sub-agent is gepauzeerd',
|
|
486
|
+
pausedUntil: 'Een sub-agent is gepauzeerd tot {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Bezig op de achtergrond',
|
|
489
|
+
subagents_one: '{{count}} sub-agent op de achtergrond',
|
|
490
|
+
subagents_other: '{{count}} sub-agents op de achtergrond',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Taak stoppen',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.1",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
80
|
-
"@adecore/utils": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.62.1",
|
|
76
|
+
"@adecore/editor": "0.62.1",
|
|
77
|
+
"@adecore/editor-react": "0.62.1",
|
|
78
|
+
"@adecore/intelligent-ui": "0.62.1",
|
|
79
|
+
"@adecore/merge": "0.62.1",
|
|
80
|
+
"@adecore/utils": "0.62.1",
|
|
81
81
|
"@codemirror/commands": "^6.11.1",
|
|
82
82
|
"@codemirror/language": "^6.13.1",
|
|
83
83
|
"@codemirror/state": "^6.7.6",
|
|
@@ -101,14 +101,14 @@
|
|
|
101
101
|
"zustand": "^5.0.16"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@adecore/ui": "^0.
|
|
104
|
+
"@adecore/ui": "^0.62.1",
|
|
105
105
|
"i18next": "^26.4.2",
|
|
106
106
|
"react": "^19.3.0",
|
|
107
107
|
"react-dom": "^19.3.0",
|
|
108
108
|
"react-i18next": "^17.0.15"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@adecore/ui": "0.
|
|
111
|
+
"@adecore/ui": "0.62.1",
|
|
112
112
|
"@types/bun": "^1.4.4",
|
|
113
113
|
"@types/react": "^19.3.0",
|
|
114
114
|
"@types/react-dom": "^19.3.0",
|
package/src/chat/index.ts
CHANGED
|
@@ -91,6 +91,7 @@ export { RUNTIME_MODES, runtimeModeLabel, runtimeModeHint } from './runtime-mode
|
|
|
91
91
|
export { CHAT_SEND_KEYS, SEND_AND_NEW_SHORTCUT, sendKeyLabel, sendKeyHint, type ChatSendKey } from './send-key';
|
|
92
92
|
export type { StashedAttachment, StashedPrompt, StashedQuote } from './stash';
|
|
93
93
|
export { subagentTitle, summaryWordOf, stopOf, type SubagentStop } from './subagent-list';
|
|
94
|
+
export { waitingOnOf, waitingOnLabel, type WaitingChild, type WaitingOn, type WaitingOnInput } from './waiting-on';
|
|
94
95
|
export { useSubagentSupport } from './subagent-support';
|
|
95
96
|
|
|
96
97
|
export {
|
|
@@ -16,6 +16,7 @@ import { backgroundCounts } from '../activity';
|
|
|
16
16
|
import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskIdOf, taskRowStateOf } from '../subagent-list';
|
|
17
17
|
import { useSubagentSupport } from '../subagent-support';
|
|
18
18
|
import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail, type SubagentStep } from '../subagent-view';
|
|
19
|
+
import { waitingOnLabel, waitingOnOf } from '../waiting-on';
|
|
19
20
|
import { flyoutWorkflows, workflowPillOf, type WorkflowCall, type WorkflowWord } from '../workflow-list';
|
|
20
21
|
import { WorkflowRow } from './rows/WorkflowRow';
|
|
21
22
|
import { SubagentStopButton } from './SubagentStopButton';
|
|
@@ -98,7 +99,8 @@ export function ChatActivity({ chatId, workflows: showsWorkflows = true }: { cha
|
|
|
98
99
|
{background.length > 0 && (
|
|
99
100
|
<Flyout
|
|
100
101
|
icon={<Icon icon={shells > 0 ? SquareTerminal : Activity} size={14} />}
|
|
101
|
-
label={
|
|
102
|
+
label={<BackgroundLabel tasks={background} />}
|
|
103
|
+
heading={[shells > 0 && t('activity.shells', { count: shells }), monitors > 0 && t('activity.monitors', { count: monitors })]
|
|
102
104
|
.filter(Boolean)
|
|
103
105
|
.join(' · ')}
|
|
104
106
|
>
|
|
@@ -116,12 +118,12 @@ export function StatusIcon({ word }: { word: StatusWord }) {
|
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
/* A chip that opens a list over it, headed by what the chip says unless the list counts more than the chip does. */
|
|
119
|
-
function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; label:
|
|
121
|
+
function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; label: ReactNode; heading?: ReactNode; children: ReactNode }) {
|
|
120
122
|
return (
|
|
121
123
|
<Popover.Root>
|
|
122
124
|
<Surface
|
|
123
125
|
render={<Popover.Trigger />}
|
|
124
|
-
className="pointer-events-auto inline-flex h-7.5 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text"
|
|
126
|
+
className="pointer-events-auto inline-flex h-7.5 max-w-full min-w-0 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text"
|
|
125
127
|
>
|
|
126
128
|
{icon}
|
|
127
129
|
{label}
|
|
@@ -134,6 +136,14 @@ function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; l
|
|
|
134
136
|
);
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
/* What the background chip says: the oldest command or monitor and how long it has run, on a clock of its own. */
|
|
140
|
+
function BackgroundLabel({ tasks }: { tasks: readonly ChatBackgroundTask[] }) {
|
|
141
|
+
const now = useNow(1000);
|
|
142
|
+
const waiting = waitingOnOf({ background: tasks });
|
|
143
|
+
|
|
144
|
+
return <span className="truncate">{waiting === null ? null : waitingOnLabel(waiting, now)}</span>;
|
|
145
|
+
}
|
|
146
|
+
|
|
137
147
|
function WorkflowIcon({ word }: { word: WorkflowWord }) {
|
|
138
148
|
return word === 'stalled' ? <Icon icon={TriangleAlert} size={14} className="shrink-0 text-status-needs-you" /> : <StatusIcon word={word} />;
|
|
139
149
|
}
|
|
@@ -77,9 +77,24 @@ export function TokenChip({ kind, value, sigil, icon, label, spelled, tone, onOp
|
|
|
77
77
|
*/
|
|
78
78
|
export function ReferenceChip({ id, lastName, goneHint }: { id: string; lastName?: string; goneHint?: string }) {
|
|
79
79
|
const { t } = useTranslation('agent-chat');
|
|
80
|
-
const { items, open } = useContext(ReferenceLookupContext);
|
|
80
|
+
const { items, open, outside } = useContext(ReferenceLookupContext);
|
|
81
81
|
const { ReferenceIcon } = useChatHost();
|
|
82
82
|
const item = items.find((candidate) => candidate.id === id);
|
|
83
|
+
const elsewhere = item === undefined ? (outside?.(id) ?? null) : null;
|
|
84
|
+
|
|
85
|
+
if (elsewhere !== null) {
|
|
86
|
+
const opens = elsewhere.open;
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<TokenChip
|
|
90
|
+
kind="gone"
|
|
91
|
+
icon={<Icon icon={elsewhere.icon} size={14} className={TOKEN_ICON} />}
|
|
92
|
+
label={lastName || t('references.gone')}
|
|
93
|
+
tone={clsx(REFERENCE_TONE, opens !== null && 'hover:bg-text/12')}
|
|
94
|
+
onOpen={opens ?? undefined}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
83
98
|
|
|
84
99
|
if (item === undefined) {
|
|
85
100
|
const chip = (
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
+
import type { OutsideReference } from '../../host';
|
|
2
3
|
import type { Referable } from '../chat-references';
|
|
3
4
|
|
|
4
5
|
export interface ReferenceLookup {
|
|
5
6
|
items: readonly Referable[];
|
|
6
7
|
/* Null where the host opens nothing. */
|
|
7
8
|
open: ((id: string) => void) | null;
|
|
9
|
+
/* What an id that is none of `items` still stands for; absent, or null, where it stands for nothing. */
|
|
10
|
+
outside?(id: string): OutsideReference | null;
|
|
8
11
|
/* What a person pointed at with `#` in this thread, which a reply wins over another of the same name. */
|
|
9
12
|
referenced?: readonly string[];
|
|
10
13
|
}
|
|
@@ -46,13 +46,14 @@ export function useReferenceLookup(chatId: string): ReferenceLookup {
|
|
|
46
46
|
|
|
47
47
|
/* The same for a row that may stand outside a scope. */
|
|
48
48
|
export function useReferenceLookupIn(scopeId: string, chatId: string): ReferenceLookup {
|
|
49
|
-
const { openReference } = useChatHost();
|
|
49
|
+
const { openReference, outsideReference } = useChatHost();
|
|
50
50
|
const referables = useHostReferables(scopeId, chatId);
|
|
51
51
|
const key = useChatRow(chatId, (chat) => threadReferencedKey(chat?.structure));
|
|
52
52
|
|
|
53
53
|
return {
|
|
54
54
|
items: referables.items,
|
|
55
55
|
open: openReference ? (id: string) => openReference(scopeId, id) : null,
|
|
56
|
+
...(outsideReference ? { outside: (id: string) => outsideReference(scopeId, id) } : {}),
|
|
56
57
|
referenced: key === '' ? [] : key.split('\n')
|
|
57
58
|
};
|
|
58
59
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ChatBackgroundTask, ChatInfo } from '@adecore/agent-contracts';
|
|
2
|
+
import { formatElapsedShort, formatMoment } from '@adecore/ui/format';
|
|
3
|
+
import i18next from 'i18next';
|
|
4
|
+
|
|
5
|
+
/* An open task the chat delegated: whether its child waits out a limit, and that child's info where the client has it. */
|
|
6
|
+
export interface WaitingChild {
|
|
7
|
+
paused?: { until?: number };
|
|
8
|
+
child?: Pick<ChatInfo, 'status' | 'requests'>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* What a chat has that it may be waiting on, as every client already holds it. */
|
|
12
|
+
export interface WaitingOnInput {
|
|
13
|
+
children?: readonly WaitingChild[];
|
|
14
|
+
background?: readonly ChatBackgroundTask[];
|
|
15
|
+
/* Background subagents and workflows of the CLI's own, counted where the thread is loaded. */
|
|
16
|
+
subagents?: number;
|
|
17
|
+
workflows?: number;
|
|
18
|
+
/* `ChatInfo.delegating`, for a client that has only the info and so no counts. */
|
|
19
|
+
delegating?: boolean;
|
|
20
|
+
/* The status line of the plan the chat works on. */
|
|
21
|
+
planStatus?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type WaitingOn =
|
|
25
|
+
| { kind: 'needs-you'; count: number }
|
|
26
|
+
| { kind: 'paused'; until?: number }
|
|
27
|
+
| { kind: 'command'; task: ChatBackgroundTask }
|
|
28
|
+
| { kind: 'background'; subagents: number; workflows: number }
|
|
29
|
+
| { kind: 'plan'; text: string };
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* The one thing a chat waits on, most pressing first: a child that needs the person, a child paused
|
|
33
|
+
* until a time, the oldest command or monitor in the background, background subagents and workflows,
|
|
34
|
+
* and the plan's status line. Null when it waits on none of them.
|
|
35
|
+
*/
|
|
36
|
+
export function waitingOnOf(input: WaitingOnInput): WaitingOn | null {
|
|
37
|
+
const children = input.children ?? [];
|
|
38
|
+
const needsYou = children.filter((entry) => entry.child?.status === 'needs-you' || (entry.child?.requests?.length ?? 0) > 0).length;
|
|
39
|
+
|
|
40
|
+
if (needsYou > 0) {
|
|
41
|
+
return { kind: 'needs-you', count: needsYou };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const paused = children.filter((entry) => entry.paused !== undefined);
|
|
45
|
+
|
|
46
|
+
if (paused.length > 0) {
|
|
47
|
+
const times = paused.flatMap((entry) => (entry.paused?.until === undefined ? [] : [entry.paused.until]));
|
|
48
|
+
|
|
49
|
+
return times.length === 0 ? { kind: 'paused' } : { kind: 'paused', until: Math.min(...times) };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const oldest = (input.background ?? []).reduce<ChatBackgroundTask | null>(
|
|
53
|
+
(found, task) => (found === null || task.startedAt < found.startedAt ? task : found),
|
|
54
|
+
null
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (oldest !== null) {
|
|
58
|
+
return { kind: 'command', task: oldest };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const subagents = input.subagents ?? 0;
|
|
62
|
+
const workflows = input.workflows ?? 0;
|
|
63
|
+
|
|
64
|
+
if (subagents > 0 || workflows > 0 || input.delegating === true) {
|
|
65
|
+
return { kind: 'background', subagents, workflows };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const status = input.planStatus?.trim();
|
|
69
|
+
|
|
70
|
+
return status ? { kind: 'plan', text: status } : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* The line a person reads for it, in the words of the `agent-chat` namespace; `now` ages a command. */
|
|
74
|
+
export function waitingOnLabel(waiting: WaitingOn, now: number): string {
|
|
75
|
+
const t = (key: string, options?: Record<string, unknown>): string => i18next.t(`agent-chat:${key}`, options ?? {});
|
|
76
|
+
|
|
77
|
+
switch (waiting.kind) {
|
|
78
|
+
case 'needs-you':
|
|
79
|
+
return t('waitingOn.needsYou', { count: waiting.count });
|
|
80
|
+
case 'paused':
|
|
81
|
+
return waiting.until === undefined ? t('waitingOn.paused') : t('waitingOn.pausedUntil', { time: formatMoment(waiting.until, now) });
|
|
82
|
+
case 'command':
|
|
83
|
+
return t('waitingOn.command', {
|
|
84
|
+
command: waiting.task.command || waiting.task.description || t(`activity.${waiting.task.kind}`),
|
|
85
|
+
age: formatElapsedShort(Math.max(0, now - waiting.task.startedAt))
|
|
86
|
+
});
|
|
87
|
+
case 'background':
|
|
88
|
+
if (waiting.subagents === 0 && waiting.workflows === 0) {
|
|
89
|
+
return t('waitingOn.background');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return [
|
|
93
|
+
waiting.subagents > 0 && t('waitingOn.subagents', { count: waiting.subagents }),
|
|
94
|
+
waiting.workflows > 0 && t('waitingOn.workflows', { count: waiting.workflows })
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(' · ');
|
|
98
|
+
case 'plan':
|
|
99
|
+
return waiting.text;
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/host.ts
CHANGED
|
@@ -191,6 +191,12 @@ export interface ReferenceIconProps {
|
|
|
191
191
|
className?: string;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/* What a chip of an id that is no view or node still stands for, such as a sender from outside: its mark, and what clicking it opens. */
|
|
195
|
+
export interface OutsideReference {
|
|
196
|
+
icon: LucideIcon;
|
|
197
|
+
open: (() => void) | null;
|
|
198
|
+
}
|
|
199
|
+
|
|
194
200
|
/* What an app's own bar over the composer gets: the chat it stands on, which may be one the bar has nothing for. */
|
|
195
201
|
export interface ComposerHeaderSlotProps {
|
|
196
202
|
scopeId: string;
|
|
@@ -589,6 +595,11 @@ export interface ChatHost {
|
|
|
589
595
|
ReferenceIcon?: ComponentType<ReferenceIconProps> | null;
|
|
590
596
|
/* Opens a view or zooms to a node a message points at; left out, a chip opens nothing. */
|
|
591
597
|
openReference?(scopeId: string, id: string): void;
|
|
598
|
+
/*
|
|
599
|
+
* What an id among no `useReferables` items stands for, such as a sender from outside, which keeps the name its
|
|
600
|
+
* message gave it. Null, or left out, draws the chip as gone.
|
|
601
|
+
*/
|
|
602
|
+
outsideReference?(scopeId: string, id: string): OutsideReference | null;
|
|
592
603
|
/* Opens the CLI's own login for an account, somewhere the app can run a command; null offers none. */
|
|
593
604
|
openLogin: ((scopeId: string, kind: AgentKind, accountId: string, name: string) => Promise<void>) | null;
|
|
594
605
|
/* Why a login cannot start from here right now, or null when it can. */
|
package/src/index.ts
CHANGED
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stop',
|
|
480
480
|
stopFailed: 'Could not stop task'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'A sub-agent needs you',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents need you',
|
|
485
|
+
paused: 'A sub-agent is paused',
|
|
486
|
+
pausedUntil: 'A sub-agent is paused until {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Working in the background',
|
|
489
|
+
subagents_one: '{{count}} sub-agent in the background',
|
|
490
|
+
subagents_other: '{{count}} sub-agents in the background',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Stop task',
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stoppen',
|
|
480
480
|
stopFailed: 'Kon de taak niet stoppen'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'Een sub-agent vraagt aandacht',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents vragen aandacht',
|
|
485
|
+
paused: 'Een sub-agent is gepauzeerd',
|
|
486
|
+
pausedUntil: 'Een sub-agent is gepauzeerd tot {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Bezig op de achtergrond',
|
|
489
|
+
subagents_one: '{{count}} sub-agent op de achtergrond',
|
|
490
|
+
subagents_other: '{{count}} sub-agents op de achtergrond',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Taak stoppen',
|