@adecore/agents-react 0.46.3 → 0.47.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 (56) hide show
  1. package/dist/chat/index.d.ts +1 -0
  2. package/dist/chat/index.js +1 -0
  3. package/dist/chat/logic/scrubber.js +12 -0
  4. package/dist/chat/logic/timeline-copy.js +2 -0
  5. package/dist/chat/logic/timeline.d.ts +6 -1
  6. package/dist/chat/logic/timeline.js +36 -10
  7. package/dist/chat/ui/ChatActivity.d.ts +2 -1
  8. package/dist/chat/ui/ChatActivity.js +295 -61
  9. package/dist/chat/ui/Composer.d.ts +2 -1
  10. package/dist/chat/ui/Composer.js +492 -486
  11. package/dist/chat/ui/PromptEditor.js +4 -1
  12. package/dist/chat/ui/ReferenceChip.d.ts +2 -1
  13. package/dist/chat/ui/ReferenceChip.js +135 -100
  14. package/dist/chat/ui/composer/ComposerMenu.js +17 -11
  15. package/dist/chat/ui/composer/chips.d.ts +3 -0
  16. package/dist/chat/ui/composer/chips.js +14 -10
  17. package/dist/chat/ui/reference-icons.d.ts +3 -0
  18. package/dist/chat/ui/reference-icons.js +15 -2
  19. package/dist/chat/ui/rows/MessageRows.d.ts +6 -1
  20. package/dist/chat/ui/rows/MessageRows.js +166 -10
  21. package/dist/chat/ui/rows/RowContainer.js +21 -22
  22. package/dist/chat/ui/rows/Rows.js +37 -19
  23. package/dist/chat/ui/rows/WorkflowRow.d.ts +2 -1
  24. package/dist/chat/ui/rows/WorkflowRow.js +197 -191
  25. package/dist/chat/ui/rows/row-rhythm.d.ts +1 -0
  26. package/dist/chat/ui/rows/row-rhythm.js +12 -3
  27. package/dist/chat/workflow-list.d.ts +12 -0
  28. package/dist/chat/workflow-list.js +54 -0
  29. package/dist/host.d.ts +8 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/locales/en/agent-chat.d.ts +9 -0
  32. package/dist/locales/en/agent-chat.js +9 -0
  33. package/dist/locales/nl/agent-chat.d.ts +9 -0
  34. package/dist/locales/nl/agent-chat.js +9 -0
  35. package/package.json +8 -8
  36. package/src/chat/index.ts +1 -0
  37. package/src/chat/logic/scrubber.ts +5 -0
  38. package/src/chat/logic/timeline-copy.ts +2 -0
  39. package/src/chat/logic/timeline.ts +33 -2
  40. package/src/chat/ui/ChatActivity.tsx +52 -6
  41. package/src/chat/ui/Composer.tsx +19 -3
  42. package/src/chat/ui/PromptEditor.tsx +3 -1
  43. package/src/chat/ui/ReferenceChip.tsx +15 -5
  44. package/src/chat/ui/composer/ComposerMenu.tsx +4 -2
  45. package/src/chat/ui/composer/chips.ts +15 -9
  46. package/src/chat/ui/reference-icons.ts +13 -1
  47. package/src/chat/ui/rows/MessageRows.tsx +35 -0
  48. package/src/chat/ui/rows/RowContainer.tsx +2 -2
  49. package/src/chat/ui/rows/Rows.tsx +3 -0
  50. package/src/chat/ui/rows/WorkflowRow.tsx +9 -4
  51. package/src/chat/ui/rows/row-rhythm.ts +12 -3
  52. package/src/chat/workflow-list.ts +65 -0
  53. package/src/host.ts +15 -1
  54. package/src/index.ts +1 -0
  55. package/src/locales/en/agent-chat.ts +9 -0
  56. package/src/locales/nl/agent-chat.ts +9 -0
package/dist/host.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { Highlighter, ThemeRegistration } from 'shiki';
5
5
  import type { LucideIcon } from 'lucide-react';
6
6
  import type { EditorEngine } from '@adecore/editor';
7
7
  import type { AgentKind, ChatAttachment, ChatCheckpointDiff, ChatConfigurePayload, ChatGoalAction, ChatItem, ChatSubagentItem, ChatUiChoicePayload, ChatUiQueryPayload, ChatUiQueryReading, ChatUiLinkPayload, ChatUiLinkReading, ChatVisual, ModelSelection, ProviderPlatform, RuntimeMode } from '@adecore/agent-contracts';
8
- import type { Referables } from './chat/chat-references.js';
8
+ import type { ReferableKind, Referables } from './chat/chat-references.js';
9
9
  import type { TimelineRow } from './chat/logic/timeline.js';
10
10
  import type { FindReveal } from './chat/ui/find-reveal.js';
