-
Notifications
You must be signed in to change notification settings - Fork 4k
[feat] Add image thumbnails to st.chat_input file uploads
#13547
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
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ PR preview is ready!
|
95af98d to
d4253be
Compare
d4253be to
d3cd7a1
Compare
b42d84f to
c644a77
Compare
d3cd7a1 to
3f4716f
Compare
c644a77 to
79baf6a
Compare
3f4716f to
1855aac
Compare
1855aac to
d9ed691
Compare
79baf6a to
c672a13
Compare
st.chat_input file uploads
frontend/lib/src/components/widgets/ChatInput/fileUpload/useImagePreview.ts
Outdated
Show resolved
Hide resolved
b584b83 to
ca6ffd9
Compare
908aff1 to
ea9f235
Compare
49b1769 to
1c4a42f
Compare
1c4a42f to
89fc027
Compare
f9309c2 to
49dfc04
Compare
SummaryThis PR adds image preview thumbnails for image files uploaded via Changes include:
Code QualityThe code quality is good overall and follows Streamlit's established patterns: Strengths:
Minor observations:
Test CoverageE2E Tests: ✅
Unit Tests: The following unit tests should be added:
Backwards Compatibility✅ Fully backwards compatible
Security & Risk✅ No security concerns identified
Minor consideration:
Recommendations
VerdictCHANGES REQUESTED: The implementation is solid and follows best practices, but the PR is missing unit tests for the new This is an automated AI review. Please verify the feedback and use your judgment. |
SummaryThis PR adds image thumbnail previews to file chips in Key changes:
Code QualityStrengths
// Derive the preview URL during render - createObjectURL is synchronous
const previewUrl = useMemo(() => {
if (!file || !isImageFile(filename)) {
return null
}
return URL.createObjectURL(file)
}, [file, filename])
// Effect only for cleanup - revoke the blob URL when it changes or unmounts
useEffect(() => {
return () => {
if (previewUrl) {
URL.revokeObjectURL(previewUrl)
}
}
}, [previewUrl])
Minor Observations
Test CoverageUnit Tests - Excellent Coverage
E2E TestsThe existing The test follows the E2E best practices:
Backwards CompatibilityNo breaking changes. This is a purely additive feature:
Security & RiskLow risk:
RecommendationsNo blocking issues. Minor suggestions for future consideration:
VerdictAPPROVED: This is a well-implemented feature with excellent test coverage, proper memory management, and follows React/TypeScript best practices. The code is clean, maintainable, and introduces no breaking changes or security concerns. This is an automated AI review. Please verify the feedback and use your judgment. |
kmcgrady
left a 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.
Small question but the code looks good.
| export const StyledChatUploadedFileImagePreview = styled.img({ | ||
| width: "100%", | ||
| height: "100%", | ||
| objectFit: "cover", |
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.
Just double checking this shouldn't be contain? I only ask cause I figure the user would want to see the full icon picture.
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.
Good q, let me clarify with Jessi.
Merge activity
|
- Add useImagePreview.test.ts for hook behavior and blob URL memory management - Add isImageFile and getFileExtension tests to getFileTypeIcon.test.ts - Add image preview rendering tests to ChatUploadedFile.test.tsx
4a11a35 to
ff186eb
Compare
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0300%
💡 Consider adding more unit tests to maintain or improve coverage. |

Describe your changes
Added image preview thumbnails for image files in chat input file chips. When users upload image files to the chat input, a thumbnail preview of the image is now displayed in the file chip instead of a generic file icon. This provides better visual feedback and makes it easier to identify uploaded images.
Screenshot or video (only for visual changes)
The PR updates the snapshot tests for file chips in both light and dark themes across all browsers to reflect the new image preview functionality.
Testing Plan
useImagePreviewhook to create and manage blob URLs for image previewsContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.