Skip to content

Conversation

@hllshiro
Copy link
Collaborator

@hllshiro hllshiro commented Aug 6, 2025

Pull Request Description

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
After creating a new chat from an old one, starting a new MCP service will cause currently enabled tools to be incorrectly disabled.
Details see below

Describe the solution you'd like
The error is caused by the incorrect default list selection when the session has no special settings for enabledMcpTools.
Details see below

UI/UX changes for Desktop Application
none

Platform Compatibility Notes
If this PR has specific platform compatibility considerations (Windows, macOS, Linux), please describe them here.

  • Are there any platform-specific behaviors or code adjustments? no
  • Have you tested on all relevant platforms? only windows

Pull Request Description (中文)

你的功能请求是否与某个问题有关?请描述一下。
请对问题进行清晰扼要的描述。
从旧的聊天中创建新聊天后,开启一个新的MCP服务,当前已启用的tools会被错误的关闭。

default.mp4

请描述你希望的解决方案

错误是当会话没有关于enabledMcpTools的特殊设置时,默认列表选择错误导致的。

image

⬇️

image

桌面应用程序的 UI/UX 更改
如果此 PR 引入了 UI/UX 更改,请详细描述它们。

平台兼容性注意事项
如果此 PR 具有特定的平台兼容性考虑因素(Windows、macOS、Linux),请在此处描述。

  • 是否有任何平台特定的行为或代码调整?无
  • 你是否已在所有相关平台上进行过测试?仅windows

Summary by CodeRabbit

  • Bug Fixes
    • Improved the handling of enabled MCP tools so that, if no tools are explicitly configured, all available tools are enabled by default instead of none.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

The update changes the logic for determining the set of enabled MCP tools during a server status update. Instead of defaulting to an empty list when no tools are configured, the code now defaults to enabling all available tool function names.

Changes

Cohort / File(s) Change Summary
MCP Tools Enabled List Logic
src/renderer/src/stores/mcp.ts
Adjusts fallback logic for enabled MCP tools: if none are set, all tool function names are enabled by default.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Store (mcp.ts)
    participant Tools List

    User->>Store (mcp.ts): Update server status
    Store (mcp.ts)->>Store (mcp.ts): Check enabledMcpTools
    alt enabledMcpTools is set
        Store (mcp.ts)->>Store (mcp.ts): Use enabledMcpTools
    else not set
        Store (mcp.ts)->>Tools List: Get all tool function names
        Store (mcp.ts)->>Store (mcp.ts): Use all tool function names as enabled list
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~6 minutes

Possibly related PRs

  • fix: fixed dirty data problems #691: Both PRs address handling the enabled MCP tools list when unset, with this PR changing the fallback to include all tools by default.
  • Feature/mcp tool improve #635: This PR modifies how the enabled MCP tools list is derived, directly relating to changes that introduce and propagate the enabledMcpTools concept across the stack.

Suggested reviewers

  • zerob13

Poem

In the warren of code, a change hops through,
Now all MCP tools, not just a few!
No empty list, but a garden in bloom,
Every function name finds its room.
With every server status, the tools all cheer,
"Enable us all!"—the rabbit engineer. 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 421acc1 and 5d4fa34.

📒 Files selected for processing (1)
  • src/renderer/src/stores/mcp.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Use English for logs and comments

Files:

  • src/renderer/src/stores/mcp.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Strict type checking enabled for TypeScript

**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/src/**/*.{ts,tsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

src/renderer/src/**/*.{ts,tsx,vue}: Use Pinia for frontend state management
Renderer to Main: Use usePresenter.ts composable for direct presenter method calls

Files:

  • src/renderer/src/stores/mcp.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/development-setup.mdc)

**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写

Files:

  • src/renderer/src/stores/mcp.ts
src/{main,renderer}/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/electron-best-practices.mdc)

