Skip to content

Conversation

chesterkmr
Copy link
Contributor

@chesterkmr chesterkmr commented Jun 17, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved collection flow status updates to prevent unnecessary status changes during form submission.
  • Refactor
    • Enhanced the final submission process for collection flows to better manage context and workflow events.
  • Chores
    • Updated internal data migration references.
  • New Features
    • Added the ability to remove specific plugin outputs from the collection flow context.

Copy link

changeset-bot bot commented Jun 17, 2025

⚠️ No Changeset found

Latest commit: 12f8da5

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 Jun 17, 2025

Walkthrough

The changes introduce a conditional update to the collection flow status during form submission in the UI, add a utility method for removing plugin outputs in the backend service, and refactor the final submission controller logic to update workflow runtime data before updating collection flow state and triggering events. A subproject commit reference for data migrations was also updated.

Changes

File(s) Change Summary
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/… Collection flow status is now set to "inprogress" only if the current status is "pending" during submission.
services/workflows-service/src/collection-flow/services/collection-flow.service.ts Added removePluginsOutput method to remove specified plugin outputs from context.
services/workflows-service/src/collection-flow/controllers/collection-flow.controller.ts Refactored finalSubmission to update workflow runtime data before collection flow state and event triggering.
services/workflows-service/prisma/data-migrations Updated subproject commit reference.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CollectionFlowUI
    participant BackendAPI
    participant CollectionFlowService

    User->>CollectionFlowUI: Submit form
    CollectionFlowUI->>CollectionFlowUI: Check current status
    alt Status is pending
        CollectionFlowUI->>CollectionFlowUI: Set status to inprogress
    else Status is not pending
        CollectionFlowUI->>CollectionFlowUI: Do not update status
    end
    CollectionFlowUI->>BackendAPI: Send submission data
    BackendAPI->>CollectionFlowService: Call finalSubmission
    CollectionFlowService->>CollectionFlowService: Remove plugin outputs (if needed)
    CollectionFlowService->>BackendAPI: Update workflow runtime data
    BackendAPI->>BackendAPI: Update collection flow state
    BackendAPI->>BackendAPI: Trigger workflow event
Loading

Possibly related PRs

Suggested reviewers

  • tomer-shvadron

Poem

A bunny hopped through code so bright,
Tweaked the flows to set things right.
Plugins cleaned with gentle care,
Status checks now wise and fair.
Backend and UI, in harmony anew—
This rabbit’s work is swift and true!
🐇✨


📜 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 ee066c6 and d6ca97a.

📒 Files selected for processing (1)
  • services/workflows-service/src/collection-flow/services/collection-flow.service.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • services/workflows-service/src/collection-flow/services/collection-flow.service.ts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: spell_check
  • GitHub Check: test_linux
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: lint
  • GitHub Check: format
✨ 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: 3

🧹 Nitpick comments (3)
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx (1)

197-199: Consider capturing the return value of setCollectionFlowStatus for clearer intent

setCollectionFlowStatus mutates the context and returns the updated object, yet the returned value is discarded.
Although the current mutation-in-place behaviour works, explicitly re-assigning helps future maintainers understand that the function produces a new value and prevents surprises if its implementation ever changes to an immutable approach.

-        if (values.collectionFlow?.state?.status === CollectionFlowStatusesEnum.pending) {
-          setCollectionFlowStatus(values, CollectionFlowStatusesEnum.inprogress);
-        }
+        if (values.collectionFlow?.state?.status === CollectionFlowStatusesEnum.pending) {
+          values = setCollectionFlowStatus(values, CollectionFlowStatusesEnum.inprogress);
+        }
services/workflows-service/src/collection-flow/controllers/collection-flow.controller.ts (2)

181-187: Update workflow data and collection-flow state inside a transaction

updateWorkflowRuntimeData and updateCollectionFlowState execute independently.
If the first call succeeds and the second fails (or vice-versa) the database will hold inconsistent records.

Consider wrapping both writes in a single Prisma transaction (or explicit DB transaction) to guarantee atomicity.


205-208: Propagate arrayMergeOption when triggering the final event

If the workflow depends on deep-merge semantics (as used elsewhere in the controller) omitting arrayMergeOption here could yield different merge behaviour from the sync step above.

Confirm whether this event should replicate the merge behaviour of /sync/context. If yes, include the option.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 662cb8d and fae9452.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx (1 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/collection-flow/controllers/collection-flow.controller.ts (2 hunks)
  • services/workflows-service/src/collection-flow/services/collection-flow.service.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx (2)
packages/common/src/utils/collection-flow/enums/collection-flow-status-enum.ts (1)
  • CollectionFlowStatusesEnum (1-18)
packages/common/src/utils/collection-flow/set-collection-flow-status.ts (1)
  • setCollectionFlowStatus (10-29)
services/workflows-service/src/collection-flow/services/collection-flow.service.ts (1)
services/workflows-service/src/rule-engine/core/test/data-helper.ts (1)
  • context (1-123)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_linux
  • GitHub Check: format
  • GitHub Check: lint
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (2)
services/workflows-service/prisma/data-migrations (1)

1-1: Confirm submodule commit update
The data-migrations subproject reference was bumped to 66f23f0003a77e37d353fe35b7fe5ec8526bfb72. Ensure this commit contains the required migration scripts for recent schema changes.

#!/bin/bash
# Verify submodule HEAD matches the updated commit
git submodule update --init --recursive services/workflows-service/prisma/data-migrations
git -C services/workflows-service/prisma/data-migrations rev-parse HEAD

Expect output 66f23f0003a77e37d353fe35b7fe5ec8526bfb72.

services/workflows-service/src/collection-flow/controllers/collection-flow.controller.ts (1)

189-200: Status is forced to completed without checking current state

During an edit flow the status could legitimately be revision or failed.
Blindly overriding to completed may hide unresolved issues.

Request verification that this is the intended business rule; if not, gate the change behind an explicit state check similar to the UI logic introduced in the PR.

@chesterkmr chesterkmr force-pushed the bal-4370-flaky-plugin-rerun-during-submission-in-edit branch from fae9452 to 36aba91 Compare June 17, 2025 12:22
@chesterkmr chesterkmr force-pushed the bal-4370-flaky-plugin-rerun-during-submission-in-edit branch from 36aba91 to ee066c6 Compare June 17, 2025 12:26
@chesterkmr chesterkmr enabled auto-merge (squash) June 17, 2025 13:39
@chesterkmr chesterkmr merged commit 4b8d1a2 into dev Jun 17, 2025
17 checks passed
@chesterkmr chesterkmr deleted the bal-4370-flaky-plugin-rerun-during-submission-in-edit branch June 17, 2025 13:51
alonp99 pushed a commit that referenced this pull request Jun 18, 2025
* fix: fixed issue where edit status was updated to in progress (#3427)

* feat: reworked final submission & added plugins output cleanup

* fix: fixed types
tomer-shvadron added a commit that referenced this pull request Jul 8, 2025
* fix: fixed issue where edit status was updated to in progress (#3427)

* fix: fixed checkbox styles in ui package (#3430)

* Bal 4370 flaky plugin rerun during submission in edit (#3428)

* fix: fixed issue where edit status was updated to in progress (#3427)

* feat: reworked final submission & added plugins output cleanup

* fix: fixed types

* refactor(workflow.service): enhance final state detection logic

* refactor(workflow.service): enhance final state detection logic

---------

Co-authored-by: Illia Rudniev <[email protected]>
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