@flytedan/flytebot-design-system 0.71.1 → 0.71.3

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
@@ -6401,8 +6401,11 @@ var INLINE = [
6401
6401
  ["bare", /(?<![\w@/])(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/]
6402
6402
  ];
6403
6403
  function inlineNodes(src, ctx, keyBase) {
6404
+ return hiddenInlineNodes(hideEscapes(String(src == null ? "" : src)), ctx, keyBase);
6405
+ }
6406
+ function hiddenInlineNodes(hidden, ctx, keyBase) {
6404
6407
  const out = [];
6405
- let rest = hideEscapes(String(src == null ? "" : src)), guard = 0;
6408
+ let rest = hidden, guard = 0;
6406
6409
  const d = showEscapes;
6407
6410
  const key = () => keyBase + "-" + out.length;
6408
6411
  while (rest && guard++ < 800) {
@@ -6422,13 +6425,13 @@ function inlineNodes(src, ctx, keyBase) {
6422
6425
  out.push(ctx.allowImages && src2 ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("img", { className: "fd-md-img", src: src2, alt: d(g(1) || ""), title: g(3) ? d(g(3)) : void 0, loading: "lazy" }, key()) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "fd-md-imgalt", children: d(g(1) || "image") }, key()));
6423
6426
  } else if (kind === "link") {
6424
6427
  const href = safeHref(d(g(2)));
6425
- out.push(href ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("a", { href, title: g(3) ? d(g(3)) : void 0, target: /^https?:/i.test(href) ? "_blank" : void 0, rel: "noopener noreferrer", onClick: ctx.onLinkClick, children: inlineNodes(g(1), ctx, key()) }, key()) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { children: d(g(1)) }, key()));
6428
+ out.push(href ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("a", { href, title: g(3) ? d(g(3)) : void 0, target: /^https?:/i.test(href) ? "_blank" : void 0, rel: "noopener noreferrer", onClick: ctx.onLinkClick, children: hiddenInlineNodes(g(1), ctx, key()) }, key()) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { children: d(g(1)) }, key()));
6426
6429
  } else if (kind === "cite") {
6427
6430
  out.push(ctx.renderCitation ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(React35.Fragment, { children: ctx.renderCitation(d(g(1))) }, key()) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("sup", { className: "fd-md-cite", children: d(g(1)) }, key()));
6428
- } else if (kind === "strongem") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("em", { children: inlineNodes(g(1), ctx, key()) }) }, key()));
6429
- else if (kind === "strong") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("strong", { children: inlineNodes(g(1) || g(2), ctx, key()) }, key()));
6430
- else if (kind === "em") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("em", { children: inlineNodes(g(1) || g(2), ctx, key()) }, key()));
6431
- else if (kind === "del") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("del", { children: inlineNodes(g(1), ctx, key()) }, key()));
6431
+ } else if (kind === "strongem") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("strong", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("em", { children: hiddenInlineNodes(g(1), ctx, key()) }) }, key()));
6432
+ else if (kind === "strong") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("strong", { children: hiddenInlineNodes(g(1) || g(2), ctx, key()) }, key()));
6433
+ else if (kind === "em") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("em", { children: hiddenInlineNodes(g(1) || g(2), ctx, key()) }, key()));
6434
+ else if (kind === "del") out.push(/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("del", { children: hiddenInlineNodes(g(1), ctx, key()) }, key()));
6432
6435
  else if (kind === "autolink" || kind === "bare") {
6433
6436
  const href = safeHref(d(g(1)));
6434
6437
  out.push(href ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("a", { href, target: "_blank", rel: "noopener noreferrer", onClick: ctx.onLinkClick, children: d(g(1)).replace(/^mailto:/, "") }, key()) : d(g(1)));
@@ -13611,6 +13614,8 @@ function useChatEngine(opts) {
13611
13614
  const stoppedRef = React70.useRef(false);
13612
13615
  const abortRef = React70.useRef(null);
13613
13616
  const serverCount = React70.useRef(0);
13617
+ const serverIds = React70.useRef(/* @__PURE__ */ new Set());
13618
+ const liveTurn = React70.useRef(null);
13614
13619
  const threadRef = React70.useRef(null);
13615
13620
  const mounted = React70.useRef(true);
13616
13621
  React70.useEffect(() => {
@@ -13639,15 +13644,35 @@ function useChatEngine(opts) {
13639
13644
  const data = await apiAdapter.getThread(id);
13640
13645
  const list = [...data && data.messages || []];
13641
13646
  serverCount.current = list.length;
13647
+ serverIds.current = new Set(list.map((m) => m.id));
13642
13648
  commit(list);
13643
13649
  return list;
13644
13650
  }, [apiAdapter]);
13645
13651
  async function mergeThread() {
13646
13652
  const data = await apiAdapter.getThread(threadRef.current);
13647
13653
  const server = data && data.messages || [];
13654
+ const turn = liveTurn.current;
13655
+ const ownIds = /* @__PURE__ */ new Set();
13656
+ let progress;
13657
+ if (turn) {
13658
+ for (const m of server) {
13659
+ if (turn.known.has(m.id)) continue;
13660
+ ownIds.add(m.id);
13661
+ if (m.role === "assistant") progress = m;
13662
+ }
13663
+ }
13648
13664
  const ids = new Set(server.map((m) => m.id));
13649
13665
  serverCount.current = server.length;
13650
- commit([...server, ...listRef.current.filter((m) => !ids.has(m.id))]);
13666
+ serverIds.current = ids;
13667
+ const next = [...server.filter((m) => !ownIds.has(m.id)), ...listRef.current.filter((m) => !ids.has(m.id))];
13668
+ commit(turn && progress ? next.map((m) => m.id === turn.holderId ? foldProgress(m, progress) : m) : next);
13669
+ }
13670
+ function foldProgress(holder, progress) {
13671
+ return Object.assign({}, holder, {
13672
+ steps: progress.steps ?? holder.steps,
13673
+ text: progress.text || holder.text,
13674
+ packet: progress.packet ?? holder.packet
13675
+ });
13651
13676
  }
13652
13677
  React70.useEffect(() => {
13653
13678
  if (!apiAdapter) {
@@ -13802,6 +13827,7 @@ function useChatEngine(opts) {
13802
13827
  { id: userId, role: "user", text: turn.text || null, attachments: turn.attachments, pending: true, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
13803
13828
  { id: holderId, role: "assistant", text: "", streaming: !!apiAdapter.streamMessage, working: !apiAdapter.streamMessage, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
13804
13829
  );
13830
+ liveTurn.current = { known: new Set(serverIds.current), holderId };
13805
13831
  const ac = typeof AbortController !== "undefined" ? new AbortController() : { abort() {
13806
13832
  }, signal: void 0 };
13807
13833
  abortRef.current = ac;
@@ -13857,6 +13883,7 @@ function useChatEngine(opts) {
13857
13883
  commit(listRef.current.filter((m) => m.id !== holderId));
13858
13884
  }
13859
13885
  } finally {
13886
+ liveTurn.current = null;
13860
13887
  abortRef.current = null;
13861
13888
  busyRef.current = false;
13862
13889
  setBusy(false);