From f890da0cda077313e734f689bd74a79cab003ab6 Mon Sep 17 00:00:00 2001 From: MyPrototypeWhat <43230886+MyPrototypeWhat@users.noreply.github.com> Date: Sun, 9 Mar 2025 17:25:23 +0800 Subject: [PATCH] Fix/message refactor bug (#3087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ feat: add Model Context Protocol (MCP) support (#2809) * ✨ feat: add Model Context Protocol (MCP) server configuration (main) - Added `@modelcontextprotocol/sdk` dependency for MCP integration. - Introduced MCP server configuration UI in settings with add, edit, delete, and activation functionalities. - Created `useMCPServers` hook to manage MCP server state and actions. - Added i18n support for MCP settings with translation keys. - Integrated MCP settings into the application's settings navigation and routing. - Implemented Redux state management for MCP servers. - Updated `yarn.lock` with new dependencies and their resolutions. * 🌟 feat: implement mcp service and integrate with ipc handlers - Added `MCPService` class to manage Model Context Protocol servers. - Implemented various handlers in `ipc.ts` for managing MCP servers including listing, adding, updating, deleting, and activating/deactivating servers. - Integrated MCP related types into existing type declarations for consistency across the application. - Updated `preload` to expose new MCP related APIs to the renderer process. - Enhanced `MCPSettings` component to interact directly with the new MCP service for adding, updating, deleting servers and setting their active states. - Introduced selectors in the MCP Redux slice for fetching active and all servers from the store. - Moved MCP types to a centralized location in `@renderer/types` for reuse across different parts of the application. * feat: enhance MCPService initialization to prevent recursive calls and improve error handling * feat: enhance MCP integration by adding MCPTool type and updating related methods * feat: implement streaming support for tool calls in OpenAIProvider and enhance message processing * fix: finish_reason undefined * fix: Improve translation error handling in MessageMenubar --------- Co-authored-by: LiuVaayne <10231735+vaayne@users.noreply.github.com> Co-authored-by: kangfenmao --- src/renderer/src/pages/home/Messages/MessageMenubar.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/pages/home/Messages/MessageMenubar.tsx b/src/renderer/src/pages/home/Messages/MessageMenubar.tsx index b8dce585..0d9d2436 100644 --- a/src/renderer/src/pages/home/Messages/MessageMenubar.tsx +++ b/src/renderer/src/pages/home/Messages/MessageMenubar.tsx @@ -48,7 +48,7 @@ interface Props { message: Message assistant: Assistant topic: Topic - model: Model + model?: Model index?: number isGrouped?: boolean isLastMessage: boolean @@ -180,12 +180,12 @@ const MessageMenubar: FC = (props) => { }) // 翻译完成后,提交流消息 - dispatch(commitStreamMessage({ topicId: topic.id })) + dispatch(commitStreamMessage({ topicId: topic.id, messageId: message.id })) } catch (error) { console.error('Translation failed:', error) window.message.error({ content: t('translate.error.failed'), key: 'translate-message' }) dispatch(updateMessage({ topicId: topic.id, messageId: message.id, updates: { translatedContent: undefined } })) - dispatch(clearStreamMessage({ topicId: topic.id })) + dispatch(clearStreamMessage({ topicId: topic.id, messageId: message.id })) } finally { setIsTranslating(false) }