-
Notifications
You must be signed in to change notification settings - Fork 614
fix: custom prompt sync after setting #1065
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 Currently processing new changes in this PR. This may take a few minutes, please wait... 📒 Files selected for processing (12)
WalkthroughThe changes add custom prompts support with reactive state management and IPC synchronization, Settings window persistence, reactive context length tracking in ChatInput, and error messages across multiple locales for missing prompts. Changes
Sequence DiagramsequenceDiagram
participant MainProc as Main Process
participant Config as ConfigPresenter
participant Renderer as Renderer Process
participant Store as MCP Store
participant UI as ChatView
MainProc->>Config: setCustomPrompts(prompts, count)
Config->>Renderer: emit CONFIG_EVENTS.CUSTOM_PROMPTS_CHANGED
Renderer->>Store: IPC listener receives event
Store->>Store: reload custom prompts
Note over UI: User selects custom prompt
UI->>Store: getPrompt(promptName)
Store->>Store: check if custom-prompts-server source
alt Custom Prompt Found
Store->>Store: substitute parameters from args
Store-->>UI: return user-content message
else Custom Prompt Not Found
Store-->>UI: throw promptNotFound error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
src/main/events.ts(1 hunks)src/main/presenter/configPresenter/index.ts(1 hunks)src/main/presenter/windowPresenter/index.ts(3 hunks)src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue(1 hunks)src/renderer/src/components/ChatView.vue(1 hunks)src/renderer/src/components/chat-input/ChatInput.vue(2 hunks)src/renderer/src/components/chat-input/composables/useContextLength.ts(2 hunks)src/renderer/src/components/chat-input/composables/useSendButtonState.ts(3 hunks)src/renderer/src/events.ts(1 hunks)src/renderer/src/i18n/en-US/mcp.json(1 hunks)src/renderer/src/i18n/fa-IR/mcp.json(1 hunks)src/renderer/src/i18n/fr-FR/mcp.json(1 hunks)src/renderer/src/i18n/ja-JP/mcp.json(1 hunks)src/renderer/src/i18n/ko-KR/mcp.json(1 hunks)src/renderer/src/i18n/pt-BR/mcp.json(1 hunks)src/renderer/src/i18n/ru-RU/mcp.json(1 hunks)src/renderer/src/i18n/zh-CN/mcp.json(1 hunks)src/renderer/src/i18n/zh-HK/mcp.json(1 hunks)src/renderer/src/i18n/zh-TW/mcp.json(1 hunks)src/renderer/src/stores/mcp.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (24)
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/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/pt-BR/mcp.jsonsrc/renderer/src/i18n/zh-HK/mcp.jsonsrc/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/ko-KR/mcp.jsonsrc/renderer/src/components/ChatView.vuesrc/renderer/src/i18n/fa-IR/mcp.jsonsrc/renderer/src/stores/mcp.tssrc/renderer/src/i18n/ru-RU/mcp.jsonsrc/renderer/src/i18n/en-US/mcp.jsonsrc/renderer/src/i18n/ja-JP/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.jsonsrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/src/**
📄 CodeRabbit inference engine (AGENTS.md)
Place Vue 3 app source under src/renderer/src (components, stores, views, i18n, lib)
Files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/pt-BR/mcp.jsonsrc/renderer/src/i18n/zh-HK/mcp.jsonsrc/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/ko-KR/mcp.jsonsrc/renderer/src/components/ChatView.vuesrc/renderer/src/i18n/fa-IR/mcp.jsonsrc/renderer/src/stores/mcp.tssrc/renderer/src/i18n/ru-RU/mcp.jsonsrc/renderer/src/i18n/en-US/mcp.jsonsrc/renderer/src/i18n/ja-JP/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.jsonsrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/src/i18n/**/*.{ts,json,yml,yaml}
📄 CodeRabbit inference engine (AGENTS.md)
Store i18n resources under src/renderer/src/i18n
Files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/pt-BR/mcp.jsonsrc/renderer/src/i18n/zh-HK/mcp.jsonsrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/ko-KR/mcp.jsonsrc/renderer/src/i18n/fa-IR/mcp.jsonsrc/renderer/src/i18n/ru-RU/mcp.jsonsrc/renderer/src/i18n/en-US/mcp.jsonsrc/renderer/src/i18n/ja-JP/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.json
**/*.{ts,tsx,js,jsx,vue,css,scss,md,json,yml,yaml}
📄 CodeRabbit inference engine (AGENTS.md)
Prettier style: single quotes, no semicolons, print width 100; run pnpm run format
Files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/pt-BR/mcp.jsonsrc/renderer/src/i18n/zh-HK/mcp.jsonsrc/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/ko-KR/mcp.jsonsrc/renderer/src/components/ChatView.vuesrc/renderer/src/i18n/fa-IR/mcp.jsonsrc/renderer/src/stores/mcp.tssrc/renderer/src/i18n/ru-RU/mcp.jsonsrc/main/presenter/windowPresenter/index.tssrc/renderer/src/i18n/en-US/mcp.jsonsrc/renderer/src/i18n/ja-JP/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.jsonsrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/main/presenter/configPresenter/index.tssrc/renderer/src/components/chat-input/ChatInput.vue
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/stores/mcp.tssrc/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/main/presenter/configPresenter/index.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/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/stores/mcp.tssrc/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/main/presenter/configPresenter/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/stores/mcp.tssrc/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/main/presenter/configPresenter/index.ts
src/renderer/**/*.{vue,ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
渲染进程代码放在
src/renderer
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/chat-input/ChatInput.vue
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/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
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/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/**/*.{vue,ts}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Implement lazy loading for routes and components.
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/chat-input/ChatInput.vue
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.Use Pinia for frontend state management (do not introduce alternative state libraries)
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/chat-input/ChatInput.vue
**/*.{ts,tsx,js,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/main/presenter/configPresenter/index.tssrc/renderer/src/components/chat-input/ChatInput.vue
**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Enable and adhere to strict TypeScript typing (avoid implicit any, prefer precise types)
Use PascalCase for TypeScript types and classes
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/main/presenter/configPresenter/index.tssrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/src/**/*.{vue,ts}
📄 CodeRabbit inference engine (AGENTS.md)
All user-facing strings must use vue-i18n ($t/keys) rather than hardcoded literals
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx,vue}: Use OxLint for JS/TS code; keep lint clean
Use camelCase for variables and functions
Use SCREAMING_SNAKE_CASE for constants
Files:
src/renderer/src/events.tssrc/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/stores/mcp.tssrc/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/main/presenter/configPresenter/index.tssrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/src/components/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Organize UI components by feature within src/renderer/src/
Files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/ChatView.vuesrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/src/**/*.vue
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
Use scoped styles to prevent CSS conflicts between components
Files:
src/renderer/src/components/ChatView.vuesrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/{src,shell,floating}/**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
src/renderer/{src,shell,floating}/**/*.vue: Use Vue 3 Composition API for all components
All user-facing strings must use i18n keys via vue-i18n (no hard-coded UI strings)
Use Tailwind CSS utilities and ensure styles are scoped in Vue components
Files:
src/renderer/src/components/ChatView.vuesrc/renderer/src/components/chat-input/ChatInput.vue
src/renderer/**/*.vue
📄 CodeRabbit inference engine (AGENTS.md)
Name Vue component files in PascalCase (e.g., ChatInput.vue)
Files:
src/renderer/src/components/ChatView.vuesrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/chat-input/ChatInput.vue
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/main/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Use Electron's built-in APIs for file system and native dialogs
Files:
src/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/main/presenter/configPresenter/index.ts
src/main/**/*.{ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
主进程代码放在
src/main
Files:
src/main/presenter/windowPresenter/index.tssrc/main/events.tssrc/main/presenter/configPresenter/index.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Place Electron main-process presenters under src/main/presenter/ (Window, Tab, Thread, Mcp, Config, LLMProvider)
Files:
src/main/presenter/windowPresenter/index.tssrc/main/presenter/configPresenter/index.ts
🧠 Learnings (33)
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/i18n/*.json : Maintain consistent structure across all translation files
Applied to files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.json
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/i18n/common.json : Shared translation keys must be placed in 'src/renderer/src/i18n/common.json'
Applied to files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/pt-BR/mcp.jsonsrc/renderer/src/i18n/zh-HK/mcp.jsonsrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/ko-KR/mcp.jsonsrc/renderer/src/i18n/fa-IR/mcp.jsonsrc/renderer/src/i18n/ru-RU/mcp.jsonsrc/renderer/src/i18n/en-US/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.json
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/i18n/*.json : Regularly check for unused translation keys in i18n files
Applied to files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.json
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/i18n/*.json : When adding new translations, add shared keys to 'common.json' and language-specific keys to the respective language file; keep all language files' keys consistent
Applied to files:
src/renderer/src/i18n/zh-CN/mcp.jsonsrc/renderer/src/i18n/zh-TW/mcp.jsonsrc/renderer/src/i18n/fr-FR/mcp.json
📚 Learning: 2025-07-21T01:46:19.702Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/error-logging.mdc:0-0
Timestamp: 2025-07-21T01:46:19.702Z
Learning: Applies to **/*.{ts,tsx} : 提供用户友好的错误信息
Applied to files:
src/renderer/src/i18n/zh-HK/mcp.json
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Leverage ref, reactive, and computed for reactive state management.
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/{composables,utils}/**/*.ts : Use VueUse for common composables and utility functions.
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Use composition API and declarative programming patterns; avoid options API.
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Use Vue 3 with TypeScript, leveraging defineComponent and PropType.
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-21T01:47:28.817Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:28.817Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx,js,jsx} : Use the Composition API for better code organization and reusability
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{ts,tsx,vue} : Use arrow functions for methods and computed properties.
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-21T01:47:28.817Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:28.817Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx,js,jsx} : Leverage Vue's built-in reactivity system for efficient data handling
Applied to files:
src/renderer/src/components/chat-input/composables/useContextLength.tssrc/renderer/src/components/chat-input/composables/useSendButtonState.tssrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-10-14T08:02:59.495Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: AGENTS.md:0-0
Timestamp: 2025-10-14T08:02:59.495Z
Learning: Applies to src/renderer/**/*.vue : Name Vue component files in PascalCase (e.g., ChatInput.vue)
Applied to files:
src/renderer/src/components/ChatView.vuesrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-09-06T03:07:23.817Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-06T03:07:23.817Z
Learning: Applies to src/main/presenter/mcpPresenter/index.ts : Register new MCP tools in src/main/presenter/mcpPresenter/index.ts
Applied to files:
src/renderer/src/stores/mcp.tssrc/main/presenter/configPresenter/index.ts
📚 Learning: 2025-09-06T03:07:23.817Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-06T03:07:23.817Z
Learning: Applies to src/main/presenter/mcpPresenter/inMemoryServers/*.ts : Implement new MCP tools under src/main/presenter/mcpPresenter/inMemoryServers/
Applied to files:
src/renderer/src/stores/mcp.ts
📚 Learning: 2025-07-21T01:46:52.880Z
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 does not support native function calling, it must prepare messages using prompt wrapping (e.g., `prepareFunctionCallPrompt`) before making the API call.
Applied to files:
src/renderer/src/stores/mcp.tssrc/main/presenter/configPresenter/index.ts
📚 Learning: 2025-07-21T01:46:52.880Z
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: 2025-10-14T08:02:59.495Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: AGENTS.md:0-0
Timestamp: 2025-10-14T08:02:59.495Z
Learning: Applies to src/main/presenter/**/*.ts : Place Electron main-process presenters under src/main/presenter/ (Window, Tab, Thread, Mcp, Config, LLMProvider)
Applied to files:
src/main/presenter/windowPresenter/index.tssrc/main/presenter/configPresenter/index.ts
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/i18n/*.json : Translation key naming must use dot-separated hierarchy, lowercase letters, and meaningful descriptive names (e.g., 'common.button.submit')
Applied to files:
src/renderer/src/i18n/fr-FR/mcp.json
📚 Learning: 2025-09-06T03:07:23.817Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-06T03:07:23.817Z
Learning: Applies to src/renderer/{src,shell,floating}/**/*.vue : All user-facing strings must use i18n keys via vue-i18n (no hard-coded UI strings)
Applied to files:
src/renderer/src/i18n/fr-FR/mcp.jsonsrc/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/composables/**/*.ts : Use camelCase for composables (e.g., useAuthState.ts).
Applied to files:
src/renderer/src/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-06-21T15:49:17.044Z
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/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-07-21T01:47:03.479Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:03.479Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Keep the store focused on global state, not component-specific data
Applied to files:
src/renderer/src/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-07-21T01:47:03.479Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:03.479Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use getters for computed state properties
Applied to files:
src/renderer/src/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-07-21T01:47:03.479Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:03.479Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Use modules to organize related state and actions
Applied to files:
src/renderer/src/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-07-21T01:47:03.479Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:03.479Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Implement proper state persistence for maintaining data across sessions
Applied to files:
src/renderer/src/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-07-21T01:47:03.479Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/pinia-best-practices.mdc:0-0
Timestamp: 2025-07-21T01:47:03.479Z
Learning: Applies to src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx} : Utilize actions for side effects and asynchronous operations
Applied to files:
src/renderer/src/components/chat-input/composables/useSendButtonState.ts
📚 Learning: 2025-09-06T03:07:23.817Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-06T03:07:23.817Z
Learning: Applies to src/main/presenter/configPresenter/providers.ts : Add provider configuration entries in src/main/presenter/configPresenter/providers.ts
Applied to files:
src/main/presenter/configPresenter/index.ts
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Use provide/inject for dependency injection when appropriate.
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-10-14T08:02:59.495Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: AGENTS.md:0-0
Timestamp: 2025-10-14T08:02:59.495Z
Learning: Applies to src/renderer/src/**/*.{vue,ts} : All user-facing strings must use vue-i18n ($t/keys) rather than hardcoded literals
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Use <script setup> syntax for concise component definitions.
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/**/* : Use the 'vue-i18n' framework for all internationalization in the renderer
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
📚 Learning: 2025-10-14T08:02:59.495Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: AGENTS.md:0-0
Timestamp: 2025-10-14T08:02:59.495Z
Learning: Use TypeScript + Vue 3 Composition API with Pinia for state and Tailwind for styles in the renderer
Applied to files:
src/renderer/src/components/chat-input/ChatInput.vue
🪛 ast-grep (0.39.6)
src/renderer/src/stores/mcp.ts
[warning] 488-488: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp({{${key}}}, 'g')
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
🔇 Additional comments (20)
src/renderer/src/i18n/ko-KR/mcp.json (1)
250-251: No issues found.The
promptNotFoundkey has been successfully added to all 10 locale files (en-US, ja-JP, zh-CN, zh-TW, zh-HK, fr-FR, ru-RU, fa-IR, pt-BR, ko-KR), ensuring consistent internationalization across all supported languages.src/renderer/src/i18n/zh-CN/mcp.json (1)
25-26: LGTM! Consistent i18n addition across all locales.The
promptNotFoundtranslation key has been added consistently across all locale files (zh-CN, en-US, zh-TW, fr-FR, zh-HK, ja-JP, pt-BR) with proper JSON syntax and appropriate translations for each language. The {name} placeholder is used consistently to support dynamic error messages when a custom prompt is not found.src/renderer/src/events.ts (1)
28-29: LGTM! Event constant added correctly.The new
CUSTOM_PROMPTS_CHANGEDevent follows the established naming convention (domain:event-name format with lowercase and hyphens) and is appropriately placed in theCONFIG_EVENTSobject. This enables proper IPC notification when custom prompts are modified, supporting the reactive state management mentioned in the PR objectives.src/renderer/src/i18n/fa-IR/mcp.json (1)
250-251: LGTM! Localization key added correctly.The new
promptNotFounderror message key has been added consistently with the existing structure, and the trailing comma maintains valid JSON syntax.src/main/presenter/configPresenter/index.ts (1)
1305-1308: LGTM! Event notification pattern is well-implemented.The renderer-wide notification after saving custom prompts follows the established pattern in this file and ensures all windows stay synchronized. Cache invalidation at line 1303 before the notification ensures fresh data on reload.
src/main/presenter/windowPresenter/index.ts (3)
1279-1291: LGTM! Window state persistence improves UX.The settings window now persists its position and size between sessions using
electron-window-state, which is a good UX improvement. The default dimensions (900x600) are appropriate for settings content, and using a separate state file (settings-window-state.json) keeps it independent from other windows.
1328-1344: LGTM! External URL handling is secure.The URL validation only allows
http://andhttps://protocols, which prevents potential security issues from openingfile://,javascript:, or other schemes. Invalid URLs and blocked protocols are properly logged for debugging.
1360-1361: LGTM! State manager cleanup prevents memory leaks.Calling
unmanage()when the settings window closes ensures the state manager stops tracking the window, preventing memory leaks. This pattern is consistent with the shell window management at line 882.src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue (1)
208-208: LGTM! Documentation comment clarifies event flow.The inline comment helps developers understand that the main window will be notified when custom prompts are loaded, referencing the newly added
CONFIG_EVENTS.CUSTOM_PROMPTS_CHANGEDevent.src/renderer/src/components/ChatView.vue (1)
15-15: LGTM! Context length binding enables reactive tracking.The new
:context-lengthprop binding passes the reactivecontextLengthfrom the chat store to theChatInputcomponent. This works seamlessly with ChatInput's use oftoRef(props, 'contextLength')to track context length changes reactively.src/renderer/src/i18n/ru-RU/mcp.json (1)
250-251: LGTM! Localization key added correctly.The new
promptNotFounderror message key has been added consistently with the existing structure, and the trailing comma maintains valid JSON syntax.src/renderer/src/components/chat-input/ChatInput.vue (2)
269-269: LGTM! Import addition supports reactive prop handling.The
toRefimport from Vue enables reactive wrapping of thecontextLengthprop, which is used at lines 438 and 446 to provide reactive context length tracking to composables.
438-446: LGTM! Reactive prop handling enables runtime updates.Using
toRef(props, 'contextLength')instead of direct prop access creates a reactive reference that automatically updates when the parent component changes thecontextLengthprop. This enables the context length tracker and send button state to respond to runtime changes in context length.This pattern aligns well with the Vue 3 Composition API best practices and works seamlessly with the updated composables that accept
MaybeRef<number | undefined>.src/renderer/src/stores/mcp.ts (2)
497-499: Good architectural separation.Moving the MCP enablement check to only apply to MCP prompts (not custom prompts from config) is the correct design decision. Custom prompts are configuration-based and should be available regardless of MCP status.
559-564: LGTM! Proper IPC synchronization pattern.The IPC listener correctly handles custom prompt configuration changes by reloading the prompts list. This ensures the UI stays synchronized with configuration updates made in the Settings window.
src/renderer/src/components/chat-input/composables/useContextLength.ts (3)
2-6: LGTM! Proper reactive type support.The addition of
unrefandMaybeRefimports correctly enables the composable to handle both static values and reactive refs forcontextLength.
14-14: Good API flexibility with MaybeRef.Changing
contextLengthtoMaybeRef<number | undefined>allows callers to pass either a plain number or a reactive ref, providing better flexibility for reactive context length updates.
34-35: Consistent unref usage throughout.The
unref()calls properly unwrap theMaybeRefvalue in all computed properties, ensuring correct reactivity tracking while maintaining backward compatibility with non-ref values.Also applies to: 43-44
src/renderer/src/components/chat-input/composables/useSendButtonState.ts (2)
2-3: LGTM! Consistent MaybeRef adoption.The imports and type changes align perfectly with the parallel changes in
useContextLength.ts, providing a consistent API across composables.Also applies to: 12-12
25-28: Clean pattern: extract once, use multiple times.Extracting the
unref(contextLength)result into alengthvariable avoids redundant unwrapping calls and improves code readability. The usage in both thenewThreadandchatvariants is correct.Also applies to: 37-37
src/main/events.ts
Outdated
| DEFAULT_SYSTEM_PROMPT_CHANGED: 'config:default-system-prompt-changed', // 默认系统提示词变更事件 | ||
| CUSTOM_PROMPTS_CHANGED: 'config:custom-prompts-changed' // 自定义提示词变更事件 |
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.
Use English for comments.
The inline comment on line 38 is in Chinese (中文), but the coding guidelines require all comments to be in English.
As per coding guidelines:
- DEFAULT_SYSTEM_PROMPT_CHANGED: 'config:default-system-prompt-changed', // 默认系统提示词变更事件
+ DEFAULT_SYSTEM_PROMPT_CHANGED: 'config:default-system-prompt-changed', // Default system prompt changed eventThe new CUSTOM_PROMPTS_CHANGED event key follows proper naming conventions and integrates well with the event system.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| DEFAULT_SYSTEM_PROMPT_CHANGED: 'config:default-system-prompt-changed', // 默认系统提示词变更事件 | |
| CUSTOM_PROMPTS_CHANGED: 'config:custom-prompts-changed' // 自定义提示词变更事件 | |
| DEFAULT_SYSTEM_PROMPT_CHANGED: 'config:default-system-prompt-changed', // Default system prompt changed event | |
| CUSTOM_PROMPTS_CHANGED: 'config:custom-prompts-changed' // 自定义提示词变更事件 |
🤖 Prompt for AI Agents
In src/main/events.ts around lines 38 to 39, the inline comment for
DEFAULT_SYSTEM_PROMPT_CHANGED is written in Chinese; update that comment to
English to comply with coding guidelines (e.g., change "默认系统提示词变更事件" to "Default
system prompt changed event") and keep the existing English comment for
CUSTOM_PROMPTS_CHANGED unchanged.
Summary by CodeRabbit
New Features
Improvements