@helpai/elements 0.58.2 → 0.59.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/elements-web-component.esm.js +19 -19
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +19 -19
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +19 -19
- package/elements.esm.js.map +3 -3
- package/elements.js +19 -19
- package/elements.js.map +3 -3
- package/index.d.ts +1 -1
- package/index.mjs +37 -3
- package/package.json +1 -1
- package/schema.d.ts +26 -26
- package/web-component.mjs +37 -3
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-Daefe1g1.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
package/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ var BRAND = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// src/core/version.ts
|
|
32
|
-
var ELEMENTS_VERSION = true ? "0.
|
|
32
|
+
var ELEMENTS_VERSION = true ? "0.59.0" : "0.0.0-dev";
|
|
33
33
|
var ELEMENTS_VERSION_PARAM = "_ev";
|
|
34
34
|
|
|
35
35
|
// src/i18n/strings.ts
|
|
@@ -3208,6 +3208,8 @@ var StreamReducer = class {
|
|
|
3208
3208
|
return;
|
|
3209
3209
|
case "data-conversation-rebind":
|
|
3210
3210
|
return;
|
|
3211
|
+
case "data-suggestions":
|
|
3212
|
+
return;
|
|
3211
3213
|
default: {
|
|
3212
3214
|
const _exhaustive = chunk;
|
|
3213
3215
|
void _exhaustive;
|
|
@@ -6838,6 +6840,22 @@ function ConversationList({
|
|
|
6838
6840
|
// src/ui/suggestions.tsx
|
|
6839
6841
|
import { jsx as jsx22 } from "preact/jsx-runtime";
|
|
6840
6842
|
var p19 = BRAND.cssPrefix;
|
|
6843
|
+
function parseSuggestions(data) {
|
|
6844
|
+
const raw = data?.suggestions;
|
|
6845
|
+
if (!Array.isArray(raw)) return [];
|
|
6846
|
+
const out = [];
|
|
6847
|
+
for (const item of raw) {
|
|
6848
|
+
if (!item || typeof item !== "object") continue;
|
|
6849
|
+
const { id, label, text } = item;
|
|
6850
|
+
if (typeof label !== "string" || !label) continue;
|
|
6851
|
+
out.push({
|
|
6852
|
+
id: typeof id === "string" && id ? id : `s${out.length}`,
|
|
6853
|
+
label,
|
|
6854
|
+
text: typeof text === "string" && text ? text : label
|
|
6855
|
+
});
|
|
6856
|
+
}
|
|
6857
|
+
return out;
|
|
6858
|
+
}
|
|
6841
6859
|
function Suggestions({ suggestions, onPick }) {
|
|
6842
6860
|
if (suggestions.length === 0) return null;
|
|
6843
6861
|
return /* @__PURE__ */ jsx22("div", { class: `${p19}-suggestions`, role: "group", "aria-label": "Suggested replies", children: suggestions.map((s, i) => /* @__PURE__ */ jsx22(
|
|
@@ -8407,6 +8425,18 @@ function App({ options, hostElement, bus }) {
|
|
|
8407
8425
|
useEffect16(() => {
|
|
8408
8426
|
if (effectiveLocale !== activeLocale) setActiveLocale(effectiveLocale);
|
|
8409
8427
|
}, [effectiveLocale, activeLocale]);
|
|
8428
|
+
const pendingSuggestionsRef = useRef9(null);
|
|
8429
|
+
const captureSuggestions = useCallback6((chunk) => {
|
|
8430
|
+
if (chunk.type !== "data-suggestions") return false;
|
|
8431
|
+
pendingSuggestionsRef.current = parseSuggestions(chunk.data);
|
|
8432
|
+
return true;
|
|
8433
|
+
}, []);
|
|
8434
|
+
const flushSuggestions = useCallback6(() => {
|
|
8435
|
+
if (pendingSuggestionsRef.current) {
|
|
8436
|
+
setSuggestions(pendingSuggestionsRef.current);
|
|
8437
|
+
pendingSuggestionsRef.current = null;
|
|
8438
|
+
}
|
|
8439
|
+
}, []);
|
|
8410
8440
|
const adoptConversationRebind = useCallback6(
|
|
8411
8441
|
(chunk) => {
|
|
8412
8442
|
if (chunk.type !== "data-conversation-rebind") return false;
|
|
@@ -8426,9 +8456,10 @@ function App({ options, hostElement, bus }) {
|
|
|
8426
8456
|
const runResume = useCallback6(
|
|
8427
8457
|
async (handle) => {
|
|
8428
8458
|
let bubble = null;
|
|
8459
|
+
pendingSuggestionsRef.current = null;
|
|
8429
8460
|
try {
|
|
8430
8461
|
for await (const evt of handle.iter) {
|
|
8431
|
-
if (adoptConversationRebind(evt.chunk)) continue;
|
|
8462
|
+
if (adoptConversationRebind(evt.chunk) || captureSuggestions(evt.chunk)) continue;
|
|
8432
8463
|
if (!bubble) {
|
|
8433
8464
|
bubble = makeAssistantMessage();
|
|
8434
8465
|
resumeBubbleRef.current = bubble;
|
|
@@ -8454,6 +8485,7 @@ function App({ options, hostElement, bus }) {
|
|
|
8454
8485
|
bubble.status = "complete";
|
|
8455
8486
|
feedback.play("messageReceived");
|
|
8456
8487
|
emitMessage(bus, options, "assistant", assistantText(bubble));
|
|
8488
|
+
flushSuggestions();
|
|
8457
8489
|
}
|
|
8458
8490
|
}
|
|
8459
8491
|
} catch (err) {
|
|
@@ -8592,12 +8624,13 @@ function App({ options, hostElement, bus }) {
|
|
|
8592
8624
|
userPrefs: persistence.loadUserPrefs()
|
|
8593
8625
|
});
|
|
8594
8626
|
setStreaming(true);
|
|
8627
|
+
pendingSuggestionsRef.current = null;
|
|
8595
8628
|
const handle = transport.sendMessage(body);
|
|
8596
8629
|
setActiveCancel(() => handle.cancel);
|
|
8597
8630
|
setActiveDetach(() => handle.detach);
|
|
8598
8631
|
try {
|
|
8599
8632
|
for await (const evt of handle.iter) {
|
|
8600
|
-
if (adoptConversationRebind(evt.chunk)) continue;
|
|
8633
|
+
if (adoptConversationRebind(evt.chunk) || captureSuggestions(evt.chunk)) continue;
|
|
8601
8634
|
reducer.apply(evt.chunk);
|
|
8602
8635
|
if (evt.chunk.type === "finish" && evt.chunk.canContinue === false) {
|
|
8603
8636
|
setCanSend(false);
|
|
@@ -8616,6 +8649,7 @@ function App({ options, hostElement, bus }) {
|
|
|
8616
8649
|
assistantMsg.status = "complete";
|
|
8617
8650
|
feedback.play("messageReceived");
|
|
8618
8651
|
emitMessage(bus, options, "assistant", assistantText(assistantMsg));
|
|
8652
|
+
flushSuggestions();
|
|
8619
8653
|
}
|
|
8620
8654
|
} catch (error) {
|
|
8621
8655
|
if (isAbortError(error)) {
|
package/package.json
CHANGED
package/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, E as Endpoints, H as HandshakeResponse, L as Link, P as PAGE_AREA_SUGGESTIONS, f as PageContext, S as ServerConfig, b as SiteConfig, U as UserContext, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial, g as assetSchema, h as blocksConfigSchema, i as connectionConfigPartialSchema, j as connectionConfigSchema, k as cssColorSchema, l as cssLengthSchema, m as endpointsSchema, n as handshakeResponseSchema, o as linkSchema, p as localeSchema, q as pageContextSchema, s as serverConfigSchema, r as siteConfigSchema, u as userContextSchema, t as uuid7Schema, w as widgetConfigPartialSchema, v as widgetConfigSchema, x as widgetSettingsPartialSchema, y as widgetSettingsSchema } from './deployment-
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, E as Endpoints, H as HandshakeResponse, L as Link, P as PAGE_AREA_SUGGESTIONS, f as PageContext, S as ServerConfig, b as SiteConfig, U as UserContext, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial, g as assetSchema, h as blocksConfigSchema, i as connectionConfigPartialSchema, j as connectionConfigSchema, k as cssColorSchema, l as cssLengthSchema, m as endpointsSchema, n as handshakeResponseSchema, o as linkSchema, p as localeSchema, q as pageContextSchema, s as serverConfigSchema, r as siteConfigSchema, u as userContextSchema, t as uuid7Schema, w as widgetConfigPartialSchema, v as widgetConfigSchema, x as widgetSettingsPartialSchema, y as widgetSettingsSchema } from './deployment-Daefe1g1.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -56,9 +56,9 @@ declare const presentationSchema: z.ZodObject<{
|
|
|
56
56
|
inset: z.ZodOptional<z.ZodString>;
|
|
57
57
|
initialSize: z.ZodDefault<z.ZodEnum<{
|
|
58
58
|
fullscreen: "fullscreen";
|
|
59
|
-
normal: "normal";
|
|
60
59
|
expanded: "expanded";
|
|
61
60
|
auto: "auto";
|
|
61
|
+
normal: "normal";
|
|
62
62
|
}>>;
|
|
63
63
|
autoSizeBreakpoint: z.ZodDefault<z.ZodNumber>;
|
|
64
64
|
}, z.core.$loose>>;
|
|
@@ -242,9 +242,9 @@ type LauncherOptions = z.infer<typeof launcherOptionsSchema>;
|
|
|
242
242
|
|
|
243
243
|
declare const initialSizeSchema: z.ZodEnum<{
|
|
244
244
|
fullscreen: "fullscreen";
|
|
245
|
-
normal: "normal";
|
|
246
245
|
expanded: "expanded";
|
|
247
246
|
auto: "auto";
|
|
247
|
+
normal: "normal";
|
|
248
248
|
}>;
|
|
249
249
|
declare const resizeOptionsSchema: z.ZodObject<{
|
|
250
250
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -271,9 +271,9 @@ declare const sizeOptionsSchema: z.ZodObject<{
|
|
|
271
271
|
inset: z.ZodOptional<z.ZodString>;
|
|
272
272
|
initialSize: z.ZodDefault<z.ZodEnum<{
|
|
273
273
|
fullscreen: "fullscreen";
|
|
274
|
-
normal: "normal";
|
|
275
274
|
expanded: "expanded";
|
|
276
275
|
auto: "auto";
|
|
276
|
+
normal: "normal";
|
|
277
277
|
}>>;
|
|
278
278
|
autoSizeBreakpoint: z.ZodDefault<z.ZodNumber>;
|
|
279
279
|
}, z.core.$loose>;
|
|
@@ -325,40 +325,40 @@ type FeatureFlags = z.infer<typeof featureFlagsSchema>;
|
|
|
325
325
|
*/
|
|
326
326
|
|
|
327
327
|
declare const actionNameSchema: z.ZodEnum<{
|
|
328
|
+
close: "close";
|
|
328
329
|
expand: "expand";
|
|
329
330
|
fullscreen: "fullscreen";
|
|
330
|
-
|
|
331
|
-
language: "language";
|
|
331
|
+
clear: "clear";
|
|
332
332
|
theme: "theme";
|
|
333
|
+
language: "language";
|
|
333
334
|
textSize: "textSize";
|
|
334
335
|
history: "history";
|
|
335
|
-
clear: "clear";
|
|
336
336
|
sound: "sound";
|
|
337
337
|
}>;
|
|
338
338
|
type ActionName = z.infer<typeof actionNameSchema>;
|
|
339
339
|
declare const headerActionsSchema: z.ZodArray<z.ZodEnum<{
|
|
340
|
+
close: "close";
|
|
340
341
|
expand: "expand";
|
|
341
342
|
fullscreen: "fullscreen";
|
|
342
|
-
|
|
343
|
-
language: "language";
|
|
343
|
+
clear: "clear";
|
|
344
344
|
theme: "theme";
|
|
345
|
+
language: "language";
|
|
345
346
|
textSize: "textSize";
|
|
346
347
|
history: "history";
|
|
347
|
-
clear: "clear";
|
|
348
348
|
sound: "sound";
|
|
349
349
|
}>>;
|
|
350
350
|
type HeaderActions = z.infer<typeof headerActionsSchema>;
|
|
351
351
|
/** Section wrapper — `actions` list wrapped under `header` in the dashboard form. */
|
|
352
352
|
declare const headerSchema: z.ZodObject<{
|
|
353
353
|
actions: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
354
|
+
close: "close";
|
|
354
355
|
expand: "expand";
|
|
355
356
|
fullscreen: "fullscreen";
|
|
356
|
-
|
|
357
|
-
language: "language";
|
|
357
|
+
clear: "clear";
|
|
358
358
|
theme: "theme";
|
|
359
|
+
language: "language";
|
|
359
360
|
textSize: "textSize";
|
|
360
361
|
history: "history";
|
|
361
|
-
clear: "clear";
|
|
362
362
|
sound: "sound";
|
|
363
363
|
}>>>;
|
|
364
364
|
}, z.core.$loose>;
|
|
@@ -374,33 +374,33 @@ type HeaderOptions = z.infer<typeof headerSchema>;
|
|
|
374
374
|
*/
|
|
375
375
|
|
|
376
376
|
declare const feedbackEventSchema: z.ZodEnum<{
|
|
377
|
+
voiceStart: "voiceStart";
|
|
378
|
+
voiceStop: "voiceStop";
|
|
377
379
|
error: "error";
|
|
378
380
|
messageReceived: "messageReceived";
|
|
379
381
|
messageSent: "messageSent";
|
|
380
|
-
voiceStart: "voiceStart";
|
|
381
|
-
voiceStop: "voiceStop";
|
|
382
382
|
}>;
|
|
383
383
|
type FeedbackEvent = z.infer<typeof feedbackEventSchema>;
|
|
384
384
|
declare const soundOptionsSchema: z.ZodObject<{
|
|
385
385
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
386
386
|
volume: z.ZodDefault<z.ZodNumber>;
|
|
387
387
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
388
|
+
voiceStart: "voiceStart";
|
|
389
|
+
voiceStop: "voiceStop";
|
|
388
390
|
error: "error";
|
|
389
391
|
messageReceived: "messageReceived";
|
|
390
392
|
messageSent: "messageSent";
|
|
391
|
-
voiceStart: "voiceStart";
|
|
392
|
-
voiceStop: "voiceStop";
|
|
393
393
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>;
|
|
394
394
|
}, z.core.$loose>;
|
|
395
395
|
type SoundOptions = z.infer<typeof soundOptionsSchema>;
|
|
396
396
|
declare const hapticsOptionsSchema: z.ZodObject<{
|
|
397
397
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
398
398
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
399
|
+
voiceStart: "voiceStart";
|
|
400
|
+
voiceStop: "voiceStop";
|
|
399
401
|
error: "error";
|
|
400
402
|
messageReceived: "messageReceived";
|
|
401
403
|
messageSent: "messageSent";
|
|
402
|
-
voiceStart: "voiceStart";
|
|
403
|
-
voiceStop: "voiceStop";
|
|
404
404
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodNumber>]>>>;
|
|
405
405
|
}, z.core.$loose>;
|
|
406
406
|
type HapticsOptions = z.infer<typeof hapticsOptionsSchema>;
|
|
@@ -409,21 +409,21 @@ declare const feedbackSchema: z.ZodObject<{
|
|
|
409
409
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
410
410
|
volume: z.ZodDefault<z.ZodNumber>;
|
|
411
411
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
412
|
+
voiceStart: "voiceStart";
|
|
413
|
+
voiceStop: "voiceStop";
|
|
412
414
|
error: "error";
|
|
413
415
|
messageReceived: "messageReceived";
|
|
414
416
|
messageSent: "messageSent";
|
|
415
|
-
voiceStart: "voiceStart";
|
|
416
|
-
voiceStop: "voiceStop";
|
|
417
417
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>;
|
|
418
418
|
}, z.core.$loose>>;
|
|
419
419
|
haptics: z.ZodOptional<z.ZodObject<{
|
|
420
420
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
421
421
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
422
|
+
voiceStart: "voiceStart";
|
|
423
|
+
voiceStop: "voiceStop";
|
|
422
424
|
error: "error";
|
|
423
425
|
messageReceived: "messageReceived";
|
|
424
426
|
messageSent: "messageSent";
|
|
425
|
-
voiceStart: "voiceStart";
|
|
426
|
-
voiceStop: "voiceStop";
|
|
427
427
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodNumber>]>>>;
|
|
428
428
|
}, z.core.$loose>>;
|
|
429
429
|
}, z.core.$loose>;
|
|
@@ -858,18 +858,18 @@ type I18nOptions = z.infer<typeof i18nSchema>;
|
|
|
858
858
|
*/
|
|
859
859
|
|
|
860
860
|
declare const moduleLayoutSchema: z.ZodEnum<{
|
|
861
|
+
home: "home";
|
|
861
862
|
chat: "chat";
|
|
862
863
|
help: "help";
|
|
863
|
-
home: "home";
|
|
864
864
|
news: "news";
|
|
865
865
|
}>;
|
|
866
866
|
type ModuleLayout = z.infer<typeof moduleLayoutSchema>;
|
|
867
867
|
declare const moduleSchema: z.ZodObject<{
|
|
868
868
|
label: z.ZodString;
|
|
869
869
|
layout: z.ZodEnum<{
|
|
870
|
+
home: "home";
|
|
870
871
|
chat: "chat";
|
|
871
872
|
help: "help";
|
|
872
|
-
home: "home";
|
|
873
873
|
news: "news";
|
|
874
874
|
}>;
|
|
875
875
|
contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -895,9 +895,9 @@ type ModuleOptions = z.infer<typeof moduleSchema>;
|
|
|
895
895
|
declare const modulesSchema: z.ZodArray<z.ZodObject<{
|
|
896
896
|
label: z.ZodString;
|
|
897
897
|
layout: z.ZodEnum<{
|
|
898
|
+
home: "home";
|
|
898
899
|
chat: "chat";
|
|
899
900
|
help: "help";
|
|
900
|
-
home: "home";
|
|
901
901
|
news: "news";
|
|
902
902
|
}>;
|
|
903
903
|
contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
package/web-component.mjs
CHANGED
|
@@ -1934,7 +1934,7 @@ function createAuth(opts) {
|
|
|
1934
1934
|
}
|
|
1935
1935
|
|
|
1936
1936
|
// src/core/version.ts
|
|
1937
|
-
var ELEMENTS_VERSION = true ? "0.
|
|
1937
|
+
var ELEMENTS_VERSION = true ? "0.59.0" : "0.0.0-dev";
|
|
1938
1938
|
var ELEMENTS_VERSION_PARAM = "_ev";
|
|
1939
1939
|
|
|
1940
1940
|
// src/stream/types.ts
|
|
@@ -3167,6 +3167,8 @@ var StreamReducer = class {
|
|
|
3167
3167
|
return;
|
|
3168
3168
|
case "data-conversation-rebind":
|
|
3169
3169
|
return;
|
|
3170
|
+
case "data-suggestions":
|
|
3171
|
+
return;
|
|
3170
3172
|
default: {
|
|
3171
3173
|
const _exhaustive = chunk;
|
|
3172
3174
|
void _exhaustive;
|
|
@@ -6797,6 +6799,22 @@ function ConversationList({
|
|
|
6797
6799
|
// src/ui/suggestions.tsx
|
|
6798
6800
|
import { jsx as jsx22 } from "preact/jsx-runtime";
|
|
6799
6801
|
var p19 = BRAND.cssPrefix;
|
|
6802
|
+
function parseSuggestions(data) {
|
|
6803
|
+
const raw = data?.suggestions;
|
|
6804
|
+
if (!Array.isArray(raw)) return [];
|
|
6805
|
+
const out = [];
|
|
6806
|
+
for (const item of raw) {
|
|
6807
|
+
if (!item || typeof item !== "object") continue;
|
|
6808
|
+
const { id, label, text } = item;
|
|
6809
|
+
if (typeof label !== "string" || !label) continue;
|
|
6810
|
+
out.push({
|
|
6811
|
+
id: typeof id === "string" && id ? id : `s${out.length}`,
|
|
6812
|
+
label,
|
|
6813
|
+
text: typeof text === "string" && text ? text : label
|
|
6814
|
+
});
|
|
6815
|
+
}
|
|
6816
|
+
return out;
|
|
6817
|
+
}
|
|
6800
6818
|
function Suggestions({ suggestions, onPick }) {
|
|
6801
6819
|
if (suggestions.length === 0) return null;
|
|
6802
6820
|
return /* @__PURE__ */ jsx22("div", { class: `${p19}-suggestions`, role: "group", "aria-label": "Suggested replies", children: suggestions.map((s, i) => /* @__PURE__ */ jsx22(
|
|
@@ -8366,6 +8384,18 @@ function App({ options, hostElement, bus }) {
|
|
|
8366
8384
|
useEffect16(() => {
|
|
8367
8385
|
if (effectiveLocale !== activeLocale) setActiveLocale(effectiveLocale);
|
|
8368
8386
|
}, [effectiveLocale, activeLocale]);
|
|
8387
|
+
const pendingSuggestionsRef = useRef9(null);
|
|
8388
|
+
const captureSuggestions = useCallback6((chunk) => {
|
|
8389
|
+
if (chunk.type !== "data-suggestions") return false;
|
|
8390
|
+
pendingSuggestionsRef.current = parseSuggestions(chunk.data);
|
|
8391
|
+
return true;
|
|
8392
|
+
}, []);
|
|
8393
|
+
const flushSuggestions = useCallback6(() => {
|
|
8394
|
+
if (pendingSuggestionsRef.current) {
|
|
8395
|
+
setSuggestions(pendingSuggestionsRef.current);
|
|
8396
|
+
pendingSuggestionsRef.current = null;
|
|
8397
|
+
}
|
|
8398
|
+
}, []);
|
|
8369
8399
|
const adoptConversationRebind = useCallback6(
|
|
8370
8400
|
(chunk) => {
|
|
8371
8401
|
if (chunk.type !== "data-conversation-rebind") return false;
|
|
@@ -8385,9 +8415,10 @@ function App({ options, hostElement, bus }) {
|
|
|
8385
8415
|
const runResume = useCallback6(
|
|
8386
8416
|
async (handle) => {
|
|
8387
8417
|
let bubble = null;
|
|
8418
|
+
pendingSuggestionsRef.current = null;
|
|
8388
8419
|
try {
|
|
8389
8420
|
for await (const evt of handle.iter) {
|
|
8390
|
-
if (adoptConversationRebind(evt.chunk)) continue;
|
|
8421
|
+
if (adoptConversationRebind(evt.chunk) || captureSuggestions(evt.chunk)) continue;
|
|
8391
8422
|
if (!bubble) {
|
|
8392
8423
|
bubble = makeAssistantMessage();
|
|
8393
8424
|
resumeBubbleRef.current = bubble;
|
|
@@ -8413,6 +8444,7 @@ function App({ options, hostElement, bus }) {
|
|
|
8413
8444
|
bubble.status = "complete";
|
|
8414
8445
|
feedback.play("messageReceived");
|
|
8415
8446
|
emitMessage(bus, options, "assistant", assistantText(bubble));
|
|
8447
|
+
flushSuggestions();
|
|
8416
8448
|
}
|
|
8417
8449
|
}
|
|
8418
8450
|
} catch (err) {
|
|
@@ -8551,12 +8583,13 @@ function App({ options, hostElement, bus }) {
|
|
|
8551
8583
|
userPrefs: persistence.loadUserPrefs()
|
|
8552
8584
|
});
|
|
8553
8585
|
setStreaming(true);
|
|
8586
|
+
pendingSuggestionsRef.current = null;
|
|
8554
8587
|
const handle = transport.sendMessage(body);
|
|
8555
8588
|
setActiveCancel(() => handle.cancel);
|
|
8556
8589
|
setActiveDetach(() => handle.detach);
|
|
8557
8590
|
try {
|
|
8558
8591
|
for await (const evt of handle.iter) {
|
|
8559
|
-
if (adoptConversationRebind(evt.chunk)) continue;
|
|
8592
|
+
if (adoptConversationRebind(evt.chunk) || captureSuggestions(evt.chunk)) continue;
|
|
8560
8593
|
reducer.apply(evt.chunk);
|
|
8561
8594
|
if (evt.chunk.type === "finish" && evt.chunk.canContinue === false) {
|
|
8562
8595
|
setCanSend(false);
|
|
@@ -8575,6 +8608,7 @@ function App({ options, hostElement, bus }) {
|
|
|
8575
8608
|
assistantMsg.status = "complete";
|
|
8576
8609
|
feedback.play("messageReceived");
|
|
8577
8610
|
emitMessage(bus, options, "assistant", assistantText(assistantMsg));
|
|
8611
|
+
flushSuggestions();
|
|
8578
8612
|
}
|
|
8579
8613
|
} catch (error) {
|
|
8580
8614
|
if (isAbortError(error)) {
|