Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Fix AI chat not updating the file version properly (#8416)

James Brunton459146bb3573
diff --git a/frontend/editor/src/proprietary/components/chat/ChatContext.tsx b/frontend/editor/src/proprietary/components/chat/ChatContext.tsx
index cc3fa3d06a..b2f64c00e0 100644
--- a/frontend/editor/src/proprietary/components/chat/ChatContext.tsx
+++ b/frontend/editor/src/proprietary/components/chat/ChatContext.tsx
@@ -18,7 +18,10 @@ import {
reportAccountLinkBlock,
reportFreeTierExhausted,
} from "@app/services/accountLinkBlock";
-import { createChildStub } from "@app/contexts/file/fileActions";
+import {
+ createChildStub,
+ generateProcessedFileMetadata,
+} from "@app/contexts/file/fileActions";
import {
createNewStirlingFileStub,
createStirlingFile,
@@ -490,14 +493,31 @@ export function ChatProvider({ children }: { children: ReactNode }) {
);
}
}
+ // consumeFiles takes the stubs as final and never hydrates them, so
+ // without page metadata here the page editor waits on it forever.
+ const metadata = await Promise.all(
+ files.map((file) => generateProcessedFileMetadata(file)),
+ );
const consumedIds: StirlingFileStub["id"][] = [];
const stubs = files.map((file, i) => {
const source = sourceForOutput[i];
+ const thumbnail = metadata[i]?.thumbnailUrl;
if (source && outputsPerSource.get(source.id) === 1) {
consumedIds.push(source.id);
- return createChildStub(source, operation, file);
+ return createChildStub(
+ source,
+ operation,
+ file,
+ thumbnail,
+ metadata[i],
+ );
}
- return createNewStirlingFileStub(file);
+ return createNewStirlingFileStub(
+ file,
+ undefined,
+ thumbnail,
+ metadata[i],
+ );
});
const stirlingFiles = files.map((file, i) =>
createStirlingFile(file, stubs[i].id),