控制UI发送消息的代码分析核心发送方法在 openclaw-cn\ui\src\ui\controllers\chat.ts 文件中, sendChatMessage 函数是发送消息的核心实现:export async function sendChatMessage( state: ChatState, message: string, attachments?: ChatAttachment[], ): Promisestring | null { if (!state.client || !state. connected) { return null; } const msg = message.trim(); const hasAttachments = attachments attachments. length 0; if (!msg !hasAttachments) { return null; } // 构建用户消息内容块 const contentBlocks: Array{ type: string; text?: string; source?: unknown } = []; if (msg) { contentBlocks.push({ type: "text", text: msg }); } // 添加图片预览到消息中 if (hasAttachments) { for (cons
控制UI发送消息的代码分析
控制UI发送消息的代码分析核心发送方法在 openclaw-cn\ui\src\ui\controllers\chat.ts 文件中, sendChatMessage 函数是发送消息的核心实现:export async function sendChatMessage( state: ChatState, message: string, attachments?: ChatAttachment[], ): Promisestring | null { if (!state.client || !state. connected) { return null; } const msg = message.trim(); const hasAttachments = attachments attachments. length 0; if (!msg !hasAttachments) { return null; } // 构建用户消息内容块 const contentBlocks: Array{ type: string; text?: string; source?: unknown } = []; if (msg) { contentBlocks.push({ type: "text", text: msg }); } // 添加图片预览到消息中 if (hasAttachments) { for (cons