diff --git a/src/common/stores/chat/chat.conversation.ts b/src/common/stores/chat/chat.conversation.ts index 46cb91143..5b8c3b778 100644 --- a/src/common/stores/chat/chat.conversation.ts +++ b/src/common/stores/chat/chat.conversation.ts @@ -16,17 +16,17 @@ export interface DConversation { userTitle?: string; autoTitle?: string; - // TODO: @deprecated - this should be the system purpose of current head of the conversation + // TODO: [x Head] - this should be the system purpose of current head of the conversation // there should be the concept of the audience of the current head systemPurposeId: SystemPurposeId; // system purpose of this conversation - // TODO: @deprecated - should be a view-related cache - tokenCount: number; // f(messages, llmId) - // when updated is null, we don't have messages yet (timestamps as Date.now()) created: number; // creation timestamp updated: number | null; // last update timestamp + // TODO: @deprecated - should be a view-related cache + tokenCount: number; // f(messages, llmId) + // Not persisted, used while in-memory, or temporarily by the UI // TODO: @deprecated - shouls not be in here - it's actually a per-message/operation thing abortController: AbortController | null; @@ -101,7 +101,8 @@ export function duplicateCConversation(conversation: DConversation, lastMessageI // helpers - conversion export function convertCConversation_V3_V4(conversation: DConversation) { - conversation.messages.forEach(message => convertDMessage_V3_V4(message)); + // .messages + conversation.messages.forEach(convertDMessage_V3_V4); } diff --git a/src/common/stores/chat/chat.message.ts b/src/common/stores/chat/chat.message.ts index 03a424a47..8905b4c9f 100644 --- a/src/common/stores/chat/chat.message.ts +++ b/src/common/stores/chat/chat.message.ts @@ -153,11 +153,19 @@ export function duplicateDMessage(message: DMessage): DMessage { // helpers - conversion export function convertDMessage_V3_V4(message: DMessage) { - const v3 = message as DMessage & { text: string }; - if (!message.content || message.content.length === 0) { - message.content = [createTextPart(v3.text || '')]; - delete (v3 as any).text; + + // .content + if (!message.content || !Array.isArray(message.content)) { + + // v3.text -> v4.content + message.content = [ + createTextPart((message as any).text || ''), + ]; + delete (message as any).text; + } + + // .userAttachments if (!message.userAttachments?.length) message.userAttachments = []; }