MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / deleteAndRelinkMessage

Method deleteAndRelinkMessage

packages/node-runtime/src/ai/chats.ts:752–776  ·  view source on GitHub ↗
(aiChatId: string, messageId: string)

Source from the content-addressed store, hash-verified

750 }
751
752 deleteAndRelinkMessage(aiChatId: string, messageId: string): void {
753 const db = this.getDb()
754 const target = this.getMessageRow(messageId)
755 if (!target || target.aiChatId !== aiChatId) {
756 throw new Error('Message not found in AI chat')
757 }
758
759 db.prepare('UPDATE ai_message SET parent_id = ? WHERE parent_id = ? AND ai_chat_id = ?').run(
760 target.parentId,
761 messageId,
762 aiChatId
763 )
764
765 const conv = this.getAIChat(aiChatId)
766 if (conv?.activeMessageId === messageId) {
767 const now = Math.floor(Date.now() / 1000)
768 db.prepare('UPDATE ai_chat SET active_message_id = ?, updated_at = ? WHERE id = ?').run(
769 target.parentId,
770 now,
771 aiChatId
772 )
773 }
774
775 db.prepare('DELETE FROM ai_message WHERE id = ?').run(messageId)
776 }
777
778 insertMessageAfter(
779 aiChatId: string,

Callers

nothing calls this directly

Calls 6

getDbMethod · 0.95
getMessageRowMethod · 0.95
getAIChatMethod · 0.95
runMethod · 0.65
prepareMethod · 0.65
nowMethod · 0.45

Tested by

no test coverage detected