{#if messages.length == 0} { const chatTextAreaElement = document.getElementById('chat-textarea'); if (chatTextAreaElement) { prompt = p; await tick(); chatTextAreaElement.style.height = ''; chatTextAreaElement.style.height = Math.min(chatTextAreaElement.scrollHeight, 200) + 'px'; chatTextAreaElement.focus(); } }} /> {:else} {#key chatId} {#each messages as message, messageIdx} {#if message.role === 'user'} messageDeleteHandler(message.id)} user={$user} {readOnly} {message} isFirstMessage={messageIdx === 0} siblings={message.parentId !== null ? history.messages[message.parentId]?.childrenIds ?? [] : Object.values(history.messages) .filter((message) => message.parentId === null) .map((message) => message.id) ?? []} {confirmEditMessage} {showPreviousMessage} {showNextMessage} copyToClipboard={copyToClipboardWithToast} /> {:else} { console.log('save', e); const message = e.detail; history.messages[message.id] = message; await updateChatById(localStorage.token, chatId, { messages: messages, history: history }); }} /> {/if} {/each} {#if bottomPadding} {/if} {/key} {/if}