reifyui 0.8.2 → 0.8.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.js CHANGED
@@ -697,6 +697,7 @@ function ChatPanel(props) {
697
697
  const [draft, setDraft] = useState2("");
698
698
  const [busy, setBusy] = useState2(false);
699
699
  const [connecting, setConnecting] = useState2(false);
700
+ const [dropped, setDropped] = useState2(false);
700
701
  const [histLoading, setHistLoading] = useState2(true);
701
702
  const [staged, setStaged] = useState2([]);
702
703
  const [attachErr, setAttachErr] = useState2("");
@@ -768,12 +769,18 @@ function ChatPanel(props) {
768
769
  }
769
770
  pendingRef.current = null;
770
771
  setConnecting(false);
772
+ if (out.dropped) {
773
+ setDropped(true);
774
+ return;
775
+ }
771
776
  updateLastAsst((a) => a.status === "running" ? { ...a, status: "done" } : a);
772
777
  api.current.onChanged?.();
773
- } catch {
774
- dropRunningAsst();
775
- pendingRef.current = { text, files };
776
- setConnecting(true);
778
+ } catch (e) {
779
+ updateLastAsst((a) => ({
780
+ ...a,
781
+ blocks: a.blocks.length ? a.blocks : withText([], e && e.message || "The turn could not be started."),
782
+ status: "failed"
783
+ }));
777
784
  } finally {
778
785
  setBusy(false);
779
786
  }
@@ -835,6 +842,26 @@ function ChatPanel(props) {
835
842
  }, RETRY_MS);
836
843
  return () => window.clearInterval(iv);
837
844
  }, [connecting, busy, deliver]);
845
+ useEffect3(() => {
846
+ if (!dropped) return void 0;
847
+ let dead = false;
848
+ const tick = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
849
+ if (dead || !hist?.length) return;
850
+ const last = hist[hist.length - 1];
851
+ const settled = !(last.role === "assistant" && last.status === "running") && !externalBusy;
852
+ setMessages(hist);
853
+ if (settled) {
854
+ setDropped(false);
855
+ api.current.onChanged?.();
856
+ }
857
+ }).catch(() => {
858
+ });
859
+ const iv = window.setInterval(tick, POLL_MS);
860
+ return () => {
861
+ dead = true;
862
+ window.clearInterval(iv);
863
+ };
864
+ }, [dropped, externalBusy, sessionId]);
838
865
  useEffect3(() => {
839
866
  let dead = false;
840
867
  let poll;
@@ -946,7 +973,8 @@ function ChatPanel(props) {
946
973
  toggle,
947
974
  title ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-title", title, children: title }) : null,
948
975
  headerRight,
949
- connecting ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-conn", children: connectingLabel }) : null
976
+ connecting ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-conn", children: connectingLabel }) : null,
977
+ dropped ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-conn", children: workingLabel }) : null
950
978
  ] }),
951
979
  /* @__PURE__ */ jsxs6("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
952
980
  histLoading ? /* @__PURE__ */ jsx6(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx6(