Add zoom and pan support in session detail view#1339
Conversation
✅ Deploy Preview for antenna-ssec ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for antenna-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughRenames the ChangesThumbnail accessor rename
Zoom/pan capture viewer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ui/src/pages/session-details/capture/capture.tsx (1)
57-82:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle missing
srcexplicitly to prevent a stuck loading state.
setIsLoading(true)runs before checkingsrc. Whensrcis null/undefined, the component can remain indefinitely in loading UI with no explicit empty-state handling.💡 Suggested fix
useLayoutEffect(() => { if (!imageRef.current) { return } - setIsLoading(true) - setNaturalSize(undefined) - - if (src) { - imageRef.current.src = src - imageRef.current.onload = () => { - if (imageRef.current?.width && imageRef.current.height) { - setNaturalSize({ - width: imageRef.current.naturalWidth, - height: imageRef.current.naturalHeight, - }) - } - setIsLoading(false) - } - - imageRef.current.onerror = () => { - setNaturalSize(undefined) - setIsLoading(false) - } - } + if (!src) { + setNaturalSize(undefined) + setIsLoading(false) + return + } + + setIsLoading(true) + setNaturalSize(undefined) + imageRef.current.src = src + imageRef.current.onload = () => { + if (imageRef.current?.width && imageRef.current.height) { + setNaturalSize({ + width: imageRef.current.naturalWidth, + height: imageRef.current.naturalHeight, + }) + } + setIsLoading(false) + } + + imageRef.current.onerror = () => { + setNaturalSize(undefined) + setIsLoading(false) + } }, [src])As per coding guidelines: "Handle empty and null states explicitly — API fields can be null even when the surrounding payload is present".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui/src/pages/session-details/capture/capture.tsx` around lines 57 - 82, The useLayoutEffect hook sets isLoading to true at the beginning but does not explicitly handle the case when src is null or undefined, causing the loading state to remain true indefinitely. After setting setIsLoading(true) and setNaturalSize(undefined), add an else clause to the if (src) condition that explicitly calls setIsLoading(false) and optionally setNaturalSize(undefined) to handle the empty-state case when src is missing or falsy.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@ui/src/pages/session-details/capture/capture.tsx`:
- Around line 57-82: The useLayoutEffect hook sets isLoading to true at the
beginning but does not explicitly handle the case when src is null or undefined,
causing the loading state to remain true indefinitely. After setting
setIsLoading(true) and setNaturalSize(undefined), add an else clause to the if
(src) condition that explicitly calls setIsLoading(false) and optionally
setNaturalSize(undefined) to handle the empty-state case when src is missing or
falsy.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c87d497b-6ee1-47a0-8dfc-554cf87acf80
⛔ Files ignored due to path filters (1)
ui/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (10)
ui/package.jsonui/src/data-services/models/capture.tsui/src/pages/captures/capture-columns.tsxui/src/pages/captures/capture-gallery.tsxui/src/pages/session-details/capture/capture.module.scssui/src/pages/session-details/capture/capture.tsxui/src/pages/session-details/session-details.tsxui/src/pages/session-details/view-settings.tsxui/src/pages/session-details/zoom-settings.tsxui/src/utils/language.ts

Summary
In this PR we make it possible to zoom and pan the capture in the session detail view. This makes it possible to see more details in high res captures. Users can zoom using the mouse wheel or using button controls in UI.
The solution using the library react-zoom-pan-pinch.
Notes
We now load the original image instead of the medium thumbnail image in the session detail view. Before merge, maybe we should load both, so we can still show something quicker, but still make it possible to see all the details?
Screenshots
Summary by CodeRabbit
New Features
Style