src/{main,renderer}/**/*.ts: Use context isolation for improved security
Implement proper inter-process communication (IPC) patterns
Optimize application startup time with lazy loading
Implement proper error handling and logging for debugging

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/src/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/i18n.mdc)

src/renderer/src/**/*: All user-facing strings must use i18n keys (avoid hardcoded user-visible text in code)
Use the 'vue-i18n' framework for all internationalization in the renderer
Ensure all user-visible text in the renderer uses the translation system

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/pinia-best-practices.mdc)

src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx}: Use modules to organize related state and actions
Implement proper state persistence for maintaining data across sessions
Use getters for computed state properties
Utilize actions for side effects and asynchronous operations
Keep the store focused on global state, not component-specific data

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/**/*.{vue,ts,js,tsx,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

渲染进程代码放在 src/renderer

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-best-practices.mdc)

src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
Implement proper state management with Pinia
Utilize Vue Router for navigation and route management
Leverage Vue's built-in reactivity system for efficient data handling

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/**/*.{ts,tsx,vue}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,tsx,vue}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use TypeScript for all code; prefer types over interfaces.
Avoid enums; use const objects instead.
Use arrow functions for methods and computed properties.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/**/*.{vue,ts}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

Implement lazy loading for routes and components.

Files:

  • src/renderer/src/stores/mcp.ts
src/renderer/**/*.{ts,vue}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
Implement SEO best practices using Nuxt's useHead and useSeoMeta.

Files:

  • src/renderer/src/stores/mcp.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T01:45:33.790Z
