@flytedan/flytebot-design-system 0.71.2 → 0.71.4
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 +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12437,6 +12437,10 @@ 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);
|
|
12442
|
+
const lastTurnOwn = React70.useRef(/* @__PURE__ */ new Set());
|
|
12443
|
+
const retired = React70.useRef(/* @__PURE__ */ new Set());
|
|
12440
12444
|
const threadRef = React70.useRef(null);
|
|
12441
12445
|
const mounted = React70.useRef(true);
|
|
12442
12446
|
React70.useEffect(() => {
|
|
@@ -12465,15 +12469,35 @@ function useChatEngine(opts) {
|
|
|
12465
12469
|
const data = await apiAdapter.getThread(id);
|
|
12466
12470
|
const list = [...data && data.messages || []];
|
|
12467
12471
|
serverCount.current = list.length;
|
|
12472
|
+
serverIds.current = new Set(list.map((m) => m.id));
|
|
12468
12473
|
commit(list);
|
|
12469
12474
|
return list;
|
|
12470
12475
|
}, [apiAdapter]);
|
|
12471
12476
|
async function mergeThread() {
|
|
12472
12477
|
const data = await apiAdapter.getThread(threadRef.current);
|
|
12473
12478
|
const server = data && data.messages || [];
|
|
12479
|
+
const turn = liveTurn.current;
|
|
12480
|
+
const ownIds = /* @__PURE__ */ new Set();
|
|
12481
|
+
let progress;
|
|
12482
|
+
if (turn) {
|
|
12483
|
+
for (const m of server) {
|
|
12484
|
+
if (turn.known.has(m.id)) continue;
|
|
12485
|
+
ownIds.add(m.id);
|
|
12486
|
+
if (m.role === "assistant") progress = m;
|
|
12487
|
+
}
|
|
12488
|
+
}
|
|
12474
12489
|
const ids = new Set(server.map((m) => m.id));
|
|
12475
12490
|
serverCount.current = server.length;
|
|
12476
|
-
|
|
12491
|
+
serverIds.current = ids;
|
|
12492
|
+
const next = [...server.filter((m) => !ownIds.has(m.id) && !retired.current.has(m.id)), ...listRef.current.filter((m) => !ids.has(m.id))];
|
|
12493
|
+
commit(turn && progress ? next.map((m) => m.id === turn.holderId ? foldProgress(m, progress) : m) : next);
|
|
12494
|
+
}
|
|
12495
|
+
function foldProgress(holder, progress) {
|
|
12496
|
+
return Object.assign({}, holder, {
|
|
12497
|
+
steps: progress.steps ?? holder.steps,
|
|
12498
|
+
text: progress.text || holder.text,
|
|
12499
|
+
packet: progress.packet ?? holder.packet
|
|
12500
|
+
});
|
|
12477
12501
|
}
|
|
12478
12502
|
React70.useEffect(() => {
|
|
12479
12503
|
if (!apiAdapter) {
|
|
@@ -12628,6 +12652,7 @@ function useChatEngine(opts) {
|
|
|
12628
12652
|
{ id: userId, role: "user", text: turn.text || null, attachments: turn.attachments, pending: true, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
12629
12653
|
{ id: holderId, role: "assistant", text: "", streaming: !!apiAdapter.streamMessage, working: !apiAdapter.streamMessage, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
12630
12654
|
);
|
|
12655
|
+
liveTurn.current = { known: new Set(serverIds.current), holderId };
|
|
12631
12656
|
const ac = typeof AbortController !== "undefined" ? new AbortController() : { abort() {
|
|
12632
12657
|
}, signal: void 0 };
|
|
12633
12658
|
abortRef.current = ac;
|
|
@@ -12683,6 +12708,9 @@ function useChatEngine(opts) {
|
|
|
12683
12708
|
commit(listRef.current.filter((m) => m.id !== holderId));
|
|
12684
12709
|
}
|
|
12685
12710
|
} finally {
|
|
12711
|
+
const known = liveTurn.current.known;
|
|
12712
|
+
lastTurnOwn.current = new Set([...serverIds.current].filter((id2) => !known.has(id2)));
|
|
12713
|
+
liveTurn.current = null;
|
|
12686
12714
|
abortRef.current = null;
|
|
12687
12715
|
busyRef.current = false;
|
|
12688
12716
|
setBusy(false);
|
|
@@ -12743,6 +12771,7 @@ function useChatEngine(opts) {
|
|
|
12743
12771
|
const turn = list[at];
|
|
12744
12772
|
commit(list.slice(0, at));
|
|
12745
12773
|
serverCount.current = Math.max(0, serverCount.current - 1);
|
|
12774
|
+
lastTurnOwn.current.forEach((id) => retired.current.add(id));
|
|
12746
12775
|
stoppedRef.current = false;
|
|
12747
12776
|
queueRef.current = [{ id: uid("q"), text: turn.text || "", attachments: turn.attachments }].concat(queueRef.current);
|
|
12748
12777
|
setQueue(queueRef.current.slice());
|