-
Notifications
You must be signed in to change notification settings - Fork 614
fix: deeplink one click #1138
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
fix: deeplink one click #1138
Conversation
WalkthroughThis PR adds startup deeplink handling to the application by detecting deeplinks (deepchat://) during cold start and subsequent app instances, persisting MCP installation configurations to localStorage, and enabling renderers to consume these configurations during initialization. The changes span the main process, presenter layer, and renderer components. Changes
Sequence Diagram(s)sequenceDiagram
participant Main as Main Process
participant Presenter as DeeplinkPresenter
participant WM as Window Manager
participant LS as localStorage
participant Settings as Settings Renderer
participant Shell as Shell Renderer
rect rgb(200, 220, 250)
Note over Main,Shell: Cold Start with MCP Deeplink
Main->>Main: Parse deeplink from env/args
Main->>Presenter: checkStartupDeepLink()
Presenter->>LS: Save pending-mcp-install
Presenter->>Presenter: Build MCP config
Presenter->>WM: waitForFirstShellWindow()
WM-->>Presenter: Shell window ready
Presenter->>LS: saveMcpConfigToShellWindow()
Shell->>Shell: onMounted: read pending-mcp-install
Shell->>LS: Get MCP config from localStorage
Shell->>Shell: Enable MCP, cache config
Shell->>Shell: Navigate to settings-mcp
end
rect rgb(220, 250, 200)
Note over Main,Settings: Running App with MCP Deeplink
Main->>Presenter: handleDeepLink (MCP install)
Presenter->>Presenter: Detect hasWindows = true
Presenter->>WM: createSettingsWindow()
WM-->>Presenter: Settings window created
Presenter->>LS: saveMcpConfigToSettingsWindow()
Settings->>Settings: onMounted: read pending-mcp-install
Settings->>LS: Get MCP config from localStorage
Settings->>Settings: Enable MCP, cache config
Settings->>Settings: Navigate to settings-mcp
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ 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: 5
🧹 Nitpick comments (7)
src/main/index.ts (1)
30-32: Simplify the redundant regex pattern.The condition is overly complex.
arg.startsWith('deepchat://')will match the same cases asarg.includes('deepchat://')for a valid deeplink. Thearg.match(/^deepchat:/)is also redundant whenstartsWithis used.const deepLinkArg = process.argv.find((arg) => { - return arg.startsWith('deepchat://') || arg.includes('deepchat://') || arg.match(/^deepchat:/) + return arg.startsWith('deepchat://') })src/main/presenter/deeplinkPresenter/index.ts (1)
468-494: Consider adding an early return if no valid MCP servers were parsed.If all server configurations fail validation,
completeMcpConfig.mcpServerswill be empty but the code still creates windows and stores the empty config to localStorage. This could lead to confusing user experience.completeMcpConfig.mcpServers[serverName] = finalConfig } + // Check if any valid servers were processed + if (Object.keys(completeMcpConfig.mcpServers).length === 0) { + console.warn('No valid MCP servers found in deeplink configuration') + return + } + if (hasWindows) {src/renderer/shell/App.vue (1)
47-56: Consider using the centralizednavigateToMcpSettingshelper.This navigation logic duplicates the logic in
useMcpInstallDeeplinkHandlerfromstoreInitializer.ts. Consider extracting and reusing the navigation helper to maintain consistency and reduce duplication.Alternatively, export
navigateToMcpSettingsfromstoreInitializer.tsand use it here:import { navigateToMcpSettings } from '@/lib/storeInitializer' // Then in onMounted: await navigateToMcpSettings(router)src/renderer/src/lib/storeInitializer.ts (2)
57-65: Redundant route check after navigation to settings.At line 61,
router.hasRoute('settings-mcp')is checked again, but ifhasSettingsMcpRoutewas false at line 42, it will still be false here since route definitions don't change at runtime. This check will never pass.if (hasSettingsRootRoute) { if (currentRoute.name !== 'settings') { await router.push({ name: 'settings' }) } - if (router.hasRoute('settings-mcp')) { - await router.push({ name: 'settings-mcp' }) - } + // settings-mcp route doesn't exist (checked above), just stay on settings return }
38-73: Consider exportingnavigateToMcpSettingsfor reuse.This helper centralizes MCP settings navigation logic. Since similar navigation is needed in
shell/App.vue, consider exporting this function (with router as a parameter) to avoid duplication.- const navigateToMcpSettings = async () => { + const navigateToMcpSettings = async (router: ReturnType<typeof useRouter>) => { await router.isReady() // ... rest of implementation } +// Export for use in other components +export { navigateToMcpSettings }src/renderer/settings/App.vue (2)
123-151: Consider consolidating the twoonMountedhooks for clarity.The file now has two separate
onMountedhooks (lines 123-151 and 262-319). While valid in Vue 3 Composition API, consolidating them into a single hook would improve readability and make the initialization flow easier to follow.Also applies to: 262-319
299-299: Avoid double stringification.The config is parsed from localStorage at line 286, then re-stringified here. You could pass the original
pendingMcpInstallstring directly to avoid the redundant parse-stringify cycle.- mcpStore.setMcpInstallCache(JSON.stringify(mcpConfig)) + mcpStore.setMcpInstallCache(pendingMcpInstall)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/main/index.ts(1 hunks)src/main/presenter/deeplinkPresenter/index.ts(7 hunks)src/renderer/settings/App.vue(5 hunks)src/renderer/shell/App.vue(1 hunks)src/renderer/src/lib/storeInitializer.ts(2 hunks)src/shared/types/presenters/legacy.presenters.d.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (27)
**/*.{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/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/renderer/shell/App.vuesrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.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/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.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/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.ts
**/*.{js,ts,jsx,tsx,mjs,cjs}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
Write logs and comments in English
Files:
src/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.ts
src/shared/**/*.d.ts
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Define type definitions in shared/*.d.ts files for objects exposed by the main process to the renderer process
Files:
src/shared/types/presenters/legacy.presenters.d.ts
src/**/*
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
New features should be developed in the
srcdirectory
Files:
src/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/renderer/shell/App.vuesrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.ts
src/shared/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Shared type definitions and utilities between main and renderer processes should be placed in
src/shared
Files:
src/shared/types/presenters/legacy.presenters.d.ts
src/shared/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Shared types and utilities should be placed in
src/shared/
Files:
src/shared/types/presenters/legacy.presenters.d.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/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/renderer/shell/App.vuesrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use OxLint for linting JavaScript and TypeScript files
Files:
src/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.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/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use EventBus for inter-process communication events
Files:
src/shared/types/presenters/legacy.presenters.d.tssrc/main/index.tssrc/main/presenter/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.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/index.tssrc/main/presenter/deeplinkPresenter/index.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/index.tssrc/main/presenter/deeplinkPresenter/index.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/shell/App.vuesrc/renderer/settings/App.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/shell/App.vuesrc/renderer/settings/App.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/shell/App.vuesrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.ts
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/shell/App.vuesrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.ts
src/renderer/**
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Use lowercase with dashes for directories (e.g., components/auth-wizard)
Files:
src/renderer/shell/App.vuesrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.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/shell/App.vuesrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.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/deeplinkPresenter/index.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/deeplinkPresenter/index.tssrc/renderer/src/lib/storeInitializer.ts
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/lib/storeInitializer.ts
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/lib/storeInitializer.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/lib/storeInitializer.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/lib/storeInitializer.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/lib/storeInitializer.ts
🧠 Learnings (24)
📚 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/shared/types/presenters/legacy.presenters.d.tssrc/main/presenter/deeplinkPresenter/index.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/shared/types/presenters/legacy.presenters.d.tssrc/main/presenter/deeplinkPresenter/index.ts
📚 Learning: 2025-08-28T12:01:03.917Z
Learnt from: hllshiro
Repo: ThinkInAIXYZ/deepchat PR: 803
File: src/main/presenter/trayPresenter.ts:0-0
Timestamp: 2025-08-28T12:01:03.917Z
Learning: In the DeepChat application, calling app.quit() directly will automatically trigger the LifecycleManager's shutdown handling through Electron's before-quit event interception, so explicit calls to LifecycleManager.requestShutdown() are not needed when simply quitting the application.
Applied to files:
src/main/index.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} : Utilize Vue Router for navigation and route management in Vue.js applications
Applied to files:
src/renderer/shell/App.vuesrc/renderer/src/lib/storeInitializer.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/**/*.vue : Ensure proper error handling and loading states in all UI components
Applied to files:
src/renderer/shell/App.vue
📚 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/**/*.{ts,tsx,vue} : Vue 3 app code in `src/renderer/src` should be organized into `components/`, `stores/`, `views/`, `i18n/`, `lib/` directories with shell UI in `src/renderer/shell/`
Applied to files:
src/renderer/shell/App.vue
📚 Learning: 2025-11-25T05:27:49.615Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-router-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:49.615Z
Learning: Applies to src/renderer/src/router/**/*.{ts,tsx,js,jsx} : Implement proper navigation guards for authentication and authorization in Vue Router
Applied to files:
src/renderer/shell/App.vuesrc/renderer/src/lib/storeInitializer.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/(pages|components)/**/*.vue : Implement lazy loading for routes and components
Applied to files:
src/renderer/shell/App.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 PascalCase for component names (e.g., AuthWizard.vue)
Applied to files:
src/renderer/shell/App.vue
📚 Learning: 2025-11-25T05:27:49.615Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-router-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:49.615Z
Learning: Applies to src/renderer/src/router/**/*.{ts,tsx,js,jsx} : Implement route-level code splitting for better performance in Vue Router
Applied to files:
src/renderer/shell/App.vue
📚 Learning: 2025-11-25T05:27:49.615Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-router-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:49.615Z
Learning: Applies to src/renderer/src/router/**/*.{ts,tsx,js,jsx} : Use dynamic routing for handling variable route segments in Vue Router
Applied to files:
src/renderer/shell/App.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: Use Pinia for frontend state management and Vue Router for SPA routing
Applied to files:
src/renderer/shell/App.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/mcpPresenter/**/*.ts : Register new MCP tools in `mcpPresenter/index.ts` after implementing them in `inMemoryServers/`
Applied to files:
src/main/presenter/deeplinkPresenter/index.tssrc/renderer/settings/App.vuesrc/renderer/src/lib/storeInitializer.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/main/presenter/deeplinkPresenter/index.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 : Electron main process code belongs in `src/main/` with presenters in `presenter/` (Window/Tab/Thread/Mcp/Config/LLMProvider) and `eventbus.ts` for app events
Applied to files:
src/main/presenter/deeplinkPresenter/index.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/deeplinkPresenter/index.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/main/presenter/deeplinkPresenter/index.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/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/deeplinkPresenter/index.tssrc/renderer/settings/App.vue
📚 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/**/*.ts : Use Electron's built-in APIs for file system and native dialogs instead of Node.js or custom implementations
Applied to files:
src/main/presenter/deeplinkPresenter/index.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/**/*.ts : Use EventBus from `src/main/eventbus.ts` for main-to-renderer communication, broadcasting events via `mainWindow.webContents.send()`
Applied to files:
src/main/presenter/deeplinkPresenter/index.ts
📚 Learning: 2025-11-25T05:27:26.656Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T05:27:26.656Z
Learning: Applies to src/main/**/*.{js,ts} : Main process code for Electron should be placed in `src/main`
Applied to files:
src/main/presenter/deeplinkPresenter/index.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/settings/App.vue
📚 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: Implement proper error handling and logging for debugging in Electron applications
Applied to files:
src/renderer/settings/App.vue
📚 Learning: 2025-11-25T05:27:49.615Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-router-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:49.615Z
Learning: Applies to src/renderer/src/router/**/*.{vue,ts,tsx,js,jsx} : Use named routes for easier navigation and maintenance in Vue Router
Applied to files:
src/renderer/src/lib/storeInitializer.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 (8)
src/shared/types/presenters/legacy.presenters.d.ts (1)
192-192: LGTM!The new
createSettingsWindowmethod signature is consistent with the existing window creation patterns in the interface (e.g.,createShellWindowalso returnsPromise<number | null>).src/main/index.ts (1)
23-77: Approve the defensive deeplink capture logic.The multiple capture points (command line, environment variables,
open-url, andsecond-instanceevents) with immediateprocess.env.STARTUP_DEEPLINKassignment provide robust cold-start deeplink handling across platforms. The redundancy is acceptable as defensive coding for race conditions.src/main/presenter/deeplinkPresenter/index.ts (1)
149-180: Approve startup deeplink detection with redundant fallbacks.The
checkStartupDeepLinkmethod appropriately checks both the environment variable (set by main process) and command line arguments as a fallback. The cleanup ofprocess.env.STARTUP_DEEPLINK(line 161) prevents duplicate processing.src/renderer/shell/App.vue (1)
22-65: Good error handling implementation.The try-catch block properly handles errors, clears corrupted localStorage data, and logs meaningful error messages. The immediate removal of
pending-mcp-installafter reading (line 29) prevents reprocessing on subsequent mounts.src/renderer/settings/App.vue (4)
76-77: LGTM!Imports for MCP store and deeplink handler follow existing patterns and use appropriate path aliases.
94-97: Early listener registration is acceptable for IPC race prevention.Calling
setupMcpDeeplink()synchronously at module scope (beforeonMounted) is unconventional but justified to catch IPC events that may arrive before the component is fully mounted. Ensure the handler's internals are safe to execute before Vue's reactivity is fully initialized for this component.
325-333: LGTM!Proper cleanup of the MCP deeplink handler in
onBeforeUnmountmatches the setup pattern and prevents memory leaks.
302-310: Based on my verification, I can now provide the rewritten review comment:The current implementation correctly triggers MCP installation via store reactivity, not route navigation.
When
setMcpInstallCache()is called beforerouter.replace(), the watch in McpServers.vue (withimmediate: true) detects the store change and opens the dialog. Whether already onsettings-mcpor navigating to it, the cache change triggers the watch callback. Therouter.replace()call serves to refresh the route state, not to initiate the dialog—this is already handled by the store mechanism. No modification needed.
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.