Skip to content

feat: add IUserTaskService with optional ActivityInstanceId (#4535)#7763

Open
pavankadabala-png wants to merge 2 commits into
elsa-workflows:mainfrom
pavankadabala-png:feat/4535-user-task-service
Open

feat: add IUserTaskService with optional ActivityInstanceId (#4535)#7763
pavankadabala-png wants to merge 2 commits into
elsa-workflows:mainfrom
pavankadabala-png:feat/4535-user-task-service

Conversation

@pavankadabala-png

Copy link
Copy Markdown

What this does

Adds a high-level IUserTaskService for triggering user actions against suspended RunTask activities, targeting them by workflow identity instead of the internal TaskId.

Today the only entry point is the low-level ITaskReporter.ReportCompletionAsync(taskId, ...), which requires the caller to already know the TaskId generated at dispatch time. This PR complements it with a service that lets callers target a task by workflow-instance ID, activity-instance ID, or correlation ID.

Why

Closes #4535. The ActivityInstanceId field solves the Fork scenario raised in the issue: when several parallel branches each contain a RunTask with the same task name, the caller otherwise can't say which branch to resume. Supplying ActivityInstanceId disambiguates it.

Changes

  • TriggerUserAction (record) — Action, optional WorkflowInstanceId, ActivityInstanceId, CorrelationId.
  • IUserTaskServiceExecuteUserActionAsync (synchronous resume via IWorkflowResumer) and DispatchUserActionAsync (async enqueue via IBookmarkQueue).
  • UserTaskService — builds a BookmarkFilter from the TriggerUserAction fields and delegates to the appropriate resumer/queue.
  • Registered alongside ITaskReporter in WorkflowRuntimeFeature.

Notes

  • No breaking changes; this is purely additive.
  • Follows existing Runtime module conventions (namespaces, primary constructors, ActivityTypeNameHelper.GenerateTypeName<RunTask>()).
  • Happy to reshape this as ITaskReporter overloads instead if that's preferred — see discussion on IUserTaskService enhancement - optional activityId #4535.

…kflows#4535)

Adds a high-level IUserTaskService for triggering user actions against
suspended RunTask activities without requiring callers to know the
internal TaskId generated at dispatch time.

New types:
- TriggerUserAction record (Action, WorkflowInstanceId?, ActivityInstanceId?,
  CorrelationId?) — mirrors the record requested in the issue, using
  ActivityInstanceId to match Elsa 3 conventions.
- IUserTaskService interface — two methods:
    ExecuteUserActionAsync  (synchronous, via IWorkflowResumer)
    DispatchUserActionAsync (asynchronous, via IBookmarkQueue)
- UserTaskService implementation — builds a BookmarkFilter from the
  TriggerUserAction fields and delegates to the appropriate resumer.

The ActivityInstanceId field specifically solves the Fork scenario
described in the issue: when multiple RunTask activities in parallel
branches share the same TaskName, supplying ActivityInstanceId ensures
only the intended branch is resumed.

DI registration added alongside ITaskReporter in WorkflowRuntimeFeature.

Closes elsa-workflows#4535
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@pavankadabala-png

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

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.

IUserTaskService enhancement - optional activityId

1 participant