@athenaintel/react 0.10.4 → 0.10.6

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
@@ -66589,17 +66589,31 @@ function ThreadListItem() {
66589
66589
  function useAthenaThreadManager() {
66590
66590
  const runtime = useAssistantRuntime({ optional: true });
66591
66591
  const threadId = useThread({ optional: true, selector: (s) => s.threadId });
66592
- const threadList = useThreadList({ optional: true });
66593
- if (!runtime || !threadList) {
66594
- return null;
66595
- }
66596
- return {
66597
- activeThreadId: threadId ?? null,
66598
- threadIds: threadList.threadIds,
66599
- isLoading: threadList.isLoading,
66600
- switchToThread: (id) => runtime.threads.switchToThread(id),
66601
- switchToNewThread: () => runtime.threads.switchToNewThread()
66602
- };
66592
+ const threadIds = useThreadList({ optional: true, selector: (s) => s.threadIds });
66593
+ const isLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
66594
+ const runtimeRef = useRef(runtime);
66595
+ runtimeRef.current = runtime;
66596
+ const switchToThread = useCallback(
66597
+ (id) => runtimeRef.current.threads.switchToThread(id),
66598
+ []
66599
+ );
66600
+ const switchToNewThread = useCallback(
66601
+ () => runtimeRef.current.threads.switchToNewThread(),
66602
+ []
66603
+ );
66604
+ const activeThreadId = threadId ?? null;
66605
+ return useMemo(() => {
66606
+ if (!runtime || threadIds == null || isLoading == null) {
66607
+ return null;
66608
+ }
66609
+ return {
66610
+ activeThreadId,
66611
+ threadIds,
66612
+ isLoading,
66613
+ switchToThread,
66614
+ switchToNewThread
66615
+ };
66616
+ }, [runtime, activeThreadId, threadIds, isLoading, switchToThread, switchToNewThread]);
66603
66617
  }
66604
66618
  function useAppendToComposer() {
66605
66619
  const aui = useAui();