-
Notifications
You must be signed in to change notification settings - Fork 590
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
fix carousel lookers rendering as imavid in ordered dynamic groups #4938
Conversation
WalkthroughThe changes involve updates to the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
app/packages/core/src/components/Modal/Group/DynamicGroup/carousel/DynamicGroupsFlashlightWrapper.tsx (1)
Line range hint
1-185
: Well-structured component with room for minor improvementThe
DynamicGroupsFlashlightWrapper
component is well-implemented, making good use of React hooks and Recoil for state management. The integration of the Flashlight instance and its lifecycle management is handled effectively.To further improve code readability, consider extracting some of the complex logic (e.g., Flashlight initialization and update logic) into separate custom hooks or utility functions. This would make the main component more concise and easier to understand.
app/packages/core/src/components/Modal/Group/GroupCarousel.tsx (2)
75-75
: Approved: Fix for looker rendering issue.The change from
false
totrue
in theuseCreateLooker
call addresses the issue mentioned in the PR objectives, fixing the rendering of image and Imavid lookers.Consider adding a comment explaining the significance of this boolean value for future maintainability. For example:
useCreateLooker( true, // Set to true to enable correct rendering for image and Imavid lookers true, // ... rest of the arguments )
Line range hint
77-80
: Approved: New highlight function improves group visualization.The newly added
highlight
function enhances the component by determining which samples should be highlighted based on their group. This improvement aligns with the PR objectives and the AI-generated summary.Consider adding type annotations to improve code clarity:
const highlight = useCallback( (sample: Sample): boolean => get(sample, groupField).name === currentSlice, [currentSlice, groupField] );This change would make the function's input and output types explicit, enhancing code readability and type safety.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
- app/packages/core/src/components/Modal/Group/DynamicGroup/carousel/DynamicGroupsFlashlightWrapper.tsx (1 hunks)
- app/packages/core/src/components/Modal/Group/GroupCarousel.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/core/src/components/Modal/Group/DynamicGroup/carousel/DynamicGroupsFlashlightWrapper.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/core/src/components/Modal/Group/GroupCarousel.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
🔇 Additional comments (4)
app/packages/core/src/components/Modal/Group/DynamicGroup/carousel/DynamicGroupsFlashlightWrapper.tsx (3)
62-62
: Approved: Key fix for looker rendering issueThis change from
false
totrue
in theuseCreateLooker
hook is crucial for addressing the main objective of this PR. It ensures that lookers are created with the correct configuration, fixing the issue where image lookers were incorrectly rendered as Imavid lookers.
Line range hint
122-133
: Correct usage of dependencies in useLayoutEffect hooksThe useLayoutEffect hooks in this component have appropriate dependency arrays:
- The first hook (lines 122-133) correctly includes
mediaField
, ensuring that the flashlight is reset when the selected media field changes.- The second hook (lines 149-157) has a comprehensive list of dependencies (
deferred
,flashlight
,updateItem
,options
,selected
) that trigger updates to flashlight items when relevant data changes.This implementation ensures that the component responds correctly to changes in its dependencies, maintaining consistency between the state and the UI.
Also applies to: 149-157
Line range hint
1-185
: Summary: Approved changes with minor improvement suggestionsThe changes in this file successfully address the main objective of the PR by fixing the looker rendering issue. The overall implementation of the
DynamicGroupsFlashlightWrapper
component is of high quality, with proper use of React hooks and Recoil for state management.Key points:
- The critical fix on line 62 resolves the looker rendering problem.
- The component structure and lifecycle management are well-implemented.
- Dependencies in useLayoutEffect hooks are correctly specified.
While the current implementation is approved, consider the earlier suggestion to extract complex logic into separate hooks or utility functions for improved readability in future iterations.
app/packages/core/src/components/Modal/Group/GroupCarousel.tsx (1)
Line range hint
1-238
: Summary: Changes effectively address the PR objectives.The modifications in this file successfully tackle the rendering issue for image and Imavid lookers in the group carousel. The changes are minimal yet impactful, maintaining good code quality and adhering to React and TypeScript best practices. The new
highlight
function and the adjustment touseCreateLooker
work together to improve the visualization of grouped samples.While the changes are approved, consider implementing the minor suggestions provided in the previous comments to further enhance code clarity and maintainability.
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.
I'm not sure how existing e2e covers this, but makes sense to me. My mistake
What changes are proposed in this pull request?
Roughly speaking, the flow we use to decide whether to render image vs imavid looker is shown below:
Notice how
shouldRenderImavid
itself is parametrized by the modal setting - this was introduced in #4676. For the flow to work correctly,useCreateLooker
needs the appropriate prop. It was erroneously set tofalse
inDynamicGroupsFlashlightWrapper
andGroupCarousel::Column
, causing lookers to be rendered as Imavid when grid's "render frames as video" setting was enabled. This PR fixes the issue by passingisModal = true
for both cases.How is this patch tested? If it is not, please explain why.
Existing E2E
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
Description: Fixes an issue with image rendering in the carousel when grid’s render-frames-as-video setting is enabled.
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
New Features
Bug Fixes