-
Notifications
You must be signed in to change notification settings - Fork 603
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
Improve colorscheme ux #4763
Improve colorscheme ux #4763
Conversation
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.
@coderabbitai review
@coderabbitai review |
Actions performedReview triggered.
|
WalkthroughThe changes involve updates to the documentation and code related to color schemes in datasets. Key modifications include the introduction of a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Dataset
participant ColorScheme
User->>Dataset: Configure dataset with color scheme
Dataset->>ColorScheme: Instantiate ColorScheme with color_by="value"
ColorScheme->>Dataset: Assign colors based on dataset values
Dataset->>User: Display dataset with updated color scheme
Possibly related PRs
Suggested labels
Suggested reviewers
Recent review detailsConfiguration used: .coderabbit.yaml Files selected for processing (1)
Additional comments not posted (1)
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: 0
Outside diff range, codebase verification and nitpick comments (1)
docs/source/user_guide/using_datasets.rst (1)
462-462
: Consider using a more specific variable name.Instead of
color_by="value"
, consider using a more descriptive name likecolor_by="mask_target_value"
to clarify what thevalue
represents.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- docs/source/user_guide/app.rst (1 hunks)
- docs/source/user_guide/using_datasets.rst (1 hunks)
- fiftyone/core/odm/dataset.py (6 hunks)
Files skipped from review due to trivial changes (1)
- docs/source/user_guide/app.rst
Files skipped from review as they are similar to previous changes (1)
- fiftyone/core/odm/dataset.py
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: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- docs/source/user_guide/using_datasets.rst (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- docs/source/user_guide/using_datasets.rst
aae922b
to
a673d46
Compare
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, codebase verification and nitpick comments (9)
app/packages/core/src/components/ColorModal/controls/IdxColorList.tsx (1)
36-36
: Approve changes to validation logic and suggest placeholder text refinement.The changes to make the
onValidate
property required and the integration of validation logic into theNumberInput
component are positive, enhancing the robustness and clarity of the component. The updated placeholder text "integer (>0)" is more inclusive of valid input values but could be further refined to "Enter a positive integer" for better clarity.Also applies to: 170-170, 180-180, 189-189
app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx (1)
151-154
: Approve new validation function and suggest placeholder text improvement.The introduction of the
onValidateNumber
function is a positive change, centralizing and clarifying the validation logic for float inputs. However, the simplified placeholder text "float" could be improved to "Enter a float between 0 and 1" to provide better guidance to users about the expected input range.Also applies to: 175-175, 177-178
app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx (3)
Line range hint
1-1
: Documentation and TODOs are missing.The file lacks a comprehensive documentation header explaining the purpose and functionality of the component. Adding a detailed comment at the beginning of the file would improve maintainability and understandability.
Line range hint
6-6
: Consider using TypeScript for better type safety.The file uses plain JavaScript. Converting this to TypeScript could enhance type safety and reduce potential runtime errors, especially in a complex state management scenario like this one.
Enhance Validation Logic in
validateIntMask
The
validateIntMask
function currently checks if the input is a positive integer but does not handle values above 255. Given the removal of themax
prop, it's important to update this function to include an upper limit check to prevent potential bugs.
- File:
app/packages/core/src/components/ColorModal/utils.ts
- Function:
validateIntMask
- Suggested Enhancement: Add a condition to ensure the value does not exceed 255.
Analysis chain
Line range hint
6-6
: Validation logic might need enhancement.Given the removal of the
max
prop, it's crucial to ensure that the validation logic (validateIntMask
) adequately handles cases where the input might exceed expected limits. This change could potentially introduce bugs if the validation logic is not robust enough.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check the implementation of `validateIntMask` to ensure it handles values above 255. # Test: Search for the function implementation. Expect: Handling of values above 255. ast-grep --lang javascript --pattern $'function validateIntMask($_) { $$$ }'Length of output: 79
Script:
#!/bin/bash # Search for the term `validateIntMask` across the entire codebase to locate its definition or usage. rg 'validateIntMask' -A 5Length of output: 3191
app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx (3)
Line range hint
1-1
: Documentation and TODOs are missing.The file lacks a comprehensive documentation header explaining the purpose and functionality of the component. Adding a detailed comment at the beginning of the file would improve maintainability and understandability.
Line range hint
6-6
: Consider using TypeScript for better type safety.The file uses plain JavaScript. Converting this to TypeScript could enhance type safety and reduce potential runtime errors, especially in a complex state management scenario like this one.
Enhance Validation Logic in
validateIntMask
The
validateIntMask
function currently does not handle cases where the input value exceeds 255. To prevent potential bugs, consider enhancing the validation logic to include a check for values above 255.
- File:
app/packages/core/src/components/ColorModal/utils.ts
- Function:
validateIntMask
Analysis chain
Line range hint
6-6
: Validation logic might need enhancement.Given the removal of the
max
prop, it's crucial to ensure that the validation logic (validateIntMask
) adequately handles cases where the input might exceed expected limits. This change could potentially introduce bugs if the validation logic is not robust enough.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check the implementation of `validateIntMask` to ensure it handles values above 255. # Test: Search for the function implementation. Expect: Handling of values above 255. ast-grep --lang javascript --pattern $'function validateIntMask($_) { $$$ }'Length of output: 79
Script:
#!/bin/bash # Search for the term `validateIntMask` across the codebase to locate its definition or references. rg 'validateIntMask'Length of output: 580
Script:
#!/bin/bash # Extract the implementation of `validateIntMask` from utils.ts to analyze its logic. rg -A 10 'export const validateIntMask' app/packages/core/src/components/ColorModal/utils.tsLength of output: 490
app/packages/core/src/components/Common/Input.tsx (1)
1-1
: Documentation and TODOs are missing.The file lacks a comprehensive documentation header explaining the purpose and functionality of the component. Adding a detailed comment at the beginning of the file would improve maintainability and understandability.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (11)
- app/packages/core/src/components/ColorModal/colorPalette/Colorscale.tsx (7 hunks)
- app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx (1 hunks)
- app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx (1 hunks)
- app/packages/core/src/components/ColorModal/controls/IdxColorList.tsx (4 hunks)
- app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx (2 hunks)
- app/packages/core/src/components/ColorModal/utils.ts (1 hunks)
- app/packages/core/src/components/Common/Input.tsx (3 hunks)
- docs/source/user_guide/app.rst (1 hunks)
- docs/source/user_guide/using_datasets.rst (2 hunks)
- fiftyone/core/odm/dataset.py (6 hunks)
- fiftyone/core/plots/plotly.py (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- docs/source/user_guide/app.rst
- docs/source/user_guide/using_datasets.rst
- fiftyone/core/odm/dataset.py
Additional context used
Path-based instructions (7)
app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.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/ColorModal/colorPalette/FieldsMaskTarget.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/Common/Input.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/ColorModal/utils.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.app/packages/core/src/components/ColorModal/controls/IdxColorList.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/ColorModal/controls/ManualColorScaleList.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/ColorModal/colorPalette/Colorscale.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.
Biome
app/packages/core/src/components/Common/Input.tsx
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (4)
app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx (1)
Line range hint
6-6
: Use of multiple Recoil hooks.The component uses multiple Recoil hooks (
useRecoilValue
,useSetSessionColorScheme
) effectively to manage global state. This is a good practice in Recoil-based applications, ensuring that the component reacts to state changes efficiently.app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx (1)
Line range hint
6-6
: Use of multiple Recoil hooks.The component uses multiple Recoil hooks (
useRecoilValue
,useRecoilState
) effectively to manage global state. This is a good practice in Recoil-based applications, ensuring that the component reacts to state changes efficiently.app/packages/core/src/components/Common/Input.tsx (1)
159-239
: Robust error handling added toNumberInput
.The addition of error handling logic in the
NumberInput
component is a significant improvement. It enhances the user experience by providing immediate feedback on input validity. The implementation ofuseState
for managing the error state and thehandleBlur
function for onBlur event handling are well-integrated.Tools
Biome
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
fiftyone/core/plots/plotly.py (1)
1523-1523
: Review of_get_continuous_color
function sorting addition.The addition of sorting to the
colorscale
list ensures that the colors are processed in ascending order based on the first element of each tuple. This is crucial for the correct functioning of the color interpolation logic that follows, ensuring that the colors are interpolated correctly based on the sorted order.This change aligns with the PR's objective to enhance the clarity and correctness of color handling in plots, particularly ensuring that the colorscale is correctly applied. The sorting logic is implemented efficiently and should not introduce significant overhead.
bf29aca
to
848abfc
Compare
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: 0
Outside diff range and nitpick comments (1)
app/packages/core/src/components/Common/Input.tsx (1)
169-176
: LGTM, but consider using optional chaining for better safety.The code changes are approved. The
handleBlur
function is implemented correctly to validate the input and update the error state.However, the static analysis tool suggests using optional chaining for
onBlur
to enhance code safety and readability. This change would prevent potential runtime errors whenonBlur
is undefined.Apply this diff to implement optional chaining:
- onBlur && onBlur(); + onBlur?.();Tools
Biome
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (11)
- app/packages/core/src/components/ColorModal/colorPalette/Colorscale.tsx (7 hunks)
- app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx (1 hunks)
- app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx (1 hunks)
- app/packages/core/src/components/ColorModal/controls/IdxColorList.tsx (4 hunks)
- app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx (2 hunks)
- app/packages/core/src/components/ColorModal/utils.ts (1 hunks)
- app/packages/core/src/components/Common/Input.tsx (3 hunks)
- docs/source/user_guide/app.rst (1 hunks)
- docs/source/user_guide/using_datasets.rst (2 hunks)
- fiftyone/core/odm/dataset.py (6 hunks)
- fiftyone/core/plots/plotly.py (1 hunks)
Files skipped from review as they are similar to previous changes (8)
- app/packages/core/src/components/ColorModal/colorPalette/Colorscale.tsx
- app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx
- app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx
- app/packages/core/src/components/ColorModal/controls/IdxColorList.tsx
- app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx
- docs/source/user_guide/app.rst
- docs/source/user_guide/using_datasets.rst
- fiftyone/core/plots/plotly.py
Additional context used
Path-based instructions (2)
app/packages/core/src/components/Common/Input.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/ColorModal/utils.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.
Biome
app/packages/core/src/components/Common/Input.tsx
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (14)
app/packages/core/src/components/Common/Input.tsx (4)
159-167
: LGTM!The code changes are approved. The introduction of the
error
state variable and the construction of the error message based on themin
andmax
props are implemented correctly. This will provide useful feedback to the user about the input constraints.
178-184
: LGTM!The code changes are approved. The
useEffect
hook is implemented correctly to validate the input whenever thevalue
orvalidator
changes and update theerror
state accordingly. This ensures that the error message is always in sync with the current input value and validation rules.
223-223
: The suggestion to use optional chaining foronKeyDown
is valid but has already been covered in a previous review comment. Please refer to that comment for the recommended changes.Tools
Biome
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
232-232
: The suggestion to use optional chaining foronFocus
is valid but has already been covered in a previous review comment. Please refer to that comment for the recommended changes.Tools
Biome
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
app/packages/core/src/components/ColorModal/utils.ts (1)
205-206
: ** Address the concerns raised in the previous review comment.**The past review comment is still valid as the validation logic has been further simplified without addressing the following concerns:
- The function now accepts a broader range of input types (
number | string | undefined
), which increases flexibility but could lead to issues with type safety if non-numeric strings are passed. Consider adding explicit type checks to ensure the input can be reliably converted to a number.- The previous validation criteria, which required the value to be within the range of 1 to 255, have been removed. Clarify if this change is intended or if the range check needs to be added back.
Apply this diff to address the concerns:
-export const validateIntMask = (value: number | string | undefined) => { - if (!value || !Number.isInteger(Number(value)) || Number(value) <= 0) { +export const validateIntMask = (value: number | string | undefined) => { + if (typeof value !== 'number' && typeof value !== 'string') { + return false; + } + const numValue = Number(value); + if (!Number.isInteger(numValue) || numValue < 1 || numValue > 255) { return false; } return true;fiftyone/core/odm/dataset.py (9)
179-179
: LGTM!The code change is approved. The
color_by
parameter has been updated to indicate that colors should be assigned based on dataset values.
194-194
: LGTM!The code change is approved. The comment provides useful guidance to users about not defining
intTarget
0 inmaskTargetsColors
.
211-211
: LGTM!The code change is approved. The comment provides useful guidance to users about the valid range for
value
incolorscales
.
225-225
: LGTM!The code change is approved. The comment provides useful guidance to users about not defining
intTarget
0 indefault_mask_targets_colors
.
317-319
: LGTM!The code change is approved. Calling the
clean
method during initialization ensures that theColorScheme
instance is validated.
325-331
: LGTM!The code change is approved. The
clean
method ensures that various properties of theColorScheme
instance are validated, includingcolor_by
,opacity
, and mask target colors.
333-337
: LGTM!The code change is approved. The
_validate_color_by
method ensures thatcolor_by
must be one of the specified values.
339-341
: LGTM!The code change is approved. The
_validate_opacity
method ensures thatopacity
must be between 0 and 1.
343-455
: LGTM!The code changes are approved. The added validation methods, including
_validate_default_mask_targets_colors
,_validate_fields
,_validate_mask_targets
,_validate_colorscales
,_validate_default_colorscale
, and_validate_single_colorscale
, enhance the robustness and clarity of the color scheme configuration, making it easier for users to understand and utilize the color settings effectively.These methods ensure that various properties of the
ColorScheme
instance are validated, such as:
- Default mask target colors must have positive integer
intTarget
values.- Fields must have a
path
specified.- Mask targets must have positive integer
intTarget
values.- Colorscales must be a list or None.
- Default colorscale must be a dict with either a
name
or alist
.- Single colorscale must be a dict with either a
name
or alist
, and thelist
must have colors defined for 0 and 1.The added validation logic improves the user experience by providing immediate error messages when invalid arguments are input, preventing confusion and ensuring correct usage.
@@ -315,6 +316,137 @@ def _id(self): | |||
def _id(self, value): | |||
self.id = str(value) | |||
|
|||
def _validate(self): |
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.
@lanzhenw I changed this to a private _validate()
method because if we were to implement it as clean()
, it would cause it to become impossible to load an existing dataset that happens to have an invalid color scheme:
dataset = fo.load_dataset("dataset-with-invalid-color-scheme")
# ValueError: color_by field "foo" is invalid
The only backwards compatible thing I can think of to do is provide a method that users can manually call to check if their color scheme is valid or not.
- ``color``: a color string | ||
|
||
Note that the pixel value ``0`` is a reserved "background" class |
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.
@lanzhenw if this is not already the case, can you update the frontend so that if maskTargets are provided that contain target=0
, it will simply ignore the value rather than crashing?
Here's how this is documented for Segmentation
fields:
Note that it doesn't say that target=0
is not allowed. It just says that this is a special value that is always rendered as invisible in the App, which means that if the user provided 0: "background"
in their mask targets, then they won't see background
in the tooltip when hovering over 0 pixels in the App.
The consistent behavior for color schemes would be to silently ignore a color if it is provided for pixel value 0.
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.
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.
The backend aspects of this LGTM to me now, but I need to defer to @benjaminpkane for review of the frontend aspects (I have not tested this locally)
Also seeking confirmation from @lanzhenw that the App will indeed gracefully ignore target=0
mask targets if provided.
app/packages/core/src/components/ColorModal/colorPalette/Colorscale.tsx
Outdated
Show resolved
Hide resolved
app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx
Outdated
Show resolved
Hide resolved
4f664a9
to
2b59cc7
Compare
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: 0
Outside diff range and nitpick comments (1)
app/packages/core/src/components/Common/Input.tsx (1)
187-239
: Rendering logic looks good! Consider using optional chaining for better safety.The rendering logic is correctly modified to include the
ErrorMessage
component for displaying error messages. The conditional rendering based on theerror
state is implemented correctly.The static analysis tool suggests using optional chaining at several places to enhance code safety and readability. This change would prevent potential runtime errors when accessing properties on undefined objects.
Apply this diff to implement optional chaining:
- onBlur && onBlur(); + onBlur?.(); - onKeyDown && onKeyDown(e); + onKeyDown?.(e); - onFocus && onFocus(); + onFocus?.();Tools
Biome
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (11)
- app/packages/core/src/components/ColorModal/colorPalette/Colorscale.tsx (6 hunks)
- app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx (0 hunks)
- app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx (0 hunks)
- app/packages/core/src/components/ColorModal/controls/IdxColorList.tsx (4 hunks)
- app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx (2 hunks)
- app/packages/core/src/components/ColorModal/utils.ts (1 hunks)
- app/packages/core/src/components/Common/Input.tsx (3 hunks)
- docs/source/user_guide/app.rst (1 hunks)
- docs/source/user_guide/using_datasets.rst (1 hunks)
- fiftyone/core/odm/dataset.py (6 hunks)
- fiftyone/core/plots/plotly.py (1 hunks)
Files not reviewed due to no reviewable changes (2)
- app/packages/core/src/components/ColorModal/colorPalette/DefaultMaskTargets.tsx
- app/packages/core/src/components/ColorModal/colorPalette/FieldsMaskTarget.tsx
Files skipped from review as they are similar to previous changes (8)
- app/packages/core/src/components/ColorModal/colorPalette/Colorscale.tsx
- app/packages/core/src/components/ColorModal/controls/IdxColorList.tsx
- app/packages/core/src/components/ColorModal/controls/ManualColorScaleList.tsx
- app/packages/core/src/components/ColorModal/utils.ts
- docs/source/user_guide/app.rst
- docs/source/user_guide/using_datasets.rst
- fiftyone/core/odm/dataset.py
- fiftyone/core/plots/plotly.py
Additional context used
Path-based instructions (1)
app/packages/core/src/components/Common/Input.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.
Biome
app/packages/core/src/components/Common/Input.tsx
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (2)
app/packages/core/src/components/Common/Input.tsx (2)
35-40
: LGTM!The
ErrorMessage
styled component is correctly defined and styled for displaying error messages.
159-184
: Great job adding error handling!The error handling logic is correctly implemented using the
useState
anduseEffect
hooks. The error message construction based onmin
andmax
props, thehandleBlur
function for input validation, and theuseEffect
hook for keeping the error state in sync with the input value and validator are all implemented correctly.Tools
Biome
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
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: 0
Outside diff range and nitpick comments (1)
app/packages/core/src/components/Common/Input.tsx (1)
170-170
: Consider using optional chaining for better safety.The static analysis tool suggests using optional chaining at several places to enhance code safety and readability. This change would prevent potential runtime errors when accessing properties on undefined objects.
Apply this diff to implement optional chaining:
- onBlur && onBlur(); + onBlur?.(); - onKeyDown && onKeyDown(e); + onKeyDown?.(e); - onFocus && onFocus(); + onFocus?.();Also applies to: 223-223, 232-232
Tools
Biome
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- app/packages/core/src/components/Common/Input.tsx (3 hunks)
Additional context used
Path-based instructions (1)
app/packages/core/src/components/Common/Input.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.
Biome
app/packages/core/src/components/Common/Input.tsx
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 223-223: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 232-232: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (1)
app/packages/core/src/components/Common/Input.tsx (1)
159-184
: Excellent work on improving the error handling and user feedback!The added error handling logic and rendering of error messages greatly enhance the user experience by providing immediate feedback on input validity. The
error
state variable is appropriately managed using theuseState
hook, and thehandleBlur
function anduseEffect
hook ensure that the error state is kept in sync with the input value.The
ErrorMessage
styled component is a nice touch for displaying the error message below the input field when an error is present.Also applies to: 187-239
Tools
Biome
[error] 170-170: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
… 0 and 1 to create a valid rgb colorscale list
4739e60
to
440b2a1
Compare
if (list[0].value !== 0) { | ||
list.unshift({ value: 0, color: list[0].color }); | ||
} | ||
if (list[list.length - 1].value !== 1) { | ||
list.push({ value: 1, color: list[list.length - 1].color }); | ||
} |
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.
Nice!
What changes are proposed in this pull request?
example:

How is this patch tested? If it is not, please explain why.
(Details)
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
color_by
parameter to dynamically adjust color schemes based on dataset values.Colorscale
component.Bug Fixes
Documentation
default_colorscale
and removal of redundant notes.