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

Fix sidebar state persistence #4745

Merged
merged 4 commits into from
Aug 29, 2024
Merged

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Aug 28, 2024

What changes are proposed in this pull request?

Fixes sidebar ordering state persistance, as well as group and field filter expansion. Currently, Opening the modal resets the current ordering due to the page transition. See recording below to observe the unwanted behavior

Screen.Recording.2024-08-28.at.1.44.29.PM.mov

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

Added test case to e2e quickstart smoke test

Release Notes

  • Fixed sidebar ordering and expansion persistance

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 sidebar state management to respond to the expanded/collapsed state of the sidebar.
    • Added a new test case to verify sidebar persistence during user interactions.
  • Bug Fixes

    • Improved logic for determining the expanded state of sidebar groups, ensuring accurate rendering.
  • Chores

    • Updated naming conventions for clarity in state management entities.

@benjaminpkane benjaminpkane added bug Bug fixes app Issues related to App features labels Aug 28, 2024
@benjaminpkane benjaminpkane requested review from sashankaryal and a team August 28, 2024 17:45
@benjaminpkane benjaminpkane self-assigned this Aug 28, 2024
Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Walkthrough

The changes involve updates to several files within the application, focusing on modifications to GraphQL fragments, state management, and testing. Key alterations include replacing the name field with datasetId in the sidebarGroupsFragment, enhancing the robustness of state management functions, and streamlining the export structure for sidebar groups. Additionally, new tests have been added to verify the persistence of the sidebar state during user interactions.

Changes

Files Change Summary
app/packages/relay/src/fragments/sidebarGroupsFragment.ts Replaced name with datasetId in the sidebarGroupsFragment.
app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts Reformatted comments and updated conditional checks for fragmentOptions.keys to use optional chaining.
app/packages/state/src/hooks/useSetModalState.ts Added import for sidebarExpandedAtoms and integrated it into modal state management.
app/packages/state/src/recoil/sidebar.ts Modified resolveGroups function to check for boolean values in expanded. Simplified sidebarGroupsDefinition export to focus on graphQLSyncFragmentAtomFamily.
app/packages/state/src/recoil/sidebarExpanded.ts Changed keys for sidebarExpandedStore and sidebarExpanded to improve naming consistency.
e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts Added a new test case for "sidebar persistence" to verify the behavior of the sidebar when toggling groups.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Sidebar
    participant Modal
    participant StateManagement

    User->>Sidebar: Toggle "PRIMITIVES" group
    Sidebar->>StateManagement: Update sidebar state
    User->>Modal: Open first sample
    User->>Modal: Close modal
    Sidebar->>User: Display updated state (group hidden)
Loading

🐇 In the code, I hop and play,
With changes brightening the day.
From names to IDs, we leap with glee,
Testing persistence, just wait and see!
In the sidebar, new paths we find,
A joyful journey, with code aligned! 🌟

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9929c04 and 4453dd4.

