chore upgrade assistant to AI SDK v7

This commit is contained in:
ajnart committed 2026-08-13 19:57:02 +02:00
1 parent e662a175c0
commit 876f312a2e
6 files changed
+37 -8

No files matched your search

@@ -259,6 +259,8 @@ const createHistoryAdapter = (threadId: string | undefined): ThreadHistoryAdapte
withFormat<TMessage, TStorageFormat extends Record<string, unknown>>(
formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>,
) {
// assistant-ui's current AI SDK v7 runtime intentionally keeps this identifier for its
// persisted UIMessage wire format. It is a storage codec name, not the installed SDK version.
if (formatAdapter.format !== "ai-sdk/v6") {
throw new Error(`Unsupported assistant message format: ${formatAdapter.format}`);
}
@@ -375,6 +377,8 @@ const AssistantThreadRuntime = () => {
sendAutomaticallyWhen: shouldAutomaticallyContinueAssistant,
});
// The lower-level AI SDK v7 runtime is intentional: Homarr supplies its own tRPC-backed
// thread list and history adapters and shares this chat instance with its custom transport.
const runtime = useAISDKRuntime(chat, {
...assistantAiSdkRuntimeOptions,
adapters: {
@@ -305,6 +305,16 @@ describe("AssistantRuntimeProviderWithTools", () => {
await act(async () => root.unmount());
});
test("forwards main-thread reloads through the surface runtime", async () => {
const { root, a, sharedRuntime } = await renderSurfaceTestAssistant();
const reloadMainThread = vi.spyOn(sharedRuntime.threads, "reloadMainThread").mockResolvedValue();
await act(async () => a.threads().reloadMainThread());
expect(reloadMainThread).toHaveBeenCalledOnce();
await act(async () => root.unmount());
});
test("restores focus after the Lexical run-start behavior tries to focus every surface", async () => {
const outsideInput = document.createElement("input");
document.body.append(outsideInput);
@@ -348,6 +348,7 @@ export const createAssistantSurfaceRuntime = (runtime: AssistantRuntime): Assist
switchToNewThread: () => sharedThreads.switchToNewThread(),
getLoadThreadsPromise: () => sharedThreads.getLoadThreadsPromise(),
reload: () => sharedThreads.reload(),
reloadMainThread: () => sharedThreads.reloadMainThread(),
loadMore: () => sharedThreads.loadMore(),
};