Improve error handling when posting new messages (#892)
Browse files* send an error or if no text was written
* fix loading indicator
* fix lastIsError code
Files changed (3)
105 unmodified lines106107108109109110111112105 unmodified lines clearTimeout(pendingTimeout);
// Add loading animation to the last message if update takes more than 600ms if ((loading && isLast) || emptyLoad) { if (isLast && loading && emptyLoad) { pendingTimeout = setTimeout(() => { if (contentEl) { loadingEl = new IconLoading({85 unmodified lines8687888989909192939495149 unmodified lines24524624724524824925025185 unmodified lines const convTreeStore = useConvTreeStore();
$: lastMessage = browser && (messages.find((m) => m.id == $convTreeStore.leaf) as Message); $: lastIsError = lastMessage && lastMessage.from === "user" && !loading; $: lastIsError = lastMessage && ((lastMessage.from === "user" && !loading) || lastMessage.updates?.findIndex((u) => u.type === "status" && u.status === "error") !== -1);
$: sources = files.map((file) => file2base64(file));
149 unmodified lines on:click={() => { if (lastMessage && lastMessage.ancestors) { dispatch("retry", { id: lastMessage.ancestors[lastMessage.ancestors.length - 1], id: lastMessage.id, }); } }}376 unmodified lines377378379380381382383384385386387388389390391376 unmodified lines } } catch (e) { update({ type: "status", status: "error", message: (e as Error).message }); } finally { // check if no output was generated if (messageToWriteTo.content === previousText) { update({ type: "status", status: "error", message: "No output was generated. Something went wrong.", }); } }
await collections.conversations.updateOne(src/lib/components/chat/ChatMessage.svelte+1-1
src/lib/components/chat/ChatWindow.svelte+5-2
src/routes/conversation/[id]/+server.ts+9