@adecore/agents-react 0.46.3 → 0.48.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 (105) hide show
  1. package/dist/agents/accounts.d.ts +9 -1
  2. package/dist/agents/accounts.js +31 -7
  3. package/dist/chat/account-choice.d.ts +5 -4
  4. package/dist/chat/account-choice.js +47 -39
  5. package/dist/chat/index.d.ts +1 -0
  6. package/dist/chat/index.js +1 -0
  7. package/dist/chat/logic/scrubber.js +12 -0
  8. package/dist/chat/logic/timeline-copy.js +2 -0
  9. package/dist/chat/logic/timeline.d.ts +6 -1
  10. package/dist/chat/logic/timeline.js +36 -10
  11. package/dist/chat/preferences.d.ts +2 -2
  12. package/dist/chat/preferences.js +11 -5
  13. package/dist/chat/ui/AccountPill.js +9 -6
  14. package/dist/chat/ui/ChatActivity.d.ts +2 -1
  15. package/dist/chat/ui/ChatActivity.js +295 -61
  16. package/dist/chat/ui/Composer.d.ts +2 -1
  17. package/dist/chat/ui/Composer.js +492 -486
  18. package/dist/chat/ui/LimitState.js +180 -172
  19. package/dist/chat/ui/PromptEditor.js +4 -1
  20. package/dist/chat/ui/ReferenceChip.d.ts +2 -1
  21. package/dist/chat/ui/ReferenceChip.js +135 -100
  22. package/dist/chat/ui/UnifiedDiff.js +22 -19
  23. package/dist/chat/ui/composer/ComposerControls.js +1 -1
  24. package/dist/chat/ui/composer/ComposerMenu.js +17 -11
  25. package/dist/chat/ui/composer/chips.d.ts +3 -0
  26. package/dist/chat/ui/composer/chips.js +14 -10
  27. package/dist/chat/ui/composer/use-chat-controls.js +70 -67
  28. package/dist/chat/ui/diff/EditorEditDiff.d.ts +3 -1
  29. package/dist/chat/ui/diff/EditorEditDiff.js +24 -18
  30. package/dist/chat/ui/diff/EditorPatchDiff.d.ts +3 -1
  31. package/dist/chat/ui/diff/EditorPatchDiff.js +4 -2
  32. package/dist/chat/ui/diff/diff-props.d.ts +2 -0
  33. package/dist/chat/ui/reference-icons.d.ts +3 -0
  34. package/dist/chat/ui/reference-icons.js +15 -2
  35. package/dist/chat/ui/rows/MessageRows.d.ts +6 -1
  36. package/dist/chat/ui/rows/MessageRows.js +166 -10
  37. package/dist/chat/ui/rows/RowContainer.js +21 -22
  38. package/dist/chat/ui/rows/Rows.js +37 -19
  39. package/dist/chat/ui/rows/WorkflowRow.d.ts +2 -1
  40. package/dist/chat/ui/rows/WorkflowRow.js +197 -191
  41. package/dist/chat/ui/rows/row-rhythm.d.ts +1 -0
  42. package/dist/chat/ui/rows/row-rhythm.js +12 -3
  43. package/dist/chat/workflow-list.d.ts +12 -0
  44. package/dist/chat/workflow-list.js +54 -0
  45. package/dist/host-hooks.d.ts +3 -0
  46. package/dist/host-hooks.js +8 -0
  47. package/dist/host.d.ts +11 -1
  48. package/dist/index.d.ts +1 -1
  49. package/dist/locales/en/agent-chat.d.ts +9 -0
  50. package/dist/locales/en/agent-chat.js +9 -0
  51. package/dist/locales/en/agent-providers.d.ts +5 -0
  52. package/dist/locales/en/agent-providers.js +8 -3
  53. package/dist/locales/nl/agent-chat.d.ts +9 -0
  54. package/dist/locales/nl/agent-chat.js +9 -0
  55. package/dist/locales/nl/agent-providers.d.ts +5 -0
  56. package/dist/locales/nl/agent-providers.js +8 -3
  57. package/dist/providers/AccountOrderList.d.ts +10 -0
  58. package/dist/providers/AccountOrderList.js +158 -0
  59. package/dist/providers/CliDetail.js +55 -61
  60. package/dist/providers/account-actions.d.ts +1 -0
  61. package/dist/providers/account-actions.js +39 -0
  62. package/dist/providers/index.d.ts +1 -1
  63. package/dist/providers/index.js +1 -1
  64. package/dist/usage/limit-groups.js +6 -1
  65. package/package.json +8 -8
  66. package/src/agents/accounts.ts +42 -6
  67. package/src/chat/account-choice.ts +31 -10
  68. package/src/chat/index.ts +1 -0
  69. package/src/chat/logic/scrubber.ts +5 -0
  70. package/src/chat/logic/timeline-copy.ts +2 -0
  71. package/src/chat/logic/timeline.ts +33 -2
  72. package/src/chat/preferences.ts +33 -8
  73. package/src/chat/ui/AccountPill.tsx +3 -3
  74. package/src/chat/ui/ChatActivity.tsx +52 -6
  75. package/src/chat/ui/Composer.tsx +19 -3
  76. package/src/chat/ui/LimitState.tsx +4 -2
  77. package/src/chat/ui/PromptEditor.tsx +3 -1
  78. package/src/chat/ui/ReferenceChip.tsx +15 -5
  79. package/src/chat/ui/UnifiedDiff.tsx +12 -1
  80. package/src/chat/ui/composer/ComposerControls.tsx +1 -1
  81. package/src/chat/ui/composer/ComposerMenu.tsx +4 -2
  82. package/src/chat/ui/composer/chips.ts +15 -9
  83. package/src/chat/ui/composer/use-chat-controls.ts +4 -1
  84. package/src/chat/ui/diff/EditorEditDiff.tsx +9 -4
  85. package/src/chat/ui/diff/EditorPatchDiff.tsx +5 -1
  86. package/src/chat/ui/diff/diff-props.ts +3 -0
  87. package/src/chat/ui/reference-icons.ts +13 -1
  88. package/src/chat/ui/rows/MessageRows.tsx +35 -0
  89. package/src/chat/ui/rows/RowContainer.tsx +2 -2
  90. package/src/chat/ui/rows/Rows.tsx +3 -0
  91. package/src/chat/ui/rows/WorkflowRow.tsx +9 -4
  92. package/src/chat/ui/rows/row-rhythm.ts +12 -3
  93. package/src/chat/workflow-list.ts +65 -0
  94. package/src/host-hooks.ts +13 -0
  95. package/src/host.ts +23 -1
  96. package/src/index.ts +1 -0
  97. package/src/locales/en/agent-chat.ts +9 -0
  98. package/src/locales/en/agent-providers.ts +8 -3
  99. package/src/locales/nl/agent-chat.ts +9 -0
  100. package/src/locales/nl/agent-providers.ts +8 -3
  101. package/src/providers/AccountOrderList.tsx +124 -0
  102. package/src/providers/CliDetail.tsx +33 -28
  103. package/src/providers/account-actions.ts +30 -0
  104. package/src/providers/index.ts +11 -1
  105. package/src/usage/limit-groups.ts +8 -1
