@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.js
CHANGED
|
@@ -12437,6 +12437,8 @@ function useChatEngine(opts) {
|
|
|
12437
12437
|
const stoppedRef = React70.useRef(false);
|
|
12438
12438
|
const abortRef = React70.useRef(null);
|
|
12439
12439
|
const serverCount = React70.useRef(0);
|
|
12440
|
+
const serverIds = React70.useRef(/* @__PURE__ */ new Set());
|
|
12441
|
+
const liveTurn = React70.useRef(null);
|
|
12440
12442
|
const threadRef = React70.useRef(null);
|
|
12441
12443
|
const mounted = React70.useRef(true);
|
|
12442
12444
|
React70.useEffect(() => {
|
|
@@ -12465,15 +12467,35 @@ function useChatEngine(opts) {
|
|
|
12465
12467
|
const data = await apiAdapter.getThread(id);
|
|
12466
12468
|
const list = [...data && data.messages || []];
|
|
12467
12469
|
serverCount.current = list.length;
|
|
12470
|
+
serverIds.current = new Set(list.map((m) => m.id));
|
|
12468
12471
|
commit(list);
|
|
12469
12472
|
return list;
|
|
12470
12473
|
}, [apiAdapter]);
|
|
12471
12474
|
async function mergeThread() {
|
|
12472
12475
|
const data = await apiAdapter.getThread(threadRef.current);
|
|
12473
12476
|
const server = data && data.messages || [];
|
|
12477
|
+
const turn = liveTurn.current;
|
|
12478
|
+
const ownIds = /* @__PURE__ */ new Set();
|
|
12479
|
+
let progress;
|
|
12480
|
+
if (turn) {
|
|
12481
|
+
for (const m of server) {
|
|
12482
|
+
if (turn.known.has(m.id)) continue;
|
|
12483
|
+
ownIds.add(m.id);
|
|
12484
|
+
if (m.role === "assistant") progress = m;
|
|
12485
|
+
}
|
|
12486
|
+
}
|
|
12474
12487
|
const ids = new Set(server.map((m) => m.id));
|
|
12475
12488
|
serverCount.current = server.length;
|
|
12476
|
-
|
|
12489
|
+
serverIds.current = ids;
|
|
12490
|
+
const next = [...server.filter((m) => !ownIds.has(m.id)), ...listRef.current.filter((m) => !ids.has(m.id))];
|
|
12491
|
+
commit(turn && progress ? next.map((m) => m.id === turn.holderId ? foldProgress(m, progress) : m) : next);
|
|
12492
|
+
}
|
|
12493
|
+
function foldProgress(holder, progress) {
|
|
12494
|
+
return Object.assign({}, holder, {
|
|
12495
|
+
steps: progress.steps ?? holder.steps,
|
|
12496
|
+
text: progress.text || holder.text,
|
|
12497
|
+
packet: progress.packet ?? holder.packet
|
|
12498
|
+
});
|
|
12477
12499
|
}
|
|
12478
12500
|
React70.useEffect(() => {
|
|
12479
12501
|
if (!apiAdapter) {
|
|
@@ -12628,6 +12650,7 @@ function useChatEngine(opts) {
|
|
|
12628
12650
|
{ id: userId, role: "user", text: turn.text || null, attachments: turn.attachments, pending: true, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
12629
12651
|
{ id: holderId, role: "assistant", text: "", streaming: !!apiAdapter.streamMessage, working: !apiAdapter.streamMessage, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
12630
12652
|
);
|
|
12653
|
+
liveTurn.current = { known: new Set(serverIds.current), holderId };
|
|
12631
12654
|
const ac = typeof AbortController !== "undefined" ? new AbortController() : { abort() {
|
|
12632
12655
|
}, signal: void 0 };
|
|
12633
12656
|
abortRef.current = ac;
|
|
@@ -12683,6 +12706,7 @@ function useChatEngine(opts) {
|
|
|
12683
12706
|
commit(listRef.current.filter((m) => m.id !== holderId));
|
|
12684
12707
|
}
|
|
12685
12708
|
} finally {
|
|
12709
|
+
liveTurn.current = null;
|
|
12686
12710
|
abortRef.current = null;
|
|
12687
12711
|
busyRef.current = false;
|
|
12688
12712
|
setBusy(false);
|