Learning: Applies to src/main/presenter/mcpPresenter/inMemoryServers/*.ts : Implement new MCP tool in src/main/presenter/mcpPresenter/inMemoryServers/ when adding a new MCP tool
📚 Learning: applies to src/main/presenter/mcppresenter/inmemoryservers/*.ts : implement new mcp tool in src/main...
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T01:45:33.790Z
Learning: Applies to src/main/presenter/mcpPresenter/inMemoryServers/*.ts : Implement new MCP tool in src/main/presenter/mcpPresenter/inMemoryServers/ when adding a new MCP tool

Applied to files:

  • src/renderer/src/stores/mcp.ts
📚 Learning: applies to src/main/presenter/mcppresenter/index.ts : register new mcp tool in mcppresenter/index.ts...
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T01:45:33.790Z
Learning: Applies to src/main/presenter/mcpPresenter/index.ts : Register new MCP tool in mcpPresenter/index.ts

Applied to files:

  • src/renderer/src/stores/mcp.ts
📚 Learning: applies to src/main/presenter/llmproviderpresenter/providers/*.ts : when a provider supports native ...
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-07-21T01:46:52.880Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : When a provider supports native function calling, MCP tools must be converted to the provider's format (e.g., using `convertToProviderTools`) and included in the API request.

Applied to files:

  • src/renderer/src/stores/mcp.ts
📚 Learning: in src/renderer/src/stores/chat.ts, the user prefers to keep both `text` and `content` properties in...
Learnt from: neoragex2002
PR: ThinkInAIXYZ/deepchat#550
File: src/renderer/src/stores/chat.ts:1011-1035
Timestamp: 2025-06-21T15:49:17.044Z
Learning: In src/renderer/src/stores/chat.ts, the user prefers to keep both `text` and `content` properties in the `handleMeetingInstruction` function's `sendMessage` call, even though they are redundant, rather than removing the `content` property.

Applied to files:

  • src/renderer/src/stores/mcp.ts
📚 Learning: applies to src/main/presenter/llmproviderpresenter/index.ts : `src/main/presenter/llmproviderpresent...
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-07-21T01:46:52.880Z
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 frontend communication via `eventBus`.

Applied to files:

  • src/renderer/src/stores/mcp.ts
📚 Learning: in the meeting server implementation (src/main/presenter/mcppresenter/inmemoryservers/meetingserver....
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.

Applied to files:

  • src/renderer/src/stores/mcp.ts
🔇 Additional comments (1)
src/renderer/src/stores/mcp.ts (1)

173-174: LGTM! This fix correctly addresses the tool disabling issue.

The change properly handles the case where enabledMcpTools is undefined by defaulting to all available tool function names instead of an empty array. This ensures that when a new chat session lacks explicit MCP tool configuration, all tools remain enabled rather than being incorrectly disabled.

The fallback logic [...tools.value].map((tool) => tool.function.name) provides a sensible default that maintains tool availability across session transitions.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zerob13 zerob13 merged commit cc88dad into ThinkInAIXYZ:dev Aug 6, 2025
2 checks passed
@hllshiro hllshiro mentioned this pull request Aug 6, 2025
zerob13 pushed a commit that referenced this pull request Aug 6, 2025
* fix: update current tools assignment to include tool names when MCP tools are not enabled

* fix: update enabled MCP tools assignment to include tool names on session switch
zerob13 added a commit that referenced this pull request Aug 6, 2025
* fix: prevent tooltip from overlapping HTML preview in ArtifactDialog (#683)

* fix: unwatch is not a function error in knowledge settings components (#684)

* fix: resolve message editing and markdown rendering issues (#685)

* docs: update Electron-Vite link format to full URL (#687)

* fix: built-in knowledge settings not loaded when first entering (#688)

* fix: enhance lifecycle management by adding unmounted hook and MCP state watcher

* fix: improve knowledge destruction confirmation and enhance unwatch handling in settings

* fix: resolve database lock issue in data reset functionality (#689)

* feat: implement provider-based request rate limit (#686)

* feat: implement provider-based request rate limit

* feat: add input validation with confirmation dialog

* refactor: merge RateLimitPresenter into LLMProviderPresenter

* Optimize/builtin knowledge interaction (#690)

* feat: improve builtInKnowledge file icon style

* feat: add builtInKnowledge resume icon tooltip

* feat: format code

* Update src/renderer/src/i18n/fa-IR/settings.json

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/renderer/src/i18n/ja-JP/settings.json

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/renderer/src/i18n/fr-FR/settings.json

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update settings.json

* Update src/renderer/src/i18n/fr-FR/settings.json

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: Fix French and Korean translations for pause and delete file confirmation messages

---------

Co-authored-by: sqsyli <sqsyli@qq.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: fixed dirty data problems (#691)

fixed the old session tool error caused by
fixed the problem that the tool list was not reset when creating a new session

* feat: add mentions support in deeplink (#692)

* feat: add mentions support in chat input and store

* style: format imports and clean up code for better readability

* fix: improve mentions handling in handleStart method

* fix: prompt attach files (#695)

* fix: update file icon handling and improve file upload process

* fix: remove redundant FileItem interface definition in PromptSetting.vue

* fix: implement confirmation dialog for prompt deletion in PromptSetting.vue

* fix: streamline file upload process by removing redundant file content reading logic

* feat: add npm registry caching and optimization system (#697)

* fix: resolve input focus loss issue after sending messages (#694)

* fix: resolve deeplink message not displaying when triggered from settings page (#699)

* fix: update current tools assignment to include tool names when MCP tools are not enabled (#698)

* feat: add support for new models  (#700)

* chore: update ollama model settings

* chore: add support for gpt-oss

* chore: bump to 0.2.9

* fix: refine #698 (#701)

* fix: update current tools assignment to include tool names when MCP tools are not enabled

* fix: update enabled MCP tools assignment to include tool names on session switch

* feat: add Claude Opus 4.1 support and fix anthropic model list dialog (#702)

---------

Co-authored-by: yyhhyyyyyy <yyhhyyyyyy8@gmail.com>
Co-authored-by: cycleccc <2991205548@qq.com>
Co-authored-by: hllshiro <40970081+hllshiro@users.noreply.github.com>
Co-authored-by: sqsyli <sqsyli@qq.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants