feat: add thumbnail generation for shared analysis results#948
Open
Anusmita12 wants to merge 2 commits into
Open
feat: add thumbnail generation for shared analysis results#948Anusmita12 wants to merge 2 commits into
Anusmita12 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds thumbnail preview support for shared analysis results by sending embedded images from the frontend, generating a downscaled thumbnail on the backend, and displaying it in the frontend history list.
Changes:
- Frontend now includes embedded result images in the share payload and renders returned thumbnails in history items
- Backend generates and stores a thumbnail from the first provided image
- Adds Pillow dependency and minimal thumbnail service tests
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/index.html | Sends embedded images with share request; renders thumbnail previews in history UI |
| backend/app/services/thumbnail.py | Introduces thumbnail generation from base64/data URLs via Pillow |
| backend/app/routers/share.py | Generates thumbnail during share creation and returns it in the response |
| backend/app/schemas.py | Extends share request/record schemas with images input and thumbnail output |
| backend/requirements.txt | Adds Pillow dependency for image processing |
| backend/tests/test_thumbnail.py | Adds basic tests for invalid/empty inputs to thumbnail generator |
| README.md | Documents new “Thumbnail Previews” capability |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| THUMB_QUALITY = 72 | ||
|
|
||
|
|
||
| def _b64_to_pil(data_url: str) -> Optional[Image.Image]: |
Comment on lines
+7
to
+11
| try: | ||
| from PIL import Image | ||
| PIL_AVAILABLE = True | ||
| except ImportError: | ||
| PIL_AVAILABLE = False |
| code: str = Field(..., min_length=1, max_length=settings.max_code_chars) | ||
| result: dict[str, Any] | None = Field(default=None) | ||
| result_json: str | None = Field(default=None) | ||
| images: list[str] = Field(default_factory=list) |
Comment on lines
4028
to
+4029
| <div class="history-item" onclick="loadEntry('${h.id}')" tabindex="0" role="button" aria-label="${getTranslation('history_entry_label').replace('{lang}', h.lang || '?').replace('{time}', h.ts)}" onkeydown="if(event.key==='Enter'||event.key===' ') { event.preventDefault(); loadEntry('${h.id}'); }"> | ||
| ${h.thumbnail ? `<img src="${h.thumbnail}" alt="preview" style="width:56px;height:32px;object-fit:cover;border-radius:4px;flex-shrink:0;">` : ''} |
Comment on lines
+1
to
+7
| from app.services.thumbnail import generate_thumbnail | ||
|
|
||
| def test_generate_thumbnail_returns_none_for_invalid_input(): | ||
| assert generate_thumbnail("not_valid_base64") is None | ||
|
|
||
| def test_generate_thumbnail_returns_none_for_empty_string(): | ||
| assert generate_thumbnail("") is None No newline at end of file |
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.
Implements a thumbnail generation pipeline for shared analyses. When a user shares an analysis result that contains embedded images, a small preview thumbnail is automatically generated and stored alongside the share record. Thumbnails are displayed in the query history list view for quick visual identification.
Shared analyses containing images had no preview, making list views and sharing previews unhelpful. This addresses the issue by adding a server-side image processing pipeline using Pillow to downscale embedded images into lightweight WebP thumbnails.
Changes made:
backend/app/services/thumbnail.py— new Pillow-based image downscaler (320×180 WebP)backend/requirements.txt— addedPillow>=10.0.0backend/app/schemas.py— addedimagesfield toShareCreateRequest,thumbnailfield toShareRecordbackend/app/models.py— added nullablethumbnailcolumn toSharedSnippetbackend/app/routers/share.py— callsgenerate_thumbnailon share creation, stores and returns resultfrontend/index.html— collects embedded images on share, saves thumbnail to history, displays thumbnail in history listbackend/tests/test_thumbnail.py— basic tests for the thumbnail serviceScreenshots
