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

New Embeddings CTA #4997

Merged
merged 5 commits into from
Oct 30, 2024
Merged

New Embeddings CTA #4997

merged 5 commits into from
Oct 30, 2024

Conversation

ritch
Copy link
Contributor

@ritch ritch commented Oct 28, 2024

What changes are proposed in this pull request?

image
image

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

Opening the embeddings panel locally. No automated tests.

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

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

    • Introduced the ComputeVisualizationButton component for computing visualizations.
    • Added the EmptyEmbeddings component to provide user guidance when no embeddings are available.
    • Included content variations for open-source and team functionalities within the EmptyEmbeddings component.
  • Bug Fixes

    • Simplified the loading state handling in the Embeddings component, improving user experience.
    • Updated the icon for the "Embeddings" panel to enhance visual consistency.

Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

Walkthrough

This pull request introduces three new React components: ComputeVisualizationButton, EmptyEmbeddings, and several functions including OSSContent, ComputeVisContent, and ViewDocsButton. The ComputeVisualizationButton triggers a panel event for computing visualizations. The Embeddings component has been modified to incorporate the ComputeVisualizationButton and the new EmptyEmbeddings component, which replaces previous loading states. The EmptyEmbeddings component provides user information about embeddings, with conditional rendering based on the hasComputeVisualization boolean.

Changes

File Path Change Summary
app/packages/embeddings/src/ComputeVisualizationButton.tsx New component ComputeVisualizationButton added.
app/packages/embeddings/src/Embeddings.tsx Modified to include ComputeVisualizationButton and EmptyEmbeddings. Removed loading state.
app/packages/embeddings/src/EmptyEmbeddings.tsx New component EmptyEmbeddings added, along with functions OSSContent, ComputeVisContent, and ViewDocsButton.
app/packages/embeddings/src/index.ts Icon updated from ScatterPlotIcon to WorkspacesIcon in component registration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ComputeVisualizationButton
    participant Panel

    User->>ComputeVisualizationButton: Clicks button
    ComputeVisualizationButton->>Panel: Trigger compute visualization event
Loading

🐰 "In the garden where ideas bloom,
A button now dispels the gloom.
With visuals to compute and share,
Empty spaces filled with care.
Hop along, let's celebrate,
New features make our work first-rate!" 🐇


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.

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: 6

🧹 Outside diff range and nitpick comments (6)
app/packages/embeddings/src/ComputeVisualizationButton.tsx (1)

7-7: Add TypeScript interface for component props

Even though the component currently doesn't accept props, it's good practice to explicitly define the interface for maintainability and documentation.

+interface ComputeVisualizationButtonProps {}
+
-export default function ComputeVisualizationButton() {
+export default function ComputeVisualizationButton({}: ComputeVisualizationButtonProps) {
app/packages/embeddings/src/EmptyEmbeddings.tsx (4)

1-5: Add TypeScript types and organize imports

Consider adding TypeScript types and organizing imports by category:

+ import { FC } from 'react';
  import { Box, Button, Link, Typography, Grid } from "@mui/material";
+ import { OpenInNewIcon, ScatterPlotIcon } from "@mui/icons-material";
- import ScatterPlotIcon from "@mui/icons-material/ScatterPlot";
- import OpenInNewIcon from "@mui/icons-material/OpenInNew";
  import { useTheme } from "@fiftyone/components";
  import ComputeVisualizationButton from "./ComputeVisualizationButton";

+ interface EmptyEmbeddingsProps {}

71-84: Resolve button styling inconsistencies

The button uses both color="warning" and custom sx styling which might lead to conflicts. Consider using one approach:

  <Button
    variant="contained"
-   color="warning"
    href="https://docs.voxel51.com/user_guide/app.html#embeddings-panel"
    target="_blank"
    rel="noopener noreferrer"
    sx={{
      backgroundColor: theme.primary.main,
      color: theme.text.primary,
+     '&:hover': {
+       backgroundColor: theme.primary.dark,
+     },
    }}
    endIcon={<OpenInNewIcon />}
  >

90-100: Simplify TeamsContent component

The component has unused variables and unnecessary wrapper elements:

- function TeamsContent() {
-   const theme = useTheme();
-   const secondaryBodyColor = theme.text.secondary;
-   return (
-     <>
-       <Grid item>
-         <ComputeVisualizationButton />
-       </Grid>
-     </>
-   );
- }
+ const TeamsContent = () => (
+   <Grid item>
+     <ComputeVisualizationButton />
+   </Grid>
+ );

7-58: Consider adding error boundaries and loading states

The component could benefit from additional error handling and loading states:

  1. Wrap ComputeVisualizationButton in an error boundary
  2. Add loading state handling for async operations
  3. Consider adding retry mechanisms for failed computations

Would you like me to provide an example implementation of these improvements?

app/packages/embeddings/src/Embeddings.tsx (1)

142-144: Consider adding accessibility attributes to the ComputeVisualizationButton.

While the placement is correct, consider enhancing the button's accessibility by ensuring it has proper ARIA attributes and keyboard navigation support.

-            <ComputeVisualizationButton />
+            <ComputeVisualizationButton 
+              aria-label="Compute visualization"
+              role="button"
+            />
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cf5a33d and f1ade98.

📒 Files selected for processing (3)
  • app/packages/embeddings/src/ComputeVisualizationButton.tsx (1 hunks)
  • app/packages/embeddings/src/Embeddings.tsx (3 hunks)
  • app/packages/embeddings/src/EmptyEmbeddings.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
app/packages/embeddings/src/ComputeVisualizationButton.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/embeddings/src/Embeddings.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/embeddings/src/EmptyEmbeddings.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/embeddings/src/Embeddings.tsx (2)

26-27: LGTM! Import statements follow React conventions.

The new component imports are properly organized and follow naming conventions.


160-160: Verify loading state handling in EmptyEmbeddings.

The simplified return statement improves code clarity, but we should ensure that loading states are properly handled in the EmptyEmbeddings component.

✅ Verification successful

Loading states are properly handled in parent component

After reviewing both the EmptyEmbeddings component and its parent Embeddings component, I can confirm that:

  • EmptyEmbeddings is a static component that displays when there's no data to show (canSelect is false)
  • Loading states are handled in the parent component through:
    • labelSelector.isLoading for label selection
    • Conditional rendering of components based on showPlot and canSelect
  • The simplified return statement is correct as EmptyEmbeddings doesn't need to handle loading states itself
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for loading state handling in EmptyEmbeddings
ast-grep --pattern 'function EmptyEmbeddings() {
  $$$
  loading $$$
  $$$
}'

# Check if Loading component is used
rg -A 5 "Loading" "app/packages/embeddings/src/EmptyEmbeddings.tsx"

Length of output: 145


Script:

#!/bin/bash
# Let's first check if the file exists and see its content
cat app/packages/embeddings/src/EmptyEmbeddings.tsx

# As a backup, let's search for EmptyEmbeddings component definition
ast-grep --pattern 'const EmptyEmbeddings = $$$'

# Also search for function declaration
ast-grep --pattern 'function EmptyEmbeddings($$$) {
  $$$
}'

