@adecore/agents-react 0.54.11 → 0.54.13
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/ChatEmptyScene.d.ts +3 -0
- package/dist/chat/ui/ChatEmptyScene.js +118 -0
- package/dist/chat/ui/Composer.js +296 -294
- package/dist/chat/ui/Timeline.js +42 -54
- package/dist/chat/ui/composer/placeholder.d.ts +13 -4
- package/dist/chat/ui/composer/placeholder.js +36 -16
- package/dist/chat/ui/composer/use-prompt-menus.d.ts +1 -0
- package/dist/chat/ui/composer/use-prompt-menus.js +16 -13
- package/dist/locales/en/agent-chat.d.ts +2 -1
- package/dist/locales/en/agent-chat.js +4 -3
- package/dist/locales/nl/agent-chat.d.ts +2 -1
- package/dist/locales/nl/agent-chat.js +4 -3
- package/dist/theme.css +20 -1
- package/package.json +9 -9
- package/src/chat/ui/ChatEmptyScene.tsx +31 -0
- package/src/chat/ui/Composer.tsx +8 -1
- package/src/chat/ui/Timeline.tsx +9 -15
- package/src/chat/ui/composer/placeholder.ts +35 -12
- package/src/chat/ui/composer/use-prompt-menus.ts +2 -0
- package/src/locales/en/agent-chat.ts +4 -3
- package/src/locales/nl/agent-chat.ts +4 -3
- package/src/theme.css +20 -1
|
@@ -1,10 +1,32 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
1
2
|
import { useMemo } from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { useHostComposerPlaceholder } from '../../../host-hooks';
|
|
4
5
|
import { useChatScope } from '../../../scope';
|
|
5
6
|
|
|
7
|
+
interface PlaceholderHint {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface HintConditions {
|
|
13
|
+
mentionable: boolean;
|
|
14
|
+
referable: boolean;
|
|
15
|
+
hasSkills: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* The keys that open a picker in this chat, in the order a person reads them. */
|
|
19
|
+
export function placeholderHints(t: TFunction<'agent-chat'>, { mentionable, referable, hasSkills }: HintConditions): PlaceholderHint[] {
|
|
20
|
+
return [
|
|
21
|
+
{ key: '/', label: t('composer.placeholder.commands') },
|
|
22
|
+
...(mentionable ? [{ key: '@', label: t('composer.placeholder.files') }] : []),
|
|
23
|
+
...(referable ? [{ key: '#', label: t('composer.placeholder.references') }] : []),
|
|
24
|
+
...(hasSkills ? [{ key: '$', label: t('composer.placeholder.skills') }] : [])
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
/* The empty box names its sigils as key caps, so they read as keys to press rather than as punctuation. */
|
|
7
|
-
function hintedPlaceholder(lead: string, joiner: string, hints: ReadonlyArray<
|
|
29
|
+
function hintedPlaceholder(lead: string, joiner: string, hints: ReadonlyArray<PlaceholderHint>): HTMLElement {
|
|
8
30
|
const root = document.createElement('span');
|
|
9
31
|
root.className = 'composer-hints';
|
|
10
32
|
const extra = document.createElement('span');
|
|
@@ -12,9 +34,12 @@ function hintedPlaceholder(lead: string, joiner: string, hints: ReadonlyArray<{
|
|
|
12
34
|
extra.append(joiner);
|
|
13
35
|
|
|
14
36
|
for (const hint of hints) {
|
|
37
|
+
const pair = document.createElement('span');
|
|
38
|
+
pair.className = hint.key === '#' ? 'composer-hint composer-hint-references' : 'composer-hint';
|
|
15
39
|
const cap = document.createElement('kbd');
|
|
16
40
|
cap.textContent = hint.key;
|
|
17
|
-
|
|
41
|
+
pair.append(cap, hint.label);
|
|
42
|
+
extra.append(pair);
|
|
18
43
|
}
|
|
19
44
|
|
|
20
45
|
root.append(lead, extra);
|
|
@@ -22,16 +47,14 @@ function hintedPlaceholder(lead: string, joiner: string, hints: ReadonlyArray<{
|
|
|
22
47
|
return root;
|
|
23
48
|
}
|
|
24
49
|
|
|
25
|
-
interface PlaceholderInput {
|
|
50
|
+
interface PlaceholderInput extends HintConditions {
|
|
26
51
|
chatId: string;
|
|
27
52
|
disabled: boolean;
|
|
28
53
|
readOnly: boolean;
|
|
29
|
-
mentionable: boolean;
|
|
30
|
-
hasSkills: boolean;
|
|
31
54
|
}
|
|
32
55
|
|
|
33
56
|
/* What the empty box says: why nothing can be written, or the host's words and the keys that open a picker. */
|
|
34
|
-
export function useHintedPlaceholder({ chatId, disabled, readOnly, mentionable, hasSkills }: PlaceholderInput): string | HTMLElement {
|
|
57
|
+
export function useHintedPlaceholder({ chatId, disabled, readOnly, mentionable, referable, hasSkills }: PlaceholderInput): string | HTMLElement {
|
|
35
58
|
const { t } = useTranslation('agent-chat');
|
|
36
59
|
const scope = useChatScope();
|
|
37
60
|
const lead = useHostComposerPlaceholder(scope.id, chatId);
|
|
@@ -45,10 +68,10 @@ export function useHintedPlaceholder({ chatId, disabled, readOnly, mentionable,
|
|
|
45
68
|
return t('composer.placeholder.readOnly');
|
|
46
69
|
}
|
|
47
70
|
|
|
48
|
-
return hintedPlaceholder(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [disabled, readOnly, lead, mentionable, hasSkills, t]);
|
|
71
|
+
return hintedPlaceholder(
|
|
72
|
+
lead ?? t('composer.placeholder.lead'),
|
|
73
|
+
t('composer.placeholder.joiner'),
|
|
74
|
+
placeholderHints(t, { mentionable, referable, hasSkills })
|
|
75
|
+
);
|
|
76
|
+
}, [disabled, readOnly, lead, mentionable, referable, hasSkills, t]);
|
|
54
77
|
}
|
|
@@ -366,6 +366,8 @@ export function usePromptMenus<D extends PromptDraft>({
|
|
|
366
366
|
inputAria,
|
|
367
367
|
menuOpen,
|
|
368
368
|
hasSkills: skills.length > 0,
|
|
369
|
+
// While only chats can be pointed at, the hint that names views would promise what `#` does not open.
|
|
370
|
+
offersViews: offersReferences && !referables.chatsOnly,
|
|
369
371
|
skillNames: skills.map((skill) => skill.name),
|
|
370
372
|
commandQuery,
|
|
371
373
|
commands,
|
|
@@ -254,10 +254,10 @@ export default {
|
|
|
254
254
|
night: 'Still up?'
|
|
255
255
|
},
|
|
256
256
|
empty: {
|
|
257
|
-
ready: '{{model}} is ready
|
|
257
|
+
ready: '{{model}} is ready',
|
|
258
|
+
task: 'Ask a question or give it a task.',
|
|
258
259
|
ask: 'Ask anything.',
|
|
259
|
-
canRead: 'It can read'
|
|
260
|
-
worksIn: 'It works in'
|
|
260
|
+
canRead: 'It can read'
|
|
261
261
|
},
|
|
262
262
|
loading: 'Loading conversation',
|
|
263
263
|
loadingEarlier: 'Loading earlier messages',
|
|
@@ -376,6 +376,7 @@ export default {
|
|
|
376
376
|
joiner: ', or',
|
|
377
377
|
commands: 'commands',
|
|
378
378
|
files: 'files',
|
|
379
|
+
references: 'views',
|
|
379
380
|
skills: 'skills',
|
|
380
381
|
readOnly: 'Go back to the main agent to write'
|
|
381
382
|
},
|
|
@@ -254,10 +254,10 @@ export default {
|
|
|
254
254
|
night: 'Nog wakker?'
|
|
255
255
|
},
|
|
256
256
|
empty: {
|
|
257
|
-
ready: '{{model}} staat klaar
|
|
257
|
+
ready: '{{model}} staat klaar',
|
|
258
|
+
task: 'Stel een vraag of geef een opdracht.',
|
|
258
259
|
ask: 'Vraag maar raak.',
|
|
259
|
-
canRead: 'Kan lezen'
|
|
260
|
-
worksIn: 'Werkt in'
|
|
260
|
+
canRead: 'Kan lezen'
|
|
261
261
|
},
|
|
262
262
|
loading: 'Gesprek laden',
|
|
263
263
|
loadingEarlier: 'Eerdere berichten laden',
|
|
@@ -376,6 +376,7 @@ export default {
|
|
|
376
376
|
joiner: ', of',
|
|
377
377
|
commands: "commando's",
|
|
378
378
|
files: 'bestanden',
|
|
379
|
+
references: 'weergaven',
|
|
379
380
|
skills: 'skills',
|
|
380
381
|
readOnly: 'Ga terug naar de main agent om te schrijven'
|
|
381
382
|
},
|
package/src/theme.css
CHANGED
|
@@ -293,7 +293,7 @@
|
|
|
293
293
|
/* The same editor as a form field (`PromptEditor`): the field's inset, and room for a few lines before it scrolls. */
|
|
294
294
|
.composer-input.prompt-editor .cm-editor { max-height: 240px; }
|
|
295
295
|
.composer-input.prompt-editor .cm-editor .cm-scroller .cm-content { min-height: 80px; padding: 6px 10px; }
|
|
296
|
-
.composer-hints, .composer-hints-extra { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
|
|
296
|
+
.composer-hints, .composer-hints-extra, .composer-hint { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
|
|
297
297
|
/* The joiner starts with its own comma, so it sits against the lead without the gap. */
|
|
298
298
|
.composer-hints-extra { margin-left: -8px; }
|
|
299
299
|
.composer-hints kbd { padding: 0 6px; border-radius: 5px; background: var(--surface-active); color: var(--text-muted); font-family: var(--font-mono); font-size: var(--text-code); line-height: var(--text-code--line-height); }
|
|
@@ -305,6 +305,10 @@
|
|
|
305
305
|
@container composer (width < 36rem) {
|
|
306
306
|
.composer-hints-extra { display: none; }
|
|
307
307
|
}
|
|
308
|
+
/* The longest line, in Dutch on a 14px root, needs 38rem; until then `#` goes first and the rest stay. */
|
|
309
|
+
@container composer (width < 39rem) {
|
|
310
|
+
.composer-hint-references { display: none; }
|
|
311
|
+
}
|
|
308
312
|
/* Markdown stays source while you type: the markers stay put and dim, and what they wrap takes its look. */
|
|
309
313
|
.composer-input .cm-md-mark { color: var(--text-faint); }
|
|
310
314
|
.composer-input .cm-md-strong, .composer-input .cm-md-heading { font-weight: 600; }
|
|
@@ -315,3 +319,18 @@
|
|
|
315
319
|
.composer-input .cm-content .cm-line.cm-md-fence { padding: 0 8px; background: var(--surface-sunken); font-family: var(--font-mono); font-size: var(--text-code); }
|
|
316
320
|
.composer-input .cm-content .cm-line.cm-md-fence-start { padding-top: 4px; border-top-left-radius: 6px; border-top-right-radius: 6px; }
|
|
317
321
|
.composer-input .cm-content .cm-line.cm-md-fence-end { padding-bottom: 4px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }
|
|
322
|
+
|
|
323
|
+
/* The empty thread's scene: a question that goes out, and the model typing before its answer stands. */
|
|
324
|
+
@keyframes chat-scene-send { 0%, 3% { transform: translateY(16px); opacity: 0; } 12%, 100% { transform: none; opacity: 1; } }
|
|
325
|
+
@keyframes chat-scene-typing { 0%, 18% { opacity: 0; } 20%, 32% { opacity: 1; } 34%, 100% { opacity: 0; } }
|
|
326
|
+
@keyframes chat-scene-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-3px); } }
|
|
327
|
+
.chat-scene-send { transform-box: view-box; }
|
|
328
|
+
.chat-scene-typing { opacity: 0; }
|
|
329
|
+
.chat-scene-bounce { transform-box: fill-box; }
|
|
330
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
331
|
+
.chat-scene-send { animation: chat-scene-send 8s var(--scene-arrive) infinite; }
|
|
332
|
+
.chat-scene-typing { animation: chat-scene-typing 8s infinite; }
|
|
333
|
+
.chat-scene-bounce { animation: chat-scene-bounce 0.9s ease-in-out infinite; }
|
|
334
|
+
.chat-scene-bounce:nth-child(2) { animation-delay: 0.15s; }
|
|
335
|
+
.chat-scene-bounce:nth-child(3) { animation-delay: 0.3s; }
|
|
336
|
+
}
|