11
11
  import type { PromptAction } from './prompts/logic/prompts.js';
@@ -111,6 +111,12 @@ export interface ComposerSlotProps {
111
111
  disabled: boolean;
112
112
  insert(text: string): void;
113
113
  }
114
+ export interface ReferenceIconProps {
115
+ id: string;
116
+ kind: ReferableKind;
117
+ size: number;
118
+ className?: string;
119
+ }
114
120
  export interface ComposerHeaderSlotProps {
115
121
  scopeId: string;
116
122
  chatId: string;
@@ -282,6 +288,7 @@ export interface ChatHost {
282
288
  title: string;
283
289
  }>;
284
290
  useReferables?(scopeId: string, chatId: string): Referables;
291
+ ReferenceIcon?: ComponentType<ReferenceIconProps> | null;
285
292
  openReference?(scopeId: string, id: string): void;
286
293
  openLogin: ((scopeId: string, kind: AgentKind, accountId: string, name: string) => Promise<void>) | null;
287
294
  useLoginBlocked(scopeId: string): string | null;
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 ComposerSendAction, type ComposerSendDraft, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookMatch, type CommandName, 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 ComposerSendAction, type ComposerSendDraft, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookMatch, type CommandName, 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';
@@ -120,6 +120,10 @@ declare const _default: {
120
120
  showLess: string;
121
121
  quoteGone: string;
122
122
  };
123
+ message: {
124
+ heading: string;
125
+ unnamed: string;
126
+ };
123
127
  report: {
124
128
  heading: string;
125
129
  };
@@ -416,6 +420,11 @@ declare const _default: {
416
420
  monitors_other: string;
417
421
  pausedUntil: string;
418
422
  progress: string;
423
+ workflow: string;
424
+ workflows_one: string;
425
+ workflows_other: string;
426
+ workflowProgress: string;
427
+ workflowStalled: string;
419
428
  needsYou_one: string;
420
429
  needsYou_other: string;
421
430
  took: {
@@ -120,6 +120,10 @@ export default {
120
120
  showLess: 'Show less',
121
121
  quoteGone: 'Quoted reply no longer in this chat.'
122
122
  },
123
+ message: {
124
+ heading: 'Message from {{name}}',
125
+ unnamed: 'another node'
126
+ },
123
127
  report: {
124
128
  heading: 'Report'
125
129
  },
@@ -416,6 +420,11 @@ export default {
416
420
  monitors_other: '{{count}} monitors',
417
421
  pausedUntil: 'paused until {{time}}',
418
422
  progress: '{{done}} of {{total}} sub-agents done',
423
+ workflow: 'Workflow',
424
+ workflows_one: '{{count}} workflow',
425
+ workflows_other: '{{count}} workflows',
426
+ workflowProgress: '{{name}} · {{done}}/{{total}}',
427
+ workflowStalled: '{{name}} · no progress',
419
428
  needsYou_one: '{{count}} needs you',
420
429
  needsYou_other: '{{count}} need you',
421
430
  took: {
@@ -120,6 +120,10 @@ declare const _default: {
120
120
  showLess: string;
121
121
  quoteGone: string;
122
122
  };
123
+ message: {
124
+ heading: string;
125
+ unnamed: string;
126
+ };
123
127
  report: {
124
128
  heading: string;
125
129
  };
@@ -416,6 +420,11 @@ declare const _default: {
416
420
  monitors_other: string;
417
421
  pausedUntil: string;
418
422
  progress: string;
423
+ workflow: string;
424
+ workflows_one: string;
425
+ workflows_other: string;
426
+ workflowProgress: string;
427
+ workflowStalled: string;
419
428
  needsYou_one: string;
420
429
  needsYou_other: string;
421
430
  took: {
@@ -120,6 +120,10 @@ export default {
120
120
  showLess: 'Minder tonen',
121
121
  quoteGone: 'Geciteerd antwoord staat niet meer in deze chat.'
122
122
  },
123
+ message: {
124
+ heading: 'Bericht van {{name}}',
125
+ unnamed: 'een andere node'
126
+ },
123
127
  report: {
124
128
  heading: 'Rapport'
125
129
  },
@@ -416,6 +420,11 @@ export default {
416
420
  monitors_other: '{{count}} monitors',
417
421
  pausedUntil: 'gepauzeerd tot {{time}}',
418
422
  progress: '{{done}} van {{total}} sub-agents klaar',
423
+ workflow: 'Workflow',
424
+ workflows_one: '{{count}} workflow',
425
+ workflows_other: '{{count}} workflows',
426
+ workflowProgress: '{{name}} · {{done}}/{{total}}',
427
+ workflowStalled: '{{name}} · geen voortgang',
419
428
  needsYou_one: '{{count}} vraagt aandacht',
420
429
  needsYou_other: '{{count}} vragen aandacht',
421
430
  took: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents-react",
3
- "version": "0.46.3",
3
+ "version": "0.47.0",
4
4
  "description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -72,11 +72,11 @@
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.46.3",
76
- "@adecore/editor": "0.46.3",
77
- "@adecore/editor-react": "0.46.3",
78
- "@adecore/intelligent-ui": "0.46.3",
79
- "@adecore/merge": "0.46.3",
75
+ "@adecore/agent-contracts": "0.47.0",
76
+ "@adecore/editor": "0.47.0",
77
+ "@adecore/editor-react": "0.47.0",
78
+ "@adecore/intelligent-ui": "0.47.0",
79
+ "@adecore/merge": "0.47.0",
80
80
  "@codemirror/commands": "^6.11.1",
81
81
  "@codemirror/language": "^6.13.1",
82
82
  "@codemirror/state": "^6.7.6",
@@ -100,14 +100,14 @@
100
100
  "zustand": "^5.0.16"
101
101
  },
102
102
  "peerDependencies": {
103
- "@adecore/ui": "^0.46.3",
103
+ "@adecore/ui": "^0.47.0",
104
104
  "i18next": "^26.4.2",
105
105
  "react": "^19.3.0",
106
106
  "react-dom": "^19.3.0",
107
107
  "react-i18next": "^17.0.15"
108
108
  },
109
109
  "devDependencies": {
110
- "@adecore/ui": "0.46.3",
110
+ "@adecore/ui": "0.47.0",
111
111
  "@types/bun": "^1.4.4",
112
112
  "@types/react": "^19.3.0",
113
113
  "@types/react-dom": "^19.3.0",
package/src/chat/index.ts CHANGED
@@ -3,6 +3,7 @@ export { type AccountChoice, useAccountChoice, type NewAccountChoice, useNewAcco
3
3
  export { transportActions, actionsOf, useChatActions } from './actions';
4
4
  export { type ChatSendExtras, ChatClient } from './chat-client';
5
5
  export type { ProjectChat, Referable, ReferableKind, Referables } from './chat-references';
6
+ export { REFERENCE_ICONS } from './ui/reference-icons';
6
7
  export { sendFromComposer, type ComposerSend } from './composer-send';
7
8
  export { stepEffortFromComposer } from './composer-effort';
8
9
  export type { EffortStep } from './logic/effort';
@@ -89,6 +89,11 @@ export function ticksOf(
89
89
  return [{ id: row.id, rowIndex, kind: 'person', text, createdAt: row.item.createdAt, turnId: row.item.turnId, bookmark }];
90
90
  }
91
91
 
92
+ // A message another node sent stands in for the turn it opened, whose own line it hides.
93
+ if (row.kind === 'message') {
94
+ return [{ id: row.id, rowIndex, kind: 'wake', text: row.message.text, createdAt: row.createdAt, turnId: null, bookmark }];
95
+ }
96
+
92
97
  // The other turns nobody asked for (a sub-agent that finished, the CLI going on) are no place to return to.
93
98
  if (row.kind === 'turn-start' && ((row.turn.taskIds?.length ?? 0) > 0 || (row.turn.messageFrom?.length ?? 0) > 0)) {
94
99
  return [{ id: row.id, rowIndex, kind: 'wake', text: row.label, createdAt: row.turn.createdAt, turnId: row.turn.id, bookmark: null }];
@@ -49,6 +49,8 @@ export function messageTextOf(row: TimelineRow): string | null {
49
49
  return row.item.result ?? row.item.summary ?? null;
50
50
  case 'note':
51
51
  return row.text;
52
+ case 'message':
53
+ return row.message.text || null;
52
54
  default:
53
55
  return null;
54
56
  }
@@ -4,6 +4,7 @@ import type {
4
4
  ChatAssistantItem,
5
5
  ChatCheckpointDiff,
6
6
  ChatItem,
7
+ ChatNoteMessage,
7
8
  ChatQuestionItem,
8
9
  ChatSubagentItem,
9
10
  ChatThinkingItem,
@@ -55,6 +56,8 @@ export type TimelineRow =
55
56
  | { kind: 'approval'; id: string; item: ChatApprovalItem }
56
57
  | { kind: 'question'; id: string; item: ChatQuestionItem }
57
58
  | { kind: 'note'; id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }
59
+ // A message another node sent the chat, drawn as said to it under the name of its sender.
60
+ | { kind: 'message'; id: string; message: ChatNoteMessage; createdAt: number }
58
61
  | { kind: 'compaction'; id: string; preTokens: number | null }
59
62
  | {
60
63
  kind: 'changed-files';
@@ -455,7 +458,11 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
455
458
 
456
459
  break;
457
460
  case 'note':
458
- rows.push({ kind: 'note', id: item.id, level: item.level, text: item.text, ...(item.from === undefined ? {} : { from: item.from }) });
461
+ if (item.message !== undefined) {
462
+ rows.push({ kind: 'message', id: item.id, message: item.message, createdAt: item.createdAt });
463
+ } else {
464
+ rows.push({ kind: 'note', id: item.id, level: item.level, text: item.text, ...(item.from === undefined ? {} : { from: item.from }) });
465
+ }
459
466
 
460
467
  break;
461
468
  case 'compaction':
@@ -601,6 +608,29 @@ function chunksByTurn(items: ChatItem[]): TurnChunk[] {
601
608
  return chunks;
602
609
  }
603
610
 
611
+ /* Whether every node whose message opened the turn has that message among the rows right above it. */
612
+ function opensUnderItsMessages(turn: ChatTurnItem, rows: readonly TimelineRow[]): boolean {
613
+ const from = turn.messageFrom ?? [];
614
+
615
+ if (from.length === 0) {
616
+ return false;
617
+ }
618
+
619
+ const senders = new Set<string>();
620
+
621
+ for (let i = rows.length - 1; i >= 0; i--) {
622
+ const row = rows[i]!;
623
+
624
+ if (row.kind !== 'message') {
625
+ break;
626
+ }
627
+
628
+ senders.add(row.message.from);
629
+ }
630
+
631
+ return from.every((id) => senders.has(id));
632
+ }
633
+
604
634
  /* The whole thread as rows; items without a turn (older records) are shown as they are. */
605
635
  export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions): TimelineRow[] {
606
636
  const rows: TimelineRow[] = [];
@@ -617,7 +647,8 @@ export function deriveTimelineRows(items: ChatItem[], options: TimelineOptions):
617
647
  const turn = chunk.items.find((item): item is ChatTurnItem => item.kind === 'turn');
618
648
  const conversation = chunk.items.filter((item) => item.kind !== 'turn');
619
649
 
620
- if (turn?.origin === 'agent') {
650
+ // A turn a message opened needs no line of its own when that message stands right above it.
651
+ if (turn?.origin === 'agent' && !opensUnderItsMessages(turn, rows)) {
621
652
  // The agent started this one itself, so there is no message of the person to show above it.
622
653
  rows.push({ kind: 'turn-start', id: `start-${turnId}`, turn, label: agentTurnLabel(turn) });
623
654
  }
@@ -1,14 +1,16 @@
1
- import { type ReactNode } from 'react';
1
+ import { useState, type ReactNode } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { useShallow } from 'zustand/shallow';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { Activity, MessageCircleQuestionMark, Square, SquareTerminal } from 'lucide-react';
5
+ import { Activity, MessageCircleQuestionMark, Square, SquareTerminal, TriangleAlert } from 'lucide-react';
6
6
  import type { ChatBackgroundTask, ChatSubagentItem } from '@adecore/agent-contracts';
7
7
  import { backgroundCounts } from '../activity';
8
8
  import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskIdOf, taskRowStateOf } from '../subagent-list';
9
9
  import { useSubagentSupport } from '../subagent-support';
10
- import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail } from '../subagent-view';
10
+ import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail, type SubagentStep } from '../subagent-view';
11
+ import { flyoutWorkflows, workflowPillOf, type WorkflowCall, type WorkflowWord } from '../workflow-list';
11
12
  import { SubagentStopButton } from './SubagentStopButton';
13
+ import { WorkflowRow } from './rows/WorkflowRow';
12
14
  import { formatElapsedShort } from '@adecore/ui/format';
13
15
  import { Icon, IconButton, Popover, Surface, useNow } from '@adecore/ui';
14
16
  import { useChatRow, useChats } from '../../state/chats';
@@ -24,14 +26,19 @@ const NO_ITEMS: readonly string[] = [];
24
26
 
25
27
  const ROW_BODY = 'flex min-h-9 min-w-0 grow items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left';
26
28
 
27
- /* What the chat keeps working on beside the thread, in one small line over the composer: its sub-agents and what runs in the background. */
28
- export function ChatActivity({ chatId }: { chatId: string }) {
29
+ /*
30
+ * What the chat keeps working on beside the thread, in one small line over the composer: its sub-agents,
31
+ * its workflows and what runs in the background. Without `workflows` an app shows them somewhere else.
32
+ */
33
+ export function ChatActivity({ chatId, workflows: showsWorkflows = true }: { chatId: string; workflows?: boolean }) {
29
34
  const host = useChatHost();
30
35
  const { t } = useTranslation('agent-chat');
31
36
  const order = useChatRow(chatId, (row) => row?.order) ?? NO_ITEMS;
32
37
  const before = useChatRow(chatId, (row) => row?.subagentsBefore) ?? NO_ITEMS;
38
+ const workflowsBefore = useChatRow(chatId, (row) => row?.workflowsBefore) ?? NO_ITEMS;
33
39
  const structure = useChatRow(chatId, (row) => row?.structure);
34
40
  const subagents = structure === undefined ? [] : flyoutSubagents([...before, ...order], structure);
41
+ const workflows = structure === undefined || !showsWorkflows ? [] : flyoutWorkflows([...workflowsBefore, ...order], structure);
35
42
  const { id, keyOf } = useChatScope();
36
43
  const tasks = useHostTasks(id);
37
44
  // The infos of these sub-agents' own chats, so the info of any other chat changing does not draw this again.
@@ -53,7 +60,7 @@ export function ChatActivity({ chatId }: { chatId: string }) {
53
60
 
54
61
  const background = useChatRow(chatId, (row) => row?.info.background) ?? NO_TASKS;
55
62
 
56
- if (subagents.length === 0 && background.length === 0) {
63
+ if (subagents.length === 0 && workflows.length === 0 && background.length === 0) {
57
64
  return null;
58
65
  }
59
66
 
@@ -87,6 +94,7 @@ export function ChatActivity({ chatId }: { chatId: string }) {
87
94
  ) : (
88
95
  <Slot chatId={chatId} items={subagents} />
89
96
  ))}
97
+ {workflows.length > 0 && <WorkflowFlyout chatId={chatId} calls={workflows} />}
90
98
  {background.length > 0 && (
91
99
  <Flyout
92
100
  icon={<Icon icon={shells > 0 ? SquareTerminal : Activity} size={14} />}
@@ -126,6 +134,44 @@ function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; l
126
134
  );
127
135
  }
128
136
 
137
+ function WorkflowIcon({ word }: { word: WorkflowWord }) {
138
+ return word === 'stalled' ? <Icon icon={TriangleAlert} size={14} className="shrink-0 text-status-needs-you" /> : <StatusIcon word={word} />;
139
+ }
140
+
141
+ /* The workflows as the thread draws them, each with its phases; opening an agent shows its conversation in the thread's place. */
142
+ function WorkflowFlyout({ chatId, calls }: { chatId: string; calls: readonly WorkflowCall[] }) {
143
+ const { t } = useTranslation('agent-chat');
144
+ const { show } = useSubagentTrail(chatId);
145
+ const [open, setOpen] = useState(false);
146
+ const pill = workflowPillOf(calls);
147
+
148
+ const openAgent = (step: SubagentStep): void => {
149
+ setOpen(false);
150
+ show(openFromMain(step));
151
+ };
152
+
153
+ return (
154
+ <Popover.Root open={open} onOpenChange={setOpen}>
155
+ <Surface
156
+ render={<Popover.Trigger />}
157
+ className="pointer-events-auto inline-flex h-7.5 max-w-full min-w-0 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text"
158
+ >
159
+ <WorkflowIcon word={pill.word} />
160
+ <span className="truncate">{pill.label}</span>
161
+ {calls.length === 1 && <span className="sr-only">, {t(`rows.workflow.${pill.word}`)}</span>}
162
+ </Surface>
163
+ <Popover.Popup side="top" className="w-96">
164
+ <div className="px-2.5 pt-1.5 pb-1 text-xs text-text-faint">{t('activity.workflows', { count: calls.length })}</div>
165
+ <div className="max-h-96 overflow-auto px-2.5 pb-1.5">
166
+ {calls.map((call) => (
167
+ <WorkflowRow key={call.id} chatId={chatId} tool={call} workflow={call.workflow} onOpenAgent={openAgent} place="flyout" />
168
+ ))}
169
+ </div>
170
+ </Popover.Popup>
171
+ </Popover.Root>
172
+ );
173
+ }
174
+
129
175
  /* One line of a flyout; with `onOpen` the line leads somewhere and closes the flyout on the way. */
130
176
  function ActivityRow({
131
177
  icon,
@@ -58,6 +58,8 @@ interface ComposerProps {
58
58
  disabled: boolean;
59
59
  /* Nothing can be written, while the chat's own prompts are still answered here. */
60
60
  readOnly?: boolean;
61
+ /* Off where the app shows the chat's workflows somewhere else, such as beside its node. */
62
+ workflowPill?: boolean;
61
63
  /* Opened for one CLI from a menu. The model is the remembered one and there is nothing to pick. */
62
64
  providerFixed: boolean;
63
65
  /* A promise says whether the host took the message, which a send that also opens a new chat waits for. */
@@ -78,7 +80,18 @@ function sendLabelKey(busy: boolean, steerable: boolean, delivery: 'queue' | 'st
78
80
  return delivery === 'steer' ? 'composer.steerButton' : 'composer.queueWithSteerButton';
79
81
  }
80
82
 
81
- export function Composer({ chatId, info, focused, answerPromptsElsewhere, disabled, readOnly = false, providerFixed, onSend, onRetarget }: ComposerProps) {
83
+ export function Composer({
84
+ chatId,
85
+ info,
86
+ focused,
87
+ answerPromptsElsewhere,
88
+ disabled,
89
+ readOnly = false,
90
+ workflowPill = true,
91
+ providerFixed,
92
+ onSend,
93
+ onRetarget
94
+ }: ComposerProps) {
82
95
  const { t } = useTranslation('agent-chat');
83
96
  const host = useChatHost();
84
97
  const scope = useChatScope();
@@ -177,7 +190,10 @@ export function Composer({ chatId, info, focused, answerPromptsElsewhere, disabl
177
190
  const pending = usePendingRequests(chatId);
178
191
  const compactionOffer = useCompactionOffer(chatId, info, capabilities?.compaction);
179
192
  const placeholder = useHintedPlaceholder({ chatId, disabled, readOnly, mentionable: capabilities?.mentions !== false, hasSkills: menus.hasSkills });
180
- const editorExtensions = [chipDecorations({ mentions: draft.mentions, skills: draft.skills, references: menus.referenceChips }), LEAVE_DROPS_TO_THE_CARD];
193
+ const editorExtensions = [
194
+ chipDecorations({ mentions: draft.mentions, skills: draft.skills, references: menus.referenceChips, referenceIcon: host.ReferenceIcon }),
195
+ LEAVE_DROPS_TO_THE_CARD
196
+ ];
181
197
 
182
198
  /* The timeline owns the scroller; this is the one bit of it the composer needs to know. */
183
199
  const atEnd = useSyncExternalStore(
@@ -237,7 +253,7 @@ export function Composer({ chatId, info, focused, answerPromptsElsewhere, disabl
237
253
  </Tooltip>
238
254
  </div>
239
255
  )}
240
- <ChatActivity chatId={chatId} />
256
+ <ChatActivity chatId={chatId} workflows={workflowPill} />
241
257
  <div
242
258
  className={clsx(
243
259
  '@container/composer pointer-events-auto flex flex-col overflow-hidden rounded-2xl border shadow-float backdrop-blur-[14px] focus-ring-within',
@@ -2,6 +2,7 @@ import { useLayoutEffect, useRef, type SetStateAction } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { Surface } from '@adecore/ui';
4
4
  import type { ChatSkill } from '@adecore/agent-contracts';
5
+ import { useChatHost } from '../../host';
5
6
  import type { Referables } from '../chat-references';
6
7
  import { ComposerInput, type ComposerInputHandle } from './ComposerInput';
7
8
  import { chipDecorations } from './composer/chips';
@@ -47,6 +48,7 @@ export function PromptEditor({
47
48
  disabled = false,
48
49
  className
49
50
  }: PromptEditorProps) {
51
+ const host = useChatHost();
50
52
  const inputRef = useRef<ComposerInputHandle>(null);
51
53
  // A pick writes twice in one event (the text, then what it picked), and the second must build on the first.
52
54
  const latest = useRef(value);
@@ -77,7 +79,7 @@ export function PromptEditor({
77
79
  label
78
80
  });
79
81
 
80
- const extensions = chipDecorations({ mentions: value.mentions, skills: value.skills, references: menus.referenceChips });
82
+ const extensions = chipDecorations({ mentions: value.mentions, skills: value.skills, references: menus.referenceChips, referenceIcon: host.ReferenceIcon });
81
83
 
82
84
  const onKeyDown = (e: KeyboardEvent): boolean => {
83
85
  if (e.isComposing) {
@@ -3,8 +3,9 @@ import clsx from 'clsx';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { CircleOff } from 'lucide-react';
5
5
  import { Icon } from '@adecore/ui';
6
+ import { useChatHost } from '../../host';
6
7
  import { REFERENCE_GONE_TONE, REFERENCE_TONE, TOKEN_ICON, TOKEN_IN_MESSAGE } from './chips';
7
- import { REFERENCE_ICONS } from './reference-icons';
8
+ import { referenceGlyph } from './reference-icons';
8
9
  import { ReferenceLookupContext } from './reference-lookup';
9
10
 
10
11
  interface TokenChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
@@ -51,15 +52,24 @@ export function TokenChip({ kind, value, sigil, icon, label, tone, onOpen, class
51
52
  );
52
53
  }
53
54
 
54
- /* A view, node or chat a message points at, under the name it has now; one that went says so. */
55
- export function ReferenceChip({ id }: { id: string }) {
55
+ /*
56
+ * A view, node or chat a message points at, under the name it has now. One that went says so, under
57
+ * `lastName` when the message knows what it was called.
58
+ */
59
+ export function ReferenceChip({ id, lastName }: { id: string; lastName?: string }) {
56
60
  const { t } = useTranslation('agent-chat');
57
61
  const { items, open } = useContext(ReferenceLookupContext);
62
+ const { ReferenceIcon } = useChatHost();
58
63
  const item = items.find((candidate) => candidate.id === id);
59
64
 
60
65
  if (item === undefined) {
61
66
  return (
62
- <TokenChip kind="gone" icon={<Icon icon={CircleOff} size={14} className={TOKEN_ICON} />} label={t('references.gone')} tone={REFERENCE_GONE_TONE} />
67
+ <TokenChip
68
+ kind="gone"
69
+ icon={<Icon icon={CircleOff} size={14} className={TOKEN_ICON} />}
70
+ label={lastName || t('references.gone')}
71
+ tone={REFERENCE_GONE_TONE}
72
+ />
63
73
  );
64
74
  }
65
75
 
@@ -68,7 +78,7 @@ export function ReferenceChip({ id }: { id: string }) {
68
78
  kind="reference"
69
79
  value={item.id}
70
80
  sigil="#"
71
- icon={<Icon icon={REFERENCE_ICONS[item.kind]} size={14} className={TOKEN_ICON} />}
81
+ icon={referenceGlyph(ReferenceIcon, { id: item.id, kind: item.kind, size: 14, className: TOKEN_ICON })}
72
82
  label={item.name || t('references.untitled')}
73
83
  tone={clsx(REFERENCE_TONE, open !== null && 'hover:bg-text/12')}
74
84
  onOpen={open === null ? undefined : () => open(item.id)}
@@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next';
3
3
  import clsx from 'clsx';
4
4
  import { SquareSlash, Zap } from 'lucide-react';
5
5
  import { FileIcon, Icon, Menu, MiddleTruncate } from '@adecore/ui';
6
- import { REFERENCE_ICONS } from '../reference-icons';
6
+ import { useChatHost } from '../../../host';
7
+ import { referenceGlyph } from '../reference-icons';
7
8
  import type { ComposerMenus as Menus } from './use-composer-menus';
8
9
  import { optionIdOf } from './menu-aria';
9
10
 
@@ -108,6 +109,7 @@ function MentionMenu({ menus, query }: { menus: Menus; query: string }) {
108
109
  /* The views, nodes and chats a `#` offers, what stands on this canvas first, each with its kind or what tells it apart. */
109
110
  function ReferenceMenu({ menus }: { menus: Menus }) {
110
111
  const { t } = useTranslation('agent-chat');
112
+ const { ReferenceIcon } = useChatHost();
111
113
  const { listId, referenceMatches } = menus;
112
114
 
113
115
  const groups = (['canvas', 'views'] as const)
@@ -126,7 +128,7 @@ function ReferenceMenu({ menus }: { menus: Menus }) {
126
128
 
127
129
  return (
128
130
  <MenuOption key={item.id} menus={menus} index={index} className="items-center" onPick={() => menus.chooseReference(item)}>
129
- <Icon icon={REFERENCE_ICONS[item.kind]} size={14} className="shrink-0 text-text-faint" />
131
+ {referenceGlyph(ReferenceIcon, { id: item.id, kind: item.kind, size: 14, className: 'shrink-0 text-text-faint' })}
130
132
  <span className="truncate text-text">{item.name}</span>
131
133
  <span className="ml-auto shrink-0 truncate pl-2 text-text-faint">
132
134
  {item.detail ?? t(`composer.references.kinds.${item.kind}`)}
@@ -1,13 +1,13 @@
1
- import { createElement } from 'react';
1
+ import type { ComponentType } from 'react';
2
2
  import { createRoot, type Root } from 'react-dom/client';
3
3
  import { syntaxTree } from '@codemirror/language';
4
4
  import { Facet, StateField, type EditorState, type Extension, type Range } from '@codemirror/state';
5
5
  import { Decoration, EditorView, WidgetType, type DecorationSet } from '@codemirror/view';
6
- import { Icon } from '@adecore/ui';
6
+ import type { ReferenceIconProps } from '../../../host';
7
7
  import type { ReferableKind } from '../../chat-references';
8
8
  import { chipRanges, type ReferenceToken } from '../../mentions';
9
9
  import { CHIP_IN_EDITOR, MENTION_TONE, REFERENCE_TONE, SKILL_TONE, TOKEN_ICON_IN_EDITOR } from '../chips';
10
- import { REFERENCE_ICONS } from '../reference-icons';
10
+ import { referenceGlyph } from '../reference-icons';
11
11
  import { codeRanges } from './editor';
12
12
 
13
13
  export interface ChipChoices {
@@ -15,6 +15,8 @@ export interface ChipChoices {
15
15
  skills: string[];
16
16
  /* Null for a kind the host no longer names, which draws the chip without its mark. */
17
17
  references?: ReadonlyArray<ReferenceToken & { kind: ReferableKind | null }>;
18
+ /* The host's mark of a reference, which the editor draws outside the host's provider. */
19
+ referenceIcon?: ComponentType<ReferenceIconProps> | null;
18
20
  }
19
21
 
20
22
  const NO_CHOICES: ChipChoices = { mentions: [], skills: [] };
@@ -28,24 +30,28 @@ const referenceMark = Decoration.mark({ class: `${REFERENCE_TONE} ${CHIP_IN_EDIT
28
30
 
29
31
  const roots = new WeakMap<HTMLElement, Root>();
30
32
 
31
- /* The kind's mark in place of the `#`, the way a sent message draws it. */
33
+ /* The reference's mark in place of the `#`, the way a sent message draws it. */
32
34
  class ReferenceIcon extends WidgetType {
35
+ readonly id: string;
33
36
  readonly kind: ReferableKind;
37
+ readonly hostIcon: ComponentType<ReferenceIconProps> | null;
34
38
 
35
- constructor(kind: ReferableKind) {
39
+ constructor(id: string, kind: ReferableKind, hostIcon: ComponentType<ReferenceIconProps> | null) {
36
40
  super();
41
+ this.id = id;
37
42
  this.kind = kind;
43
+ this.hostIcon = hostIcon;
38
44
  }
39
45
 
40
46
  override eq(other: ReferenceIcon): boolean {
41
- return other.kind === this.kind;
47
+ return other.id === this.id && other.kind === this.kind && other.hostIcon === this.hostIcon;
42
48
  }
43
49
 
44
50
  toDOM(): HTMLElement {
45
51
  const holder = document.createElement('span');
46
52
  holder.className = TOKEN_ICON_IN_EDITOR;
47
53
  const root = createRoot(holder);
48
- root.render(createElement(Icon, { icon: REFERENCE_ICONS[this.kind], size: 12 }));
54
+ root.render(referenceGlyph(this.hostIcon, { id: this.id, kind: this.kind, size: 12 }));
49
55
  roots.set(holder, root);
50
56
 
51
57
  return holder;
@@ -60,7 +66,7 @@ class ReferenceIcon extends WidgetType {
60
66
  }
61
67
 
62
68
  function chipMarks(state: EditorState): DecorationSet {
63
- const { mentions, skills, references = [] } = state.facet(choices);
69
+ const { mentions, skills, references = [], referenceIcon = null } = state.facet(choices);
64
70
  const kinds = new Map(references.map((token) => [token.id, token.kind]));
65
71
  const marks: Range<Decoration>[] = [];
66
72
 
@@ -76,7 +82,7 @@ function chipMarks(state: EditorState): DecorationSet {
76
82
  const kind = kinds.get(range.value);
77
83
 
78
84
  if (kind !== undefined && kind !== null) {
79
- marks.push(Decoration.replace({ widget: new ReferenceIcon(kind) }).range(range.from, range.from + 1));
85
+ marks.push(Decoration.replace({ widget: new ReferenceIcon(range.value, kind, referenceIcon) }).range(range.from, range.from + 1));
80
86
  }
81
87
  }
82
88
 
@@ -1,7 +1,10 @@
1
+ import { createElement, type ComponentType, type ReactNode } from 'react';
1
2
  import { Database, FileText, Frame, Globe, MessageSquare, PenTool, Smartphone, StickyNote, Terminal, Type, Workflow, type LucideIcon } from 'lucide-react';
3
+ import { Icon } from '@adecore/ui';
4
+ import type { ReferenceIconProps } from '../../host';
2
5
  import type { ReferableKind } from '../chat-references';
3
6
 
4
- /* The mark of what a `#` points at, in the picker and on its chip. */
7
+ /* The mark of what a `#` points at, in the picker and on its chip, when the host draws none of its own. */
5
8
  export const REFERENCE_ICONS: Record<ReferableKind, LucideIcon> = {
6
9
  canvas: Frame,
7
10
  chat: MessageSquare,
@@ -15,3 +18,12 @@ export const REFERENCE_ICONS: Record<ReferableKind, LucideIcon> = {
15
18
  file: FileText,
16
19
  database: Database
17
20
  };
21
+
22
+ /* The host's mark of a reference, or the mark of its kind. */
23
+ export function referenceGlyph(HostIcon: ComponentType<ReferenceIconProps> | null | undefined, props: ReferenceIconProps): ReactNode {
24
+ if (HostIcon) {
25
+ return createElement(HostIcon, props);
26
+ }
27
+
28
+ return createElement(Icon, { icon: REFERENCE_ICONS[props.kind], size: props.size, className: props.className });
29
+ }