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 video tooltip #4916

Merged
merged 3 commits into from
Oct 11, 2024
Merged

Fix video tooltip #4916

merged 3 commits into from
Oct 11, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Oct 10, 2024

What changes are proposed in this pull request?

Adds the tooltip back to the modal video looker. Also fixes changing the color scheme for video lookers. See recording for current issue

Screen.Recording.2024-10-11.at.9.59.48.AM.mov

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

Summary by CodeRabbit

  • New Features

    • Enhanced state management for the modal looker, improving integration with the modal context.
    • Improved video frame management and playback functionality.
    • Added support for tracking multiple buffer ranges in video playback.
  • Bug Fixes

    • Simplified the ModalLookerNoTimeline component, removing unused imports and unnecessary state management.
    • Streamlined state management in the ColorFooter component.
  • Documentation

    • Updated import statements for clarity and consistency.

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

coderabbitai bot commented Oct 10, 2024

Walkthrough

The changes in this pull request involve modifications to the ModalLooker.tsx, use-looker.ts, ColorFooter.tsx, video.ts, and state.ts files. The ModalLooker.tsx file has been simplified by removing unused imports and state management hooks. The use-looker.ts file has been updated to enhance state management through the integration of Recoil's useSetRecoilState and the useModalContext. The ColorFooter.tsx file has transitioned to a simpler state management approach using useRecoilValue. Additionally, the video.ts file has introduced a new setReader method and refined frame management logic, while state.ts has added a new buffers property to the VideoState interface.

Changes

File Path Change Summary
app/packages/core/src/components/Modal/ModalLooker.tsx Removed unused imports and simplified ModalLookerNoTimeline component; removed useEffect hooks.
app/packages/core/src/components/Modal/use-looker.ts Added useSetRecoilState for state management; introduced new effects for setting modal looker state.
app/packages/core/src/components/ColorModal/ColorFooter.tsx Changed state management from useRecoilState to useRecoilValue; updated useEffect for activeColorEntry.
app/packages/looker/src/lookers/video.ts Added setReader method; modified updateSample and pluckOverlays methods for better frame management.
app/packages/looker/src/state.ts Added buffers property to VideoState interface for enhanced state management of video playback.

Possibly related PRs

  • timeline fix: loadrange in imavid #4857: The changes in the ImaVidLooker.tsx file related to loading buffer ranges and simplifying state management are directly connected to the modifications in the ModalLooker.tsx file, which also involves handling looker instances and state management.
  • Video playback #4878: The addition of video looker support in the modal timeline is relevant to the changes in ModalLooker.tsx, which now conditionally renders VideoLookerReact based on the dataset type, enhancing the integration of video functionality within the modal context.

Suggested labels

enhancement

Suggested reviewers

  • sashankaryal
  • ritch

Poem

In the modal's glow, we hop and play,
Simplified paths light up the way.
With lookers in sync, our data's in tune,
A dance of components, beneath the moon.
Hoppity joy, let changes unfold,
In the world of code, new stories are told! 🐇✨


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 requested a review from a team October 10, 2024 21:56
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/core/src/components/Modal/use-looker.ts (2)

106-108: LGTM: State management hooks added correctly

The new Recoil state setter setModalLooker and the context hook setActiveLookerRef are correctly implemented. They follow React and Recoil best practices for state management.

Consider adding a blank line between these two declarations for improved readability:

 const setModalLooker = useSetRecoilState(fos.modalLooker);
+
 const { setActiveLookerRef } = useModalContext();

114-118: LGTM with suggestion: Effect for updating activeLookerRef

This effect correctly updates the activeLookerRef when the looker is defined. The null check is a good practice.

Consider improving type safety by replacing the type assertion with a type guard:

useEffect(() => {
  if (looker && 'isLooker' in looker) {
    setActiveLookerRef(looker);
  }
}, [looker, setActiveLookerRef]);

This assumes there's an 'isLooker' property or method on the Lookers type. If not, consider adding one or using a different type guard that fits your specific Looker type.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 233689b and 4ed23c9.

📒 Files selected for processing (2)
  • app/packages/core/src/components/Modal/ModalLooker.tsx (2 hunks)
  • app/packages/core/src/components/Modal/use-looker.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/core/src/components/Modal/ModalLooker.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/use-looker.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 (5)
app/packages/core/src/components/Modal/ModalLooker.tsx (2)

4-5: Improved import statements

The changes in the import statements reflect a simplification of the component's logic. Removing unused hooks and adding useMemo suggests an optimization in the code, which aligns with React best practices.


30-30: Simplified ModalLookerNoTimeline component

The ModalLookerNoTimeline component has been significantly simplified by removing useEffect hooks and state management logic. This change aligns with React best practices by making the component more focused and potentially moving state management to a more appropriate location.

However, it's important to ensure that the functionality previously handled by the removed code is now managed correctly elsewhere in the application.

To verify that the removed functionality is handled elsewhere, please run the following script:

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

4-4: LGTM: Import statements updated correctly

The new imports for useSetRecoilState from Recoil and useModalContext from the local hooks file are correctly added. These additions align with the new state management functionality introduced in the hook.

Also applies to: 7-7


110-112: LGTM: Effect for updating modalLooker state

This effect correctly updates the modalLooker state using the setModalLooker function whenever the looker changes. The dependencies array is properly set, including both looker and setModalLooker.


106-118: Overall changes enhance modal looker state management

The additions to the useLooker hook improve the integration of the looker with the modal's state management and context. These changes align well with the PR objective of fixing the video tooltip.

Key improvements:

  1. Synchronization of the looker state with Recoil state
  2. Integration with the modal context

These enhancements should lead to better state consistency and improved tooltip functionality for video lookers.

minhtuev
minhtuev previously approved these changes Oct 10, 2024
Copy link
Contributor

@minhtuev minhtuev left a comment

Choose a reason for hiding this comment

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

LGTM!

findtopher
findtopher previously approved these changes Oct 11, 2024
Copy link
Member

@findtopher findtopher left a comment

Choose a reason for hiding this comment

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

😋

Copy link
Member

@findtopher findtopher left a comment

Choose a reason for hiding this comment

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

Now with more lint!

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/looker/src/state.ts (1)

344-344: LGTM! Consider adding a comment for clarity.

The addition of the buffers property to the VideoState interface is a good enhancement for managing multiple buffer ranges in video playback. The use of Readonly ensures immutability, which is excellent for state management.

Consider adding a brief comment to explain the purpose of the buffers property:

/**
 * Represents the buffered ranges of the video.
 * Each buffer range is a tuple of [start, end] in seconds.
 */
buffers: Buffers;

This comment would provide clarity for other developers working with this interface in the future.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1198eb2 and e9267c5.

📒 Files selected for processing (2)
  • app/packages/looker/src/lookers/video.ts (6 hunks)
  • app/packages/looker/src/state.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/looker/src/lookers/video.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/looker/src/state.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.

Copy link
Contributor

@lanzhenw lanzhenw left a comment

Choose a reason for hiding this comment

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

Screenshot 2024-10-11 at 9 12 13 AM

Nice clean ups. color by value mode in the frame still have a minor issue. You can address that later.

Comment on lines +28 to 30
() => foq.subscribe((_, { set }) => set(activeColorEntry, null)),
[]
);
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@benjaminpkane
Copy link
Contributor Author

Nice clean ups. color by value mode in the frame still have a minor issue. You can address that later.

Those are label tags. None of these labels have tags road sign or vehicle, so the coloring shown makes sense, I think. If there was another issue, let's make a ticket

@benjaminpkane benjaminpkane merged commit 2adc94e into release/v1.0.1 Oct 11, 2024
11 checks passed
@benjaminpkane benjaminpkane deleted the bugfix/video-tooltip branch October 11, 2024 14:23
@lanzhenw
Copy link
Contributor

Screenshot 2024-10-11 at 9 28 46 AM

It's working. I selected the wrong field 😅

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.

4 participants