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

Illiar/fix/v2 adjustments #3007

Merged
merged 5 commits into from
Jan 29, 2025
Merged

Illiar/fix/v2 adjustments #3007

merged 5 commits into from
Jan 29, 2025

Conversation

chesterkmr
Copy link
Collaborator

@chesterkmr chesterkmr commented Jan 29, 2025

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved form validation handling with more robust error reporting.
    • Enhanced input field event handling for better user experience.
    • Fixed potential runtime errors in document processing.
  • Performance

    • Optimized rule engine execution timing.
    • Refined form interaction validation delays.
  • Chores

    • Updated UI package to version 0.5.70.
    • Updated subproject commit references.

Copy link

changeset-bot bot commented Jan 29, 2025

⚠️ No Changeset found

Latest commit: c4ff95d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Walkthrough

The pull request encompasses modifications across multiple files in the Ballerine project, focusing on form validation, error handling, and component interactions. Changes include adjusting validation parameters in the CollectionFlowUI, implementing optional chaining in document retrieval, updating the UI package changelog, enhancing event handling in the DatePickerInput, and modifying rule engine execution delays and document update mechanisms.

Changes

File Change Summary
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx Modified validationParams: disabled validateOnBlur, set abortEarly to false, increased validationDelay to 500ms
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/hooks/usePriorityFields/utils/generate-priority-fields.ts Added optional chaining (?.) to document retrieval for safer access
packages/ui/CHANGELOG.md Added version 0.5.70 with "Param adjustments & bugfixes" note
packages/ui/src/components/molecules/inputs/DatePickerInput/DatePickerInput.tsx Added onBlur and onFocus event handlers to inputProps
packages/ui/src/components/organisms/Form/DynamicForm/fields/DocumentField/hooks/useDocumentUpload/helpers/create-or-update-fileid-or-file-in-documents/create-or-update-fileid-or-file-in-documents.ts Added structuredClone() when updating existing documents
packages/ui/src/components/organisms/Form/DynamicForm/hooks/external/useField/useField.ts Reduced executionDelay to 100ms, removed setTouched from onChange callback dependency array
packages/ui/src/components/organisms/Form/DynamicForm/hooks/external/useField/useField.unit.test.ts Updated test cases with reduced executionDelay and modified test assertions
services/workflows-service/prisma/data-migrations Updated subproject commit hash

Suggested Reviewers

  • Omri-Levy
  • tomer-shvadron

Poem

