-
Notifications
You must be signed in to change notification settings - Fork 614
fixed: the mcpServer you need maybe undefined when you want to use #601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant Component as KnowledgeSettings.vue
participant MCPStore as MCP Store
Component->>MCPStore: Watch mcpStore.config.ready
MCPStore-->>Component: config.ready = false (initial)
MCPStore->>MCPStore: loadConfig()
MCPStore-->>MCPStore: Set config.ready = true
MCPStore-->>Component: Notify watcher (config.ready is true)
Component->>Component: Load config from MCP
Component->>Component: Unregister watcher
Component->>Component: Cleanup watcher on unmount (if needed)
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/renderer/src/components/settings/RagflowKnowledgeSettings.vue (1)
434-453: Excellent reactive loading pattern with minor safety suggestion.The implementation correctly waits for MCP readiness before loading configuration and includes proper cleanup to prevent memory leaks. The self-unregistering watcher is a good approach to ensure single execution.
Consider initializing
unwatchto prevent potential undefined access:-let unwatch: () => void // only use here, so declare it here +let unwatch: (() => void) | undefined // only use here, so declare it here onMounted(async () => { unwatch = watch( () => mcpStore.config.ready, async (ready) => { if (ready) { - unwatch() // only run once to avoid multiple calls + unwatch?.() // only run once to avoid multiple calls await loadRagflowConfigFromMcp() } }, { immediate: true } ) }) // cancel the watch to avoid memory leaks onUnmounted(() => { - if (unwatch) { - unwatch() - } + unwatch?.() })src/renderer/src/components/settings/DifyKnowledgeSettings.vue (1)
417-436: Excellent reactive loading pattern with minor safety suggestion.The implementation correctly waits for MCP readiness before loading configuration and includes proper cleanup to prevent memory leaks. The pattern is consistent with other knowledge settings components.
Consider the same safety improvement as suggested for RagflowKnowledgeSettings:
-let unwatch: () => void // only use here, so declare it here +let unwatch: (() => void) | undefined // only use here, so declare it here onMounted(async () => { unwatch = watch( () => mcpStore.config.ready, async (ready) => { if (ready) { - unwatch() // only run once to avoid multiple calls + unwatch?.() // only run once to avoid multiple calls await loadDifyConfigFromMcp() } }, { immediate: true } ) }) // cancel the watch to avoid memory leaks onUnmounted(() => { - if (unwatch) { - unwatch() - } + unwatch?.() })src/renderer/src/components/settings/FastGptKnowledgeSettings.vue (2)
358-358: Remove debug console.log statement.This debug statement should be removed for production code.
- console.log(mcpStore.config)
416-435: Excellent reactive loading pattern with minor safety suggestion.The implementation correctly waits for MCP readiness before loading configuration and includes proper cleanup to prevent memory leaks. The pattern is consistent with other knowledge settings components.
Consider the same safety improvement as suggested for other knowledge settings components:
-let unwatch: () => void // only use here, so declare it here +let unwatch: (() => void) | undefined // only use here, so declare it here onMounted(async () => { unwatch = watch( () => mcpStore.config.ready, async (ready) => { if (ready) { - unwatch() // only run once to avoid multiple calls + unwatch?.() // only run once to avoid multiple calls await loadFastGptConfigFromMcp() } }, { immediate: true } ) }) // cancel the watch to avoid memory leaks onUnmounted(() => { - if (unwatch) { - unwatch() - } + unwatch?.() })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/renderer/src/components/settings/DifyKnowledgeSettings.vue(2 hunks)src/renderer/src/components/settings/FastGptKnowledgeSettings.vue(3 hunks)src/renderer/src/components/settings/RagflowKnowledgeSettings.vue(2 hunks)src/renderer/src/stores/mcp.ts(2 hunks)src/shared/presenter.d.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/development-setup.mdc
**/*.{ts,tsx}
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/error-logging.mdc
src/renderer/src/**/*
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/i18n.mdc
src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx}
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/pinia-best-practices.mdc
src/renderer/**
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/project-structure.mdc
src/shared/*.d.ts
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/electron-best-practices.mdc
src/shared/**
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- .cursor/rules/project-structure.mdc
🧠 Learnings (5)
📓 Common learnings
Learnt from: neoragex2002
PR: ThinkInAIXYZ/deepchat#550
File: src/main/presenter/mcpPresenter/inMemoryServers/meetingServer.ts:250-252
Timestamp: 2025-06-21T15:48:29.950Z
Learning: In the meeting server implementation (src/main/presenter/mcpPresenter/inMemoryServers/meetingServer.ts), when multiple tabs have the same title, the user prefers to let the code silently select the first match without adding warnings or additional ambiguity handling.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-06-23T13:06:02.806Z
Learning: In Vue.js applications, prefer the Composition API for better code organization and reusability.
src/renderer/src/components/settings/RagflowKnowledgeSettings.vue (11)
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Implement proper state persistence for maintaining data across sessions
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Import the Icon component from '@iconify/vue' and use it for rendering icons in Vue components.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Use <script setup> syntax for concise Vue 3 component definitions.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Use template syntax for declarative rendering in Vue components.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-06-23T13:06:02.806Z
Learning: In Vue.js applications, prefer the Composition API for better code organization and reusability.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Utilize Nuxt's auto-imports feature for components and composables to reduce boilerplate.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Use VueUse for common composables and utility functions to promote code reuse.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Use Iconify/Vue for icon implementation, preferring the 'lucide:' icon family, and follow the '{collection}:{icon-name}' naming pattern.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Leverage ref, reactive, and computed for reactive state management in the Composition API.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Implement custom composables for reusable logic in Vue 3/Nuxt 3 projects.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-06-30T12:23:45.479Z
Learning: Applies to src/renderer/src/**/* : Do not hardcode user-facing text in code; always use the translation system (vue-i18n) for all user-visible strings
src/renderer/src/components/settings/FastGptKnowledgeSettings.vue (15)
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Implement proper state persistence for maintaining data across sessions
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Keep the store focused on global state, not component-specific data
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Utilize actions for side effects and asynchronous operations
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use modules to organize related state and actions
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use getters for computed state properties
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Import the Icon component from '@iconify/vue' and use it for rendering icons in Vue components.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Use <script setup> syntax for concise Vue 3 component definitions.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Use template syntax for declarative rendering in Vue components.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-06-23T13:06:02.806Z
Learning: In Vue.js applications, prefer the Composition API for better code organization and reusability.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Utilize Nuxt's auto-imports feature for components and composables to reduce boilerplate.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Use VueUse for common composables and utility functions to promote code reuse.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Use Iconify/Vue for icon implementation, preferring the 'lucide:' icon family, and follow the '{collection}:{icon-name}' naming pattern.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Leverage ref, reactive, and computed for reactive state management in the Composition API.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Implement custom composables for reusable logic in Vue 3/Nuxt 3 projects.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-06-30T12:23:45.479Z
Learning: Applies to src/renderer/src/**/* : Do not hardcode user-facing text in code; always use the translation system (vue-i18n) for all user-visible strings
src/shared/presenter.d.ts (4)
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-06-30T12:24:03.565Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : `src/main/presenter/llmProviderPresenter/index.ts` should manage the overall Agent loop, conversation history, tool execution via `McpPresenter`, and communication with the frontend via `eventBus`.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/electron-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:23:13.338Z
Learning: Applies to src/main/presenter/**/*.ts : Use context isolation for improved security
Learnt from: neoragex2002
PR: ThinkInAIXYZ/deepchat#550
File: src/main/presenter/mcpPresenter/inMemoryServers/meetingServer.ts:250-252
Timestamp: 2025-06-21T15:48:29.950Z
Learning: In the meeting server implementation (src/main/presenter/mcpPresenter/inMemoryServers/meetingServer.ts), when multiple tabs have the same title, the user prefers to let the code silently select the first match without adding warnings or additional ambiguity handling.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/electron-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:23:13.338Z
Learning: Applies to src/renderer/src/composables/usePresenter.ts : The IPC in the renderer process is implemented in usePresenter.ts, allowing direct calls to the presenter-related interfaces exposed by the main process
src/renderer/src/components/settings/DifyKnowledgeSettings.vue (15)
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Implement proper state persistence for maintaining data across sessions
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Utilize actions for side effects and asynchronous operations
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Keep the store focused on global state, not component-specific data
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-router-best-practices.mdc:0-0
Timestamp: 2025-06-23T13:06:06.476Z
Learning: In Vue Router setup (src/renderer/src/router/), route-level code splitting should be implemented to enhance application performance.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-06-30T12:24:10.749Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use getters for computed state properties
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Import the Icon component from '@iconify/vue' and use it for rendering icons in Vue components.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Use <script setup> syntax for concise Vue 3 component definitions.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Use template syntax for declarative rendering in Vue components.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-06-23T13:06:02.806Z
Learning: In Vue.js applications, prefer the Composition API for better code organization and reusability.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Utilize Nuxt's auto-imports feature for components and composables to reduce boilerplate.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Use Iconify/Vue for icon implementation, preferring the 'lucide:' icon family, and follow the '{collection}:{icon-name}' naming pattern.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.335Z
Learning: Use VueUse for common composables and utility functions to promote code reuse.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Leverage ref, reactive, and computed for reactive state management in the Composition API.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-06-23T13:06:15.336Z
Learning: Implement custom composables for reusable logic in Vue 3/Nuxt 3 projects.
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-06-30T12:23:45.479Z
Learning: Applies to src/renderer/src/**/* : Do not hardcode user-facing text in code; always use the translation system (vue-i18n) for all user-visible strings
🔇 Additional comments (6)
src/shared/presenter.d.ts (1)
878-878: LGTM: Clean type definition addition.The
readyboolean property is a sensible addition to track MCP initialization state. The property follows TypeScript conventions and integrates well with the existing interface structure.src/renderer/src/components/settings/RagflowKnowledgeSettings.vue (1)
186-186: LGTM: Proper import addition for cleanup logic.The
onUnmountedimport is necessary for the memory leak prevention pattern implemented below.src/renderer/src/components/settings/DifyKnowledgeSettings.vue (1)
186-186: LGTM: Proper import addition for cleanup logic.The
onUnmountedimport is necessary for the memory leak prevention pattern implemented below.src/renderer/src/components/settings/FastGptKnowledgeSettings.vue (1)
186-186: LGTM: Proper import addition for cleanup logic.The
onUnmountedimport is necessary for the memory leak prevention pattern implemented below.src/renderer/src/stores/mcp.ts (2)
42-42: LGTM: Proper initialization state.The
ready: falseinitial state correctly indicates that MCP configuration loading is not yet complete.
115-116: LGTM: Proper readiness signaling.Setting
ready: trueafter successful configuration loading is the correct place to signal that MCP initialization is complete. This enables the reactive loading pattern in the Vue components.
| () => mcpStore.config.ready, | ||
| async (ready) => { | ||
| if (ready) { | ||
| unwatch() // only run once to avoid multiple calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接使用 https://vuejs.org/guide/essentials/watchers.html#once-watchers
{once:true} 应该就可以
Pull Request Description
Is your feature request related to a problem? Please describe.
#551
In Setting -> KnowledgeBase Tab, server config is load undefined beacuse when mcpserver is initing and component load the server config, so it will be undefined.
Describe the solution you'd like
UI/UX changes for Desktop Application
nothing
Platform Compatibility Notes
nothing
Additional context
#551
Summary by CodeRabbit
New Features
Refactor
Chores