Fix image storage performance for large local histories#30
Fix image storage performance for large local histories#30NormanMises wants to merge 5 commits intoCookSleep:mainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR addresses performance and memory issues when many large (e.g., 4K) images are stored locally by introducing thumbnail persistence, bounded in-memory caching, and by avoiding eager image loading during initialization.
Changes:
- Add persisted thumbnail/metadata fields to stored image records and introduce thumbnail retrieval APIs.
- Replace unbounded image caching with bounded LRU-style caches for originals and thumbnails.
- Update UI components to prefer thumbnails for list/detail previews and reduce expensive blur effects in overlays/modals.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Extends StoredImage with persisted thumbnail + dimension metadata fields. |
| src/store.ts | Adds bounded LRU caches, thumbnail cache helpers, and changes init to enumerate IDs for orphan cleanup without loading all images. |
| src/lib/db.ts | Generates/stores thumbnails on write and provides thumbnail/ID enumeration helpers. |
| src/components/TaskCard.tsx | Switches task card cover rendering to use cached thumbnails (and tags images with data-image-id). |
| src/components/DetailModal.tsx | Uses thumbnails for output preview rendering and tags images with data-image-id. |
| src/components/Lightbox.tsx | Passes imageId through and tags the displayed image for context menu original-resolution actions. |
| src/components/ImageContextMenu.tsx | Uses data-image-id to resolve/copy/download the original image when the displayed src is a thumbnail. |
| src/components/SizePickerModal.tsx | Removes backdrop blur from overlay for performance. |
| src/components/SettingsModal.tsx | Removes backdrop blur from overlay/dropdown for performance. |
| src/components/HelpModal.tsx | Removes backdrop blur from overlay for performance. |
| src/components/ConfirmDialog.tsx | Removes backdrop blur from overlay and adjusts modal background opacity. |
| src/components/InputBar.tsx | Removes backdrop blur from drag overlay and adjusts opacity for performance. |
Comments suppressed due to low confidence (1)
src/components/DetailModal.tsx:316
- The output preview now only renders when
currentOutputPreviewSrcexists (thumbnail). If thumbnail retrieval/generation fails, the modal shows no output image at all. Add a fallback to load/show the original output image (viaensureImageCached) when the thumbnail is unavailable, so users can still view/click the result.
{task.status === 'done' && outputLen > 0 && currentOutputPreviewSrc && (
<>
<img
ref={mainImageRef}
src={currentOutputPreviewSrc}
data-image-id={currentOutputImageId}
className="saveable-image max-w-[calc(100%-2rem)] max-h-[calc(100%-2rem)] object-contain cursor-pointer"
onLoad={() => {
const panel = imagePanelRef.current
const image = mainImageRef.current
if (!panel || !image) return
const panelRect = panel.getBoundingClientRect()
const imageRect = image.getBoundingClientRect()
setImageLabelLeft(Math.max(8, imageRect.left - panelRect.left))
}}
onClick={() =>
setLightboxImageId(task.outputImages[imageIndex], task.outputImages)
}
alt=""
/>
<div data-selectable-text className="absolute top-[15px] flex items-center gap-1.5" style={{ left: imageLabelLeft }}>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addressed in
Verification:
|
Fixes #29.
Summary
dataUrl, and use thumbnails for task cards and detail previews so list/detail interactions do not decode full 4K originals.backdrop-bluroverlays from modals/lightbox.Verification
npm testpasses: 8 test files, 43 tests.npm run buildpasses.