@agent-native/core 0.12.40 → 0.13.0
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/agent/run-manager.d.ts +5 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +48 -2
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +8 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +36 -5
- package/dist/agent/run-store.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +42 -3
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/ConnectBuilderCard.js +1 -1
- package/dist/client/ConnectBuilderCard.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +27 -16
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/RunStuckBanner.d.ts +35 -0
- package/dist/client/RunStuckBanner.d.ts.map +1 -0
- package/dist/client/RunStuckBanner.js +66 -0
- package/dist/client/RunStuckBanner.js.map +1 -0
- package/dist/client/components/CodeRequiredDialog.js +1 -1
- package/dist/client/components/CodeRequiredDialog.js.map +1 -1
- package/dist/client/composer/ComposerPlusMenu.d.ts +3 -3
- package/dist/client/composer/ComposerPlusMenu.js +3 -3
- package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
- package/dist/client/composer/TiptapComposer.js +1 -1
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +2 -2
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts +7 -0
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +91 -43
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-run-stuck-detection.d.ts +47 -0
- package/dist/client/use-run-stuck-detection.d.ts.map +1 -0
- package/dist/client/use-run-stuck-detection.js +102 -0
- package/dist/client/use-run-stuck-detection.js.map +1 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +2 -0
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState, useRef, useEffect, useCallback, useMemo, forwardRef, useImperativeHandle, } from "react";
|
|
2
|
+
import React, { useState, useRef, useEffect, useLayoutEffect, useCallback, useMemo, forwardRef, useImperativeHandle, } from "react";
|
|
3
3
|
import { AssistantRuntimeProvider, useLocalRuntime, useThreadRuntime, useThread, useAui, useComposer, useMessageRuntime, ThreadPrimitive, ComposerPrimitive, MessagePrimitive, } from "@assistant-ui/react";
|
|
4
4
|
import { SimpleImageAttachmentAdapter, CompositeAttachmentAdapter, } from "@assistant-ui/react";
|
|
5
5
|
import { MarkdownTextPrimitive } from "@assistant-ui/react-markdown";
|
|
@@ -18,6 +18,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel,
|
|
|
18
18
|
import { IframeEmbed, parseEmbedBody } from "./IframeEmbed.js";
|
|
19
19
|
import { useDevMode } from "./use-dev-mode.js";
|
|
20
20
|
import { agentNativePath } from "./api-path.js";
|
|
21
|
+
import { getThreadCacheKey } from "./use-chat-threads.js";
|
|
21
22
|
import { BUILDER_SPACE_SETTINGS_URL } from "./error-format.js";
|
|
22
23
|
import { ThumbsFeedback } from "./observability/ThumbsFeedback.js";
|
|
23
24
|
import { TiptapComposer, } from "./composer/TiptapComposer.js";
|
|
@@ -1491,7 +1492,22 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1491
1492
|
}, [isRunning, tabId, threadId]);
|
|
1492
1493
|
// ─── Chat persistence ──────────────────────────────────────────────
|
|
1493
1494
|
const hasRestoredRef = useRef(false);
|
|
1494
|
-
|
|
1495
|
+
// Cached thread data from a prior session, read synchronously so existing
|
|
1496
|
+
// chats can paint their messages on first commit instead of after the server
|
|
1497
|
+
// round-trip. The server fetch still runs to refresh with the latest.
|
|
1498
|
+
const [cachedThreadData] = useState(() => {
|
|
1499
|
+
if (typeof window === "undefined")
|
|
1500
|
+
return null;
|
|
1501
|
+
if (!threadId || isNewThread)
|
|
1502
|
+
return null;
|
|
1503
|
+
try {
|
|
1504
|
+
return localStorage.getItem(getThreadCacheKey(threadId));
|
|
1505
|
+
}
|
|
1506
|
+
catch {
|
|
1507
|
+
return null;
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1510
|
+
const [isRestoring, setIsRestoring] = useState(!!threadId && !isNewThread && !cachedThreadData);
|
|
1495
1511
|
const onSaveThreadRef = useRef(onSaveThread);
|
|
1496
1512
|
onSaveThreadRef.current = onSaveThread;
|
|
1497
1513
|
const onGenerateTitleRef = useRef(onGenerateTitle);
|
|
@@ -1692,6 +1708,23 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1692
1708
|
return false;
|
|
1693
1709
|
}
|
|
1694
1710
|
}, [apiUrl, refreshThreadFromServer, startReconnectToRun, threadId]);
|
|
1711
|
+
// Hydrate from the localStorage cache synchronously so the message bubbles
|
|
1712
|
+
// paint on the first commit instead of after the server round-trip. The
|
|
1713
|
+
// server fetch below still runs to refresh with the latest content.
|
|
1714
|
+
const hydratedFromCacheRef = useRef(false);
|
|
1715
|
+
useLayoutEffect(() => {
|
|
1716
|
+
if (hydratedFromCacheRef.current)
|
|
1717
|
+
return;
|
|
1718
|
+
if (!cachedThreadData)
|
|
1719
|
+
return;
|
|
1720
|
+
hydratedFromCacheRef.current = true;
|
|
1721
|
+
try {
|
|
1722
|
+
importThreadData(cachedThreadData, { markTitleGenerated: true });
|
|
1723
|
+
}
|
|
1724
|
+
catch {
|
|
1725
|
+
// Corrupt cache entry — ignore and let the server fetch repopulate.
|
|
1726
|
+
}
|
|
1727
|
+
}, [cachedThreadData, importThreadData]);
|
|
1695
1728
|
// Restore messages from server on mount (when threadId is set)
|
|
1696
1729
|
useEffect(() => {
|
|
1697
1730
|
if (hasRestoredRef.current)
|
|
@@ -1706,7 +1739,12 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1706
1739
|
return;
|
|
1707
1740
|
const data = await res.json();
|
|
1708
1741
|
if (data.threadData) {
|
|
1709
|
-
|
|
1742
|
+
// Skip the re-import if the server data matches what we already
|
|
1743
|
+
// hydrated from cache — avoids a second runtime.import that would
|
|
1744
|
+
// briefly flicker the message list.
|
|
1745
|
+
if (data.threadData !== cachedThreadData) {
|
|
1746
|
+
importThreadData(data.threadData, { markTitleGenerated: true });
|
|
1747
|
+
}
|
|
1710
1748
|
}
|
|
1711
1749
|
// Also skip title generation if thread already has a title
|
|
1712
1750
|
if (data.title) {
|
|
@@ -1746,6 +1784,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1746
1784
|
threadRuntime,
|
|
1747
1785
|
importThreadData,
|
|
1748
1786
|
reconnectActiveRunForThread,
|
|
1787
|
+
cachedThreadData,
|
|
1749
1788
|
]);
|
|
1750
1789
|
// If assistant-ui stops the local runtime while the background server run is
|
|
1751
1790
|
// still alive, immediately switch into the same reconnect path used after a
|