fix(preview): skip thumbnail generation when image preview is disabled - #1621
fix(preview): skip thumbnail generation when image preview is disabled#1621YuriNachos wants to merge 1 commit into
Conversation
When show_image_preview = false, Model.RenderWithPath still spawned the thumbnail-generation subprocess (ffmpeg/pdftoppm/gs) for video/PDF/PS files, only to discard the result in renderImagePreview's disabled guard. Add an early ShowImagePreview check inside the thumbnail-eligible branch, before GetThumbnailOrGenerate, returning the existing disabled placeholder so no subprocess runs while image preview is disabled. The visible output is unchanged; only the wasted child process is eliminated. Fixes yorukot#1620 🤖 Written with Cursor Co-authored-by: Cursor
|
🎉 Thank you for your first contribution to superfile! We’re really excited to have you here 🙌 A maintainer might ask you to make a few changes before we can merge this PR. 👉 Please also take a moment to review our Contribution Guide If you have any questions, feel free to open a Discussion or just ask in the comments! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe preview renderer now checks ChangesPreview generation guard
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Following up on this since the fix is small and self-contained — |
Description
When
show_image_preview = false, hovering a video/PDF/PS file in the preview panel stillspawned the thumbnail-generation subprocess (
ffmpeg/pdftoppm/gs) only to discard theresult —
renderImagePreview's disabled guard threw the generated thumbnail away, but onlyafter the child process had already run. This wastes CPU and, as reported in #1620, surfaces
as visible
ffmpegchild processes while image preview is turned off.Model.RenderWithPathnow checkscommon.Config.ShowImagePreviewbeforeGetThumbnailOrGenerateand returns the existingImage preview is disabledplaceholder, so nothumbnail subprocess is spawned while image preview is disabled.
Fixes #1620
Changes
src/internal/ui/preview/render.go— add an early-return guard at the top of thethumbnail-eligible branch (
if m.thumbnailGenerator != nil && m.thumbnailGenerator.SupportsExt(ext))that returns
FilePreviewImagePreviewDisabledTextwhenShowImagePreviewis false, beforeGetThumbnailOrGenerateis reached. The enabled path is unchanged; the existing guard insiderenderImagePreviewis kept as defense-in-depth. The guard is scoped to the thumbnail branch sothat text and directory preview are unaffected.
Test plan
make dev— green (golangci-lint v2.12.20 issues, all tests pass,spfbuilds)gofmt -l .— emptygo test ./src/internal/ui/preview/ -run TestRenderWithPathDoesNotGenerateThumbnailWhenImagePreviewDisabled -v— PASS (and FAILs on unmodifiedmain, where it captures theError generating thumbnail/ ffmpegexit statuslog)show_image_preview = false, hover a video file in the preview panel — noffmpegchild process is spawned (verified via the capturedslogoutput; runtime drops to ~0)🤖 Written with Cursor
Co-authored-by: Cursor
Summary by CodeRabbit