Skip to content
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

Persist current slice during group modal navigation #4836

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Sep 24, 2024

What changes are proposed in this pull request?

Fixes active slice persistence in the group modal

Screen.Recording.2024-09-24.at.2.28.02.PM.mov

How is this patch tested? If it is not, please explain why.

e2e assertion

Release Notes

  • Fixed active slice persistence during group modal navigation

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features
    • Enhanced the "quickstart-groups" test suite to verify sidebar navigation functionality.
  • Bug Fixes
    • Adjusted control flow in the sample expansion logic for improved functionality.

@benjaminpkane benjaminpkane added bug Bug fixes app Issues related to App features labels Sep 24, 2024
@benjaminpkane benjaminpkane self-assigned this Sep 24, 2024
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes involve modifications to the useSetExpandedSample.ts file, specifically adjusting the indentation of a set function call to ensure it operates correctly within a conditional block. Additionally, enhancements have been made to the "quickstart-groups" test suite, which now includes new operations that toggle a sidebar group and validate the sidebar entry text against an expected value.

Changes

File Path Change Summary
app/packages/state/src/hooks/useSetExpandedSample.ts Adjusted indentation of set(groupAtoms.modalGroupSlice, fallback); to align with conditional logic.
e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts Enhanced the test suite with new operations for toggling a sidebar group and verifying entry text.

Possibly related PRs

  • Fix selection for group modal #4789: The changes in this PR involve modifications to the control flow in the handle_group_filter function, similar to the indentation adjustment in the useSetExpandedSample.ts file, indicating a focus on refining conditional logic.

Suggested reviewers

  • imanjra
  • sashankaryal

🐇 In the code, we hop and play,
Adjusting lines in a tidy way.
Tests now check with joyful cheer,
Sidebar entries, oh so clear!
With every change, we leap and bound,
In our code garden, joy is found! 🌼


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@benjaminpkane benjaminpkane marked this pull request as ready for review September 24, 2024 20:15
@benjaminpkane benjaminpkane requested a review from a team September 24, 2024 20:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
app/packages/state/src/hooks/useSetExpandedSample.ts (1)

Line range hint 1-55: Consider minor improvements for clarity and maintainability

While the current implementation is solid, consider the following suggestions to further enhance the code:

  1. If the THREE_D set is used in other parts of the application, consider moving it to a separate constants file for better reusability and maintainability.

  2. The state management logic, especially the fallback selection process, is quite complex. Adding some comments to explain the purpose and logic of these operations would improve code readability and make it easier for other developers to understand and maintain the code.

Example:

// Select a non-3D fallback when the current media type is 3D
if (THREE_D.has(map[fallback])) {
  // Find the first non-3D media type as a fallback
  fallback = types
    .filter(({ mediaType }) => !THREE_D.has(mediaType))
    .map(({ name }) => name)
    .sort()[0];

  set(groupAtoms.modalGroupSlice, fallback);
}

These changes would improve the overall clarity and maintainability of the code without affecting its functionality.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75e8e87 and 9986cc4.

Files selected for processing (2)
  • app/packages/state/src/hooks/useSetExpandedSample.ts (1 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts (1 hunks)
Additional context used
Path-based instructions (2)
app/packages/state/src/hooks/useSetExpandedSample.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts (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 not posted (3)
app/packages/state/src/hooks/useSetExpandedSample.ts (2)

31-32: Approved: Improved logic for handling 3D media types

The change to move set(groupAtoms.modalGroupSlice, fallback); inside the conditional block is a good improvement. This ensures that the modalGroupSlice is only updated when the current media type is 3D and a non-3D fallback is selected. This change aligns with the PR objective of fixing active slice persistence during group modal navigation.

The modification prevents unnecessary updates to the modalGroupSlice when dealing with non-3D media types, which should lead to more predictable behavior and better performance.


Line range hint 1-55: Approved: Well-structured custom hook implementation

The overall structure and implementation of the useSetExpandedSample hook adhere to React and Recoil best practices:

  1. It effectively uses useRecoilCallback for managing complex state updates.
  2. The commit function is separated from the setter, promoting a clear separation of concerns.
  3. The returned function is wrapped in useCallback, optimizing performance by preventing unnecessary recreations.

This implementation should provide efficient and predictable state management for the group modal navigation feature.

e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts (1)

95-101: LGTM! The added test case aligns well with the PR objectives.

The new test steps effectively validate the persistence of the active slice during group modal navigation, which is the main goal of this pull request. The implementation follows the existing testing patterns and provides good coverage for the described scenario.

Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benjaminpkane benjaminpkane merged commit 666f630 into develop Sep 25, 2024
11 checks passed
@benjaminpkane benjaminpkane deleted the bugfix/modal-group-slice branch September 25, 2024 17:49
@coderabbitai coderabbitai bot mentioned this pull request Oct 21, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features bug Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants