-
Notifications
You must be signed in to change notification settings - Fork 626
feat: enhance image file display with context-aware thumbnails #793
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
WalkthroughAdds a context prop to FileItem for layout control, introduces image-specific rendering in message context, and updates ChatInput to pass context='input'. Paste handling now includes a thumbnail field on image MessageFile objects sourced from compressed base64. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant CI as ChatInput.vue
participant FI as FileItem.vue
participant Types as @shared/chat (MessageFile)
U->>CI: Paste image
CI->>CI: Extract imageInfo (compressedBase64)
CI->>Types: Create MessageFile { thumbnail, ... }
CI->>FI: Render FileItem context='input' with file data
Note over FI: New prop 'context' controls layout<br/>Image-specific UI only when context == 'message'
U->>CI: Send message
CI->>FI: Render in message list context='message'
alt Image file with thumbnail
FI->>FI: isImageFile == true
FI-->U: Show vertical thumbnail card + delete action
else Non-image or no thumbnail
FI-->U: Show horizontal item layout + delete action
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/components/FileItem.vue (1)
63-65: Use i18n for user-visible “tokens” labelRenderer must not hardcode user-facing strings. Inject vue-i18n and use a key, e.g., fileItem.tokens.
@@ - <TooltipContent> - <p>{{ tokens }} tokens</p> - </TooltipContent> + <TooltipContent> + <p>{{ t('fileItem.tokens', { count: tokens }) }}</p> + </TooltipContent>-import { computed } from 'vue' +import { computed } from 'vue' +import { useI18n } from 'vue-i18n' @@ -defineEmits<{ +const { t } = useI18n() + +defineEmits<{Follow-up: add fileItem.tokens to locale files (e.g., "fileItem.tokens": "{count} tokens").
Also applies to: 72-72, 92-92
src/renderer/src/components/ChatInput.vue (1)
524-524: Unify logs to English per repo guidelineSeveral console messages are in Chinese; convert to English.
- console.error('文件处理失败:', error) + console.error('File processing failed:', error) @@ - console.error('文件准备失败:', error) + console.error('File preparation failed:', error) @@ - console.error('读取资源失败:', error) + console.error('Failed to read resource:', error) @@ - console.error('文件准备失败:', error) + console.error('File preparation failed:', error) @@ - console.warn('恢复焦点时出错:', error) + console.warn('Error restoring focus:', error)Also applies to: 549-549, 621-621, 925-925, 1195-1195
🧹 Nitpick comments (4)
src/renderer/src/components/FileItem.vue (2)
12-12: Add alt text + lazy/async decoding and fixed dimensions to thumbnailsImproves a11y, CLS, and performance; aligns with our image optimization learnings.
- <img :src="thumbnail" class="w-20 h-20 rounded-md border object-cover" /> + <img + :src="thumbnail" + :alt="fileName" + loading="lazy" + decoding="async" + width="80" + height="80" + class="w-20 h-20 rounded-md border object-cover" + />- <img v-if="thumbnail" :src="thumbnail" class="w-8 h-8 rounded-md border" /> + <img + v-if="thumbnail" + :src="thumbnail" + :alt="fileName" + loading="lazy" + decoding="async" + width="32" + height="32" + class="w-8 h-8 rounded-md border" + />Also applies to: 37-37
6-6: Translate inline comments to EnglishRepo guideline: use English for all comments. Please convert the template comments.
- <!-- 图片文件在消息中使用特殊布局 --> + <!-- Use special layout for image files inside messages --> @@ - <!-- 非图片文件或输入框中的图片使用原有布局 --> + <!-- Use the original layout for non-image files or images inside the input area -->Also applies to: 31-31
src/renderer/src/components/ChatInput.vue (2)
35-35: Use literal binding for static propNo need for v-bind when passing a static string.
- :context="'input'" + context="input"
972-1005: Detach DOM/window listeners on unmount to avoid leaksExtract handlers to named functions, add/remove them in mounted/unmounted.
@@ -onMounted(() => { +const handleContextMenuAskAI = (e: any) => { + inputText.value = e.detail + editor.commands.setContent(e.detail) + editor.commands.focus() +} +const handleVisibilityChange = () => { + if (!document.hidden) { + setTimeout(() => { + restoreFocus() + }, 100) + } +} + +onMounted(() => { @@ - window.addEventListener('context-menu-ask-ai', (e: any) => { - inputText.value = e.detail - editor.commands.setContent(e.detail) - editor.commands.focus() - }) + window.addEventListener('context-menu-ask-ai', handleContextMenuAskAI) @@ - document.addEventListener('visibilitychange', () => { - if (!document.hidden) { - setTimeout(() => { - restoreFocus() - }, 100) - } - }) + document.addEventListener('visibilitychange', handleVisibilityChange) @@ onUnmounted(() => { @@ - window.electron.ipcRenderer.removeListener('rate-limit:config-updated', handleRateLimitEvent) + window.electron.ipcRenderer.removeListener('rate-limit:config-updated', handleRateLimitEvent) window.electron.ipcRenderer.removeListener('rate-limit:request-executed', handleRateLimitEvent) window.electron.ipcRenderer.removeListener('rate-limit:request-queued', handleRateLimitEvent) + window.removeEventListener('context-menu-ask-ai', handleContextMenuAskAI) + document.removeEventListener('visibilitychange', handleVisibilityChange) })If adding new top-level consts outside the shown ranges is preferable, place the two handler declarations just above onMounted.
Also applies to: 1007-1014
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/renderer/src/components/ChatInput.vue(2 hunks)src/renderer/src/components/FileItem.vue(4 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
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/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
渲染进程代码放在
src/renderer
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
Implement proper state management with Pinia
Utilize Vue Router for navigation and route management
Leverage Vue's built-in reactivity system for efficient data handling
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/src/**/*.vue
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
Use scoped styles to prevent CSS conflicts between components
src/renderer/src/**/*.vue: Follow existing component patterns when creating new UI components
Ensure responsive design with Tailwind CSS for new UI components
Add proper error handling and loading states to UI components
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,tsx,vue}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use TypeScript for all code; prefer types over interfaces.
Avoid enums; use const objects instead.
Use arrow functions for methods and computed properties.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/**/*.{vue,ts}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Implement lazy loading for routes and components.
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/**/*.{ts,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
Implement SEO best practices using Nuxt's useHead and useSeoMeta.
src/renderer/**/*.{ts,vue}: Use Pinia for frontend state management
From renderer to main, call presenters via the usePresenter.ts composable
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
src/renderer/**/*.vue: Use Vue 3 Composition API for all components
Use Tailwind CSS with scoped styles for component styling
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
src/renderer/src/**
📄 CodeRabbit inference engine (CLAUDE.md)
Organize UI components by feature under src/renderer/src/
Files:
src/renderer/src/components/FileItem.vuesrc/renderer/src/components/ChatInput.vue
🧠 Learnings (3)
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Use Iconify/Vue for icon implementation.
Applied to files:
src/renderer/src/components/FileItem.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Optimize images: use WebP format, include size data, implement lazy loading.
Applied to files:
src/renderer/src/components/FileItem.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Import Icon component from Iconify/Vue.
Applied to files:
src/renderer/src/components/FileItem.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-check (x64)
🔇 Additional comments (3)
src/renderer/src/components/FileItem.vue (2)
101-103: Image type detection is correct and conciseUsing startsWith('image/') is appropriate here.
84-89: All FileItem instances correctly handle the newcontextprop
- In MessageItemUser.vue, the
contextprop is omitted, so it safely defaults to'message'.- In ChatInput.vue, the
contextprop is explicitly set to'input'.No additional call sites require updates.
src/renderer/src/components/ChatInput.vue (1)
506-508: Thumbnail wiring verified—no changes neededI’ve confirmed that:
- The
MessageFiletype insrc/shared/chat.d.tsdeclaresthumbnail?: string, allowing both defined and undefined values.- Both
prepareFileandprepareDirectoryinsrc/main/presenter/filePresenter/FilePresenter.tsalways include athumbnailfield (defaulting to''or the adapter’s result), covering drag-and-drop, file picker, and paste paths.- The UI components (
ChatInput.vue,FileItem.vue, etc.) already handle missing or empty thumbnails gracefully.All ingestion paths align correctly.
enhance image file display with context-aware thumbnails


Summary by CodeRabbit