diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 513a10d4..8d8d9946 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -260,6 +260,37 @@ showSettings = true; }; + const editMessage = async (messageIdx) => { + messages = messages.map((message, idx) => { + if (messageIdx === idx) { + message.edit = true; + message.editedContent = message.content; + } + return message; + }); + }; + + const confirmEditMessage = async (messageIdx) => { + let user_prompt = messages.at(messageIdx).editedContent; + + messages.splice(messageIdx, messages.length - messageIdx); + messages = messages; + + await submitPrompt(user_prompt); + }; + + const cancelEditMessage = (messageIdx) => { + messages = messages.map((message, idx) => { + if (messageIdx === idx) { + message.edit = undefined; + message.editedContent = undefined; + } + return message; + }); + + console.log(messages); + }; + ////////////////////////// // Ollama functions ////////////////////////// @@ -633,7 +664,7 @@ {:else} {#each messages as message, messageIdx}