@adecore/agents-react 0.54.16 → 0.55.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.
Files changed (91) hide show
  1. package/dist/agents/AgentModelLabel.d.ts +5 -0
  2. package/dist/agents/AgentModelLabel.js +32 -7
  3. package/dist/chat/account-choice.d.ts +1 -0
  4. package/dist/chat/account-choice.js +13 -4
  5. package/dist/chat/mentions.d.ts +24 -2
  6. package/dist/chat/mentions.js +84 -10
  7. package/dist/chat/subagent-list.d.ts +0 -1
  8. package/dist/chat/subagent-list.js +1 -9
  9. package/dist/chat/tag-suggestions.d.ts +22 -0
  10. package/dist/chat/tag-suggestions.js +71 -0
  11. package/dist/chat/ui/Composer.js +489 -447
  12. package/dist/chat/ui/ComposerInput.d.ts +1 -0
  13. package/dist/chat/ui/ComposerInput.js +9 -1
  14. package/dist/chat/ui/Markdown.js +41 -25
  15. package/dist/chat/ui/NamedChip.d.ts +5 -0
  16. package/dist/chat/ui/NamedChip.js +118 -0
  17. package/dist/chat/ui/Pickers.d.ts +0 -4
  18. package/dist/chat/ui/Pickers.js +1 -141
  19. package/dist/chat/ui/PromptEditor.js +2 -1
  20. package/dist/chat/ui/ReferenceChip.d.ts +3 -2
  21. package/dist/chat/ui/ReferenceChip.js +58 -36
  22. package/dist/chat/ui/RunSettings.d.ts +3 -2
  23. package/dist/chat/ui/RunSettings.js +386 -361
  24. package/dist/chat/ui/SubagentInfo.js +98 -114
  25. package/dist/chat/ui/SubagentTimeline.js +65 -43
  26. package/dist/chat/ui/Timeline.js +14 -8
  27. package/dist/chat/ui/chip-clipboard.js +10 -0
  28. package/dist/chat/ui/composer/ComposerControls.d.ts +6 -1
  29. package/dist/chat/ui/composer/ComposerControls.js +171 -158
  30. package/dist/chat/ui/composer/ComposerMenu.js +187 -55
  31. package/dist/chat/ui/composer/ComposerPlusMenu.d.ts +18 -0
  32. package/dist/chat/ui/composer/ComposerPlusMenu.js +400 -0
  33. package/dist/chat/ui/composer/ComposerStatusLine.d.ts +4 -0
  34. package/dist/chat/ui/composer/ComposerStatusLine.js +239 -0
  35. package/dist/chat/ui/composer/chips.d.ts +2 -0
  36. package/dist/chat/ui/composer/chips.js +66 -5
  37. package/dist/chat/ui/composer/insert.d.ts +1 -0
  38. package/dist/chat/ui/composer/insert.js +24 -0
  39. package/dist/chat/ui/composer/use-composer-menus.js +34 -17
  40. package/dist/chat/ui/composer/use-prompt-menus.d.ts +10 -2
  41. package/dist/chat/ui/composer/use-prompt-menus.js +290 -202
  42. package/dist/chat/ui/covered-bottom.d.ts +1 -0
  43. package/dist/chat/ui/covered-bottom.js +6 -0
  44. package/dist/chat/ui/named-chip-look.d.ts +14 -0
  45. package/dist/chat/ui/named-chip-look.js +72 -0
  46. package/dist/chat/ui/rehype-chips.js +13 -2
  47. package/dist/host-hooks.d.ts +2 -1
  48. package/dist/host-hooks.js +6 -0
  49. package/dist/host.d.ts +17 -0
  50. package/dist/index.d.ts +1 -1
  51. package/dist/locales/en/agent-chat.d.ts +14 -2
  52. package/dist/locales/en/agent-chat.js +16 -4
  53. package/dist/locales/nl/agent-chat.d.ts +14 -2
  54. package/dist/locales/nl/agent-chat.js +16 -4
  55. package/dist/state/chats.d.ts +1 -0
  56. package/dist/state/chats.js +45 -0
  57. package/package.json +9 -9
  58. package/src/agents/AgentModelLabel.tsx +10 -1
  59. package/src/chat/account-choice.ts +8 -0
  60. package/src/chat/mentions.ts +110 -13
  61. package/src/chat/subagent-list.ts +1 -14
  62. package/src/chat/tag-suggestions.ts +121 -0
  63. package/src/chat/ui/Composer.tsx +24 -12
  64. package/src/chat/ui/ComposerInput.tsx +13 -1
  65. package/src/chat/ui/Markdown.tsx +5 -0
  66. package/src/chat/ui/NamedChip.tsx +34 -0
  67. package/src/chat/ui/Pickers.tsx +1 -51
  68. package/src/chat/ui/PromptEditor.tsx +7 -1
  69. package/src/chat/ui/ReferenceChip.tsx +15 -4
  70. package/src/chat/ui/RunSettings.tsx +51 -29
  71. package/src/chat/ui/SubagentInfo.tsx +17 -17
  72. package/src/chat/ui/SubagentTimeline.tsx +7 -2
  73. package/src/chat/ui/Timeline.tsx +11 -5
  74. package/src/chat/ui/chip-clipboard.ts +8 -1
  75. package/src/chat/ui/composer/ComposerControls.tsx +24 -17
  76. package/src/chat/ui/composer/ComposerMenu.tsx +83 -15
  77. package/src/chat/ui/composer/ComposerPlusMenu.tsx +158 -0
  78. package/src/chat/ui/composer/ComposerStatusLine.tsx +94 -0
  79. package/src/chat/ui/composer/chips.ts +78 -7
  80. package/src/chat/ui/composer/insert.ts +12 -0
  81. package/src/chat/ui/composer/use-composer-menus.ts +5 -2
  82. package/src/chat/ui/composer/use-prompt-menus.ts +55 -10
  83. package/src/chat/ui/covered-bottom.ts +7 -0
  84. package/src/chat/ui/named-chip-look.ts +64 -0
  85. package/src/chat/ui/rehype-chips.ts +17 -2
  86. package/src/host-hooks.ts +11 -1
  87. package/src/host.ts +29 -0
  88. package/src/index.ts +2 -0
  89. package/src/locales/en/agent-chat.ts +16 -4
  90. package/src/locales/nl/agent-chat.ts +16 -4
  91. package/src/state/chats.ts +26 -0
