- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.4k
 
Change the way that uploaded images are shown; remove base64 strings (Gray Screen Fix) #8225
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
base: main
Are you sure you want to change the base?
Conversation
…globalStorage URIs; fix 401
- Fixed CodeQL security issue by properly validating vscode-cdn.net domain instead of substring check - Added missing copy action check for HTTPS/vscode-cdn URLs before opening image - Updated tests to match the more secure URL validation logic
      
        
              This comment was marked as outdated.
        
        
      
    
  This comment was marked as outdated.
          
Critical Issue FoundThis PR introduces a critical bug that breaks image display in the chat view: Issue: Images stored in backend messages are converted to base64 data URLs (via  Root cause: The PR's approach stores base64 in  Impact: This matches the exact bug reported by @hannesrudolph - images included with messages are not showing up in the chatview. TODO
 Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.  | 
    
        
          
                src/core/task/Task.ts
              
                Outdated
          
        
      | // Convert webview URIs to base64 data URLs for backend storage (one-time conversion) | ||
| const { normalizeImageRefsToDataUrls } = await import("../../integrations/misc/imageDataUrl") | ||
| const base64Images = images ? await normalizeImageRefsToDataUrls(images) : undefined | ||
| 
               | 
          ||
| await this.say("text", task, base64Images) // Store base64 in backend messages | 
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.
Critical bug: Images stored in ClineMessage.images[] are now base64 data URLs (after normalizeImageRefsToDataUrls conversion), but the frontend's Thumbnails component filters out all base64 data URIs (line 40 of Thumbnails.tsx). This means images attached to messages will never render in the chat view. The PR converts webview URIs to base64 for backend storage but doesn't provide a mechanism to convert them back to webview URIs when displaying messages in the frontend. This breaks the core functionality described in the user's report: "Images included with a message sent to the chatview are not showing up."
- Add imagesBase64 field to ClineMessage schema for efficient dual storage - Store both webview URIs (for display) and base64 (for API) when creating messages - Remove repeated base64→file→URI conversions on every render - Update all tools to use base64 from stored messages for API calls - Eliminates file I/O overhead during rendering and message updates - Improves performance by storing each format once instead of converting repeatedly
- Function is now primarily used for testing - Production code uses dual-storage (images + imagesBase64) - Removed redundant cache since same hash always produces same file path - Simplified implementation and removed obsolete test
| * NOTE: This function is primarily used for testing. In production, the dual-storage | ||
| * approach (images + imagesBase64 in ClineMessage) eliminates the need for this conversion. | ||
| * No caching is implemented since this is a test utility. | 
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.
The comment states "No caching is implemented" but line 98 still calls setImageBase64ForPath(filePath, dataUrl) which caches the reverse mapping. The comment should be updated to clarify that while forward caching (base64ToFilePathCache) was removed, reverse caching for image-cache lookups is still performed.
- Function was only used in tests, not in production code - Dual-storage approach (images + imagesBase64) eliminated need for base64→file conversion - Removed ~60 lines of function code + ~90 lines of tests - Simplified imageDataUrl module to focus on production use case - Kept normalizeImageRefsToDataUrls which is used in production (Task.ts)


Problem
Webview URIs in frontend caused memory efficiency, but broke image visibility for OpenRouter and other providers.
Solution
Store base64 data URLs directly in backend messages when first received from frontend:
Key Changes
Performance
Fixes image visibility while maintaining webview memory efficiency goals.
Important
This PR optimizes image handling by storing base64 data URLs in backend messages, improving performance and security, and includes comprehensive tests.
normalizeImageRefsToDataUrls().Thumbnails.image-cache.ts.ChatTextArea.tsxandChatView.tsxto handle image uploads and conversions.Thumbnails.tsxto exclude base64 images from rendering.image-handler.spec.tsandimageDataUrl.spec.ts.Thumbnailscomponent only renders safe image URIs inThumbnails.spec.tsx.This description was created by
 for 3ff9b21. You can customize this summary. It will automatically update as commits are pushed.