-
Notifications
You must be signed in to change notification settings - Fork 601
feat: add mcp passthrough for acp agent #1218
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds per-agent MCP selection and management across presenter, runtime, and renderer: new presenter APIs and data fields, UI selector, conversion/filtering of MCP servers into ACP sessions, tool filtering and access checks, i18n entries, and tests wiring McpConfHelper into ACP flows. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant AcpSettings as "ACP Settings UI"
participant ConfigPresenter
participant AcpConfHelper
participant AcpSessionMgr as "AcpSessionManager"
participant McpConverter as "convertMcpConfigToAcpFormat"
participant McpFilter as "filterMcpServersByTransportSupport"
participant AcpProcess as "ACP Session/Process"
User->>AcpSettings: toggle MCP selections (agent)
AcpSettings->>ConfigPresenter: setAgentMcpSelections(agentId,isBuiltin,mcpIds)
ConfigPresenter->>AcpConfHelper: setAgentMcpSelections(...)
AcpConfHelper-->>ConfigPresenter: persist OK
ConfigPresenter->>AcpSettings: handleAcpAgentsMutated -> refresh UI
Note right of AcpSessionMgr: Session init flow
AcpSessionMgr->>ConfigPresenter: getAgentMcpSelections(agentId)
ConfigPresenter->>AcpConfHelper: getAgentMcpSelections(...)
AcpConfHelper-->>ConfigPresenter: [mcpIds]
ConfigPresenter-->>AcpSessionMgr: [mcpIds]
AcpSessionMgr->>McpConverter: convert selected configs -> ACP servers
McpConverter-->>AcpSessionMgr: [servers]
AcpSessionMgr->>McpFilter: filter servers by mcpCapabilities
McpFilter-->>AcpSessionMgr: [filteredServers]
AcpSessionMgr->>AcpProcess: newSession(..., mcpServers=[filteredServers])
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 8
🧹 Nitpick comments (6)
src/renderer/src/i18n/zh-CN/mcp.json (1)
162-164: New ACP/MCP tool labels look consistentThe new keys (
acpManagedHint,acpServersSelected,acpServersNone) and{count}placeholder align with other locales and existing MCP tooling text.Just ensure the same keys exist in all supported locales to keep i18n bundles structurally in sync.
src/main/presenter/mcpPresenter/agentMcpFilter.ts (1)
3-16: LGTM! Clean and focused filtering utility.The
getAgentFilteredToolsfunction implements a straightforward filtering strategy:
- Guard clauses: Properly handles missing
agentIdor empty selections by returning[]- Efficient lookup: Uses
Setfor O(1) membership checks during filtering- Safe access: Uses optional chaining (
tool.server?.name) to handle undefined server references- Dependency injection: Accepts
configPresenteras a parameter, promoting testabilityOptional suggestion: Consider adding try-catch around the
configPresenter.getAgentMcpSelectionscall to handle potential failures gracefully. Per coding guidelines: "Always use try-catch to handle possible errors in TypeScript code" and "Provide meaningful error messages when catching errors."🔎 Optional: Add error handling
export async function getAgentFilteredTools( agentId: string, isBuiltin: boolean | undefined, allTools: MCPToolDefinition[], configPresenter: IConfigPresenter ): Promise<MCPToolDefinition[]> { if (!agentId) return [] - const selections = await configPresenter.getAgentMcpSelections(agentId, isBuiltin) + try { + const selections = await configPresenter.getAgentMcpSelections(agentId, isBuiltin) - if (!selections?.length) return [] + if (!selections?.length) return [] - const selectionSet = new Set(selections) - return allTools.filter((tool) => selectionSet.has(tool.server?.name)) + const selectionSet = new Set(selections) + return allTools.filter((tool) => selectionSet.has(tool.server?.name)) + } catch (error) { + console.error(`Failed to get MCP selections for agent ${agentId}:`, error) + return [] + } }src/renderer/src/components/chat-input/composables/useAgentMcpData.ts (1)
36-38: Minor: Guard against undefined inset.hascall.
prompt.client?.namecould beundefinedifclientis missing. WhileSet.has(undefined)returnsfalse(safe behavior), adding an explicit guard improves clarity.🔎 Suggested refinement
return mcpStore.prompts.filter( - (prompt) => prompt.client?.name === CUSTOM_PROMPTS_CLIENT || set.has(prompt.client?.name) + (prompt) => + prompt.client?.name === CUSTOM_PROMPTS_CLIENT || + (prompt.client?.name && set.has(prompt.client.name)) )src/main/presenter/llmProviderPresenter/agent/mcpConfigConverter.ts (1)
4-26: Consider consolidating normalize helpers.
normalizeStringRecordToArrayandnormalizeHeadershave similar logic. You could unify them with a generic helper, though the current approach provides clear type boundaries.🔎 Optional consolidation
const normalizeRecord = ( record: Record<string, unknown> | undefined | null ): Array<{ name: string; value: string }> => { if (!record || typeof record !== 'object') return [] return Object.entries(record) .map(([name, value]) => ({ name: String(name).trim(), value: typeof value === 'string' ? value : String(value ?? '') })) .filter((entry) => entry.name.length > 0) }Then use
normalizeRecordfor bothenvandheaders.src/renderer/src/components/mcp-config/AgentMcpSelector.vue (1)
31-49: Missing error handling inload()function.The
load()function catches errors implicitly via thefinallyblock but doesn't handle or surface errors to the user. If fetching MCP servers or selections fails, the component will silently show an empty state without any error indication.🔎 Proposed fix to add error handling
const load = async () => { if (!props.agentId) return loading.value = true try { const [servers, currentSelections] = await Promise.all([ configPresenter.getMcpServers(), configPresenter.getAgentMcpSelections(props.agentId, props.isBuiltin) ]) availableServers.value = Object.entries(servers ?? {}).map(([name, config]) => ({ name, config })) selections.value = Array.isArray(currentSelections) ? currentSelections : [] + } catch (error) { + console.error('[AgentMcpSelector] Failed to load MCP servers:', error) + availableServers.value = [] + selections.value = [] } finally { loading.value = false } }src/main/presenter/configPresenter/acpConfHelper.ts (1)
155-164: Consider:getAgentMcpSelectionsdoesn't require async.The method is marked
asyncbut only calls synchronous methods (getBuiltins(),getCustoms(),normalizeMcpSelections()). While this works fine, theasynckeyword is unnecessary.However, keeping it async maintains API consistency with the other MCP selection methods and allows for future async operations without API changes. This is acceptable as-is.
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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: 1
🧹 Nitpick comments (3)
src/renderer/src/i18n/ru-RU/settings.json (1)
1032-1032: Consider refining the word choice for clarity.The translation "В настоящее время не существует дополнительного MCP" is grammatically correct. However, if this empty-state message means "no available MCP" rather than "no additional MCP beyond some baseline", consider using "доступных" instead of "дополнительного":
- "mcpAccessEmpty": "В настоящее время не существует дополнительного MCP.", + "mcpAccessEmpty": "В настоящее время нет доступных MCP.",This would align better with
mcpAccessTitle: "Доступные MCP"(Available MCP). However, if "additional" is the intended meaning in the original text, the current translation is appropriate.Based on coding guidelines, verify that this translation is consistent with the English source and other language files (zh-CN, en-US, ko-KR, zh-HK, fr-FR, fa-IR).
src/renderer/src/components/NewThread.vue (1)
328-334: RedundantsyncModelWithModecall aftersetActiveFromEnabled.When
matchesModeProviderreturns true andsetActiveFromEnabledis called, the model is already aligned with the mode. The subsequentsyncModelWithModecall (line 331) will perform an early return due to the mode check at lines 296-298, but it's still unnecessary overhead.Consider removing the redundant sync call
Since the model was already validated as matching the mode by
matchesModeProvider, thesyncModelWithModecall is redundant:if (candidate?.settings?.modelId && candidate?.settings?.providerId) { const match = findEnabledModel(candidate.settings.providerId, candidate.settings.modelId) if (match && matchesModeProvider(candidate.settings.providerId, currentMode)) { setActiveFromEnabled({ ...match.model, providerId: match.providerId }) initialized.value = true - syncModelWithMode(chatMode.currentMode.value) return } }The same applies to lines 347 and 360.
src/renderer/src/stores/chat.ts (1)
133-134: Consider encapsulating the request ID counter.The
activeAgentMcpSelectionsRequestIdis a module-levelletvariable outside the store's reactive state. While this works for deduplication, it's a slight deviation from the Pinia pattern. This is minor and acceptable for this use case.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/mcp-config/AgentMcpSelector.vuesrc/renderer/src/i18n/en-US/settings.jsonsrc/renderer/src/i18n/fr-FR/settings.jsonsrc/renderer/src/i18n/ja-JP/settings.jsonsrc/renderer/src/i18n/ko-KR/settings.jsonsrc/renderer/src/i18n/pt-BR/settings.jsonsrc/renderer/src/i18n/ru-RU/settings.jsonsrc/renderer/src/stores/chat.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/renderer/src/i18n/pt-BR/settings.json
- src/renderer/src/components/mcp-config/AgentMcpSelector.vue
- src/renderer/src/i18n/ko-KR/settings.json
- src/renderer/src/i18n/fr-FR/settings.json
- src/renderer/src/i18n/ja-JP/settings.json
🧰 Additional context used
📓 Path-based instructions (32)
src/renderer/src/i18n/**/*.json
📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)
src/renderer/src/i18n/**/*.json: Translation key naming convention: use dot-separated hierarchical structure with lowercase letters and descriptive names (e.g., 'common.button.submit')
Maintain consistent key-value structure across all language translation files (zh-CN, en-US, ko-KR, ru-RU, zh-HK, fr-FR, fa-IR)
Files:
src/renderer/src/i18n/ru-RU/settings.jsonsrc/renderer/src/i18n/en-US/settings.json
src/**/*
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
New features should be developed in the
srcdirectory
Files:
src/renderer/src/i18n/ru-RU/settings.jsonsrc/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.tssrc/renderer/src/i18n/en-US/settings.json
src/renderer/**
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Use lowercase with dashes for directories (e.g., components/auth-wizard)
Files:
src/renderer/src/i18n/ru-RU/settings.jsonsrc/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.tssrc/renderer/src/i18n/en-US/settings.json
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for logs and comments (Chinese text exists in legacy code, but new code should use English)
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Enable and maintain strict TypeScript type checking for all files
**/*.{ts,tsx}: Always use try-catch to handle possible errors in TypeScript code
Provide meaningful error messages when catching errors
Log detailed error logs including error details, context, and stack traces
Distinguish and handle different error types (UserError, NetworkError, SystemError, BusinessError) with appropriate handlers in TypeScript
Use structured logging with logger.error(), logger.warn(), logger.info(), logger.debug() methods from logging utilities
Do not suppress errors (avoid empty catch blocks or silently ignoring errors)
Provide user-friendly error messages for user-facing errors in TypeScript components
Implement error retry mechanisms for transient failures in TypeScript
Avoid logging sensitive information (passwords, tokens, PII) in logs
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Organize core business logic into dedicated Presenter classes, with one presenter per functional domain
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.ts
src/main/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use EventBus from
src/main/eventbus.tsfor main-to-renderer communication, broadcasting events viamainWindow.webContents.send()
src/main/**/*.ts: Use EventBus pattern for inter-process communication within the main process to decouple modules
Use Electron's built-in APIs for file system and native dialogs instead of Node.js or custom implementations
src/main/**/*.ts: Electron main process code belongs insrc/main/with presenters inpresenter/(Window/Tab/Thread/Mcp/Config/LLMProvider) andeventbus.tsfor app events
Use the Presenter pattern in the main process for UI coordination
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.ts
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Do not include AI co-authoring information (e.g., 'Co-Authored-By: Claude') in git commits
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
**/*.{js,ts,jsx,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Write logs and comments in English
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
{src/main/presenter/**/*.ts,src/renderer/**/*.ts}
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
src/main/presenter/llmProviderPresenter/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-agent-loop.mdc)
Define the standardized
LLMCoreStreamEventinterface with fields:type(text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data),content(for text),reasoning_content(for reasoning),tool_call_id,tool_call_name,tool_call_arguments_chunk(for streaming),tool_call_arguments_complete(for complete arguments),error_message,usageobject with token counts,stop_reason(tool_use | max_tokens | stop_sequence | error | complete), andimage_dataobject with Base64-encoded data and mimeType
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
src/main/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Main process code for Electron should be placed in
src/main
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.ts
src/**/*.{ts,tsx,vue,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Prettier with single quotes, no semicolons, and 100 character width
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use OxLint for linting JavaScript and TypeScript files
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx}: Use camelCase for variable and function names in TypeScript files
Use PascalCase for type and class names in TypeScript
Use SCREAMING_SNAKE_CASE for constant names
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use EventBus for inter-process communication events
Files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.vue: Use Vue 3 Composition API for all components instead of Options API
Use Tailwind CSS with scoped styles for component styling
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
src/renderer/**/*.vue: All user-facing strings must use i18n keys via vue-i18n for internationalization
Ensure proper error handling and loading states in all UI components
Implement responsive design using Tailwind CSS utilities for all UI components
src/renderer/**/*.vue: Use composition API and declarative programming patterns; avoid options API
Structure files: exported component, composables, helpers, static content, types
Use PascalCase for component names (e.g., AuthWizard.vue)
Use Vue 3 with TypeScript, leveraging defineComponent and PropType
Use template syntax for declarative rendering
Use Shadcn Vue, Radix Vue, and Tailwind for components and styling
Implement responsive design with Tailwind CSS; use a mobile-first approach
Use Suspense for asynchronous components
Use <script setup> syntax for concise component definitions
Prefer 'lucide:' icon family as the primary choice for Iconify icons
Import Icon component from '@iconify/vue' and use with lucide icons following pattern '{collection}:{icon-name}'
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/NewThread.vue
src/renderer/src/**/*.{vue,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)
src/renderer/src/**/*.{vue,ts,tsx}: All user-facing strings must use i18n keys with vue-i18n framework in the renderer
Import and use useI18n() composable with the t() function to access translations in Vue components and TypeScript files
Use the dynamic locale.value property to switch languages at runtime
Avoid hardcoding user-facing text and ensure all user-visible text uses the i18n translation system
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
src/renderer/**/*.{vue,js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Renderer process code should be placed in
src/renderer(Vue 3 application)
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.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 in Vue.js applications
Implement proper state management with Pinia in Vue.js applications
Utilize Vue Router for navigation and route management in Vue.js applications
Leverage Vue's built-in reactivity system for efficient data handling
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
src/renderer/src/**/*.vue
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
Use scoped styles to prevent CSS conflicts between Vue components
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,tsx,vue}: Write concise, technical TypeScript code with accurate examples
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
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 statementsVue 3 app code in
src/renderer/srcshould be organized intocomponents/,stores/,views/,i18n/,lib/directories with shell UI insrc/renderer/shell/
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
src/renderer/**/*.{ts,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching
Leverage ref, reactive, and computed for reactive state management
Use provide/inject for dependency injection when appropriate
Use Iconify/Vue for icon implementation
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
src/renderer/src/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (AGENTS.md)
src/renderer/src/**/*.{ts,tsx,vue}: Use TypeScript with Vue 3 Composition API for the renderer application
All user-facing strings must use vue-i18n keys insrc/renderer/src/i18n
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
src/renderer/src/components/**/*.vue
📄 CodeRabbit inference engine (AGENTS.md)
src/renderer/src/components/**/*.vue: Use Tailwind for styles in Vue components
Vue component files must use PascalCase naming (e.g.,ChatInput.vue)
Files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use the
usePresenter.tscomposable for renderer-to-main IPC communication to call presenter methods directly
Files:
src/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.ts
src/renderer/**/composables/*.ts
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/composables/*.ts: Use camelCase for composables (e.g., useAuthState.ts)
Use VueUse for common composables and utility functions
Implement custom composables for reusable logic
Files:
src/renderer/src/components/chat-input/composables/useInputSettings.ts
src/renderer/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Use TypeScript for all code; prefer types over interfaces
Files:
src/renderer/src/components/chat-input/composables/useInputSettings.tssrc/renderer/src/stores/chat.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 in Pinia stores
Implement proper state persistence for maintaining data across sessions in Pinia stores
Use getters for computed state properties in Pinia stores
Utilize actions for side effects and asynchronous operations in Pinia stores
Keep Pinia stores focused on global state, not component-specific data
Files:
src/renderer/src/stores/chat.ts
src/renderer/**/stores/*.ts
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Use Pinia for state management
Files:
src/renderer/src/stores/chat.ts
src/renderer/src/stores/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Pinia for state management
Files:
src/renderer/src/stores/chat.ts
🧠 Learnings (29)
📓 Common learnings
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T05:28:20.513Z
Learning: Integrate MCP tools into the LLM provider architecture
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/mcpPresenter/**/*.ts : Register new MCP tools in `mcpPresenter/index.ts` after implementing them in `inMemoryServers/`
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/i18n/**/*.json : Maintain consistent key-value structure across all language translation files (zh-CN, en-US, ko-KR, ru-RU, zh-HK, fr-FR, fa-IR)
Applied to files:
src/renderer/src/i18n/ru-RU/settings.json
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/mcpPresenter/**/*.ts : Register new MCP tools in `mcpPresenter/index.ts` after implementing them in `inMemoryServers/`
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, handle native tool support by converting MCP tools to Provider format using `convertToProviderTools` and including them in the API request; for Providers without native function call support, prepare messages using `prepareFunctionCallPrompt` before making the API call
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Implement separation of concerns where `src/main/presenter/llmProviderPresenter/index.ts` manages the Agent loop and conversation history, while Provider files handle LLM API interactions, Provider-specific request/response formatting, tool definition conversion, and native vs non-native tool call mechanisms
Applied to files:
src/main/presenter/llmProviderPresenter/agent/acpProcessManager.tssrc/main/presenter/threadPresenter/managers/conversationManager.tssrc/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts` (`startStreamCompletion`), implement the Agent loop that manages the overall conversation flow, including multiple rounds of LLM calls and tool usage, maintaining `conversationMessages` history, calling `provider.coreStream()` on each iteration, and controlling the loop using `needContinueConversation` and `toolCallCount` (compared against `MAX_TOOL_CALLS`)
Applied to files:
src/main/presenter/threadPresenter/managers/conversationManager.ts
📚 Learning: 2025-11-25T05:28:20.513Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T05:28:20.513Z
Learning: Applies to src/renderer/src/components/**/*.vue : Vue component files must use PascalCase naming (e.g., `ChatInput.vue`)
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-11-25T05:27:45.545Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:45.545Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx,js,jsx} : Use the Composition API for better code organization and reusability in Vue.js applications
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vuesrc/renderer/src/components/NewThread.vue
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx} : Avoid hardcoding user-facing text and ensure all user-visible text uses the i18n translation system
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.vue : Use composition API and declarative programming patterns; avoid options API
Applied to files:
src/renderer/src/components/NewThread.vue
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/configPresenter/**/*.ts : Store and retrieve custom prompts via `configPresenter.getCustomPrompts()` for config-based data source management
Applied to files:
src/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/renderer/**/*.ts : Use the `usePresenter.ts` composable for renderer-to-main IPC communication to call presenter methods directly
Applied to files:
src/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts`, listen for standardized events yielded by `coreStream` and handle them accordingly: buffer text content (`currentContent`), handle `tool_call_start/chunk/end` events by collecting tool details and calling `presenter.mcpPresenter.callTool`, send frontend events via `eventBus` with tool call status, format tool results for the next LLM call, and set `needContinueConversation = true`
Applied to files:
src/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:28:20.513Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T05:28:20.513Z
Learning: Applies to src/main/**/*.ts : Use the Presenter pattern in the main process for UI coordination
Applied to files:
src/renderer/src/components/NewThread.vuesrc/renderer/src/stores/chat.ts
📚 Learning: 2025-06-21T15:49:17.044Z
Learnt from: neoragex2002
Repo: ThinkInAIXYZ/deepchat PR: 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/chat.ts
📚 Learning: 2025-11-25T05:27:20.067Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:20.067Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use modules to organize related state and actions in Pinia stores
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/stores/*.ts : Use Pinia for state management
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:28:20.513Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T05:28:20.513Z
Learning: Applies to src/renderer/src/stores/**/*.ts : Use Pinia for state management
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:20.067Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:20.067Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Keep Pinia stores focused on global state, not component-specific data
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:20.067Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:20.067Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use getters for computed state properties in Pinia stores
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:20.067Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:20.067Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Implement proper state persistence for maintaining data across sessions in Pinia stores
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:20.067Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:20.067Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Utilize actions for side effects and asynchronous operations in Pinia stores
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:45.545Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:45.545Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx,js,jsx} : Implement proper state management with Pinia in Vue.js applications
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Use Pinia for frontend state management and Vue Router for SPA routing
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.{ts,vue} : Leverage ref, reactive, and computed for reactive state management
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:39.200Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/provider-guidelines.mdc:0-0
Timestamp: 2025-11-25T05:27:39.200Z
Learning: Applies to **/*Provider**/index.ts : Do not emit `AssistantMessageBlock` or any UI types from Provider implementations to UI layer
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts`, handle `stop` events by checking `stop_reason`: if `'tool_use'`, add the buffered assistant message and prepare for the next loop iteration; otherwise, add the final assistant message and exit the loop
Applied to files:
src/renderer/src/stores/chat.ts
📚 Learning: 2025-11-25T05:26:24.867Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/electron-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:26:24.867Z
Learning: Applies to {src/main/presenter/**/*.ts,src/renderer/**/*.ts} : Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Applied to files:
src/renderer/src/stores/chat.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-check (x64)
🔇 Additional comments (21)
src/renderer/src/components/chat-input/composables/useInputSettings.ts (2)
21-38: LGTM! Clean implementation of the setter pattern.The
setWebSearchfunction properly:
- Returns early when the value is unchanged (avoiding unnecessary persistence calls)
- Reverts to the previous value on error
- Logs meaningful error context
The refactored
toggleWebSearchcorrectly delegates tosetWebSearch, reducing code duplication.
75-81: API surface looks good.The public API is cleanly expanded to include both the direct setter (
setWebSearch) and the toggle convenience method (toggleWebSearch), giving consumers flexibility in how they update the web search state.src/renderer/src/components/chat-input/ChatInput.vue (5)
564-569: LGTM! Clean integration of web search control.The
canUseWebSearchcomputed property provides a single source of truth for web search availability based on chat mode. This is well-placed near the settings destructuring for clarity.
185-202: Good use of conditional rendering for the web search button.Gating the entire
Tooltipcomponent withv-if="canUseWebSearch"cleanly hides the button when web search is not applicable, maintaining a consistent UI for non-chat modes.
793-800: Defensive logic ensures search is never sent when unavailable.The ternary
canUseWebSearch.value ? settings.value.webSearch : falseensures thesearchfield is alwaysfalsewhen web search is not supported, regardless of any stale state. This is good defensive programming.
815-818: Guard clause prevents unintended toggling.The early return when
!canUseWebSearch.valueis a good safeguard, even though the button is hidden viav-if. This protects against programmatic calls or future refactors that might bypass the UI gate.
952-960: Watcher correctly resets web search state on mode change.The watcher properly:
- Watches both mode and webSearch state to catch all transitions
- Uses
immediate: trueto enforce the invariant on initial load- Uses
voidfor the fire-and-forget async call (sincesetWebSearchhandles its own error recovery internally)One consideration: if the user rapidly switches modes before
setWebSearchcompletes, the optimistic UI update insetWebSearchshould handle this gracefully since it reverts on failure.src/renderer/src/i18n/ru-RU/settings.json (1)
1031-1031: Placeholder fix successfully applied.The
mcpAccessBadgenow correctly uses{count}instead of{количество}, which will properly interpolate with the calling code. This addresses the issue raised in the previous review.src/renderer/src/i18n/en-US/settings.json (2)
892-892: LGTM!The key naming follows the established camelCase convention used throughout this file, and the text is clear and appropriate for a UI label.
894-894: LGTM!The badge label format with the
{count}placeholder is concise and follows the established pattern used elsewhere in the translations.src/renderer/src/components/NewThread.vue (3)
262-270: LGTM! Clean mode-matching helpers.The
pickModelForModeandmatchesModeProviderfunctions are well-designed and provide a clear abstraction for mode-aware model selection.
285-310: Config persistence added insetActiveFromEnabled.The update to persist model selection to
chatConfigand the newsyncModelWithModefunction are well-structured. The early return when the mode already matches (lines 296-298) is a good optimization to avoid unnecessary work.
391-403: Mode-change watcher correctly consolidated.The watcher now uses a single
syncModelWithMode(newMode, true)call which is much cleaner than the previous extensive ACP vs non-ACP switching logic mentioned in the AI summary.src/main/presenter/llmProviderPresenter/agent/acpProcessManager.ts (3)
35-35: Interface correctly extended withmcpCapabilities.The
AcpProcessHandleinterface now includes the optionalmcpCapabilitiesproperty.
528-536: MCP capabilities correctly extracted from initialization result.The code properly reads
agentCapabilities.mcpCapabilitiesfrom the initialization response and stores it onhandleSeed.mcpCapabilities. The console log provides useful debugging information.
590-594: Past review issue resolved:mcpCapabilitiesnow propagated to final handle.The previous reviews flagged that
mcpCapabilitieswas captured but never exposed on the finalAcpProcessHandle. This has been correctly addressed by includingmcpCapabilities: handleSeed.mcpCapabilitiesin the handle construction.src/renderer/src/stores/chat.ts (4)
128-163: Well-designed ACP mode tracking with request deduplication.The implementation handles several important aspects correctly:
isAcpModecomputed property cleanly derives fromcurrentModeactiveAcpAgentIdproperly extracts the agent ID only in ACP mode- Request deduplication via
activeAgentMcpSelectionsRequestIdprevents stale responses from overwriting newer data- Error handling with fallback to empty array ensures graceful degradation
- The watcher with
{ immediate: true }ensures initial state is populated
263-267: State reset on thread clear is appropriate.Resetting
acpWorkdirMapandagentWorkspacePathwhen clearing the active thread ensures clean state for the next conversation.
1385-1390: Event-driven refresh of MCP selections.Listening for
MODEL_LIST_CHANGEDwith a filter for the 'acp' provider ensures the MCP selections are refreshed when relevant configuration changes. This is a good integration pattern.
1555-1556: New computed properties correctly exposed.
isAcpModeandactiveAgentMcpSelectionsare appropriately added to the store's return object for consumption by other components.src/main/presenter/threadPresenter/managers/conversationManager.ts (1)
186-187: The implementation is correct and follows established patterns. Type definitions foracpWorkdirMapandagentWorkspacePathare properly defined in CONVERSATION_SETTINGS asRecord<string, string | null>andstring | nullrespectively, matching the reset values. The reset pattern is consistent with other conversation-specific fields likesystemPromptandselectedVariantsMap—no filesystem cleanup is required, as this clears in-memory references for a fresh conversation start. Since each conversation maintains isolated settings, resetting workspace paths for a new conversation does not disrupt active processes.
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: 2
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/presenter/configPresenter/systemPromptHelper.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.tssrc/main/presenter/threadPresenter/utils/promptBuilder.tssrc/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
✅ Files skipped from review due to trivial changes (1)
- src/main/presenter/configPresenter/systemPromptHelper.ts
🧰 Additional context used
📓 Path-based instructions (21)
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for logs and comments (Chinese text exists in legacy code, but new code should use English)
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/renderer/settings/components/prompt/SystemPromptSettingsSection.vuesrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Enable and maintain strict TypeScript type checking for all files
**/*.{ts,tsx}: Always use try-catch to handle possible errors in TypeScript code
Provide meaningful error messages when catching errors
Log detailed error logs including error details, context, and stack traces
Distinguish and handle different error types (UserError, NetworkError, SystemError, BusinessError) with appropriate handlers in TypeScript
Use structured logging with logger.error(), logger.warn(), logger.info(), logger.debug() methods from logging utilities
Do not suppress errors (avoid empty catch blocks or silently ignoring errors)
Provide user-friendly error messages for user-facing errors in TypeScript components
Implement error retry mechanisms for transient failures in TypeScript
Avoid logging sensitive information (passwords, tokens, PII) in logs
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Organize core business logic into dedicated Presenter classes, with one presenter per functional domain
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/main/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use EventBus from
src/main/eventbus.tsfor main-to-renderer communication, broadcasting events viamainWindow.webContents.send()
src/main/**/*.ts: Use EventBus pattern for inter-process communication within the main process to decouple modules
Use Electron's built-in APIs for file system and native dialogs instead of Node.js or custom implementations
src/main/**/*.ts: Electron main process code belongs insrc/main/with presenters inpresenter/(Window/Tab/Thread/Mcp/Config/LLMProvider) andeventbus.tsfor app events
Use the Presenter pattern in the main process for UI coordination
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Do not include AI co-authoring information (e.g., 'Co-Authored-By: Claude') in git commits
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
**/*.{js,ts,jsx,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Write logs and comments in English
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
{src/main/presenter/**/*.ts,src/renderer/**/*.ts}
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/**/*
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
New features should be developed in the
srcdirectory
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/renderer/settings/components/prompt/SystemPromptSettingsSection.vuesrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/main/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Main process code for Electron should be placed in
src/main
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/**/*.{ts,tsx,vue,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Prettier with single quotes, no semicolons, and 100 character width
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/renderer/settings/components/prompt/SystemPromptSettingsSection.vuesrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use OxLint for linting JavaScript and TypeScript files
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx}: Use camelCase for variable and function names in TypeScript files
Use PascalCase for type and class names in TypeScript
Use SCREAMING_SNAKE_CASE for constant names
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use EventBus for inter-process communication events
Files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.vue: Use Vue 3 Composition API for all components instead of Options API
Use Tailwind CSS with scoped styles for component styling
Files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
src/renderer/**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
src/renderer/**/*.vue: All user-facing strings must use i18n keys via vue-i18n for internationalization
Ensure proper error handling and loading states in all UI components
Implement responsive design using Tailwind CSS utilities for all UI components
src/renderer/**/*.vue: Use composition API and declarative programming patterns; avoid options API
Structure files: exported component, composables, helpers, static content, types
Use PascalCase for component names (e.g., AuthWizard.vue)
Use Vue 3 with TypeScript, leveraging defineComponent and PropType
Use template syntax for declarative rendering
Use Shadcn Vue, Radix Vue, and Tailwind for components and styling
Implement responsive design with Tailwind CSS; use a mobile-first approach
Use Suspense for asynchronous components
Use <script setup> syntax for concise component definitions
Prefer 'lucide:' icon family as the primary choice for Iconify icons
Import Icon component from '@iconify/vue' and use with lucide icons following pattern '{collection}:{icon-name}'
Files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
src/renderer/**/*.{vue,js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Renderer process code should be placed in
src/renderer(Vue 3 application)
Files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
src/renderer/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,tsx,vue}: Write concise, technical TypeScript code with accurate examples
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
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 statementsVue 3 app code in
src/renderer/srcshould be organized intocomponents/,stores/,views/,i18n/,lib/directories with shell UI insrc/renderer/shell/
Files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
src/renderer/**
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Use lowercase with dashes for directories (e.g., components/auth-wizard)
Files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
src/renderer/**/*.{ts,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching
Leverage ref, reactive, and computed for reactive state management
Use provide/inject for dependency injection when appropriate
Use Iconify/Vue for icon implementation
Files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
src/main/presenter/llmProviderPresenter/providers/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
src/main/presenter/llmProviderPresenter/providers/*.ts: Each LLM provider must implement thecoreStreammethod following the standardized event interface for tool calling and response streaming
Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation
src/main/presenter/llmProviderPresenter/providers/*.ts: In Provider implementations (src/main/presenter/llmProviderPresenter/providers/*.ts), thecoreStream(messages, modelId, temperature, maxTokens)method should perform a single-pass streaming API request for each conversation round without containing multi-turn tool call loop logic
In Provider implementations, handle native tool support by converting MCP tools to Provider format usingconvertToProviderToolsand including them in the API request; for Providers without native function call support, prepare messages usingprepareFunctionCallPromptbefore making the API call
In Provider implementations, parse Provider-specific data chunks from the streaming response andyieldstandardizedLLMCoreStreamEventobjects conforming to the standard stream event interface, including text, reasoning, tool calls, usage, errors, stop reasons, and image data
In Provider implementations, include helper methods for Provider-specific operations such asformatMessages,convertToProviderTools,parseFunctionCalls, andprepareFunctionCallPrompt
Files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
src/main/presenter/llmProviderPresenter/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-agent-loop.mdc)
Define the standardized
LLMCoreStreamEventinterface with fields:type(text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data),content(for text),reasoning_content(for reasoning),tool_call_id,tool_call_name,tool_call_arguments_chunk(for streaming),tool_call_arguments_complete(for complete arguments),error_message,usageobject with token counts,stop_reason(tool_use | max_tokens | stop_sequence | error | complete), andimage_dataobject with Base64-encoded data and mimeType
Files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/mcpPresenter/**/*.ts : Register new MCP tools in `mcpPresenter/index.ts` after implementing them in `inMemoryServers/`
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T05:28:20.513Z
Learning: Integrate MCP tools into the LLM provider architecture
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, handle native tool support by converting MCP tools to Provider format using `convertToProviderTools` and including them in the API request; for Providers without native function call support, prepare messages using `prepareFunctionCallPrompt` before making the API call
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/configPresenter/**/*.ts : Store and retrieve custom prompts via `configPresenter.getCustomPrompts()` for config-based data source management
Applied to files:
src/main/presenter/threadPresenter/utils/promptBuilder.tssrc/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, include helper methods for Provider-specific operations such as `formatMessages`, `convertToProviderTools`, `parseFunctionCalls`, and `prepareFunctionCallPrompt`
Applied to files:
src/main/presenter/threadPresenter/utils/promptBuilder.ts
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx} : Avoid hardcoding user-facing text and ensure all user-visible text uses the i18n translation system
Applied to files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/i18n/**/*.json : Maintain consistent key-value structure across all language translation files (zh-CN, en-US, ko-KR, ru-RU, zh-HK, fr-FR, fa-IR)
Applied to files:
src/renderer/settings/components/prompt/SystemPromptSettingsSection.vue
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation
Applied to files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Implement separation of concerns where `src/main/presenter/llmProviderPresenter/index.ts` manages the Agent loop and conversation history, while Provider files handle LLM API interactions, Provider-specific request/response formatting, tool definition conversion, and native vs non-native tool call mechanisms
Applied to files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations (`src/main/presenter/llmProviderPresenter/providers/*.ts`), the `coreStream(messages, modelId, temperature, maxTokens)` method should perform a *single-pass* streaming API request for each conversation round without containing multi-turn tool call loop logic
Applied to files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/**/*.ts : Define the standardized `LLMCoreStreamEvent` interface with fields: `type` (text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data), `content` (for text), `reasoning_content` (for reasoning), `tool_call_id`, `tool_call_name`, `tool_call_arguments_chunk` (for streaming), `tool_call_arguments_complete` (for complete arguments), `error_message`, `usage` object with token counts, `stop_reason` (tool_use | max_tokens | stop_sequence | error | complete), and `image_data` object with Base64-encoded data and mimeType
Applied to files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, parse Provider-specific data chunks from the streaming response and `yield` standardized `LLMCoreStreamEvent` objects conforming to the standard stream event interface, including text, reasoning, tool calls, usage, errors, stop reasons, and image data
Applied to files:
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-check (x64)
🔇 Additional comments (3)
src/main/presenter/threadPresenter/utils/promptBuilder.ts (1)
928-928: LGTM! Improved text clarity.The simplified phrasing "Today is" is more concise and natural than "Today's date and time is", while the detailed timestamp that follows makes it clear the full date and time information is included.
src/main/presenter/llmProviderPresenter/providers/anthropicProvider.ts (2)
76-76: LGTM!The
first_idcorrectly points to the new first model in the list.
262-263: Verify the anthropic-beta header flags; found potential discrepancies.The header consistently uses the same four beta flags in both OAuth methods. Verification found:
- ✓
interleaved-thinking-2025-05-14andfine-grained-tool-streaming-2025-05-14are confirmed as valid public beta features.- ✗
claude-code-20250219is not explicitly documented in current sources; the code execution tool usescode-execution-2025-08-25instead. Clarify if this flag is correct or should be updated.- ✗
oauth-2025-04-20could not be verified in current Anthropic API documentation. Confirm this flag is valid and necessary.If any flag is invalid, Anthropic's API returns an
invalid_request_error. Please verify these flags are current and will not cause API failures.
finish #1213
Summary by CodeRabbit
New Features
Improvements
Localization
Tests
✏️ Tip: You can customize this high-level summary in your review settings.