Files ignored due to path filters (3)
  • app/packages/app/src/pages/datasets/__generated__/DatasetPageQuery.graphql.ts is excluded by !**/__generated__/**
  • app/packages/relay/src/fragments/__generated__/sidebarGroupsFragment.graphql.ts is excluded by !**/__generated__/**
  • app/packages/relay/src/queries/__generated__/datasetQuery.graphql.ts is excluded by !**/__generated__/**
Files selected for processing (6)
  • app/packages/relay/src/fragments/sidebarGroupsFragment.ts (1 hunks)
  • app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts (2 hunks)
  • app/packages/state/src/hooks/useSetModalState.ts (2 hunks)
  • app/packages/state/src/recoil/sidebar.ts (2 hunks)
  • app/packages/state/src/recoil/sidebarExpanded.ts (2 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1 hunks)
Additional context used
Path-based instructions (6)
app/packages/relay/src/fragments/sidebarGroupsFragment.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.

app/packages/state/src/recoil/sidebarExpanded.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.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.

app/packages/state/src/hooks/useSetModalState.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.

app/packages/relay/src/graphQLSyncFragmentAtomFamily.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.

app/packages/state/src/recoil/sidebar.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 (33)
app/packages/relay/src/fragments/sidebarGroupsFragment.ts (1)

5-5: Verify the impact of changing the queried field.

The field being queried has changed from name to datasetId. Ensure that all components using this fragment are updated to handle datasetId instead of name.

Run the following script to verify the usage of this fragment in the codebase:

#!/bin/bash
# Description: Verify all components using `sidebarGroupsFragment` are updated to handle `datasetId`.

# Test: Search for the fragment usage. Expect: Only occurrences of `datasetId`.
rg --type graphql -A 5 $'sidebarGroupsFragment'
app/packages/state/src/recoil/sidebarExpanded.ts (2)

8-8: LGTM!

The change clarifies the purpose of the atom family and distinguishes it from other related entities.

The code changes are approved.


22-22: LGTM!

The change aligns the key with the naming convention used in the atom family.

The code changes are approved.

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

89-94: LGTM!

The new test case enhances the test coverage by ensuring that the sidebar behaves correctly when interacting with other components.

The code changes are approved.

app/packages/state/src/hooks/useSetModalState.ts (5)

13-13: LGTM!

The import statement for sidebarExpandedAtoms is correct and aligns with the file's purpose.


47-47: LGTM!

The new entry is correctly added to the data array, ensuring the expanded state of the sidebar is managed.


48-48: LGTM!

The new entry is correctly added to the data array, ensuring the expanded state of the sidebar is managed.


49-49: LGTM!

The new entry is correctly added to the data array, ensuring the expanded state of the sidebar is managed.


50-50: LGTM!

The new entry is correctly added to the data array, ensuring the expanded state of the sidebar is managed.

app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts (2)

59-60: LGTM!

The comment reformatting improves readability and does not affect functionality.


97-97: LGTM!

The use of optional chaining enhances the robustness of the code by preventing potential runtime errors.

app/packages/state/src/recoil/sidebar.ts (22)

217-217: LGTM!

The change ensures that only groups explicitly marked as boolean values in the expanded object are considered for expansion.


319-319: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


322-322: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


323-323: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


324-324: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


325-325: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


326-326: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


327-327: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


328-328: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


329-329: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


330-330: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


331-331: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


332-332: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


333-333: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


334-334: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


335-335: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


336-336: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


337-337: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


338-338: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


339-339: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


340-340: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.


341-341: LGTM!

The simplification focuses the export on the GraphQL sync fragment atom family, improving code clarity.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9929c04 and 4453dd4.

Files ignored due to path filters (3)
  • app/packages/app/src/pages/datasets/__generated__/DatasetPageQuery.graphql.ts is excluded by !**/__generated__/**
  • app/packages/relay/src/fragments/__generated__/sidebarGroupsFragment.graphql.ts is excluded by !**/__generated__/**
  • app/packages/relay/src/queries/__generated__/datasetQuery.graphql.ts is excluded by !**/__generated__/**
Files selected for processing (6)
  • app/packages/relay/src/fragments/sidebarGroupsFragment.ts (1 hunks)
  • app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts (2 hunks)
  • app/packages/state/src/hooks/useSetModalState.ts (2 hunks)
  • app/packages/state/src/recoil/sidebar.ts (2 hunks)
  • app/packages/state/src/recoil/sidebarExpanded.ts (2 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts
  • app/packages/state/src/recoil/sidebarExpanded.ts
Additional context used
Path-based instructions (4)
app/packages/relay/src/fragments/sidebarGroupsFragment.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.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.

app/packages/state/src/hooks/useSetModalState.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.

app/packages/state/src/recoil/sidebar.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 (5)
app/packages/relay/src/fragments/sidebarGroupsFragment.ts (1)

5-5: LGTM!

The change from name to datasetId is appropriate and aligns with the PR objectives.

The code changes are approved.

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

88-94: LGTM!

The new test case sidebar persistence is well-structured and effectively verifies the sidebar state persistence.

The code changes are approved.

app/packages/state/src/hooks/useSetModalState.ts (1)

13-13: LGTM!

The addition of sidebarExpandedAtoms and its integration into the modal state management logic is appropriate and aligns with the PR objectives.

The code changes are approved.

Also applies to: 65-68

app/packages/state/src/recoil/sidebar.ts (2)

217-218: LGTM!

The change to use typeof expanded[group.name] === "boolean" ensures that only groups with a boolean value in expanded are marked as expanded, improving the precision of the expansion logic.

The code changes are approved.


319-366: LGTM!

The simplification of the sidebarGroupsDefinition export enhances clarity and maintainability by focusing solely on the synchronization of sidebar groups with GraphQL fragments.

The code changes are approved.

Copy link
Contributor

@sashankaryal sashankaryal 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 dbdda14 into release/v0.25.1 Aug 29, 2024
17 checks passed
@benjaminpkane benjaminpkane deleted the bugfix/sidebar-groups branch August 29, 2024 15:57
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