@flytedan/flytebot-design-system 0.71.4 → 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.js CHANGED
@@ -12478,18 +12478,24 @@ function useChatEngine(opts) {
12478
12478
  const server = data && data.messages || [];
12479
12479
  const turn = liveTurn.current;
12480
12480
  const ownIds = /* @__PURE__ */ new Set();
12481
- let progress;
12481
+ const ownAssistants = [];
12482
12482
  if (turn) {
12483
12483
  for (const m of server) {
12484
12484
  if (turn.known.has(m.id)) continue;
12485
12485
  ownIds.add(m.id);
12486
- if (m.role === "assistant") progress = m;
12486
+ if (m.role === "assistant") ownAssistants.push(m);
12487
12487
  }
12488
12488
  }
12489
+ const progress = ownAssistants.pop();
12490
+ const cards = ownAssistants;
12489
12491
  const ids = new Set(server.map((m) => m.id));
12490
12492
  serverCount.current = server.length;
12491
12493
  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))];
12494
+ const settled = server.filter((m) => !ownIds.has(m.id) && !retired.current.has(m.id));
12495
+ const local = listRef.current.filter((m) => !ids.has(m.id));
12496
+ const at = local.findIndex((m) => m.id === turn?.holderId);
12497
+ const tail = at < 0 ? [...cards, ...local] : [...local.slice(0, at), ...cards, ...local.slice(at)];
12498
+ const next = [...settled, ...tail];
12493
12499
  commit(turn && progress ? next.map((m) => m.id === turn.holderId ? foldProgress(m, progress) : m) : next);
12494
12500
  }
12495
12501
  function foldProgress(holder, progress) {