@athenaintel/react 0.10.13 → 0.10.14

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
@@ -24722,6 +24722,68 @@ function useAthenaThreadManager() {
24722
24722
  };
24723
24723
  }, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
24724
24724
  }
24725
+ const POLL_DELAY_MS = 5e3;
24726
+ const POLL_INTERVAL_MS = 1e3;
24727
+ const POLL_MAX_DURATION_MS = 6e4;
24728
+ function useThreadTitlePolling(refresh) {
24729
+ const threadKey = useThread({
24730
+ optional: true,
24731
+ selector: (s) => {
24732
+ var _a2, _b;
24733
+ return ((_a2 = s.metadata) == null ? void 0 : _a2.remoteId) ?? ((_b = s.metadata) == null ? void 0 : _b.id) ?? s.threadId;
24734
+ }
24735
+ }) ?? null;
24736
+ const hasMessages = useThread({
24737
+ optional: true,
24738
+ selector: (s) => s.messages.length > 0
24739
+ }) ?? false;
24740
+ const currentTitle = useThreadList({
24741
+ optional: true,
24742
+ selector: (s) => {
24743
+ const main = s.threadItems[s.mainThreadId];
24744
+ return (main == null ? void 0 : main.title) ?? "";
24745
+ }
24746
+ }) ?? "";
24747
+ const hasTitle = currentTitle.trim().length > 0;
24748
+ const polledThreadsRef = useRef(/* @__PURE__ */ new Set());
24749
+ const refreshRef = useRef(refresh);
24750
+ refreshRef.current = refresh;
24751
+ useEffect(() => {
24752
+ if (!threadKey || hasTitle || !hasMessages) {
24753
+ return;
24754
+ }
24755
+ if (polledThreadsRef.current.has(threadKey)) {
24756
+ return;
24757
+ }
24758
+ polledThreadsRef.current.add(threadKey);
24759
+ let stopped = false;
24760
+ let intervalId = null;
24761
+ let maxTimeoutId = null;
24762
+ const stop = () => {
24763
+ stopped = true;
24764
+ if (intervalId !== null) {
24765
+ clearInterval(intervalId);
24766
+ intervalId = null;
24767
+ }
24768
+ if (maxTimeoutId !== null) {
24769
+ clearTimeout(maxTimeoutId);
24770
+ maxTimeoutId = null;
24771
+ }
24772
+ };
24773
+ const startTimeoutId = setTimeout(() => {
24774
+ if (stopped) return;
24775
+ refreshRef.current();
24776
+ intervalId = setInterval(() => {
24777
+ refreshRef.current();
24778
+ }, POLL_INTERVAL_MS);
24779
+ maxTimeoutId = setTimeout(stop, POLL_MAX_DURATION_MS - POLL_DELAY_MS);
24780
+ }, POLL_DELAY_MS);
24781
+ return () => {
24782
+ clearTimeout(startTimeoutId);
24783
+ stop();
24784
+ };
24785
+ }, [threadKey, hasTitle, hasMessages]);
24786
+ }
24725
24787
  function createJSONStorage(getStorage, options) {
24726
24788
  let storage;
24727
24789
  try {
@@ -25438,6 +25500,7 @@ function AthenaWithThreadList({
25438
25500
  });
25439
25501
  return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
25440
25502
  /* @__PURE__ */ jsx(AssetPanelThreadSync, {}),
25503
+ /* @__PURE__ */ jsx(ThreadTitlePoller, { refresh: handleRefresh }),
25441
25504
  children
25442
25505
  ] }) }) }) });
25443
25506
  }
@@ -25450,6 +25513,10 @@ function AssetPanelThreadSync() {
25450
25513
  }, [activeThreadId, setCurrentThread]);
25451
25514
  return null;
25452
25515
  }
25516
+ function ThreadTitlePoller({ refresh }) {
25517
+ useThreadTitlePolling(refresh);
25518
+ return null;
25519
+ }
25453
25520
  function AthenaProvider({
25454
25521
  children,
25455
25522
  config: config2,