Skip to content

Conversation

@tomer-shvadron
Copy link
Contributor

@tomer-shvadron tomer-shvadron commented Jul 8, 2025

Summary by CodeRabbit

  • Refactor
    • Improved efficiency and clarity in status checks within the collection flow by consolidating repeated logic.
  • Chores
    • Updated internal workflow state logic to better identify final workflow states using state tags.
    • Updated a subproject dependency reference for data migrations.

@changeset-bot
Copy link

changeset-bot bot commented Jul 8, 2025

⚠️ No Changeset found

Latest commit: b53004e

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

Walkthrough

The updates include a refactor in a frontend component to cache a repeated function call, an internal logic change in a workflow service to consider additional state tags as final, and a subproject reference update for data migrations. No public APIs or exported entity signatures were altered.

Changes

File(s) Change Summary
apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx Refactored to cache repeated function call for collection flow state; logic remains unchanged.
services/workflows-service/prisma/data-migrations Updated subproject commit reference.
services/workflows-service/src/workflow/workflow.service.ts Modified final state detection to include specific state tags in addition to type check.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant WorkflowService
    participant State

    Client->>WorkflowService: updateWorkflowRuntimeData()
    WorkflowService->>State: get current state
    alt State type is 'final' OR tags include 'APPROVED'/'REJECTED'
        WorkflowService->>WorkflowService: Set isFinal = true
    else
        WorkflowService->>WorkflowService: Set isFinal = false
    end
    WorkflowService-->>Client: Return updated workflow runtime data
Loading

Poem

In code we hop, with logic tight,
Cached a state for cleaner sight.
Workflows now know when they're done,
With tags or type, the check is one.
A migration hops to fresher ground,
In every change, efficiency is found!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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

🧹 Nitpick comments (1)
apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx (1)

64-64: Cache the derived state with useMemo for stability

getCollectionFlowState is called on every render. While inexpensive, wrapping it in useMemo guards against unnecessary recomputation and prevents future regressions if the helper becomes heavier.

-import { useEffect, useState } from 'react';
+import { useEffect, useState, useMemo } from 'react';
 ...
-const collectionFlowState = getCollectionFlowState(collectionFlowData?.context)?.status;
+const collectionFlowState = useMemo(
+  () => getCollectionFlowState(collectionFlowData?.context)?.status,
+  [collectionFlowData?.context],
+);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b8d1a2 and b53004e.

📒 Files selected for processing (3)
  • apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx (1 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/workflow/workflow.service.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: Use consistent naming conventions for related components (workflows, UI definitions, filters) in Ballerine migrations to improve maintainability and clarity.
services/workflows-service/prisma/data-migrations (2)

undefined

<retrieved_learning>
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: Use consistent naming conventions for related components (workflows, UI definitions, filters) in Ballerine migrations to improve maintainability and clarity.
</retrieved_learning>

<retrieved_learning>
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
</retrieved_learning>

apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx (2)
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/backoffice-v2.mdc:0-0
Timestamp: 2025-06-24T09:35:48.303Z
Learning: In the apps/backoffice-v2 React TypeScript codebase, always use functional components and TypeScript for all UI components to ensure consistency and type safety.
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/backoffice-v2.mdc:0-0
Timestamp: 2025-06-24T09:35:48.303Z
Learning: Use React Context for shared state that needs to be accessed by multiple components, and implement state machines for managing complex flows.
🧬 Code Graph Analysis (2)
apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx (4)
packages/common/src/utils/collection-flow/enums/collection-flow-status-enum.ts (1)
  • CollectionFlowStatusesEnum (1-18)
apps/kyb-app/src/pages/CollectionFlow/versions/v1/components/pages/Approved/Approved.tsx (1)
  • Approved (8-41)
apps/kyb-app/src/pages/CollectionFlow/versions/v1/components/pages/Rejected/Rejected.tsx (1)
  • Rejected (6-28)
apps/kyb-app/src/pages/CollectionFlow/versions/v1/components/pages/CompletedScreen/CompletedScreen.tsx (1)
  • CompletedScreen (15-65)
services/workflows-service/src/workflow/workflow.service.ts (1)
packages/common/src/consts/index.ts (2)
  • TStateTag (58-58)
  • StateTag (3-16)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: lint
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: test_linux
🔇 Additional comments (4)
services/workflows-service/prisma/data-migrations (1)

1-1: Submodule pointer changed – double-check downstream compatibility

The submodule now points to b78175f6a5c61310b3d4b8dd9ab43a9e65a01b84.
Please verify that:

  1. The commit is present on the remote (no local‐only work).
  2. All CI jobs use git submodule update --init --recursive so the new revision is fetched.
  3. Any generated outputs (e.g., regenerated Prisma client) have been rebuilt and committed if required.

Failure to do so can break fresh clones or deployments.

apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx (1)

66-80: Readability & logic unchanged – nice consolidation

Replacing four repeated invocations of getCollectionFlowState(...).status with the single collectionFlowState variable eliminates duplication and makes the conditional flow clearer. No functional change introduced.

services/workflows-service/src/workflow/workflow.service.ts (2)

66-67: LGTM! Clean import additions for state tag functionality.

The imports for StateTag and TStateTag are correctly added and follow the existing import patterns in the file.


1394-1406: Excellent enhancement to final state detection logic.

The implementation correctly extends final state determination to include tag-based checks alongside the existing type-based approach. The logic is sound:

  • Uses proper constants from the common package
  • Employs safe optional chaining to handle potential undefined values
  • Maintains backward compatibility by preserving the original type-based check
  • The OR condition appropriately combines both detection methods

This change provides valuable flexibility for workflow designers to mark states as final using tags rather than requiring the state type to be 'final'.

@alonp99 alonp99 enabled auto-merge (squash) July 8, 2025 13:26
@tomer-shvadron tomer-shvadron disabled auto-merge July 8, 2025 13:46
@tomer-shvadron tomer-shvadron merged commit 1bb2593 into dev Jul 8, 2025
9 checks passed
@tomer-shvadron tomer-shvadron deleted the bal-4462 branch July 8, 2025 13:46
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.

4 participants