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

remove reload_on_navigation panel option #5018

Merged
merged 1 commit into from
Nov 2, 2024

Conversation

sashankaryal
Copy link
Contributor

@sashankaryal sashankaryal commented Oct 31, 2024

Panel component subscribing to fos.modalUniqueId has negative performance consequences on the app, most importantly the sample modal plugin. This PR removes that.

Motivation

Keying the panel component by "modal unique ID", which is a concatenation of sample and group id, leads to a slippery slope where the contract is not well-defined. This behavior was added to support shouldReloadOnNavigation panel option for modal panels, but what is "navigation" anyway? This gets tricky in dynamic groups of groups, for instance. Also, key=foo is a bad react pattern.

Removing this panel option also incentivizes the plugin author to write better code where they control the scope and maintain strict ownership of the resources they create / subscribe to, and their lifecycles.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced an optional reloadOnNavigation property for future plugin functionality (commented out).
  • Bug Fixes

    • Removed the reloadOnNavigation option from various components and methods, streamlining the panel registration and rendering process.
  • Refactor

    • Simplified the Panel component by eliminating unnecessary state dependencies and rendering logic.
  • Documentation

    • Updated documentation to reflect the removal of the reload_on_navigation parameter in relevant classes and methods.

@sashankaryal sashankaryal requested a review from a team October 31, 2024 10:10
@sashankaryal sashankaryal self-assigned this Oct 31, 2024
Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

Walkthrough

The changes in this pull request primarily involve the removal of the reloadOnNavigation property from various components related to panel registration and configuration. This property was eliminated from the registerPanel function in register.tsx, the PanelOptions type in index.ts, and the PanelConfig class in panel.py. Additionally, the Operations class in operations.py no longer includes this parameter in its method signature. These modifications streamline the panel management system by removing unnecessary dependencies and simplifying the overall structure.

Changes

File Path Change Summary
app/packages/operators/src/Panel/register.tsx Removed reloadOnNavigation property from panelOptions in registerComponent call.
app/packages/plugins/src/index.ts Added commented-out reloadOnNavigation property to PanelOptions; improved error handling in loadPlugins and fetchPluginsMetadata; refined usePlugins and useActivePlugins hooks.
app/packages/spaces/src/components/Panel.tsx Removed useRecoilValue for fos.currentModalUniqueId, simplified destructuring of panel, and removed shouldKeyComponent.
fiftyone/operators/operations.py Removed reload_on_navigation parameter from register_panel method signature.
fiftyone/operators/panel.py Removed reload_on_navigation parameter from __init__ and to_json methods in PanelConfig; updated documentation.

Possibly related PRs

  • add reload_on_navigation for modal panels #4846: This PR adds the reloadOnNavigation property to the panelOptions object in the registerPanel function, which is directly related to the removal of the same property in the main PR.
  • DashboardView #4557: Although this PR primarily focuses on the introduction of a new component for managing a dynamic dashboard layout, it also involves changes to the Panel component that may interact with the reloadOnNavigation functionality.
  • python panel and operator views tweaks and fixes #4580: This PR modifies the PanelConfig class to include a reload_on_navigation parameter, which aligns with the changes made in the main PR regarding the handling of navigation-related panel behavior.
  • add spaces context to operators #4902: This PR enhances the operator context by incorporating spaces and workspace functionalities, which may indirectly relate to how panels are registered and managed, including their navigation behavior.

Suggested labels

bug, app

Suggested reviewers

  • ritch
  • imanjra

🐇 In the code, we made a change,
To simplify and rearrange.
The reload option has hopped away,
To keep our panels light and sway.
With cleaner paths and smoother flow,
Our app will shine and surely grow! 🌟


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.

@sashankaryal sashankaryal force-pushed the remove-reload-on-navigation branch from dc01277 to 6e4f93b Compare October 31, 2024 17:24
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 (2)
app/packages/spaces/src/components/Panel.tsx (1)

43-43: Consider adding explicit type annotation for Component

While the destructuring is correctly simplified, adding an explicit type annotation would improve type safety and documentation.

-  const { component: Component } = panel;
+  const { component: Component }: { component: React.ComponentType<{panelNode: typeof node; dimensions: typeof dimensions}> } = panel;
fiftyone/operators/operations.py (1)

335-335: LGTM: Removal of reload_on_navigation parameter improves performance

The removal of this parameter aligns with the PR objectives to eliminate navigation-based reloading, which was causing performance issues. This change encourages better resource management by plugin authors.

Plugin authors should now implement their own resource lifecycle management strategies, such as:

  • Using React's useEffect for cleanup
  • Implementing explicit refresh mechanisms when needed
  • Properly scoping subscriptions to component lifecycle
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 35f8f61 and 6e4f93b.

📒 Files selected for processing (5)
  • app/packages/operators/src/Panel/register.tsx (0 hunks)
  • app/packages/plugins/src/index.ts (0 hunks)
  • app/packages/spaces/src/components/Panel.tsx (3 hunks)
  • fiftyone/operators/operations.py (1 hunks)
  • fiftyone/operators/panel.py (0 hunks)
💤 Files with no reviewable changes (3)
  • app/packages/operators/src/Panel/register.tsx
  • app/packages/plugins/src/index.ts
  • fiftyone/operators/panel.py
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/spaces/src/components/Panel.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 (2)
app/packages/spaces/src/components/Panel.tsx (2)

4-4: LGTM: Import changes align with functionality removal

The removal of useRecoilValue import while keeping useSetRecoilState is consistent with the elimination of modal unique ID subscription.


54-54: LGTM: Improved component rendering pattern

The removal of the key prop is a positive change as it:

  1. Eliminates unnecessary remounts that were triggered by modal unique ID changes
  2. Relies on the proper React.memo implementation for optimization
  3. Maintains clean props passing with only essential dependencies

This change aligns well with React best practices and the PR's performance improvement goals.

Copy link
Contributor

@benjaminpkane benjaminpkane 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 d586c4c into release/v1.0.2 Nov 2, 2024
13 checks passed
@benjaminpkane benjaminpkane deleted the remove-reload-on-navigation branch November 2, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants