@athenaintel/react 0.10.15 → 0.10.16
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 +27 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.js +27 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1214,27 +1214,6 @@ export declare const useAthenaLinkClickHandler: () => AthenaLinkClickHandler;
|
|
|
1214
1214
|
|
|
1215
1215
|
export declare const useAthenaRuntime: (config: AthenaRuntimeConfig) => AssistantRuntime;
|
|
1216
1216
|
|
|
1217
|
-
/**
|
|
1218
|
-
* Hook for managing thread navigation.
|
|
1219
|
-
*
|
|
1220
|
-
* Returns `null` when called outside `<AthenaProvider enableThreadList>`
|
|
1221
|
-
* or before the runtime has initialized.
|
|
1222
|
-
*
|
|
1223
|
-
* @example
|
|
1224
|
-
* ```tsx
|
|
1225
|
-
* function MyComponent() {
|
|
1226
|
-
* const threads = useAthenaThreadManager();
|
|
1227
|
-
* if (!threads) return null;
|
|
1228
|
-
*
|
|
1229
|
-
* return (
|
|
1230
|
-
* <div>
|
|
1231
|
-
* <p>Active: {threads.activeThreadId}</p>
|
|
1232
|
-
* <button onClick={() => threads.switchToNewThread()}>New Chat</button>
|
|
1233
|
-
* </div>
|
|
1234
|
-
* );
|
|
1235
|
-
* }
|
|
1236
|
-
* ```
|
|
1237
|
-
*/
|
|
1238
1217
|
export declare function useAthenaThreadManager(): AthenaThreadManagerState | null;
|
|
1239
1218
|
|
|
1240
1219
|
/**
|
package/dist/index.js
CHANGED
|
@@ -24554,6 +24554,7 @@ const useAthenaRuntime = (config2) => {
|
|
|
24554
24554
|
prevThreadIdRef.current = threadId;
|
|
24555
24555
|
hasResumedRef.current = false;
|
|
24556
24556
|
}
|
|
24557
|
+
const resolvedStatusApiUrl = apiUrl.replace(/\/api\/chat$/, "/api/status");
|
|
24557
24558
|
useEffect(() => {
|
|
24558
24559
|
if (isExistingThread && !hasResumedRef.current) {
|
|
24559
24560
|
hasResumedRef.current = true;
|
|
@@ -24565,15 +24566,23 @@ const useAthenaRuntime = (config2) => {
|
|
|
24565
24566
|
runtime.thread.importExternalState({
|
|
24566
24567
|
messages: state.messages
|
|
24567
24568
|
});
|
|
24568
|
-
|
|
24569
|
-
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24574
|
-
|
|
24569
|
+
try {
|
|
24570
|
+
const statusRes = await fetch(resolvedStatusApiUrl, {
|
|
24571
|
+
method: "POST",
|
|
24572
|
+
headers: { "Content-Type": "application/json" },
|
|
24573
|
+
body: JSON.stringify({ threadId })
|
|
24574
|
+
});
|
|
24575
|
+
if (statusRes.ok) {
|
|
24576
|
+
const status = await statusRes.json();
|
|
24577
|
+
if (status.isRunning) {
|
|
24578
|
+
const lastMessageId = ((_a2 = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _a2.id) ?? null;
|
|
24579
|
+
runtime.thread.unstable_resumeRun({ parentId: lastMessageId });
|
|
24575
24580
|
}
|
|
24576
24581
|
}
|
|
24582
|
+
} catch (statusErr) {
|
|
24583
|
+
if (IS_DEV) {
|
|
24584
|
+
console.warn("[AthenaSDK] Sync server status check failed:", statusErr);
|
|
24585
|
+
}
|
|
24577
24586
|
}
|
|
24578
24587
|
} catch (err) {
|
|
24579
24588
|
if (IS_DEV) {
|
|
@@ -24586,7 +24595,7 @@ const useAthenaRuntime = (config2) => {
|
|
|
24586
24595
|
}
|
|
24587
24596
|
})();
|
|
24588
24597
|
}
|
|
24589
|
-
}, [isExistingThread, runtime, threadId, backendUrl]);
|
|
24598
|
+
}, [isExistingThread, runtime, threadId, backendUrl, resolvedStatusApiUrl]);
|
|
24590
24599
|
return runtime;
|
|
24591
24600
|
};
|
|
24592
24601
|
function TooltipProvider({
|
|
@@ -24701,12 +24710,18 @@ const ThreadListRefreshContext = createContext(null);
|
|
|
24701
24710
|
function useRefreshThreadList() {
|
|
24702
24711
|
return useContext(ThreadListRefreshContext);
|
|
24703
24712
|
}
|
|
24713
|
+
const LOCAL_ID_PREFIX = "__LOCALID_";
|
|
24714
|
+
const isLocalPlaceholder = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX);
|
|
24704
24715
|
function useAthenaThreadManager() {
|
|
24705
24716
|
const runtime = useAssistantRuntime({ optional: true });
|
|
24706
|
-
const remoteId = useThread({
|
|
24707
|
-
|
|
24708
|
-
|
|
24709
|
-
|
|
24717
|
+
const remoteId = useThread({
|
|
24718
|
+
optional: true,
|
|
24719
|
+
selector: (s) => {
|
|
24720
|
+
var _a2;
|
|
24721
|
+
const id = (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
|
|
24722
|
+
return isLocalPlaceholder(id) ? void 0 : id;
|
|
24723
|
+
}
|
|
24724
|
+
});
|
|
24710
24725
|
const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
|
|
24711
24726
|
const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
|
|
24712
24727
|
const runtimeRef = useRef(runtime);
|