Skip to content

[NAE-2232] Frontend Actions Task events resolver#305

Merged
machacjozef merged 8 commits into
release/7.0.0-rev8from
NAE-2232
Oct 20, 2025
Merged

[NAE-2232] Frontend Actions Task events resolver#305
machacjozef merged 8 commits into
release/7.0.0-rev8from
NAE-2232

Conversation

@martinkranec
Copy link
Copy Markdown
Contributor

@martinkranec martinkranec commented Oct 13, 2025

Description

Add FrontActionService integration to event task services for handling front actions

Implements NAE-2232

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

Manually

Test Configuration

Name Tested on
OS Windows 11
Runtime Node 22.17.0
Dependency Manager Npm 10.9.2
Framework version
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • New Features

    • The app now automatically detects and executes front-end actions defined in task outcomes after assigning, cancelling, or finishing a task.
    • Front-end actions run alongside changed-field handling, enabling immediate UI updates and automated follow-up steps without manual intervention.
    • Behavior is consistent across assign, cancel, and finish flows for improved responsiveness when tasks trigger additional actions.
  • Bug Fixes

    • Safer handling when no front-end actions are present to avoid runtime errors.

machacjozef and others added 4 commits October 2, 2025 16:11
…/7.0.0-rev9

# Conflicts:
#	package.json
#	projects/netgrif-components-core/package.json
#	projects/netgrif-components/package.json
- add FrontActionService integration to event task services for handling front actions
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 13, 2025

Walkthrough

Assign, cancel, and finish task services now inject FrontActionService and execute parsed frontActions from operation outcomes via FrontActionService.runAll after changed-fields emission; constructor signatures updated. task-data.service.ts condition for triggering front actions was relaxed using optional chaining to avoid undefined errors.

Changes

Cohort / File(s) Summary
Task service front-action integration
projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts, projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts, projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts
Add FrontActionService dependency and FrontAction import; parse frontActions from backend outcome and call FrontActionService.runAll when non-empty after emitting changed fields; constructors updated to accept the new dependency; existing reload/notification flow preserved.
Task data front-actions check
projects/netgrif-components-core/src/lib/task/services/task-data.service.ts
Replace strict boolean/null check with optional chaining when testing frontActions presence, preventing errors when frontActions is undefined while preserving behavior when defined and non-empty.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI
  participant Service as Assign/Cancel/Finish Service
  participant Backend
  participant FrontAction as FrontActionService

  UI->>Service: trigger task operation
  Service->>Backend: perform operation (assign/cancel/finish)
  Backend-->>Service: outcome (changedFields?, frontActions?)
  Service->>Service: emit changedFields (if any)

  alt frontActions present
    Service->>FrontAction: runAll(frontActions)
    FrontAction-->>Service: done
  else no frontActions
    Note over Service: no front actions to run
  end

  Service->>UI: continue reload/notification/close flow
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

bugfix, enhancement

Pre-merge checks

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title mentions front-end actions and task events but lacks a clear verb or description of the change, making it hard to immediately understand that the PR integrates FrontActionService into task event services. Consider revising the title to clearly state the action and scope, for example “Integrate FrontActionService into task event services” to improve clarity.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@martinkranec martinkranec self-assigned this Oct 13, 2025
@martinkranec martinkranec marked this pull request as ready for review October 13, 2025 12:00
@coderabbitai coderabbitai Bot added the bugfix label Oct 13, 2025
Copy link
Copy Markdown

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1bddbd and a232034.

📒 Files selected for processing (3)
  • projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts (3 hunks)
  • projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts (3 hunks)
  • projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (1)
projects/netgrif-components-core/src/lib/data-fields/models/changed-fields.ts (1)
  • FrontAction (48-53)
projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts (1)
projects/netgrif-components-core/src/lib/data-fields/models/changed-fields.ts (1)
  • FrontAction (48-53)
projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts (1)
projects/netgrif-components-core/src/lib/data-fields/models/changed-fields.ts (1)
  • FrontAction (48-53)
⏰ 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). (17)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: Matrix Test (24)
  • GitHub Check: Matrix Test (20)
  • GitHub Check: Matrix Test (22)
  • GitHub Check: Test with SonarCloud
🔇 Additional comments (9)
projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts (3)

26-30: LGTM! Imports are correct.

The imports for EventService, FrontActionService, and FrontAction are properly added and necessary for the new functionality.


53-55: LGTM! Constructor injection follows Angular patterns.

The FrontActionService is correctly injected as a protected member, consistent with other service injections in this constructor.


142-151: No change needed: error path handling consistent

Error path in cancel-task.service.ts matches assign-task and finish-task services: front actions are only executed on success. No changes required.

projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts (4)

27-28: LGTM!

The imports are correctly organized and reference the appropriate modules.


47-47: LGTM!

The FrontActionService is properly injected following Angular's dependency injection pattern, consistent with other service dependencies in the constructor.


127-128: LGTM!

The parsing logic follows the same pattern as the changed fields parsing above it (lines 125-126), maintaining consistency in how outcome tree data is extracted.


132-135: Wrap FrontActionService.runAll in error handling and confirm error-case behavior

  • Surround runAll(frontActions) with a try–catch (or verify it internally swallows exceptions) to ensure reload/notification logic always runs.
  • Verify whether error outcomes should execute front actions—CancelTaskService and FinishTaskService omit them on error.
projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (2)

27-28: LGTM! Imports are correctly added.

The import statements for FrontActionService and FrontAction are properly structured and necessary for the new functionality.


49-50: LGTM! Constructor correctly updated.

The FrontActionService injection follows the established pattern and is properly stored as a protected member for use in the class methods.

Comment on lines +129 to +138
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);


if (!!changedFieldsMap) {
this._changedFieldsService.emitChangedFields(changedFieldsMap);
}

if (!!frontActions && frontActions.length > 0) {
this._frontActionService.runAll(frontActions);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify error handling and consider using optional chaining.

The front actions parsing and execution logic is correct. However, consider the following:

  1. Error handling: Verify that FrontActionService.runAll() handles errors internally. If it can throw exceptions, wrap the call in a try-catch block to prevent disrupting the cancel flow.

  2. Optional refactor: The null check can be modernized using optional chaining:

-                if (!!frontActions && frontActions.length > 0) {
+                if (frontActions?.length > 0) {
                     this._frontActionService.runAll(frontActions);
                 }

Run the following script to verify error handling in FrontActionService:


🏁 Script executed:

#!/bin/bash
# Verify error handling in FrontActionService.runAll method
ast-grep --pattern $'class FrontActionService {
  $$$
  runAll($$$) {
    $$$
  }
  $$$
}'

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Locate FrontActionService definition
rg -n "class FrontActionService" -g "*.ts"

# Inspect runAll implementation for error handling
file=$(rg -l "class FrontActionService" -g "*.ts")
rg -nP 'runAll\s*\(' -C3 "$file"

Length of output: 297


Wrap runAll in error handling and modernize null check

  • Wrap the call to this._frontActionService.runAll(frontActions) in a try { … } catch { … } block to ensure any thrown errors don’t interrupt the cancel flow.
  • Replace if (!!frontActions && frontActions.length > 0) with if (frontActions?.length > 0).
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts
around lines 129 to 138, replace the double-negation null check with optional
chaining (if (frontActions?.length > 0)) and wrap the call to
this._frontActionService.runAll(frontActions) in a try { ... } catch (err) { ...
} block so any thrown errors do not break the cancel flow; in the catch block
log the error using the service's existing logger (or console.error if no logger
exists) and do not rethrow so processing continues.

Comment thread projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts Outdated
Comment thread projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts Outdated
Copy link
Copy Markdown

@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: 2

♻️ Duplicate comments (2)
projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (1)

141-148: Previous review concerns remain unaddressed.