🐰 Validation dance, a rabbit's delight,
Parameters tweaked with algorithmic might
Optional chains and delays so neat
Code refactored, now running sweet
Hop along, improvements in flight! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 447b79d and c4ff95d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • services/workflows-service/prisma/data-migrations (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • services/workflows-service/prisma/data-migrations
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test_windows
  • GitHub Check: build (windows-latest)
  • GitHub Check: test_linux
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: spell_check
  • GitHub Check: lint

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

🧹 Nitpick comments (2)
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/hooks/usePriorityFields/utils/generate-priority-fields.ts (2)

27-29: LGTM! Consider adding debug logging.

The addition of optional chaining is a good defensive programming practice. However, consider adding debug logging when documents are undefined to help with troubleshooting.

-        const document = documents?.find(
+        const document = documents?.find(
           (doc: TDocument) => doc.id === element.params?.template?.id,
         );
+        if (!documents) {
+          console.debug(
+            `No documents found for element ${element.id} at path ${formatValueDestination(
+              element.valueDestination,
+              stack,
+            )}`,
+          );
+        }

Line range hint 44-45: TODO comments need attention.

These TODO comments indicate incomplete implementation for extracting priority fields from other elements.

Would you like me to help implement the extraction of priority fields from other elements? I can analyze the codebase to understand the requirements and propose a solution.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2cd32a and 862ecdd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • apps/kyb-app/CHANGELOG.md (1 hunks)
  • apps/kyb-app/package.json (2 hunks)
  • apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx (1 hunks)
  • apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/hooks/usePriorityFields/utils/generate-priority-fields.ts (1 hunks)
  • packages/react-pdf-toolkit/CHANGELOG.md (1 hunks)
  • packages/react-pdf-toolkit/package.json (2 hunks)
  • packages/ui/CHANGELOG.md (1 hunks)
  • packages/ui/package.json (1 hunks)
  • packages/ui/src/components/molecules/inputs/DatePickerInput/DatePickerInput.tsx (1 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/fields/DocumentField/hooks/useDocumentUpload/helpers/create-or-update-fileid-or-file-in-documents/create-or-update-fileid-or-file-in-documents.ts (1 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/hooks/external/useField/useField.ts (2 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/hooks/external/useField/useField.unit.test.ts (2 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
✅ Files skipped from review due to trivial changes (7)
  • packages/ui/package.json
  • packages/react-pdf-toolkit/CHANGELOG.md
  • packages/react-pdf-toolkit/package.json
  • apps/kyb-app/package.json
  • packages/ui/CHANGELOG.md
  • services/workflows-service/prisma/data-migrations
  • apps/kyb-app/CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: spell_check
  • GitHub Check: lint
🔇 Additional comments (5)
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx (1)

24-26: Review validation timing and behavior changes.

The validation parameter changes affect form behavior in significant ways:

  1. Validation no longer triggers on blur events
  2. All validation errors will be collected instead of stopping at the first error
  3. Validation delay increased to 500ms

Please confirm these changes align with the intended user experience, particularly:

  • Users won't get immediate feedback when leaving a field
  • Validation will run less frequently but show all errors at once
  • The increased delay won't make the form feel unresponsive
✅ Verification successful

Validation parameter changes align with established patterns

The changes match existing validation configurations in the codebase:

  • validateOnBlur: false is used in other form implementations
  • abortEarly: false is the standard default
  • validationDelay: 500ms is the consistent default timing
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other validation delay configurations in the codebase
rg "validationDelay|validateOnBlur|abortEarly" --type typescript

Length of output: 101


Script:

#!/bin/bash
# Search for validation parameters in .ts and .tsx files
rg "validationDelay|validateOnBlur|abortEarly" -g "*.ts" -g "*.tsx" -A 2 -B 2

# Also search for form configuration patterns
rg "const.*validationParams|const.*formConfig" -g "*.ts" -g "*.tsx" -A 5 -B 1

Length of output: 65122

packages/ui/src/components/organisms/Form/DynamicForm/hooks/external/useField/useField.ts (2)

46-46: Optimization: Removed unnecessary dependency.

Removing setTouched from the onChange dependencies is a good optimization as it prevents unnecessary recreations of the handler.


29-29: Consider the impact of faster rule execution.

The executionDelay has been reduced from 500ms to 100ms, making rule evaluation more responsive but potentially increasing the frequency of evaluations.

Please verify that this change:

  • Doesn't cause performance issues with complex rules
  • Maintains a good balance between responsiveness and resource usage
✅ Verification successful

Execution delay change is safe and well-supported

The reduction to 100ms is safe because:

  • The rule execution system uses debouncing to prevent excessive evaluations
  • The change is localized to the useField hook, maintaining the default 500ms elsewhere
  • The codebase has comprehensive test coverage for different execution delays
  • No performance-related issues were found in the tests
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of executionDelay to ensure consistency
rg "executionDelay.*[0-9]+" --type typescript

Length of output: 82


Script:

#!/bin/bash
# Search for executionDelay in TypeScript files
rg "executionDelay" -g "*.ts" -g "*.tsx" -A 2 -B 2

# Search for performance tests or benchmarks
rg "performance|benchmark" -g "*.test.ts" -g "*.test.tsx" -g "*.spec.ts" -g "*.spec.tsx"

# Look for rule execution patterns
rg "rule.*execut|execut.*rule" -g "*.ts" -g "*.tsx" -A 2 -B 2

Length of output: 28540

packages/ui/src/components/organisms/Form/DynamicForm/fields/DocumentField/hooks/useDocumentUpload/helpers/create-or-update-fileid-or-file-in-documents/create-or-update-fileid-or-file-in-documents.ts (1)

31-31: Good: Added proper template cloning.

Using structuredClone ensures a deep copy of the template, preventing unintended mutations of the original object.

packages/ui/src/components/organisms/Form/DynamicForm/hooks/external/useField/useField.unit.test.ts (1)

276-276: Test alignment: Updated executionDelay in tests.

The test expectations have been properly updated to match the new executionDelay value in the implementation.

Also applies to: 298-298

@chesterkmr chesterkmr merged commit 15a2af8 into dev Jan 29, 2025
18 checks passed
@chesterkmr chesterkmr deleted the illiar/fix/v2-adjustments branch January 29, 2025 16:06
@coderabbitai coderabbitai bot mentioned this pull request Jan 31, 2025
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