@adecore/agents-react 0.37.2 → 0.38.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/chat-client.d.ts +1 -0
- package/dist/chat/chat-client.js +2 -1
- package/dist/chat/chat-references.d.ts +16 -1
- package/dist/chat/chat-references.js +29 -3
- package/dist/chat/drafts.d.ts +2 -0
- package/dist/chat/drafts.js +21 -5
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/logic/visual-height.d.ts +1 -0
- package/dist/chat/logic/visual-height.js +1 -1
- package/dist/chat/mentions.d.ts +31 -14
- package/dist/chat/mentions.js +186 -41
- package/dist/chat/stash.d.ts +1 -0
- package/dist/chat/stash.js +4 -2
- package/dist/chat/ui/Composer.js +438 -429
- package/dist/chat/ui/ComposerInput.d.ts +1 -0
- package/dist/chat/ui/ComposerInput.js +2 -0
- package/dist/chat/ui/HostMenuItems.d.ts +4 -0
- package/dist/chat/ui/HostMenuItems.js +15 -0
- package/dist/chat/ui/Markdown.d.ts +3 -1
- package/dist/chat/ui/Markdown.js +194 -120
- package/dist/chat/ui/MessageActions.js +70 -66
- package/dist/chat/ui/ReferenceChip.d.ts +15 -0
- package/dist/chat/ui/ReferenceChip.js +255 -0
- package/dist/chat/ui/Timeline.js +52 -29
- package/dist/chat/ui/TimelineMenu.js +84 -78
- package/dist/chat/ui/VisualFrame.d.ts +8 -0
- package/dist/chat/ui/VisualFrame.js +217 -115
- package/dist/chat/ui/chip-clipboard.d.ts +9 -0
- package/dist/chat/ui/chip-clipboard.js +105 -0
- package/dist/chat/ui/chips.d.ts +5 -0
- package/dist/chat/ui/chips.js +15 -1
- package/dist/chat/ui/composer/ComposerMenu.js +140 -79
- package/dist/chat/ui/composer/DraftParts.d.ts +0 -4
- package/dist/chat/ui/composer/DraftParts.js +0 -41
- package/dist/chat/ui/composer/chip-paste.d.ts +15 -0
- package/dist/chat/ui/composer/chip-paste.js +104 -0
- package/dist/chat/ui/composer/chips.d.ts +5 -0
- package/dist/chat/ui/composer/chips.js +59 -9
- package/dist/chat/ui/composer/key-handler.js +9 -0
- package/dist/chat/ui/composer/use-composer-draft.d.ts +0 -1
- package/dist/chat/ui/composer/use-composer-draft.js +2 -10
- package/dist/chat/ui/composer/use-composer-menus.d.ts +12 -2
- package/dist/chat/ui/composer/use-composer-menus.js +192 -149
- package/dist/chat/ui/composer/use-composer-submit.js +17 -12
- package/dist/chat/ui/composer/use-draft-files.d.ts +7 -1
- package/dist/chat/ui/composer/use-draft-files.js +90 -58
- package/dist/chat/ui/composer/use-take-back.js +2 -1
- package/dist/chat/ui/index.d.ts +1 -1
- package/dist/chat/ui/index.js +1 -1
- package/dist/chat/ui/reference-icons.d.ts +3 -0
- package/dist/chat/ui/reference-icons.js +15 -0
- package/dist/chat/ui/reference-lookup.d.ts +7 -0
- package/dist/chat/ui/reference-lookup.js +6 -0
- package/dist/chat/ui/rehype-chips.d.ts +8 -1
- package/dist/chat/ui/rehype-chips.js +35 -11
- package/dist/chat/ui/rows/GeneratedImageRow.js +8 -4
- package/dist/chat/ui/rows/MessageRows.js +218 -158
- package/dist/chat/ui/rows/VisualRow.js +184 -142
- package/dist/chat/ui/rows/row-rhythm.js +6 -4
- package/dist/chat/ui/thread-references.d.ts +4 -0
- package/dist/chat/ui/thread-references.js +78 -0
- package/dist/host-hooks.d.ts +2 -0
- package/dist/host-hooks.js +7 -0
- package/dist/host.d.ts +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +20 -3
- package/dist/locales/en/agent-chat.js +24 -7
- package/dist/locales/nl/agent-chat.d.ts +20 -3
- package/dist/locales/nl/agent-chat.js +24 -7
- package/package.json +8 -8
- package/src/chat/chat-client.ts +4 -1
- package/src/chat/chat-references.ts +44 -3
- package/src/chat/drafts.ts +24 -6
- package/src/chat/index.ts +1 -1
- package/src/chat/logic/visual-height.ts +1 -1
- package/src/chat/mentions.ts +202 -36
- package/src/chat/stash.ts +6 -2
- package/src/chat/ui/Composer.tsx +14 -4
- package/src/chat/ui/ComposerInput.tsx +4 -0
- package/src/chat/ui/HostMenuItems.tsx +11 -0
- package/src/chat/ui/Markdown.tsx +57 -25
- package/src/chat/ui/MessageActions.tsx +5 -2
- package/src/chat/ui/ReferenceChip.tsx +74 -0
- package/src/chat/ui/Timeline.tsx +24 -2
- package/src/chat/ui/TimelineMenu.tsx +7 -3
- package/src/chat/ui/VisualFrame.tsx +68 -21
- package/src/chat/ui/chip-clipboard.ts +115 -0
- package/src/chat/ui/chips.ts +20 -1
- package/src/chat/ui/composer/ComposerMenu.tsx +53 -37
- package/src/chat/ui/composer/DraftParts.tsx +0 -12
- package/src/chat/ui/composer/chip-paste.ts +122 -0
- package/src/chat/ui/composer/chips.ts +60 -10
- package/src/chat/ui/composer/key-handler.ts +9 -0
- package/src/chat/ui/composer/use-composer-draft.ts +1 -7
- package/src/chat/ui/composer/use-composer-menus.ts +68 -29
- package/src/chat/ui/composer/use-composer-submit.ts +13 -6
- package/src/chat/ui/composer/use-draft-files.ts +39 -5
- package/src/chat/ui/composer/use-take-back.ts +2 -1
- package/src/chat/ui/index.ts +1 -1
- package/src/chat/ui/reference-icons.ts +17 -0
- package/src/chat/ui/reference-lookup.ts +13 -0
- package/src/chat/ui/rehype-chips.ts +38 -13
- package/src/chat/ui/rows/GeneratedImageRow.tsx +9 -4
- package/src/chat/ui/rows/MessageRows.tsx +88 -64
- package/src/chat/ui/rows/VisualRow.tsx +5 -1
- package/src/chat/ui/rows/row-rhythm.ts +6 -4
- package/src/chat/ui/thread-references.ts +47 -0
- package/src/host-hooks.ts +9 -0
- package/src/host.ts +24 -1
- package/src/index.ts +1 -0
- package/src/locales/en/agent-chat.ts +24 -7
- package/src/locales/nl/agent-chat.ts +24 -7
- package/dist/chat/ui/ChatReferenceChip.d.ts +0 -4
- package/dist/chat/ui/ChatReferenceChip.js +0 -110
- package/src/chat/ui/ChatReferenceChip.tsx +0 -26
|
@@ -4,28 +4,28 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { ensureSyntaxTree, syntaxTree } from '@codemirror/language';
|
|
5
5
|
import { useChatHost } from '../../../host.js';
|
|
6
6
|
import { useChatScope } from '../../../scope.js';
|
|
7
|
-
import {
|
|
7
|
+
import { referenceSuggestions, referenceTokens } from '../../chat-references.js';
|
|
8
8
|
import { usableSlashCommands } from '../../guards.js';
|
|
9
|
-
import {
|
|
9
|
+
import { chipRanges, findMentionQuery, findReferenceQuery, findSkillQuery, insertMention, insertReference, insertSkill, mentionPick, NO_MENTION_SEARCH, queryOutsideChips } from '../../mentions.js';
|
|
10
10
|
import { inCode } from './keys.js';
|
|
11
11
|
import { clampMenuIndex, composerMenuAria } from './menu-aria.js';
|
|
12
|
-
import {
|
|
12
|
+
import { useHostReferables } from '../../../host-hooks.js';
|
|
13
13
|
const SEARCH_DEBOUNCE_MS = 80;
|
|
14
14
|
// What fits above the composer without turning the picker into a file tree.
|
|
15
15
|
const MENTION_RESULTS = 8;
|
|
16
|
-
|
|
17
|
-
const CHAT_RESULTS = 4;
|
|
16
|
+
const REFERENCE_RESULTS = 8;
|
|
18
17
|
// Commands the composer handles itself; the CLI's own ones are sent through as text.
|
|
19
18
|
export const LOCAL_COMMANDS = ['model', 'compact', 'clear'];
|
|
20
19
|
function sameQuery(left, right) {
|
|
21
20
|
return left?.start === right?.start && left?.query === right?.query;
|
|
22
21
|
}
|
|
23
22
|
/*
|
|
24
|
-
* The pickers over the box: `/` for a command, `$` for a skill
|
|
25
|
-
* One is open at a time, and the arrow keys and the editor's ARIA attributes
|
|
23
|
+
* The pickers over the box: `/` for a command, `$` for a skill, `@` for a file and `#` for a view,
|
|
24
|
+
* a node or another chat. One is open at a time, and the arrow keys and the editor's ARIA attributes
|
|
25
|
+
* follow that one.
|
|
26
26
|
*/
|
|
27
27
|
export function useComposerMenus(t0) {
|
|
28
|
-
const $ = _c(
|
|
28
|
+
const $ = _c(110);
|
|
29
29
|
const {
|
|
30
30
|
chatId,
|
|
31
31
|
info,
|
|
@@ -47,9 +47,10 @@ export function useComposerMenus(t0) {
|
|
|
47
47
|
const {
|
|
48
48
|
searchFiles
|
|
49
49
|
} = host;
|
|
50
|
-
const
|
|
50
|
+
const referables = useHostReferables(scope.id, chatId);
|
|
51
51
|
const [menuIndex, setMenuIndex] = useState(0);
|
|
52
52
|
const [mention, setMention] = useState(null);
|
|
53
|
+
const [referenceQuery, setReferenceQuery] = useState(null);
|
|
53
54
|
const [skillQuery, setSkillQuery] = useState(null);
|
|
54
55
|
let t2;
|
|
55
56
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -242,97 +243,102 @@ export function useComposerMenus(t0) {
|
|
|
242
243
|
const commandMenuOpen = commandQuery !== null && commands.length > 0;
|
|
243
244
|
const skillMenuOpen = !commandMenuOpen && skillQuery !== null && skillMatches.length > 0;
|
|
244
245
|
const mentionMenuOpen = !commandMenuOpen && !skillMenuOpen && mention !== null;
|
|
246
|
+
const files_0 = mention === null ? [] : searched.files;
|
|
247
|
+
const mentionCount = files_0.length;
|
|
245
248
|
let t10;
|
|
246
|
-
if ($[35] !==
|
|
247
|
-
t10 =
|
|
248
|
-
$[35] =
|
|
249
|
-
$[36] =
|
|
250
|
-
$[37] = t10;
|
|
249
|
+
if ($[35] !== referables.chatsOnly) {
|
|
250
|
+
t10 = item => !referables.chatsOnly || item.kind === "chat";
|
|
251
|
+
$[35] = referables.chatsOnly;
|
|
252
|
+
$[36] = t10;
|
|
251
253
|
} else {
|
|
252
|
-
t10 = $[
|
|
254
|
+
t10 = $[36];
|
|
253
255
|
}
|
|
254
|
-
const
|
|
256
|
+
const offersReferences = referables.items.some(t10);
|
|
257
|
+
const referenceMenuOpen = !commandMenuOpen && !skillMenuOpen && !mentionMenuOpen && referenceQuery !== null && offersReferences;
|
|
258
|
+
const referenceMatches = referenceMenuOpen ? referenceSuggestions(referables, referenceQuery.query, [chatId, ...draft.chats, ...draft.references], REFERENCE_RESULTS) : [];
|
|
255
259
|
let t11;
|
|
256
|
-
if ($[
|
|
257
|
-
|
|
258
|
-
$[
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
if ($[37] !== draft.chats || $[38] !== draft.referenceNames || $[39] !== draft.references || $[40] !== referables.items) {
|
|
261
|
+
let t12;
|
|
262
|
+
if ($[42] !== referables.items) {
|
|
263
|
+
t12 = token => ({
|
|
264
|
+
...token,
|
|
265
|
+
kind: referables.items.find(item_0 => item_0.id === token.id)?.kind ?? null
|
|
266
|
+
});
|
|
267
|
+
$[42] = referables.items;
|
|
268
|
+
$[43] = t12;
|
|
269
|
+
} else {
|
|
270
|
+
t12 = $[43];
|
|
271
|
+
}
|
|
272
|
+
t11 = referenceTokens([...draft.chats, ...draft.references], referables.items, draft.referenceNames).map(t12);
|
|
273
|
+
$[37] = draft.chats;
|
|
274
|
+
$[38] = draft.referenceNames;
|
|
275
|
+
$[39] = draft.references;
|
|
276
|
+
$[40] = referables.items;
|
|
277
|
+
$[41] = t11;
|
|
263
278
|
} else {
|
|
264
|
-
t11 = $[
|
|
279
|
+
t11 = $[41];
|
|
265
280
|
}
|
|
266
|
-
const
|
|
267
|
-
const mentionCount = chatMatches.length + files_0.length;
|
|
281
|
+
const referenceChips = t11;
|
|
268
282
|
const listId = useId();
|
|
269
|
-
const menuOpen = commandMenuOpen || skillMenuOpen || mentionMenuOpen;
|
|
270
|
-
const menuCount = commandMenuOpen ? commands.length : skillMenuOpen ? skillMatches.length : mentionCount;
|
|
271
|
-
|
|
283
|
+
const menuOpen = commandMenuOpen || skillMenuOpen || mentionMenuOpen || referenceMenuOpen;
|
|
284
|
+
const menuCount = commandMenuOpen ? commands.length : skillMenuOpen ? skillMatches.length : mentionMenuOpen ? mentionCount : referenceMatches.length;
|
|
285
|
+
const activeIndex = clampMenuIndex(menuIndex, menuCount);
|
|
286
|
+
const inputAria = composerMenuAria({
|
|
287
|
+
label: t("composer.inputLabel"),
|
|
288
|
+
listId,
|
|
289
|
+
open: menuOpen,
|
|
290
|
+
activeIndex,
|
|
291
|
+
count: menuCount
|
|
292
|
+
});
|
|
272
293
|
let t12;
|
|
273
|
-
if ($[
|
|
274
|
-
|
|
275
|
-
t12 = composerMenuAria({
|
|
276
|
-
label: t("composer.inputLabel"),
|
|
277
|
-
listId,
|
|
278
|
-
open: menuOpen,
|
|
279
|
-
activeIndex,
|
|
280
|
-
count: menuCount
|
|
281
|
-
});
|
|
282
|
-
$[43] = listId;
|
|
283
|
-
$[44] = menuCount;
|
|
284
|
-
$[45] = menuIndex;
|
|
285
|
-
$[46] = menuOpen;
|
|
286
|
-
$[47] = t;
|
|
287
|
-
$[48] = activeIndex;
|
|
288
|
-
$[49] = t12;
|
|
289
|
-
} else {
|
|
290
|
-
activeIndex = $[48];
|
|
291
|
-
t12 = $[49];
|
|
292
|
-
}
|
|
293
|
-
const inputAria = t12;
|
|
294
|
-
let t13;
|
|
295
|
-
if ($[50] !== capabilities?.mentions) {
|
|
296
|
-
t13 = (value, selection, state) => {
|
|
294
|
+
if ($[44] !== capabilities?.mentions || $[45] !== draft.mentions || $[46] !== draft.skills || $[47] !== referenceChips) {
|
|
295
|
+
t12 = (value, selection, state) => {
|
|
297
296
|
const empty = selection.from === selection.to;
|
|
298
297
|
const tree = empty ? ensureSyntaxTree(state, selection.from, 50) ?? syntaxTree(state) : null;
|
|
299
298
|
const caret = tree !== null && !inCode(tree, value, selection.from) ? selection.from : null;
|
|
300
|
-
const
|
|
299
|
+
const chips = caret === null ? [] : chipRanges(value, draft.mentions, draft.skills, [], referenceChips);
|
|
300
|
+
const skill_1 = caret === null ? null : queryOutsideChips(findSkillQuery(value, caret), chips);
|
|
301
301
|
setSkillQuery(current => sameQuery(current, skill_1) ? current : skill_1);
|
|
302
|
-
const next = caret === null || capabilities?.mentions === false ? null : findMentionQuery(value, caret);
|
|
302
|
+
const next = caret === null || capabilities?.mentions === false ? null : queryOutsideChips(findMentionQuery(value, caret), chips);
|
|
303
303
|
setMention(current_0 => sameQuery(current_0, next) ? current_0 : next);
|
|
304
|
+
const reference = caret === null ? null : queryOutsideChips(findReferenceQuery(value, caret), chips);
|
|
305
|
+
setReferenceQuery(current_1 => sameQuery(current_1, reference) ? current_1 : reference);
|
|
304
306
|
};
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
307
|
+
$[44] = capabilities?.mentions;
|
|
308
|
+
$[45] = draft.mentions;
|
|
309
|
+
$[46] = draft.skills;
|
|
310
|
+
$[47] = referenceChips;
|
|
311
|
+
$[48] = t12;
|
|
307
312
|
} else {
|
|
308
|
-
|
|
313
|
+
t12 = $[48];
|
|
309
314
|
}
|
|
310
|
-
const trackTriggers =
|
|
311
|
-
let
|
|
312
|
-
if ($[
|
|
313
|
-
|
|
315
|
+
const trackTriggers = t12;
|
|
316
|
+
let t13;
|
|
317
|
+
if ($[49] !== inputRef) {
|
|
318
|
+
t13 = caret_0 => {
|
|
314
319
|
requestAnimationFrame(() => inputRef.current?.setCaret(caret_0));
|
|
315
320
|
};
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
321
|
+
$[49] = inputRef;
|
|
322
|
+
$[50] = t13;
|
|
318
323
|
} else {
|
|
319
|
-
|
|
324
|
+
t13 = $[50];
|
|
320
325
|
}
|
|
321
|
-
const moveCaret =
|
|
322
|
-
let
|
|
323
|
-
if ($[
|
|
324
|
-
|
|
326
|
+
const moveCaret = t13;
|
|
327
|
+
let t14;
|
|
328
|
+
if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
|
|
329
|
+
t14 = () => {
|
|
325
330
|
setMention(null);
|
|
326
331
|
setSkillQuery(null);
|
|
332
|
+
setReferenceQuery(null);
|
|
327
333
|
};
|
|
328
|
-
$[
|
|
334
|
+
$[51] = t14;
|
|
329
335
|
} else {
|
|
330
|
-
|
|
336
|
+
t14 = $[51];
|
|
331
337
|
}
|
|
332
|
-
const close =
|
|
333
|
-
let
|
|
334
|
-
if ($[
|
|
335
|
-
|
|
338
|
+
const close = t14;
|
|
339
|
+
let t15;
|
|
340
|
+
if ($[52] !== draft.mentions || $[53] !== mention || $[54] !== moveCaret || $[55] !== setText || $[56] !== text) {
|
|
341
|
+
t15 = path => {
|
|
336
342
|
if (!mention) {
|
|
337
343
|
return;
|
|
338
344
|
}
|
|
@@ -341,64 +347,80 @@ export function useComposerMenus(t0) {
|
|
|
341
347
|
setMention(null);
|
|
342
348
|
moveCaret(result.caret);
|
|
343
349
|
};
|
|
344
|
-
$[
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[
|
|
348
|
-
$[
|
|
349
|
-
$[
|
|
350
|
+
$[52] = draft.mentions;
|
|
351
|
+
$[53] = mention;
|
|
352
|
+
$[54] = moveCaret;
|
|
353
|
+
$[55] = setText;
|
|
354
|
+
$[56] = text;
|
|
355
|
+
$[57] = t15;
|
|
350
356
|
} else {
|
|
351
|
-
|
|
357
|
+
t15 = $[57];
|
|
352
358
|
}
|
|
353
|
-
const chooseMention =
|
|
359
|
+
const chooseMention = t15;
|
|
360
|
+
let t16;
|
|
361
|
+
if ($[58] !== chooseMention || $[59] !== mention || $[60] !== searched) {
|
|
362
|
+
t16 = index => {
|
|
363
|
+
const path_0 = mention === null ? null : mentionPick(index, searched, mention.query);
|
|
364
|
+
if (path_0 !== null) {
|
|
365
|
+
chooseMention(path_0);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
$[58] = chooseMention;
|
|
369
|
+
$[59] = mention;
|
|
370
|
+
$[60] = searched;
|
|
371
|
+
$[61] = t16;
|
|
372
|
+
} else {
|
|
373
|
+
t16 = $[61];
|
|
374
|
+
}
|
|
375
|
+
const chooseMentionAt = t16;
|
|
354
376
|
let t17;
|
|
355
|
-
if ($[
|
|
356
|
-
t17 =
|
|
357
|
-
if (!
|
|
377
|
+
if ($[62] !== moveCaret || $[63] !== referenceQuery || $[64] !== setDraft || $[65] !== text) {
|
|
378
|
+
t17 = item_1 => {
|
|
379
|
+
if (!referenceQuery) {
|
|
358
380
|
return;
|
|
359
381
|
}
|
|
360
|
-
const result_0 =
|
|
361
|
-
|
|
362
|
-
|
|
382
|
+
const result_0 = insertReference(text, referenceQuery, item_1.name);
|
|
383
|
+
const chat = item_1.kind === "chat";
|
|
384
|
+
const add = ids => ids.includes(item_1.id) ? ids : [...ids, item_1.id];
|
|
385
|
+
setDraft(current_2 => ({
|
|
386
|
+
...current_2,
|
|
363
387
|
text: result_0.text,
|
|
364
|
-
chats:
|
|
388
|
+
chats: chat ? add(current_2.chats) : current_2.chats,
|
|
389
|
+
references: chat ? current_2.references : add(current_2.references),
|
|
390
|
+
referenceNames: {
|
|
391
|
+
...current_2.referenceNames,
|
|
392
|
+
[item_1.id]: item_1.name
|
|
393
|
+
}
|
|
365
394
|
}));
|
|
366
|
-
|
|
395
|
+
setReferenceQuery(null);
|
|
367
396
|
moveCaret(result_0.caret);
|
|
368
397
|
};
|
|
369
|
-
$[61] = mention;
|
|
370
398
|
$[62] = moveCaret;
|
|
371
|
-
$[63] =
|
|
372
|
-
$[64] =
|
|
373
|
-
$[65] =
|
|
399
|
+
$[63] = referenceQuery;
|
|
400
|
+
$[64] = setDraft;
|
|
401
|
+
$[65] = text;
|
|
402
|
+
$[66] = t17;
|
|
374
403
|
} else {
|
|
375
|
-
t17 = $[
|
|
404
|
+
t17 = $[66];
|
|
376
405
|
}
|
|
377
|
-
const
|
|
406
|
+
const chooseReference = t17;
|
|
378
407
|
let t18;
|
|
379
|
-
if ($[
|
|
380
|
-
t18 =
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
} else {
|
|
385
|
-
if (pick?.kind === "file") {
|
|
386
|
-
chooseMention(pick.path);
|
|
387
|
-
}
|
|
408
|
+
if ($[67] !== chooseReference || $[68] !== referenceMatches) {
|
|
409
|
+
t18 = index_0 => {
|
|
410
|
+
const item_2 = referenceMatches[index_0] ?? referenceMatches[0];
|
|
411
|
+
if (item_2 !== undefined) {
|
|
412
|
+
chooseReference(item_2);
|
|
388
413
|
}
|
|
389
414
|
};
|
|
390
|
-
$[
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[69] = mention;
|
|
394
|
-
$[70] = searched;
|
|
395
|
-
$[71] = t18;
|
|
415
|
+
$[67] = chooseReference;
|
|
416
|
+
$[68] = referenceMatches;
|
|
417
|
+
$[69] = t18;
|
|
396
418
|
} else {
|
|
397
|
-
t18 = $[
|
|
419
|
+
t18 = $[69];
|
|
398
420
|
}
|
|
399
|
-
const
|
|
421
|
+
const chooseReferenceAt = t18;
|
|
400
422
|
let t19;
|
|
401
|
-
if ($[
|
|
423
|
+
if ($[70] !== draft.mentions || $[71] !== draft.skills || $[72] !== moveCaret || $[73] !== setText || $[74] !== skillQuery || $[75] !== text) {
|
|
402
424
|
t19 = name_2 => {
|
|
403
425
|
const result_1 = skillQuery ? insertSkill(text, skillQuery, name_2) : {
|
|
404
426
|
text: `$${name_2} `,
|
|
@@ -408,21 +430,21 @@ export function useComposerMenus(t0) {
|
|
|
408
430
|
setSkillQuery(null);
|
|
409
431
|
moveCaret(result_1.caret);
|
|
410
432
|
};
|
|
411
|
-
$[
|
|
412
|
-
$[
|
|
413
|
-
$[
|
|
414
|
-
$[
|
|
415
|
-
$[
|
|
416
|
-
$[
|
|
417
|
-
$[
|
|
433
|
+
$[70] = draft.mentions;
|
|
434
|
+
$[71] = draft.skills;
|
|
435
|
+
$[72] = moveCaret;
|
|
436
|
+
$[73] = setText;
|
|
437
|
+
$[74] = skillQuery;
|
|
438
|
+
$[75] = text;
|
|
439
|
+
$[76] = t19;
|
|
418
440
|
} else {
|
|
419
|
-
t19 = $[
|
|
441
|
+
t19 = $[76];
|
|
420
442
|
}
|
|
421
443
|
const chooseSkill = t19;
|
|
422
444
|
let t20;
|
|
423
|
-
if ($[
|
|
424
|
-
t20 = (command_0,
|
|
425
|
-
setMenuIndex(
|
|
445
|
+
if ($[77] !== chooseSkill || $[78] !== inputRef || $[79] !== setText) {
|
|
446
|
+
t20 = (command_0, index_1) => {
|
|
447
|
+
setMenuIndex(index_1);
|
|
426
448
|
if (command_0.skill) {
|
|
427
449
|
chooseSkill(command_0.name);
|
|
428
450
|
return;
|
|
@@ -430,16 +452,16 @@ export function useComposerMenus(t0) {
|
|
|
430
452
|
setText(`/${command_0.name}`);
|
|
431
453
|
inputRef.current?.focus();
|
|
432
454
|
};
|
|
433
|
-
$[
|
|
434
|
-
$[
|
|
435
|
-
$[
|
|
436
|
-
$[
|
|
455
|
+
$[77] = chooseSkill;
|
|
456
|
+
$[78] = inputRef;
|
|
457
|
+
$[79] = setText;
|
|
458
|
+
$[80] = t20;
|
|
437
459
|
} else {
|
|
438
|
-
t20 = $[
|
|
460
|
+
t20 = $[80];
|
|
439
461
|
}
|
|
440
462
|
const pickCommand = t20;
|
|
441
463
|
let t21;
|
|
442
|
-
if ($[
|
|
464
|
+
if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
|
|
443
465
|
t21 = (key, count) => {
|
|
444
466
|
if (key === "ArrowDown") {
|
|
445
467
|
setMenuIndex(i => (i + 1) % count);
|
|
@@ -451,19 +473,28 @@ export function useComposerMenus(t0) {
|
|
|
451
473
|
}
|
|
452
474
|
return false;
|
|
453
475
|
};
|
|
454
|
-
$[
|
|
476
|
+
$[81] = t21;
|
|
455
477
|
} else {
|
|
456
|
-
t21 = $[
|
|
478
|
+
t21 = $[81];
|
|
457
479
|
}
|
|
458
480
|
const moveInMenu = t21;
|
|
459
481
|
const t22 = skills.length > 0;
|
|
460
482
|
let t23;
|
|
461
|
-
if ($[
|
|
462
|
-
t23 =
|
|
483
|
+
if ($[82] !== skills) {
|
|
484
|
+
t23 = skills.map(_temp4);
|
|
485
|
+
$[82] = skills;
|
|
486
|
+
$[83] = t23;
|
|
487
|
+
} else {
|
|
488
|
+
t23 = $[83];
|
|
489
|
+
}
|
|
490
|
+
let t24;
|
|
491
|
+
if ($[84] !== activeIndex || $[85] !== chooseMention || $[86] !== chooseMentionAt || $[87] !== chooseReference || $[88] !== chooseReferenceAt || $[89] !== chooseSkill || $[90] !== commandMenuOpen || $[91] !== commandQuery || $[92] !== commands || $[93] !== files_0 || $[94] !== inputAria || $[95] !== listId || $[96] !== mention || $[97] !== mentionCount || $[98] !== mentionMenuOpen || $[99] !== pickCommand || $[100] !== referables || $[101] !== referenceChips || $[102] !== referenceMatches || $[103] !== referenceMenuOpen || $[104] !== skillMatches || $[105] !== skillMenuOpen || $[106] !== t22 || $[107] !== t23 || $[108] !== trackTriggers) {
|
|
492
|
+
t24 = {
|
|
463
493
|
listId,
|
|
464
494
|
activeIndex,
|
|
465
495
|
inputAria,
|
|
466
496
|
hasSkills: t22,
|
|
497
|
+
skillNames: t23,
|
|
467
498
|
commandQuery,
|
|
468
499
|
commands,
|
|
469
500
|
commandMenuOpen,
|
|
@@ -472,23 +503,27 @@ export function useComposerMenus(t0) {
|
|
|
472
503
|
mention,
|
|
473
504
|
mentionMenuOpen,
|
|
474
505
|
mentionCount,
|
|
475
|
-
chatMatches,
|
|
476
506
|
files: files_0,
|
|
507
|
+
referenceMenuOpen,
|
|
508
|
+
referenceMatches,
|
|
509
|
+
referables,
|
|
510
|
+
referenceChips,
|
|
477
511
|
setMenuIndex,
|
|
478
512
|
trackTriggers,
|
|
479
513
|
close,
|
|
480
514
|
chooseMention,
|
|
481
|
-
chooseChat,
|
|
482
515
|
chooseMentionAt,
|
|
516
|
+
chooseReference,
|
|
517
|
+
chooseReferenceAt,
|
|
483
518
|
chooseSkill,
|
|
484
519
|
pickCommand,
|
|
485
520
|
moveInMenu
|
|
486
521
|
};
|
|
487
522
|
$[84] = activeIndex;
|
|
488
|
-
$[85] =
|
|
489
|
-
$[86] =
|
|
490
|
-
$[87] =
|
|
491
|
-
$[88] =
|
|
523
|
+
$[85] = chooseMention;
|
|
524
|
+
$[86] = chooseMentionAt;
|
|
525
|
+
$[87] = chooseReference;
|
|
526
|
+
$[88] = chooseReferenceAt;
|
|
492
527
|
$[89] = chooseSkill;
|
|
493
528
|
$[90] = commandMenuOpen;
|
|
494
529
|
$[91] = commandQuery;
|
|
@@ -500,15 +535,23 @@ export function useComposerMenus(t0) {
|
|
|
500
535
|
$[97] = mentionCount;
|
|
501
536
|
$[98] = mentionMenuOpen;
|
|
502
537
|
$[99] = pickCommand;
|
|
503
|
-
$[100] =
|
|
504
|
-
$[101] =
|
|
505
|
-
$[102] =
|
|
506
|
-
$[103] =
|
|
507
|
-
$[104] =
|
|
538
|
+
$[100] = referables;
|
|
539
|
+
$[101] = referenceChips;
|
|
540
|
+
$[102] = referenceMatches;
|
|
541
|
+
$[103] = referenceMenuOpen;
|
|
542
|
+
$[104] = skillMatches;
|
|
543
|
+
$[105] = skillMenuOpen;
|
|
544
|
+
$[106] = t22;
|
|
545
|
+
$[107] = t23;
|
|
546
|
+
$[108] = trackTriggers;
|
|
547
|
+
$[109] = t24;
|
|
508
548
|
} else {
|
|
509
|
-
|
|
549
|
+
t24 = $[109];
|
|
510
550
|
}
|
|
511
|
-
return
|
|
551
|
+
return t24;
|
|
552
|
+
}
|
|
553
|
+
function _temp4(skill_2) {
|
|
554
|
+
return skill_2.name;
|
|
512
555
|
}
|
|
513
556
|
function _temp3(skill) {
|
|
514
557
|
return skill.name;
|
|
@@ -7,11 +7,10 @@ import { checkAttachmentLimits, uploadBytes } from '../../attachments.js';
|
|
|
7
7
|
import { registerComposerSender } from '../../composer-send.js';
|
|
8
8
|
import { isEmptyDraft } from '../../drafts.js';
|
|
9
9
|
import { CONTINUE_PROMPT } from '../../logic/continue-after-stop.js';
|
|
10
|
-
import { presentMentions, presentSkills } from '../../mentions.js';
|
|
10
|
+
import { presentMentions, presentReferences, presentSkills } from '../../mentions.js';
|
|
11
11
|
import { withQuote } from '../../quote.js';
|
|
12
12
|
import { restorableChats, stashDraft, useStash } from '../../stash.js';
|
|
13
13
|
import { scrollTimelineToEnd } from '../../timeline-scroll.js';
|
|
14
|
-
import { useHostReferableChats } from '../../../host-hooks.js';
|
|
15
14
|
/* Sends the draft, or runs the command it names, and puts it away in the stash and back. */
|
|
16
15
|
export function useComposerSubmit(t0) {
|
|
17
16
|
const $ = _c(49);
|
|
@@ -39,7 +38,6 @@ export function useComposerSubmit(t0) {
|
|
|
39
38
|
draft,
|
|
40
39
|
setDraft
|
|
41
40
|
} = box;
|
|
42
|
-
const referable = useHostReferableChats();
|
|
43
41
|
let t1;
|
|
44
42
|
if ($[0] !== chatId || $[1] !== host.openNewChat || $[2] !== scope.id) {
|
|
45
43
|
t1 = (sent, andNew) => {
|
|
@@ -100,15 +98,18 @@ export function useComposerSubmit(t0) {
|
|
|
100
98
|
box.clear();
|
|
101
99
|
return;
|
|
102
100
|
}
|
|
101
|
+
const chats = presentReferences(trimmed, draft.chats, menus.referenceChips);
|
|
102
|
+
const references = menus.referables.chatsOnly ? [] : presentReferences(trimmed, draft.references, menus.referenceChips);
|
|
103
103
|
const sent_0 = onSend(withQuote(quote, trimmed), {
|
|
104
104
|
delivery,
|
|
105
105
|
mentions: presentMentions(trimmed, draft.mentions),
|
|
106
106
|
skills: presentSkills(trimmed, draft.skills),
|
|
107
|
-
chats
|
|
107
|
+
chats,
|
|
108
108
|
quoteSource: quote !== "" && quoteSource !== null ? {
|
|
109
109
|
itemId: quoteSource
|
|
110
110
|
} : undefined,
|
|
111
|
-
attachments: draft.attachments
|
|
111
|
+
attachments: draft.attachments,
|
|
112
|
+
references: references.length > 0 ? references : undefined
|
|
112
113
|
});
|
|
113
114
|
afterSend(sent_0, how === "and-new");
|
|
114
115
|
box.clear();
|
|
@@ -161,20 +162,21 @@ export function useComposerSubmit(t0) {
|
|
|
161
162
|
}
|
|
162
163
|
useEffect(t4, t5);
|
|
163
164
|
let t6;
|
|
164
|
-
if ($[25] !== chatId || $[26] !== history || $[27] !== inputRef || $[28] !==
|
|
165
|
+
if ($[25] !== chatId || $[26] !== history || $[27] !== inputRef || $[28] !== menus || $[29] !== setDraft || $[30] !== setNotice || $[31] !== t) {
|
|
165
166
|
t6 = prompt => {
|
|
166
167
|
const stashedQuote = prompt.quote;
|
|
167
168
|
const here = stashedQuote !== undefined && stashedQuote.chatId === chatId;
|
|
168
169
|
const {
|
|
169
|
-
chats,
|
|
170
|
+
chats: chats_0,
|
|
170
171
|
dropped
|
|
171
|
-
} = restorableChats(prompt.chats, new Set(
|
|
172
|
+
} = restorableChats(prompt.chats, new Set(menus.referables.items.filter(_temp3).map(_temp4)), chatId);
|
|
172
173
|
setDraft(current => ({
|
|
173
174
|
...current,
|
|
174
175
|
text: stashedQuote === undefined || here ? prompt.text : withQuote(stashedQuote.text, prompt.text),
|
|
175
176
|
mentions: [...prompt.mentions],
|
|
176
177
|
skills: [...prompt.skills],
|
|
177
|
-
chats,
|
|
178
|
+
chats: chats_0,
|
|
179
|
+
references: [...prompt.references],
|
|
178
180
|
...(here ? {
|
|
179
181
|
quote: stashedQuote.text,
|
|
180
182
|
quoteSource: stashedQuote.itemId
|
|
@@ -191,7 +193,7 @@ export function useComposerSubmit(t0) {
|
|
|
191
193
|
$[25] = chatId;
|
|
192
194
|
$[26] = history;
|
|
193
195
|
$[27] = inputRef;
|
|
194
|
-
$[28] =
|
|
196
|
+
$[28] = menus;
|
|
195
197
|
$[29] = setDraft;
|
|
196
198
|
$[30] = setNotice;
|
|
197
199
|
$[31] = t;
|
|
@@ -261,8 +263,11 @@ export function useComposerSubmit(t0) {
|
|
|
261
263
|
}
|
|
262
264
|
return t9;
|
|
263
265
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
266
|
+
function _temp4(item_0) {
|
|
267
|
+
return item_0.id;
|
|
268
|
+
}
|
|
269
|
+
function _temp3(item) {
|
|
270
|
+
return item.kind === "chat";
|
|
266
271
|
}
|
|
267
272
|
function _temp2(attachment) {
|
|
268
273
|
return {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type DragEvent, type RefObject } from 'react';
|
|
2
2
|
import { EditorView } from '@codemirror/view';
|
|
3
3
|
import type { ProviderCapabilities } from '@adecore/agent-contracts';
|
|
4
|
+
import type { Referable } from '../../chat-references.js';
|
|
5
|
+
import { type ReferenceToken } from '../../mentions.js';
|
|
4
6
|
import type { ComposerInputHandle } from '../ComposerInput.js';
|
|
5
7
|
import type { ComposerDraft } from './use-composer-draft.js';
|
|
6
8
|
export declare const LEAVE_DROPS_TO_THE_CARD: import("@codemirror/state").Extension;
|
|
@@ -11,8 +13,11 @@ interface DraftFilesInput {
|
|
|
11
13
|
draft: ComposerDraft;
|
|
12
14
|
inputRef: RefObject<ComposerInputHandle | null>;
|
|
13
15
|
setNotice(notice: string): void;
|
|
16
|
+
skills: readonly string[];
|
|
17
|
+
referables: readonly Referable[];
|
|
18
|
+
referenceChips: readonly ReferenceToken[];
|
|
14
19
|
}
|
|
15
|
-
export declare function useDraftFiles({ capabilities, providerName, writable, draft: { draft, setDraft, setText }, inputRef, setNotice }: DraftFilesInput): {
|
|
20
|
+
export declare function useDraftFiles({ capabilities, providerName, writable, draft: { draft, setDraft, setText }, inputRef, setNotice, skills, referables, referenceChips }: DraftFilesInput): {
|
|
16
21
|
dragging: boolean;
|
|
17
22
|
dropTarget: {
|
|
18
23
|
'data-takes-drop': string;
|
|
@@ -23,5 +28,6 @@ export declare function useDraftFiles({ capabilities, providerName, writable, dr
|
|
|
23
28
|
addFiles: (incoming: File[]) => void;
|
|
24
29
|
noteKey: (e: KeyboardEvent) => void;
|
|
25
30
|
onPaste: (e: ClipboardEvent, view: EditorView) => boolean;
|
|
31
|
+
onCopy: (e: ClipboardEvent, view: EditorView) => boolean;
|
|
26
32
|
};
|
|
27
33
|
export {};
|