@flytedan/flytebot-design-system 0.71.3 → 0.71.5

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 CHANGED
@@ -13616,6 +13616,8 @@ function useChatEngine(opts) {
13616
13616
  const serverCount = React70.useRef(0);
13617
13617
  const serverIds = React70.useRef(/* @__PURE__ */ new Set());
13618
13618
  const liveTurn = React70.useRef(null);
13619
+ const lastTurnOwn = React70.useRef(/* @__PURE__ */ new Set());
13620
+ const retired = React70.useRef(/* @__PURE__ */ new Set());
13619
13621
  const threadRef = React70.useRef(null);
13620
13622
  const mounted = React70.useRef(true);
13621
13623
  React70.useEffect(() => {
@@ -13653,18 +13655,24 @@ function useChatEngine(opts) {
13653
13655
  const server = data && data.messages || [];
13654
13656
  const turn = liveTurn.current;
13655
13657
  const ownIds = /* @__PURE__ */ new Set();
13656
- let progress;
13658
+ const ownAssistants = [];
13657
13659
  if (turn) {
13658
13660
  for (const m of server) {
13659
13661
  if (turn.known.has(m.id)) continue;
13660
13662
  ownIds.add(m.id);
13661
- if (m.role === "assistant") progress = m;
13663
+ if (m.role === "assistant") ownAssistants.push(m);
13662
13664
  }
13663
13665
  }
13666
+ const progress = ownAssistants.pop();
13667
+ const cards = ownAssistants;
13664
13668
  const ids = new Set(server.map((m) => m.id));
13665
13669
  serverCount.current = server.length;
13666
13670
  serverIds.current = ids;
13667
- const next = [...server.filter((m) => !ownIds.has(m.id)), ...listRef.current.filter((m) => !ids.has(m.id))];
13671
+ const settled = server.filter((m) => !ownIds.has(m.id) && !retired.current.has(m.id));
13672
+ const local = listRef.current.filter((m) => !ids.has(m.id));
13673
+ const at = local.findIndex((m) => m.id === turn?.holderId);
13674
+ const tail = at < 0 ? [...cards, ...local] : [...local.slice(0, at), ...cards, ...local.slice(at)];
13675
+ const next = [...settled, ...tail];
13668
13676
  commit(turn && progress ? next.map((m) => m.id === turn.holderId ? foldProgress(m, progress) : m) : next);
13669
13677
  }
13670
13678
  function foldProgress(holder, progress) {
@@ -13883,6 +13891,8 @@ function useChatEngine(opts) {
13883
13891
  commit(listRef.current.filter((m) => m.id !== holderId));
13884
13892
  }
13885
13893
  } finally {
13894
+ const known = liveTurn.current.known;
13895
+ lastTurnOwn.current = new Set([...serverIds.current].filter((id2) => !known.has(id2)));
13886
13896
  liveTurn.current = null;
13887
13897
  abortRef.current = null;
13888
13898
  busyRef.current = false;
@@ -13944,6 +13954,7 @@ function useChatEngine(opts) {
13944
13954
  const turn = list[at];
13945
13955
  commit(list.slice(0, at));
13946
13956
  serverCount.current = Math.max(0, serverCount.current - 1);
13957
+ lastTurnOwn.current.forEach((id) => retired.current.add(id));
13947
13958
  stoppedRef.current = false;
13948
13959
  queueRef.current = [{ id: uid("q"), text: turn.text || "", attachments: turn.attachments }].concat(queueRef.current);
13949
13960
  setQueue(queueRef.current.slice());