@@ -1,4 +1,13 @@
1
- import type { AgentKind, ChatUsage, ModelInfo, ModelOptionDescriptor, ModelSelection, ProviderInfo, RuntimeMode } from '@adecore/agent-contracts';
1
+ import {
2
+ UsageProviderSchema,
3
+ type AgentKind,
4
+ type ChatUsage,
5
+ type ModelInfo,
6
+ type ModelOptionDescriptor,
7
+ type ModelSelection,
8
+ type ProviderInfo,
9
+ type RuntimeMode
10
+ } from '@adecore/agent-contracts';
2
11
  import { Icon, Menu, Tooltip, useNow } from '@adecore/ui';
3
12
  import { formatPercent, formatTokens } from '@adecore/ui/format';
4
13
  import clsx from 'clsx';
@@ -23,14 +32,16 @@ import { Fragment, useEffect, useRef, useState, type KeyboardEvent } from 'react
23
32
  import { useTranslation } from 'react-i18next';
24
33
  import { limitsOfAccount, sessionWindow } from '../../agents/account-limits';
25
34
  import { AccountDot } from '../../agents/AccountDot';
26
- import { canContinueOn } from '../../agents/accounts';
35
+ import { accountColor, canContinueOn } from '../../agents/accounts';
27
36
  import { AgentIcon } from '../../agents/AgentIcon';
28
- import { modelName, shortModelName } from '../../agents/model-name';
37
+ import { modelName } from '../../agents/model-name';
29
38
  import { localizedOption } from '../../agents/option-words';
30
39
  import { useChatHost } from '../../host';
40
+ import { PROVIDER_COLORS } from '../../usage/format';
31
41
  import { useUsageLimits } from '../../usage/limits';
32
42
  import type { AccountChoice } from '../account-choice';
33
43
  import { CONTEXT_OPTION, contextFraction, contextSegments, orderOptions, type ContextPart } from '../logic/context-usage';
44
+ import { EFFORT_OPTION } from '../logic/effort';
34
45
  import { favoritesFirst, inPickerOrder, searchModels, separatesGroups, shortlistOf, wantsModelSearch } from '../logic/picker-entries';
35
46
  import { favoriteModelsOf, toggleFavoriteModel, useChatPreferences } from '../preferences';
36
47
  import { RUNTIME_MODES } from '../runtime-modes';
@@ -81,6 +92,8 @@ interface RunSettingsProps {
81
92
  onCompact(): void;
82
93
  /* Null while the chat's CLI has fewer than two accounts that are on. */
83
94
  account: AccountPick | null;
95
+ /* The color a person gave the account the chat runs under, which tints the mark also when it is the only account. */
96
+ accountColorId?: string;
84
97
  }
85
98
 
