-
Notifications
You must be signed in to change notification settings - Fork 625
fix: restore MCP permission approval flow #1064
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
WalkthroughThreadPresenter and promptBuilder were extended to manage MCP tool permission flows: creating permission blocks with extra metadata, handling grant/deny responses, synchronizing generating state (including pending tool calls), resuming or continuing agent generation, and adding post-tool-execution context construction utilities. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Presenter as ThreadPresenter
participant State as GeneratingState
participant MCP as MCP Service
participant Tools as Tool Executor
User->>Presenter: Agent emits tool_call requiring permission
Presenter->>State: append permission block (extra: needsUserAction, permissionType, serverName, toolName, permissionRequest)
Presenter->>User: emit permission-request UI
alt User grants
User->>Presenter: handlePermissionResponse(messageId, toolCallId, granted=true,...)
Presenter->>State: update block status = "granted", clear needsUserAction, persist grantedPermissions
Presenter->>MCP: waitForMcpServiceReady(serverName)
Presenter->>Presenter: restartAgentLoopAfterPermission(messageId)
Presenter->>Tools: load/execute tool (post-permission)
Tools->>Presenter: emit tool_call event + response
Presenter->>Presenter: resumeStreamCompletion(conversationId,messageId)
else User denies
User->>Presenter: handlePermissionResponse(messageId, toolCallId, granted=false,...)
Presenter->>State: update block status = "denied", clear needsUserAction, clear pendingToolCall
Presenter->>Presenter: continueAfterPermissionDenied(messageId)
Presenter->>State: continue generation with denial/error context (buildPostToolExecutionContext)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (10)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Files:
src/{main,renderer}/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Files:
src/main/**/*.ts📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
Files:
src/main/**/*.{ts,js,tsx,jsx}📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Files:
**/*.{ts,tsx,js,vue}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,vue}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/main/presenter/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx,vue,css,scss,md,json,yml,yaml}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx,vue}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (3)📚 Learning: 2025-09-06T03:07:23.817ZApplied to files:
📚 Learning: 2025-09-06T03:07:23.817ZApplied to files:
📚 Learning: 2025-07-21T01:46:52.880ZApplied to files:
🧬 Code graph analysis (1)src/main/presenter/threadPresenter/index.ts (8)
🔇 Additional comments (7)
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/main/presenter/threadPresenter/index.ts (4)
2837-2842: On grant failure, re‑enable user action and surface a retryable state.Currently sets status='error' but leaves needsUserAction=false, blocking recovery.
} catch (permissionError) { console.error(`[ThreadPresenter] Failed to grant permission:`, permissionError) // 权限授予失败,将状态更新为错误 permissionBlock.status = 'error' + if (permissionBlock.extra) { + permissionBlock.extra.needsUserAction = true + } + permissionBlock.content = + 'Failed to grant permission. Please retry or check MCP server settings.' await this.messageManager.editMessage(messageId, JSON.stringify(content)) throw permissionError }
3021-3028: Preserve context when resuming without in‑memory state.Fallback calls startStreamCompletion without messageId; pass messageId to ensure the correct tool-call context is reconstructed.
- await this.startStreamCompletion(conversationId) + await this.startStreamCompletion(conversationId, messageId)
1239-1239: Avoid logging entire conversation objects (PII/compliance).This can leak user data in logs. Log IDs/flags only.
- console.log('sendMessage', conversation) + console.debug('[ThreadPresenter] sendMessage', { conversationId, hasSettings: !!conversation.settings })
1218-1224: Critical: clearContext deletes all messages globally.Calling
sqlitePresenter.deleteAllMessages()has no conversation filtering and wipes the entire messages table. UsemessageManager.clearAllMessages(conversationId)instead, which deletes only messages in the specified conversation.async clearContext(conversationId: string): Promise<void> { await this.sqlitePresenter.runTransaction(async () => { const conversation = await this.getConversation(conversationId) if (conversation) { - await this.sqlitePresenter.deleteAllMessages() + await this.messageManager.clearAllMessages(conversationId) } }) }
🧹 Nitpick comments (5)
src/main/presenter/threadPresenter/index.ts (5)
388-391: Type the permission extra payload.Record<string, ...> hides structure and weakens TS safety. Define a PermissionExtra type and use it.
+type PermissionExtra = { + needsUserAction: boolean + permissionType: 'read' | 'write' | 'all' + serverName?: string + toolName?: string + permissionRequest?: unknown + grantedPermissions?: 'read' | 'write' | 'all' +} - const extra: Record<string, string | number | object[] | boolean> = { + const extra: PermissionExtra = { needsUserAction: true, permissionType }Also applies to: 425-427
403-405: Avoid JSON.stringify for permissionRequest; keep sanitized, structured data.Stringifying drops type safety and may bloat storage. Store a minimal, sanitized object instead.
- if (permission_request) { - extra.permissionRequest = JSON.stringify(permission_request) - } + if (permission_request) { + // keep only non-sensitive fields needed by renderer + const { permissionType, scope, reason } = permission_request as any + extra.permissionRequest = { permissionType, scope, reason } + }
3144-3186: Make waitForMcpServiceReady return boolean and branch on timeout.Void-return resolves even on timeout; caller can’t decide whether to proceed or warn.
- private async waitForMcpServiceReady( - serverName: string, - maxWaitTime: number = 3000 - ): Promise<void> { + private async waitForMcpServiceReady( + serverName: string, + maxWaitTime: number = 3000 + ): Promise<boolean> { ... - return new Promise((resolve) => { + return new Promise((resolve) => { ... - resolve() + resolve(true) ... - resolve() // 超时也继续,避免阻塞 + resolve(false) // timeout ... - resolve() // 出错也继续,避免阻塞 + resolve(false) // errorAnd handle at call site:
- await this.waitForMcpServiceReady(serverName) + const ready = await this.waitForMcpServiceReady(serverName) + if (!ready) { + console.warn(`[ThreadPresenter] MCP service ${serverName} not confirmed ready; continuing optimistically`) + }Also applies to: 2828-2836
77-88: Unify logs/comments to English and adopt structured logging.Multiple logs/comments are in Chinese and use console.* directly. Guidelines require English logs and structured logging with levels and context.
- Replace console.* with a logger (INFO/WARN/ERROR/DEBUG, timestamp, context).
- Convert comments and user-facing log text to English.
As per coding guidelinesAlso applies to: 282-339, 850-857, 1294-1298, 1503-1514, 1591-1600, 1769-1772
3189-3215: Pending tool-call finder: OK; consider including serverName.Works, but including server_name would help downstream context if needed by promptBuilder.
Return { id, name, params, serverName?: string } for completeness if available.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/presenter/threadPresenter/index.ts(5 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/main/presenter/threadPresenter/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/main/presenter/threadPresenter/index.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/threadPresenter/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别
Files:
src/main/presenter/threadPresenter/index.ts
src/main/**/*.{ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
主进程代码放在
src/main
Files:
src/main/presenter/threadPresenter/index.ts
**/*.{ts,tsx,js,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/main/presenter/threadPresenter/index.ts
**/*.{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/main/presenter/threadPresenter/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/threadPresenter/index.ts
**/*.{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/main/presenter/threadPresenter/index.ts
**/*.{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/main/presenter/threadPresenter/index.ts
🧠 Learnings (1)
📚 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 : The main Agent loop should buffer text content, handle tool call events, format tool results for the next LLM call, and manage conversation continuation logic.
Applied to files:
src/main/presenter/threadPresenter/index.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 (2)
src/main/presenter/threadPresenter/index.ts (2)
437-447: Granted flow OK; ensure extra.grantedPermissions matches union.Looks correct. After adopting PermissionExtra, this remains type‑safe.
Please verify the renderer uses status === 'granted' and extra.grantedPermissions to show the approved state.
457-461: Denied flow OK.Block status and needsUserAction reset are correct.
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/components/message/MessageBlockPermissionRequest.vue (2)
182-206: Add 'success' handling to icons/styles for consistency.Currently 'success' shows a clock icon with muted color. Treat it like 'granted'.
const getStatusIcon = () => { switch (props.block.status) { case 'granted': return 'lucide:check' + case 'success': + return 'lucide:check' case 'denied': return 'lucide:x' case 'error': return 'lucide:alert' default: return 'lucide:clock' } } const getStatusIconClass = () => { switch (props.block.status) { case 'granted': - return 'bg-green-500 rounded-full text-white p-0.5 dark:bg-green-800' + return 'bg-green-500 rounded-full text-white p-0.5 dark:bg-green-800' + case 'success': + return 'bg-green-500 rounded-full text-white p-0.5 dark:bg-green-800' case 'denied': return 'text-white p-0.5 bg-red-500 rounded-full dark:bg-red-800' case 'error': return 'text-white p-0.5 bg-red-500 rounded-full dark:bg-red-800' default: return 'text-muted-foreground' } }
208-220: Fix i18n for status text and add missing i18n keys; handle 'success' status consistently across text, icons, and styling.Three issues found:
Hardcoded strings in
getStatusText()violate i18n rules:
- Line 217:
'Error'→ use i18n key- Line 219:
'Pending'→ use i18n keyMissing i18n keys in
components.json:
messageBlockPermissionRequest.error(needed)messageBlockPermissionRequest.pending(needed)Inconsistent 'success' status handling:
getStatusText()maps 'success' to 'granted' textgetStatusIcon()andgetStatusIconClass()lack 'success' case (fall to default clock/muted styling)- Must add
case 'success':to both icon functions to treat it like 'granted' for visual consistencyApply the suggested diff, add the missing i18n keys to
components.json, and updategetStatusIcon()andgetStatusIconClass()with:case 'success': // same as 'granted' case
♻️ Duplicate comments (1)
src/main/presenter/threadPresenter/index.ts (1)
392-396: Least‑privilege: default to 'read' and validate permissionType.Defaulting to 'write' is unsafe; validate against allowlist and fall back to 'read'.
- const permissionType = permission_request?.permissionType ?? 'write' + const requested = permission_request?.permissionType + const permissionType: 'read' | 'write' | 'all' = + requested === 'read' || requested === 'write' || requested === 'all' ? requested : 'read'
🧹 Nitpick comments (6)
src/renderer/src/components/message/MessageBlockPermissionRequest.vue (2)
6-6: Tailwind class typo: use min-h-[40px], not h-min-[40px].'h-min-[...]' is not a Tailwind utility; this likely has no effect.
- class="flex flex-col h-min-[40px] hover:bg-muted select-none cursor-pointer pt-3 overflow-hidden w-[380px] break-all shadow-sm my-2 items-start gap-3 rounded-lg border bg-card text-card-foreground" + class="flex flex-col min-h-[40px] hover:bg-muted select-none cursor-pointer pt-3 overflow-hidden w-[380px] break-all shadow-sm my-2 items-start gap-3 rounded-lg border bg-card text-card-foreground"- class="flex flex-col h-min-[40px] overflow-hidden w-[380px] break-all shadow-sm my-2 rounded-lg border bg-card text-card-foreground p-3" + class="flex flex-col min-h-[40px] overflow-hidden w-[380px] break-all shadow-sm my-2 rounded-lg border bg-card text-card-foreground p-3"Also applies to: 32-32
152-176: Standardize comment language to English.A few inline comments are in Chinese; repo guideline asks logs/comments in English. Convert for consistency. Example:
- // 处理 undefined content + // Handle undefined content - // 检查是否是 i18n key + // Check if content is an i18n key - // 回退到使用 extra 字段中的信息 + // Fallback to extra fields if JSON parse fails - // 向后兼容:直接返回原文本 + // Backward compatibility: return raw textsrc/main/presenter/threadPresenter/promptBuilder.ts (2)
317-339: collectAssistantTextBeforePermission: safe and minimal, but consider trimming whitespace.Joining without separators can fuse paragraphs; consider
parts.join('\n')to preserve readability.
307-311: Hardcoded Chinese in tool execution context should be parameterized for localization.The Chinese instruction text at line 307 will bias LLM responses regardless of user locale. While your codebase already supports i18n (with
getContextMenuLabels,getErrorMessageLabelspatterns in other presenters),buildPostToolExecutionContextcurrently has no access to locale information.This requires refactoring the function signature to accept locale (either directly or via
conversation.settings), similar to howthreadPresenteraccessesconfigPresenter.getLanguage(). Note: an identical hardcoded string also appears insrc/main/presenter/llmProviderPresenter/index.ts:1268.src/main/presenter/threadPresenter/index.ts (2)
3062-3207: Continue-after-deny flow is robust; minor polish possible.Flow sends a tool 'end' with failure reason, rebuilds context via
buildPostToolExecutionContext, and resumes streaming. Consider including a machine-readable error code intool_call_response_rawif upstream supports it, to let renderers style the failure.
245-258: Standardize logs/comments in English for consistency.Several logs/comments are Chinese. Repo guideline: logs/comments should be in English. Convert in touched areas going forward.
Also applies to: 874-889, 1363-1376
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/presenter/threadPresenter/index.ts(13 hunks)src/main/presenter/threadPresenter/promptBuilder.ts(4 hunks)src/main/presenter/threadPresenter/types.ts(2 hunks)src/renderer/src/components/message/MessageBlockPermissionRequest.vue(1 hunks)
🧰 Additional context used
📓 Path-based instructions (22)
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/components/message/MessageBlockPermissionRequest.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
渲染进程代码放在
src/renderer
Files:
src/renderer/src/components/message/MessageBlockPermissionRequest.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/components/message/MessageBlockPermissionRequest.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/message/MessageBlockPermissionRequest.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/components/message/MessageBlockPermissionRequest.vue
src/renderer/**/*.{vue,ts}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Implement lazy loading for routes and components.
Files:
src/renderer/src/components/message/MessageBlockPermissionRequest.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/components/message/MessageBlockPermissionRequest.vue
**/*.{ts,tsx,js,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/renderer/src/components/message/MessageBlockPermissionRequest.vuesrc/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
**/*.{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/components/message/MessageBlockPermissionRequest.vuesrc/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
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/message/MessageBlockPermissionRequest.vue
src/renderer/src/components/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Organize UI components by feature within src/renderer/src/
Files:
src/renderer/src/components/message/MessageBlockPermissionRequest.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/components/message/MessageBlockPermissionRequest.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/components/message/MessageBlockPermissionRequest.vue
**/*.{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/components/message/MessageBlockPermissionRequest.vuesrc/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
**/*.{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/components/message/MessageBlockPermissionRequest.vuesrc/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
src/renderer/**/*.vue
📄 CodeRabbit inference engine (AGENTS.md)
Name Vue component files in PascalCase (e.g., ChatInput.vue)
Files:
src/renderer/src/components/message/MessageBlockPermissionRequest.vue
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/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/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.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/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别
Files:
src/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
src/main/**/*.{ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
主进程代码放在
src/main
Files:
src/main/presenter/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/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/threadPresenter/types.tssrc/main/presenter/threadPresenter/promptBuilder.tssrc/main/presenter/threadPresenter/index.ts
🧠 Learnings (4)
📚 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/main/presenter/threadPresenter/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/main/presenter/threadPresenter/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 : The main Agent loop should buffer text content, handle tool call events, format tool results for the next LLM call, and manage conversation continuation logic.
Applied to files:
src/main/presenter/threadPresenter/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/main/presenter/threadPresenter/index.ts
🧬 Code graph analysis (3)
src/main/presenter/threadPresenter/types.ts (1)
src/main/presenter/threadPresenter/promptBuilder.ts (1)
PendingToolCall(23-30)
src/main/presenter/threadPresenter/promptBuilder.ts (3)
src/shared/types/presenters/legacy.presenters.d.ts (3)
CONVERSATION(746-755)ModelConfig(132-150)ChatMessage(1376-1376)src/shared/chat.d.ts (1)
AssistantMessage(39-42)src/main/presenter/threadPresenter/messageContent.ts (1)
buildUserMessageContext(155-164)
src/main/presenter/threadPresenter/index.ts (7)
src/shared/chat.d.ts (2)
AssistantMessage(39-42)AssistantMessageBlock(84-138)src/main/events.ts (1)
STREAM_EVENTS(59-63)src/main/presenter/threadPresenter/promptBuilder.ts (1)
buildPostToolExecutionContext(234-315)src/main/presenter/threadPresenter/types.ts (1)
GeneratingMessageState(4-36)src/shared/types/presenters/legacy.presenters.d.ts (2)
MCPToolDefinition(1146-1162)MCPToolResponse(1178-1207)src/shared/types/core/mcp.ts (2)
MCPToolDefinition(3-19)MCPToolResponse(58-71)src/main/presenter/index.ts (1)
presenter(223-223)
⏰ 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/types.ts (1)
2-2: Type-only import for PendingToolCall is appropriate; no runtime cycle.Using
import typeprevents runtime deps; addingpendingToolCall?: PendingToolCallcleanly extends state without side effects. LGTM.Also applies to: 15-15
src/main/presenter/threadPresenter/promptBuilder.ts (1)
23-30: Exported PendingToolCall shape looks good.The added server metadata fields enable richer UI/state sync later. No issues.
src/main/presenter/threadPresenter/index.ts (1)
2834-2879: Good: in-memory state sync prevents DB overwrite after permission.Copying the updated permission block back into
generatingState.message.contentavoids stale overwrites. LGTM.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_6901e3a46178832c81e9b8b20b870860
Summary by CodeRabbit
New Features
Bug Fixes / Improvements