The earlier review flagged that runAll() lacks error handling and may be asynchronous. The current implementation still:

  1. Missing error handling: If runAll() throws, it will interrupt the finish flow (reload/close operations won't execute).
  2. Unclear async behavior: If runAll() performs async operations, the current fire-and-forget approach may cause race conditions with subsequent reload/close.

Please verify the FrontActionService.runAll implementation to confirm:

  • Whether it's synchronous or returns a Promise
  • How it handles internal errors

Based on the findings:

  • If synchronous: wrap the call in try-catch to prevent exceptions from blocking task finish
  • If asynchronous: make this method async and await the call, with try-catch around it
#!/bin/bash
# Description: Examine FrontActionService.runAll signature and error handling

# Find FrontActionService implementation
file=$(fd -e ts FrontActionService | grep -v spec | grep -v test)

if [ -z "$file" ]; then
  echo "FrontActionService file not found"
  exit 1
fi

echo "=== FrontActionService location ==="
echo "$file"
echo ""

# Display the runAll method signature and implementation
echo "=== runAll method implementation ==="
rg -nP -A 20 '(public|protected|private)?\s*(async\s+)?runAll\s*\(' "$file"
projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts (1)

134-136: Guard runAll to keep the cancel flow resilient.

If any front action throws, the subscription will blow up before we resolve the queue, leaving the cancel flow stuck. Wrap the call in a try/catch, log via _log, and continue so reload/notifications still run.

                 if (frontActions?.length > 0) {
-                    this._frontActionService.runAll(frontActions);
+                    try {
+                        this._frontActionService.runAll(frontActions);
+                    } catch (err) {
+                        this._log.error('Failed to execute front actions for cancel outcome', err);
+                    }
                 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a232034 and 8efb792.

📒 Files selected for processing (4)
  • projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts (3 hunks)
  • projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts (3 hunks)
  • projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (3 hunks)
  • projects/netgrif-components-core/src/lib/task/services/task-data.service.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts (1)
projects/netgrif-components-core/src/lib/data-fields/models/changed-fields.ts (1)
  • FrontAction (48-53)
projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts (1)
projects/netgrif-components-core/src/lib/data-fields/models/changed-fields.ts (1)
  • FrontAction (48-53)
projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (1)
projects/netgrif-components-core/src/lib/data-fields/models/changed-fields.ts (1)
  • FrontAction (48-53)
⏰ 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). (9)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
🔇 Additional comments (5)
projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts (2)

27-28: LGTM!

The imports are correctly specified and necessary for the front action integration.


49-50: LGTM!

The constructor correctly injects FrontActionService following Angular's dependency injection pattern. The protected visibility is appropriate for use within class methods.

projects/netgrif-components-core/src/lib/task/services/task-data.service.ts (1)

65-65: LGTM! FrontActionService injection added correctly.

The FrontActionService dependency is properly injected following Angular's dependency injection pattern and is used appropriately in the processSuccessfulSetDataRequest method to execute front actions from task outcomes.

projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts (2)

27-28: LGTM! Imports are correct.

The imports for FrontActionService and FrontAction are appropriate and necessary for the new front-action handling functionality.


47-47: LGTM! Constructor injection follows existing patterns.

The FrontActionService is correctly injected as a protected dependency, consistent with other service injections in this constructor.

Comment on lines +127 to +134
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);

if (!!changedFieldsMap) {
this._changedFieldsService.emitChangedFields(changedFieldsMap);
}
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify error handling and consistency with error path.

The front-action execution logic is well-structured with safe optional chaining on line 132. However, two aspects need verification:

  1. Error handling: Confirm that FrontActionService.runAll handles errors internally and won't throw unhandled exceptions that could disrupt the assign workflow.

  2. Error path consistency: The error path (lines 145-148) emits changed fields but does not parse or execute front actions. Verify this is intentional—should front actions also be executed when outcomeResource.error is true but an outcome is present?

Run the following script to examine the error handling in FrontActionService.runAll:


🏁 Script executed:

#!/bin/bash
# Description: Check FrontActionService.runAll implementation for error handling

# Find and display the runAll method implementation
ast-grep --pattern $'class FrontActionService {
  $$$
  runAll($$$) {
    $$$
  }
  $$$
}'

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Locate the FrontActionService class declaration
rg -nP 'class\s+FrontActionService' -C3 -g '*.ts'

# Locate the runAll method within the codebase
rg -nP '\brunAll\s*\(' -C3 -g '*.ts'

Length of output: 5238


🏁 Script executed:

#!/bin/bash
# Display FrontActionService implementation
sed -n '1,200p' projects/netgrif-components-core/src/lib/actions/services/front-action.service.ts

# Locate run method definition
rg -nP 'public\s+run\(' -C3 -g projects/netgrif-components-core/src/lib/actions/services/front-action.service.ts

# Display assign-task.service.ts around error path
sed -n '120,200p' projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts

Length of output: 5347


Add error handling to front action execution and ensure error path consistency

  • FrontActionService.runAll/run does not catch exceptions or guard against undefined handlers—wrap each call in try/catch and return early if get(...) returns no function to prevent uncaught errors.
  • In assign-task.service.ts error branch (L145–148), frontActions aren’t parsed or executed—confirm whether front actions should also run when outcomeResource.error is true.
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts
around lines 127 to 134, update front action execution to be defensive and add
consistent error-path handling: change the runAll invocation so each front
action call is checked for a valid handler (return early or skip if get(...)
yields undefined) and wrap each handler invocation in try/catch to prevent
exceptions from bubbling; additionally, in the error branch around lines 145–148
parse frontActions from outcomeResource.outcome the same way and execute them
(with the same guarded try/catch/handler-existence checks) so front actions are
consistently processed whether outcomeResource.error is true or false.

Comment on lines +492 to 494
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

LGTM! Optional chaining provides safe front action execution.

The optional chaining operator correctly handles cases where parseFrontActionsFromOutcomeTree may return undefined or null, preventing potential runtime errors. The execution order (after changed-fields emission, before cleanup) aligns with the integration pattern described in the PR objectives.

To confirm the optional chaining is necessary, verify whether parseFrontActionsFromOutcomeTree can return undefined or null:


🏁 Script executed:

#!/bin/bash
# Description: Check the return type and implementation of parseFrontActionsFromOutcomeTree

# Search for the method definition and its return type
ast-grep --pattern $'parseFrontActionsFromOutcomeTree($$$) {
  $$$
}'

# Also search for the method signature/declaration
rg -nP --type=ts -A 10 'parseFrontActionsFromOutcomeTree\s*\(' | head -50

Length of output: 6399


Remove unnecessary optional chaining on frontActions (task-data.service.ts:492–494)
parseFrontActionsFromOutcomeTree always returns an array, so frontActions is never undefined or null. Change

if (frontActions?.length > 0) {
    this._frontActionService.runAll(frontActions);
}

to

if (frontActions.length > 0) {
    this._frontActionService.runAll(frontActions);
}
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/task/services/task-data.service.ts
around lines 492–494, remove the unnecessary optional chaining on frontActions
because parseFrontActionsFromOutcomeTree always returns an array; change the
conditional to check frontActions.length > 0 and call
this._frontActionService.runAll(frontActions) when true so the code uses a
direct length check instead of frontActions?.length.

Kovy95
Kovy95 previously approved these changes Oct 14, 2025
@machacjozef machacjozef changed the base branch from release/7.0.0-rev9 to release/7.0.0-rev8 October 20, 2025 12:18
@machacjozef machacjozef dismissed Kovy95’s stale review October 20, 2025 12:18

The base branch was changed.

@sonarqubecloud
Copy link
Copy Markdown

@machacjozef machacjozef merged commit d47a60f into release/7.0.0-rev8 Oct 20, 2025
10 of 11 checks passed
@machacjozef machacjozef deleted the NAE-2232 branch October 20, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants