reifyui 0.13.3 → 0.13.4

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
@@ -754,6 +754,7 @@ function ChatPanel(props) {
754
754
  const [draft, setDraft] = useState3("");
755
755
  const [busy, setBusy] = useState3(false);
756
756
  const [connecting, setConnecting] = useState3(false);
757
+ const [dropped, setDropped] = useState3(false);
757
758
  const [histLoading, setHistLoading] = useState3(true);
758
759
  const [staged, setStaged] = useState3([]);
759
760
  const [attachErr, setAttachErr] = useState3("");
@@ -825,12 +826,18 @@ function ChatPanel(props) {
825
826
  }
826
827
  pendingRef.current = null;
827
828
  setConnecting(false);
829
+ if (out.dropped) {
830
+ setDropped(true);
831
+ return;
832
+ }
828
833
  updateLastAsst((a) => a.status === "running" ? { ...a, status: "done" } : a);
829
834
  api.current.onChanged?.();
830
- } catch {
831
- dropRunningAsst();
832
- pendingRef.current = { text, files };
833
- setConnecting(true);
835
+ } catch (e) {
836
+ updateLastAsst((a) => ({
837
+ ...a,
838
+ blocks: a.blocks.length ? a.blocks : withText([], e && e.message || "The turn could not be started."),
839
+ status: "failed"
840
+ }));
834
841
  } finally {
835
842
  setBusy(false);
836
843
  }
@@ -892,6 +899,26 @@ function ChatPanel(props) {
892
899
  }, RETRY_MS);
893
900
  return () => window.clearInterval(iv);
894
901
  }, [connecting, busy, deliver]);
902
+ useEffect3(() => {
903
+ if (!dropped) return void 0;
904
+ let dead = false;
905
+ const tick = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
906
+ if (dead || !hist?.length) return;
907
+ const last = hist[hist.length - 1];
908
+ const settled = !(last.role === "assistant" && last.status === "running") && !externalBusy;
909
+ setMessages(hist);
910
+ if (settled) {
911
+ setDropped(false);
912
+ api.current.onChanged?.();
913
+ }
914
+ }).catch(() => {
915
+ });
916
+ const iv = window.setInterval(tick, POLL_MS);
917
+ return () => {
918
+ dead = true;
919
+ window.clearInterval(iv);
920
+ };
921
+ }, [dropped, externalBusy, sessionId]);
895
922
  useEffect3(() => {
896
923
  let dead = false;
897
924
  let poll;
@@ -1003,7 +1030,8 @@ function ChatPanel(props) {
1003
1030
  toggle,
1004
1031
  title ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-title", title, children: title }) : null,
1005
1032
  headerRight,
1006
- connecting ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: connectingLabel }) : null
1033
+ connecting ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: connectingLabel }) : null,
1034
+ dropped ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: workingLabel }) : null
1007
1035
  ] }),
1008
1036
  /* @__PURE__ */ jsxs5("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
1009
1037
  histLoading ? /* @__PURE__ */ jsx5(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx5(