Length of output: 7000


Script:

#!/bin/bash
# Let's check the parent component to understand how loading is handled
cat app/packages/embeddings/src/Embeddings.tsx

Length of output: 5356

app/packages/embeddings/src/ComputeVisualizationButton.tsx Outdated Show resolved Hide resolved
app/packages/embeddings/src/ComputeVisualizationButton.tsx Outdated Show resolved Hide resolved
app/packages/embeddings/src/ComputeVisualizationButton.tsx Outdated Show resolved Hide resolved
Comment on lines 7 to 11
export default function EmptyEmbeddings() {
const theme = useTheme();
const secondaryBodyColor = theme.text.secondary;
const isTeams = false;

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace hard-coded flag with prop or context

The isTeams flag should not be hard-coded as it determines component behavior. Consider using a prop or context value.

- export default function EmptyEmbeddings() {
+ interface EmptyEmbeddingsProps {
+   isTeams?: boolean;
+ }
+ 
+ export default function EmptyEmbeddings({ isTeams = false }: EmptyEmbeddingsProps) {
  const theme = useTheme();
  const secondaryBodyColor = theme.text.secondary;
-  const isTeams = false;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export default function EmptyEmbeddings() {
const theme = useTheme();
const secondaryBodyColor = theme.text.secondary;
const isTeams = false;
interface EmptyEmbeddingsProps {
isTeams?: boolean;
}
export default function EmptyEmbeddings({ isTeams = false }: EmptyEmbeddingsProps) {
const theme = useTheme();
const secondaryBodyColor = theme.text.secondary;

Comment on lines 13 to 34
<Box
sx={{
height: "calc(100% - 32px)",
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "#262626",
margin: 2,
}}
>
<Box
sx={{
width: "100%",
maxWidth: "510px",
display: "flex",
flexDirection: "column",
alignItems: "center",
textAlign: "center",
padding: 4,
borderRadius: 2,
}}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use theme colors instead of hard-coded values

Replace hard-coded colors with theme values for consistency and maintainability.

  <Box
    sx={{
      height: "calc(100% - 32px)",
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
-     backgroundColor: "#262626",
+     backgroundColor: theme.background.secondary,
      margin: 2,
    }}
  >

Committable suggestion was skipped due to low confidence.

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: 3

🧹 Outside diff range and nitpick comments (4)
app/packages/embeddings/src/EmptyEmbeddings.tsx (4)

9-18: Add TypeScript types to improve code clarity and maintainability.

The custom hook would benefit from explicit TypeScript types for better maintainability and type safety.

-const useFirstExistingUri = (uris: string[]) => {
+interface OperatorCheckResult {
+  firstExistingUri: string | undefined;
+  exists: boolean;
+}
+
+const useFirstExistingUri = (uris: string[]): OperatorCheckResult => {

20-28: Add TypeScript interface for component props.

The component should have a proper TypeScript interface defined for its props, even if currently empty, to maintain consistency and allow for future extensibility.

+interface EmptyEmbeddingsProps {}
+
-export default function EmptyEmbeddings() {
+export default function EmptyEmbeddings({}: EmptyEmbeddingsProps) {

69-69: Remove empty Grid item.

The empty Grid item serves no purpose and should be removed.

-          <Grid item />

123-133: Clean up unused variables and simplify component structure.

The component has unused variables and unnecessary Fragment wrapper.

 function TeamsContent() {
-  const theme = useTheme();
-  const secondaryBodyColor = theme.text.secondary;
   return (
-    <>
-      <Grid item>
-        <ComputeVisualizationButton />
-      </Grid>
-    </>
+    <Grid item>
+      <ComputeVisualizationButton />
+    </Grid>
   );
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f1ade98 and ee792ee.

📒 Files selected for processing (2)
  • app/packages/embeddings/src/EmptyEmbeddings.tsx (1 hunks)
  • app/packages/embeddings/src/index.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/packages/embeddings/src/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/embeddings/src/EmptyEmbeddings.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.

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: 4

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ee792ee and 9ef86c9.

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

Copy link
Contributor

@imanjra imanjra left a comment

Choose a reason for hiding this comment

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

LGTM

@ritch ritch merged commit b6e8496 into develop Oct 30, 2024
10 of 11 checks passed
@ritch ritch deleted the embeddings_cta branch October 30, 2024 01:35
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2024
7 tasks
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