86
99
  interface AccountPick {
@@ -141,14 +154,17 @@ export function RunSettings({
141
154
  usage,
142
155
  compactDisabled,
143
156
  onCompact,
144
- account
157
+ account,
158
+ accountColorId
145
159
  }: RunSettingsProps) {
146
160
  const { t } = useTranslation('agent-chat');
161
+ const { accents } = useChatHost();
147
162
  const [query, setQuery] = useState('');
148
163
  const searchRef = useRef<HTMLInputElement>(null);
149
164
  const owner = providers.find((entry) => entry.kind === provider);
150
165
  const current = modelName(selection.model, owner?.models);
151
- const short = shortModelName(current, owner?.models);
166
+ // Claude's mark already says whose model it is, so the pill drops the maker's name in front of it.
167
+ const pillName = provider === 'claude' || provider === 'anthropic-claude-api' ? current.replace(/^Claude /, '') : current;
152
168
  const options = orderOptions((model?.options ?? []).map(localizedOption));
153
169
 
154
170
  const summary = options.flatMap((option) => {
@@ -165,6 +181,14 @@ export function RunSettings({
165
181
  summary.push({ id: CONTEXT_OPTION, label: formatTokens(usage.contextWindow ?? 0), ring: true });
166
182
  }
167
183
 
184
+ // Reasoning and the other knobs read as words after the model's name; the context stands apart with its ring.
185
+ const words = summary.filter((entry) => !entry.ring).sort((a, b) => Number(b.id === EFFORT_OPTION) - Number(a.id === EFFORT_OPTION));
186
+ const context = summary.find((entry) => entry.ring) ?? null;
187
+ const usageKind = UsageProviderSchema.safeParse(provider);
188
+ const providerColor = usageKind.success ? PROVIDER_COLORS[usageKind.data] : null;
189
+ // A chosen account without a color of its own still reads apart by the provider's; a sole one without a color keeps the mark as it is.
190
+ const accountTint = accountColor(accountColorId, accents.all) ?? (account?.choice.current ? providerColor : null);
191
+
168
192
  const grouped = providers.length > 1;
169
193
  const live = modelGroupsOf(providers, false);
170
194
  const legacy = modelGroupsOf(providers, true);
@@ -340,39 +364,37 @@ export function RunSettings({
340
364
  <Menu.Trigger
341
365
  disabled={disabled}
342
366
  className={clsx(
343
- 'flex h-8 min-w-0 items-center gap-2 rounded-full border pr-3 pl-2.5 text-xs whitespace-nowrap text-text-muted @max-xl/composer:gap-1.5 @max-sm/composer:pr-2.5',
344
- open ? 'border-accent bg-accent-soft' : 'border-border hover:bg-surface-hover-edged'
367
+ 'flex h-8 min-w-0 items-center gap-2 rounded-full border border-transparent pr-3 pl-2.5 text-xs whitespace-nowrap text-text-muted @max-xl/composer:gap-1.5 @max-sm/composer:pr-2.5',
368
+ open ? 'bg-surface-hover text-text' : 'hover:bg-surface-hover'
345
369
  )}
346
370
  >
347
- <AgentIcon kind={provider} size={14} className="shrink-0" />
348
- {/* The composer's width decides how much is said: words give way first, then whole parts. */}
371
+ {/* An account of its own tints the mark; its name stays in the menu. */}
372
+ <span className="flex shrink-0" style={accountTint === null ? undefined : { color: accountTint }}>
373
+ <AgentIcon kind={provider} size={14} />
374
+ </span>
375
+ {/* The composer's width decides how much is said: the window's size and the mode's name give way first, never the model's version. */}
349
376
  <span className="flex min-w-0 items-center gap-2 overflow-hidden @max-xl/composer:gap-1.5">
350
- <span className="truncate font-medium text-text @max-xl/composer:hidden">{current}</span>
351
- <span className="hidden truncate font-medium text-text @max-xl/composer:inline">{short}</span>
352
- {account !== null && (
353
- <span className="flex min-w-0 items-center gap-2 @max-xl/composer:gap-1.5">
354
- <span className="shrink-0 text-text-faint">·</span>
355
- <AccountDot color={account.choice.current?.account.color} />
356
- {/* The account name remains in the menu when the composer is narrow. */}
357
- <span className="truncate @max-xl/composer:hidden">
358
- {account.choice.current === null ? account.choice.currentId : account.choice.nameOf(account.choice.current)}
377
+ <span className="flex min-w-0 items-center gap-1.5">
378
+ <span className="truncate font-medium text-text">{pillName}</span>
379
+ {words.map((entry) => (
380
+ <span key={entry.id} className={clsx('shrink-0', entry.id !== EFFORT_OPTION && '@max-xl/composer:hidden')}>
381
+ {entry.label}
359
382
  </span>
360
- </span>
361
- )}
362
- {summary.map((entry) => (
363
- <span
364
- key={entry.id}
365
- className={clsx('flex shrink-0 items-center gap-2 @max-xl/composer:gap-1.5', !entry.ring && '@max-xl/composer:hidden')}
366
- >
383
+ ))}
384
+ </span>
385
+ {context !== null && (
386
+ <span className="flex shrink-0 items-center gap-2 @max-xl/composer:gap-1.5">
367
387
  <span className="text-text-faint">·</span>
368
- {entry.ring && <ContextRing usage={usage} />}
369
- <span className={clsx(entry.ring && '@max-sm/composer:hidden')}>{entry.label}</span>
388
+ <ContextRing usage={usage} />
389
+ <span className="@max-xl/composer:hidden">{context.label}</span>
370
390
  </span>
371
- ))}
391
+ )}
372
392
  <span className="shrink-0 text-text-faint">·</span>
373
393
  <span className={clsx('flex shrink-0 items-center gap-1', fullAccess && 'text-status-needs-you')}>
374
394
  <Icon icon={MODE_ICONS[shownMode]} size={12} className="shrink-0" />
375
- <span>{effectiveRuntimeMode === undefined && permissionMode !== undefined ? permissionMode : t(`modes.${shownMode}.short`)}</span>
395
+ <span className="@max-xl/composer:hidden">
396
+ {effectiveRuntimeMode === undefined && permissionMode !== undefined ? permissionMode : t(`modes.${shownMode}.short`)}
397
+ </span>
376
398
  {permissionFallback && <Icon icon={TriangleAlert} size={12} className="shrink-0 text-status-needs-you" />}
377
399
  </span>
378
400
  </span>
@@ -1,18 +1,18 @@
1
- import { useNow } from '@adecore/ui';
2
- import { Fragment } from 'react';
1
+ import { Tooltip, useNow } from '@adecore/ui';
3
2
  import { useTranslation } from 'react-i18next';
4
3
  import { useModelName } from '../../agents/model-name';
5
4
  import { useHostTask } from '../../host-hooks';
6
5
  import { useChatScope } from '../../scope';
7
6
  import { useChatRow } from '../../state/chats';
8
- import { entryTimeOf, statusWordOf, subagentFacts, taskIdOf } from '../subagent-list';
7
+ import { entryTimeOf, statusWordOf, taskIdOf } from '../subagent-list';
9
8
  import { useSubagentItem } from '../subagent-view';
10
9
  import { StatusIcon } from './ChatActivity';
11
10
  import { SubagentActions, SubagentBreadcrumb } from './SubagentControls';
12
11
 
13
12
  /*
14
- * What a sub-agent is, over its conversation: the way down to it, its state and time, the model it runs on
15
- * and what it spent, and the way out. Only the way down and out for a conversation whose row the thread lost.
13
+ * What a sub-agent is, over its conversation: its state, with its time in the tooltip, the way down to
14
+ * it, the model it runs on, and the way out. Only the way down and out for a conversation whose row the
15
+ * thread lost.
16
16
  */
17
17
  export function SubagentInfo({ chatId, toolUseId }: { chatId: string; toolUseId: string }) {
18
18
  const { t } = useTranslation('agent-chat');
@@ -23,25 +23,25 @@ export function SubagentInfo({ chatId, toolUseId }: { chatId: string; toolUseId:
23
23
  const modelName = useModelName(provider, item?.model ?? '');
24
24
  const now = useNow(1000, item?.status === 'running');
25
25
  const word = item === null ? null : statusWordOf(item, task);
26
- const facts = item === null ? [] : subagentFacts(item, item.model === undefined ? null : modelName);
26
+ const time = item === null ? '' : entryTimeOf(item, task, now);
27
27
 
28
28
  return (
29
29
  <section aria-label={t('subagents.info.label')} className="shrink-0 border-b border-border py-1.5 pr-1.5 pl-4">
30
30
  <div className="flex min-w-0 items-center gap-2 text-xs text-text-faint">
31
- <SubagentBreadcrumb chatId={chatId} className="max-w-1/3 shrink-0 font-medium" />
32
- {item !== null && word !== null && (
31
+ {word !== null && (
32
+ <Tooltip label={time === '' ? t(`common.status.${word}`) : time}>
33
+ <span className="flex shrink-0" role="img" aria-label={t(`common.status.${word}`)}>
34
+ <StatusIcon word={word} />
35
+ </span>
36
+ </Tooltip>
37
+ )}
38
+ <SubagentBreadcrumb chatId={chatId} className="max-w-1/2 shrink-0 font-medium" />
39
+ {item?.model !== undefined && modelName !== '' && (
33
40
  <>
34
- <StatusIcon word={word} />
35
- <span className="sr-only">{t(`common.status.${word}`)}</span>
36
- <span className="shrink-0 text-text-muted tabular-nums">{entryTimeOf(item, task, now)}</span>
41
+ <span aria-hidden="true">·</span>
42
+ <span className="min-w-0 truncate">{modelName}</span>
37
43
  </>
38
44
  )}
39
- {facts.map((fact) => (
40
- <Fragment key={fact}>
41
- <span aria-hidden="true">·</span>
42
- <span className="min-w-0 truncate">{fact}</span>
43
- </Fragment>
44
- ))}
45
45
  <span className="grow" />
46
46
  <SubagentActions chatId={chatId} />
47
47
  </div>
@@ -1,6 +1,6 @@
1
1
  import { EmptyState, ContextMenu, Icon, ScrollArea } from '@adecore/ui';
2
2
  import { Bot, LoaderCircle } from 'lucide-react';
3
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
3
+ import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useChatHost } from '../../host';
6
6
  import { useHostHidesToolCalls } from '../../host-hooks';
@@ -14,6 +14,7 @@ import { INITIAL_CONVERSATION, SubagentConversation, type SubagentConversationSt
14
14
  import { useSubagentSupport } from '../subagent-support';
15
15
  import { openBelow, useSubagentTrail, type SubagentStep } from '../subagent-view';
16
16
  import { firstRowInView, restoreAnchor, wantsEarlier, type ReadingAnchor } from '../timeline-scroll';
17
+ import { CoveredBottomContext } from './covered-bottom';
17
18
  import { FileLinkContext } from './file-links';
18
19
  import { ReplyContext } from './reply-context';
19
20
  import { FOLLOW_THRESHOLD_PX, rowRhythm } from './rows/row-rhythm';
@@ -52,6 +53,7 @@ export function SubagentTimeline({
52
53
  const threadRef = useRef<HTMLDivElement>(null);
53
54
  const [target, setTarget] = useState<TimelineTarget>(EMPTY_TARGET);
54
55
  const followRef = useRef(true);
56
+ const covered = useContext(CoveredBottomContext);
55
57
 
56
58
  const stopFollowing = () => {
57
59
  followRef.current = false;
@@ -146,7 +148,8 @@ export function SubagentTimeline({
146
148
  };
147
149
 
148
150
  return (
149
- <div className="flex h-full min-h-0 flex-col" style={readingWidthStyle(readingWidth)}>
151
+ // Only the conversation scrolls under the composer; a note in its place keeps clear of it.
152
+ <div className="flex h-full min-h-0 flex-col" style={{ ...readingWidthStyle(readingWidth), paddingBottom: state.status === 'ready' ? 0 : covered }}>
150
153
  {info && <SubagentInfo chatId={chatId} toolUseId={toolUseId} />}
151
154
  {state.status === 'loading' && <div className="chat-column-content px-4 pt-4 text-xs text-text-faint">{t('subagents.loading')}</div>}
152
155
  {state.status === 'failed' && (
@@ -163,6 +166,7 @@ export function SubagentTimeline({
163
166
  data-file-scope-id={scope.id}
164
167
  className="grow"
165
168
  viewportClassName="chat-thread relative px-4 pt-4 pb-3"
169
+ coveredBottom={covered}
166
170
  // The thread keeps its reader in place itself when a page goes in above.
167
171
  style={{ overflowAnchor: 'none' }}
168
172
  onScroll={(event) => {
@@ -206,6 +210,7 @@ export function SubagentTimeline({
206
210
  </ContextMenu.Trigger>
207
211
  <TimelineMenuPopup target={target} thread={threadRef} />
208
212
  </ContextMenu.Root>
213
+ <div className="shrink-0" style={{ height: covered }} aria-hidden />
209
214
  </ScrollArea>
210
215
  </ReplyContext.Provider>
211
216
  </FileLinkContext.Provider>
@@ -66,6 +66,7 @@ import {
66
66
  } from '../timeline-scroll';
67
67
  import { BookmarkMarker } from './BookmarkMarker';
68
68
  import { ChatEmptyScene } from './ChatEmptyScene';
69
+ import { CoveredBottomContext } from './covered-bottom';
69
70
  import { FileLinkContext } from './file-links';
70
71
  import { FindRevealContext } from './find-reveal';
71
72
  import { MessageActions } from './MessageActions';
@@ -208,8 +209,9 @@ const ThreadRow = memo(function ThreadRow({ row, previous, index, top, measure,
208
209
  });
209
210
 
210
211
  /*
211
- * `overlay` stands in the thread's place and ends where the composer starts, so the thread keeps
212
- * where it was underneath and the composer stays in reach for the prompts it answers.
212
+ * `overlay` stands in the thread's place and runs on under the composer as the thread does
213
+ * (`CoveredBottomContext`), so the thread keeps where it was underneath and the composer stays in
214
+ * reach for the prompts it answers.
213
215
  * `onContentHeight` hears what the thread's rows and its padding take, without the composer, once
214
216
  * the rows in view are laid out at their real heights, for a host that sizes its frame to the thread.
215
217
  * Rows out of view still count at an estimate, so a frame up to the viewport's height gets it exact.
@@ -246,6 +248,7 @@ export function Timeline({
246
248
  const fullItems = () => useChats.getState().byKey[keyOf(chatId)]?.items;
247
249
 
248
250
  const scrollRef = useRef<HTMLDivElement>(null);
251
+ const overlayRef = useRef<HTMLDivElement>(null);
249
252
  const threadRef = useRef<HTMLDivElement>(null);
250
253
  const contentRef = useRef<HTMLDivElement>(null);
251
254
  const quoteTakerRef = useRef<QuoteTaker | null>(null);
@@ -1054,12 +1057,15 @@ export function Timeline({
1054
1057
  : { position: 'absolute', insetInline: 0, bottom: 0 }
1055
1058
  }
1056
1059
  onWheel={(e) => {
1057
- const scroller = scrollRef.current;
1060
+ // A sub-agent's conversation scrolls under the composer too, in a scroller of its own.
1061
+ const scroller = overlay ? (overlayRef.current?.querySelector<HTMLElement>('.chat-thread') ?? null) : scrollRef.current;
1058
1062
 
1059
1063
  // A wheel over the composer moves the thread it lies over, as it did inside the scroller.
1064
+ // A popup of the composer is portaled elsewhere, but its wheel still bubbles here through React.
1060
1065
  if (
1061
1066
  scroller === null ||
1062
1067
  coveredHeight === 0 ||
1068
+ !e.currentTarget.contains(e.target as Node) ||
1063
1069
  e.ctrlKey ||
1064
1070
  scrollsWithin(e.target as Element, e.currentTarget, e.deltaX, e.deltaY)
1065
1071
  ) {
@@ -1105,8 +1111,8 @@ export function Timeline({
1105
1111
  </div>
1106
1112
  )}
1107
1113
  {overlay && (
1108
- <div className="absolute inset-0 z-5 flex flex-col bg-surface" style={{ paddingBottom: coveredHeight }}>
1109
- {overlay}
1114
+ <div ref={overlayRef} className="absolute inset-0 z-5 flex flex-col bg-surface">
1115
+ <CoveredBottomContext value={coveredHeight}>{overlay}</CoveredBottomContext>
1110
1116
  </div>
1111
1117
  )}
1112
1118
  </div>
@@ -9,7 +9,8 @@ import {
9
9
  tokenizeNamedReferences,
10
10
  writeClipboardChips,
11
11
  type ChipSegment,
12
- type ClipboardChips
12
+ type ClipboardChips,
13
+ type NamedChipKind
13
14
  } from '../mentions';
14
15
  import type { ReferenceLookup } from './reference-lookup';
15
16
 
@@ -55,6 +56,12 @@ function segmentOf(chip: Element): ChipSegment | null {
55
56
 
56
57
  return name === null || name === '' ? null : { kind: 'reference', id: value, name };
57
58
  }
59
+ case 'model':
60
+ case 'account': {
61
+ const slash = value.indexOf('/');
62
+
63
+ return slash < 1 ? null : { kind: chip.getAttribute('data-chip') as NamedChipKind, cli: value.slice(0, slash), id: value.slice(slash + 1) };
64
+ }
58
65
  default:
59
66
  return null;
60
67
  }
@@ -1,18 +1,18 @@
1
1
  import { holdsConversation, type ChatInfo } from '@adecore/agent-contracts';
2
2
  import { Button, ErrorBoundary, Icon, Menu, Tooltip, type Shortcut } from '@adecore/ui';
3
3
  import clsx from 'clsx';
4
- import { ArrowUp, ChevronDown, Play, Plus, Square } from 'lucide-react';
4
+ import { ArrowUp, ChevronDown, Play, Square } from 'lucide-react';
5
5
  import { useRef, useState, type Ref } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { useChatHost, type ComposerSendAction, type ComposerSendDraft } from '../../../host';
8
8
  import { useChatScope } from '../../../scope';
9
9
  import { useProviders } from '../../../state/providers';
10
- import { useAccountChoice } from '../../account-choice';
10
+ import { useAccountChoice, useAccountColorId } from '../../account-choice';
11
11
  import type { StashedPrompt } from '../../stash';
12
12
  import { composerStopLabel } from '../../subagent-list';
13
13
  import { HostMenuItems } from '../HostMenuItems';
14
- import { StashPicker } from '../Pickers';
15
14
  import { RunSettings } from '../RunSettings';
15
+ import { ComposerPlusMenu, type PlusMenuSigils } from './ComposerPlusMenu';
16
16
  import type { ChatControls } from './use-chat-controls';
17
17
 
18
18
  interface SendProps {
@@ -94,26 +94,34 @@ interface ComposerControlsProps {
94
94
  providerFixed: boolean;
95
95
  writable: boolean;
96
96
  attachable: boolean;
97
+ emptyDraft: boolean;
98
+ sigils: PlusMenuSigils;
97
99
  controls: ChatControls;
98
100
  send: SendProps;
99
101
  dictationToolbar: Ref<HTMLDivElement>;
100
102
  onFiles(files: File[]): void;
101
103
  onRestore(prompt: StashedPrompt): void;
104
+ onStash(): void;
105
+ onSigil(sigil: string): void;
102
106
  insert(text: string): void;
103
107
  }
104
108
 
105
- /* The row under the box: attach, the chat's settings, the stash, the app's own control, and stop and send. */
109
+ /* The row under the box: the + with attach, the stash and the sigils, the chat's settings, the app's own control, and stop and send. */
106
110
  export function ComposerControls({
107
111
  chatId,
108
112
  info,
109
113
  providerFixed,
110
114
  writable,
111
115
  attachable,
116
+ emptyDraft,
117
+ sigils,
112
118
  controls,
113
119
  send,
114
120
  dictationToolbar,
115
121
  onFiles,
116
122
  onRestore,
123
+ onStash,
124
+ onSigil,
117
125
  insert
118
126
  }: ComposerControlsProps) {
119
127
  const { t } = useTranslation('agent-chat');
@@ -121,6 +129,7 @@ export function ComposerControls({
121
129
  const Slot = useChatHost().ComposerSlot;
122
130
  const providers = useProviders((row) => row.providers);
123
131
  const accountChoice = useAccountChoice(info.provider, info.account, chatId);
132
+ const accountColorId = useAccountColorId(info.provider, info.account);
124
133
  const fileInputRef = useRef<HTMLInputElement>(null);
125
134
  const busy = info.activeTurnId !== null;
126
135
  const model = providers.find((entry) => entry.kind === info.provider)?.models.find((entry) => entry.slug === info.selection.model);
@@ -136,18 +145,16 @@ export function ComposerControls({
136
145
  return (
137
146
  // The composer's controls are round, from attach to send, so they keep their own shape instead of `.icon-btn`'s.
138
147
  <div className="flex items-center gap-2 pt-3 pr-3.5 pb-3.5 pl-5 @max-md/composer:gap-1.5 @max-md/composer:p-3 @max-md/composer:pt-2.5">
139
- {attachable && (
140
- <Tooltip label={t('composer.attach')} name>
141
- <button
142
- type="button"
143
- className="grid h-8 w-8 shrink-0 place-items-center rounded-full border border-border text-text-muted hover:bg-surface-hover-edged hover:text-text disabled:opacity-50"
144
- disabled={!writable}
145
- onClick={() => fileInputRef.current?.click()}
146
- >
147
- <Icon icon={Plus} size={16} />
148
- </button>
149
- </Tooltip>
150
- )}
148
+ <ComposerPlusMenu
149
+ writable={writable}
150
+ attachable={attachable}
151
+ emptyDraft={emptyDraft}
152
+ sigils={sigils}
153
+ onAttach={() => fileInputRef.current?.click()}
154
+ onRestore={onRestore}
155
+ onStash={onStash}
156
+ onSigil={onSigil}
157
+ />
151
158
  <input
152
159
  ref={fileInputRef}
153
160
  type="file"
@@ -176,8 +183,8 @@ export function ComposerControls({
176
183
  compactDisabled={busy || !writable}
177
184
  onCompact={controls.compact}
178
185
  account={accountChoice === null ? null : { choice: accountChoice, started, onPick: controls.chooseAccount }}
186
+ {...(accountColorId === undefined ? {} : { accountColorId })}
179
187
  />
180
- <StashPicker onRestore={onRestore} />
181
188
  {Slot !== null && (
182
189
  <ErrorBoundary label={t('composer.slotFailed')} resetKeys={[chatId]} compact className="relative rounded-lg">
183
190
  <Slot scopeId={scope.id} chatId={chatId} disabled={!writable} insert={insert} />
@@ -3,8 +3,11 @@ import clsx from 'clsx';
3
3
  import { SquareSlash, Zap } from 'lucide-react';
4
4
  import type { ReactNode } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
+ import { CliMark } from '../../../agents/AgentModelLabel';
6
7
  import { useChatHost } from '../../../host';
7
8
  import type { Referable } from '../../chat-references';
9
+ import type { AccountSuggestion, ModelSuggestion } from '../../tag-suggestions';
10
+ import { ModelMarks } from '../ModelMarks';
8
11
  import { referenceGlyph } from '../reference-icons';
9
12
  import { optionIdOf } from './menu-aria';
10
13
  import type { ComposerMenus as Menus } from './use-composer-menus';
@@ -76,28 +79,93 @@ function SkillMenu({ menus }: { menus: Menus }) {
76
79
  );
77
80
  }
78
81
 
82
+ /* The CLI's mark of a model or account row, in the color of the account it runs on, as its chip wears it. */
83
+ function NamedMark({ menus, pick }: { menus: Menus; pick: ModelSuggestion | AccountSuggestion }) {
84
+ const { color } = menus.namedLook(pick.kind, pick.cli, pick.id);
85
+
86
+ return (
87
+ <span className="flex shrink-0" style={color === undefined ? undefined : { color }}>
88
+ <CliMark kind={pick.cli} size={14} />
89
+ </span>
90
+ );
91
+ }
92
+
79
93
  function MentionMenu({ menus, query }: { menus: Menus; query: string }) {
80
94
  const { t } = useTranslation('agent-chat');
81
- const { listId, files, mentionCount } = menus;
95
+ const { listId, files, modelMatches, accountMatches, mentionCount } = menus;
82
96
  const filesLabelId = `${listId}-files`;
83
- const filesLabelShown = query === '';
97
+ const modelsLabelId = `${listId}-models`;
98
+ const accountsLabelId = `${listId}-accounts`;
99
+ const sectioned = modelMatches.length + accountMatches.length > 0;
100
+ // A label for the files only where it says something: the folder's own list, or files beside other sections.
101
+ const filesLabel = query === '' ? t('composer.mentions.here') : sectioned ? t('composer.mentions.files') : null;
102
+ // Models and accounts come first, so the files the query also finds never push them out of sight.
103
+ const accountsFrom = modelMatches.length;
104
+ const filesFrom = accountsFrom + accountMatches.length;
84
105
 
85
106
  return (
86
107
  <div className="border-b border-border px-1.5 py-1.5">
87
108
  {mentionCount > 0 && (
88
- <div id={listId} role="listbox" {...(filesLabelShown ? { 'aria-labelledby': filesLabelId } : { 'aria-label': t('composer.mentions.files') })}>
89
- {filesLabelShown && <Menu.Label id={filesLabelId}>{t('composer.mentions.here')}</Menu.Label>}
90
- {files.map((path, index) => {
91
- const { name, dir } = splitPath(path);
92
-
93
- return (
94
- <MenuOption key={path} menus={menus} index={index} className="items-center" onPick={() => menus.chooseMention(path)}>
95
- <FileIcon path={path} size={14} />
96
- <span className="truncate font-mono text-text">{name}</span>
97
- {dir && <MiddleTruncate text={dir} tooltip={false} className="text-text-faint" />}
98
- </MenuOption>
99
- );
100
- })}
109
+ <div id={listId} role="listbox" aria-label={t('composer.mentions.files')}>
110
+ {modelMatches.length > 0 && (
111
+ <div role="group" aria-labelledby={modelsLabelId}>
112
+ <Menu.Label id={modelsLabelId}>{t('composer.mentions.models')}</Menu.Label>
113
+ {modelMatches.map((match, index) => (
114
+ <MenuOption
115
+ key={`${match.cli}/${match.id}`}
116
+ menus={menus}
117
+ index={index}
118
+ className="items-center"
119
+ onPick={() => menus.chooseNamed(match)}
120
+ >
121
+ <NamedMark menus={menus} pick={match} />
122
+ <span className="truncate text-text">{match.model.name}</span>
123
+ <span className="truncate font-mono text-text-faint">{match.id}</span>
124
+ <ModelMarks model={match.model} />
125
+ </MenuOption>
126
+ ))}
127
+ </div>
128
+ )}
129
+ {accountMatches.length > 0 && (
130
+ <div role="group" aria-labelledby={accountsLabelId}>
131
+ <Menu.Label id={accountsLabelId}>{t('composer.mentions.accounts')}</Menu.Label>
132
+ {accountMatches.map((match, index) => (
133
+ <MenuOption
134
+ key={`${match.cli}/${match.id}`}
135
+ menus={menus}
136
+ index={accountsFrom + index}
137
+ className="items-center"
138
+ onPick={() => menus.chooseNamed(match)}
139
+ >
140
+ <NamedMark menus={menus} pick={match} />
141
+ <span className="truncate text-text">{match.name}</span>
142
+ <span className="truncate text-text-faint">{match.provider.name}</span>
143
+ </MenuOption>
144
+ ))}
145
+ </div>
146
+ )}
147
+ {files.length > 0 && (
148
+ <div role="group" {...(filesLabel === null ? { 'aria-label': t('composer.mentions.files') } : { 'aria-labelledby': filesLabelId })}>
149
+ {filesLabel !== null && <Menu.Label id={filesLabelId}>{filesLabel}</Menu.Label>}
150
+ {files.map((path, index) => {
151
+ const { name, dir } = splitPath(path);
152
+
153
+ return (
154
+ <MenuOption
155
+ key={path}
156
+ menus={menus}
157
+ index={filesFrom + index}
158
+ className="items-center"
159
+ onPick={() => menus.chooseMention(path)}
160
+ >
161
+ <FileIcon path={path} size={14} />
162
+ <span className="truncate font-mono text-text">{name}</span>
163
+ {dir && <MiddleTruncate text={dir} tooltip={false} className="text-text-faint" />}
164
+ </MenuOption>
165
+ );
166
+ })}
167
+ </div>
168
+ )}
101
169
  </div>
102
170
  )}
103
171
  {mentionCount === 0 && (