@adecore/agents-react 0.48.4 → 0.49.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/logic/timeline.d.ts +1 -0
- package/dist/chat/logic/timeline.js +5 -1
- package/dist/chat/ui/Markdown.js +26 -24
- package/dist/chat/ui/markdown-blocks.d.ts +1 -0
- package/dist/chat/ui/markdown-blocks.js +66 -5
- package/dist/chat/ui/rows/Rows.js +28 -16
- package/dist/chat/ui/rows/WorkRows.d.ts +2 -1
- package/dist/chat/ui/rows/WorkRows.js +148 -99
- package/package.json +8 -8
- package/src/chat/logic/timeline.ts +4 -2
- package/src/chat/ui/Markdown.tsx +4 -3
- package/src/chat/ui/markdown-blocks.ts +97 -2
- package/src/chat/ui/rows/Rows.tsx +1 -1
- package/src/chat/ui/rows/WorkRows.tsx +17 -5
|
@@ -569,10 +569,14 @@ export function deriveTimelineRows(items, options) {
|
|
|
569
569
|
const live = shownRows(rowsForItems(conversation, options, children), options);
|
|
570
570
|
rows.push(...(active ? withLiveThought(live, conversation) : live));
|
|
571
571
|
if (active) {
|
|
572
|
+
const tool = conversation.findLast(item => item.kind === 'tool' && item.state === 'running' && parentOf(item) === null);
|
|
572
573
|
rows.push({
|
|
573
574
|
kind: 'working',
|
|
574
575
|
id: `working-${turnId}`,
|
|
575
|
-
startedAt: turn?.createdAt ?? Date.now()
|
|
576
|
+
startedAt: turn?.createdAt ?? Date.now(),
|
|
577
|
+
...(tool === undefined ? {} : {
|
|
578
|
+
tool
|
|
579
|
+
})
|
|
576
580
|
});
|
|
577
581
|
}
|
|
578
582
|
continue;
|
package/dist/chat/ui/Markdown.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import { createContext, memo, useContext } from 'react';
|
|
2
|
+
import { createContext, memo, useContext, useState } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { Zap } from 'lucide-react';
|
|
5
5
|
import ReactMarkdown from 'react-markdown';
|
|
@@ -9,7 +9,7 @@ import { MENTION_TONE, SKILL_TONE, TOKEN_ICON } from './chips.js';
|
|
|
9
9
|
import { CodeBlock } from './CodeBlock.js';
|
|
10
10
|
import { MermaidBlock } from './MermaidBlock.js';
|
|
11
11
|
import { CodeStreamingContext } from './code-streaming.js';
|
|
12
|
-
import {
|
|
12
|
+
import { createMarkdownBlockSplitter } from './markdown-blocks.js';
|
|
13
13
|
import { ReferenceChip, TokenChip } from './ReferenceChip.js';
|
|
14
14
|
import { ReferenceLookupContext } from './reference-lookup.js';
|
|
15
15
|
import { rehypeChips, rehypeNamedReferences } from './rehype-chips.js';
|
|
@@ -1025,7 +1025,7 @@ const ReplyFence = memo(function ReplyFence(t0) {
|
|
|
1025
1025
|
* as it is added instead, for a reply that is shown a block at a time.
|
|
1026
1026
|
*/
|
|
1027
1027
|
export const ReplyMarkdown = memo(function ReplyMarkdown(t0) {
|
|
1028
|
-
const $ = _c(
|
|
1028
|
+
const $ = _c(15);
|
|
1029
1029
|
const {
|
|
1030
1030
|
text,
|
|
1031
1031
|
streaming,
|
|
@@ -1033,15 +1033,16 @@ export const ReplyMarkdown = memo(function ReplyMarkdown(t0) {
|
|
|
1033
1033
|
reply
|
|
1034
1034
|
} = t0;
|
|
1035
1035
|
const arriving = t1 === undefined ? false : t1;
|
|
1036
|
+
const [split] = useState(createMarkdownBlockSplitter);
|
|
1036
1037
|
let t2;
|
|
1037
1038
|
let t3;
|
|
1038
1039
|
let t4;
|
|
1039
|
-
if ($[0] !== arriving || $[1] !== reply || $[2] !==
|
|
1040
|
-
const blocks =
|
|
1040
|
+
if ($[0] !== arriving || $[1] !== reply || $[2] !== split || $[3] !== streaming || $[4] !== text) {
|
|
1041
|
+
const blocks = split(text);
|
|
1041
1042
|
t2 = "chat-markdown prose prose-sm max-w-none text-sm";
|
|
1042
1043
|
t3 = arriving || undefined;
|
|
1043
1044
|
let t5;
|
|
1044
|
-
if ($[
|
|
1045
|
+
if ($[8] !== reply || $[9] !== streaming) {
|
|
1045
1046
|
t5 = (block, index) => block.fence !== undefined ? /*#__PURE__*/_jsx(ReplyFence, {
|
|
1046
1047
|
info: block.fence.info,
|
|
1047
1048
|
body: block.fence.body,
|
|
@@ -1054,38 +1055,39 @@ export const ReplyMarkdown = memo(function ReplyMarkdown(t0) {
|
|
|
1054
1055
|
open: streaming && block.openFence,
|
|
1055
1056
|
reply: reply
|
|
1056
1057
|
}, index);
|
|
1057
|
-
$[
|
|
1058
|
-
$[
|
|
1059
|
-
$[
|
|
1058
|
+
$[8] = reply;
|
|
1059
|
+
$[9] = streaming;
|
|
1060
|
+
$[10] = t5;
|
|
1060
1061
|
} else {
|
|
1061
|
-
t5 = $[
|
|
1062
|
+
t5 = $[10];
|
|
1062
1063
|
}
|
|
1063
1064
|
t4 = blocks.map(t5);
|
|
1064
1065
|
$[0] = arriving;
|
|
1065
1066
|
$[1] = reply;
|
|
1066
|
-
$[2] =
|
|
1067
|
-
$[3] =
|
|
1068
|
-
$[4] =
|
|
1069
|
-
$[5] =
|
|
1070
|
-
$[6] =
|
|
1067
|
+
$[2] = split;
|
|
1068
|
+
$[3] = streaming;
|
|
1069
|
+
$[4] = text;
|
|
1070
|
+
$[5] = t2;
|
|
1071
|
+
$[6] = t3;
|
|
1072
|
+
$[7] = t4;
|
|
1071
1073
|
} else {
|
|
1072
|
-
t2 = $[
|
|
1073
|
-
t3 = $[
|
|
1074
|
-
t4 = $[
|
|
1074
|
+
t2 = $[5];
|
|
1075
|
+
t3 = $[6];
|
|
1076
|
+
t4 = $[7];
|
|
1075
1077
|
}
|
|
1076
1078
|
let t5;
|
|
1077
|
-
if ($[
|
|
1079
|
+
if ($[11] !== t2 || $[12] !== t3 || $[13] !== t4) {
|
|
1078
1080
|
t5 = /*#__PURE__*/_jsx("div", {
|
|
1079
1081
|
className: t2,
|
|
1080
1082
|
"data-arriving": t3,
|
|
1081
1083
|
children: t4
|
|
1082
1084
|
});
|
|
1083
|
-
$[
|
|
1084
|
-
$[
|
|
1085
|
-
$[
|
|
1086
|
-
$[
|
|
1085
|
+
$[11] = t2;
|
|
1086
|
+
$[12] = t3;
|
|
1087
|
+
$[13] = t4;
|
|
1088
|
+
$[14] = t5;
|
|
1087
1089
|
} else {
|
|
1088
|
-
t5 = $[
|
|
1090
|
+
t5 = $[14];
|
|
1089
1091
|
}
|
|
1090
1092
|
return t5;
|
|
1091
1093
|
});
|
|
@@ -11,4 +11,5 @@ export interface MarkdownFence {
|
|
|
11
11
|
source: string;
|
|
12
12
|
}
|
|
13
13
|
export declare function splitMarkdownBlocks(text: string): MarkdownBlock[];
|
|
14
|
+
export declare function createMarkdownBlockSplitter(): (text: string) => readonly MarkdownBlock[];
|
|
14
15
|
export declare function settledBlocksText(text: string): string;
|
|
@@ -33,11 +33,50 @@ const BOLD_LINE = /^ {0,3}\*\*(?:[^*]|\*(?!\*))+\*\*:?[ \t]*$/;
|
|
|
33
33
|
* Joined back together the blocks are the text.
|
|
34
34
|
*/
|
|
35
35
|
export function splitMarkdownBlocks(text) {
|
|
36
|
+
return scanMarkdownBlocks(text).blocks;
|
|
37
|
+
}
|
|
38
|
+
/* The source may be replaced as well as appended; only cuts with a complete, independent context line can survive an append. */
|
|
39
|
+
export function createMarkdownBlockSplitter() {
|
|
40
|
+
let previous = null;
|
|
41
|
+
let offset = 0;
|
|
42
|
+
let retained = [];
|
|
43
|
+
let result = [];
|
|
44
|
+
return text => {
|
|
45
|
+
if (text === previous) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
if (previous === null || !text.startsWith(previous)) {
|
|
49
|
+
offset = 0;
|
|
50
|
+
retained = [];
|
|
51
|
+
}
|
|
52
|
+
let scan = scanMarkdownBlocks(text.slice(offset), true);
|
|
53
|
+
// The existing definition guard can match a label that starts before the checkpoint.
|
|
54
|
+
if (offset > 0 && (scan.whole || DEFINITION.test(text))) {
|
|
55
|
+
offset = 0;
|
|
56
|
+
retained = [];
|
|
57
|
+
scan = scanMarkdownBlocks(text, true);
|
|
58
|
+
}
|
|
59
|
+
result = [...retained, ...scan.blocks];
|
|
60
|
+
if (scan.checkpoint !== null) {
|
|
61
|
+
// Retained substrings must not deliberately keep whole earlier reply versions alive.
|
|
62
|
+
const settled = scan.blocks.slice(0, scan.checkpoint.count).map(block => structuredClone(block));
|
|
63
|
+
retained = [...retained, ...settled];
|
|
64
|
+
offset += scan.checkpoint.offset;
|
|
65
|
+
}
|
|
66
|
+
previous = text;
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function scanMarkdownBlocks(text, checkpoints = false) {
|
|
36
71
|
if (DEFINITION.test(text) || LONE_RETURN.test(text)) {
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
72
|
+
return {
|
|
73
|
+
blocks: [{
|
|
74
|
+
text,
|
|
75
|
+
openFence: isFenceOpenAtEnd(text)
|
|
76
|
+
}],
|
|
77
|
+
checkpoint: null,
|
|
78
|
+
whole: true
|
|
79
|
+
};
|
|
41
80
|
}
|
|
42
81
|
const lines = text.split('\n');
|
|
43
82
|
const blocks = [];
|
|
@@ -61,6 +100,19 @@ export function splitMarkdownBlocks(text) {
|
|
|
61
100
|
let known = true;
|
|
62
101
|
// Where the line above starts when it is blank.
|
|
63
102
|
let blankAbove = null;
|
|
103
|
+
let completeLine = false;
|
|
104
|
+
let independentLine = false;
|
|
105
|
+
let lineStart = 0;
|
|
106
|
+
let checkpoint = null;
|
|
107
|
+
const remember = end => {
|
|
108
|
+
if (!checkpoints || !completeLine || !independentLine || end !== lineStart || !known || lineFence !== null || fence !== null || top !== null || closed !== null || item !== null || html !== null) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
checkpoint = {
|
|
112
|
+
offset: end,
|
|
113
|
+
count: blocks.length
|
|
114
|
+
};
|
|
115
|
+
};
|
|
64
116
|
const cutAt = end => {
|
|
65
117
|
if (end > start) {
|
|
66
118
|
blocks.push({
|
|
@@ -69,9 +121,13 @@ export function splitMarkdownBlocks(text) {
|
|
|
69
121
|
});
|
|
70
122
|
}
|
|
71
123
|
start = end;
|
|
124
|
+
remember(end);
|
|
72
125
|
};
|
|
73
126
|
for (const [index, line] of lines.entries()) {
|
|
74
127
|
const at = offset;
|
|
128
|
+
lineStart = at;
|
|
129
|
+
completeLine = index < lines.length - 1;
|
|
130
|
+
independentLine = checkpoints && completeLine && index > 0 && known && lineFence === null && fence === null && top === null && item === null && html === null && BLANK.test(withoutReturn(lines[index - 1]));
|
|
75
131
|
offset += line.length + 1;
|
|
76
132
|
const content = withoutReturn(line);
|
|
77
133
|
const blank = BLANK.test(line);
|
|
@@ -101,6 +157,7 @@ export function splitMarkdownBlocks(text) {
|
|
|
101
157
|
blocks.push(fenceBlock(text.slice(start, at), closed.fence, closed.source, true));
|
|
102
158
|
start = at;
|
|
103
159
|
closed = null;
|
|
160
|
+
remember(at);
|
|
104
161
|
}
|
|
105
162
|
if (html !== null) {
|
|
106
163
|
// Raw HTML holds no fence and no blank line to cut at until its marker.
|
|
@@ -180,7 +237,11 @@ export function splitMarkdownBlocks(text) {
|
|
|
180
237
|
openFence: (known ? fence : lineFence) !== null
|
|
181
238
|
});
|
|
182
239
|
}
|
|
183
|
-
return
|
|
240
|
+
return {
|
|
241
|
+
blocks,
|
|
242
|
+
checkpoint,
|
|
243
|
+
whole: false
|
|
244
|
+
};
|
|
184
245
|
}
|
|
185
246
|
/*
|
|
186
247
|
* The blocks of a reply still being written that will not change any more: every block but the last.
|
|
@@ -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(93);
|
|
74
74
|
const {
|
|
75
75
|
row,
|
|
76
76
|
chatId,
|
|
@@ -457,44 +457,56 @@ export function Row(t0) {
|
|
|
457
457
|
case "working":
|
|
458
458
|
{
|
|
459
459
|
let t1;
|
|
460
|
-
if ($[83] !== row.
|
|
461
|
-
t1 =
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
$[83] = row.
|
|
460
|
+
if ($[83] !== row.tool) {
|
|
461
|
+
t1 = row.tool === undefined ? {} : {
|
|
462
|
+
tool: row.tool
|
|
463
|
+
};
|
|
464
|
+
$[83] = row.tool;
|
|
465
465
|
$[84] = t1;
|
|
466
466
|
} else {
|
|
467
467
|
t1 = $[84];
|
|
468
468
|
}
|
|
469
|
-
|
|
469
|
+
let t2;
|
|
470
|
+
if ($[85] !== row.startedAt || $[86] !== t1) {
|
|
471
|
+
t2 = /*#__PURE__*/_jsx(WorkingRow, {
|
|
472
|
+
startedAt: row.startedAt,
|
|
473
|
+
...t1
|
|
474
|
+
});
|
|
475
|
+
$[85] = row.startedAt;
|
|
476
|
+
$[86] = t1;
|
|
477
|
+
$[87] = t2;
|
|
478
|
+
} else {
|
|
479
|
+
t2 = $[87];
|
|
480
|
+
}
|
|
481
|
+
return t2;
|
|
470
482
|
}
|
|
471
483
|
case "app-card":
|
|
472
484
|
{
|
|
473
485
|
let t1;
|
|
474
|
-
if ($[
|
|
486
|
+
if ($[88] !== row.card) {
|
|
475
487
|
t1 = /*#__PURE__*/_jsx(AppCardRow, {
|
|
476
488
|
card: row.card
|
|
477
489
|
});
|
|
478
|
-
$[
|
|
479
|
-
$[
|
|
490
|
+
$[88] = row.card;
|
|
491
|
+
$[89] = t1;
|
|
480
492
|
} else {
|
|
481
|
-
t1 = $[
|
|
493
|
+
t1 = $[89];
|
|
482
494
|
}
|
|
483
495
|
return t1;
|
|
484
496
|
}
|
|
485
497
|
case "visual":
|
|
486
498
|
{
|
|
487
499
|
let t1;
|
|
488
|
-
if ($[
|
|
500
|
+
if ($[90] !== chatId || $[91] !== row.visual) {
|
|
489
501
|
t1 = /*#__PURE__*/_jsx(VisualRow, {
|
|
490
502
|
chatId: chatId,
|
|
491
503
|
visual: row.visual
|
|
492
504
|
});
|
|
493
|
-
$[
|
|
494
|
-
$[
|
|
495
|
-
$[
|
|
505
|
+
$[90] = chatId;
|
|
506
|
+
$[91] = row.visual;
|
|
507
|
+
$[92] = t1;
|
|
496
508
|
} else {
|
|
497
|
-
t1 = $[
|
|
509
|
+
t1 = $[92];
|
|
498
510
|
}
|
|
499
511
|
return t1;
|
|
500
512
|
}
|
|
@@ -66,6 +66,7 @@ export declare function ChangedFilesRow({ tools, diff, checkpoint, baseMoved, ch
|
|
|
66
66
|
turnId: string;
|
|
67
67
|
heldBack?: boolean;
|
|
68
68
|
}): import("react").JSX.Element;
|
|
69
|
-
export declare function WorkingRow({ startedAt }: {
|
|
69
|
+
export declare function WorkingRow({ startedAt, tool }: {
|
|
70
70
|
startedAt: number;
|
|
71
|
+
tool?: ChatToolItem;
|
|
71
72
|
}): import("react").JSX.Element;
|
|
@@ -1310,6 +1310,14 @@ export function RunningFor(t0) {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
return t2;
|
|
1312
1312
|
}
|
|
1313
|
+
/* The mark of one call: the look its shell command runs under, else what the tool is about. */
|
|
1314
|
+
function callIcon(tool, commandLooks) {
|
|
1315
|
+
const shell = shellCommand(tool.name, tool.input);
|
|
1316
|
+
const run = shell === null ? null : matchCommandLook(shell, commandLooks);
|
|
1317
|
+
return run === null ? toolIcon(tool.name) : /*#__PURE__*/_jsx(run.look.Mark, {
|
|
1318
|
+
size: 12
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1313
1321
|
/* A call still running: its timer on the line, and for a provider that streams output, the last lines under it. */
|
|
1314
1322
|
export function WorkLiveRow(t0) {
|
|
1315
1323
|
const $ = _c(50);
|
|
@@ -1503,7 +1511,7 @@ function _temp3(o) {
|
|
|
1503
1511
|
return !o;
|
|
1504
1512
|
}
|
|
1505
1513
|
export function WorkGroupRow(t0) {
|
|
1506
|
-
const $ = _c(
|
|
1514
|
+
const $ = _c(31);
|
|
1507
1515
|
const {
|
|
1508
1516
|
tools,
|
|
1509
1517
|
summary,
|
|
@@ -1514,6 +1522,9 @@ export function WorkGroupRow(t0) {
|
|
|
1514
1522
|
const {
|
|
1515
1523
|
t
|
|
1516
1524
|
} = useTranslation("agent-chat");
|
|
1525
|
+
const {
|
|
1526
|
+
commandLooks
|
|
1527
|
+
} = useChatHost();
|
|
1517
1528
|
let t1;
|
|
1518
1529
|
if ($[0] !== tools) {
|
|
1519
1530
|
t1 = tools.filter(_temp4);
|
|
@@ -1532,89 +1543,102 @@ export function WorkGroupRow(t0) {
|
|
|
1532
1543
|
t2 = $[3];
|
|
1533
1544
|
}
|
|
1534
1545
|
const failed = t2;
|
|
1546
|
+
let T0;
|
|
1547
|
+
let latest;
|
|
1535
1548
|
let t3;
|
|
1536
|
-
if ($[4] !==
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1549
|
+
if ($[4] !== commandLooks || $[5] !== look || $[6] !== tools) {
|
|
1550
|
+
latest = tools.findLast(_temp6);
|
|
1551
|
+
T0 = ToggleLine;
|
|
1552
|
+
t3 = latest !== undefined ? callIcon(latest, commandLooks) : look === undefined ? toolIcon(tools[0].name) : /*#__PURE__*/_jsx(look.Mark, {
|
|
1540
1553
|
size: 12
|
|
1541
1554
|
});
|
|
1542
|
-
$[4] =
|
|
1543
|
-
$[5] =
|
|
1544
|
-
$[6] = tools
|
|
1545
|
-
$[7] =
|
|
1555
|
+
$[4] = commandLooks;
|
|
1556
|
+
$[5] = look;
|
|
1557
|
+
$[6] = tools;
|
|
1558
|
+
$[7] = T0;
|
|
1559
|
+
$[8] = latest;
|
|
1560
|
+
$[9] = t3;
|
|
1546
1561
|
} else {
|
|
1547
|
-
|
|
1562
|
+
T0 = $[7];
|
|
1563
|
+
latest = $[8];
|
|
1564
|
+
t3 = $[9];
|
|
1548
1565
|
}
|
|
1549
1566
|
let t4;
|
|
1550
|
-
if ($[
|
|
1567
|
+
if ($[10] !== look || $[11] !== running || $[12] !== summary || $[13] !== t || $[14] !== tools.length) {
|
|
1551
1568
|
t4 = running > 0 ? t("group.toolCalls", {
|
|
1552
1569
|
count: tools.length
|
|
1553
1570
|
}) : look?.brand === undefined ? summary : withBrand(summary, [look.brand]);
|
|
1554
|
-
$[
|
|
1555
|
-
$[
|
|
1556
|
-
$[
|
|
1557
|
-
$[
|
|
1558
|
-
$[
|
|
1559
|
-
$[
|
|
1571
|
+
$[10] = look;
|
|
1572
|
+
$[11] = running;
|
|
1573
|
+
$[12] = summary;
|
|
1574
|
+
$[13] = t;
|
|
1575
|
+
$[14] = tools.length;
|
|
1576
|
+
$[15] = t4;
|
|
1560
1577
|
} else {
|
|
1561
|
-
t4 = $[
|
|
1578
|
+
t4 = $[15];
|
|
1562
1579
|
}
|
|
1563
1580
|
let t5;
|
|
1564
|
-
if ($[
|
|
1581
|
+
if ($[16] !== t4) {
|
|
1565
1582
|
t5 = /*#__PURE__*/_jsx("span", {
|
|
1566
1583
|
className: "tabular-nums",
|
|
1567
1584
|
children: t4
|
|
1568
1585
|
});
|
|
1569
|
-
$[
|
|
1570
|
-
$[
|
|
1586
|
+
$[16] = t4;
|
|
1587
|
+
$[17] = t5;
|
|
1571
1588
|
} else {
|
|
1572
|
-
t5 = $[
|
|
1589
|
+
t5 = $[17];
|
|
1573
1590
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1591
|
+
const t6 = latest !== undefined;
|
|
1592
|
+
let t7;
|
|
1593
|
+
if ($[18] !== running || $[19] !== t) {
|
|
1594
|
+
t7 = running > 0 && /*#__PURE__*/_jsx("span", {
|
|
1577
1595
|
className: "shrink-0 text-text-faint tabular-nums",
|
|
1578
1596
|
children: t("group.running", {
|
|
1579
1597
|
count: running
|
|
1580
1598
|
})
|
|
1581
1599
|
});
|
|
1582
|
-
$[
|
|
1583
|
-
$[
|
|
1584
|
-
$[
|
|
1600
|
+
$[18] = running;
|
|
1601
|
+
$[19] = t;
|
|
1602
|
+
$[20] = t7;
|
|
1585
1603
|
} else {
|
|
1586
|
-
|
|
1604
|
+
t7 = $[20];
|
|
1587
1605
|
}
|
|
1588
|
-
let
|
|
1589
|
-
if ($[
|
|
1590
|
-
|
|
1591
|
-
children: /*#__PURE__*/_jsx(
|
|
1606
|
+
let t8;
|
|
1607
|
+
if ($[21] !== T0 || $[22] !== expanded || $[23] !== failed || $[24] !== onToggle || $[25] !== t3 || $[26] !== t5 || $[27] !== t6 || $[28] !== t7 || $[29] !== tools[0].createdAt) {
|
|
1608
|
+
t8 = /*#__PURE__*/_jsx("div", {
|
|
1609
|
+
children: /*#__PURE__*/_jsx(T0, {
|
|
1592
1610
|
icon: t3,
|
|
1593
1611
|
label: t5,
|
|
1594
1612
|
open: expanded,
|
|
1595
1613
|
onToggle: onToggle,
|
|
1596
1614
|
failed: failed,
|
|
1597
|
-
|
|
1615
|
+
live: t6,
|
|
1616
|
+
trailing: t7,
|
|
1598
1617
|
time: tools[0].createdAt
|
|
1599
1618
|
})
|
|
1600
1619
|
});
|
|
1601
|
-
$[
|
|
1602
|
-
$[
|
|
1603
|
-
$[
|
|
1604
|
-
$[
|
|
1605
|
-
$[
|
|
1606
|
-
$[
|
|
1607
|
-
$[
|
|
1608
|
-
$[
|
|
1620
|
+
$[21] = T0;
|
|
1621
|
+
$[22] = expanded;
|
|
1622
|
+
$[23] = failed;
|
|
1623
|
+
$[24] = onToggle;
|
|
1624
|
+
$[25] = t3;
|
|
1625
|
+
$[26] = t5;
|
|
1626
|
+
$[27] = t6;
|
|
1627
|
+
$[28] = t7;
|
|
1628
|
+
$[29] = tools[0].createdAt;
|
|
1629
|
+
$[30] = t8;
|
|
1609
1630
|
} else {
|
|
1610
|
-
|
|
1631
|
+
t8 = $[30];
|
|
1611
1632
|
}
|
|
1612
|
-
return
|
|
1633
|
+
return t8;
|
|
1613
1634
|
}
|
|
1614
1635
|
/*
|
|
1615
1636
|
* A settled turn folded behind how long it took and what it did. A line and not a button, like the
|
|
1616
1637
|
* tool lines it hides; the work reads fainter than the time so the eye lands on the time first.
|
|
1617
1638
|
*/
|
|
1639
|
+
function _temp6(tool_1) {
|
|
1640
|
+
return tool_1.state === "running";
|
|
1641
|
+
}
|
|
1618
1642
|
function _temp5(tool_0) {
|
|
1619
1643
|
return tool_0.state === "error";
|
|
1620
1644
|
}
|
|
@@ -1639,7 +1663,7 @@ export function TurnFoldRow(t0) {
|
|
|
1639
1663
|
let t2;
|
|
1640
1664
|
let t3;
|
|
1641
1665
|
if ($[0] !== commandLooks || $[1] !== expandable || $[2] !== expanded || $[3] !== label || $[4] !== turn.state || $[5] !== work) {
|
|
1642
|
-
const brands = commandLooks?.flatMap(
|
|
1666
|
+
const brands = commandLooks?.flatMap(_temp7) ?? [];
|
|
1643
1667
|
const t4 = expandable && "hover:bg-surface-hover";
|
|
1644
1668
|
const t5 = turn.state === "error" && "text-status-error";
|
|
1645
1669
|
let t6;
|
|
@@ -1783,7 +1807,7 @@ export function TurnFoldRow(t0) {
|
|
|
1783
1807
|
}
|
|
1784
1808
|
return t7;
|
|
1785
1809
|
}
|
|
1786
|
-
function
|
|
1810
|
+
function _temp7(t0) {
|
|
1787
1811
|
const {
|
|
1788
1812
|
brand
|
|
1789
1813
|
} = t0;
|
|
@@ -1899,7 +1923,7 @@ function ChangedFilesCard(t0) {
|
|
|
1899
1923
|
let t2;
|
|
1900
1924
|
let t3;
|
|
1901
1925
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1902
|
-
t2 = () => setExpanded(
|
|
1926
|
+
t2 = () => setExpanded(_temp8);
|
|
1903
1927
|
t3 = /*#__PURE__*/_jsx(Icon, {
|
|
1904
1928
|
icon: FileDiff,
|
|
1905
1929
|
size: 12,
|
|
@@ -2056,7 +2080,7 @@ function ChangedFilesCard(t0) {
|
|
|
2056
2080
|
* checkpoint but no stored diff asks the host for one, which is also how a running turn gets it.
|
|
2057
2081
|
* A diff the thread keeps only the first files of (`heldBack`) asks for the whole when a person does.
|
|
2058
2082
|
*/
|
|
2059
|
-
function
|
|
2083
|
+
function _temp8(value) {
|
|
2060
2084
|
return !value;
|
|
2061
2085
|
}
|
|
2062
2086
|
export function ChangedFilesRow(t0) {
|
|
@@ -2106,7 +2130,7 @@ export function ChangedFilesRow(t0) {
|
|
|
2106
2130
|
if (alive) {
|
|
2107
2131
|
setFetched(answer);
|
|
2108
2132
|
}
|
|
2109
|
-
}).catch(
|
|
2133
|
+
}).catch(_temp9);
|
|
2110
2134
|
return () => {
|
|
2111
2135
|
alive = false;
|
|
2112
2136
|
};
|
|
@@ -2128,7 +2152,7 @@ export function ChangedFilesRow(t0) {
|
|
|
2128
2152
|
const {
|
|
2129
2153
|
keyOf
|
|
2130
2154
|
} = useChatScope();
|
|
2131
|
-
const flash = useTimelineFlash(
|
|
2155
|
+
const flash = useTimelineFlash(_temp0);
|
|
2132
2156
|
let t6;
|
|
2133
2157
|
if ($[13] !== chatId || $[14] !== flash || $[15] !== keyOf || $[16] !== turnId) {
|
|
2134
2158
|
t6 = flash !== null && flash.opens && flash.key === keyOf(chatId) && flash.rowId === `files-${turnId}` ? flash.nonce : 0;
|
|
@@ -2147,7 +2171,7 @@ export function ChangedFilesRow(t0) {
|
|
|
2147
2171
|
const t8 = checkpointDiff.truncated;
|
|
2148
2172
|
let t9;
|
|
2149
2173
|
if ($[18] !== files) {
|
|
2150
|
-
t9 = files.reduce(
|
|
2174
|
+
t9 = files.reduce(_temp1, 0);
|
|
2151
2175
|
$[18] = files;
|
|
2152
2176
|
$[19] = t9;
|
|
2153
2177
|
} else {
|
|
@@ -2155,7 +2179,7 @@ export function ChangedFilesRow(t0) {
|
|
|
2155
2179
|
}
|
|
2156
2180
|
let t10;
|
|
2157
2181
|
if ($[20] !== files) {
|
|
2158
|
-
t10 = files.reduce(
|
|
2182
|
+
t10 = files.reduce(_temp10, 0);
|
|
2159
2183
|
$[20] = files;
|
|
2160
2184
|
$[21] = t10;
|
|
2161
2185
|
} else {
|
|
@@ -2245,16 +2269,16 @@ export function ChangedFilesRow(t0) {
|
|
|
2245
2269
|
}
|
|
2246
2270
|
return t7;
|
|
2247
2271
|
}
|
|
2248
|
-
function
|
|
2272
|
+
function _temp10(sum_0, file_0) {
|
|
2249
2273
|
return sum_0 + file_0.deleted;
|
|
2250
2274
|
}
|
|
2251
|
-
function
|
|
2275
|
+
function _temp1(sum, file) {
|
|
2252
2276
|
return sum + file.added;
|
|
2253
2277
|
}
|
|
2254
|
-
function
|
|
2278
|
+
function _temp0(s) {
|
|
2255
2279
|
return s.target;
|
|
2256
2280
|
}
|
|
2257
|
-
function
|
|
2281
|
+
function _temp9() {}
|
|
2258
2282
|
function ProviderReviewFiles(t0) {
|
|
2259
2283
|
const $ = _c(16);
|
|
2260
2284
|
const {
|
|
@@ -2280,7 +2304,7 @@ function ProviderReviewFiles(t0) {
|
|
|
2280
2304
|
} else {
|
|
2281
2305
|
t2 = $[4];
|
|
2282
2306
|
}
|
|
2283
|
-
t1 = reviews.filter(t2).flatMap(
|
|
2307
|
+
t1 = reviews.filter(t2).flatMap(_temp11);
|
|
2284
2308
|
$[0] = open;
|
|
2285
2309
|
$[1] = reviews;
|
|
2286
2310
|
$[2] = t1;
|
|
@@ -2338,7 +2362,7 @@ function ProviderReviewFiles(t0) {
|
|
|
2338
2362
|
return t2;
|
|
2339
2363
|
}
|
|
2340
2364
|
/* The fallback card, built from what the CLI itself reported about its edits. */
|
|
2341
|
-
function
|
|
2365
|
+
function _temp11(t0) {
|
|
2342
2366
|
const {
|
|
2343
2367
|
reviews: reviews_0
|
|
2344
2368
|
} = t0;
|
|
@@ -2380,7 +2404,7 @@ function ProviderChangedFiles(t0) {
|
|
|
2380
2404
|
entryFor(change.path || tool.id).edits.push(change);
|
|
2381
2405
|
}
|
|
2382
2406
|
}
|
|
2383
|
-
t1 = [...byPath].map(
|
|
2407
|
+
t1 = [...byPath].map(_temp12);
|
|
2384
2408
|
$[0] = tools;
|
|
2385
2409
|
$[1] = byPath;
|
|
2386
2410
|
$[2] = t1;
|
|
@@ -2419,8 +2443,8 @@ function ProviderChangedFiles(t0) {
|
|
|
2419
2443
|
}
|
|
2420
2444
|
return t3;
|
|
2421
2445
|
}
|
|
2422
|
-
/* "Working for 00:14". */
|
|
2423
|
-
function
|
|
2446
|
+
/* "Working for 00:14", under the mark of the call running last; between calls, a spinner. */
|
|
2447
|
+
function _temp12(t0) {
|
|
2424
2448
|
const [path_0, entry] = t0;
|
|
2425
2449
|
return {
|
|
2426
2450
|
path: path_0,
|
|
@@ -2429,13 +2453,17 @@ function _temp11(t0) {
|
|
|
2429
2453
|
};
|
|
2430
2454
|
}
|
|
2431
2455
|
export function WorkingRow(t0) {
|
|
2432
|
-
const $ = _c(
|
|
2456
|
+
const $ = _c(20);
|
|
2433
2457
|
const {
|
|
2434
|
-
startedAt
|
|
2458
|
+
startedAt,
|
|
2459
|
+
tool
|
|
2435
2460
|
} = t0;
|
|
2436
2461
|
const {
|
|
2437
2462
|
t
|
|
2438
2463
|
} = useTranslation("agent-chat");
|
|
2464
|
+
const {
|
|
2465
|
+
commandLooks
|
|
2466
|
+
} = useChatHost();
|
|
2439
2467
|
let t1;
|
|
2440
2468
|
if ($[0] !== startedAt) {
|
|
2441
2469
|
t1 = () => formatClockDuration(Date.now() - startedAt);
|
|
@@ -2445,59 +2473,80 @@ export function WorkingRow(t0) {
|
|
|
2445
2473
|
t1 = $[1];
|
|
2446
2474
|
}
|
|
2447
2475
|
const ref = useTickingText(t1);
|
|
2448
|
-
|
|
2449
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2450
|
-
t2 = /*#__PURE__*/_jsx("span", {
|
|
2451
|
-
className: `${ROW_GUTTER} text-status-running`,
|
|
2452
|
-
children: /*#__PURE__*/_jsx(Spinner, {
|
|
2453
|
-
size: 12
|
|
2454
|
-
})
|
|
2455
|
-
});
|
|
2456
|
-
$[2] = t2;
|
|
2457
|
-
} else {
|
|
2458
|
-
t2 = $[2];
|
|
2459
|
-
}
|
|
2476
|
+
const t2 = tool === undefined ? "text-status-running" : "text-accent";
|
|
2460
2477
|
let t3;
|
|
2461
|
-
if ($[
|
|
2462
|
-
t3 =
|
|
2463
|
-
$[
|
|
2464
|
-
$[
|
|
2478
|
+
if ($[2] !== t2) {
|
|
2479
|
+
t3 = clsx(ROW_GUTTER, t2);
|
|
2480
|
+
$[2] = t2;
|
|
2481
|
+
$[3] = t3;
|
|
2465
2482
|
} else {
|
|
2466
|
-
t3 = $[
|
|
2483
|
+
t3 = $[3];
|
|
2467
2484
|
}
|
|
2468
2485
|
let t4;
|
|
2469
|
-
if ($[5] !==
|
|
2470
|
-
t4 = /*#__PURE__*/_jsx(
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
$[5] =
|
|
2486
|
+
if ($[4] !== commandLooks || $[5] !== tool) {
|
|
2487
|
+
t4 = tool === undefined ? /*#__PURE__*/_jsx(Spinner, {
|
|
2488
|
+
size: 12
|
|
2489
|
+
}) : callIcon(tool, commandLooks);
|
|
2490
|
+
$[4] = commandLooks;
|
|
2491
|
+
$[5] = tool;
|
|
2475
2492
|
$[6] = t4;
|
|
2476
2493
|
} else {
|
|
2477
2494
|
t4 = $[6];
|
|
2478
2495
|
}
|
|
2479
2496
|
let t5;
|
|
2480
|
-
if ($[7] !==
|
|
2497
|
+
if ($[7] !== t3 || $[8] !== t4) {
|
|
2481
2498
|
t5 = /*#__PURE__*/_jsx("span", {
|
|
2499
|
+
className: t3,
|
|
2500
|
+
children: t4
|
|
2501
|
+
});
|
|
2502
|
+
$[7] = t3;
|
|
2503
|
+
$[8] = t4;
|
|
2504
|
+
$[9] = t5;
|
|
2505
|
+
} else {
|
|
2506
|
+
t5 = $[9];
|
|
2507
|
+
}
|
|
2508
|
+
let t6;
|
|
2509
|
+
if ($[10] !== t) {
|
|
2510
|
+
t6 = t("work.workingFor");
|
|
2511
|
+
$[10] = t;
|
|
2512
|
+
$[11] = t6;
|
|
2513
|
+
} else {
|
|
2514
|
+
t6 = $[11];
|
|
2515
|
+
}
|
|
2516
|
+
let t7;
|
|
2517
|
+
if ($[12] !== t6) {
|
|
2518
|
+
t7 = /*#__PURE__*/_jsx("span", {
|
|
2519
|
+
className: "chat-live-text",
|
|
2520
|
+
children: t6
|
|
2521
|
+
});
|
|
2522
|
+
$[12] = t6;
|
|
2523
|
+
$[13] = t7;
|
|
2524
|
+
} else {
|
|
2525
|
+
t7 = $[13];
|
|
2526
|
+
}
|
|
2527
|
+
let t8;
|
|
2528
|
+
if ($[14] !== ref) {
|
|
2529
|
+
t8 = /*#__PURE__*/_jsx("span", {
|
|
2482
2530
|
ref: ref,
|
|
2483
2531
|
className: "tabular-nums"
|
|
2484
2532
|
});
|
|
2485
|
-
$[
|
|
2486
|
-
$[
|
|
2533
|
+
$[14] = ref;
|
|
2534
|
+
$[15] = t8;
|
|
2487
2535
|
} else {
|
|
2488
|
-
|
|
2536
|
+
t8 = $[15];
|
|
2489
2537
|
}
|
|
2490
|
-
let
|
|
2491
|
-
if ($[
|
|
2492
|
-
|
|
2538
|
+
let t9;
|
|
2539
|
+
if ($[16] !== t5 || $[17] !== t7 || $[18] !== t8) {
|
|
2540
|
+
t9 = /*#__PURE__*/_jsxs("div", {
|
|
2493
2541
|
className: "-mx-1 mb-0.5 flex h-7 items-center gap-2 px-1 text-xs text-text-muted",
|
|
2494
|
-
children: [
|
|
2542
|
+
children: [t5, t7, t8]
|
|
2495
2543
|
});
|
|
2496
|
-
$[
|
|
2497
|
-
$[
|
|
2498
|
-
$[
|
|
2544
|
+
$[16] = t5;
|
|
2545
|
+
$[17] = t7;
|
|
2546
|
+
$[18] = t8;
|
|
2547
|
+
$[19] = t9;
|
|
2499
2548
|
} else {
|
|
2500
|
-
|
|
2549
|
+
t9 = $[19];
|
|
2501
2550
|
}
|
|
2502
|
-
return
|
|
2551
|
+
return t9;
|
|
2503
2552
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
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.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.49.1",
|
|
76
|
+
"@adecore/editor": "0.49.1",
|
|
77
|
+
"@adecore/editor-react": "0.49.1",
|
|
78
|
+
"@adecore/intelligent-ui": "0.49.1",
|
|
79
|
+
"@adecore/merge": "0.49.1",
|
|
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.
|
|
103
|
+
"@adecore/ui": "^0.49.1",
|
|
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.
|
|
110
|
+
"@adecore/ui": "0.49.1",
|
|
111
111
|
"@types/bun": "^1.4.4",
|
|
112
112
|
"@types/react": "^19.3.0",
|
|
113
113
|
"@types/react-dom": "^19.3.0",
|
|
@@ -72,7 +72,7 @@ export type TimelineRow =
|
|
|
72
72
|
}
|
|
73
73
|
| { kind: 'turn-fold'; id: string; turn: ChatTurnItem; label: string; work: string[]; hiddenCount: number; expanded: boolean; expandable: boolean }
|
|
74
74
|
| { kind: 'forks'; id: string; turnId: string }
|
|
75
|
-
| { kind: 'working'; id: string; startedAt: number }
|
|
75
|
+
| { kind: 'working'; id: string; startedAt: number; tool?: ChatToolItem }
|
|
76
76
|
// A card of the app's own (`thread-cards.ts`), never derived from an item.
|
|
77
77
|
| { kind: 'app-card'; id: string; card: ThreadCard }
|
|
78
78
|
// A page an agent published, placed by when it was published (`thread-cards.ts`), never derived from an item.
|
|
@@ -662,7 +662,9 @@ export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions):
|
|
|
662
662
|
rows.push(...(active ? withLiveThought(live, conversation) : live));
|
|
663
663
|
|
|
664
664
|
if (active) {
|
|
665
|
-
|
|
665
|
+
const tool = conversation.findLast((item): item is ChatToolItem => item.kind === 'tool' && item.state === 'running' && parentOf(item) === null);
|
|
666
|
+
|
|
667
|
+
rows.push({ kind: 'working', id: `working-${turnId}`, startedAt: turn?.createdAt ?? Date.now(), ...(tool === undefined ? {} : { tool }) });
|
|
666
668
|
}
|
|
667
669
|
|
|
668
670
|
continue;
|
package/src/chat/ui/Markdown.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, memo, useContext, type ComponentProps, type MouseEvent, type ReactNode } from 'react';
|
|
1
|
+
import { createContext, memo, useContext, useState, type ComponentProps, type MouseEvent, type ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { Zap } from 'lucide-react';
|
|
4
4
|
import ReactMarkdown, { type Components, type ExtraProps, type Options } from 'react-markdown';
|
|
@@ -8,7 +8,7 @@ import { MENTION_TONE, SKILL_TONE, TOKEN_ICON } from './chips';
|
|
|
8
8
|
import { CodeBlock } from './CodeBlock';
|
|
9
9
|
import { MermaidBlock } from './MermaidBlock';
|
|
10
10
|
import { CodeStreamingContext } from './code-streaming';
|
|
11
|
-
import {
|
|
11
|
+
import { createMarkdownBlockSplitter } from './markdown-blocks';
|
|
12
12
|
import { ReferenceChip, TokenChip } from './ReferenceChip';
|
|
13
13
|
import { ReferenceLookupContext } from './reference-lookup';
|
|
14
14
|
import { rehypeChips, rehypeNamedReferences, type ChipOptions, type NamedReferenceOptions } from './rehype-chips';
|
|
@@ -469,7 +469,8 @@ export const ReplyMarkdown = memo(function ReplyMarkdown({
|
|
|
469
469
|
arriving?: boolean;
|
|
470
470
|
reply?: ShellCodeBlockReply;
|
|
471
471
|
}) {
|
|
472
|
-
const
|
|
472
|
+
const [split] = useState(createMarkdownBlockSplitter);
|
|
473
|
+
const blocks = split(text);
|
|
473
474
|
|
|
474
475
|
return (
|
|
475
476
|
<div className="chat-markdown prose prose-sm max-w-none text-sm" data-arriving={arriving || undefined}>
|
|
@@ -93,8 +93,64 @@ const BOLD_LINE = /^ {0,3}\*\*(?:[^*]|\*(?!\*))+\*\*:?[ \t]*$/;
|
|
|
93
93
|
* Joined back together the blocks are the text.
|
|
94
94
|
*/
|
|
95
95
|
export function splitMarkdownBlocks(text: string): MarkdownBlock[] {
|
|
96
|
+
return scanMarkdownBlocks(text).blocks;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface MarkdownCheckpoint {
|
|
100
|
+
offset: number;
|
|
101
|
+
count: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface MarkdownScan {
|
|
105
|
+
blocks: MarkdownBlock[];
|
|
106
|
+
checkpoint: MarkdownCheckpoint | null;
|
|
107
|
+
whole: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* The source may be replaced as well as appended; only cuts with a complete, independent context line can survive an append. */
|
|
111
|
+
export function createMarkdownBlockSplitter(): (text: string) => readonly MarkdownBlock[] {
|
|
112
|
+
let previous: string | null = null;
|
|
113
|
+
let offset = 0;
|
|
114
|
+
let retained: MarkdownBlock[] = [];
|
|
115
|
+
let result: MarkdownBlock[] = [];
|
|
116
|
+
|
|
117
|
+
return (text) => {
|
|
118
|
+
if (text === previous) {
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (previous === null || !text.startsWith(previous)) {
|
|
123
|
+
offset = 0;
|
|
124
|
+
retained = [];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let scan = scanMarkdownBlocks(text.slice(offset), true);
|
|
128
|
+
|
|
129
|
+
// The existing definition guard can match a label that starts before the checkpoint.
|
|
130
|
+
if (offset > 0 && (scan.whole || DEFINITION.test(text))) {
|
|
131
|
+
offset = 0;
|
|
132
|
+
retained = [];
|
|
133
|
+
scan = scanMarkdownBlocks(text, true);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
result = [...retained, ...scan.blocks];
|
|
137
|
+
|
|
138
|
+
if (scan.checkpoint !== null) {
|
|
139
|
+
// Retained substrings must not deliberately keep whole earlier reply versions alive.
|
|
140
|
+
const settled = scan.blocks.slice(0, scan.checkpoint.count).map((block) => structuredClone(block));
|
|
141
|
+
retained = [...retained, ...settled];
|
|
142
|
+
offset += scan.checkpoint.offset;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
previous = text;
|
|
146
|
+
|
|
147
|
+
return result;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function scanMarkdownBlocks(text: string, checkpoints = false): MarkdownScan {
|
|
96
152
|
if (DEFINITION.test(text) || LONE_RETURN.test(text)) {
|
|
97
|
-
return [{ text, openFence: isFenceOpenAtEnd(text) }];
|
|
153
|
+
return { blocks: [{ text, openFence: isFenceOpenAtEnd(text) }], checkpoint: null, whole: true };
|
|
98
154
|
}
|
|
99
155
|
|
|
100
156
|
const lines = text.split('\n');
|
|
@@ -119,6 +175,30 @@ export function splitMarkdownBlocks(text: string): MarkdownBlock[] {
|
|
|
119
175
|
let known = true;
|
|
120
176
|
// Where the line above starts when it is blank.
|
|
121
177
|
let blankAbove: number | null = null;
|
|
178
|
+
let completeLine = false;
|
|
179
|
+
let independentLine = false;
|
|
180
|
+
let lineStart = 0;
|
|
181
|
+
let checkpoint: MarkdownCheckpoint | null = null;
|
|
182
|
+
|
|
183
|
+
const remember = (end: number): void => {
|
|
184
|
+
if (
|
|
185
|
+
!checkpoints ||
|
|
186
|
+
!completeLine ||
|
|
187
|
+
!independentLine ||
|
|
188
|
+
end !== lineStart ||
|
|
189
|
+
!known ||
|
|
190
|
+
lineFence !== null ||
|
|
191
|
+
fence !== null ||
|
|
192
|
+
top !== null ||
|
|
193
|
+
closed !== null ||
|
|
194
|
+
item !== null ||
|
|
195
|
+
html !== null
|
|
196
|
+
) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
checkpoint = { offset: end, count: blocks.length };
|
|
201
|
+
};
|
|
122
202
|
|
|
123
203
|
const cutAt = (end: number): void => {
|
|
124
204
|
if (end > start) {
|
|
@@ -126,10 +206,24 @@ export function splitMarkdownBlocks(text: string): MarkdownBlock[] {
|
|
|
126
206
|
}
|
|
127
207
|
|
|
128
208
|
start = end;
|
|
209
|
+
remember(end);
|
|
129
210
|
};
|
|
130
211
|
|
|
131
212
|
for (const [index, line] of lines.entries()) {
|
|
132
213
|
const at = offset;
|
|
214
|
+
lineStart = at;
|
|
215
|
+
completeLine = index < lines.length - 1;
|
|
216
|
+
independentLine =
|
|
217
|
+
checkpoints &&
|
|
218
|
+
completeLine &&
|
|
219
|
+
index > 0 &&
|
|
220
|
+
known &&
|
|
221
|
+
lineFence === null &&
|
|
222
|
+
fence === null &&
|
|
223
|
+
top === null &&
|
|
224
|
+
item === null &&
|
|
225
|
+
html === null &&
|
|
226
|
+
BLANK.test(withoutReturn(lines[index - 1]!));
|
|
133
227
|
offset += line.length + 1;
|
|
134
228
|
const content = withoutReturn(line);
|
|
135
229
|
const blank = BLANK.test(line);
|
|
@@ -160,6 +254,7 @@ export function splitMarkdownBlocks(text: string): MarkdownBlock[] {
|
|
|
160
254
|
blocks.push(fenceBlock(text.slice(start, at), closed.fence, closed.source, true));
|
|
161
255
|
start = at;
|
|
162
256
|
closed = null;
|
|
257
|
+
remember(at);
|
|
163
258
|
}
|
|
164
259
|
|
|
165
260
|
if (html !== null) {
|
|
@@ -244,7 +339,7 @@ export function splitMarkdownBlocks(text: string): MarkdownBlock[] {
|
|
|
244
339
|
blocks.push({ text: text.slice(start), openFence: (known ? fence : lineFence) !== null });
|
|
245
340
|
}
|
|
246
341
|
|
|
247
|
-
return blocks;
|
|
342
|
+
return { blocks, checkpoint, whole: false };
|
|
248
343
|
}
|
|
249
344
|
|
|
250
345
|
/*
|
|
@@ -114,7 +114,7 @@ export function Row({ row, chatId, toggleGroup, toggleTurn, toggleSubagent, open
|
|
|
114
114
|
case 'compaction':
|
|
115
115
|
return <CompactionRow preTokens={row.preTokens} />;
|
|
116
116
|
case 'working':
|
|
117
|
-
return <WorkingRow startedAt={row.startedAt} />;
|
|
117
|
+
return <WorkingRow startedAt={row.startedAt} {...(row.tool === undefined ? {} : { tool: row.tool })} />;
|
|
118
118
|
case 'app-card':
|
|
119
119
|
return <AppCardRow card={row.card} />;
|
|
120
120
|
case 'visual':
|
|
@@ -478,6 +478,14 @@ export function RunningFor({ startedAt }: { startedAt: number }) {
|
|
|
478
478
|
return <span ref={ref} className="shrink-0 text-xs text-text-faint tabular-nums" />;
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
+
/* The mark of one call: the look its shell command runs under, else what the tool is about. */
|
|
482
|
+
function callIcon(tool: ChatToolItem, commandLooks: readonly CommandLook[] | undefined): ReactNode {
|
|
483
|
+
const shell = shellCommand(tool.name, tool.input);
|
|
484
|
+
const run = shell === null ? null : matchCommandLook(shell, commandLooks);
|
|
485
|
+
|
|
486
|
+
return run === null ? toolIcon(tool.name) : <run.look.Mark size={12} />;
|
|
487
|
+
}
|
|
488
|
+
|
|
481
489
|
/* A call still running: its timer on the line, and for a provider that streams output, the last lines under it. */
|
|
482
490
|
export function WorkLiveRow({ chatId, tool: derived }: { chatId: string; tool: ChatToolItem }) {
|
|
483
491
|
const [open, setOpen] = useState(false);
|
|
@@ -537,13 +545,15 @@ export function WorkGroupRow({
|
|
|
537
545
|
onToggle(): void;
|
|
538
546
|
}) {
|
|
539
547
|
const { t } = useTranslation('agent-chat');
|
|
548
|
+
const { commandLooks } = useChatHost();
|
|
540
549
|
const running = tools.filter((tool) => tool.state === 'running').length;
|
|
541
550
|
const failed = tools.some((tool) => tool.state === 'error');
|
|
551
|
+
const latest = tools.findLast((tool) => tool.state === 'running');
|
|
542
552
|
|
|
543
553
|
return (
|
|
544
554
|
<div>
|
|
545
555
|
<ToggleLine
|
|
546
|
-
icon={
|
|
556
|
+
icon={latest !== undefined ? callIcon(latest, commandLooks) : look === undefined ? toolIcon(tools[0]!.name) : <look.Mark size={12} />}
|
|
547
557
|
label={
|
|
548
558
|
<span className="tabular-nums">
|
|
549
559
|
{running > 0 ? t('group.toolCalls', { count: tools.length }) : look?.brand === undefined ? summary : withBrand(summary, [look.brand])}
|
|
@@ -552,6 +562,7 @@ export function WorkGroupRow({
|
|
|
552
562
|
open={expanded}
|
|
553
563
|
onToggle={onToggle}
|
|
554
564
|
failed={failed}
|
|
565
|
+
live={latest !== undefined}
|
|
555
566
|
trailing={running > 0 && <span className="shrink-0 text-text-faint tabular-nums">{t('group.running', { count: running })}</span>}
|
|
556
567
|
time={tools[0]!.createdAt}
|
|
557
568
|
/>
|
|
@@ -881,15 +892,16 @@ function ProviderChangedFiles({
|
|
|
881
892
|
);
|
|
882
893
|
}
|
|
883
894
|
|
|
884
|
-
/* "Working for 00:14". */
|
|
885
|
-
export function WorkingRow({ startedAt }: { startedAt: number }) {
|
|
895
|
+
/* "Working for 00:14", under the mark of the call running last; between calls, a spinner. */
|
|
896
|
+
export function WorkingRow({ startedAt, tool }: { startedAt: number; tool?: ChatToolItem }) {
|
|
886
897
|
const { t } = useTranslation('agent-chat');
|
|
898
|
+
const { commandLooks } = useChatHost();
|
|
887
899
|
const ref = useTickingText(() => formatClockDuration(Date.now() - startedAt));
|
|
888
900
|
|
|
889
901
|
return (
|
|
890
902
|
<div className="-mx-1 mb-0.5 flex h-7 items-center gap-2 px-1 text-xs text-text-muted">
|
|
891
|
-
<span className={
|
|
892
|
-
<Spinner size={12} />
|
|
903
|
+
<span className={clsx(ROW_GUTTER, tool === undefined ? 'text-status-running' : 'text-accent')}>
|
|
904
|
+
{tool === undefined ? <Spinner size={12} /> : callIcon(tool, commandLooks)}
|
|
893
905
|
</span>
|
|
894
906
|
<span className="chat-live-text">{t('work.workingFor')}</span>
|
|
895
907
|
<span ref={ref} className="tabular-nums" />
|