improvement(chat): partialize chat store to only persist image URL instead of full image in floating chat#2842
Merged
waleedlatif1 merged 1 commit intostagingfrom Jan 16, 2026
Conversation
…stead of full image in floating chat
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR optimizes localStorage usage by preventing full base64-encoded images from being persisted in the chat store. The implementation adds a
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Chat
participant FileUploadHook
participant FileReader
participant ChatStore
participant LocalStorage
User->>Chat: Drop/select image files
Chat->>FileUploadHook: addFiles(files)
FileUploadHook->>FileUploadHook: Validate files (size, duplicates)
FileUploadHook->>FileUploadHook: setChatFiles (functional update)
FileUploadHook-->>Chat: chatFiles updated
Chat->>Chat: getFilePreviewUrl(file)
Chat->>Chat: URL.createObjectURL(file.file)
Chat->>Chat: Store URL in ref Map
Chat-->>User: Display image preview
User->>Chat: Send message
Chat->>FileReader: readAsDataURL(file.file)
Note over FileReader: 60s timeout protection
FileReader-->>Chat: dataUrl (base64)
Chat->>Chat: processFileAttachments()
Chat->>ChatStore: addMessage(message with attachments)
ChatStore->>ChatStore: Add message to state
ChatStore->>LocalStorage: persist(state)
Note over ChatStore,LocalStorage: partialize clears dataUrl
ChatStore->>LocalStorage: Store message without base64
User->>Chat: Reload page
LocalStorage->>ChatStore: Rehydrate state
Note over LocalStorage,ChatStore: dataUrl is empty string
ChatStore-->>Chat: messages with empty dataUrl
Chat->>Chat: canDisplayAsImage checks dataUrl
Chat-->>User: Show attachment metadata only
User->>Chat: Remove file from preview
Chat->>FileUploadHook: removeFile(fileId)
Chat->>Chat: Cleanup: URL.revokeObjectURL(url)
Chat->>Chat: Remove from ref Map
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually
Checklist