@galaxycore/ai-chat 0.8.0 → 0.10.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.
- package/CHANGELOG.md +10 -0
- package/dist/appearance-Dpvr1osR.d.ts +19 -0
- package/dist/appearance.d.ts +2 -1
- package/dist/appearance.js +1 -1
- package/dist/{branches-MrtWHEkd.js → branches-CRxWPjfD.js} +274 -3
- package/dist/branches-CRxWPjfD.js.map +1 -0
- package/dist/{branches-4UjruXJV.d.ts → branches-CUAJceMN.d.ts} +177 -3
- package/dist/context.js +1 -1
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/icons-BkHI--R-.d.ts +20 -0
- package/dist/index.d.ts +34 -3
- package/dist/index.js +838 -214
- package/dist/index.js.map +1 -1
- package/dist/styles.css +47 -0
- package/dist/{ui-primitives-BJFXxysT.js → ui-primitives-XhFvDm8o.js} +10 -2
- package/dist/ui-primitives-XhFvDm8o.js.map +1 -0
- package/docs/publishing.md +5 -5
- package/package.json +1 -1
- package/dist/appearance-Bcj6SrBr.d.ts +0 -34
- package/dist/branches-MrtWHEkd.js.map +0 -1
- package/dist/ui-primitives-BJFXxysT.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,536 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { a as zhCN,
|
|
4
|
-
import { n as ChatAppearanceProvider, r as Icon, t as ChatIconButton } from "./ui-primitives-
|
|
3
|
+
import { _ as useAiChat, a as resolveChatModelSelection, c as filterMentions, d as replaceComposerTrigger, f as slugifySkillName, g as zhCN, h as resolveLabels, i as isChatReasoningEffort, l as filterSkills, m as enUS, n as useChatBranches, o as selectChatModel, p as useComposerTrigger, r as CHAT_REASONING_EFFORTS, s as detectComposerTrigger, t as projectChatBranches, u as parseSkillMarkdown } from "./branches-CRxWPjfD.js";
|
|
4
|
+
import { n as ChatAppearanceProvider, r as Icon, t as ChatIconButton } from "./ui-primitives-XhFvDm8o.js";
|
|
5
5
|
import { i as safeUrl, n as asError, r as getMessageText, t as acceptsFile } from "./utils-DqBGBYA1.js";
|
|
6
6
|
import { SpeechInputError, createBrowserSpeechAdapter, defaultSpeechInputLabels, useSpeechInput } from "./voice.js";
|
|
7
7
|
import { MarkdownResponse } from "./markdown.js";
|
|
8
8
|
import { ContextTray, createTextSelectionAdapter, useChatContext } from "./context.js";
|
|
9
9
|
import "./appearance.js";
|
|
10
10
|
import { ChatTargetingOverlay, enUSTargetingLabels, toChatContextItem, useChatTargeting, zhCNTargetingLabels } from "./targeting.js";
|
|
11
|
-
import { useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
11
|
+
import { useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { isToolUIPart } from "ai";
|
|
14
|
+
//#region src/composer-popovers.tsx
|
|
15
|
+
function ChatSlashMenu({ skills, activeIndex, onHighlight, onSelect, onAddSkill, onBrowseSkills, labels: overrides, className = "" }) {
|
|
16
|
+
const labels = resolveLabels(overrides);
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: `gc-chat__popover gc-chat__slash-menu ${className}`.trim(),
|
|
19
|
+
role: "listbox",
|
|
20
|
+
"aria-label": labels.skillsMenu,
|
|
21
|
+
children: [skills.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
22
|
+
className: "gc-chat__popover-list",
|
|
23
|
+
children: skills.map((skill, index) => {
|
|
24
|
+
const active = index === activeIndex;
|
|
25
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
26
|
+
type: "button",
|
|
27
|
+
role: "option",
|
|
28
|
+
"aria-selected": active,
|
|
29
|
+
className: "gc-chat__popover-item",
|
|
30
|
+
"data-active": active || void 0,
|
|
31
|
+
onMouseEnter: () => onHighlight?.(index),
|
|
32
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
33
|
+
onClick: () => onSelect(skill),
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "gc-chat__popover-icon",
|
|
37
|
+
"aria-hidden": "true",
|
|
38
|
+
children: skill.icon ? /* @__PURE__ */ jsx("span", {
|
|
39
|
+
className: "gc-chat__popover-emoji",
|
|
40
|
+
children: skill.icon
|
|
41
|
+
}) : /* @__PURE__ */ jsx(Icon, {
|
|
42
|
+
name: "sparkle",
|
|
43
|
+
width: 15,
|
|
44
|
+
height: 15
|
|
45
|
+
})
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ jsxs("span", {
|
|
48
|
+
className: "gc-chat__popover-copy",
|
|
49
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
50
|
+
className: "gc-chat__popover-label",
|
|
51
|
+
children: skill.name
|
|
52
|
+
}), skill.description ? /* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: "gc-chat__popover-desc",
|
|
54
|
+
children: skill.description
|
|
55
|
+
}) : null]
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsx("span", {
|
|
58
|
+
className: "gc-chat__popover-trailing",
|
|
59
|
+
"aria-hidden": "true",
|
|
60
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
61
|
+
name: "plus",
|
|
62
|
+
width: 14,
|
|
63
|
+
height: 14
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
}, skill.id);
|
|
68
|
+
})
|
|
69
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
70
|
+
className: "gc-chat__popover-empty",
|
|
71
|
+
children: labels.noMatchingSkills
|
|
72
|
+
}), onAddSkill || onBrowseSkills ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
73
|
+
className: "gc-chat__popover-divider",
|
|
74
|
+
role: "separator"
|
|
75
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
76
|
+
className: "gc-chat__popover-footer",
|
|
77
|
+
children: [onAddSkill ? /* @__PURE__ */ jsxs("button", {
|
|
78
|
+
type: "button",
|
|
79
|
+
className: "gc-chat__popover-item",
|
|
80
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
81
|
+
onClick: onAddSkill,
|
|
82
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
83
|
+
className: "gc-chat__popover-icon",
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
86
|
+
name: "plus",
|
|
87
|
+
width: 15,
|
|
88
|
+
height: 15
|
|
89
|
+
})
|
|
90
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
91
|
+
className: "gc-chat__popover-label",
|
|
92
|
+
children: labels.addSkill
|
|
93
|
+
})]
|
|
94
|
+
}) : null, onBrowseSkills ? /* @__PURE__ */ jsxs("button", {
|
|
95
|
+
type: "button",
|
|
96
|
+
className: "gc-chat__popover-item",
|
|
97
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
98
|
+
onClick: onBrowseSkills,
|
|
99
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: "gc-chat__popover-icon",
|
|
101
|
+
"aria-hidden": "true",
|
|
102
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
103
|
+
name: "compass",
|
|
104
|
+
width: 15,
|
|
105
|
+
height: 15
|
|
106
|
+
})
|
|
107
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "gc-chat__popover-label",
|
|
109
|
+
children: labels.browseSkills
|
|
110
|
+
})]
|
|
111
|
+
}) : null]
|
|
112
|
+
})] }) : null]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function mentionIcon(kind) {
|
|
116
|
+
if (kind === "tab" || kind === "page") return "page";
|
|
117
|
+
if (kind === "image" || kind === "drawing" || kind === "region") return "scan";
|
|
118
|
+
if (kind === "table" || kind === "clause" || kind === "scope") return "layers";
|
|
119
|
+
if (kind === "query" || kind === "search") return "search";
|
|
120
|
+
if (kind === "patent" || kind === "document") return "file";
|
|
121
|
+
return "text";
|
|
122
|
+
}
|
|
123
|
+
function ChatMentionMenu({ items, activeIndex, onHighlight, onSelect, labels: overrides, className = "" }) {
|
|
124
|
+
const labels = resolveLabels(overrides);
|
|
125
|
+
const groups = [];
|
|
126
|
+
items.forEach((item, index) => {
|
|
127
|
+
const last = groups.at(-1);
|
|
128
|
+
if (last && last.name === item.group) last.entries.push({
|
|
129
|
+
item,
|
|
130
|
+
index
|
|
131
|
+
});
|
|
132
|
+
else groups.push({
|
|
133
|
+
name: item.group,
|
|
134
|
+
entries: [{
|
|
135
|
+
item,
|
|
136
|
+
index
|
|
137
|
+
}]
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
return /* @__PURE__ */ jsx("div", {
|
|
141
|
+
className: `gc-chat__popover gc-chat__mention-menu ${className}`.trim(),
|
|
142
|
+
role: "listbox",
|
|
143
|
+
"aria-label": labels.mentionMenu,
|
|
144
|
+
children: items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
145
|
+
className: "gc-chat__popover-list",
|
|
146
|
+
children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs("div", {
|
|
147
|
+
className: "gc-chat__popover-group",
|
|
148
|
+
children: [group.name ? /* @__PURE__ */ jsx("div", {
|
|
149
|
+
className: "gc-chat__popover-group-label",
|
|
150
|
+
children: group.name
|
|
151
|
+
}) : null, group.entries.map(({ item, index }) => {
|
|
152
|
+
const active = index === activeIndex;
|
|
153
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
154
|
+
type: "button",
|
|
155
|
+
role: "option",
|
|
156
|
+
"aria-selected": active,
|
|
157
|
+
disabled: item.disabled,
|
|
158
|
+
className: "gc-chat__popover-item",
|
|
159
|
+
"data-active": active || void 0,
|
|
160
|
+
onMouseEnter: () => onHighlight?.(index),
|
|
161
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
162
|
+
onClick: () => {
|
|
163
|
+
if (!item.disabled) onSelect(item);
|
|
164
|
+
},
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx("span", {
|
|
167
|
+
className: "gc-chat__popover-icon",
|
|
168
|
+
"aria-hidden": "true",
|
|
169
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
170
|
+
name: mentionIcon(item.kind),
|
|
171
|
+
width: 15,
|
|
172
|
+
height: 15
|
|
173
|
+
})
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ jsxs("span", {
|
|
176
|
+
className: "gc-chat__popover-copy",
|
|
177
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
178
|
+
className: "gc-chat__popover-label",
|
|
179
|
+
children: item.label
|
|
180
|
+
}), item.description ? /* @__PURE__ */ jsx("span", {
|
|
181
|
+
className: "gc-chat__popover-desc",
|
|
182
|
+
children: item.description
|
|
183
|
+
}) : null]
|
|
184
|
+
}),
|
|
185
|
+
item.badge ? /* @__PURE__ */ jsx("span", {
|
|
186
|
+
className: "gc-chat__popover-badge",
|
|
187
|
+
children: item.badge
|
|
188
|
+
}) : null
|
|
189
|
+
]
|
|
190
|
+
}, item.id);
|
|
191
|
+
})]
|
|
192
|
+
}, group.name ?? `group-${groupIndex}`))
|
|
193
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
194
|
+
className: "gc-chat__popover-empty",
|
|
195
|
+
children: labels.noMatchingMentions
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function ChatPlusMenu({ open, onClose, actions, labels: overrides, className = "" }) {
|
|
200
|
+
const labels = resolveLabels(overrides);
|
|
201
|
+
const menuRef = useRef(null);
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!open) return;
|
|
204
|
+
const onPointerDown = (event) => {
|
|
205
|
+
if (!menuRef.current?.contains(event.target)) onClose();
|
|
206
|
+
};
|
|
207
|
+
const onKeyDown = (event) => {
|
|
208
|
+
if (event.key === "Escape") {
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
onClose();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
214
|
+
document.addEventListener("keydown", onKeyDown);
|
|
215
|
+
return () => {
|
|
216
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
217
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
218
|
+
};
|
|
219
|
+
}, [open, onClose]);
|
|
220
|
+
if (!open || !actions.length) return null;
|
|
221
|
+
const sections = [];
|
|
222
|
+
for (const action of actions) {
|
|
223
|
+
const last = sections.at(-1);
|
|
224
|
+
if (last && last.name === action.section) last.items.push(action);
|
|
225
|
+
else sections.push({
|
|
226
|
+
name: action.section,
|
|
227
|
+
items: [action]
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return /* @__PURE__ */ jsx("div", {
|
|
231
|
+
ref: menuRef,
|
|
232
|
+
className: `gc-chat__popover gc-chat__plus-menu ${className}`.trim(),
|
|
233
|
+
role: "menu",
|
|
234
|
+
"aria-label": labels.plusMenu,
|
|
235
|
+
children: sections.map((section, sectionIndex) => /* @__PURE__ */ jsxs("div", {
|
|
236
|
+
className: "gc-chat__popover-group",
|
|
237
|
+
children: [sectionIndex > 0 ? /* @__PURE__ */ jsx("div", {
|
|
238
|
+
className: "gc-chat__popover-divider",
|
|
239
|
+
role: "separator"
|
|
240
|
+
}) : null, section.items.map((action) => {
|
|
241
|
+
if (action.trailing === "toggle") return /* @__PURE__ */ jsxs("button", {
|
|
242
|
+
type: "button",
|
|
243
|
+
role: "menuitemcheckbox",
|
|
244
|
+
"aria-checked": Boolean(action.checked),
|
|
245
|
+
disabled: action.disabled,
|
|
246
|
+
className: "gc-chat__popover-item",
|
|
247
|
+
onClick: () => action.onToggle?.(!action.checked),
|
|
248
|
+
children: [
|
|
249
|
+
action.icon ? /* @__PURE__ */ jsx("span", {
|
|
250
|
+
className: "gc-chat__popover-icon",
|
|
251
|
+
"aria-hidden": "true",
|
|
252
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
253
|
+
name: action.icon,
|
|
254
|
+
width: 15,
|
|
255
|
+
height: 15
|
|
256
|
+
})
|
|
257
|
+
}) : null,
|
|
258
|
+
/* @__PURE__ */ jsxs("span", {
|
|
259
|
+
className: "gc-chat__popover-copy",
|
|
260
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
261
|
+
className: "gc-chat__popover-label",
|
|
262
|
+
children: action.label
|
|
263
|
+
}), action.description ? /* @__PURE__ */ jsx("span", {
|
|
264
|
+
className: "gc-chat__popover-desc",
|
|
265
|
+
children: action.description
|
|
266
|
+
}) : null]
|
|
267
|
+
}),
|
|
268
|
+
/* @__PURE__ */ jsx("span", {
|
|
269
|
+
className: "gc-chat__toggle-track",
|
|
270
|
+
"data-checked": Boolean(action.checked) || void 0,
|
|
271
|
+
"aria-hidden": "true",
|
|
272
|
+
children: /* @__PURE__ */ jsx("span", { className: "gc-chat__toggle-thumb" })
|
|
273
|
+
})
|
|
274
|
+
]
|
|
275
|
+
}, action.id);
|
|
276
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
277
|
+
type: "button",
|
|
278
|
+
role: "menuitem",
|
|
279
|
+
disabled: action.disabled,
|
|
280
|
+
className: "gc-chat__popover-item",
|
|
281
|
+
onClick: () => {
|
|
282
|
+
action.onSelect?.();
|
|
283
|
+
onClose();
|
|
284
|
+
},
|
|
285
|
+
children: [
|
|
286
|
+
action.icon ? /* @__PURE__ */ jsx("span", {
|
|
287
|
+
className: "gc-chat__popover-icon",
|
|
288
|
+
"aria-hidden": "true",
|
|
289
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
290
|
+
name: action.icon,
|
|
291
|
+
width: 15,
|
|
292
|
+
height: 15
|
|
293
|
+
})
|
|
294
|
+
}) : null,
|
|
295
|
+
/* @__PURE__ */ jsxs("span", {
|
|
296
|
+
className: "gc-chat__popover-copy",
|
|
297
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
298
|
+
className: "gc-chat__popover-label",
|
|
299
|
+
children: [action.label, action.badge ? /* @__PURE__ */ jsx("span", {
|
|
300
|
+
className: "gc-chat__popover-badge",
|
|
301
|
+
children: action.badge
|
|
302
|
+
}) : null]
|
|
303
|
+
}), action.description ? /* @__PURE__ */ jsx("span", {
|
|
304
|
+
className: "gc-chat__popover-desc",
|
|
305
|
+
children: action.description
|
|
306
|
+
}) : null]
|
|
307
|
+
}),
|
|
308
|
+
action.trailing === "chevron" ? /* @__PURE__ */ jsx("span", {
|
|
309
|
+
className: "gc-chat__popover-trailing",
|
|
310
|
+
"aria-hidden": "true",
|
|
311
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
312
|
+
name: "chevron",
|
|
313
|
+
width: 14,
|
|
314
|
+
height: 14
|
|
315
|
+
})
|
|
316
|
+
}) : action.trailing === "check" && action.checked ? /* @__PURE__ */ jsx("span", {
|
|
317
|
+
className: "gc-chat__popover-trailing",
|
|
318
|
+
"aria-hidden": "true",
|
|
319
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
320
|
+
name: "check",
|
|
321
|
+
width: 14,
|
|
322
|
+
height: 14
|
|
323
|
+
})
|
|
324
|
+
}) : null
|
|
325
|
+
]
|
|
326
|
+
}, action.id);
|
|
327
|
+
})]
|
|
328
|
+
}, section.name ?? `sec-${sectionIndex}`))
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/model-picker-control.tsx
|
|
333
|
+
function effortLabel(effort, labels) {
|
|
334
|
+
switch (effort) {
|
|
335
|
+
case "none": return labels.reasoningNone;
|
|
336
|
+
case "low": return labels.reasoningLow;
|
|
337
|
+
case "medium": return labels.reasoningMedium;
|
|
338
|
+
case "high": return labels.reasoningHigh;
|
|
339
|
+
case "xhigh": return labels.reasoningXhigh;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Compact composer selector for choosing the active AI model and reasoning effort.
|
|
344
|
+
* Trigger stays visually quiet (`Model Effort ⌄`) and opens an anchored popover above the composer.
|
|
345
|
+
*/
|
|
346
|
+
function ChatModelPicker({ models, value, onChange, disabled = false, labels: overrides, className = "" }) {
|
|
347
|
+
const labels = resolveLabels(overrides);
|
|
348
|
+
const [open, setOpen] = useState(false);
|
|
349
|
+
const rootRef = useRef(null);
|
|
350
|
+
const triggerRef = useRef(null);
|
|
351
|
+
const dialogId = useId();
|
|
352
|
+
const resolved = resolveChatModelSelection(models, value);
|
|
353
|
+
const activeModel = resolved.model;
|
|
354
|
+
const activeEffort = resolved.reasoningEffort;
|
|
355
|
+
const efforts = resolved.supportedEfforts;
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
if (!open) return;
|
|
358
|
+
function onPointerDown(event) {
|
|
359
|
+
if (rootRef.current && !rootRef.current.contains(event.target)) setOpen(false);
|
|
360
|
+
}
|
|
361
|
+
function onKeyDown(event) {
|
|
362
|
+
if (event.key === "Escape") {
|
|
363
|
+
event.preventDefault();
|
|
364
|
+
setOpen(false);
|
|
365
|
+
triggerRef.current?.focus();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
369
|
+
document.addEventListener("keydown", onKeyDown);
|
|
370
|
+
return () => {
|
|
371
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
372
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
373
|
+
};
|
|
374
|
+
}, [open]);
|
|
375
|
+
useEffect(() => {
|
|
376
|
+
if (disabled && open) setOpen(false);
|
|
377
|
+
}, [disabled, open]);
|
|
378
|
+
if (!activeModel) return null;
|
|
379
|
+
const canInteract = !disabled && (models.length > 1 || efforts.length > 0);
|
|
380
|
+
const effortText = activeEffort ? effortLabel(activeEffort, labels) : void 0;
|
|
381
|
+
const triggerAccessibleName = effortText ? `${labels.selectModel}: ${activeModel.label} (${effortText})` : `${labels.selectModel}: ${activeModel.label}`;
|
|
382
|
+
function handleSelectModel(option) {
|
|
383
|
+
if (option.disabled) return;
|
|
384
|
+
onChange(selectChatModel(option, activeEffort));
|
|
385
|
+
if (!option.reasoningEfforts?.length) {
|
|
386
|
+
setOpen(false);
|
|
387
|
+
triggerRef.current?.focus();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function handleSelectEffort(effort) {
|
|
391
|
+
if (!activeModel) return;
|
|
392
|
+
onChange({
|
|
393
|
+
modelId: activeModel.id,
|
|
394
|
+
...effort !== void 0 ? { reasoningEffort: effort } : {}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
398
|
+
ref: rootRef,
|
|
399
|
+
className: `gc-chat__model-picker ${className}`.trim(),
|
|
400
|
+
"data-open": open || void 0,
|
|
401
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
402
|
+
ref: triggerRef,
|
|
403
|
+
type: "button",
|
|
404
|
+
className: "gc-chat__model-trigger",
|
|
405
|
+
disabled: disabled || !canInteract,
|
|
406
|
+
"aria-haspopup": "dialog",
|
|
407
|
+
"aria-expanded": open,
|
|
408
|
+
"aria-controls": open ? dialogId : void 0,
|
|
409
|
+
"aria-label": triggerAccessibleName,
|
|
410
|
+
onClick: () => setOpen((current) => !current),
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ jsx("span", {
|
|
413
|
+
className: "gc-chat__model-trigger-name",
|
|
414
|
+
children: activeModel.label
|
|
415
|
+
}),
|
|
416
|
+
effortText ? /* @__PURE__ */ jsx("span", {
|
|
417
|
+
className: "gc-chat__model-trigger-effort",
|
|
418
|
+
children: effortText
|
|
419
|
+
}) : null,
|
|
420
|
+
canInteract ? /* @__PURE__ */ jsx("span", {
|
|
421
|
+
className: "gc-chat__model-trigger-chevron",
|
|
422
|
+
"aria-hidden": "true",
|
|
423
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
424
|
+
name: "chevronDown",
|
|
425
|
+
width: 14,
|
|
426
|
+
height: 14
|
|
427
|
+
})
|
|
428
|
+
}) : null
|
|
429
|
+
]
|
|
430
|
+
}), open ? /* @__PURE__ */ jsxs("div", {
|
|
431
|
+
id: dialogId,
|
|
432
|
+
role: "dialog",
|
|
433
|
+
"aria-label": labels.selectModel,
|
|
434
|
+
className: "gc-chat__popover gc-chat__model-popover",
|
|
435
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
436
|
+
className: "gc-chat__model-section",
|
|
437
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
438
|
+
className: "gc-chat__popover-group-label",
|
|
439
|
+
children: labels.selectModel
|
|
440
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
441
|
+
className: "gc-chat__popover-list",
|
|
442
|
+
role: "listbox",
|
|
443
|
+
"aria-label": labels.selectModel,
|
|
444
|
+
children: models.map((option) => {
|
|
445
|
+
const selected = option.id === activeModel.id;
|
|
446
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
447
|
+
type: "button",
|
|
448
|
+
role: "option",
|
|
449
|
+
"aria-selected": selected,
|
|
450
|
+
disabled: option.disabled,
|
|
451
|
+
className: "gc-chat__popover-item gc-chat__model-option",
|
|
452
|
+
"data-selected": selected || void 0,
|
|
453
|
+
onClick: () => handleSelectModel(option),
|
|
454
|
+
children: [
|
|
455
|
+
option.icon ? /* @__PURE__ */ jsx("span", {
|
|
456
|
+
className: "gc-chat__popover-icon",
|
|
457
|
+
"aria-hidden": "true",
|
|
458
|
+
children: option.icon
|
|
459
|
+
}) : null,
|
|
460
|
+
/* @__PURE__ */ jsxs("span", {
|
|
461
|
+
className: "gc-chat__popover-copy",
|
|
462
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
463
|
+
className: "gc-chat__popover-label",
|
|
464
|
+
children: [option.label, option.badge ? /* @__PURE__ */ jsx("span", {
|
|
465
|
+
className: "gc-chat__popover-badge",
|
|
466
|
+
children: option.badge
|
|
467
|
+
}) : null]
|
|
468
|
+
}), option.description ? /* @__PURE__ */ jsx("span", {
|
|
469
|
+
className: "gc-chat__popover-desc",
|
|
470
|
+
children: option.description
|
|
471
|
+
}) : null]
|
|
472
|
+
}),
|
|
473
|
+
/* @__PURE__ */ jsx("span", {
|
|
474
|
+
className: "gc-chat__popover-trailing",
|
|
475
|
+
"aria-hidden": "true",
|
|
476
|
+
children: selected ? /* @__PURE__ */ jsx(Icon, {
|
|
477
|
+
name: "check",
|
|
478
|
+
width: 14,
|
|
479
|
+
height: 14
|
|
480
|
+
}) : null
|
|
481
|
+
})
|
|
482
|
+
]
|
|
483
|
+
}, option.id);
|
|
484
|
+
})
|
|
485
|
+
})]
|
|
486
|
+
}), efforts.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
487
|
+
className: "gc-chat__popover-divider",
|
|
488
|
+
role: "separator"
|
|
489
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
490
|
+
className: "gc-chat__model-section gc-chat__reasoning-section",
|
|
491
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
492
|
+
className: "gc-chat__reasoning-header",
|
|
493
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
494
|
+
className: "gc-chat__popover-group-label",
|
|
495
|
+
children: labels.reasoningEffort
|
|
496
|
+
}), activeEffort && !activeModel.defaultReasoningEffort ? /* @__PURE__ */ jsx("button", {
|
|
497
|
+
type: "button",
|
|
498
|
+
className: "gc-chat__reasoning-reset",
|
|
499
|
+
onClick: () => handleSelectEffort(void 0),
|
|
500
|
+
children: labels.reasoningDefault
|
|
501
|
+
}) : null]
|
|
502
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
503
|
+
className: "gc-chat__reasoning-segments",
|
|
504
|
+
role: "radiogroup",
|
|
505
|
+
"aria-label": labels.reasoningEffort,
|
|
506
|
+
children: efforts.map((effort) => {
|
|
507
|
+
const selected = activeEffort === effort;
|
|
508
|
+
return /* @__PURE__ */ jsx("button", {
|
|
509
|
+
type: "button",
|
|
510
|
+
role: "radio",
|
|
511
|
+
"aria-checked": selected,
|
|
512
|
+
className: "gc-chat__reasoning-segment",
|
|
513
|
+
"data-selected": selected || void 0,
|
|
514
|
+
onClick: () => handleSelectEffort(effort),
|
|
515
|
+
children: effortLabel(effort, labels)
|
|
516
|
+
}, effort);
|
|
517
|
+
})
|
|
518
|
+
})]
|
|
519
|
+
})] }) : null]
|
|
520
|
+
}) : null]
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
14
524
|
//#region src/chat-composer.tsx
|
|
15
525
|
/** Drafts and upload requests are isolated by conversation id. */
|
|
16
526
|
function ChatComposer(props) {
|
|
17
527
|
return /* @__PURE__ */ jsx(Composer, { ...props }, props.chat.id);
|
|
18
528
|
}
|
|
19
|
-
function Composer({ chat, labels: overrides, attachments, speech, toolbar, context, requestOptions, disabled, className = "", onActionError }) {
|
|
529
|
+
function Composer({ chat, labels: overrides, attachments, speech, skills, onSelectSkill, onAddSkill, onBrowseSkills, mentions, onSelectMention, plusMenuActions, modelPicker, toolbar, context, requestOptions, disabled, className = "", onActionError }) {
|
|
20
530
|
const labels = resolveLabels(overrides);
|
|
21
531
|
const [text, setText] = useState("");
|
|
532
|
+
const [cursor, setCursor] = useState(0);
|
|
533
|
+
const [plusOpen, setPlusOpen] = useState(false);
|
|
22
534
|
const [files, setFiles] = useState([]);
|
|
23
535
|
const [error, setError] = useState();
|
|
24
536
|
const uploads = useRef(/* @__PURE__ */ new Map());
|
|
@@ -122,6 +634,61 @@ function Composer({ chat, labels: overrides, attachments, speech, toolbar, conte
|
|
|
122
634
|
}
|
|
123
635
|
const uploading = files.some((file) => !file.part);
|
|
124
636
|
const canSend = !disabled && !chat.isBusy && !voice.isActive && !uploading && files.length <= (attachments?.maxFiles ?? 5) && (text.trim().length > 0 || files.length > 0);
|
|
637
|
+
const enabledTriggers = useMemo(() => {
|
|
638
|
+
const list = [];
|
|
639
|
+
if (skills !== void 0 || onAddSkill || onBrowseSkills) list.push("/");
|
|
640
|
+
if (mentions !== void 0) list.push("@");
|
|
641
|
+
return list;
|
|
642
|
+
}, [
|
|
643
|
+
skills,
|
|
644
|
+
onAddSkill,
|
|
645
|
+
onBrowseSkills,
|
|
646
|
+
mentions
|
|
647
|
+
]);
|
|
648
|
+
const preliminary = useComposerTrigger({
|
|
649
|
+
value: text,
|
|
650
|
+
cursor,
|
|
651
|
+
triggers: enabledTriggers,
|
|
652
|
+
enabled: !disabled && !voice.isActive && enabledTriggers.length > 0,
|
|
653
|
+
itemCount: 0
|
|
654
|
+
});
|
|
655
|
+
const filteredSkills = useMemo(() => preliminary.match?.trigger === "/" ? filterSkills(skills ?? [], preliminary.match.query) : [], [preliminary.match, skills]);
|
|
656
|
+
const filteredMentions = useMemo(() => preliminary.match?.trigger === "@" ? filterMentions(mentions ?? [], preliminary.match.query) : [], [preliminary.match, mentions]);
|
|
657
|
+
function applyReplacement(match, replacement) {
|
|
658
|
+
const next = replaceComposerTrigger(text, match, replacement);
|
|
659
|
+
setText(next.value);
|
|
660
|
+
setCursor(next.cursor);
|
|
661
|
+
draft.current = next.value;
|
|
662
|
+
requestAnimationFrame(() => {
|
|
663
|
+
textarea.current?.focus();
|
|
664
|
+
textarea.current?.setSelectionRange(next.cursor, next.cursor);
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
function commitSkill(skill, match) {
|
|
668
|
+
if (match) applyReplacement(match, onSelectSkill ? "" : `${skill.prompt}\n`);
|
|
669
|
+
onSelectSkill?.(skill);
|
|
670
|
+
}
|
|
671
|
+
function commitMention(item, match) {
|
|
672
|
+
if (match) applyReplacement(match, onSelectMention ? "" : `@${item.label} `);
|
|
673
|
+
onSelectMention?.(item);
|
|
674
|
+
}
|
|
675
|
+
const activeItemsCount = preliminary.match?.trigger === "/" ? filteredSkills.length : preliminary.match?.trigger === "@" ? filteredMentions.length : 0;
|
|
676
|
+
const trigger = useComposerTrigger({
|
|
677
|
+
value: text,
|
|
678
|
+
cursor,
|
|
679
|
+
triggers: enabledTriggers,
|
|
680
|
+
enabled: !disabled && !voice.isActive && enabledTriggers.length > 0,
|
|
681
|
+
itemCount: activeItemsCount,
|
|
682
|
+
onCommit: (index, match) => {
|
|
683
|
+
if (match.trigger === "/") {
|
|
684
|
+
const chosen = filteredSkills[index];
|
|
685
|
+
if (chosen) commitSkill(chosen, match);
|
|
686
|
+
} else {
|
|
687
|
+
const chosen = filteredMentions[index];
|
|
688
|
+
if (chosen && !chosen.disabled) commitMention(chosen, match);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
});
|
|
125
692
|
async function send() {
|
|
126
693
|
if (!canSend || sending.current) return;
|
|
127
694
|
sending.current = true;
|
|
@@ -149,225 +716,282 @@ function Composer({ chat, labels: overrides, attachments, speech, toolbar, conte
|
|
|
149
716
|
}
|
|
150
717
|
return /* @__PURE__ */ jsxs("div", {
|
|
151
718
|
className: "gc-chat__composer-wrap",
|
|
152
|
-
children: [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
719
|
+
children: [
|
|
720
|
+
trigger.open && trigger.match?.trigger === "/" ? /* @__PURE__ */ jsx(ChatSlashMenu, {
|
|
721
|
+
skills: filteredSkills,
|
|
722
|
+
activeIndex: trigger.activeIndex,
|
|
723
|
+
onHighlight: trigger.setActiveIndex,
|
|
724
|
+
onSelect: (skill) => commitSkill(skill, trigger.match),
|
|
725
|
+
onAddSkill: onAddSkill ? () => {
|
|
726
|
+
trigger.dismiss();
|
|
727
|
+
onAddSkill();
|
|
728
|
+
} : void 0,
|
|
729
|
+
onBrowseSkills: onBrowseSkills ? () => {
|
|
730
|
+
trigger.dismiss();
|
|
731
|
+
onBrowseSkills();
|
|
732
|
+
} : void 0,
|
|
733
|
+
labels: overrides
|
|
734
|
+
}) : null,
|
|
735
|
+
trigger.open && trigger.match?.trigger === "@" ? /* @__PURE__ */ jsx(ChatMentionMenu, {
|
|
736
|
+
items: filteredMentions,
|
|
737
|
+
activeIndex: trigger.activeIndex,
|
|
738
|
+
onHighlight: trigger.setActiveIndex,
|
|
739
|
+
onSelect: (item) => commitMention(item, trigger.match),
|
|
740
|
+
labels: overrides
|
|
741
|
+
}) : null,
|
|
742
|
+
plusMenuActions?.length ? /* @__PURE__ */ jsx(ChatPlusMenu, {
|
|
743
|
+
open: plusOpen,
|
|
744
|
+
onClose: () => setPlusOpen(false),
|
|
745
|
+
actions: plusMenuActions,
|
|
746
|
+
labels: overrides
|
|
747
|
+
}) : null,
|
|
748
|
+
context != null ? /* @__PURE__ */ jsx("div", {
|
|
749
|
+
className: "gc-chat__context",
|
|
750
|
+
children: context
|
|
751
|
+
}) : null,
|
|
752
|
+
/* @__PURE__ */ jsxs("form", {
|
|
753
|
+
className: `gc-chat__composer ${className}`,
|
|
754
|
+
onSubmit: (event) => {
|
|
166
755
|
event.preventDefault();
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
756
|
+
send();
|
|
757
|
+
},
|
|
758
|
+
onDragOver: (event) => {
|
|
759
|
+
if (attachments && !disabled) event.preventDefault();
|
|
760
|
+
},
|
|
761
|
+
onDrop: (event) => {
|
|
762
|
+
if (attachments && !disabled) {
|
|
763
|
+
event.preventDefault();
|
|
764
|
+
addFiles(Array.from(event.dataTransfer.files));
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
children: [
|
|
768
|
+
files.length ? /* @__PURE__ */ jsx("ul", {
|
|
769
|
+
className: "gc-chat__attachments",
|
|
770
|
+
"aria-label": labels.attach,
|
|
771
|
+
children: files.map((file) => /* @__PURE__ */ jsxs("li", {
|
|
772
|
+
className: "gc-chat__attachment",
|
|
773
|
+
children: [
|
|
774
|
+
/* @__PURE__ */ jsx(Icon, { name: "file" }),
|
|
775
|
+
/* @__PURE__ */ jsx("span", { children: file.name }),
|
|
776
|
+
!file.part ? /* @__PURE__ */ jsx("span", {
|
|
777
|
+
role: "status",
|
|
778
|
+
children: labels.uploading
|
|
779
|
+
}) : null,
|
|
780
|
+
/* @__PURE__ */ jsx(ChatIconButton, {
|
|
781
|
+
label: `${labels.removeAttachment}: ${file.name}`,
|
|
782
|
+
icon: "close",
|
|
783
|
+
onClick: () => removeFile(file.id)
|
|
784
|
+
})
|
|
785
|
+
]
|
|
786
|
+
}, file.id))
|
|
787
|
+
}) : null,
|
|
788
|
+
speech && voice.state === "consent" && /* @__PURE__ */ jsxs("div", {
|
|
789
|
+
className: "gc-chat__voice-consent",
|
|
790
|
+
role: "group",
|
|
791
|
+
"aria-label": voiceLabels.consentTitle,
|
|
176
792
|
children: [
|
|
177
|
-
/* @__PURE__ */ jsx(
|
|
178
|
-
/* @__PURE__ */ jsx("
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
793
|
+
/* @__PURE__ */ jsx("strong", { children: voiceLabels.consentTitle }),
|
|
794
|
+
/* @__PURE__ */ jsx("p", {
|
|
795
|
+
className: "gc-chat__voice-disclosure",
|
|
796
|
+
children: voice.disclosure
|
|
797
|
+
}),
|
|
798
|
+
/* @__PURE__ */ jsxs("label", {
|
|
799
|
+
className: "gc-chat__voice-remember",
|
|
800
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
801
|
+
type: "checkbox",
|
|
802
|
+
checked: rememberSpeech,
|
|
803
|
+
onChange: (event) => setRememberSpeech(event.target.checked)
|
|
804
|
+
}), voiceLabels.remember]
|
|
805
|
+
}),
|
|
806
|
+
/* @__PURE__ */ jsxs("div", {
|
|
807
|
+
className: "gc-chat__voice-actions",
|
|
808
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
809
|
+
type: "button",
|
|
810
|
+
className: "gc-chat__button",
|
|
811
|
+
disabled: disabled || chat.isBusy,
|
|
812
|
+
onClick: () => voice.confirm(rememberSpeech),
|
|
813
|
+
children: voiceLabels.confirm
|
|
814
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
815
|
+
type: "button",
|
|
816
|
+
className: "gc-chat__button",
|
|
817
|
+
onClick: voice.cancel,
|
|
818
|
+
children: voiceLabels.cancel
|
|
819
|
+
})]
|
|
187
820
|
})
|
|
188
821
|
]
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
role: "group",
|
|
194
|
-
"aria-label": voiceLabels.consentTitle,
|
|
195
|
-
children: [
|
|
196
|
-
/* @__PURE__ */ jsx("strong", { children: voiceLabels.consentTitle }),
|
|
197
|
-
/* @__PURE__ */ jsx("p", {
|
|
198
|
-
className: "gc-chat__voice-disclosure",
|
|
199
|
-
children: voice.disclosure
|
|
200
|
-
}),
|
|
201
|
-
/* @__PURE__ */ jsxs("label", {
|
|
202
|
-
className: "gc-chat__voice-remember",
|
|
203
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
204
|
-
type: "checkbox",
|
|
205
|
-
checked: rememberSpeech,
|
|
206
|
-
onChange: (event) => setRememberSpeech(event.target.checked)
|
|
207
|
-
}), voiceLabels.remember]
|
|
208
|
-
}),
|
|
209
|
-
/* @__PURE__ */ jsxs("div", {
|
|
210
|
-
className: "gc-chat__voice-actions",
|
|
211
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
212
|
-
type: "button",
|
|
213
|
-
className: "gc-chat__button",
|
|
214
|
-
disabled: disabled || chat.isBusy,
|
|
215
|
-
onClick: () => voice.confirm(rememberSpeech),
|
|
216
|
-
children: voiceLabels.confirm
|
|
217
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
218
|
-
type: "button",
|
|
219
|
-
className: "gc-chat__button",
|
|
220
|
-
onClick: voice.cancel,
|
|
221
|
-
children: voiceLabels.cancel
|
|
222
|
-
})]
|
|
223
|
-
})
|
|
224
|
-
]
|
|
225
|
-
}),
|
|
226
|
-
speech && voice.isActive && /* @__PURE__ */ jsxs("div", {
|
|
227
|
-
className: "gc-chat__voice",
|
|
228
|
-
"data-state": voice.state,
|
|
229
|
-
children: [
|
|
230
|
-
/* @__PURE__ */ jsxs("span", {
|
|
231
|
-
className: "gc-chat__voice-wave",
|
|
232
|
-
"aria-hidden": "true",
|
|
233
|
-
children: [
|
|
234
|
-
/* @__PURE__ */ jsx("i", {}),
|
|
235
|
-
/* @__PURE__ */ jsx("i", {}),
|
|
236
|
-
/* @__PURE__ */ jsx("i", {}),
|
|
237
|
-
/* @__PURE__ */ jsx("i", {}),
|
|
238
|
-
/* @__PURE__ */ jsx("i", {})
|
|
239
|
-
]
|
|
240
|
-
}),
|
|
241
|
-
/* @__PURE__ */ jsx("span", {
|
|
242
|
-
className: "gc-chat__voice-status",
|
|
243
|
-
role: "status",
|
|
244
|
-
children: voice.state === "starting" ? voiceLabels.starting : voice.state === "stopping" ? voiceLabels.stopping : voiceLabels.listening
|
|
245
|
-
}),
|
|
246
|
-
/* @__PURE__ */ jsxs("div", {
|
|
247
|
-
className: "gc-chat__voice-actions",
|
|
248
|
-
children: [/* @__PURE__ */ jsx(ChatIconButton, {
|
|
249
|
-
disabled: voice.state === "stopping",
|
|
250
|
-
label: voiceLabels.finish,
|
|
251
|
-
icon: "check",
|
|
252
|
-
onClick: voice.stop
|
|
253
|
-
}), /* @__PURE__ */ jsx(ChatIconButton, {
|
|
254
|
-
label: voiceLabels.cancel,
|
|
255
|
-
icon: "close",
|
|
256
|
-
onClick: voice.cancel
|
|
257
|
-
})]
|
|
258
|
-
}),
|
|
259
|
-
/* @__PURE__ */ jsxs("p", {
|
|
260
|
-
className: "gc-chat__voice-transcript",
|
|
261
|
-
children: [
|
|
262
|
-
voice.result.finalText,
|
|
263
|
-
/* @__PURE__ */ jsx("span", { children: voice.result.interimText }),
|
|
264
|
-
!voice.result.finalText && !voice.result.interimText ? voiceLabels.empty : null
|
|
265
|
-
]
|
|
266
|
-
})
|
|
267
|
-
]
|
|
268
|
-
}),
|
|
269
|
-
speech && !voice.support.supported && /* @__PURE__ */ jsx("p", {
|
|
270
|
-
id: `${inputId}-voice-support`,
|
|
271
|
-
className: "gc-chat__voice-unsupported",
|
|
272
|
-
children: voice.support.reason
|
|
273
|
-
}),
|
|
274
|
-
speech && voice.error && /* @__PURE__ */ jsx("p", {
|
|
275
|
-
className: "gc-chat__voice-error",
|
|
276
|
-
role: "alert",
|
|
277
|
-
children: voice.error.message
|
|
278
|
-
}),
|
|
279
|
-
/* @__PURE__ */ jsx("textarea", {
|
|
280
|
-
ref: textarea,
|
|
281
|
-
className: "gc-chat__input",
|
|
282
|
-
"aria-label": labels.placeholder,
|
|
283
|
-
placeholder: labels.placeholder,
|
|
284
|
-
value: text,
|
|
285
|
-
rows: 2,
|
|
286
|
-
disabled,
|
|
287
|
-
onChange: (event) => setText(event.target.value),
|
|
288
|
-
onPaste: (event) => {
|
|
289
|
-
if (attachments && event.clipboardData.files.length) {
|
|
290
|
-
event.preventDefault();
|
|
291
|
-
addFiles(Array.from(event.clipboardData.files));
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
onKeyDown: (event) => {
|
|
295
|
-
if (event.key === "Escape" && !event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
296
|
-
event.currentTarget.blur();
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
300
|
-
event.preventDefault();
|
|
301
|
-
send();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}),
|
|
305
|
-
/* @__PURE__ */ jsxs("div", {
|
|
306
|
-
className: "gc-chat__composer-bottom",
|
|
307
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
308
|
-
className: "gc-chat__toolbar",
|
|
822
|
+
}),
|
|
823
|
+
speech && voice.isActive && /* @__PURE__ */ jsxs("div", {
|
|
824
|
+
className: "gc-chat__voice",
|
|
825
|
+
"data-state": voice.state,
|
|
309
826
|
children: [
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
827
|
+
/* @__PURE__ */ jsxs("span", {
|
|
828
|
+
className: "gc-chat__voice-wave",
|
|
829
|
+
"aria-hidden": "true",
|
|
830
|
+
children: [
|
|
831
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
832
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
833
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
834
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
835
|
+
/* @__PURE__ */ jsx("i", {})
|
|
836
|
+
]
|
|
837
|
+
}),
|
|
838
|
+
/* @__PURE__ */ jsx("span", {
|
|
839
|
+
className: "gc-chat__voice-status",
|
|
840
|
+
role: "status",
|
|
841
|
+
children: voice.state === "starting" ? voiceLabels.starting : voice.state === "stopping" ? voiceLabels.stopping : voiceLabels.listening
|
|
842
|
+
}),
|
|
843
|
+
/* @__PURE__ */ jsxs("div", {
|
|
844
|
+
className: "gc-chat__voice-actions",
|
|
845
|
+
children: [/* @__PURE__ */ jsx(ChatIconButton, {
|
|
846
|
+
disabled: voice.state === "stopping",
|
|
847
|
+
label: voiceLabels.finish,
|
|
848
|
+
icon: "check",
|
|
849
|
+
onClick: voice.stop
|
|
850
|
+
}), /* @__PURE__ */ jsx(ChatIconButton, {
|
|
851
|
+
label: voiceLabels.cancel,
|
|
852
|
+
icon: "close",
|
|
853
|
+
onClick: voice.cancel
|
|
854
|
+
})]
|
|
855
|
+
}),
|
|
856
|
+
/* @__PURE__ */ jsxs("p", {
|
|
857
|
+
className: "gc-chat__voice-transcript",
|
|
858
|
+
children: [
|
|
859
|
+
voice.result.finalText,
|
|
860
|
+
/* @__PURE__ */ jsx("span", { children: voice.result.interimText }),
|
|
861
|
+
!voice.result.finalText && !voice.result.interimText ? voiceLabels.empty : null
|
|
862
|
+
]
|
|
332
863
|
})
|
|
333
864
|
]
|
|
334
|
-
}),
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
865
|
+
}),
|
|
866
|
+
speech && !voice.support.supported && /* @__PURE__ */ jsx("p", {
|
|
867
|
+
id: `${inputId}-voice-support`,
|
|
868
|
+
className: "gc-chat__voice-unsupported",
|
|
869
|
+
children: voice.support.reason
|
|
870
|
+
}),
|
|
871
|
+
speech && voice.error && /* @__PURE__ */ jsx("p", {
|
|
872
|
+
className: "gc-chat__voice-error",
|
|
873
|
+
role: "alert",
|
|
874
|
+
children: voice.error.message
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
877
|
+
ref: textarea,
|
|
878
|
+
className: "gc-chat__input",
|
|
879
|
+
"aria-label": labels.placeholder,
|
|
880
|
+
placeholder: labels.placeholder,
|
|
881
|
+
value: text,
|
|
882
|
+
rows: 2,
|
|
883
|
+
disabled,
|
|
884
|
+
onChange: (event) => {
|
|
885
|
+
setText(event.target.value);
|
|
886
|
+
setCursor(event.target.selectionStart ?? event.target.value.length);
|
|
887
|
+
},
|
|
888
|
+
onSelect: (event) => setCursor(event.currentTarget.selectionStart ?? text.length),
|
|
889
|
+
onClick: (event) => setCursor(event.currentTarget.selectionStart ?? text.length),
|
|
890
|
+
onPaste: (event) => {
|
|
891
|
+
if (attachments && event.clipboardData.files.length) {
|
|
348
892
|
event.preventDefault();
|
|
349
|
-
|
|
893
|
+
addFiles(Array.from(event.clipboardData.files));
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
onKeyDown: (event) => {
|
|
897
|
+
if (trigger.handleKeyDown(event)) return;
|
|
898
|
+
if (event.key === "Escape" && !event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
899
|
+
if (plusOpen) {
|
|
900
|
+
setPlusOpen(false);
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
event.currentTarget.blur();
|
|
904
|
+
return;
|
|
350
905
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
906
|
+
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
907
|
+
event.preventDefault();
|
|
908
|
+
send();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}),
|
|
912
|
+
/* @__PURE__ */ jsxs("div", {
|
|
913
|
+
className: "gc-chat__composer-bottom",
|
|
914
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
915
|
+
className: "gc-chat__toolbar",
|
|
916
|
+
children: [
|
|
917
|
+
attachments ? /* @__PURE__ */ jsx("input", {
|
|
918
|
+
ref: fileInput,
|
|
919
|
+
id: inputId,
|
|
920
|
+
type: "file",
|
|
921
|
+
hidden: true,
|
|
922
|
+
multiple: true,
|
|
923
|
+
accept: attachments.accept,
|
|
924
|
+
disabled,
|
|
925
|
+
onChange: (event) => {
|
|
926
|
+
addFiles(Array.from(event.target.files ?? []));
|
|
927
|
+
event.target.value = "";
|
|
928
|
+
}
|
|
929
|
+
}) : null,
|
|
930
|
+
plusMenuActions?.length ? /* @__PURE__ */ jsx(ChatIconButton, {
|
|
931
|
+
disabled,
|
|
932
|
+
label: labels.plusMenu,
|
|
933
|
+
icon: plusOpen ? "close" : "plus",
|
|
934
|
+
"aria-expanded": plusOpen,
|
|
935
|
+
"aria-haspopup": "menu",
|
|
936
|
+
onClick: () => setPlusOpen((current) => !current)
|
|
937
|
+
}) : attachments ? /* @__PURE__ */ jsx(ChatIconButton, {
|
|
938
|
+
disabled,
|
|
939
|
+
label: labels.attach,
|
|
940
|
+
icon: "plus",
|
|
941
|
+
onClick: () => fileInput.current?.click()
|
|
942
|
+
}) : null,
|
|
943
|
+
toolbar,
|
|
944
|
+
!attachments && !speech && toolbar == null && /* @__PURE__ */ jsx("span", {
|
|
945
|
+
className: "gc-chat__input-hint",
|
|
946
|
+
children: labels.composerHint
|
|
947
|
+
})
|
|
948
|
+
]
|
|
949
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
950
|
+
className: "gc-chat__composer-actions",
|
|
951
|
+
children: [
|
|
952
|
+
modelPicker ? /* @__PURE__ */ jsx(ChatModelPicker, {
|
|
953
|
+
...modelPicker,
|
|
954
|
+
labels: overrides,
|
|
955
|
+
disabled: disabled || chat.isBusy || modelPicker.disabled
|
|
956
|
+
}) : null,
|
|
957
|
+
speech && /* @__PURE__ */ jsx(ChatIconButton, {
|
|
958
|
+
label: voiceLabels.start,
|
|
959
|
+
icon: "mic",
|
|
960
|
+
tooltip: voice.support.reason ?? voiceLabels.start,
|
|
961
|
+
"aria-describedby": !voice.support.supported ? `${inputId}-voice-support` : void 0,
|
|
962
|
+
disabled: disabled || chat.isBusy || voice.isActive || voice.state === "consent" || !voice.support.supported,
|
|
963
|
+
onClick: voice.start
|
|
964
|
+
}),
|
|
965
|
+
chat.isBusy ? /* @__PURE__ */ jsx(ChatIconButton, {
|
|
966
|
+
className: "gc-chat__send",
|
|
967
|
+
label: labels.stop,
|
|
968
|
+
icon: "stop",
|
|
969
|
+
onClick: (event) => {
|
|
970
|
+
event.preventDefault();
|
|
971
|
+
chat.stop().catch(report);
|
|
972
|
+
}
|
|
973
|
+
}) : /* @__PURE__ */ jsx(ChatIconButton, {
|
|
974
|
+
className: "gc-chat__send",
|
|
975
|
+
type: "submit",
|
|
976
|
+
disabled: !canSend,
|
|
977
|
+
label: labels.send,
|
|
978
|
+
icon: "send"
|
|
979
|
+
})
|
|
980
|
+
]
|
|
357
981
|
})]
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
982
|
+
}),
|
|
983
|
+
error ? /* @__PURE__ */ jsxs("div", {
|
|
984
|
+
className: "gc-chat__error",
|
|
985
|
+
role: "alert",
|
|
986
|
+
children: [error, /* @__PURE__ */ jsx(ChatIconButton, {
|
|
987
|
+
label: labels.dismiss,
|
|
988
|
+
icon: "close",
|
|
989
|
+
onClick: () => setError(void 0)
|
|
990
|
+
})]
|
|
991
|
+
}) : null
|
|
992
|
+
]
|
|
993
|
+
})
|
|
994
|
+
]
|
|
371
995
|
});
|
|
372
996
|
}
|
|
373
997
|
function fitTextarea(element) {
|
|
@@ -1634,6 +2258,6 @@ function ChatHistoryMenu({ conversations, currentId, onSelect, onNewChat, disabl
|
|
|
1634
2258
|
});
|
|
1635
2259
|
}
|
|
1636
2260
|
//#endregion
|
|
1637
|
-
export { AiChat, ChatAppearanceProvider, ChatBranchSwitcher, ChatCheckpointBanner, ChatComposer, ChatHistoryMenu, Icon as ChatIcon, ChatIconButton, ChatMessages, ChatPanel, ChatTargetingOverlay, ContextTray, SpeechInputError, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, enUS, enUSTargetingLabels, getMessageText, projectChatBranches, toChatContextItem, useAiChat, useChatBranches, useChatContext, useChatTargeting, useSpeechInput, zhCN, zhCNTargetingLabels };
|
|
2261
|
+
export { AiChat, CHAT_REASONING_EFFORTS, ChatAppearanceProvider, ChatBranchSwitcher, ChatCheckpointBanner, ChatComposer, ChatHistoryMenu, Icon as ChatIcon, ChatIconButton, ChatMentionMenu, ChatMessages, ChatModelPicker, ChatPanel, ChatPlusMenu, ChatSlashMenu, ChatTargetingOverlay, ContextTray, SpeechInputError, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, enUSTargetingLabels, filterMentions, filterSkills, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatModelSelection, selectChatModel, slugifySkillName, toChatContextItem, useAiChat, useChatBranches, useChatContext, useChatTargeting, useComposerTrigger, useSpeechInput, zhCN, zhCNTargetingLabels };
|
|
1638
2262
|
|
|
1639
2263
|
//# sourceMappingURL=index.js.map
|