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

Modal tagging fixes #5514

Open
wants to merge 3 commits into
base: release/v1.3.1
Choose a base branch
from
Open

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Feb 24, 2025

What changes are proposed in this pull request?

Fixes a regression that recreates looker instances after tagging. Recreating the instance means "resetting" all state for the user, e.g. resetting playback for video, or any zoom level

Also removes an incorrect detach_frames flag for the updated samples tagging response. Fixes a blank first frame issue after tagging (see "Before" recording)

Before

Screen.Recording.2025-02-24.at.1.32.42.PM.mov

After

Screen.Recording.2025-02-24.at.1.32.18.PM.mov

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

Locally

Release Notes

  • Fixed sample updates after tagging in the modal

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

  • Refactor
    • Enhanced the modal interface by refining how sample data is updated and managed, ensuring smoother interactions and improved efficiency.
    • Streamlined video tagging by simplifying the pipeline configuration for frame processing, resulting in a more robust and consistent experience.

Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

Walkthrough

This pull request introduces modifications to two components. In the core modal component, a sampleRef is added using useRef to preserve the sample data, thereby avoiding unnecessary instance recreation. The useMemo hook now utilizes sampleRef.current and a new useEffect manages the sample update when colorScheme or looker changes. In the tag route, the detach_frames parameter is removed from the view._pipeline call, simplifying the pipeline setup for frame processing.

Changes

File Summary
app/.../use-looker.ts Introduces sampleRef using useRef to maintain sample data; updates useMemo to reference sampleRef.current; adds a new useEffect to handle sample updates.
fiftyone/.../tag.py Removes the detach_frames parameter from the view._pipeline method call in the Tag class while retaining the attach_frames parameter.

Sequence Diagram(s)

sequenceDiagram
    participant C as Component
    participant UL as useLooker
    participant SR as sampleRef
    participant L as Looker
    C->>UL: Render with sample, colorScheme
    UL->>SR: Update current with sample data
    UL->>UL: Execute useMemo (using SR.current)
    alt On colorScheme or looker change
        UL->>L: Call updateSample(sample.sample)
    end
Loading

Possibly related PRs

Suggested labels

bug, app

Suggested reviewers

  • sashankaryal

Poem

I'm hopping through the code with glee,
A rabbit's dance in tech, wild and free.
Sample data now flows without a glitch,
With useRef and hooks, it's a neat little switch.
🐰🥕 Code blooms like spring, so bright and fair,
Each update a hop in the digital air.
Let's celebrate with hops and flair!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2a660c and a91921a.

📒 Files selected for processing (2)
  • app/packages/core/src/components/Modal/use-looker.ts (1 hunks)
  • fiftyone/server/routes/tag.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: Review the Typescript and React code for co...

**/*.{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/use-looker.ts
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test / test-python (ubuntu-latest-m, 3.11)
  • GitHub Check: test / test-python (ubuntu-latest-m, 3.10)
  • GitHub Check: test / test-app
  • GitHub Check: lint / eslint
  • GitHub Check: e2e / test-e2e
  • GitHub Check: build / build
  • GitHub Check: build
🔇 Additional comments (4)
fiftyone/server/routes/tag.py (1)

98-98: LGTM! Removal of detach_frames parameter aligns with PR objectives.

The removal of the detach_frames parameter from view._pipeline call is a valid fix for the blank first frame issue mentioned in the PR objectives. The attach_frames parameter is correctly retained and set based on the video media type.

app/packages/core/src/components/Modal/use-looker.ts (3)

32-37: LGTM! Good use of useRef to prevent unnecessary instance recreation.

The addition of sampleRef using useRef is a valid optimization that prevents unnecessary looker instance recreation. The comments clearly explain the purpose of this change.


38-45: LGTM! Proper usage of useMemo with useRef.

The modification to use sampleRef.current in useMemo and removing sample from the dependency array is correct. This change effectively prevents unnecessary looker recreations while maintaining proper memoization.


47-54: LGTM! Well-structured useEffect for handling sample updates.

The new useEffect hook correctly handles sample updates when colorScheme or looker changes, while properly skipping the initial render using initialRef. The dependency array is complete and accurate.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.

3 participants