-
Notifications
You must be signed in to change notification settings - Fork 557
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
New Embeddings CTA #4997
Conversation
WalkthroughThis pull request introduces three new React components: Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ComputeVisualizationButton
participant Panel
User->>ComputeVisualizationButton: Clicks button
ComputeVisualizationButton->>Panel: Trigger compute visualization event
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 propsEven 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 importsConsider 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 inconsistenciesThe 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 componentThe 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 statesThe component could benefit from additional error handling and loading states:
- Wrap
ComputeVisualizationButton
in an error boundary- Add loading state handling for async operations
- 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
📒 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
andcanSelect
- 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.tsxLength of output: 5356
export default function EmptyEmbeddings() { | ||
const theme = useTheme(); | ||
const secondaryBodyColor = theme.text.secondary; | ||
const isTeams = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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; | |
<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, | ||
}} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this 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
📒 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.
There was a problem hiding this 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
📒 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What changes are proposed in this pull request?
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?
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?
fiftyone
Python library changesSummary by CodeRabbit
Summary by CodeRabbit
New Features
ComputeVisualizationButton
component for computing visualizations.EmptyEmbeddings
component to provide user guidance when no embeddings are available.EmptyEmbeddings
component.Bug Fixes
Embeddings
component, improving user experience.