@flytedan/flytebot-design-system 0.71.5 → 0.71.6

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
@@ -12434,6 +12434,7 @@ function useChatEngine(opts) {
12434
12434
  const listRef = React70.useRef([]);
12435
12435
  const queueRef = React70.useRef([]);
12436
12436
  const busyRef = React70.useRef(false);
12437
+ const loadedRef = React70.useRef(false);
12437
12438
  const stoppedRef = React70.useRef(false);
12438
12439
  const abortRef = React70.useRef(null);
12439
12440
  const serverCount = React70.useRef(0);
@@ -12529,6 +12530,7 @@ function useChatEngine(opts) {
12529
12530
  queueRef.current = [];
12530
12531
  setQueue([]);
12531
12532
  stoppedRef.current = false;
12533
+ loadedRef.current = false;
12532
12534
  setStatus("resolving");
12533
12535
  setFatal(null);
12534
12536
  (async () => {
@@ -12549,12 +12551,14 @@ function useChatEngine(opts) {
12549
12551
  await loadThread(id);
12550
12552
  if (dead) return;
12551
12553
  setStatus("ready");
12554
+ loadedRef.current = true;
12552
12555
  onThreadReady && onThreadReady(id);
12553
12556
  const stored = store.get(STORAGE_PREFIX + id);
12554
12557
  const last = [...visibleMessages(listRef.current)].reverse().find((m) => m.role === "assistant");
12555
12558
  if (stored) resumeJob(stored);
12556
12559
  else if (last && last.working && last.jobId) resumeJob(last.jobId, last.id);
12557
12560
  else if (initialMessage) send(initialMessage);
12561
+ drain();
12558
12562
  } catch (err) {
12559
12563
  if (dead) return;
12560
12564
  if (!fail(err)) {
@@ -12644,6 +12648,7 @@ function useChatEngine(opts) {
12644
12648
  busyRef.current = false;
12645
12649
  setBusy(false);
12646
12650
  setTurnStartedAt(null);
12651
+ drain();
12647
12652
  });
12648
12653
  }
12649
12654
  async function dispatchTurn(turn) {
@@ -12724,7 +12729,7 @@ function useChatEngine(opts) {
12724
12729
  }
12725
12730
  }
12726
12731
  async function drain() {
12727
- if (busyRef.current) return;
12732
+ if (busyRef.current || !loadedRef.current) return;
12728
12733
  while (queueRef.current.length) {
12729
12734
  if (stoppedRef.current) return;
12730
12735
  const turn = queueRef.current[0];