(message: ChatMessage)
| 90 | |
| 91 | // 更新消息(按 id 匹配) |
| 92 | async updateMessage(message: ChatMessage): Promise<void> { |
| 93 | const messagesDir = await this.getChildDir(MESSAGES_DIR); |
| 94 | const messages = await this.readJsonFile<ChatMessage[]>(`${message.conversationId}.json`, [], messagesDir); |
| 95 | const index = messages.findIndex((m) => m.id === message.id); |
| 96 | if (index >= 0) { |
| 97 | messages[index] = message; |
| 98 | await this.writeJsonFile(`${message.conversationId}.json`, messages, messagesDir); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // 保存整个消息列表(用于批量更新) |
| 103 | async saveMessages(conversationId: string, messages: ChatMessage[]): Promise<void> { |
nothing calls this directly
no test coverage detected