@@ -4,8 +4,9 @@ import clsx from 'clsx';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { CircleOff } from 'lucide-react';
6
6
  import { Icon } from '@adecore/ui';
7
+ import { useChatHost } from '../../host.js';
7
8
  import { REFERENCE_GONE_TONE, REFERENCE_TONE, TOKEN_ICON, TOKEN_IN_MESSAGE } from './chips.js';
8
- import { REFERENCE_ICONS } from './reference-icons.js';
9
+ import { referenceGlyph } from './reference-icons.js';
9
10
  import { ReferenceLookupContext } from './reference-lookup.js';
10
11
  /*
11
12
  * One token in the transcript. One that opens is a span with a button's role rather than a button,
@@ -124,11 +125,15 @@ export function TokenChip(t0) {
124
125
  }
125
126
  return t9;
126
127
  }
127
- /* A view, node or chat a message points at, under the name it has now; one that went says so. */
128
+ /*
129
+ * A view, node or chat a message points at, under the name it has now. One that went says so, under
130
+ * `lastName` when the message knows what it was called.
131
+ */
128
132
  export function ReferenceChip(t0) {
129
- const $ = _c(26);
133
+ const $ = _c(37);
130
134
  const {
131
- id
135
+ id,
136
+ lastName
132
137
  } = t0;
133
138
  const {
134
139
  t
@@ -137,119 +142,149 @@ export function ReferenceChip(t0) {
137
142
  items,
138
143
  open
139
144
  } = useContext(ReferenceLookupContext);
145
+ const {
146
+ ReferenceIcon
147
+ } = useChatHost();
148
+ let T0;
149
+ let item;
140
150
  let t1;
141
- if ($[0] !== id || $[1] !== items) {
142
- let t2;
143
- if ($[3] !== id) {
144
- t2 = candidate => candidate.id === id;
145
- $[3] = id;
146
- $[4] = t2;
147
- } else {
148
- t2 = $[4];
149
- }
150
- t1 = items.find(t2);
151
- $[0] = id;
152
- $[1] = items;
153
- $[2] = t1;
154
- } else {
155
- t1 = $[2];
156
- }
157
- const item = t1;
158
- if (item === undefined) {
159
- let t2;
160
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
161
- t2 = /*#__PURE__*/_jsx(Icon, {
162
- icon: CircleOff,
151
+ let t2;
152
+ let t3;
153
+ let t4;
154
+ let t5;
155
+ if ($[0] !== ReferenceIcon || $[1] !== id || $[2] !== items || $[3] !== lastName || $[4] !== t) {
156
+ t5 = Symbol.for("react.early_return_sentinel");
157
+ bb0: {
158
+ let t6;
159
+ if ($[12] !== id) {
160
+ t6 = candidate => candidate.id === id;
161
+ $[12] = id;
162
+ $[13] = t6;
163
+ } else {
164
+ t6 = $[13];
165
+ }
166
+ item = items.find(t6);
167
+ if (item === undefined) {
168
+ let t7;
169
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
170
+ t7 = /*#__PURE__*/_jsx(Icon, {
171
+ icon: CircleOff,
172
+ size: 14,
173
+ className: TOKEN_ICON
174
+ });
175
+ $[14] = t7;
176
+ } else {
177
+ t7 = $[14];
178
+ }
179
+ let t8;
180
+ if ($[15] !== lastName || $[16] !== t) {
181
+ t8 = lastName || t("references.gone");
182
+ $[15] = lastName;
183
+ $[16] = t;
184
+ $[17] = t8;
185
+ } else {
186
+ t8 = $[17];
187
+ }
188
+ let t9;
189
+ if ($[18] !== t8) {
190
+ t9 = /*#__PURE__*/_jsx(TokenChip, {
191
+ kind: "gone",
192
+ icon: t7,
193
+ label: t8,
194
+ tone: REFERENCE_GONE_TONE
195
+ });
196
+ $[18] = t8;
197
+ $[19] = t9;
198
+ } else {
199
+ t9 = $[19];
200
+ }
201
+ t5 = t9;
202
+ break bb0;
203
+ }
204
+ T0 = TokenChip;
205
+ t1 = "reference";
206
+ t2 = item.id;
207
+ t3 = "#";
208
+ t4 = referenceGlyph(ReferenceIcon, {
209
+ id: item.id,
210
+ kind: item.kind,
163
211
  size: 14,
164
212
  className: TOKEN_ICON
165
213
  });
166
- $[5] = t2;
167
- } else {
168
- t2 = $[5];
169
- }
170
- let t3;
171
- if ($[6] !== t) {
172
- t3 = t("references.gone");
173
- $[6] = t;
174
- $[7] = t3;
175
- } else {
176
- t3 = $[7];
177
- }
178
- let t4;
179
- if ($[8] !== t3) {
180
- t4 = /*#__PURE__*/_jsx(TokenChip, {
181
- kind: "gone",
182
- icon: t2,
183
- label: t3,
184
- tone: REFERENCE_GONE_TONE
185
- });
186
- $[8] = t3;
187
- $[9] = t4;
188
- } else {
189
- t4 = $[9];
190
214
  }
191
- return t4;
192
- }
193
- const t2 = item.id;
194
- const t3 = REFERENCE_ICONS[item.kind];
195
- let t4;
196
- if ($[10] !== t3) {
197
- t4 = /*#__PURE__*/_jsx(Icon, {
198
- icon: t3,
199
- size: 14,
200
- className: TOKEN_ICON
201
- });
202
- $[10] = t3;
203
- $[11] = t4;
215
+ $[0] = ReferenceIcon;
216
+ $[1] = id;
217
+ $[2] = items;
218
+ $[3] = lastName;
219
+ $[4] = t;
220
+ $[5] = T0;
221
+ $[6] = item;
222
+ $[7] = t1;
223
+ $[8] = t2;
224
+ $[9] = t3;
225
+ $[10] = t4;
226
+ $[11] = t5;
204
227
  } else {
205
- t4 = $[11];
228
+ T0 = $[5];
229
+ item = $[6];
230
+ t1 = $[7];
231
+ t2 = $[8];
232
+ t3 = $[9];
233
+ t4 = $[10];
234
+ t5 = $[11];
206
235
  }
207
- let t5;
208
- if ($[12] !== item.name || $[13] !== t) {
209
- t5 = item.name || t("references.untitled");
210
- $[12] = item.name;
211
- $[13] = t;
212
- $[14] = t5;
213
- } else {
214
- t5 = $[14];
236
+ if (t5 !== Symbol.for("react.early_return_sentinel")) {
237
+ return t5;
215
238
  }
216
- const t6 = open !== null && "hover:bg-text/12";
217
- let t7;
218
- if ($[15] !== t6) {
219
- t7 = clsx(REFERENCE_TONE, t6);
220
- $[15] = t6;
221
- $[16] = t7;
239
+ let t6;
240
+ if ($[20] !== item.name || $[21] !== t) {
241
+ t6 = item.name || t("references.untitled");
242
+ $[20] = item.name;
243
+ $[21] = t;
244
+ $[22] = t6;
222
245
  } else {
223
- t7 = $[16];
246
+ t6 = $[22];
224
247
  }
248
+ const t7 = open !== null && "hover:bg-text/12";
225
249
  let t8;
226
- if ($[17] !== item.id || $[18] !== open) {
227
- t8 = open === null ? undefined : () => open(item.id);
228
- $[17] = item.id;
229
- $[18] = open;
230
- $[19] = t8;
250
+ if ($[23] !== t7) {
251
+ t8 = clsx(REFERENCE_TONE, t7);
252
+ $[23] = t7;
253
+ $[24] = t8;
231
254
  } else {
232
- t8 = $[19];
255
+ t8 = $[24];
233
256
  }
234
257
  let t9;
235
- if ($[20] !== item.id || $[21] !== t4 || $[22] !== t5 || $[23] !== t7 || $[24] !== t8) {
236
- t9 = /*#__PURE__*/_jsx(TokenChip, {
237
- kind: "reference",
258
+ if ($[25] !== item.id || $[26] !== open) {
259
+ t9 = open === null ? undefined : () => open(item.id);
260
+ $[25] = item.id;
261
+ $[26] = open;
262
+ $[27] = t9;
263
+ } else {
264
+ t9 = $[27];
265
+ }
266
+ let t10;
267
+ if ($[28] !== T0 || $[29] !== t1 || $[30] !== t2 || $[31] !== t3 || $[32] !== t4 || $[33] !== t6 || $[34] !== t8 || $[35] !== t9) {
268
+ t10 = /*#__PURE__*/_jsx(T0, {
269
+ kind: t1,
238
270
  value: t2,
239
- sigil: "#",
271
+ sigil: t3,
240
272
  icon: t4,
241
- label: t5,
242
- tone: t7,
243
- onOpen: t8
273
+ label: t6,
274
+ tone: t8,
275
+ onOpen: t9
244
276
  });
245
- $[20] = item.id;
246
- $[21] = t4;
247
- $[22] = t5;
248
- $[23] = t7;
249
- $[24] = t8;
250
- $[25] = t9;
277
+ $[28] = T0;
278
+ $[29] = t1;
279
+ $[30] = t2;
280
+ $[31] = t3;
281
+ $[32] = t4;
282
+ $[33] = t6;
283
+ $[34] = t8;
284
+ $[35] = t9;
285
+ $[36] = t10;
251
286
  } else {
252
- t9 = $[25];
287
+ t10 = $[36];
253
288
  }
254
- return t9;
289
+ return t10;
255
290
  }
@@ -14,7 +14,7 @@ const LegacyUnifiedDiff = lazyNamed(() => import('./diff/LegacyUnifiedDiff.js'),
14
14
  });
15
15
  const EditorPatchDiff = lazyNamed(() => import('./diff/EditorPatchDiff.js'), 'default');
16
16
  export default function UnifiedDiff(props) {
17
- const $ = _c(61);
17
+ const $ = _c(62);
18
18
  const host = useChatHost();
19
19
  const {
20
20
  t
@@ -27,7 +27,8 @@ export default function UnifiedDiff(props) {
27
27
  overflow: t2,
28
28
  diffStyle: t3,
29
29
  fill: t4,
30
- maxHeight
30
+ maxHeight,
31
+ onSource
31
32
  } = props;
32
33
  const allowEditor = t0 === undefined ? true : t0;
33
34
  const ignoreWhitespace = t1 === undefined ? false : t1;
@@ -190,7 +191,7 @@ export default function UnifiedDiff(props) {
190
191
  }
191
192
  const t15 = overflow === "wrap";
192
193
  let t16;
193
- if ($[44] !== change || $[45] !== contents || $[46] !== diffStyle || $[47] !== fill || $[48] !== ignoreWhitespace || $[49] !== loadEngine || $[50] !== maxHeight || $[51] !== t15 || $[52] !== unavailable) {
194
+ if ($[44] !== change || $[45] !== contents || $[46] !== diffStyle || $[47] !== fill || $[48] !== ignoreWhitespace || $[49] !== loadEngine || $[50] !== maxHeight || $[51] !== onSource || $[52] !== t15 || $[53] !== unavailable) {
194
195
  t16 = /*#__PURE__*/_jsx(EditorPatchDiff, {
195
196
  change: change,
196
197
  sourceChecked: true,
@@ -201,7 +202,8 @@ export default function UnifiedDiff(props) {
201
202
  maxHeight: maxHeight,
202
203
  layout: diffStyle,
203
204
  loadEngine: loadEngine,
204
- fallback: unavailable
205
+ fallback: unavailable,
206
+ onSource: onSource
205
207
  });
206
208
  $[44] = change;
207
209
  $[45] = contents;
@@ -210,37 +212,38 @@ export default function UnifiedDiff(props) {
210
212
  $[48] = ignoreWhitespace;
211
213
  $[49] = loadEngine;
212
214
  $[50] = maxHeight;
213
- $[51] = t15;
214
- $[52] = unavailable;
215
- $[53] = t16;
215
+ $[51] = onSource;
216
+ $[52] = t15;
217
+ $[53] = unavailable;
218
+ $[54] = t16;
216
219
  } else {
217
- t16 = $[53];
220
+ t16 = $[54];
218
221
  }
219
222
  let t17;
220
- if ($[54] !== t14 || $[55] !== t16) {
223
+ if ($[55] !== t14 || $[56] !== t16) {
221
224
  t17 = /*#__PURE__*/_jsx(LazyBoundary, {
222
225
  fallback: t14,
223
226
  children: t16
224
227
  });
225
- $[54] = t14;
226
- $[55] = t16;
227
- $[56] = t17;
228
+ $[55] = t14;
229
+ $[56] = t16;
230
+ $[57] = t17;
228
231
  } else {
229
- t17 = $[56];
232
+ t17 = $[57];
230
233
  }
231
234
  let t18;
232
- if ($[57] !== t12 || $[58] !== t17 || $[59] !== unavailable) {
235
+ if ($[58] !== t12 || $[59] !== t17 || $[60] !== unavailable) {
233
236
  t18 = /*#__PURE__*/_jsx(DiffFallbackBoundary, {
234
237
  fallback: unavailable,
235
238
  resetKeys: t12,
236
239
  children: t17
237
240
  });
238
- $[57] = t12;
239
- $[58] = t17;
240
- $[59] = unavailable;
241
- $[60] = t18;
241
+ $[58] = t12;
242
+ $[59] = t17;
243
+ $[60] = unavailable;
244
+ $[61] = t18;
242
245
  } else {
243
- t18 = $[60];
246
+ t18 = $[61];
244
247
  }
245
248
  return t18;
246
249
  }
@@ -240,7 +240,7 @@ export function ComposerControls(t0) {
240
240
  const scope = useChatScope();
241
241
  const Slot = useChatHost().ComposerSlot;
242
242
  const providers = useProviders(_temp);
243
- const accountChoice = useAccountChoice(info.provider, info.account);
243
+ const accountChoice = useAccountChoice(info.provider, info.account, chatId);
244
244
  const fileInputRef = useRef(null);
245
245
  const busy = info.activeTurnId !== null;
246
246
  let t1;
@@ -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.js';
6
+ import { useChatHost } from '../../../host.js';
7
+ import { referenceGlyph } from '../reference-icons.js';
7
8
  import { optionIdOf } from './menu-aria.js';
8
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  function splitPath(path) {
@@ -298,19 +299,22 @@ function MentionMenu(t0) {
298
299
  }
299
300
  /* The views, nodes and chats a `#` offers, what stands on this canvas first, each with its kind or what tells it apart. */
300
301
  function ReferenceMenu(t0) {
301
- const $ = _c(5);
302
+ const $ = _c(6);
302
303
  const {
303
304
  menus
304
305
  } = t0;
305
306
  const {
306
307
  t
307
308
  } = useTranslation("agent-chat");
309
+ const {
310
+ ReferenceIcon
311
+ } = useChatHost();
308
312
  const {
309
313
  listId,
310
314
  referenceMatches
311
315
  } = menus;
312
316
  let t1;
313
- if ($[0] !== listId || $[1] !== menus || $[2] !== referenceMatches || $[3] !== t) {
317
+ if ($[0] !== ReferenceIcon || $[1] !== listId || $[2] !== menus || $[3] !== referenceMatches || $[4] !== t) {
314
318
  const groups = ["canvas", "views"].map(group => ({
315
319
  group,
316
320
  items: referenceMatches.filter(item => item.group === group)
@@ -339,8 +343,9 @@ function ReferenceMenu(t0) {
339
343
  index: index,
340
344
  className: "items-center",
341
345
  onPick: () => menus.chooseReference(item_0),
342
- children: [/*#__PURE__*/_jsx(Icon, {
343
- icon: REFERENCE_ICONS[item_0.kind],
346
+ children: [referenceGlyph(ReferenceIcon, {
347
+ id: item_0.id,
348
+ kind: item_0.kind,
344
349
  size: 14,
345
350
  className: "shrink-0 text-text-faint"
346
351
  }), /*#__PURE__*/_jsx("span", {
@@ -359,13 +364,14 @@ function ReferenceMenu(t0) {
359
364
  children: t("composer.references.noMatch")
360
365
  })
361
366
  });
362
- $[0] = listId;
363
- $[1] = menus;
364
- $[2] = referenceMatches;
365
- $[3] = t;
366
- $[4] = t1;
367
+ $[0] = ReferenceIcon;
368
+ $[1] = listId;
369
+ $[2] = menus;
370
+ $[3] = referenceMatches;
371
+ $[4] = t;
372
+ $[5] = t1;
367
373
  } else {
368
- t1 = $[4];
374
+ t1 = $[5];
369
375
  }
370
376
  return t1;
371
377
  }
@@ -1,4 +1,6 @@
1
+ import type { ComponentType } from 'react';
1
2
  import { type Extension } from '@codemirror/state';
3
+ import type { ReferenceIconProps } from '../../../host.js';
2
4
  import type { ReferableKind } from '../../chat-references.js';
3
5
  import { type ReferenceToken } from '../../mentions.js';
4
6
  export interface ChipChoices {
@@ -7,5 +9,6 @@ export interface ChipChoices {
7
9
  references?: ReadonlyArray<ReferenceToken & {
8
10
  kind: ReferableKind | null;
9
11
  }>;
12
+ referenceIcon?: ComponentType<ReferenceIconProps> | null;
10
13
  }
11
14
  export declare function chipDecorations(value: ChipChoices): Extension;
@@ -1,12 +1,10 @@
1
- import { createElement } from 'react';
2
1
  import { createRoot } from 'react-dom/client';
3
2
  import { syntaxTree } from '@codemirror/language';
4
3
  import { Facet, StateField } from '@codemirror/state';
5
4
  import { Decoration, EditorView, WidgetType } from '@codemirror/view';
6
- import { Icon } from '@adecore/ui';
7
5
  import { chipRanges } from '../../mentions.js';
8
6
  import { CHIP_IN_EDITOR, MENTION_TONE, REFERENCE_TONE, SKILL_TONE, TOKEN_ICON_IN_EDITOR } from '../chips.js';
9
- import { REFERENCE_ICONS } from '../reference-icons.js';
7
+ import { referenceGlyph } from '../reference-icons.js';
10
8
  import { codeRanges } from './editor.js';
11
9
  const NO_CHOICES = {
12
10
  mentions: [],
@@ -27,22 +25,27 @@ const referenceMark = Decoration.mark({
27
25
  inclusiveStart: true
28
26
  });
29
27
  const roots = new WeakMap();
30
- /* The kind's mark in place of the `#`, the way a sent message draws it. */
28
+ /* The reference's mark in place of the `#`, the way a sent message draws it. */
31
29
  class ReferenceIcon extends WidgetType {
30
+ id;
32
31
  kind;
33
- constructor(kind) {
32
+ hostIcon;
33
+ constructor(id, kind, hostIcon) {
34
34
  super();
35
+ this.id = id;
35
36
  this.kind = kind;
37
+ this.hostIcon = hostIcon;
36
38
  }
37
39
  eq(other) {
38
- return other.kind === this.kind;
40
+ return other.id === this.id && other.kind === this.kind && other.hostIcon === this.hostIcon;
39
41
  }
40
42
  toDOM() {
41
43
  const holder = document.createElement('span');
42
44
  holder.className = TOKEN_ICON_IN_EDITOR;
43
45
  const root = createRoot(holder);
44
- root.render(createElement(Icon, {
45
- icon: REFERENCE_ICONS[this.kind],
46
+ root.render(referenceGlyph(this.hostIcon, {
47
+ id: this.id,
48
+ kind: this.kind,
46
49
  size: 12
47
50
  }));
48
51
  roots.set(holder, root);
@@ -59,7 +62,8 @@ function chipMarks(state) {
59
62
  const {
60
63
  mentions,
61
64
  skills,
62
- references = []
65
+ references = [],
66
+ referenceIcon = null
63
67
  } = state.facet(choices);
64
68
  const kinds = new Map(references.map(token => [token.id, token.kind]));
65
69
  const marks = [];
@@ -73,7 +77,7 @@ function chipMarks(state) {
73
77
  const kind = kinds.get(range.value);
74
78
  if (kind !== undefined && kind !== null) {
75
79
  marks.push(Decoration.replace({
76
- widget: new ReferenceIcon(kind)
80
+ widget: new ReferenceIcon(range.value, kind, referenceIcon)
77
81
  }).range(range.from, range.from + 1));
78
82
  }
79
83
  }