@adecore/agents-react 0.61.0 → 0.62.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/ui/ReferenceChip.js +127 -71
- package/dist/chat/ui/reference-lookup.d.ts +2 -0
- package/dist/chat/ui/thread-references.js +30 -16
- package/dist/host.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/package.json +9 -9
- package/src/chat/ui/ReferenceChip.tsx +16 -1
- package/src/chat/ui/reference-lookup.ts +3 -0
- package/src/chat/ui/thread-references.ts +2 -1
- package/src/host.ts +11 -0
- package/src/index.ts +1 -0
|
@@ -154,7 +154,7 @@ export function TokenChip(t0) {
|
|
|
154
154
|
* `lastName` when the message knows what it was called, with `goneHint` on its tooltip when there is one.
|
|
155
155
|
*/
|
|
156
156
|
export function ReferenceChip(t0) {
|
|
157
|
-
const $ = _c(
|
|
157
|
+
const $ = _c(58);
|
|
158
158
|
const {
|
|
159
159
|
id,
|
|
160
160
|
lastName,
|
|
@@ -165,7 +165,8 @@ export function ReferenceChip(t0) {
|
|
|
165
165
|
} = useTranslation("agent-chat");
|
|
166
166
|
const {
|
|
167
167
|
items,
|
|
168
|
-
open
|
|
168
|
+
open,
|
|
169
|
+
outside
|
|
169
170
|
} = useContext(ReferenceLookupContext);
|
|
170
171
|
const {
|
|
171
172
|
ReferenceIcon
|
|
@@ -178,55 +179,109 @@ export function ReferenceChip(t0) {
|
|
|
178
179
|
let t4;
|
|
179
180
|
let t5;
|
|
180
181
|
let t6;
|
|
181
|
-
if ($[0] !== ReferenceIcon || $[1] !== goneHint || $[2] !== id || $[3] !== items || $[4] !== lastName || $[5] !== t) {
|
|
182
|
+
if ($[0] !== ReferenceIcon || $[1] !== goneHint || $[2] !== id || $[3] !== items || $[4] !== lastName || $[5] !== outside || $[6] !== t) {
|
|
182
183
|
t6 = Symbol.for("react.early_return_sentinel");
|
|
183
184
|
bb0: {
|
|
184
185
|
let t7;
|
|
185
|
-
if ($[
|
|
186
|
+
if ($[15] !== id) {
|
|
186
187
|
t7 = candidate => candidate.id === id;
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
188
|
+
$[15] = id;
|
|
189
|
+
$[16] = t7;
|
|
189
190
|
} else {
|
|
190
|
-
t7 = $[
|
|
191
|
+
t7 = $[16];
|
|
191
192
|
}
|
|
192
193
|
item = items.find(t7);
|
|
194
|
+
const elsewhere = item === undefined ? outside?.(id) ?? null : null;
|
|
195
|
+
if (elsewhere !== null) {
|
|
196
|
+
const opens = elsewhere.open;
|
|
197
|
+
let t8;
|
|
198
|
+
if ($[17] !== elsewhere.icon) {
|
|
199
|
+
t8 = /*#__PURE__*/_jsx(Icon, {
|
|
200
|
+
icon: elsewhere.icon,
|
|
201
|
+
size: 14,
|
|
202
|
+
className: TOKEN_ICON
|
|
203
|
+
});
|
|
204
|
+
$[17] = elsewhere.icon;
|
|
205
|
+
$[18] = t8;
|
|
206
|
+
} else {
|
|
207
|
+
t8 = $[18];
|
|
208
|
+
}
|
|
209
|
+
let t9;
|
|
210
|
+
if ($[19] !== lastName || $[20] !== t) {
|
|
211
|
+
t9 = lastName || t("references.gone");
|
|
212
|
+
$[19] = lastName;
|
|
213
|
+
$[20] = t;
|
|
214
|
+
$[21] = t9;
|
|
215
|
+
} else {
|
|
216
|
+
t9 = $[21];
|
|
217
|
+
}
|
|
218
|
+
const t10 = opens !== null && "hover:bg-text/12";
|
|
219
|
+
let t11;
|
|
220
|
+
if ($[22] !== t10) {
|
|
221
|
+
t11 = clsx(REFERENCE_TONE, t10);
|
|
222
|
+
$[22] = t10;
|
|
223
|
+
$[23] = t11;
|
|
224
|
+
} else {
|
|
225
|
+
t11 = $[23];
|
|
226
|
+
}
|
|
227
|
+
const t12 = opens ?? undefined;
|
|
228
|
+
let t13;
|
|
229
|
+
if ($[24] !== t11 || $[25] !== t12 || $[26] !== t8 || $[27] !== t9) {
|
|
230
|
+
t13 = /*#__PURE__*/_jsx(TokenChip, {
|
|
231
|
+
kind: "gone",
|
|
232
|
+
icon: t8,
|
|
233
|
+
label: t9,
|
|
234
|
+
tone: t11,
|
|
235
|
+
onOpen: t12
|
|
236
|
+
});
|
|
237
|
+
$[24] = t11;
|
|
238
|
+
$[25] = t12;
|
|
239
|
+
$[26] = t8;
|
|
240
|
+
$[27] = t9;
|
|
241
|
+
$[28] = t13;
|
|
242
|
+
} else {
|
|
243
|
+
t13 = $[28];
|
|
244
|
+
}
|
|
245
|
+
t6 = t13;
|
|
246
|
+
break bb0;
|
|
247
|
+
}
|
|
193
248
|
if (item === undefined) {
|
|
194
249
|
let t8;
|
|
195
|
-
if ($[
|
|
250
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
196
251
|
t8 = /*#__PURE__*/_jsx(Icon, {
|
|
197
252
|
icon: CircleOff,
|
|
198
253
|
size: 14,
|
|
199
254
|
className: TOKEN_ICON
|
|
200
255
|
});
|
|
201
|
-
$[
|
|
256
|
+
$[29] = t8;
|
|
202
257
|
} else {
|
|
203
|
-
t8 = $[
|
|
258
|
+
t8 = $[29];
|
|
204
259
|
}
|
|
205
260
|
let t9;
|
|
206
|
-
if ($[
|
|
261
|
+
if ($[30] !== lastName || $[31] !== t) {
|
|
207
262
|
t9 = lastName || t("references.gone");
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
263
|
+
$[30] = lastName;
|
|
264
|
+
$[31] = t;
|
|
265
|
+
$[32] = t9;
|
|
211
266
|
} else {
|
|
212
|
-
t9 = $[
|
|
267
|
+
t9 = $[32];
|
|
213
268
|
}
|
|
214
269
|
let t10;
|
|
215
|
-
if ($[
|
|
270
|
+
if ($[33] !== t9) {
|
|
216
271
|
t10 = /*#__PURE__*/_jsx(TokenChip, {
|
|
217
272
|
kind: "gone",
|
|
218
273
|
icon: t8,
|
|
219
274
|
label: t9,
|
|
220
275
|
tone: REFERENCE_GONE_TONE
|
|
221
276
|
});
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
277
|
+
$[33] = t9;
|
|
278
|
+
$[34] = t10;
|
|
224
279
|
} else {
|
|
225
|
-
t10 = $[
|
|
280
|
+
t10 = $[34];
|
|
226
281
|
}
|
|
227
282
|
const chip = t10;
|
|
228
283
|
let t11;
|
|
229
|
-
if ($[
|
|
284
|
+
if ($[35] !== chip || $[36] !== goneHint) {
|
|
230
285
|
t11 = goneHint === undefined ? chip : /*#__PURE__*/_jsx(Tooltip, {
|
|
231
286
|
label: goneHint,
|
|
232
287
|
children: /*#__PURE__*/_jsx("span", {
|
|
@@ -234,11 +289,11 @@ export function ReferenceChip(t0) {
|
|
|
234
289
|
children: chip
|
|
235
290
|
})
|
|
236
291
|
});
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
292
|
+
$[35] = chip;
|
|
293
|
+
$[36] = goneHint;
|
|
294
|
+
$[37] = t11;
|
|
240
295
|
} else {
|
|
241
|
-
t11 = $[
|
|
296
|
+
t11 = $[37];
|
|
242
297
|
}
|
|
243
298
|
t6 = t11;
|
|
244
299
|
break bb0;
|
|
@@ -265,68 +320,69 @@ export function ReferenceChip(t0) {
|
|
|
265
320
|
$[2] = id;
|
|
266
321
|
$[3] = items;
|
|
267
322
|
$[4] = lastName;
|
|
268
|
-
$[5] =
|
|
269
|
-
$[6] =
|
|
270
|
-
$[7] =
|
|
271
|
-
$[8] =
|
|
272
|
-
$[9] =
|
|
273
|
-
$[10] =
|
|
274
|
-
$[11] =
|
|
275
|
-
$[12] =
|
|
276
|
-
$[13] =
|
|
323
|
+
$[5] = outside;
|
|
324
|
+
$[6] = t;
|
|
325
|
+
$[7] = T0;
|
|
326
|
+
$[8] = item;
|
|
327
|
+
$[9] = t1;
|
|
328
|
+
$[10] = t2;
|
|
329
|
+
$[11] = t3;
|
|
330
|
+
$[12] = t4;
|
|
331
|
+
$[13] = t5;
|
|
332
|
+
$[14] = t6;
|
|
277
333
|
} else {
|
|
278
|
-
T0 = $[
|
|
279
|
-
item = $[
|
|
280
|
-
t1 = $[
|
|
281
|
-
t2 = $[
|
|
282
|
-
t3 = $[
|
|
283
|
-
t4 = $[
|
|
284
|
-
t5 = $[
|
|
285
|
-
t6 = $[
|
|
334
|
+
T0 = $[7];
|
|
335
|
+
item = $[8];
|
|
336
|
+
t1 = $[9];
|
|
337
|
+
t2 = $[10];
|
|
338
|
+
t3 = $[11];
|
|
339
|
+
t4 = $[12];
|
|
340
|
+
t5 = $[13];
|
|
341
|
+
t6 = $[14];
|
|
286
342
|
}
|
|
287
343
|
if (t6 !== Symbol.for("react.early_return_sentinel")) {
|
|
288
344
|
return t6;
|
|
289
345
|
}
|
|
290
346
|
let t7;
|
|
291
|
-
if ($[
|
|
347
|
+
if ($[38] !== t1 || $[39] !== t2) {
|
|
292
348
|
t7 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
293
349
|
children: [t1, t2]
|
|
294
350
|
});
|
|
295
|
-
$[
|
|
296
|
-
$[
|
|
297
|
-
$[
|
|
351
|
+
$[38] = t1;
|
|
352
|
+
$[39] = t2;
|
|
353
|
+
$[40] = t7;
|
|
298
354
|
} else {
|
|
299
|
-
t7 = $[
|
|
355
|
+
t7 = $[40];
|
|
300
356
|
}
|
|
301
357
|
let t8;
|
|
302
|
-
if ($[
|
|
358
|
+
if ($[41] !== item.name || $[42] !== t) {
|
|
303
359
|
t8 = item.name || t("references.untitled");
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
360
|
+
$[41] = item.name;
|
|
361
|
+
$[42] = t;
|
|
362
|
+
$[43] = t8;
|
|
307
363
|
} else {
|
|
308
|
-
t8 = $[
|
|
364
|
+
t8 = $[43];
|
|
309
365
|
}
|
|
310
366
|
const t9 = open !== null && "hover:bg-text/12";
|
|
311
367
|
let t10;
|
|
312
|
-
if ($[
|
|
368
|
+
if ($[44] !== t9) {
|
|
313
369
|
t10 = clsx(REFERENCE_TONE, t9);
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
370
|
+
$[44] = t9;
|
|
371
|
+
$[45] = t10;
|
|
316
372
|
} else {
|
|
317
|
-
t10 = $[
|
|
373
|
+
t10 = $[45];
|
|
318
374
|
}
|
|
319
375
|
let t11;
|
|
320
|
-
if ($[
|
|
376
|
+
if ($[46] !== item.id || $[47] !== open) {
|
|
321
377
|
t11 = open === null ? undefined : () => open(item.id);
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
$[
|
|
378
|
+
$[46] = item.id;
|
|
379
|
+
$[47] = open;
|
|
380
|
+
$[48] = t11;
|
|
325
381
|
} else {
|
|
326
|
-
t11 = $[
|
|
382
|
+
t11 = $[48];
|
|
327
383
|
}
|
|
328
384
|
let t12;
|
|
329
|
-
if ($[
|
|
385
|
+
if ($[49] !== T0 || $[50] !== t10 || $[51] !== t11 || $[52] !== t3 || $[53] !== t4 || $[54] !== t5 || $[55] !== t7 || $[56] !== t8) {
|
|
330
386
|
t12 = /*#__PURE__*/_jsx(T0, {
|
|
331
387
|
kind: t3,
|
|
332
388
|
value: t4,
|
|
@@ -336,17 +392,17 @@ export function ReferenceChip(t0) {
|
|
|
336
392
|
tone: t10,
|
|
337
393
|
onOpen: t11
|
|
338
394
|
});
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
$[
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[
|
|
395
|
+
$[49] = T0;
|
|
396
|
+
$[50] = t10;
|
|
397
|
+
$[51] = t11;
|
|
398
|
+
$[52] = t3;
|
|
399
|
+
$[53] = t4;
|
|
400
|
+
$[54] = t5;
|
|
401
|
+
$[55] = t7;
|
|
402
|
+
$[56] = t8;
|
|
403
|
+
$[57] = t12;
|
|
348
404
|
} else {
|
|
349
|
-
t12 = $[
|
|
405
|
+
t12 = $[57];
|
|
350
406
|
}
|
|
351
407
|
return t12;
|
|
352
408
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { OutsideReference } from '../../host.js';
|
|
1
2
|
import type { Referable } from '../chat-references.js';
|
|
2
3
|
export interface ReferenceLookup {
|
|
3
4
|
items: readonly Referable[];
|
|
4
5
|
open: ((id: string) => void) | null;
|
|
6
|
+
outside?(id: string): OutsideReference | null;
|
|
5
7
|
referenced?: readonly string[];
|
|
6
8
|
}
|
|
7
9
|
export declare const ReferenceLookupContext: import("react").Context<ReferenceLookup>;
|
|
@@ -35,9 +35,10 @@ export function useReferenceLookup(chatId) {
|
|
|
35
35
|
}
|
|
36
36
|
/* The same for a row that may stand outside a scope. */
|
|
37
37
|
export function useReferenceLookupIn(scopeId, chatId) {
|
|
38
|
-
const $ = _c(
|
|
38
|
+
const $ = _c(13);
|
|
39
39
|
const {
|
|
40
|
-
openReference
|
|
40
|
+
openReference,
|
|
41
|
+
outsideReference
|
|
41
42
|
} = useChatHost();
|
|
42
43
|
const referables = useHostReferables(scopeId, chatId);
|
|
43
44
|
const key = useChatRow(chatId, _temp);
|
|
@@ -51,28 +52,41 @@ export function useReferenceLookupIn(scopeId, chatId) {
|
|
|
51
52
|
t0 = $[2];
|
|
52
53
|
}
|
|
53
54
|
let t1;
|
|
54
|
-
if ($[3] !==
|
|
55
|
-
t1 =
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if ($[3] !== outsideReference || $[4] !== scopeId) {
|
|
56
|
+
t1 = outsideReference ? {
|
|
57
|
+
outside: id_0 => outsideReference(scopeId, id_0)
|
|
58
|
+
} : {};
|
|
59
|
+
$[3] = outsideReference;
|
|
60
|
+
$[4] = scopeId;
|
|
61
|
+
$[5] = t1;
|
|
58
62
|
} else {
|
|
59
|
-
t1 = $[
|
|
63
|
+
t1 = $[5];
|
|
60
64
|
}
|
|
61
65
|
let t2;
|
|
62
|
-
if ($[
|
|
63
|
-
t2 =
|
|
66
|
+
if ($[6] !== key) {
|
|
67
|
+
t2 = key === "" ? [] : key.split("\n");
|
|
68
|
+
$[6] = key;
|
|
69
|
+
$[7] = t2;
|
|
70
|
+
} else {
|
|
71
|
+
t2 = $[7];
|
|
72
|
+
}
|
|
73
|
+
let t3;
|
|
74
|
+
if ($[8] !== referables.items || $[9] !== t0 || $[10] !== t1 || $[11] !== t2) {
|
|
75
|
+
t3 = {
|
|
64
76
|
items: referables.items,
|
|
65
77
|
open: t0,
|
|
66
|
-
|
|
78
|
+
...t1,
|
|
79
|
+
referenced: t2
|
|
67
80
|
};
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
81
|
+
$[8] = referables.items;
|
|
82
|
+
$[9] = t0;
|
|
83
|
+
$[10] = t1;
|
|
84
|
+
$[11] = t2;
|
|
85
|
+
$[12] = t3;
|
|
72
86
|
} else {
|
|
73
|
-
|
|
87
|
+
t3 = $[12];
|
|
74
88
|
}
|
|
75
|
-
return
|
|
89
|
+
return t3;
|
|
76
90
|
}
|
|
77
91
|
function _temp(chat) {
|
|
78
92
|
return threadReferencedKey(chat?.structure);
|
package/dist/host.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ export interface ReferenceIconProps {
|
|
|
118
118
|
size: number;
|
|
119
119
|
className?: string;
|
|
120
120
|
}
|
|
121
|
+
export interface OutsideReference {
|
|
122
|
+
icon: LucideIcon;
|
|
123
|
+
open: (() => void) | null;
|
|
124
|
+
}
|
|
121
125
|
export interface ComposerHeaderSlotProps {
|
|
122
126
|
scopeId: string;
|
|
123
127
|
chatId: string;
|
|
@@ -374,6 +378,7 @@ export interface ChatHost {
|
|
|
374
378
|
useReferables?(scopeId: string, chatId: string): Referables;
|
|
375
379
|
ReferenceIcon?: ComponentType<ReferenceIconProps> | null;
|
|
376
380
|
openReference?(scopeId: string, id: string): void;
|
|
381
|
+
outsideReference?(scopeId: string, id: string): OutsideReference | null;
|
|
377
382
|
openLogin: ((scopeId: string, kind: AgentKind, accountId: string, name: string) => Promise<void>) | null;
|
|
378
383
|
useLoginBlocked(scopeId: string): string | null;
|
|
379
384
|
useCanReorderAccounts?(scopeId: string): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type ComposerSendAction, type ComposerSendDraft, type ComposerStatusDetail, type ComposerStatusItem, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, useChatHost, type AccentChoice, type ChatToast, type TextareaProps, type ResourceUrl } from './host.js';
|
|
1
|
+
export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type OutsideReference, type ComposerSendAction, type ComposerSendDraft, type ComposerStatusDetail, type ComposerStatusItem, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, useChatHost, type AccentChoice, type ChatToast, type TextareaProps, type ResourceUrl } from './host.js';
|
|
2
2
|
export { type ChatScope, ChatScopeContext, useChatScope } from './scope.js';
|
|
3
3
|
export { type ChatRequestMap, type ChatEventMap, type ChatTransportStatus, type ChatTransport, ChatTransportError, errorCode, isConnectionError } from './transport.js';
|
|
4
4
|
export { portTransport, type PortTransport } from './port-transport.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
80
|
-
"@adecore/utils": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.62.0",
|
|
76
|
+
"@adecore/editor": "0.62.0",
|
|
77
|
+
"@adecore/editor-react": "0.62.0",
|
|
78
|
+
"@adecore/intelligent-ui": "0.62.0",
|
|
79
|
+
"@adecore/merge": "0.62.0",
|
|
80
|
+
"@adecore/utils": "0.62.0",
|
|
81
81
|
"@codemirror/commands": "^6.11.1",
|
|
82
82
|
"@codemirror/language": "^6.13.1",
|
|
83
83
|
"@codemirror/state": "^6.7.6",
|
|
@@ -101,14 +101,14 @@
|
|
|
101
101
|
"zustand": "^5.0.16"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@adecore/ui": "^0.
|
|
104
|
+
"@adecore/ui": "^0.62.0",
|
|
105
105
|
"i18next": "^26.4.2",
|
|
106
106
|
"react": "^19.3.0",
|
|
107
107
|
"react-dom": "^19.3.0",
|
|
108
108
|
"react-i18next": "^17.0.15"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@adecore/ui": "0.
|
|
111
|
+
"@adecore/ui": "0.62.0",
|
|
112
112
|
"@types/bun": "^1.4.4",
|
|
113
113
|
"@types/react": "^19.3.0",
|
|
114
114
|
"@types/react-dom": "^19.3.0",
|
|
@@ -77,9 +77,24 @@ export function TokenChip({ kind, value, sigil, icon, label, spelled, tone, onOp
|
|
|
77
77
|
*/
|
|
78
78
|
export function ReferenceChip({ id, lastName, goneHint }: { id: string; lastName?: string; goneHint?: string }) {
|
|
79
79
|
const { t } = useTranslation('agent-chat');
|
|
80
|
-
const { items, open } = useContext(ReferenceLookupContext);
|
|
80
|
+
const { items, open, outside } = useContext(ReferenceLookupContext);
|
|
81
81
|
const { ReferenceIcon } = useChatHost();
|
|
82
82
|
const item = items.find((candidate) => candidate.id === id);
|
|
83
|
+
const elsewhere = item === undefined ? (outside?.(id) ?? null) : null;
|
|
84
|
+
|
|
85
|
+
if (elsewhere !== null) {
|
|
86
|
+
const opens = elsewhere.open;
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<TokenChip
|
|
90
|
+
kind="gone"
|
|
91
|
+
icon={<Icon icon={elsewhere.icon} size={14} className={TOKEN_ICON} />}
|
|
92
|
+
label={lastName || t('references.gone')}
|
|
93
|
+
tone={clsx(REFERENCE_TONE, opens !== null && 'hover:bg-text/12')}
|
|
94
|
+
onOpen={opens ?? undefined}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
83
98
|
|
|
84
99
|
if (item === undefined) {
|
|
85
100
|
const chip = (
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
+
import type { OutsideReference } from '../../host';
|
|
2
3
|
import type { Referable } from '../chat-references';
|
|
3
4
|
|
|
4
5
|
export interface ReferenceLookup {
|
|
5
6
|
items: readonly Referable[];
|
|
6
7
|
/* Null where the host opens nothing. */
|
|
7
8
|
open: ((id: string) => void) | null;
|
|
9
|
+
/* What an id that is none of `items` still stands for; absent, or null, where it stands for nothing. */
|
|
10
|
+
outside?(id: string): OutsideReference | null;
|
|
8
11
|
/* What a person pointed at with `#` in this thread, which a reply wins over another of the same name. */
|
|
9
12
|
referenced?: readonly string[];
|
|
10
13
|
}
|
|
@@ -46,13 +46,14 @@ export function useReferenceLookup(chatId: string): ReferenceLookup {
|
|
|
46
46
|
|
|
47
47
|
/* The same for a row that may stand outside a scope. */
|
|
48
48
|
export function useReferenceLookupIn(scopeId: string, chatId: string): ReferenceLookup {
|
|
49
|
-
const { openReference } = useChatHost();
|
|
49
|
+
const { openReference, outsideReference } = useChatHost();
|
|
50
50
|
const referables = useHostReferables(scopeId, chatId);
|
|
51
51
|
const key = useChatRow(chatId, (chat) => threadReferencedKey(chat?.structure));
|
|
52
52
|
|
|
53
53
|
return {
|
|
54
54
|
items: referables.items,
|
|
55
55
|
open: openReference ? (id: string) => openReference(scopeId, id) : null,
|
|
56
|
+
...(outsideReference ? { outside: (id: string) => outsideReference(scopeId, id) } : {}),
|
|
56
57
|
referenced: key === '' ? [] : key.split('\n')
|
|
57
58
|
};
|
|
58
59
|
}
|
package/src/host.ts
CHANGED
|
@@ -191,6 +191,12 @@ export interface ReferenceIconProps {
|
|
|
191
191
|
className?: string;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/* What a chip of an id that is no view or node still stands for, such as a sender from outside: its mark, and what clicking it opens. */
|
|
195
|
+
export interface OutsideReference {
|
|
196
|
+
icon: LucideIcon;
|
|
197
|
+
open: (() => void) | null;
|
|
198
|
+
}
|
|
199
|
+
|
|
194
200
|
/* What an app's own bar over the composer gets: the chat it stands on, which may be one the bar has nothing for. */
|
|
195
201
|
export interface ComposerHeaderSlotProps {
|
|
196
202
|
scopeId: string;
|
|
@@ -589,6 +595,11 @@ export interface ChatHost {
|
|
|
589
595
|
ReferenceIcon?: ComponentType<ReferenceIconProps> | null;
|
|
590
596
|
/* Opens a view or zooms to a node a message points at; left out, a chip opens nothing. */
|
|
591
597
|
openReference?(scopeId: string, id: string): void;
|
|
598
|
+
/*
|
|
599
|
+
* What an id among no `useReferables` items stands for, such as a sender from outside, which keeps the name its
|
|
600
|
+
* message gave it. Null, or left out, draws the chip as gone.
|
|
601
|
+
*/
|
|
602
|
+
outsideReference?(scopeId: string, id: string): OutsideReference | null;
|
|
592
603
|
/* Opens the CLI's own login for an account, somewhere the app can run a command; null offers none. */
|
|
593
604
|
openLogin: ((scopeId: string, kind: AgentKind, accountId: string, name: string) => Promise<void>) | null;
|
|
594
605
|
/* Why a login cannot start from here right now, or null when it can. */
|