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:
co-authored by
Claude Opus 4.6
parent
9f6158ddd2
commit
61a6e88667
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user