@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.cjs CHANGED
@@ -13611,6 +13611,7 @@ function useChatEngine(opts) {
13611
13611
  const listRef = React70.useRef([]);
13612
13612
  const queueRef = React70.useRef([]);
13613
13613
  const busyRef = React70.useRef(false);
13614
+ const loadedRef = React70.useRef(false);
13614
13615
  const stoppedRef = React70.useRef(false);
13615
13616
  const abortRef = React70.useRef(null);
13616
13617
  const serverCount = React70.useRef(0);
@@ -13706,6 +13707,7 @@ function useChatEngine(opts) {
13706
13707
  queueRef.current = [];
13707
13708
  setQueue([]);
13708
13709
  stoppedRef.current = false;
13710
+ loadedRef.current = false;
13709
13711
  setStatus("resolving");
13710
13712
  setFatal(null);
13711
13713
  (async () => {
@@ -13726,12 +13728,14 @@ function useChatEngine(opts) {
13726
13728
  await loadThread(id);
13727
13729
  if (dead) return;
13728
13730
  setStatus("ready");
13731
+ loadedRef.current = true;
13729
13732
  onThreadReady && onThreadReady(id);
13730
13733
  const stored = store.get(STORAGE_PREFIX + id);
13731
13734
  const last = [...visibleMessages(listRef.current)].reverse().find((m) => m.role === "assistant");
13732
13735
  if (stored) resumeJob(stored);
13733
13736
  else if (last && last.working && last.jobId) resumeJob(last.jobId, last.id);
13734
13737
  else if (initialMessage) send(initialMessage);
13738
+ drain();
13735
13739
  } catch (err) {
13736
13740
  if (dead) return;
13737
13741
  if (!fail(err)) {
@@ -13821,6 +13825,7 @@ function useChatEngine(opts) {
13821
13825
  busyRef.current = false;
13822
13826
  setBusy(false);
13823
13827
  setTurnStartedAt(null);
13828
+ drain();
13824
13829
  });
13825
13830
  }
13826
13831
  async function dispatchTurn(turn) {
@@ -13901,7 +13906,7 @@ function useChatEngine(opts) {
13901
13906
  }
13902
13907
  }
13903
13908
  async function drain() {
13904
- if (busyRef.current) return;
13909
+ if (busyRef.current || !loadedRef.current) return;
13905
13910
  while (queueRef.current.length) {
13906
13911
  if (stoppedRef.current) return;
13907
13912
  const turn = queueRef.current[0];