@adecore/agents-react 0.48.1 → 0.48.2
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/logic/timeline.d.ts +1 -0
- package/dist/chat/logic/timeline.js +3 -0
- package/dist/chat/ui/rows/MessageRows.d.ts +2 -1
- package/dist/chat/ui/rows/MessageRows.js +223 -62
- package/dist/chat/ui/rows/Rows.js +31 -29
- package/dist/host.d.ts +1 -0
- package/package.json +8 -8
- package/src/chat/logic/timeline.ts +9 -2
- package/src/chat/ui/rows/MessageRows.tsx +67 -20
- package/src/chat/ui/rows/Rows.tsx +1 -1
- package/src/host.ts +2 -0
|
@@ -28,11 +28,12 @@ export declare function LiveThoughtRow({ chatId, item: derived }: {
|
|
|
28
28
|
chatId: string;
|
|
29
29
|
item: ChatThinkingItem;
|
|
30
30
|
}): import("react").JSX.Element | null;
|
|
31
|
-
export declare function NoteRow({ id, level, text, from }: {
|
|
31
|
+
export declare function NoteRow({ id, level, text, from, said }: {
|
|
32
32
|
id: string;
|
|
33
33
|
level: 'info' | 'warning' | 'error';
|
|
34
34
|
text: string;
|
|
35
35
|
from?: string;
|
|
36
|
+
said?: true;
|
|
36
37
|
}): import("react").JSX.Element;
|
|
37
38
|
export declare function AgentTurnRow({ label, onOpen }: {
|
|
38
39
|
label: string;
|
|
@@ -28,7 +28,9 @@ import { ROW_GUTTER } from '../icons.js';
|
|
|
28
28
|
import { useOpenForFind } from '../find-reveal.js';
|
|
29
29
|
import { ReplyContext, UiReplyNavigationContext } from '../reply-context.js';
|
|
30
30
|
import { UiReply } from '../intelligent-ui/UiReply.js';
|
|
31
|
+
import { useChatHost } from '../../../host.js';
|
|
31
32
|
import { useHostAttachmentUrl, useHostChatPlace, useHostReplyAuthor, useHostStreaming } from '../../../host-hooks.js';
|
|
33
|
+
import { REFERENCE_TONE, TOKEN_IN_MESSAGE } from '../chips.js';
|
|
32
34
|
import { copySelectionWithChips } from '../chip-clipboard.js';
|
|
33
35
|
import { useReferenceLookup } from '../thread-references.js';
|
|
34
36
|
// A long prompt folds so the answer stays in view; the reader can open it.
|
|
@@ -444,7 +446,7 @@ function _temp(e) {
|
|
|
444
446
|
return copySelectionWithChips(e.nativeEvent);
|
|
445
447
|
}
|
|
446
448
|
export function SentMessageRow(t0) {
|
|
447
|
-
const $ = _c(
|
|
449
|
+
const $ = _c(14);
|
|
448
450
|
const {
|
|
449
451
|
chatId,
|
|
450
452
|
id,
|
|
@@ -453,24 +455,152 @@ export function SentMessageRow(t0) {
|
|
|
453
455
|
const {
|
|
454
456
|
t
|
|
455
457
|
} = useTranslation("agent-chat");
|
|
458
|
+
const lookup = useReferenceLookup(chatId);
|
|
459
|
+
let t1;
|
|
460
|
+
if ($[0] !== message.title || $[1] !== t) {
|
|
461
|
+
t1 = message.title || t("rows.message.unnamed");
|
|
462
|
+
$[0] = message.title;
|
|
463
|
+
$[1] = t;
|
|
464
|
+
$[2] = t1;
|
|
465
|
+
} else {
|
|
466
|
+
t1 = $[2];
|
|
467
|
+
}
|
|
468
|
+
let t2;
|
|
469
|
+
if ($[3] !== message.from || $[4] !== message.title) {
|
|
470
|
+
t2 = /*#__PURE__*/_jsx(ReferenceChip, {
|
|
471
|
+
id: message.from,
|
|
472
|
+
lastName: message.title
|
|
473
|
+
});
|
|
474
|
+
$[3] = message.from;
|
|
475
|
+
$[4] = message.title;
|
|
476
|
+
$[5] = t2;
|
|
477
|
+
} else {
|
|
478
|
+
t2 = $[5];
|
|
479
|
+
}
|
|
480
|
+
let t3;
|
|
481
|
+
if ($[6] !== id || $[7] !== message.text || $[8] !== t1 || $[9] !== t2) {
|
|
482
|
+
t3 = /*#__PURE__*/_jsx(SaidMessage, {
|
|
483
|
+
id: id,
|
|
484
|
+
name: t1,
|
|
485
|
+
chip: t2,
|
|
486
|
+
text: message.text
|
|
487
|
+
});
|
|
488
|
+
$[6] = id;
|
|
489
|
+
$[7] = message.text;
|
|
490
|
+
$[8] = t1;
|
|
491
|
+
$[9] = t2;
|
|
492
|
+
$[10] = t3;
|
|
493
|
+
} else {
|
|
494
|
+
t3 = $[10];
|
|
495
|
+
}
|
|
496
|
+
let t4;
|
|
497
|
+
if ($[11] !== lookup || $[12] !== t3) {
|
|
498
|
+
t4 = /*#__PURE__*/_jsx(ReferenceLookupContext, {
|
|
499
|
+
value: lookup,
|
|
500
|
+
children: t3
|
|
501
|
+
});
|
|
502
|
+
$[11] = lookup;
|
|
503
|
+
$[12] = t3;
|
|
504
|
+
$[13] = t4;
|
|
505
|
+
} else {
|
|
506
|
+
t4 = $[13];
|
|
507
|
+
}
|
|
508
|
+
return t4;
|
|
509
|
+
}
|
|
510
|
+
/* What the host told the agent in front of a prompt, said under the host's own name, which the text no longer has to lead with. */
|
|
511
|
+
function HostSaidRow(t0) {
|
|
512
|
+
const $ = _c(14);
|
|
513
|
+
const {
|
|
514
|
+
id,
|
|
515
|
+
text,
|
|
516
|
+
author
|
|
517
|
+
} = t0;
|
|
518
|
+
const prefix = `${author.name}: `;
|
|
519
|
+
let t1;
|
|
520
|
+
if ($[0] !== prefix || $[1] !== text) {
|
|
521
|
+
let t2;
|
|
522
|
+
if ($[3] !== prefix) {
|
|
523
|
+
t2 = part => part.startsWith(prefix) ? part.slice(prefix.length) : part;
|
|
524
|
+
$[3] = prefix;
|
|
525
|
+
$[4] = t2;
|
|
526
|
+
} else {
|
|
527
|
+
t2 = $[4];
|
|
528
|
+
}
|
|
529
|
+
t1 = text.split("\n\n").map(t2).join("\n\n");
|
|
530
|
+
$[0] = prefix;
|
|
531
|
+
$[1] = text;
|
|
532
|
+
$[2] = t1;
|
|
533
|
+
} else {
|
|
534
|
+
t1 = $[2];
|
|
535
|
+
}
|
|
536
|
+
const words = t1;
|
|
537
|
+
const t2 = author.name;
|
|
538
|
+
let t3;
|
|
539
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
540
|
+
t3 = clsx(TOKEN_IN_MESSAGE, REFERENCE_TONE, "inline-flex items-center gap-1");
|
|
541
|
+
$[5] = t3;
|
|
542
|
+
} else {
|
|
543
|
+
t3 = $[5];
|
|
544
|
+
}
|
|
545
|
+
let t4;
|
|
546
|
+
if ($[6] !== author.mark || $[7] !== author.name) {
|
|
547
|
+
t4 = /*#__PURE__*/_jsxs("span", {
|
|
548
|
+
className: t3,
|
|
549
|
+
children: [author.mark, author.name]
|
|
550
|
+
});
|
|
551
|
+
$[6] = author.mark;
|
|
552
|
+
$[7] = author.name;
|
|
553
|
+
$[8] = t4;
|
|
554
|
+
} else {
|
|
555
|
+
t4 = $[8];
|
|
556
|
+
}
|
|
557
|
+
let t5;
|
|
558
|
+
if ($[9] !== author.name || $[10] !== id || $[11] !== t4 || $[12] !== words) {
|
|
559
|
+
t5 = /*#__PURE__*/_jsx(SaidMessage, {
|
|
560
|
+
id: id,
|
|
561
|
+
name: t2,
|
|
562
|
+
chip: t4,
|
|
563
|
+
text: words
|
|
564
|
+
});
|
|
565
|
+
$[9] = author.name;
|
|
566
|
+
$[10] = id;
|
|
567
|
+
$[11] = t4;
|
|
568
|
+
$[12] = words;
|
|
569
|
+
$[13] = t5;
|
|
570
|
+
} else {
|
|
571
|
+
t5 = $[13];
|
|
572
|
+
}
|
|
573
|
+
return t5;
|
|
574
|
+
}
|
|
575
|
+
/* A message the person did not write: a bubble on the left, quieter than theirs, under a chip of who said it. A long one folds. */
|
|
576
|
+
function SaidMessage(t0) {
|
|
577
|
+
const $ = _c(28);
|
|
578
|
+
const {
|
|
579
|
+
id,
|
|
580
|
+
name,
|
|
581
|
+
chip,
|
|
582
|
+
text
|
|
583
|
+
} = t0;
|
|
584
|
+
const {
|
|
585
|
+
t
|
|
586
|
+
} = useTranslation("agent-chat");
|
|
456
587
|
const [open, setOpen] = useState(false);
|
|
457
588
|
let t1;
|
|
458
|
-
if ($[0] !==
|
|
459
|
-
t1 =
|
|
460
|
-
$[0] =
|
|
589
|
+
if ($[0] !== text) {
|
|
590
|
+
t1 = text.split("\n").length > USER_FOLD_LINES || text.length > USER_FOLD_CHARS;
|
|
591
|
+
$[0] = text;
|
|
461
592
|
$[1] = t1;
|
|
462
593
|
} else {
|
|
463
594
|
t1 = $[1];
|
|
464
595
|
}
|
|
465
596
|
const long = t1;
|
|
466
|
-
const lookup = useReferenceLookup(chatId);
|
|
467
597
|
useOpenForFind(id, "text", setOpen);
|
|
468
598
|
let t2;
|
|
469
|
-
if ($[2] !==
|
|
599
|
+
if ($[2] !== name || $[3] !== t) {
|
|
470
600
|
t2 = t("rows.message.heading", {
|
|
471
|
-
name
|
|
601
|
+
name
|
|
472
602
|
});
|
|
473
|
-
$[2] =
|
|
603
|
+
$[2] = name;
|
|
474
604
|
$[3] = t;
|
|
475
605
|
$[4] = t2;
|
|
476
606
|
} else {
|
|
@@ -487,54 +617,50 @@ export function SentMessageRow(t0) {
|
|
|
487
617
|
t3 = $[6];
|
|
488
618
|
}
|
|
489
619
|
let t4;
|
|
490
|
-
if ($[7] !==
|
|
620
|
+
if ($[7] !== chip) {
|
|
491
621
|
t4 = /*#__PURE__*/_jsx("div", {
|
|
492
622
|
className: "mb-1.5 flex max-w-[80%]",
|
|
493
|
-
children:
|
|
494
|
-
id: message.from,
|
|
495
|
-
lastName: message.title
|
|
496
|
-
})
|
|
623
|
+
children: chip
|
|
497
624
|
});
|
|
498
|
-
$[7] =
|
|
499
|
-
$[8] =
|
|
500
|
-
$[9] = t4;
|
|
625
|
+
$[7] = chip;
|
|
626
|
+
$[8] = t4;
|
|
501
627
|
} else {
|
|
502
|
-
t4 = $[
|
|
628
|
+
t4 = $[8];
|
|
503
629
|
}
|
|
504
630
|
const t5 = long && !open && FOLD;
|
|
505
631
|
let t6;
|
|
506
|
-
if ($[
|
|
632
|
+
if ($[9] !== t5) {
|
|
507
633
|
t6 = clsx(t5);
|
|
508
|
-
$[
|
|
509
|
-
$[
|
|
634
|
+
$[9] = t5;
|
|
635
|
+
$[10] = t6;
|
|
510
636
|
} else {
|
|
511
|
-
t6 = $[
|
|
637
|
+
t6 = $[10];
|
|
512
638
|
}
|
|
513
639
|
let t7;
|
|
514
|
-
if ($[
|
|
640
|
+
if ($[11] !== text) {
|
|
515
641
|
t7 = /*#__PURE__*/_jsx(MessageMarkdown, {
|
|
516
|
-
text:
|
|
642
|
+
text: text
|
|
517
643
|
});
|
|
518
|
-
$[
|
|
519
|
-
$[
|
|
644
|
+
$[11] = text;
|
|
645
|
+
$[12] = t7;
|
|
520
646
|
} else {
|
|
521
|
-
t7 = $[
|
|
647
|
+
t7 = $[12];
|
|
522
648
|
}
|
|
523
649
|
let t8;
|
|
524
|
-
if ($[
|
|
650
|
+
if ($[13] !== t6 || $[14] !== t7) {
|
|
525
651
|
t8 = /*#__PURE__*/_jsx("div", {
|
|
526
652
|
"data-find-field": "text",
|
|
527
653
|
className: t6,
|
|
528
654
|
children: t7
|
|
529
655
|
});
|
|
530
|
-
$[
|
|
531
|
-
$[
|
|
532
|
-
$[
|
|
656
|
+
$[13] = t6;
|
|
657
|
+
$[14] = t7;
|
|
658
|
+
$[15] = t8;
|
|
533
659
|
} else {
|
|
534
|
-
t8 = $[
|
|
660
|
+
t8 = $[15];
|
|
535
661
|
}
|
|
536
662
|
let t9;
|
|
537
|
-
if ($[
|
|
663
|
+
if ($[16] !== long || $[17] !== open || $[18] !== t) {
|
|
538
664
|
t9 = long && /*#__PURE__*/_jsxs("button", {
|
|
539
665
|
className: "mt-1 flex items-center gap-1 text-xs text-text-muted hover:text-text",
|
|
540
666
|
onClick: () => setOpen(_temp4),
|
|
@@ -544,53 +670,41 @@ export function SentMessageRow(t0) {
|
|
|
544
670
|
className: clsx("transition-transform", open && "rotate-180")
|
|
545
671
|
}), " ", open ? t("rows.user.showLess") : t("rows.user.showAll")]
|
|
546
672
|
});
|
|
547
|
-
$[
|
|
548
|
-
$[
|
|
549
|
-
$[
|
|
550
|
-
$[
|
|
673
|
+
$[16] = long;
|
|
674
|
+
$[17] = open;
|
|
675
|
+
$[18] = t;
|
|
676
|
+
$[19] = t9;
|
|
551
677
|
} else {
|
|
552
|
-
t9 = $[
|
|
678
|
+
t9 = $[19];
|
|
553
679
|
}
|
|
554
680
|
let t10;
|
|
555
|
-
if ($[
|
|
681
|
+
if ($[20] !== t8 || $[21] !== t9) {
|
|
556
682
|
t10 = /*#__PURE__*/_jsxs("div", {
|
|
557
683
|
className: "relative max-w-[80%] rounded-2xl bg-surface-hover px-3.5 py-2.5 text-sm wrap-anywhere text-text select-text",
|
|
558
684
|
children: [t8, t9]
|
|
559
685
|
});
|
|
560
|
-
$[
|
|
561
|
-
$[
|
|
562
|
-
$[
|
|
686
|
+
$[20] = t8;
|
|
687
|
+
$[21] = t9;
|
|
688
|
+
$[22] = t10;
|
|
563
689
|
} else {
|
|
564
|
-
t10 = $[
|
|
690
|
+
t10 = $[22];
|
|
565
691
|
}
|
|
566
692
|
let t11;
|
|
567
|
-
if ($[
|
|
693
|
+
if ($[23] !== id || $[24] !== t10 || $[25] !== t3 || $[26] !== t4) {
|
|
568
694
|
t11 = /*#__PURE__*/_jsxs("div", {
|
|
569
695
|
"data-find-item": id,
|
|
570
696
|
className: "flex flex-col items-start",
|
|
571
697
|
children: [t3, t4, t10]
|
|
572
698
|
});
|
|
573
|
-
$[
|
|
574
|
-
$[
|
|
575
|
-
$[
|
|
576
|
-
$[
|
|
577
|
-
$[
|
|
578
|
-
} else {
|
|
579
|
-
t11 = $[28];
|
|
580
|
-
}
|
|
581
|
-
let t12;
|
|
582
|
-
if ($[29] !== lookup || $[30] !== t11) {
|
|
583
|
-
t12 = /*#__PURE__*/_jsx(ReferenceLookupContext, {
|
|
584
|
-
value: lookup,
|
|
585
|
-
children: t11
|
|
586
|
-
});
|
|
587
|
-
$[29] = lookup;
|
|
588
|
-
$[30] = t11;
|
|
589
|
-
$[31] = t12;
|
|
699
|
+
$[23] = id;
|
|
700
|
+
$[24] = t10;
|
|
701
|
+
$[25] = t3;
|
|
702
|
+
$[26] = t4;
|
|
703
|
+
$[27] = t11;
|
|
590
704
|
} else {
|
|
591
|
-
|
|
705
|
+
t11 = $[27];
|
|
592
706
|
}
|
|
593
|
-
return
|
|
707
|
+
return t11;
|
|
594
708
|
}
|
|
595
709
|
/*
|
|
596
710
|
* The choice a message answers. The label stays out of the message, which holds exactly what the agent
|
|
@@ -1473,6 +1587,53 @@ const NOTE_ICON = {
|
|
|
1473
1587
|
* shows its first line and folds the rest open as markdown; one that came from a fork leads to it.
|
|
1474
1588
|
*/
|
|
1475
1589
|
export function NoteRow(t0) {
|
|
1590
|
+
const $ = _c(9);
|
|
1591
|
+
const {
|
|
1592
|
+
id,
|
|
1593
|
+
level,
|
|
1594
|
+
text,
|
|
1595
|
+
from,
|
|
1596
|
+
said
|
|
1597
|
+
} = t0;
|
|
1598
|
+
const {
|
|
1599
|
+
saidBy
|
|
1600
|
+
} = useChatHost();
|
|
1601
|
+
if (said && saidBy !== undefined) {
|
|
1602
|
+
let t1;
|
|
1603
|
+
if ($[0] !== id || $[1] !== saidBy || $[2] !== text) {
|
|
1604
|
+
t1 = /*#__PURE__*/_jsx(HostSaidRow, {
|
|
1605
|
+
id: id,
|
|
1606
|
+
text: text,
|
|
1607
|
+
author: saidBy
|
|
1608
|
+
});
|
|
1609
|
+
$[0] = id;
|
|
1610
|
+
$[1] = saidBy;
|
|
1611
|
+
$[2] = text;
|
|
1612
|
+
$[3] = t1;
|
|
1613
|
+
} else {
|
|
1614
|
+
t1 = $[3];
|
|
1615
|
+
}
|
|
1616
|
+
return t1;
|
|
1617
|
+
}
|
|
1618
|
+
let t1;
|
|
1619
|
+
if ($[4] !== from || $[5] !== id || $[6] !== level || $[7] !== text) {
|
|
1620
|
+
t1 = /*#__PURE__*/_jsx(NoteLine, {
|
|
1621
|
+
id: id,
|
|
1622
|
+
level: level,
|
|
1623
|
+
text: text,
|
|
1624
|
+
from: from
|
|
1625
|
+
});
|
|
1626
|
+
$[4] = from;
|
|
1627
|
+
$[5] = id;
|
|
1628
|
+
$[6] = level;
|
|
1629
|
+
$[7] = text;
|
|
1630
|
+
$[8] = t1;
|
|
1631
|
+
} else {
|
|
1632
|
+
t1 = $[8];
|
|
1633
|
+
}
|
|
1634
|
+
return t1;
|
|
1635
|
+
}
|
|
1636
|
+
function NoteLine(t0) {
|
|
1476
1637
|
const $ = _c(34);
|
|
1477
1638
|
const {
|
|
1478
1639
|
id,
|
|
@@ -70,7 +70,7 @@ function AppCardRow(t0) {
|
|
|
70
70
|
}
|
|
71
71
|
/* One row of a thread, the chat's own or a subagent's read back, drawn the same way in both. */
|
|
72
72
|
export function Row(t0) {
|
|
73
|
-
const $ = _c(
|
|
73
|
+
const $ = _c(90);
|
|
74
74
|
const {
|
|
75
75
|
row,
|
|
76
76
|
chatId,
|
|
@@ -403,96 +403,98 @@ export function Row(t0) {
|
|
|
403
403
|
case "note":
|
|
404
404
|
{
|
|
405
405
|
let t1;
|
|
406
|
-
if ($[71] !== row.from || $[72] !== row.id || $[73] !== row.level || $[74] !== row.text) {
|
|
406
|
+
if ($[71] !== row.from || $[72] !== row.id || $[73] !== row.level || $[74] !== row.said || $[75] !== row.text) {
|
|
407
407
|
t1 = /*#__PURE__*/_jsx(NoteRow, {
|
|
408
408
|
id: row.id,
|
|
409
409
|
level: row.level,
|
|
410
410
|
text: row.text,
|
|
411
|
-
from: row.from
|
|
411
|
+
from: row.from,
|
|
412
|
+
said: row.said
|
|
412
413
|
});
|
|
413
414
|
$[71] = row.from;
|
|
414
415
|
$[72] = row.id;
|
|
415
416
|
$[73] = row.level;
|
|
416
|
-
$[74] = row.
|
|
417
|
-
$[75] =
|
|
417
|
+
$[74] = row.said;
|
|
418
|
+
$[75] = row.text;
|
|
419
|
+
$[76] = t1;
|
|
418
420
|
} else {
|
|
419
|
-
t1 = $[
|
|
421
|
+
t1 = $[76];
|
|
420
422
|
}
|
|
421
423
|
return t1;
|
|
422
424
|
}
|
|
423
425
|
case "message":
|
|
424
426
|
{
|
|
425
427
|
let t1;
|
|
426
|
-
if ($[
|
|
428
|
+
if ($[77] !== chatId || $[78] !== row.id || $[79] !== row.message) {
|
|
427
429
|
t1 = /*#__PURE__*/_jsx(SentMessageRow, {
|
|
428
430
|
chatId: chatId,
|
|
429
431
|
id: row.id,
|
|
430
432
|
message: row.message
|
|
431
433
|
});
|
|
432
|
-
$[
|
|
433
|
-
$[
|
|
434
|
-
$[
|
|
435
|
-
$[
|
|
434
|
+
$[77] = chatId;
|
|
435
|
+
$[78] = row.id;
|
|
436
|
+
$[79] = row.message;
|
|
437
|
+
$[80] = t1;
|
|
436
438
|
} else {
|
|
437
|
-
t1 = $[
|
|
439
|
+
t1 = $[80];
|
|
438
440
|
}
|
|
439
441
|
return t1;
|
|
440
442
|
}
|
|
441
443
|
case "compaction":
|
|
442
444
|
{
|
|
443
445
|
let t1;
|
|
444
|
-
if ($[
|
|
446
|
+
if ($[81] !== row.preTokens) {
|
|
445
447
|
t1 = /*#__PURE__*/_jsx(CompactionRow, {
|
|
446
448
|
preTokens: row.preTokens
|
|
447
449
|
});
|
|
448
|
-
$[
|
|
449
|
-
$[
|
|
450
|
+
$[81] = row.preTokens;
|
|
451
|
+
$[82] = t1;
|
|
450
452
|
} else {
|
|
451
|
-
t1 = $[
|
|
453
|
+
t1 = $[82];
|
|
452
454
|
}
|
|
453
455
|
return t1;
|
|
454
456
|
}
|
|
455
457
|
case "working":
|
|
456
458
|
{
|
|
457
459
|
let t1;
|
|
458
|
-
if ($[
|
|
460
|
+
if ($[83] !== row.startedAt) {
|
|
459
461
|
t1 = /*#__PURE__*/_jsx(WorkingRow, {
|
|
460
462
|
startedAt: row.startedAt
|
|
461
463
|
});
|
|
462
|
-
$[
|
|
463
|
-
$[
|
|
464
|
+
$[83] = row.startedAt;
|
|
465
|
+
$[84] = t1;
|
|
464
466
|
} else {
|
|
465
|
-
t1 = $[
|
|
467
|
+
t1 = $[84];
|
|
466
468
|
}
|
|
467
469
|
return t1;
|
|
468
470
|
}
|
|
469
471
|
case "app-card":
|
|
470
472
|
{
|
|
471
473
|
let t1;
|
|
472
|
-
if ($[
|
|
474
|
+
if ($[85] !== row.card) {
|
|
473
475
|
t1 = /*#__PURE__*/_jsx(AppCardRow, {
|
|
474
476
|
card: row.card
|
|
475
477
|
});
|
|
476
|
-
$[
|
|
477
|
-
$[
|
|
478
|
+
$[85] = row.card;
|
|
479
|
+
$[86] = t1;
|
|
478
480
|
} else {
|
|
479
|
-
t1 = $[
|
|
481
|
+
t1 = $[86];
|
|
480
482
|
}
|
|
481
483
|
return t1;
|
|
482
484
|
}
|
|
483
485
|
case "visual":
|
|
484
486
|
{
|
|
485
487
|
let t1;
|
|
486
|
-
if ($[
|
|
488
|
+
if ($[87] !== chatId || $[88] !== row.visual) {
|
|
487
489
|
t1 = /*#__PURE__*/_jsx(VisualRow, {
|
|
488
490
|
chatId: chatId,
|
|
489
491
|
visual: row.visual
|
|
490
492
|
});
|
|
491
|
-
$[
|
|
492
|
-
$[
|
|
493
|
-
$[
|
|
493
|
+
$[87] = chatId;
|
|
494
|
+
$[88] = row.visual;
|
|
495
|
+
$[89] = t1;
|
|
494
496
|
} else {
|
|
495
|
-
t1 = $[
|
|
497
|
+
t1 = $[89];
|
|
496
498
|
}
|
|
497
499
|
return t1;
|
|
498
500
|
}
|
package/dist/host.d.ts
CHANGED
|
@@ -328,6 +328,7 @@ export interface ChatHost {
|
|
|
328
328
|
SubagentSlot: ComponentType<SubagentSlotProps> | null;
|
|
329
329
|
useThreadCards(scopeId: string, chatId: string): readonly ThreadCard[];
|
|
330
330
|
useReplyAuthor(scopeId: string, chatId: string): ReplyAuthor | null;
|
|
331
|
+
saidBy?: ReplyAuthor;
|
|
331
332
|
visuals: VisualHost | null;
|
|
332
333
|
commandLooks?: readonly CommandLook[];
|
|
333
334
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.2",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,11 +72,11 @@
|
|
|
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.48.
|
|
76
|
-
"@adecore/editor": "0.48.
|
|
77
|
-
"@adecore/editor-react": "0.48.
|
|
78
|
-
"@adecore/intelligent-ui": "0.48.
|
|
79
|
-
"@adecore/merge": "0.48.
|
|
75
|
+
"@adecore/agent-contracts": "0.48.2",
|
|
76
|
+
"@adecore/editor": "0.48.2",
|
|
77
|
+
"@adecore/editor-react": "0.48.2",
|
|
78
|
+
"@adecore/intelligent-ui": "0.48.2",
|
|
79
|
+
"@adecore/merge": "0.48.2",
|
|
80
80
|
"@codemirror/commands": "^6.11.1",
|
|
81
81
|
"@codemirror/language": "^6.13.1",
|
|
82
82
|
"@codemirror/state": "^6.7.6",
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
"zustand": "^5.0.16"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@adecore/ui": "^0.48.
|
|
103
|
+
"@adecore/ui": "^0.48.2",
|
|
104
104
|
"i18next": "^26.4.2",
|
|
105
105
|
"react": "^19.3.0",
|
|
106
106
|
"react-dom": "^19.3.0",
|
|
107
107
|
"react-i18next": "^17.0.15"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@adecore/ui": "0.48.
|
|
110
|
+
"@adecore/ui": "0.48.2",
|
|
111
111
|
"@types/bun": "^1.4.4",
|
|
112
112
|
"@types/react": "^19.3.0",
|
|
113
113
|
"@types/react-dom": "^19.3.0",
|
|
@@ -55,7 +55,7 @@ export type TimelineRow =
|
|
|
55
55
|
| ({ kind: 'subagent' } & SubagentBranch)
|
|
56
56
|
| { kind: 'approval'; id: string; item: ChatApprovalItem }
|
|
57
57
|
| { kind: 'question'; id: string; item: ChatQuestionItem }
|
|
58
|
-
| { kind: 'note'; id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }
|
|
58
|
+
| { kind: 'note'; id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string; said?: true }
|
|
59
59
|
// A message another node sent the chat, drawn as said to it under the name of its sender.
|
|
60
60
|
| { kind: 'message'; id: string; message: ChatNoteMessage; createdAt: number }
|
|
61
61
|
| { kind: 'compaction'; id: string; preTokens: number | null }
|
|
@@ -461,7 +461,14 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
|
|
|
461
461
|
if (item.message !== undefined) {
|
|
462
462
|
rows.push({ kind: 'message', id: item.id, message: item.message, createdAt: item.createdAt });
|
|
463
463
|
} else {
|
|
464
|
-
rows.push({
|
|
464
|
+
rows.push({
|
|
465
|
+
kind: 'note',
|
|
466
|
+
id: item.id,
|
|
467
|
+
level: item.level,
|
|
468
|
+
text: item.text,
|
|
469
|
+
...(item.from === undefined ? {} : { from: item.from }),
|
|
470
|
+
...(item.said === undefined ? {} : { said: item.said })
|
|
471
|
+
});
|
|
465
472
|
}
|
|
466
473
|
|
|
467
474
|
break;
|
|
@@ -37,7 +37,9 @@ import { ROW_GUTTER } from '../icons';
|
|
|
37
37
|
import { useOpenForFind } from '../find-reveal';
|
|
38
38
|
import { ReplyContext, UiReplyNavigationContext } from '../reply-context';
|
|
39
39
|
import { UiReply } from '../intelligent-ui/UiReply';
|
|
40
|
+
import { useChatHost, type ReplyAuthor } from '../../../host';
|
|
40
41
|
import { useHostAttachmentUrl, useHostChatPlace, useHostReplyAuthor, useHostStreaming } from '../../../host-hooks';
|
|
42
|
+
import { REFERENCE_TONE, TOKEN_IN_MESSAGE } from '../chips';
|
|
41
43
|
import { copySelectionWithChips } from '../chip-clipboard';
|
|
42
44
|
import { useReferenceLookup } from '../thread-references';
|
|
43
45
|
|
|
@@ -193,31 +195,66 @@ export function UserRow({ chatId, item }: { chatId: string; item: ChatUserItem }
|
|
|
193
195
|
*/
|
|
194
196
|
export function SentMessageRow({ chatId, id, message }: { chatId: string; id: string; message: ChatNoteMessage }) {
|
|
195
197
|
const { t } = useTranslation('agent-chat');
|
|
196
|
-
const [open, setOpen] = useState(false);
|
|
197
|
-
const long = message.text.split('\n').length > USER_FOLD_LINES || message.text.length > USER_FOLD_CHARS;
|
|
198
198
|
const lookup = useReferenceLookup(chatId);
|
|
199
|
-
useOpenForFind(id, 'text', setOpen);
|
|
200
199
|
|
|
201
200
|
return (
|
|
202
201
|
<ReferenceLookupContext value={lookup}>
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
202
|
+
<SaidMessage
|
|
203
|
+
id={id}
|
|
204
|
+
name={message.title || t('rows.message.unnamed')}
|
|
205
|
+
chip={<ReferenceChip id={message.from} lastName={message.title} />}
|
|
206
|
+
text={message.text}
|
|
207
|
+
/>
|
|
208
|
+
</ReferenceLookupContext>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* What the host told the agent in front of a prompt, said under the host's own name, which the text no longer has to lead with. */
|
|
213
|
+
function HostSaidRow({ id, text, author }: { id: string; text: string; author: ReplyAuthor }) {
|
|
214
|
+
const prefix = `${author.name}: `;
|
|
215
|
+
const words = text
|
|
216
|
+
.split('\n\n')
|
|
217
|
+
.map((part) => (part.startsWith(prefix) ? part.slice(prefix.length) : part))
|
|
218
|
+
.join('\n\n');
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<SaidMessage
|
|
222
|
+
id={id}
|
|
223
|
+
name={author.name}
|
|
224
|
+
chip={
|
|
225
|
+
<span className={clsx(TOKEN_IN_MESSAGE, REFERENCE_TONE, 'inline-flex items-center gap-1')}>
|
|
226
|
+
{author.mark}
|
|
227
|
+
{author.name}
|
|
228
|
+
</span>
|
|
229
|
+
}
|
|
230
|
+
text={words}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* A message the person did not write: a bubble on the left, quieter than theirs, under a chip of who said it. A long one folds. */
|
|
236
|
+
function SaidMessage({ id, name, chip, text }: { id: string; name: string; chip: ReactNode; text: string }) {
|
|
237
|
+
const { t } = useTranslation('agent-chat');
|
|
238
|
+
const [open, setOpen] = useState(false);
|
|
239
|
+
const long = text.split('\n').length > USER_FOLD_LINES || text.length > USER_FOLD_CHARS;
|
|
240
|
+
useOpenForFind(id, 'text', setOpen);
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<div data-find-item={id} className="flex flex-col items-start">
|
|
244
|
+
<MessageHeading>{t('rows.message.heading', { name })}</MessageHeading>
|
|
245
|
+
<div className="mb-1.5 flex max-w-[80%]">{chip}</div>
|
|
246
|
+
<div className="relative max-w-[80%] rounded-2xl bg-surface-hover px-3.5 py-2.5 text-sm wrap-anywhere text-text select-text">
|
|
247
|
+
<div data-find-field="text" className={clsx(long && !open && FOLD)}>
|
|
248
|
+
<MessageMarkdown text={text} />
|
|
218
249
|
</div>
|
|
250
|
+
{long && (
|
|
251
|
+
<button className="mt-1 flex items-center gap-1 text-xs text-text-muted hover:text-text" onClick={() => setOpen((o) => !o)}>
|
|
252
|
+
<Icon icon={ChevronDown} size={12} className={clsx('transition-transform', open && 'rotate-180')} />{' '}
|
|
253
|
+
{open ? t('rows.user.showLess') : t('rows.user.showAll')}
|
|
254
|
+
</button>
|
|
255
|
+
)}
|
|
219
256
|
</div>
|
|
220
|
-
</
|
|
257
|
+
</div>
|
|
221
258
|
);
|
|
222
259
|
}
|
|
223
260
|
|
|
@@ -492,7 +529,17 @@ const NOTE_ICON = {
|
|
|
492
529
|
* A line from the machine in the thread. A note of more than one line (a summary a fork sent back)
|
|
493
530
|
* shows its first line and folds the rest open as markdown; one that came from a fork leads to it.
|
|
494
531
|
*/
|
|
495
|
-
export function NoteRow({ id, level, text, from }: { id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }) {
|
|
532
|
+
export function NoteRow({ id, level, text, from, said }: { id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string; said?: true }) {
|
|
533
|
+
const { saidBy } = useChatHost();
|
|
534
|
+
|
|
535
|
+
if (said && saidBy !== undefined) {
|
|
536
|
+
return <HostSaidRow id={id} text={text} author={saidBy} />;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return <NoteLine id={id} level={level} text={text} from={from} />;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function NoteLine({ id, level, text, from }: { id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }) {
|
|
496
543
|
const { t } = useTranslation('agent-chat');
|
|
497
544
|
const [open, setOpen] = useState(false);
|
|
498
545
|
const breakAt = text.indexOf('\n');
|
|
@@ -108,7 +108,7 @@ export function Row({ row, chatId, toggleGroup, toggleTurn, toggleSubagent, open
|
|
|
108
108
|
case 'question':
|
|
109
109
|
return <QuestionHistoryRow item={row.item} />;
|
|
110
110
|
case 'note':
|
|
111
|
-
return <NoteRow id={row.id} level={row.level} text={row.text} from={row.from} />;
|
|
111
|
+
return <NoteRow id={row.id} level={row.level} text={row.text} from={row.from} said={row.said} />;
|
|
112
112
|
case 'message':
|
|
113
113
|
return <SentMessageRow chatId={chatId} id={row.id} message={row.message} />;
|
|
114
114
|
case 'compaction':
|
package/src/host.ts
CHANGED
|
@@ -522,6 +522,8 @@ export interface ChatHost {
|
|
|
522
522
|
useThreadCards(scopeId: string, chatId: string): readonly ThreadCard[];
|
|
523
523
|
/* A header over every reply with its author and how long ago it began; null names the agent for a screen reader only. */
|
|
524
524
|
useReplyAuthor(scopeId: string, chatId: string): ReplyAuthor | null;
|
|
525
|
+
/* Who speaks in what the host told the agent in front of a prompt, drawn as a message under its name; left out, that stays a note. */
|
|
526
|
+
saidBy?: ReplyAuthor;
|
|
525
527
|
/* The pages agents publish, drawn in the thread above their reply; null draws none. */
|
|
526
528
|
visuals: VisualHost | null;
|
|
527
529
|
/* Programs drawn as tools of their own; left out, every shell call reads as itself. */
|