@flytedan/flytebot-design-system 0.71.2 → 0.71.3
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.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13614,6 +13614,8 @@ function useChatEngine(opts) {
|
|
|
13614
13614
|
const stoppedRef = React70.useRef(false);
|
|
13615
13615
|
const abortRef = React70.useRef(null);
|
|
13616
13616
|
const serverCount = React70.useRef(0);
|
|
13617
|
+
const serverIds = React70.useRef(/* @__PURE__ */ new Set());
|
|
13618
|
+
const liveTurn = React70.useRef(null);
|
|
13617
13619
|
const threadRef = React70.useRef(null);
|
|
13618
13620
|
const mounted = React70.useRef(true);
|
|
13619
13621
|
React70.useEffect(() => {
|
|
@@ -13642,15 +13644,35 @@ function useChatEngine(opts) {
|
|
|
13642
13644
|
const data = await apiAdapter.getThread(id);
|
|
13643
13645
|
const list = [...data && data.messages || []];
|
|
13644
13646
|
serverCount.current = list.length;
|
|
13647
|
+
serverIds.current = new Set(list.map((m) => m.id));
|
|
13645
13648
|
commit(list);
|
|
13646
13649
|
return list;
|
|
13647
13650
|
}, [apiAdapter]);
|
|
13648
13651
|
async function mergeThread() {
|
|
13649
13652
|
const data = await apiAdapter.getThread(threadRef.current);
|
|
13650
13653
|
const server = data && data.messages || [];
|
|
13654
|
+
const turn = liveTurn.current;
|
|
13655
|
+
const ownIds = /* @__PURE__ */ new Set();
|
|
13656
|
+
let progress;
|
|
13657
|
+
if (turn) {
|
|
13658
|
+
for (const m of server) {
|
|
13659
|
+
if (turn.known.has(m.id)) continue;
|
|
13660
|
+
ownIds.add(m.id);
|
|
13661
|
+
if (m.role === "assistant") progress = m;
|
|
13662
|
+
}
|
|
13663
|
+
}
|
|
13651
13664
|
const ids = new Set(server.map((m) => m.id));
|
|
13652
13665
|
serverCount.current = server.length;
|
|
13653
|
-
|
|
13666
|
+
serverIds.current = ids;
|
|
13667
|
+
const next = [...server.filter((m) => !ownIds.has(m.id)), ...listRef.current.filter((m) => !ids.has(m.id))];
|
|
13668
|
+
commit(turn && progress ? next.map((m) => m.id === turn.holderId ? foldProgress(m, progress) : m) : next);
|
|
13669
|
+
}
|
|
13670
|
+
function foldProgress(holder, progress) {
|
|
13671
|
+
return Object.assign({}, holder, {
|
|
13672
|
+
steps: progress.steps ?? holder.steps,
|
|
13673
|
+
text: progress.text || holder.text,
|
|
13674
|
+
packet: progress.packet ?? holder.packet
|
|
13675
|
+
});
|
|
13654
13676
|
}
|
|
13655
13677
|
React70.useEffect(() => {
|
|
13656
13678
|
if (!apiAdapter) {
|
|
@@ -13805,6 +13827,7 @@ function useChatEngine(opts) {
|
|
|
13805
13827
|
{ id: userId, role: "user", text: turn.text || null, attachments: turn.attachments, pending: true, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
13806
13828
|
{ id: holderId, role: "assistant", text: "", streaming: !!apiAdapter.streamMessage, working: !apiAdapter.streamMessage, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
13807
13829
|
);
|
|
13830
|
+
liveTurn.current = { known: new Set(serverIds.current), holderId };
|
|
13808
13831
|
const ac = typeof AbortController !== "undefined" ? new AbortController() : { abort() {
|
|
13809
13832
|
}, signal: void 0 };
|
|
13810
13833
|
abortRef.current = ac;
|
|
@@ -13860,6 +13883,7 @@ function useChatEngine(opts) {
|
|
|
13860
13883
|
commit(listRef.current.filter((m) => m.id !== holderId));
|
|
13861
13884
|
}
|
|
13862
13885
|
} finally {
|
|
13886
|
+
liveTurn.current = null;
|
|
13863
13887
|
abortRef.current = null;
|
|
13864
13888
|
busyRef.current = false;
|
|
13865
13889
|
setBusy(false);
|