-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore: add hybrid search control #39258
Conversation
WalkthroughThis PR introduces a new hybrid search control by adding the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (8)
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
|
2964f57
to
f1e27ad
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.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.
Actionable comments posted: 2
🧹 Nitpick comments (2)
app/client/src/components/formControls/HybridSearch.tsx (2)
36-42
: Consider using more precise weight calculations.The current implementation scales values by 10 to avoid floating-point issues, but this approach might still lead to precision errors. Consider using a more robust solution.
- semanticWeight: (10 - value * 10) / 10, // Scale by 10 to avoid floating-point issues + semanticWeight: Math.round((1 - value) * 100) / 100, // Round to 2 decimal placesAlso applies to: 43-49
7-9
: Document the inverse relationship between weights.The weights are inversely related (when one increases, the other decreases) but this isn't documented in the interface.
export interface HybridSearchControlProps extends ControlProps, - Omit<SliderProps, "id" | "label"> {} + Omit<SliderProps, "id" | "label"> { + /** The weights are inversely related - they always sum to 1 */ +}
🛑 Comments failed to post (2)
app/client/src/components/formControls/HybridSearch.tsx (1)
57-88: 🛠️ Refactor suggestion
Add input validation and error handling.
The component lacks validation for edge cases:
- No validation that weights sum to 1
- No error handling for invalid input values
- Missing disabled state handling for the sliders when switch is off
Consider adding a validation function:
const validateWeights = (keywordWeight: number, semanticWeight: number): boolean => { return Math.abs(keywordWeight + semanticWeight - 1) < 0.001; };app/client/src/utils/formControl/FormControlRegistry.tsx (1)
230-230: 🛠️ Refactor suggestion
Use specific props type for hybrid search control.
The control is using
SliderControlProps
but should use its ownHybridSearchControlProps
interface for better type safety.- buildPropertyControl(controlProps: SliderControlProps): JSX.Element { + buildPropertyControl(controlProps: HybridSearchControlProps): JSX.Element {📝 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.buildPropertyControl(controlProps: HybridSearchControlProps): JSX.Element {
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
🧹 Nitpick comments (4)
app/client/src/components/formControls/HybridSearch.tsx (3)
11-27
: Add JSDoc documentation for the component class.Consider adding JSDoc documentation to describe the component's purpose, props, and usage.
+/** + * HybridSearchControl provides a UI for configuring hybrid search parameters + * including keyword and semantic weights. + */ export class HybridSearchControl extends BaseControl<HybridSearchControlProps> {
36-49
: Extract magic numbers into named constants.The scaling factor of 10 is used to avoid floating-point issues, but it should be extracted into a named constant for better maintainability.
+const WEIGHT_SCALE_FACTOR = 10; + const onKeywordWeightChange = (value: number) => { input?.onChange({ ...input?.value, keywordWeight: value, - semanticWeight: (10 - value * 10) / 10, + semanticWeight: (WEIGHT_SCALE_FACTOR - value * WEIGHT_SCALE_FACTOR) / WEIGHT_SCALE_FACTOR, }); };
57-89
: Enhance accessibility for the form controls.Add ARIA labels and roles to improve accessibility for screen readers.
<Flex flexDirection="column" gap="spaces-4"> <Flex width="150px"> <Switch + aria-label="Toggle hybrid search" defaultSelected={input?.value.isEnabled} onChange={onSwitchChange} > Hybrid search </Switch> </Flex> <Flex alignItems="center" gap="spaces-4"> <Slider + aria-label="Adjust keyword weight" isDisabled={!input?.value.isEnabled} label="Keyword weight"app/client/src/utils/formControl/FormControlRegistry.tsx (1)
229-233
: Consider using more specific props type.The control is using
SliderControlProps
but should useHybridSearchControlProps
for better type safety.- buildPropertyControl(controlProps: SliderControlProps): JSX.Element { + buildPropertyControl(controlProps: HybridSearchControlProps): JSX.Element {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/client/src/components/formControls/HybridSearch.tsx
(1 hunks)app/client/src/utils/formControl/FormControlRegistry.tsx
(2 hunks)app/client/src/utils/formControl/formControlTypes.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- app/client/src/utils/formControl/formControlTypes.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: client-unit-tests / client-unit-tests
- GitHub Check: client-lint / client-lint
- GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
- GitHub Check: client-prettier / prettier-check
- GitHub Check: client-build / client-build
🔇 Additional comments (1)
app/client/src/components/formControls/HybridSearch.tsx (1)
1-10
: LGTM! Clean imports and interface definition.The imports are well-organized and the interface properly extends the base types while handling potential conflicts.
f1e27ad
to
9495722
Compare
Description
Add hybrid search control for UQI forms.
Example of usage:
Fixes #39236
Automation
/ok-to-test tags="@tag.Datasource"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13324291818
Commit: 9495722
Cypress dashboard.
Tags:
@tag.Datasource
Spec:
Fri, 14 Feb 2025 07:52:38 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit