Skip to content

Conversation

@Simon-He95
Copy link
Collaborator

@Simon-He95 Simon-He95 commented Oct 28, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Prevented empty reasoning blocks from rendering.
  • Improvements

    • Smoother message leave animations via CSS-driven transitions.
    • Streamlined file export/download using a unified download utility.
    • More robust artifact content sync and status handling during streaming.
    • Centralized translation fallbacks for image/tool UI labels.
    • Minor minimap styling and stacking adjustments.
    • Reduced repeated lookups by capturing active thread context.
  • Chores

    • Added a dev tooling dependency for i18n checks.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Consolidates 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

Cohort / File(s) Summary
Download Utility Consolidation
src/renderer/src/lib/download.ts, src/renderer/src/composables/useArtifactExport.ts, src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue, src/renderer/src/stores/chat.ts
Add downloadBlob(blob, filename) and replace inline Blob URL + anchor download logic with downloadBlob calls.
Message Animation & Styling
src/renderer/src/components/message/MessageActionButtons.vue, src/renderer/src/components/message/MessageMinimap.vue
Replace per-element inline leave style mutations with CSS variables and .message-action-leaving class; adjust minimap classes (rounded-[6px]rounded-md, z-[2]z-2).
Artifact / Message Rendering Logic
src/renderer/src/components/message/MessageBlockContent.vue, src/renderer/src/components/message/MessageItemAssistant.vue
Simplify artifact watcher: guard non-artifact parts, destructure artifact, unify loading vs loaded handling via showArtifact / updateArtifactContent; render reasoning_content only when content exists.
Translation Key Centralization
src/renderer/src/components/message/MessageBlockImage.vue, src/renderer/src/components/message/MessageBlockToolCall.vue
Introduce keyMap fallback lookup for i18n-uninitialized states; replace inline conditional fallbacks with `keyMap[key]
Store Thread Handling & Minor Control Flow
src/renderer/src/stores/chat.ts
Early-capture activeThread to reduce repeated getActiveThreadId() calls, tighten null-checks across functions (regenerate, fork, load/save config, loadMessages), and use downloadBlob for exports.
Dev Dependency
package.json
Added devDependency @lingual/i18n-check ^0.8.6.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Extra attention:
    • src/renderer/src/lib/download.ts — ensure URL revoke and DOM cleanup are robust and error-handled.
    • src/renderer/src/components/message/MessageActionButtons.vue — verify reflow/transition behavior across browsers.
    • src/renderer/src/components/message/MessageBlockContent.vue — confirm artifact status handling and correct message/thread associations.
    • src/renderer/src/stores/chat.ts — verify early-captured activeThread doesn't introduce race conditions.

Possibly related PRs

Suggested reviewers

  • zerob13

Poem

🐰 A blob tucked neat in one small lair,
CSS flutters, transitions in the air,
Artifacts tidy, keys mapped true,
Threads held steady, downloads anew,
A rabbit hops — refactor, hooray! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: refactor download functionality and improve artifact handling" accurately captures the two primary refactoring efforts in the changeset. The download functionality refactoring is evident through the new downloadBlob utility module and its integration across multiple files (CustomPromptSettingsSection.vue, useArtifactExport.ts, and chat.ts). The artifact handling improvements are demonstrated in MessageBlockContent.vue's refactored artifact rendering logic and MessageItemAssistant.vue's enhanced guard conditions. While the PR also includes supporting changes such as CSS variable refactoring, translation key mapping, and activeThread optimization, these are secondary to the two main themes highlighted in the title. The title is concise, specific, and clearly communicates the primary changes without noise or vagueness.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 activeThread on line 340 and uses it on lines 343, 344, and 347. However, line 354 still calls getActiveThreadId()! instead of using the local activeThread variable.

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 keyMap object 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:

  1. Load fallback translations from a JSON file
  2. Use English fallbacks (more universally understood)
  3. 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 keyMap object contains hardcoded Chinese text as fallback translations. This mirrors the pattern in MessageBlockToolCall.vue. While this is a safety mechanism for when i18n is not initialized, consider the same alternatives mentioned for that file:

  1. Load fallback translations from a JSON file
  2. Use English fallbacks (more universally understood)
  3. Ensure i18n is always initialized before components render

As per coding guidelines

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d6e49d and e76fd81.

📒 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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/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.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/src/composables/useArtifactExport.ts
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/lib/download.ts
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/renderer/src/components/message/MessageBlockImage.vue
  • src/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.vue
  • src/renderer/settings/components/prompt/CustomPromptSettingsSection.vue
  • src/renderer/src/components/message/MessageActionButtons.vue
  • src/renderer/src/components/message/MessageMinimap.vue
  • src/renderer/src/components/message/MessageBlockContent.vue
  • src/renderer/src/components/message/MessageItemAssistant.vue
  • src/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.ts
  • src/renderer/src/lib/download.ts
  • src/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.ts
  • src/renderer/src/lib/download.ts
  • src/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.ts
  • src/renderer/src/lib/download.ts
  • src/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.content prevents 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 downloadBlob from 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 downloadBlob from 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:

  1. Reduces layout thrashing by minimizing direct style mutations
  2. Centralizes animation behavior in CSS
  3. Improves maintainability and performance
  4. Uses void element.offsetWidth to force reflow appropriately

This 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:

  1. Clearer guards: Early continue for non-artifact parts reduces nesting
  2. Destructuring: Makes the code more readable by extracting artifact properties upfront
  3. Centralized status handling: Status computation based on block.status is now deterministic and easy to follow
  4. 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 downloadBlob aligns with the PR's objective to consolidate download functionality into a shared module.


185-191: LGTM: Optimized by moving computation after guard.

Moving the tabId assignment 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 activeThread once on line 242 and using it in the loop comparison on line 244 avoids repeated getActiveThreadId() calls, improving performance.


365-393: LGTM: Consistent use of local activeThread variable.

The function properly captures activeThread once 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 activeThread once 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 activeThread once on line 838 and uses it consistently on line 841.


1306-1316: LGTM: Centralized download logic.

The use of downloadBlob on line 1313 successfully consolidates download functionality into a shared utility, eliminating inline DOM manipulation and improving maintainability.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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-label contains 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 to z-[2] - the z-2 utility is not available.

This change from z-[2] to z-2 breaks the z-index styling. As confirmed in previous review comments, the project's Tailwind configuration does not include a z-2 utility (only z-0, z-10, z-20, etc. are available). The arbitrary value z-[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

📥 Commits

Reviewing files that changed from the base of the PR and between 8c54763 and 39521c0.

📒 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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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.ts
  • src/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] to rounded-md is semantically equivalent (both are 6px) and improves consistency by using a standard Tailwind class instead of an arbitrary value.

@Simon-He95 Simon-He95 merged commit 09bb9d2 into ThinkInAIXYZ:dev Oct 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant