@adecore/agents-react 0.70.0 → 0.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/logic/fork.js +1 -0
- package/dist/chat/logic/thread-cards.js +1 -0
- package/dist/chat/logic/timeline.js +7 -0
- package/dist/chat/ui/CodeBlock.d.ts +6 -1
- package/dist/chat/ui/CodeBlock.js +39 -23
- package/dist/chat/ui/intelligent-ui/UiReply.js +11 -2
- package/dist/chat/ui/intelligent-ui/key-caps.d.ts +1 -0
- package/dist/chat/ui/intelligent-ui/key-caps.js +45 -0
- package/dist/chat/ui/intelligent-ui/link-action.d.ts +9 -0
- package/dist/chat/ui/intelligent-ui/link-action.js +32 -0
- package/dist/chat/ui/intelligent-ui/node-text.js +1 -1
- package/dist/chat/ui/intelligent-ui/patch-clip.d.ts +4 -0
- package/dist/chat/ui/intelligent-ui/patch-clip.js +64 -0
- package/dist/chat/ui/intelligent-ui/registry.js +31 -5
- package/dist/chat/ui/intelligent-ui/render-context.d.ts +13 -0
- package/dist/chat/ui/intelligent-ui/renderers/alternatives.d.ts +6 -0
- package/dist/chat/ui/intelligent-ui/renderers/alternatives.js +296 -0
- package/dist/chat/ui/intelligent-ui/renderers/changes.d.ts +4 -0
- package/dist/chat/ui/intelligent-ui/renderers/changes.js +266 -0
- package/dist/chat/ui/intelligent-ui/renderers/chart.js +522 -371
- package/dist/chat/ui/intelligent-ui/renderers/content.d.ts +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/content.js +94 -43
- package/dist/chat/ui/intelligent-ui/renderers/data.js +478 -245
- package/dist/chat/ui/intelligent-ui/renderers/diff.d.ts +4 -0
- package/dist/chat/ui/intelligent-ui/renderers/diff.js +427 -0
- package/dist/chat/ui/intelligent-ui/renderers/inputs.d.ts +1 -0
- package/dist/chat/ui/intelligent-ui/renderers/inputs.js +354 -110
- package/dist/chat/ui/intelligent-ui/renderers/keys.d.ts +3 -0
- package/dist/chat/ui/intelligent-ui/renderers/keys.js +60 -0
- package/dist/chat/ui/intelligent-ui/renderers/links.d.ts +13 -2
- package/dist/chat/ui/intelligent-ui/renderers/links.js +65 -85
- package/dist/chat/ui/intelligent-ui/renderers/meter.d.ts +4 -0
- package/dist/chat/ui/intelligent-ui/renderers/meter.js +371 -0
- package/dist/chat/ui/intelligent-ui/renderers/quote.d.ts +3 -0
- package/dist/chat/ui/intelligent-ui/renderers/quote.js +123 -0
- package/dist/chat/ui/intelligent-ui/renderers/radio.d.ts +3 -0
- package/dist/chat/ui/intelligent-ui/renderers/radio.js +205 -0
- package/dist/chat/ui/intelligent-ui/renderers/structure.d.ts +2 -0
- package/dist/chat/ui/intelligent-ui/renderers/structure.js +156 -45
- package/dist/chat/ui/intelligent-ui/renderers/text.js +365 -215
- package/dist/chat/ui/intelligent-ui/renderers/tree.d.ts +5 -0
- package/dist/chat/ui/intelligent-ui/renderers/tree.js +284 -0
- package/dist/chat/ui/intelligent-ui/table-data.d.ts +9 -2
- package/dist/chat/ui/intelligent-ui/table-data.js +68 -3
- package/dist/chat/ui/intelligent-ui/tones.d.ts +1 -1
- package/dist/chat/ui/intelligent-ui/tones.js +7 -7
- package/dist/chat/ui/intelligent-ui/use-ui-diffs.d.ts +4 -0
- package/dist/chat/ui/intelligent-ui/use-ui-diffs.js +201 -0
- package/dist/chat/ui/rows/MessageRows.d.ts +4 -1
- package/dist/chat/ui/rows/MessageRows.js +92 -1
- package/dist/chat/ui/rows/Rows.js +45 -31
- package/dist/host/host.d.ts +2 -1
- package/dist/host/timeline-row.d.ts +5 -1
- package/dist/locales/en/agent-chat.d.ts +62 -0
- package/dist/locales/en/agent-chat.js +63 -1
- package/dist/locales/nl/agent-chat.d.ts +62 -0
- package/dist/locales/nl/agent-chat.js +63 -1
- package/dist/theme.css +6 -0
- package/package.json +9 -9
- package/src/chat/logic/fork.ts +1 -0
- package/src/chat/logic/thread-cards.ts +1 -0
- package/src/chat/logic/timeline.ts +4 -0
- package/src/chat/ui/CodeBlock.tsx +38 -18
- package/src/chat/ui/intelligent-ui/UiReply.tsx +13 -2
- package/src/chat/ui/intelligent-ui/key-caps.ts +51 -0
- package/src/chat/ui/intelligent-ui/link-action.ts +32 -0
- package/src/chat/ui/intelligent-ui/node-text.ts +1 -0
- package/src/chat/ui/intelligent-ui/patch-clip.ts +83 -0
- package/src/chat/ui/intelligent-ui/registry.ts +31 -4
- package/src/chat/ui/intelligent-ui/render-context.ts +21 -0
- package/src/chat/ui/intelligent-ui/renderers/alternatives.tsx +76 -0
- package/src/chat/ui/intelligent-ui/renderers/changes.tsx +97 -0
- package/src/chat/ui/intelligent-ui/renderers/chart.tsx +122 -46
- package/src/chat/ui/intelligent-ui/renderers/content.tsx +27 -7
- package/src/chat/ui/intelligent-ui/renderers/data.tsx +165 -52
- package/src/chat/ui/intelligent-ui/renderers/diff.tsx +144 -0
- package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +111 -19
- package/src/chat/ui/intelligent-ui/renderers/keys.tsx +26 -0
- package/src/chat/ui/intelligent-ui/renderers/links.tsx +40 -24
- package/src/chat/ui/intelligent-ui/renderers/meter.tsx +105 -0
- package/src/chat/ui/intelligent-ui/renderers/quote.tsx +29 -0
- package/src/chat/ui/intelligent-ui/renderers/radio.tsx +130 -0
- package/src/chat/ui/intelligent-ui/renderers/structure.tsx +54 -7
- package/src/chat/ui/intelligent-ui/renderers/text.tsx +70 -36
- package/src/chat/ui/intelligent-ui/renderers/tree.tsx +85 -0
- package/src/chat/ui/intelligent-ui/table-data.ts +84 -6
- package/src/chat/ui/intelligent-ui/tones.ts +7 -7
- package/src/chat/ui/intelligent-ui/use-ui-diffs.ts +119 -0
- package/src/chat/ui/rows/MessageRows.tsx +23 -0
- package/src/chat/ui/rows/Rows.tsx +3 -0
- package/src/host/host.ts +4 -0
- package/src/host/timeline-row.ts +3 -0
- package/src/locales/en/agent-chat.ts +63 -1
- package/src/locales/nl/agent-chat.ts +63 -1
- package/src/theme.css +6 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UiProps } from '@adecore/intelligent-ui';
|
|
2
|
+
import type { UiRendererProps } from '../render-context.js';
|
|
3
|
+
export declare function TreeRenderer({ children }: UiRendererProps<UiProps<'Tree'>>): import("react").JSX.Element;
|
|
4
|
+
export declare function BranchRenderer({ node, children, context }: UiRendererProps<UiProps<'Branch'>>): import("react").JSX.Element;
|
|
5
|
+
export declare function LeafRenderer({ node, children, context }: UiRendererProps<UiProps<'Leaf'>>): import("react").JSX.Element;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { FileIcon, Icon } from '@adecore/ui';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Folder, FolderOpen } from 'lucide-react';
|
|
5
|
+
import { useId } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { useBlockLocal } from '../block-local.js';
|
|
8
|
+
import { uiBaseName, uiLinkAction } from '../link-action.js';
|
|
9
|
+
import { uiNodeLabel } from '../node-text.js';
|
|
10
|
+
import { UI_TONE_TEXT } from '../tones.js';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const ROW = 'flex min-h-7 min-w-0 items-center gap-2 font-mono text-code';
|
|
13
|
+
/* Nested lists, so a screen reader hears the depth and the count without a tree's own keyboard model. */
|
|
14
|
+
export function TreeRenderer(t0) {
|
|
15
|
+
const $ = _c(5);
|
|
16
|
+
const {
|
|
17
|
+
children
|
|
18
|
+
} = t0;
|
|
19
|
+
const {
|
|
20
|
+
t
|
|
21
|
+
} = useTranslation("agent-chat");
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== t) {
|
|
24
|
+
t1 = t("blocks.tree.label");
|
|
25
|
+
$[0] = t;
|
|
26
|
+
$[1] = t1;
|
|
27
|
+
} else {
|
|
28
|
+
t1 = $[1];
|
|
29
|
+
}
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[2] !== children || $[3] !== t1) {
|
|
32
|
+
t2 = /*#__PURE__*/_jsx("ul", {
|
|
33
|
+
"aria-label": t1,
|
|
34
|
+
className: "chat-ui-nodes chat-ui-flat flex flex-col rounded-xl bg-ui-tile px-3 py-2",
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
$[2] = children;
|
|
38
|
+
$[3] = t1;
|
|
39
|
+
$[4] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t2 = $[4];
|
|
42
|
+
}
|
|
43
|
+
return t2;
|
|
44
|
+
}
|
|
45
|
+
/* Open unless `open` says closed, read on every draw since the tag may still be streaming in; what a person folds stays folded as long as the page lasts. */
|
|
46
|
+
export function BranchRenderer(t0) {
|
|
47
|
+
const $ = _c(21);
|
|
48
|
+
const {
|
|
49
|
+
node,
|
|
50
|
+
children,
|
|
51
|
+
context
|
|
52
|
+
} = t0;
|
|
53
|
+
const [chosen, setChosen] = useBlockLocal(context, node.id, _temp);
|
|
54
|
+
const open = chosen ?? node.props.open !== false;
|
|
55
|
+
const contentId = useId();
|
|
56
|
+
let t1;
|
|
57
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
58
|
+
t1 = clsx(ROW, "-mx-1.5 rounded-md px-1.5 text-left text-text hover:bg-text/4");
|
|
59
|
+
$[0] = t1;
|
|
60
|
+
} else {
|
|
61
|
+
t1 = $[0];
|
|
62
|
+
}
|
|
63
|
+
let t2;
|
|
64
|
+
if ($[1] !== open || $[2] !== setChosen) {
|
|
65
|
+
t2 = () => setChosen(!open);
|
|
66
|
+
$[1] = open;
|
|
67
|
+
$[2] = setChosen;
|
|
68
|
+
$[3] = t2;
|
|
69
|
+
} else {
|
|
70
|
+
t2 = $[3];
|
|
71
|
+
}
|
|
72
|
+
const t3 = open ? FolderOpen : Folder;
|
|
73
|
+
let t4;
|
|
74
|
+
if ($[4] !== t3) {
|
|
75
|
+
t4 = /*#__PURE__*/_jsx(Icon, {
|
|
76
|
+
icon: t3,
|
|
77
|
+
size: 14,
|
|
78
|
+
className: "shrink-0 text-text-muted"
|
|
79
|
+
});
|
|
80
|
+
$[4] = t3;
|
|
81
|
+
$[5] = t4;
|
|
82
|
+
} else {
|
|
83
|
+
t4 = $[5];
|
|
84
|
+
}
|
|
85
|
+
let t5;
|
|
86
|
+
if ($[6] !== node.props.label) {
|
|
87
|
+
t5 = /*#__PURE__*/_jsx("span", {
|
|
88
|
+
className: "min-w-0 truncate",
|
|
89
|
+
children: node.props.label
|
|
90
|
+
});
|
|
91
|
+
$[6] = node.props.label;
|
|
92
|
+
$[7] = t5;
|
|
93
|
+
} else {
|
|
94
|
+
t5 = $[7];
|
|
95
|
+
}
|
|
96
|
+
let t6;
|
|
97
|
+
if ($[8] !== contentId || $[9] !== open || $[10] !== t2 || $[11] !== t4 || $[12] !== t5) {
|
|
98
|
+
t6 = /*#__PURE__*/_jsxs("button", {
|
|
99
|
+
type: "button",
|
|
100
|
+
"aria-expanded": open,
|
|
101
|
+
"aria-controls": contentId,
|
|
102
|
+
className: t1,
|
|
103
|
+
onClick: t2,
|
|
104
|
+
children: [t4, t5]
|
|
105
|
+
});
|
|
106
|
+
$[8] = contentId;
|
|
107
|
+
$[9] = open;
|
|
108
|
+
$[10] = t2;
|
|
109
|
+
$[11] = t4;
|
|
110
|
+
$[12] = t5;
|
|
111
|
+
$[13] = t6;
|
|
112
|
+
} else {
|
|
113
|
+
t6 = $[13];
|
|
114
|
+
}
|
|
115
|
+
const t7 = !open;
|
|
116
|
+
let t8;
|
|
117
|
+
if ($[14] !== children || $[15] !== contentId || $[16] !== t7) {
|
|
118
|
+
t8 = /*#__PURE__*/_jsx("ul", {
|
|
119
|
+
id: contentId,
|
|
120
|
+
hidden: t7,
|
|
121
|
+
className: "chat-ui-nodes flex flex-col pl-4",
|
|
122
|
+
children: children
|
|
123
|
+
});
|
|
124
|
+
$[14] = children;
|
|
125
|
+
$[15] = contentId;
|
|
126
|
+
$[16] = t7;
|
|
127
|
+
$[17] = t8;
|
|
128
|
+
} else {
|
|
129
|
+
t8 = $[17];
|
|
130
|
+
}
|
|
131
|
+
let t9;
|
|
132
|
+
if ($[18] !== t6 || $[19] !== t8) {
|
|
133
|
+
t9 = /*#__PURE__*/_jsxs("li", {
|
|
134
|
+
className: "flex min-w-0 flex-col",
|
|
135
|
+
children: [t6, t8]
|
|
136
|
+
});
|
|
137
|
+
$[18] = t6;
|
|
138
|
+
$[19] = t8;
|
|
139
|
+
$[20] = t9;
|
|
140
|
+
} else {
|
|
141
|
+
t9 = $[20];
|
|
142
|
+
}
|
|
143
|
+
return t9;
|
|
144
|
+
}
|
|
145
|
+
/*
|
|
146
|
+
* Named by its children, or by its file without them. With a path the host can open, the name opens it
|
|
147
|
+
* as a File link does; one it cannot stays the same text, since a tree shows a structure before it links.
|
|
148
|
+
*/
|
|
149
|
+
function _temp() {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
export function LeafRenderer(t0) {
|
|
153
|
+
const $ = _c(30);
|
|
154
|
+
const {
|
|
155
|
+
node,
|
|
156
|
+
children,
|
|
157
|
+
context
|
|
158
|
+
} = t0;
|
|
159
|
+
const {
|
|
160
|
+
t
|
|
161
|
+
} = useTranslation("agent-chat");
|
|
162
|
+
const {
|
|
163
|
+
path,
|
|
164
|
+
detail,
|
|
165
|
+
tone
|
|
166
|
+
} = node.props;
|
|
167
|
+
let t1;
|
|
168
|
+
if ($[0] !== node) {
|
|
169
|
+
t1 = uiNodeLabel(node);
|
|
170
|
+
$[0] = node;
|
|
171
|
+
$[1] = t1;
|
|
172
|
+
} else {
|
|
173
|
+
t1 = $[1];
|
|
174
|
+
}
|
|
175
|
+
const written = t1 !== "";
|
|
176
|
+
let t2;
|
|
177
|
+
if ($[2] !== children || $[3] !== path || $[4] !== written) {
|
|
178
|
+
t2 = written ? children : path === undefined ? null : uiBaseName(path);
|
|
179
|
+
$[2] = children;
|
|
180
|
+
$[3] = path;
|
|
181
|
+
$[4] = written;
|
|
182
|
+
$[5] = t2;
|
|
183
|
+
} else {
|
|
184
|
+
t2 = $[5];
|
|
185
|
+
}
|
|
186
|
+
const name = t2;
|
|
187
|
+
let t3;
|
|
188
|
+
if ($[6] !== context || $[7] !== path || $[8] !== t) {
|
|
189
|
+
t3 = path === undefined ? null : uiLinkAction(t, {
|
|
190
|
+
type: "File",
|
|
191
|
+
path
|
|
192
|
+
}, context).open;
|
|
193
|
+
$[6] = context;
|
|
194
|
+
$[7] = path;
|
|
195
|
+
$[8] = t;
|
|
196
|
+
$[9] = t3;
|
|
197
|
+
} else {
|
|
198
|
+
t3 = $[9];
|
|
199
|
+
}
|
|
200
|
+
const open = t3;
|
|
201
|
+
let t4;
|
|
202
|
+
let t5;
|
|
203
|
+
let t6;
|
|
204
|
+
if ($[10] !== name || $[11] !== open || $[12] !== path || $[13] !== tone) {
|
|
205
|
+
const look = clsx("min-w-0 truncate", tone === undefined ? "text-text" : UI_TONE_TEXT[tone]);
|
|
206
|
+
t4 = ROW;
|
|
207
|
+
if ($[17] !== path) {
|
|
208
|
+
t5 = path === undefined ? /*#__PURE__*/_jsx("span", {
|
|
209
|
+
"aria-hidden": true,
|
|
210
|
+
className: "grid size-3.5 shrink-0 place-items-center",
|
|
211
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
212
|
+
className: "size-1 rounded-full bg-text-faint"
|
|
213
|
+
})
|
|
214
|
+
}) : /*#__PURE__*/_jsx(FileIcon, {
|
|
215
|
+
path: path,
|
|
216
|
+
size: 14,
|
|
217
|
+
className: "shrink-0"
|
|
218
|
+
});
|
|
219
|
+
$[17] = path;
|
|
220
|
+
$[18] = t5;
|
|
221
|
+
} else {
|
|
222
|
+
t5 = $[18];
|
|
223
|
+
}
|
|
224
|
+
t6 = open === null ? /*#__PURE__*/_jsx("span", {
|
|
225
|
+
className: look,
|
|
226
|
+
children: name
|
|
227
|
+
}) : /*#__PURE__*/_jsx("button", {
|
|
228
|
+
type: "button",
|
|
229
|
+
className: clsx(look, "rounded-sm text-left hover:underline"),
|
|
230
|
+
onClick: open,
|
|
231
|
+
children: name
|
|
232
|
+
});
|
|
233
|
+
$[10] = name;
|
|
234
|
+
$[11] = open;
|
|
235
|
+
$[12] = path;
|
|
236
|
+
$[13] = tone;
|
|
237
|
+
$[14] = t4;
|
|
238
|
+
$[15] = t5;
|
|
239
|
+
$[16] = t6;
|
|
240
|
+
} else {
|
|
241
|
+
t4 = $[14];
|
|
242
|
+
t5 = $[15];
|
|
243
|
+
t6 = $[16];
|
|
244
|
+
}
|
|
245
|
+
let t7;
|
|
246
|
+
if ($[19] !== t || $[20] !== tone) {
|
|
247
|
+
t7 = tone !== undefined && tone !== "neutral" && /*#__PURE__*/_jsx("span", {
|
|
248
|
+
className: "sr-only",
|
|
249
|
+
children: t(`blocks.event.tone.${tone}`)
|
|
250
|
+
});
|
|
251
|
+
$[19] = t;
|
|
252
|
+
$[20] = tone;
|
|
253
|
+
$[21] = t7;
|
|
254
|
+
} else {
|
|
255
|
+
t7 = $[21];
|
|
256
|
+
}
|
|
257
|
+
let t8;
|
|
258
|
+
if ($[22] !== detail) {
|
|
259
|
+
t8 = detail !== undefined && detail !== "" && /*#__PURE__*/_jsx("span", {
|
|
260
|
+
className: "ml-auto max-w-1/2 shrink-0 truncate pl-2 font-sans text-2xs text-text-muted",
|
|
261
|
+
children: detail
|
|
262
|
+
});
|
|
263
|
+
$[22] = detail;
|
|
264
|
+
$[23] = t8;
|
|
265
|
+
} else {
|
|
266
|
+
t8 = $[23];
|
|
267
|
+
}
|
|
268
|
+
let t9;
|
|
269
|
+
if ($[24] !== t4 || $[25] !== t5 || $[26] !== t6 || $[27] !== t7 || $[28] !== t8) {
|
|
270
|
+
t9 = /*#__PURE__*/_jsxs("li", {
|
|
271
|
+
className: t4,
|
|
272
|
+
children: [t5, t6, t7, t8]
|
|
273
|
+
});
|
|
274
|
+
$[24] = t4;
|
|
275
|
+
$[25] = t5;
|
|
276
|
+
$[26] = t6;
|
|
277
|
+
$[27] = t7;
|
|
278
|
+
$[28] = t8;
|
|
279
|
+
$[29] = t9;
|
|
280
|
+
} else {
|
|
281
|
+
t9 = $[29];
|
|
282
|
+
}
|
|
283
|
+
return t9;
|
|
284
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { UiProps, UiViewNode } from '@adecore/intelligent-ui';
|
|
1
|
+
import type { UiProps, UiTone, UiViewNode } from '@adecore/intelligent-ui';
|
|
2
2
|
type UiColumnKind = NonNullable<UiProps<'Column'>['as']>;
|
|
3
3
|
export interface UiTableColumn {
|
|
4
4
|
key: string;
|
|
5
5
|
title: string;
|
|
6
6
|
unit?: string;
|
|
7
7
|
as: UiColumnKind;
|
|
8
|
+
tones?: Readonly<Record<string, UiTone>>;
|
|
8
9
|
}
|
|
9
10
|
export type UiTableCell = {
|
|
10
11
|
kind: 'empty';
|
|
@@ -13,7 +14,7 @@ export type UiTableCell = {
|
|
|
13
14
|
text: string;
|
|
14
15
|
} | {
|
|
15
16
|
kind: 'number';
|
|
16
|
-
as: 'number' | 'bytes' | 'duration';
|
|
17
|
+
as: 'number' | 'bytes' | 'duration' | 'percent';
|
|
17
18
|
value: number;
|
|
18
19
|
} | {
|
|
19
20
|
kind: 'date';
|
|
@@ -29,4 +30,10 @@ export declare const UI_TABLE_ROWS = 50;
|
|
|
29
30
|
export declare function isNumericColumn(column: UiTableColumn): boolean;
|
|
30
31
|
export declare function uiTableColumns(node: UiViewNode<UiProps<'Table'>>): UiTableColumn[];
|
|
31
32
|
export declare function uiTableCell(value: unknown, column: UiTableColumn): UiTableCell;
|
|
33
|
+
export interface UiTableSort {
|
|
34
|
+
key: string;
|
|
35
|
+
descending: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function uiTableSort(sort: string | undefined, columns: readonly UiTableColumn[]): UiTableSort | null;
|
|
38
|
+
export declare function uiTableOrder(rows: UiProps<'Table'>['rows'], column: UiTableColumn, descending: boolean): number[];
|
|
32
39
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { labelCollator } from '@adecore/ui/format';
|
|
1
2
|
import { uiChildrenOf } from './node-text.js';
|
|
2
3
|
/* Rows shown before a person asks for all of them. */
|
|
3
4
|
export const UI_TABLE_ROWS = 50;
|
|
4
5
|
/* The furthest a JavaScript Date reaches from the epoch either way, in milliseconds. */
|
|
5
6
|
const DATE_RANGE = 8.64e15;
|
|
6
|
-
const NUMERIC_KINDS = new Set(['number', 'bytes', 'duration']);
|
|
7
|
+
const NUMERIC_KINDS = new Set(['number', 'bytes', 'duration', 'percent']);
|
|
7
8
|
export function isNumericColumn(column) {
|
|
8
9
|
return NUMERIC_KINDS.has(column.as);
|
|
9
10
|
}
|
|
@@ -29,7 +30,8 @@ export function uiTableColumns(node) {
|
|
|
29
30
|
key: props.key,
|
|
30
31
|
title: props.title ?? props.key,
|
|
31
32
|
unit: props.unit,
|
|
32
|
-
as: props.as ?? 'text'
|
|
33
|
+
as: props.as ?? 'text',
|
|
34
|
+
tones: props.tones
|
|
33
35
|
}];
|
|
34
36
|
});
|
|
35
37
|
}
|
|
@@ -64,7 +66,10 @@ function numberOf(value) {
|
|
|
64
66
|
}
|
|
65
67
|
return null;
|
|
66
68
|
}
|
|
67
|
-
/*
|
|
69
|
+
/*
|
|
70
|
+
* A duration is in milliseconds, a percent is the number before the sign (`12.5` reads 12.5%) and a date is
|
|
71
|
+
* milliseconds since the epoch or an ISO string; anything else reads as text.
|
|
72
|
+
*/
|
|
68
73
|
export function uiTableCell(value, column) {
|
|
69
74
|
if (value === undefined || value === null || value === '') {
|
|
70
75
|
return {
|
|
@@ -75,6 +80,7 @@ export function uiTableCell(value, column) {
|
|
|
75
80
|
case 'number':
|
|
76
81
|
case 'bytes':
|
|
77
82
|
case 'duration':
|
|
83
|
+
case 'percent':
|
|
78
84
|
{
|
|
79
85
|
const number = numberOf(value);
|
|
80
86
|
return number === null ? {
|
|
@@ -116,4 +122,63 @@ export function uiTableCell(value, column) {
|
|
|
116
122
|
text: textOf(value)
|
|
117
123
|
};
|
|
118
124
|
}
|
|
125
|
+
}
|
|
126
|
+
/* What `sort` on a Table asks for: a column key, with ` desc` behind it for the largest first. Null for a key the table draws no column of. */
|
|
127
|
+
export function uiTableSort(sort, columns) {
|
|
128
|
+
if (sort === undefined) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const written = sort.trim();
|
|
132
|
+
const drawn = key => columns.some(column => column.key === key);
|
|
133
|
+
// A key that itself ends in a direction is that key.
|
|
134
|
+
if (drawn(written)) {
|
|
135
|
+
return {
|
|
136
|
+
key: written,
|
|
137
|
+
descending: false
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const [, key, direction] = /^(.*?)\s+(asc|desc)$/i.exec(written) ?? [];
|
|
141
|
+
return key !== undefined && drawn(key) ? {
|
|
142
|
+
key,
|
|
143
|
+
descending: direction.toLowerCase() === 'desc'
|
|
144
|
+
} : null;
|
|
145
|
+
}
|
|
146
|
+
function sortValue(cell) {
|
|
147
|
+
switch (cell.kind) {
|
|
148
|
+
case 'empty':
|
|
149
|
+
return null;
|
|
150
|
+
case 'number':
|
|
151
|
+
return cell.value;
|
|
152
|
+
case 'date':
|
|
153
|
+
return cell.at;
|
|
154
|
+
case 'file':
|
|
155
|
+
return cell.path;
|
|
156
|
+
case 'text':
|
|
157
|
+
case 'tag':
|
|
158
|
+
return cell.text;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/*
|
|
162
|
+
* The places of `rows` in the order of one column, so a row keeps the index live readings address it by.
|
|
163
|
+
* Numbers, bytes, durations, percentages and dates order by value and text by the reader's language. In
|
|
164
|
+
* either direction a number stands before text and an empty cell last, and equal rows keep their order.
|
|
165
|
+
*/
|
|
166
|
+
export function uiTableOrder(rows, column, descending) {
|
|
167
|
+
const collator = labelCollator();
|
|
168
|
+
const direction = descending ? -1 : 1;
|
|
169
|
+
return rows.map((row, index) => ({
|
|
170
|
+
index,
|
|
171
|
+
value: sortValue(uiTableCell(row[column.key], column))
|
|
172
|
+
})).sort((left, right) => {
|
|
173
|
+
if (left.value === null || right.value === null) {
|
|
174
|
+
return left.value === right.value ? left.index - right.index : left.value === null ? 1 : -1;
|
|
175
|
+
}
|
|
176
|
+
if (typeof left.value === 'string' || typeof right.value === 'string') {
|
|
177
|
+
if (typeof left.value !== typeof right.value) {
|
|
178
|
+
return typeof left.value === 'number' ? -1 : 1;
|
|
179
|
+
}
|
|
180
|
+
return direction * collator.compare(left.value, right.value) || left.index - right.index;
|
|
181
|
+
}
|
|
182
|
+
return direction * (left.value - right.value) || left.index - right.index;
|
|
183
|
+
}).map(entry => entry.index);
|
|
119
184
|
}
|
|
@@ -6,4 +6,4 @@ export declare const UI_TONE_TEXT: Readonly<Record<UiTone, string>>;
|
|
|
6
6
|
export declare const UI_TONE_SURFACE: Readonly<Record<UiTone, string>>;
|
|
7
7
|
export declare const UI_TONE_PILL: Readonly<Record<UiTone, NonNullable<PillProps['tone']>>>;
|
|
8
8
|
export declare const UI_TONE_FILL: Readonly<Record<UiTone, string>>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const UI_TONE_COLOR: Readonly<Record<UiTone, string>>;
|
|
@@ -37,11 +37,11 @@ export const UI_TONE_FILL = {
|
|
|
37
37
|
warning: 'bg-status-needs-you',
|
|
38
38
|
danger: 'bg-status-error'
|
|
39
39
|
};
|
|
40
|
-
/* The
|
|
41
|
-
export const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
/* The tone as a CSS color, for a shape that takes its color through `style`, such as a part of a bar. */
|
|
41
|
+
export const UI_TONE_COLOR = {
|
|
42
|
+
neutral: 'var(--text-muted)',
|
|
43
|
+
info: 'var(--status-running)',
|
|
44
|
+
success: 'var(--positive)',
|
|
45
|
+
warning: 'var(--status-needs-you)',
|
|
46
|
+
danger: 'var(--status-error)'
|
|
47
47
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type UiBlock, type UiState, type UiViewNode } from '@adecore/intelligent-ui';
|
|
2
|
+
import type { UiRenderContext } from './render-context.js';
|
|
3
|
+
export declare const UI_OPEN_DIFFS = 8;
|
|
4
|
+
export declare function useUiDiffs(block: UiBlock, state: UiState, context: Pick<UiRenderContext, 'scopeId' | 'chatId' | 'itemId' | 'phase'>, reads: Readonly<Record<string, string>>, nodes: readonly UiViewNode[]): UiRenderContext['diff'];
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { uiInputValues } from '@adecore/intelligent-ui';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useChatHost } from '../../../host/host.js';
|
|
5
|
+
/* The open Diffs one block asks its host for; a Diff past these stays a chip, so no block reads a whole repository. */
|
|
6
|
+
export const UI_OPEN_DIFFS = 8;
|
|
7
|
+
function openDiffs(nodes, into = []) {
|
|
8
|
+
for (const node of nodes) {
|
|
9
|
+
if (node.type === 'Diff' && node.error === undefined && node.complete) {
|
|
10
|
+
const {
|
|
11
|
+
path,
|
|
12
|
+
open,
|
|
13
|
+
from,
|
|
14
|
+
to,
|
|
15
|
+
whitespace
|
|
16
|
+
} = node.props;
|
|
17
|
+
if (open === true) {
|
|
18
|
+
into.push({
|
|
19
|
+
nodeId: node.id,
|
|
20
|
+
path,
|
|
21
|
+
from,
|
|
22
|
+
to,
|
|
23
|
+
whitespace
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
openDiffs(node.children, into);
|
|
28
|
+
}
|
|
29
|
+
return into;
|
|
30
|
+
}
|
|
31
|
+
function diffOf(reading) {
|
|
32
|
+
return reading.state === 'patch' && reading.patch !== undefined ? {
|
|
33
|
+
state: 'patch',
|
|
34
|
+
patch: reading.patch,
|
|
35
|
+
truncated: reading.truncated === true
|
|
36
|
+
} : {
|
|
37
|
+
state: 'refused',
|
|
38
|
+
code: reading.code,
|
|
39
|
+
reason: reading.reason
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/*
|
|
43
|
+
* Asks the host for the change of every open Diff of a finished block, once per request. The agent
|
|
44
|
+
* writes only the path, so what is shown is what git holds and never what a model copied.
|
|
45
|
+
*/
|
|
46
|
+
export function useUiDiffs(block, state, context, reads, nodes) {
|
|
47
|
+
const $ = _c(35);
|
|
48
|
+
let t0;
|
|
49
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
50
|
+
t0 = {};
|
|
51
|
+
$[0] = t0;
|
|
52
|
+
} else {
|
|
53
|
+
t0 = $[0];
|
|
54
|
+
}
|
|
55
|
+
const [answered, setAnswered] = useState(t0);
|
|
56
|
+
let t1;
|
|
57
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
58
|
+
t1 = new Map();
|
|
59
|
+
$[1] = t1;
|
|
60
|
+
} else {
|
|
61
|
+
t1 = $[1];
|
|
62
|
+
}
|
|
63
|
+
const asked = useRef(t1);
|
|
64
|
+
const read = useChatHost().intelligentUi?.diff;
|
|
65
|
+
let t2;
|
|
66
|
+
let wanted;
|
|
67
|
+
if ($[2] !== block.complete || $[3] !== nodes) {
|
|
68
|
+
wanted = block.complete ? openDiffs(nodes).slice(0, UI_OPEN_DIFFS) : [];
|
|
69
|
+
t2 = JSON.stringify(wanted);
|
|
70
|
+
$[2] = block.complete;
|
|
71
|
+
$[3] = nodes;
|
|
72
|
+
$[4] = t2;
|
|
73
|
+
$[5] = wanted;
|
|
74
|
+
} else {
|
|
75
|
+
t2 = $[4];
|
|
76
|
+
wanted = $[5];
|
|
77
|
+
}
|
|
78
|
+
const signature = t2;
|
|
79
|
+
let t3;
|
|
80
|
+
if ($[6] !== block || $[7] !== state) {
|
|
81
|
+
t3 = JSON.stringify(uiInputValues(block, state));
|
|
82
|
+
$[6] = block;
|
|
83
|
+
$[7] = state;
|
|
84
|
+
$[8] = t3;
|
|
85
|
+
} else {
|
|
86
|
+
t3 = $[8];
|
|
87
|
+
}
|
|
88
|
+
const input = t3;
|
|
89
|
+
let t4;
|
|
90
|
+
if ($[9] !== reads) {
|
|
91
|
+
t4 = JSON.stringify(reads);
|
|
92
|
+
$[9] = reads;
|
|
93
|
+
$[10] = t4;
|
|
94
|
+
} else {
|
|
95
|
+
t4 = $[10];
|
|
96
|
+
}
|
|
97
|
+
const tickets = t4;
|
|
98
|
+
const ready = read !== undefined && block.revision !== undefined && context.phase === "final";
|
|
99
|
+
let t5;
|
|
100
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t5 = () => {
|
|
102
|
+
const requests = asked.current;
|
|
103
|
+
return () => requests.clear();
|
|
104
|
+
};
|
|
105
|
+
$[11] = t5;
|
|
106
|
+
} else {
|
|
107
|
+
t5 = $[11];
|
|
108
|
+
}
|
|
109
|
+
let t6;
|
|
110
|
+
if ($[12] !== block.id || $[13] !== block.revision || $[14] !== context.chatId || $[15] !== context.itemId || $[16] !== context.scopeId || $[17] !== read) {
|
|
111
|
+
t6 = [block.id, block.revision, context.scopeId, context.chatId, context.itemId, read];
|
|
112
|
+
$[12] = block.id;
|
|
113
|
+
$[13] = block.revision;
|
|
114
|
+
$[14] = context.chatId;
|
|
115
|
+
$[15] = context.itemId;
|
|
116
|
+
$[16] = context.scopeId;
|
|
117
|
+
$[17] = read;
|
|
118
|
+
$[18] = t6;
|
|
119
|
+
} else {
|
|
120
|
+
t6 = $[18];
|
|
121
|
+
}
|
|
122
|
+
useEffect(t5, t6);
|
|
123
|
+
let t7;
|
|
124
|
+
let t8;
|
|
125
|
+
if ($[19] !== block.id || $[20] !== block.revision || $[21] !== context.chatId || $[22] !== context.itemId || $[23] !== context.phase || $[24] !== context.scopeId || $[25] !== input || $[26] !== read || $[27] !== signature || $[28] !== tickets) {
|
|
126
|
+
t7 = () => {
|
|
127
|
+
if (!read || !block.revision || context.phase !== "final") {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
for (const request of JSON.parse(signature)) {
|
|
131
|
+
const key = JSON.stringify(request);
|
|
132
|
+
if (asked.current.get(request.nodeId) === key) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
asked.current.set(request.nodeId, key);
|
|
136
|
+
const record = diff => {
|
|
137
|
+
if (asked.current.get(request.nodeId) === key) {
|
|
138
|
+
setAnswered(previous => ({
|
|
139
|
+
...previous,
|
|
140
|
+
[request.nodeId]: {
|
|
141
|
+
request: key,
|
|
142
|
+
diff
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
read(context.scopeId, {
|
|
148
|
+
chatId: context.chatId,
|
|
149
|
+
itemId: context.itemId,
|
|
150
|
+
blockId: block.id,
|
|
151
|
+
revision: block.revision,
|
|
152
|
+
nodeId: request.nodeId,
|
|
153
|
+
values: JSON.parse(input),
|
|
154
|
+
reads: JSON.parse(tickets)
|
|
155
|
+
}).then(reading => record(diffOf(reading)), () => record({
|
|
156
|
+
state: "refused"
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
t8 = [block.id, block.revision, context.scopeId, context.chatId, context.itemId, context.phase, signature, input, tickets, read];
|
|
161
|
+
$[19] = block.id;
|
|
162
|
+
$[20] = block.revision;
|
|
163
|
+
$[21] = context.chatId;
|
|
164
|
+
$[22] = context.itemId;
|
|
165
|
+
$[23] = context.phase;
|
|
166
|
+
$[24] = context.scopeId;
|
|
167
|
+
$[25] = input;
|
|
168
|
+
$[26] = read;
|
|
169
|
+
$[27] = signature;
|
|
170
|
+
$[28] = tickets;
|
|
171
|
+
$[29] = t7;
|
|
172
|
+
$[30] = t8;
|
|
173
|
+
} else {
|
|
174
|
+
t7 = $[29];
|
|
175
|
+
t8 = $[30];
|
|
176
|
+
}
|
|
177
|
+
useEffect(t7, t8);
|
|
178
|
+
if (!read) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
let t9;
|
|
182
|
+
if ($[31] !== answered || $[32] !== ready || $[33] !== wanted) {
|
|
183
|
+
t9 = nodeId => {
|
|
184
|
+
const request_0 = wanted.find(entry => entry.nodeId === nodeId);
|
|
185
|
+
if (request_0 === undefined || !ready) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const reading_0 = answered[nodeId];
|
|
189
|
+
return reading_0?.request === JSON.stringify(request_0) ? reading_0.diff : {
|
|
190
|
+
state: "reading"
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
$[31] = answered;
|
|
194
|
+
$[32] = ready;
|
|
195
|
+
$[33] = wanted;
|
|
196
|
+
$[34] = t9;
|
|
197
|
+
} else {
|
|
198
|
+
t9 = $[34];
|
|
199
|
+
}
|
|
200
|
+
return t9;
|
|
201
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatApprovalItem, ChatAssistantItem, ChatNoteMessage, ChatQuestionItem, ChatThinkingItem, ChatToolItem, ChatUserItem, ModelSelection } from '@adecore/agent-contracts';
|
|
1
|
+
import type { ChatApprovalItem, ChatAssistantItem, ChatNoteMessage, ChatQuestionItem, ChatSecretItem, ChatThinkingItem, ChatToolItem, ChatUserItem, ModelSelection } from '@adecore/agent-contracts';
|
|
2
2
|
import { type CommandLookSent } from '../../../host/host.js';
|
|
3
3
|
export declare function UserRow({ chatId, item }: {
|
|
4
4
|
chatId: string;
|
|
@@ -63,6 +63,9 @@ export declare function SelectionSwitchRow({ chatId, from, to }: {
|
|
|
63
63
|
export declare function ApprovalHistoryRow({ item }: {
|
|
64
64
|
item: ChatApprovalItem;
|
|
65
65
|
}): import("react").JSX.Element | null;
|
|
66
|
+
export declare function SecretRow({ item }: {
|
|
67
|
+
item: ChatSecretItem;
|
|
68
|
+
}): import("react").JSX.Element;
|
|
66
69
|
export declare function QuestionHistoryRow({ item }: {
|
|
67
70
|
item: ChatQuestionItem;
|
|
68
71
|
}): import("react").JSX.Element;
|