@adecore/agents-react 0.49.3 → 0.49.5

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 (52) hide show
  1. package/dist/chat/chat-references.d.ts +13 -1
  2. package/dist/chat/chat-references.js +13 -2
  3. package/dist/chat/ui/ReferenceChip.js +98 -77
  4. package/dist/chat/ui/ReferenceTrail.d.ts +11 -0
  5. package/dist/chat/ui/ReferenceTrail.js +65 -0
  6. package/dist/chat/ui/RunSettings.js +2 -2
  7. package/dist/chat/ui/SessionLine.js +1 -1
  8. package/dist/chat/ui/chips.d.ts +1 -0
  9. package/dist/chat/ui/chips.js +2 -0
  10. package/dist/chat/ui/composer/ComposerMenu.js +28 -22
  11. package/dist/chat/ui/composer/chips.d.ts +3 -2
  12. package/dist/chat/ui/composer/chips.js +21 -9
  13. package/dist/chat/ui/composer/use-prompt-menus.d.ts +1 -0
  14. package/dist/chat/ui/composer/use-prompt-menus.js +115 -121
  15. package/dist/chat/ui/reference-icons.js +3 -1
  16. package/dist/chat/ui/rows/MessageRows.js +21 -8
  17. package/dist/locales/en/agent-chat.d.ts +3 -0
  18. package/dist/locales/en/agent-chat.js +4 -1
  19. package/dist/locales/en/agent-usage.d.ts +0 -1
  20. package/dist/locales/en/agent-usage.js +0 -1
  21. package/dist/locales/nl/agent-chat.d.ts +3 -0
  22. package/dist/locales/nl/agent-chat.js +4 -1
  23. package/dist/locales/nl/agent-usage.d.ts +0 -1
  24. package/dist/locales/nl/agent-usage.js +0 -1
  25. package/dist/usage/LimitsList.d.ts +5 -2
  26. package/dist/usage/LimitsList.js +649 -231
  27. package/dist/usage/UsageBreakdown.js +1 -1
  28. package/dist/usage/UsageLimits.js +1 -1
  29. package/dist/usage/UsageLimitsCard.js +81 -54
  30. package/dist/usage/limit-groups.d.ts +4 -3
  31. package/dist/usage/limit-groups.js +21 -11
  32. package/package.json +8 -8
  33. package/src/chat/chat-references.ts +53 -4
  34. package/src/chat/ui/ReferenceChip.tsx +8 -2
  35. package/src/chat/ui/ReferenceTrail.tsx +29 -0
  36. package/src/chat/ui/RunSettings.tsx +2 -2
  37. package/src/chat/ui/SessionLine.tsx +1 -1
  38. package/src/chat/ui/chips.ts +3 -0
  39. package/src/chat/ui/composer/ComposerMenu.tsx +30 -11
  40. package/src/chat/ui/composer/chips.ts +29 -11
  41. package/src/chat/ui/composer/use-prompt-menus.ts +12 -7
  42. package/src/chat/ui/reference-icons.ts +18 -1
  43. package/src/chat/ui/rows/MessageRows.tsx +1 -0
  44. package/src/locales/en/agent-chat.ts +4 -1
  45. package/src/locales/en/agent-usage.ts +0 -1
  46. package/src/locales/nl/agent-chat.ts +4 -1
  47. package/src/locales/nl/agent-usage.ts +0 -1
  48. package/src/usage/LimitsList.tsx +183 -54
  49. package/src/usage/UsageBreakdown.tsx +1 -1
  50. package/src/usage/UsageLimits.tsx +1 -1
  51. package/src/usage/UsageLimitsCard.tsx +11 -7
  52. package/src/usage/limit-groups.ts +25 -8
@@ -3,13 +3,25 @@ export interface ProjectChat {
3
3
  id: string;
4
4
  title: string;
5
5
  }
