@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.cjs CHANGED
@@ -66628,17 +66628,31 @@ function ThreadListItem() {
66628
66628
  function useAthenaThreadManager() {
66629
66629
  const runtime = useAssistantRuntime({ optional: true });
66630
66630
  const threadId = useThread({ optional: true, selector: (s) => s.threadId });
66631
- const threadList = useThreadList({ optional: true });
66632
- if (!runtime || !threadList) {
66633
- return null;
66634
- }
66635
- return {
66636
- activeThreadId: threadId ?? null,
66637
- threadIds: threadList.threadIds,
66638
- isLoading: threadList.isLoading,
66639
- switchToThread: (id) => runtime.threads.switchToThread(id),
66640
- switchToNewThread: () => runtime.threads.switchToNewThread()
66641
- };
66631
+ const threadIds = useThreadList({ optional: true, selector: (s) => s.threadIds });
66632
+ const isLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
66633
+ const runtimeRef = React.useRef(runtime);
66634
+ runtimeRef.current = runtime;
66635
+ const switchToThread = React.useCallback(
66636
+ (id) => runtimeRef.current.threads.switchToThread(id),
66637
+ []
66638
+ );
66639
+ const switchToNewThread = React.useCallback(
66640
+ () => runtimeRef.current.threads.switchToNewThread(),
66641
+ []
66642
+ );
66643
+ const activeThreadId = threadId ?? null;
66644
+ return React.useMemo(() => {
66645
+ if (!runtime || threadIds == null || isLoading == null) {
66646
+ return null;
66647
+ }
66648
+ return {
66649
+ activeThreadId,
66650
+ threadIds,
66651
+ isLoading,
66652
+ switchToThread,
66653
+ switchToNewThread
66654
+ };
66655
+ }, [runtime, activeThreadId, threadIds, isLoading, switchToThread, switchToNewThread]);
66642
66656
  }
66643
66657
  function useAppendToComposer() {
66644
66658
  const aui = useAui();