@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.cjs +67 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24761,6 +24761,68 @@ function useAthenaThreadManager() {
|
|
|
24761
24761
|
};
|
|
24762
24762
|
}, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
|
|
24763
24763
|
}
|
|
24764
|
+
const POLL_DELAY_MS = 5e3;
|
|
24765
|
+
const POLL_INTERVAL_MS = 1e3;
|
|
24766
|
+
const POLL_MAX_DURATION_MS = 6e4;
|
|
24767
|
+
function useThreadTitlePolling(refresh) {
|
|
24768
|
+
const threadKey = useThread({
|
|
24769
|
+
optional: true,
|
|
24770
|
+
selector: (s) => {
|
|
24771
|
+
var _a2, _b;
|
|
24772
|
+
return ((_a2 = s.metadata) == null ? void 0 : _a2.remoteId) ?? ((_b = s.metadata) == null ? void 0 : _b.id) ?? s.threadId;
|
|
24773
|
+
}
|
|
24774
|
+
}) ?? null;
|
|
24775
|
+
const hasMessages = useThread({
|
|
24776
|
+
optional: true,
|
|
24777
|
+
selector: (s) => s.messages.length > 0
|
|
24778
|
+
}) ?? false;
|
|
24779
|
+
const currentTitle = useThreadList({
|
|
24780
|
+
optional: true,
|
|
24781
|
+
selector: (s) => {
|
|
24782
|
+
const main = s.threadItems[s.mainThreadId];
|
|
24783
|
+
return (main == null ? void 0 : main.title) ?? "";
|
|
24784
|
+
}
|
|
24785
|
+
}) ?? "";
|
|
24786
|
+
const hasTitle = currentTitle.trim().length > 0;
|
|
24787
|
+
const polledThreadsRef = React.useRef(/* @__PURE__ */ new Set());
|
|
24788
|
+
const refreshRef = React.useRef(refresh);
|
|
24789
|
+
refreshRef.current = refresh;
|
|
24790
|
+
React.useEffect(() => {
|
|
24791
|
+
if (!threadKey || hasTitle || !hasMessages) {
|
|
24792
|
+
return;
|
|
24793
|
+
}
|
|
24794
|
+
if (polledThreadsRef.current.has(threadKey)) {
|
|
24795
|
+
return;
|
|
24796
|
+
}
|
|
24797
|
+
polledThreadsRef.current.add(threadKey);
|
|
24798
|
+
let stopped = false;
|
|
24799
|
+
let intervalId = null;
|
|
24800
|
+
let maxTimeoutId = null;
|
|
24801
|
+
const stop = () => {
|
|
24802
|
+
stopped = true;
|
|
24803
|
+
if (intervalId !== null) {
|
|
24804
|
+
clearInterval(intervalId);
|
|
24805
|
+
intervalId = null;
|
|
24806
|
+
}
|
|
24807
|
+
if (maxTimeoutId !== null) {
|
|
24808
|
+
clearTimeout(maxTimeoutId);
|
|
24809
|
+
maxTimeoutId = null;
|
|
24810
|
+
}
|
|
24811
|
+
};
|
|
24812
|
+
const startTimeoutId = setTimeout(() => {
|
|
24813
|
+
if (stopped) return;
|
|
24814
|
+
refreshRef.current();
|
|
24815
|
+
intervalId = setInterval(() => {
|
|
24816
|
+
refreshRef.current();
|
|
24817
|
+
}, POLL_INTERVAL_MS);
|
|
24818
|
+
maxTimeoutId = setTimeout(stop, POLL_MAX_DURATION_MS - POLL_DELAY_MS);
|
|
24819
|
+
}, POLL_DELAY_MS);
|
|
24820
|
+
return () => {
|
|
24821
|
+
clearTimeout(startTimeoutId);
|
|
24822
|
+
stop();
|
|
24823
|
+
};
|
|
24824
|
+
}, [threadKey, hasTitle, hasMessages]);
|
|
24825
|
+
}
|
|
24764
24826
|
function createJSONStorage(getStorage, options) {
|
|
24765
24827
|
let storage;
|
|
24766
24828
|
try {
|
|
@@ -25477,6 +25539,7 @@ function AthenaWithThreadList({
|
|
|
25477
25539
|
});
|
|
25478
25540
|
return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsxs(TooltipProvider, { children: [
|
|
25479
25541
|
/* @__PURE__ */ jsxRuntime.jsx(AssetPanelThreadSync, {}),
|
|
25542
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadTitlePoller, { refresh: handleRefresh }),
|
|
25480
25543
|
children
|
|
25481
25544
|
] }) }) }) });
|
|
25482
25545
|
}
|
|
@@ -25489,6 +25552,10 @@ function AssetPanelThreadSync() {
|
|
|
25489
25552
|
}, [activeThreadId, setCurrentThread]);
|
|
25490
25553
|
return null;
|
|
25491
25554
|
}
|
|
25555
|
+
function ThreadTitlePoller({ refresh }) {
|
|
25556
|
+
useThreadTitlePolling(refresh);
|
|
25557
|
+
return null;
|
|
25558
|
+
}
|
|
25492
25559
|
function AthenaProvider({
|
|
25493
25560
|
children,
|
|
25494
25561
|
config: config2,
|