@informedai/react 0.4.5 → 0.4.7
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/dist/index.js +11 -3
- package/dist/index.mjs +11 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var import_react2 = require("react");
|
|
|
33
33
|
|
|
34
34
|
// src/context/InformedAIContext.tsx
|
|
35
35
|
var import_react = require("react");
|
|
36
|
+
var import_react_dom = require("react-dom");
|
|
36
37
|
|
|
37
38
|
// src/utils/api-client.ts
|
|
38
39
|
var DEFAULT_API_URL = "https://api.informedassistant.ai/api/v1";
|
|
@@ -514,16 +515,23 @@ function InformedAIProvider({ config, children }) {
|
|
|
514
515
|
};
|
|
515
516
|
}, [session?.id, startHeartbeat, stopHeartbeat, handleSessionDeleted, config]);
|
|
516
517
|
const handleSSEEvent = (0, import_react.useCallback)((event) => {
|
|
518
|
+
console.log("[InformedAI] SSE event:", event.type, event);
|
|
517
519
|
if (event.type === "content" && event.content) {
|
|
518
520
|
setStreamingContent((prev) => prev + event.content);
|
|
519
521
|
}
|
|
520
522
|
if (event.type === "done" || event.type === "session_update") {
|
|
523
|
+
console.log("[InformedAI] Done event - session:", event.session);
|
|
524
|
+
console.log("[InformedAI] Done event - widgetMessages:", event.session?.widgetMessages);
|
|
525
|
+
(0, import_react_dom.flushSync)(() => {
|
|
526
|
+
if (event.session) {
|
|
527
|
+
setSession(event.session);
|
|
528
|
+
}
|
|
529
|
+
setStreamingContent("");
|
|
530
|
+
setIsStreaming(false);
|
|
531
|
+
});
|
|
521
532
|
if (event.session) {
|
|
522
|
-
setSession(event.session);
|
|
523
533
|
config.onSessionChange?.(event.session);
|
|
524
534
|
}
|
|
525
|
-
setStreamingContent("");
|
|
526
|
-
setIsStreaming(false);
|
|
527
535
|
}
|
|
528
536
|
if (event.type === "error") {
|
|
529
537
|
const error2 = new Error(event.error || "Stream error");
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { useState as useState2, useRef as useRef2, useEffect as useEffect2 } fro
|
|
|
3
3
|
|
|
4
4
|
// src/context/InformedAIContext.tsx
|
|
5
5
|
import { createContext, useContext, useEffect, useState, useCallback, useRef } from "react";
|
|
6
|
+
import { flushSync } from "react-dom";
|
|
6
7
|
|
|
7
8
|
// src/utils/api-client.ts
|
|
8
9
|
var DEFAULT_API_URL = "https://api.informedassistant.ai/api/v1";
|
|
@@ -484,16 +485,23 @@ function InformedAIProvider({ config, children }) {
|
|
|
484
485
|
};
|
|
485
486
|
}, [session?.id, startHeartbeat, stopHeartbeat, handleSessionDeleted, config]);
|
|
486
487
|
const handleSSEEvent = useCallback((event) => {
|
|
488
|
+
console.log("[InformedAI] SSE event:", event.type, event);
|
|
487
489
|
if (event.type === "content" && event.content) {
|
|
488
490
|
setStreamingContent((prev) => prev + event.content);
|
|
489
491
|
}
|
|
490
492
|
if (event.type === "done" || event.type === "session_update") {
|
|
493
|
+
console.log("[InformedAI] Done event - session:", event.session);
|
|
494
|
+
console.log("[InformedAI] Done event - widgetMessages:", event.session?.widgetMessages);
|
|
495
|
+
flushSync(() => {
|
|
496
|
+
if (event.session) {
|
|
497
|
+
setSession(event.session);
|
|
498
|
+
}
|
|
499
|
+
setStreamingContent("");
|
|
500
|
+
setIsStreaming(false);
|
|
501
|
+
});
|
|
491
502
|
if (event.session) {
|
|
492
|
-
setSession(event.session);
|
|
493
503
|
config.onSessionChange?.(event.session);
|
|
494
504
|
}
|
|
495
|
-
setStreamingContent("");
|
|
496
|
-
setIsStreaming(false);
|
|
497
505
|
}
|
|
498
506
|
if (event.type === "error") {
|
|
499
507
|
const error2 = new Error(event.error || "Stream error");
|