mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-03 14:52:28 +08:00
fix: enhance file handling and UI improvements in chat and file preview components
This commit is contained in:
@@ -28,12 +28,17 @@ export default function ChatPanel() {
|
||||
} = useDiagram();
|
||||
|
||||
const onFetchChart = () => {
|
||||
return new Promise<string>((resolve) => {
|
||||
if (resolverRef && "current" in resolverRef) {
|
||||
resolverRef.current = resolve; // Store the resolver
|
||||
}
|
||||
onExport(); // Trigger the export
|
||||
});
|
||||
return Promise.race([
|
||||
new Promise<string>((resolve) => {
|
||||
if (resolverRef && "current" in resolverRef) {
|
||||
resolverRef.current = resolve;
|
||||
}
|
||||
onExport();
|
||||
}),
|
||||
new Promise<string>((_, reject) =>
|
||||
setTimeout(() => reject(new Error("Chart export timed out after 10 seconds")), 10000)
|
||||
)
|
||||
]);
|
||||
};
|
||||
// Add a step counter to track updates
|
||||
|
||||
@@ -112,8 +117,6 @@ export default function ChatPanel() {
|
||||
}
|
||||
}, [messages]);
|
||||
|
||||
console.log(JSON.stringify(messages, null, 2));
|
||||
|
||||
const onFormSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
if (input.trim() && status !== "streaming") {
|
||||
|
||||
Reference in New Issue
Block a user