feat(chat): add message editing & regeneration (M8.1)

Pencil icon on hover for user messages to edit inline. Regenerate
icon on assistant messages to re-send from the same prompt. Editing
clears all subsequent messages and triggers a fresh AI response.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-03 23:01:48 +00:00
co-authored by Claude Opus 4.6
parent 9f6158ddd2
commit 61a6e88667
5 changed files with 251 additions and 21 deletions
+24
View File
@@ -244,6 +244,28 @@ export const useChatStore = defineStore('chat', () => {
}
}
/** Update a message's content (for editing) */
function updateMessageContent(conversationId: string, messageId: string, newContent: string) {
const conv = conversations.value.get(conversationId)
if (!conv) return
const msg = conv.messages.find((m: { id: string }) => m.id === messageId)
if (msg) {
msg.content = newContent
msg.editedAt = Date.now()
conv.updatedAt = Date.now()
debouncedIDBSave(conv)
}
}
/** Delete all messages after the given index (inclusive of afterIndex) */
function deleteMessagesAfter(conversationId: string, afterIndex: number) {
const conv = conversations.value.get(conversationId)
if (!conv) return
conv.messages.splice(afterIndex)
conv.updatedAt = Date.now()
debouncedIDBSave(conv)
}
return {
conversations,
activeConversationId,
@@ -263,5 +285,7 @@ export const useChatStore = defineStore('chat', () => {
toggleChatCollapse,
setActiveConversation,
deleteConversation,
updateMessageContent,
deleteMessagesAfter,
}
})