This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-05 07:57:55 -05:00
1 parent 6c4d0ace16
commit c1c07cbe0f
3 files changed
+34 -7

No files matched your search

+28 -4
View File
@@ -1531,8 +1531,6 @@
error: e.message || 'Unknown error' error: e.message || 'Unknown error'
}) })
); );
} finally {
await processNextInQueue($chatId);
} }
}; };
@@ -1583,6 +1581,22 @@
toast.error(`${e}`); toast.error(`${e}`);
} }
} }
};
const onUpdate = async ({ file }: { file?: any } = {}) => {
if (file?.itemId) {
chatRequestQueues.update((q) => ({
...q,
[$chatId]: (q[$chatId] ?? []).map((message) =>
(message.files ?? []).some((item) => item.itemId === file.itemId)
? {
...message,
files: message.files.map((item) => (item.itemId === file.itemId ? file : item))
}
: message
)
}));
}
await processNextInQueue($chatId); await processNextInQueue($chatId);
}; };
@@ -1594,8 +1608,6 @@
await uploadGoogleDriveFile(data); await uploadGoogleDriveFile(data);
} else if (type === 'web') { } else if (type === 'web') {
await uploadWeb(data); await uploadWeb(data);
} else if (type === 'file') {
await processNextInQueue($chatId);
} }
}; };
@@ -3339,6 +3351,15 @@
// while the request was in flight (prevents overwriting $chatId // while the request was in flight (prevents overwriting $chatId
// and causing spurious toast notifications / state duplication). // and causing spurious toast notifications / state duplication).
if (res.chat_id && $chatId !== res.chat_id && $chatId === _chatId) { if (res.chat_id && $chatId !== res.chat_id && $chatId === _chatId) {
chatRequestQueues.update((q) => {
if (!q[_chatId]?.length) return q;
const { [_chatId]: pendingQueue, ...rest } = q;
return {
...rest,
[res.chat_id]: [...pendingQueue, ...(rest[res.chat_id] ?? [])]
};
});
await chatId.set(res.chat_id); await chatId.set(res.chat_id);
if (!$temporaryChatEnabled && !embedded) { if (!$temporaryChatEnabled && !embedded) {
window.history.replaceState(history.state, '', `/c/${res.chat_id}`); window.history.replaceState(history.state, '', `/c/${res.chat_id}`);
@@ -4089,6 +4110,7 @@
{stopResponse} {stopResponse}
{createMessagePair} {createMessagePair}
{onUpload} {onUpload}
{onUpdate}
messageQueue={$chatRequestQueues[$chatId] ?? []} messageQueue={$chatRequestQueues[$chatId] ?? []}
{chatTasks} {chatTasks}
onQueueSendNow={sendQueuedMessageNow} onQueueSendNow={sendQueuedMessageNow}
@@ -4176,6 +4198,7 @@
{stopResponse} {stopResponse}
{createMessagePair} {createMessagePair}
{onUpload} {onUpload}
{onUpdate}
messageQueue={$chatRequestQueues[$chatId] ?? []} messageQueue={$chatRequestQueues[$chatId] ?? []}
{chatTasks} {chatTasks}
onQueueSendNow={sendQueuedMessageNow} onQueueSendNow={sendQueuedMessageNow}
@@ -4219,6 +4242,7 @@
{createMessagePair} {createMessagePair}
{onSelect} {onSelect}
{onUpload} {onUpload}
{onUpdate}
messageQueue={$chatRequestQueues[$chatId] ?? []} messageQueue={$chatRequestQueues[$chatId] ?? []}
onQueueSendNow={sendQueuedMessageNow} onQueueSendNow={sendQueuedMessageNow}
onQueueEdit={editQueuedMessage} onQueueEdit={editQueuedMessage}
+4 -3
View File
@@ -168,6 +168,7 @@
export let onQueueSendNow: (id: string) => void = () => {}; export let onQueueSendNow: (id: string) => void = () => {};
export let onQueueEdit: (id: string) => void = () => {}; export let onQueueEdit: (id: string) => void = () => {};
export let onQueueDelete: (id: string) => void = () => {}; export let onQueueDelete: (id: string) => void = () => {};
export let onUpdate: (data?: { file?: any }) => void = () => {};
export let chatTasks = []; export let chatTasks = [];
@@ -890,7 +891,7 @@
toast.error(`${e}`); toast.error(`${e}`);
files = files.filter((item) => item?.itemId !== tempItemId); files = files.filter((item) => item?.itemId !== tempItemId);
} finally { } finally {
onUpload({ type: 'file' }); onUpdate({ file: fileItem });
} }
} else { } else {
// If temporary chat is enabled, we just add the file to the list without uploading it. // If temporary chat is enabled, we just add the file to the list without uploading it.
@@ -907,7 +908,7 @@
fileItem.error = $i18n.t('Failed to extract content from the file.'); fileItem.error = $i18n.t('Failed to extract content from the file.');
toast.error($i18n.t('Failed to extract content from the file.')); toast.error($i18n.t('Failed to extract content from the file.'));
files = files.filter((item) => item?.itemId !== tempItemId); files = files.filter((item) => item?.itemId !== tempItemId);
onUpload({ type: 'file' }); onUpdate({ file: fileItem });
return null; return null;
} else { } else {
console.log('Extracted content from file:', { console.log('Extracted content from file:', {
@@ -922,7 +923,7 @@
fileItem.id = uuidv4(); // Temporary ID for the file fileItem.id = uuidv4(); // Temporary ID for the file
files = files; files = files;
onUpload({ type: 'file' }); onUpdate({ file: fileItem });
} }
} }
}; };
@@ -56,6 +56,7 @@
export let webSearchEnabled = false; export let webSearchEnabled = false;
export let onUpload: Function = (e) => {}; export let onUpload: Function = (e) => {};
export let onUpdate: (data?: { file?: any }) => void = () => {};
export let onSelect = (e) => {}; export let onSelect = (e) => {};
export let onChange = (e) => {}; export let onChange = (e) => {};
export let onWebSearchToggle: Function = () => {}; export let onWebSearchToggle: Function = () => {};
@@ -243,6 +244,7 @@
placeholder={$i18n.t('How can I help you today?')} placeholder={$i18n.t('How can I help you today?')}
{onChange} {onChange}
{onUpload} {onUpload}
{onUpdate}
{messageQueue} {messageQueue}
{onQueueSendNow} {onQueueSendNow}
{onQueueEdit} {onQueueEdit}