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 lines106107108109110111112105 unmodified linesclearTimeout(pendingTimeout);// Add loading animation to the last message if update takes more than 600msif ((loading && isLast) || emptyLoad) {pendingTimeout = setTimeout(() => {if (contentEl) {loadingEl = new IconLoading({105 unmodified lines106107108109110111112105 unmodified linesclearTimeout(pendingTimeout);// Add loading animation to the last message if update takes more than 600msif (isLast && loading && emptyLoad) {pendingTimeout = setTimeout(() => {if (contentEl) {loadingEl = new IconLoading({
85 unmodified lines86878889909192149 unmodified lines24224324424524624724885 unmodified linesconst convTreeStore = useConvTreeStore();$: lastMessage = browser && (messages.find((m) => m.id == $convTreeStore.leaf) as Message);$: lastIsError = lastMessage && lastMessage.from === "user" && !loading;$: sources = files.map((file) => file2base64(file));149 unmodified lineson:click={() => {if (lastMessage && lastMessage.ancestors) {dispatch("retry", {id: lastMessage.ancestors[lastMessage.ancestors.length - 1],});}}}85 unmodified lines86878889909192939495149 unmodified lines24524624724824925025185 unmodified linesconst convTreeStore = useConvTreeStore();$: lastMessage = browser && (messages.find((m) => m.id == $convTreeStore.leaf) as Message);$: 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 lineson:click={() => {if (lastMessage && lastMessage.ancestors) {dispatch("retry", {id: lastMessage.id,});}}}
376 unmodified lines377378379380381382376 unmodified lines}} catch (e) {update({ type: "status", status: "error", message: (e as Error).message });}await collections.conversations.updateOne(376 unmodified lines377378379380381382383384385386387388389390391376 unmodified lines}} catch (e) {update({ type: "status", status: "error", message: (e as Error).message });} finally {// check if no output was generatedif (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