-
Notifications
You must be signed in to change notification settings - Fork 625
feat: refactor download functionality and improve artifact handling #1060
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
WalkthroughConsolidates Blob-download logic into a shared utility, switches message-leave animations to CSS-variable driven transitions, tightens artifact-rendering guards, centralizes translation fallbacks, and hardens active-thread usage across chat store functions. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as UI component
participant Store as chat/store or export caller
participant Lib as downloadBlob (lib/download.ts)
participant Browser as Browser DOM
UI->>Store: request export (generate Blob)
Store->>Lib: downloadBlob(blob, filename)
Lib->>Browser: createObjectURL(blob)
Lib->>Browser: create <a> (href, download), append to DOM
Lib->>Browser: programmatic click
Browser-->>Lib: download starts
Lib->>Browser: remove <a>, revokeObjectURL
Lib-->>Store: return (void)
Store-->>UI: export completed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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)
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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
src/renderer/src/components/message/MessageItemAssistant.vue (1)
259-259: Use English for console logs.The console error message contains Chinese text, which violates the coding guideline requiring English for all logs and comments.
As per coding guidelines.
Apply this diff to use English:
- console.error('创建对话分支失败:', error) + console.error('Failed to fork conversation:', error)src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue (2)
464-470: Replace hardcoded Chinese text with i18n keys.Lines 468 contains hardcoded Chinese text
"错误: ${errorMessage}"which violates the coding guideline that all user-facing strings must use i18n keys via vue-i18n.As per coding guidelines
Apply this diff to use i18n:
} catch (error) { const errorMessage = error instanceof Error ? error.message : String(error) toast({ title: t('promptSetting.importFailed'), - description: `错误: ${errorMessage}`, + description: t('promptSetting.importError', { error: errorMessage }), variant: 'destructive' }) }
474-480: Replace hardcoded Chinese text with i18n keys.Line 477 contains hardcoded Chinese text
"文件读取失败"which violates the coding guideline that all user-facing strings must use i18n keys via vue-i18n.As per coding guidelines
Apply this diff to use i18n:
reader.onerror = () => { toast({ title: t('promptSetting.importFailed'), - description: '文件读取失败', + description: t('promptSetting.fileReadError'), variant: 'destructive' }) }src/renderer/src/stores/chat.ts (2)
340-361: Inconsistent usage of local variable.The function correctly captures
activeThreadon line 340 and uses it on lines 343, 344, and 347. However, line 354 still callsgetActiveThreadId()!instead of using the localactiveThreadvariable.Apply this diff to use the local variable consistently:
getGeneratingMessagesCache().set(aiResponseMessage.id, { message: aiResponseMessage, - threadId: getActiveThreadId()! + threadId: activeThread })
698-724: Pre-existing logic error: Self-comparison always evaluates to true.Lines 709 and 718 both contain
if (getActiveThreadId() === getActiveThreadId()), which always evaluates to true. Based on the surrounding context and similar patterns elsewhere in the code (e.g., line 667), these should likely be:if (cached.threadId === getActiveThreadId())Note: This is a pre-existing issue, not introduced by the current PR.
Apply this diff to fix the logic:
if (mainMessage) { const enrichedMainMessage = await enrichMessageWithExtra(mainMessage) // 如果是当前激活的会话,更新显示 - if (getActiveThreadId() === getActiveThreadId()) { + if (cached.threadId === getActiveThreadId()) { const mainMsgIndex = getMessages().findIndex((m) => m.id === mainMessage.id) if (mainMsgIndex !== -1) { getMessages()[mainMsgIndex] = enrichedMainMessage as AssistantMessage | UserMessage } } } } else { // 如果是当前激活的会话,更新显示 - if (getActiveThreadId() === getActiveThreadId()) { + if (cached.threadId === getActiveThreadId()) { const msgIndex = getMessages().findIndex((m) => m.id === msg.eventId) if (msgIndex !== -1) { getMessages()[msgIndex] = enrichedMessage as AssistantMessage | UserMessage } } }
🧹 Nitpick comments (2)
src/renderer/src/components/message/MessageBlockToolCall.vue (1)
65-85: Consider externalizing fallback translations.The
keyMapobject contains hardcoded Chinese text as fallback translations. While this is a safety mechanism for when i18n is not initialized, it still violates the guideline that all user-facing strings should use i18n keys. Consider one of these approaches:
- Load fallback translations from a JSON file
- Use English fallbacks (more universally understood)
- Ensure i18n is always initialized before components render
As per coding guidelines
src/renderer/src/components/message/MessageBlockImage.vue (1)
69-85: Consider externalizing fallback translations.The
keyMapobject contains hardcoded Chinese text as fallback translations. This mirrors the pattern inMessageBlockToolCall.vue. While this is a safety mechanism for when i18n is not initialized, consider the same alternatives mentioned for that file:
- Load fallback translations from a JSON file
- Use English fallbacks (more universally understood)
- Ensure i18n is always initialized before components render
As per coding guidelines
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue(2 hunks)src/renderer/src/components/message/MessageActionButtons.vue(1 hunks)src/renderer/src/components/message/MessageBlockContent.vue(1 hunks)src/renderer/src/components/message/MessageBlockImage.vue(1 hunks)src/renderer/src/components/message/MessageBlockToolCall.vue(1 hunks)src/renderer/src/components/message/MessageItemAssistant.vue(1 hunks)src/renderer/src/components/message/MessageMinimap.vue(1 hunks)src/renderer/src/composables/useArtifactExport.ts(1 hunks)src/renderer/src/lib/download.ts(1 hunks)src/renderer/src/stores/chat.ts(8 hunks)
🧰 Additional context used
📓 Path-based instructions (20)
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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
src/renderer/**/*.{vue,ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
渲染进程代码放在
src/renderer
Files:
src/renderer/src/components/message/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
src/renderer/src/**/*.vue
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
Use scoped styles to prevent CSS conflicts between components
Files:
src/renderer/src/components/message/MessageBlockToolCall.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
src/renderer/**/*.{ts,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
**/*.{ts,tsx,js,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/renderer/src/components/message/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.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/MessageBlockToolCall.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.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/MessageBlockToolCall.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.ts
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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.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/renderer/src/components/message/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.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/MessageBlockToolCall.vuesrc/renderer/src/composables/useArtifactExport.tssrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vuesrc/renderer/src/stores/chat.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/MessageBlockToolCall.vuesrc/renderer/settings/components/prompt/CustomPromptSettingsSection.vuesrc/renderer/src/components/message/MessageActionButtons.vuesrc/renderer/src/components/message/MessageMinimap.vuesrc/renderer/src/components/message/MessageBlockContent.vuesrc/renderer/src/components/message/MessageItemAssistant.vuesrc/renderer/src/components/message/MessageBlockImage.vue
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/renderer/src/composables/useArtifactExport.tssrc/renderer/src/lib/download.tssrc/renderer/src/stores/chat.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/composables/useArtifactExport.tssrc/renderer/src/lib/download.tssrc/renderer/src/stores/chat.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别
Files:
src/renderer/src/composables/useArtifactExport.tssrc/renderer/src/lib/download.tssrc/renderer/src/stores/chat.ts
src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/pinia-best-practices.mdc)
src/renderer/src/stores/**/*.{vue,ts,tsx,js,jsx}: Use modules to organize related state and actions
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/chat.ts
🧠 Learnings (1)
📚 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/message/MessageBlockImage.vue
🧬 Code graph analysis (1)
src/renderer/src/stores/chat.ts (1)
src/renderer/src/lib/download.ts (1)
downloadBlob(4-13)
🔇 Additional comments (12)
src/renderer/src/components/message/MessageItemAssistant.vue (1)
28-28: LGTM! Good defensive guard for empty reasoning content.The addition of
&& block.contentprevents rendering MessageBlockThink when the content is empty, null, or undefined. This aligns with the PR's goal of improving artifact handling and prevents potential UI issues from empty blocks.src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue (1)
176-176: LGTM! Good refactoring to use centralized download utility.The import and usage of
downloadBlobfrom the shared utility correctly replaces the manual Blob URL download flow. This improves maintainability and consistency across the codebase.Also applies to: 377-397
src/renderer/src/composables/useArtifactExport.ts (1)
2-2: LGTM! Excellent refactoring to use centralized download utility.The migration to use
downloadBlobfrom the shared utility removes code duplication and improves maintainability. The export logic for both SVG and code exports is correct and follows the established pattern.Also applies to: 59-93
src/renderer/src/components/message/MessageActionButtons.vue (1)
54-95: LGTM! Excellent refactoring to CSS-driven animations.The refactoring from inline style manipulation to CSS variables and a dedicated class (
message-action-leaving) is a significant improvement:
- Reduces layout thrashing by minimizing direct style mutations
- Centralizes animation behavior in CSS
- Improves maintainability and performance
- Uses
void element.offsetWidthto force reflow appropriatelyThis follows best practices for Vue transitions and modern web performance optimization.
src/renderer/src/components/message/MessageBlockContent.vue (1)
52-100: LGTM! Excellent refactoring of artifact handling logic.The refactoring significantly improves the code:
- Clearer guards: Early
continuefor non-artifact parts reduces nesting- Destructuring: Makes the code more readable by extracting artifact properties upfront
- Centralized status handling: Status computation based on
block.statusis now deterministic and easy to follow- Reduced branching: The logic flow is more linear and easier to reason about
This refactoring makes the artifact update workflow more robust and maintainable, which complements the centralized download/export utilities introduced in this PR.
src/renderer/src/stores/chat.ts (7)
18-18: LGTM: Centralized download utility import.The import of
downloadBlobaligns with the PR's objective to consolidate download functionality into a shared module.
185-191: LGTM: Optimized by moving computation after guard.Moving the
tabIdassignment to line 187 after the early return check on line 186 avoids unnecessary computation when there's no active thread.
242-244: LGTM: Reduced repeated function calls in loop.Capturing
activeThreadonce on line 242 and using it in the loop comparison on line 244 avoids repeatedgetActiveThreadId()calls, improving performance.
365-393: LGTM: Consistent use of local activeThread variable.The function properly captures
activeThreadonce on line 366 and uses it consistently throughout for API calls on lines 371 and 378.
809-835: LGTM: Consistent use of local activeThread variable.The function properly captures
activeThreadonce on line 810 and uses it consistently on lines 813 and 816, reducing repeated function calls.
837-846: LGTM: Consistent use of local activeThread variable.The function properly captures
activeThreadonce on line 838 and uses it consistently on line 841.
1306-1316: LGTM: Centralized download logic.The use of
downloadBlobon line 1313 successfully consolidates download functionality into a shared utility, eliminating inline DOM manipulation and improving maintainability.
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 (1)
src/renderer/src/components/message/MessageMinimap.vue (1)
29-29: Use i18n for the aria-label instead of hardcoded text.The
aria-labelcontains hardcoded English text, which violates the coding guidelines requiring all user-facing strings to use i18n keys via vue-i18n. Accessibility labels are exposed to screen readers and should be translatable.As per coding guidelines.
Consider refactoring to use a translation key, for example:
- :aria-label="bar.ariaLabel" + :aria-label="$t('minimap.messageLabel', { index: bars.indexOf(bar) + 1, role: bar.role })"Then add the corresponding key to your i18n locale files:
{ "minimap": { "messageLabel": "Message {index}, {role}" } }
♻️ Duplicate comments (1)
src/renderer/src/components/message/MessageMinimap.vue (1)
11-11: Revert toz-[2]- thez-2utility is not available.This change from
z-[2]toz-2breaks the z-index styling. As confirmed in previous review comments, the project's Tailwind configuration does not include az-2utility (only z-0, z-10, z-20, etc. are available). The arbitrary valuez-[2]was correct and should be restored.Apply this diff to fix:
- class="flex flex-col items-end gap-1 w-full relative z-2" + class="flex flex-col items-end gap-1 w-full relative z-[2]"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/renderer/src/components/message/MessageMinimap.vue(1 hunks)src/renderer/src/lib/download.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (19)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/renderer/src/lib/download.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/lib/download.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别
Files:
src/renderer/src/lib/download.ts
src/renderer/src/**/*
📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)
src/renderer/src/**/*: All user-facing strings must use i18n keys (avoid hardcoded user-visible text in code)
Use the 'vue-i18n' framework for all internationalization in the renderer
Ensure all user-visible text in the renderer uses the translation system
Files:
src/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
渲染进程代码放在
src/renderer
Files:
src/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vue
src/renderer/**/*.{vue,ts}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Implement lazy loading for routes and components.
Files:
src/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.vue
**/*.{ts,tsx,js,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/renderer/src/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/lib/download.tssrc/renderer/src/components/message/MessageMinimap.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/MessageMinimap.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/message/MessageMinimap.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/MessageMinimap.vue
src/renderer/**/*.vue
📄 CodeRabbit inference engine (AGENTS.md)
Name Vue component files in PascalCase (e.g., ChatInput.vue)
Files:
src/renderer/src/components/message/MessageMinimap.vue
🔇 Additional comments (1)
src/renderer/src/components/message/MessageMinimap.vue (1)
3-3: Good refactor to standard Tailwind utility.The change from
rounded-[6px]torounded-mdis semantically equivalent (both are 6px) and improves consistency by using a standard Tailwind class instead of an arbitrary value.
Summary by CodeRabbit
Bug Fixes
Improvements
Chores