6
- export type ReferableKind = 'canvas' | 'chat' | 'terminal' | 'note' | 'text' | 'drawing' | 'diagram' | 'browser' | 'device' | 'file' | 'database';
6
+ export type ReferableKind = 'project' | 'canvas' | 'design' | 'chat' | 'terminal' | 'note' | 'text' | 'drawing' | 'diagram' | 'browser' | 'device' | 'file' | 'database';
7
+ export interface ReferenceStep {
8
+ id: string;
9
+ name: string;
10
+ kind: ReferableKind;
11
+ }
12
+ export interface ReferenceSection {
13
+ id: string;
14
+ name: string;
15
+ current?: boolean;
16
+ }
7
17
  export interface Referable {
8
18
  id: string;
9
19
  name: string;
10
20
  kind: ReferableKind;
11
21
  detail?: string;
12
22
  group: 'canvas' | 'views';
23
+ trail?: readonly ReferenceStep[];
24
+ section?: ReferenceSection;
13
25
  }
14
26
  export interface Referables {
15
27
  items: readonly Referable[];
@@ -26,6 +26,17 @@ export function referenceTokens(ids, items, spelled = {}) {
26
26
  /* What a `#query` offers, the canvas first: never an id in `exclude`, and only chats where the machine takes no more. */
27
27
  export function referenceSuggestions(referables, query, exclude, limit) {
28
28
  const needle = query.toLowerCase();
29
- const matches = referables.items.filter(item => item.name !== '' && (!referables.chatsOnly || item.kind === 'chat') && !exclude.includes(item.id) && item.name.toLowerCase().includes(needle));
30
- return [...matches.filter(item => item.group === 'canvas'), ...matches.filter(item => item.group === 'views')].slice(0, limit);
29
+ // A name on the way counts as well, so typing a project or a canvas finds what stands in it.
30
+ const found = referables.items.filter(item => item.name !== '' && (!referables.chatsOnly || item.kind === 'chat') && !exclude.includes(item.id) && [item.name, ...(item.trail ?? []).map(step => step.name)].some(name => name.toLowerCase().includes(needle)));
31
+ // A node never stands in the menu without its canvas above it, even a canvas that does not match or is picked.
32
+ const canvases = new Set(found.flatMap(item => item.trail?.filter(step => step.kind === 'canvas').map(step => step.id) ?? []));
33
+ const matches = referables.items.filter(item => found.includes(item) || canvases.has(item.id));
34
+ const taken = new Map();
35
+ // Per section, or a large first project would keep every other one out of the menu.
36
+ return [...matches.filter(item => item.group === 'canvas'), ...matches.filter(item => item.group === 'views')].filter(item => {
37
+ const section = item.section?.id ?? '';
38
+ const count = taken.get(section) ?? 0;
39
+ taken.set(section, count + 1);
40
+ return count < limit;
41
+ });
31
42
  }
@@ -5,14 +5,15 @@ import { useTranslation } from 'react-i18next';
5
5
  import { CircleOff } from 'lucide-react';
6
6
  import { Icon } from '@adecore/ui';
7
7
  import { useChatHost } from '../../host.js';
8
- import { REFERENCE_GONE_TONE, REFERENCE_TONE, TOKEN_ICON, TOKEN_IN_MESSAGE } from './chips.js';
8
+ import { REFERENCE_GONE_TONE, REFERENCE_TONE, TOKEN_ICON, TOKEN_ICON_BOX, TOKEN_IN_MESSAGE } from './chips.js';
9
9
  import { referenceGlyph } from './reference-icons.js';
10
10
  import { ReferenceLookupContext } from './reference-lookup.js';
11
+ import { ReferenceTrail } from './ReferenceTrail.js';
11
12
  /*
12
13
  * One token in the transcript. One that opens is a span with a button's role rather than a button,
13
14
  * since a button is a box with a baseline of its own and would not sit on the line the others sit on.
14
15
  */
15
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
17
  export function TokenChip(t0) {
17
18
  const $ = _c(30);
18
19
  let className;
@@ -130,7 +131,7 @@ export function TokenChip(t0) {
130
131
  * `lastName` when the message knows what it was called.
131
132
  */
132
133
  export function ReferenceChip(t0) {
133
- const $ = _c(37);
134
+ const $ = _c(41);
134
135
  const {
135
136
  id,
136
137
  lastName
@@ -152,60 +153,67 @@ export function ReferenceChip(t0) {
152
153
  let t3;
153
154
  let t4;
154
155
  let t5;
156
+ let t6;
155
157
  if ($[0] !== ReferenceIcon || $[1] !== id || $[2] !== items || $[3] !== lastName || $[4] !== t) {
156
- t5 = Symbol.for("react.early_return_sentinel");
158
+ t6 = Symbol.for("react.early_return_sentinel");
157
159
  bb0: {
158
- let t6;
159
- if ($[12] !== id) {
160
- t6 = candidate => candidate.id === id;
161
- $[12] = id;
162
- $[13] = t6;
160
+ let t7;
161
+ if ($[13] !== id) {
162
+ t7 = candidate => candidate.id === id;
163
+ $[13] = id;
164
+ $[14] = t7;
163
165
  } else {
164
- t6 = $[13];
166
+ t7 = $[14];
165
167
  }
166
- item = items.find(t6);
168
+ item = items.find(t7);
167
169
  if (item === undefined) {
168
- let t7;
169
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
170
- t7 = /*#__PURE__*/_jsx(Icon, {
170
+ let t8;
171
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
172
+ t8 = /*#__PURE__*/_jsx(Icon, {
171
173
  icon: CircleOff,
172
174
  size: 14,
173
175
  className: TOKEN_ICON
174
176
  });
175
- $[14] = t7;
177
+ $[15] = t8;
176
178
  } else {
177
- t7 = $[14];
179
+ t8 = $[15];
178
180
  }
179
- let t8;
180
- if ($[15] !== lastName || $[16] !== t) {
181
- t8 = lastName || t("references.gone");
182
- $[15] = lastName;
183
- $[16] = t;
184
- $[17] = t8;
181
+ let t9;
182
+ if ($[16] !== lastName || $[17] !== t) {
183
+ t9 = lastName || t("references.gone");
184
+ $[16] = lastName;
185
+ $[17] = t;
186
+ $[18] = t9;
185
187
  } else {
186
- t8 = $[17];
188
+ t9 = $[18];
187
189
  }
188
- let t9;
189
- if ($[18] !== t8) {
190
- t9 = /*#__PURE__*/_jsx(TokenChip, {
190
+ let t10;
191
+ if ($[19] !== t9) {
192
+ t10 = /*#__PURE__*/_jsx(TokenChip, {
191
193
  kind: "gone",
192
- icon: t7,
193
- label: t8,
194
+ icon: t8,
195
+ label: t9,
194
196
  tone: REFERENCE_GONE_TONE
195
197
  });
196
- $[18] = t8;
197
198
  $[19] = t9;
199
+ $[20] = t10;
198
200
  } else {
199
- t9 = $[19];
201
+ t10 = $[20];
200
202
  }
201
- t5 = t9;
203
+ t6 = t10;
202
204
  break bb0;
203
205
  }
204
206
  T0 = TokenChip;
205
- t1 = "reference";
206
- t2 = item.id;
207
- t3 = "#";
208
- t4 = referenceGlyph(ReferenceIcon, {
207
+ t3 = "reference";
208
+ t4 = item.id;
209
+ t5 = "#";
210
+ t1 = item.trail !== undefined && /*#__PURE__*/_jsx(ReferenceTrail, {
211
+ trail: item.trail,
212
+ hostIcon: ReferenceIcon,
213
+ size: 14,
214
+ iconClassName: TOKEN_ICON_BOX
215
+ });
216
+ t2 = referenceGlyph(ReferenceIcon, {
209
217
  id: item.id,
210
218
  kind: item.kind,
211
219
  size: 14,
@@ -224,6 +232,7 @@ export function ReferenceChip(t0) {
224
232
  $[9] = t3;
225
233
  $[10] = t4;
226
234
  $[11] = t5;
235
+ $[12] = t6;
227
236
  } else {
228
237
  T0 = $[5];
229
238
  item = $[6];
@@ -232,59 +241,71 @@ export function ReferenceChip(t0) {
232
241
  t3 = $[9];
233
242
  t4 = $[10];
234
243
  t5 = $[11];
244
+ t6 = $[12];
235
245
  }
236
- if (t5 !== Symbol.for("react.early_return_sentinel")) {
237
- return t5;
246
+ if (t6 !== Symbol.for("react.early_return_sentinel")) {
247
+ return t6;
238
248
  }
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;
249
+ let t7;
250
+ if ($[21] !== t1 || $[22] !== t2) {
251
+ t7 = /*#__PURE__*/_jsxs(_Fragment, {
252
+ children: [t1, t2]
253
+ });
254
+ $[21] = t1;
255
+ $[22] = t2;
256
+ $[23] = t7;
245
257
  } else {
246
- t6 = $[22];
258
+ t7 = $[23];
247
259
  }
248
- const t7 = open !== null && "hover:bg-text/12";
249
260
  let t8;
250
- if ($[23] !== t7) {
251
- t8 = clsx(REFERENCE_TONE, t7);
252
- $[23] = t7;
253
- $[24] = t8;
261
+ if ($[24] !== item.name || $[25] !== t) {
262
+ t8 = item.name || t("references.untitled");
263
+ $[24] = item.name;
264
+ $[25] = t;
265
+ $[26] = t8;
254
266
  } else {
255
- t8 = $[24];
267
+ t8 = $[26];
256
268
  }
257
- let t9;
258
- if ($[25] !== item.id || $[26] !== open) {
259
- t9 = open === null ? undefined : () => open(item.id);
260
- $[25] = item.id;
261
- $[26] = open;
269
+ const t9 = open !== null && "hover:bg-text/12";
270
+ let t10;
271
+ if ($[27] !== t9) {
272
+ t10 = clsx(REFERENCE_TONE, t9);
262
273
  $[27] = t9;
274
+ $[28] = t10;
263
275
  } else {
264
- t9 = $[27];
276
+ t10 = $[28];
265
277
  }
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,
270
- value: t2,
271
- sigil: t3,
272
- icon: t4,
273
- label: t6,
274
- tone: t8,
275
- onOpen: t9
278
+ let t11;
279
+ if ($[29] !== item.id || $[30] !== open) {
280
+ t11 = open === null ? undefined : () => open(item.id);
281
+ $[29] = item.id;
282
+ $[30] = open;
283
+ $[31] = t11;
284
+ } else {
285
+ t11 = $[31];
286
+ }
287
+ let t12;
288
+ if ($[32] !== T0 || $[33] !== t10 || $[34] !== t11 || $[35] !== t3 || $[36] !== t4 || $[37] !== t5 || $[38] !== t7 || $[39] !== t8) {
289
+ t12 = /*#__PURE__*/_jsx(T0, {
290
+ kind: t3,
291
+ value: t4,
292
+ sigil: t5,
293
+ icon: t7,
294
+ label: t8,
295
+ tone: t10,
296
+ onOpen: t11
276
297
  });
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;
298
+ $[32] = T0;
299
+ $[33] = t10;
300
+ $[34] = t11;
301
+ $[35] = t3;
302
+ $[36] = t4;
303
+ $[37] = t5;
304
+ $[38] = t7;
305
+ $[39] = t8;
306
+ $[40] = t12;
286
307
  } else {
287
- t10 = $[36];
308
+ t12 = $[40];
288
309
  }
289
- return t10;
310
+ return t12;
290
311
  }
@@ -0,0 +1,11 @@
1
+ import { type ComponentType } from 'react';
2
+ import type { ReferenceIconProps } from '../../host.js';
3
+ import type { ReferenceStep } from '../chat-references.js';
4
+ interface ReferenceTrailProps {
5
+ trail: readonly ReferenceStep[];
6
+ hostIcon: ComponentType<ReferenceIconProps> | null | undefined;
7
+ size: number;
8
+ iconClassName: string;
9
+ }
10
+ export declare function ReferenceTrail({ trail, hostIcon, size, iconClassName }: ReferenceTrailProps): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,65 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Fragment } from 'react';
3
+ import { ChevronRight } from 'lucide-react';
4
+ import { Icon } from '@adecore/ui';
5
+ import { referenceGlyph } from './reference-icons.js';
6
+ /* Where a reference stands, in front of its own mark. Each place may shorten, so the name it leads to stays whole. */
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ export function ReferenceTrail(t0) {
9
+ const $ = _c(11);
10
+ const {
11
+ trail,
12
+ hostIcon,
13
+ size,
14
+ iconClassName
15
+ } = t0;
16
+ let t1;
17
+ if ($[0] !== hostIcon || $[1] !== iconClassName || $[2] !== size || $[3] !== trail) {
18
+ let t2;
19
+ if ($[5] !== hostIcon || $[6] !== iconClassName || $[7] !== size) {
20
+ t2 = step => /*#__PURE__*/_jsxs(Fragment, {
21
+ children: [/*#__PURE__*/_jsx("span", {
22
+ className: iconClassName,
23
+ children: referenceGlyph(hostIcon, {
24
+ id: step.id,
25
+ kind: step.kind,
26
+ size
27
+ })
28
+ }), /*#__PURE__*/_jsx("span", {
29
+ className: "inline-block max-w-40 truncate align-bottom",
30
+ children: step.name
31
+ }), /*#__PURE__*/_jsx(Icon, {
32
+ icon: ChevronRight,
33
+ size: 12,
34
+ className: "mx-0.5 inline align-[calc(0.5cap-6px)]!"
35
+ })]
36
+ }, step.id);
37
+ $[5] = hostIcon;
38
+ $[6] = iconClassName;
39
+ $[7] = size;
40
+ $[8] = t2;
41
+ } else {
42
+ t2 = $[8];
43
+ }
44
+ t1 = trail.map(t2);
45
+ $[0] = hostIcon;
46
+ $[1] = iconClassName;
47
+ $[2] = size;
48
+ $[3] = trail;
49
+ $[4] = t1;
50
+ } else {
51
+ t1 = $[4];
52
+ }
53
+ let t2;
54
+ if ($[9] !== t1) {
55
+ t2 = /*#__PURE__*/_jsx("span", {
56
+ className: "font-normal text-text-muted",
57
+ children: t1
58
+ });
59
+ $[9] = t1;
60
+ $[10] = t2;
61
+ } else {
62
+ t2 = $[10];
63
+ }
64
+ return t2;
65
+ }
@@ -1148,7 +1148,7 @@ function ContextRing(t0) {
1148
1148
  r: RING_RADIUS,
1149
1149
  fill: "none",
1150
1150
  strokeWidth: "2",
1151
- className: "stroke-border-strong"
1151
+ className: "stroke-track"
1152
1152
  });
1153
1153
  $[6] = t5;
1154
1154
  } else {
@@ -1258,7 +1258,7 @@ function ContextUsage(t0) {
1258
1258
  "aria-label": t("contextMeter.aria", {
1259
1259
  percent
1260
1260
  }),
1261
- className: "flex h-1.5 overflow-hidden rounded-full bg-surface-sunken",
1261
+ className: "flex h-1.5 overflow-hidden rounded-full bg-track",
1262
1262
  children: segments ? segments.map(_temp4) : /*#__PURE__*/_jsx("div", {
1263
1263
  className: clsx("h-full rounded-full bg-current", contextTone(fraction)),
1264
1264
  style: {
@@ -40,7 +40,7 @@ export function SessionLine(t0) {
40
40
  resetsAt = window.resetsAt;
41
41
  t4 = "flex items-center gap-2 text-xs text-text-faint tabular-nums";
42
42
  const t6 = true;
43
- const t7 = "relative h-1 w-14 shrink-0 rounded-full bg-surface-sunken";
43
+ const t7 = "relative h-1 w-14 shrink-0 rounded-full bg-track";
44
44
  const t8 = clsx("absolute inset-y-0 left-0 rounded-full", tone.bar);
45
45
  const t9 = `${Math.min(100, percent)}%`;
46
46
  let t10;
@@ -5,5 +5,6 @@ export declare const REFERENCE_GONE_TONE = "bg-text/4 text-text-faint shadow-[in
5
5
  export declare const CHIP_IN_EDITOR = "box-decoration-clone rounded-md px-1 py-0.5";
6
6
  export declare const TOKEN_IN_MESSAGE = "box-decoration-clone rounded-md px-1.5 py-0.5 text-xs font-medium";
7
7
  export declare const TOKEN_ICON = "mr-1 inline align-[calc(0.5cap-7px)]!";
8
+ export declare const TOKEN_ICON_BOX = "mr-1 inline-block align-[calc(0.5cap-7px)]";
8
9
  export declare const TOKEN_ICON_IN_EDITOR = "mr-1 inline-block align-[calc(0.5cap-6px)]";
9
10
  export declare const CHIP_IN_MESSAGE = "inline-flex h-5 max-w-full items-center gap-1 rounded-md px-1.5 align-[-3px] text-xs/none font-medium";
@@ -18,6 +18,8 @@ export const TOKEN_IN_MESSAGE = 'box-decoration-clone rounded-md px-1.5 py-0.5 t
18
18
  own. Its middle goes on the middle of the name's capitals, where a mark reads as centered; the middle
19
19
  of the x-height `Icon` aligns on sits low next to a capital. */
20
20
  export const TOKEN_ICON = 'mr-1 inline align-[calc(0.5cap-7px)]!';
21
+ /* The same for a box around a 14px mark, which has no baseline but its bottom edge. */
22
+ export const TOKEN_ICON_BOX = 'mr-1 inline-block align-[calc(0.5cap-7px)]';
21
23
  /* The same middle for the 12px mark the composer draws, in a box whose bottom edge is its baseline. */
22
24
  export const TOKEN_ICON_IN_EDITOR = 'mr-1 inline-block align-[calc(0.5cap-6px)]';
23
25
  /* The same pill in the transcript: a real inline box a shade smaller than the text around it, with
@@ -6,7 +6,7 @@ import { FileIcon, Icon, Menu, MiddleTruncate } from '@adecore/ui';
6
6
  import { useChatHost } from '../../../host.js';
7
7
  import { referenceGlyph } from '../reference-icons.js';
8
8
  import { optionIdOf } from './menu-aria.js';
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
10
10
  function splitPath(path) {
11
11
  const slash = path.lastIndexOf('/');
12
12
  return slash < 0 ? {
@@ -315,33 +315,45 @@ function ReferenceMenu(t0) {
315
315
  } = menus;
316
316
  let t1;
317
317
  if ($[0] !== ReferenceIcon || $[1] !== listId || $[2] !== menus || $[3] !== referenceMatches || $[4] !== t) {
318
- const groups = ["canvas", "views"].map(group => ({
319
- group,
320
- items: referenceMatches.filter(item => item.group === group)
321
- })).filter(_temp2);
318
+ const groups = new Map();
319
+ for (const item of referenceMatches) {
320
+ const key = item.section?.id ?? item.group;
321
+ groups.set(key, [...(groups.get(key) ?? []), item]);
322
+ }
322
323
  t1 = /*#__PURE__*/_jsx("div", {
323
- className: "border-b border-border px-1.5 py-1.5",
324
+ className: "max-h-96 overflow-y-auto border-b border-border px-1.5 py-1.5",
324
325
  children: referenceMatches.length > 0 ? /*#__PURE__*/_jsx("div", {
325
326
  id: listId,
326
327
  role: "listbox",
327
328
  "aria-label": t("composer.menu.references"),
328
- children: groups.map(t2 => {
329
- const {
330
- group: group_0,
331
- items
332
- } = t2;
329
+ children: [...groups].map(t2 => {
330
+ const [key_0, items] = t2;
333
331
  return /*#__PURE__*/_jsxs("div", {
334
332
  role: "group",
335
- "aria-labelledby": `${listId}-${group_0}`,
333
+ "aria-labelledby": `${listId}-${key_0}`,
336
334
  children: [/*#__PURE__*/_jsx(Menu.Label, {
337
- id: `${listId}-${group_0}`,
338
- children: t(`composer.references.${group_0}`)
335
+ id: `${listId}-${key_0}`,
336
+ className: "flex items-center gap-1.5",
337
+ children: items[0]?.section === undefined ? t(`composer.references.${items[0]?.group ?? "views"}`) : /*#__PURE__*/_jsxs(_Fragment, {
338
+ children: [referenceGlyph(ReferenceIcon, {
339
+ id: items[0].section.id,
340
+ kind: "project",
341
+ size: 14,
342
+ className: "shrink-0"
343
+ }), /*#__PURE__*/_jsx("span", {
344
+ className: "truncate font-semibold text-text",
345
+ children: items[0].section.name
346
+ }), items[0].section.current === true && /*#__PURE__*/_jsx("span", {
347
+ className: "ml-auto shrink-0 pl-2 font-normal",
348
+ children: t("composer.references.currentProject")
349
+ })]
350
+ })
339
351
  }), items.map(item_0 => {
340
352
  const index = referenceMatches.indexOf(item_0);
341
353
  return /*#__PURE__*/_jsxs(MenuOption, {
342
354
  menus: menus,
343
355
  index: index,
344
- className: "items-center",
356
+ className: clsx("items-center", item_0.trail?.at(-1)?.kind === "canvas" && "pl-6"),
345
357
  onPick: () => menus.chooseReference(item_0),
346
358
  children: [referenceGlyph(ReferenceIcon, {
347
359
  id: item_0.id,
@@ -351,13 +363,10 @@ function ReferenceMenu(t0) {
351
363
  }), /*#__PURE__*/_jsx("span", {
352
364
  className: "truncate text-text",
353
365
  children: item_0.name
354
- }), /*#__PURE__*/_jsx("span", {
355
- className: "ml-auto shrink-0 truncate pl-2 text-text-faint",
356
- children: item_0.detail ?? t(`composer.references.kinds.${item_0.kind}`)
357
366
  })]
358
367
  }, item_0.id);
359
368
  })]
360
- }, group_0);
369
+ }, key_0);
361
370
  })
362
371
  }) : /*#__PURE__*/_jsx("div", {
363
372
  className: "px-2 py-1 text-xs text-text-faint",
@@ -376,9 +385,6 @@ function ReferenceMenu(t0) {
376
385
  return t1;
377
386
  }
378
387
  /* Whichever picker the caret opened, over the box. */
379
- function _temp2(entry) {
380
- return entry.items.length > 0;
381
- }
382
388
  export function ComposerMenu(t0) {
383
389
  const $ = _c(8);
384
390
  const {
@@ -1,13 +1,14 @@
1
- import type { ComponentType } from 'react';
1
+ import { type ComponentType } from 'react';
2
2
  import { type Extension } from '@codemirror/state';
3
3
  import type { ReferenceIconProps } from '../../../host.js';
4
- import type { ReferableKind } from '../../chat-references.js';
4
+ import type { ReferableKind, ReferenceStep } from '../../chat-references.js';
5
5
  import { type ReferenceToken } from '../../mentions.js';
6
6
  export interface ChipChoices {
7
7
  mentions: string[];
8
8
  skills: string[];
9
9
  references?: ReadonlyArray<ReferenceToken & {
10
10
  kind: ReferableKind | null;
11
+ trail?: readonly ReferenceStep[];
11
12
  }>;
12
13
  referenceIcon?: ComponentType<ReferenceIconProps> | null;
13
14
  }
@@ -1,3 +1,4 @@
1
+ import { createElement, Fragment } from 'react';
1
2
  import { createRoot } from 'react-dom/client';
2
3
  import { syntaxTree } from '@codemirror/language';
3
4
  import { Facet, StateField } from '@codemirror/state';
@@ -5,6 +6,7 @@ import { Decoration, EditorView, WidgetType } from '@codemirror/view';
5
6
  import { chipRanges } from '../../mentions.js';
6
7
  import { CHIP_IN_EDITOR, MENTION_TONE, REFERENCE_TONE, SKILL_TONE, TOKEN_ICON_IN_EDITOR } from '../chips.js';
7
8
  import { referenceGlyph } from '../reference-icons.js';
9
+ import { ReferenceTrail } from '../ReferenceTrail.js';
8
10
  import { codeRanges } from './editor.js';
9
11
  const NO_CHOICES = {
10
12
  mentions: [],
@@ -30,24 +32,34 @@ class ReferenceIcon extends WidgetType {
30
32
  id;
31
33
  kind;
32
34
  hostIcon;
33
- constructor(id, kind, hostIcon) {
35
+ trail;
36
+ constructor(id, kind, hostIcon, trail) {
34
37
  super();
35
38
  this.id = id;
36
39
  this.kind = kind;
37
40
  this.hostIcon = hostIcon;
41
+ this.trail = trail;
38
42
  }
39
43
  eq(other) {
40
- return other.id === this.id && other.kind === this.kind && other.hostIcon === this.hostIcon;
44
+ return other.id === this.id && other.kind === this.kind && other.hostIcon === this.hostIcon && JSON.stringify(other.trail) === JSON.stringify(this.trail);
41
45
  }
42
46
  toDOM() {
43
47
  const holder = document.createElement('span');
44
- holder.className = TOKEN_ICON_IN_EDITOR;
45
48
  const root = createRoot(holder);
46
- root.render(referenceGlyph(this.hostIcon, {
49
+ const glyph = referenceGlyph(this.hostIcon, {
47
50
  id: this.id,
48
51
  kind: this.kind,
49
52
  size: 12
50
- }));
53
+ });
54
+ holder.className = this.trail.length > 0 ? 'inline' : TOKEN_ICON_IN_EDITOR;
55
+ root.render(this.trail.length > 0 ? createElement(Fragment, null, createElement(ReferenceTrail, {
56
+ trail: this.trail,
57
+ hostIcon: this.hostIcon,
58
+ size: 12,
59
+ iconClassName: TOKEN_ICON_IN_EDITOR
60
+ }), createElement('span', {
61
+ className: TOKEN_ICON_IN_EDITOR
62
+ }, glyph)) : glyph);
51
63
  roots.set(holder, root);
52
64
  return holder;
53
65
  }
@@ -65,7 +77,7 @@ function chipMarks(state) {
65
77
  references = [],
66
78
  referenceIcon = null
67
79
  } = state.facet(choices);
68
- const kinds = new Map(references.map(token => [token.id, token.kind]));
80
+ const tokens = new Map(references.map(token => [token.id, token]));
69
81
  const marks = [];
70
82
  // `@a.ts` in backticks is code, not a mention.
71
83
  for (const range of chipRanges(state.doc.toString(), mentions, skills, codeRanges(state), references)) {
@@ -74,10 +86,10 @@ function chipMarks(state) {
74
86
  continue;
75
87
  }
76
88
  marks.push(referenceMark.range(range.from, range.to));
77
- const kind = kinds.get(range.value);
78
- if (kind !== undefined && kind !== null) {
89
+ const token = tokens.get(range.value);
90
+ if (token?.kind !== undefined && token.kind !== null) {
79
91
  marks.push(Decoration.replace({
80
- widget: new ReferenceIcon(range.value, kind, referenceIcon)
92
+ widget: new ReferenceIcon(range.value, token.kind, referenceIcon, token.trail ?? [])
81
93
  }).range(range.from, range.from + 1));
82
94
  }
83
95
  }
@@ -57,6 +57,7 @@ export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft,
57
57
  id: string;
58
58
  name: string;
59
59
  kind: import("../../index.js").ReferableKind | null;
60
+ trail: readonly import("../../chat-references.js").ReferenceStep[] | undefined;
60
61
  }[];
61
62
  setMenuIndex: Dispatch<SetStateAction<number>>;
62
63
  trackTriggers: (value: string, selection: TextRange, state: EditorState) => void;