elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.27k stars 1.15k forks source link

[FEAT] Interactive JavaScript Debugging for Activity Input Fields #5645

Open sfmskywalker opened 3 months ago

sfmskywalker commented 3 months ago

Overview

Implement interactive JavaScript debugging capabilities for activity input fields configured with JavaScript expressions. Users should be able to debug expressions by clicking on a small button with a bug icon, similar to the functionality in Visual Studio and Rider.

Implementation Details

  1. User Interaction:

    • Add a button with a bug icon next to activity input fields.
    • Clicking the button initiates the debugging process.
  2. Backend Integration:

    • Make an API or SignalR call to the backend when the button is clicked.
    • Use Jint to evaluate the JavaScript expression step-by-step on the backend.
    • The backend should send debugging events to the client via SignalR.
  3. Client-side Debugging:

    • Use Monaco Editor to display and interact with the JavaScript code.
    • The client should be able to step through the code and inspect local variables.
    • Monaco Editor should update to highlight the current line and display variable states.

Dependencies

Topics to Research

Resources

Goals

glime-ai[bot] commented 3 months ago

To implement interactive JavaScript debugging capabilities for activity input fields configured with JavaScript expressions in Elsa Workflow, you would need to follow the implementation details provided. Here's a summary of the steps you would take:

  1. User Interaction:

    • Implement a UI component (a button with a bug icon) next to each activity input field that supports JavaScript expressions.
    • Attach an event handler to the button that triggers the debugging process when clicked.
  2. Backend Integration:

    • Develop an API endpoint or set up a SignalR hub on the backend that can receive debugging requests.
    • Utilize the Jint library to evaluate JavaScript expressions in a step-by-step manner, allowing for breakpoints and stepping through the code.
    • Ensure that the backend can communicate with the client-side via SignalR to send debugging events and data.
  3. Client-side Debugging:

    • Integrate the Monaco Editor into the client-side application to allow users to view and interact with the JavaScript code.
    • Implement functionality in the Monaco Editor for stepping through code, setting breakpoints, and inspecting variables.
    • Update the Monaco Editor UI dynamically to reflect the current state of the debugging session, such as highlighting the current line of execution and showing variable values.
  4. Dependencies:

    • Ensure that there is a way for users to configure workflow variables with test values, which may require a separate feature implementation.
  5. Topics to Research:

    • Investigate how interactive debugging is implemented in the Monaco Editor and how to integrate it with the Elsa Workflow's JavaScript expressions.
  6. Resources:

    • Review the Jint Debugger Example and other resources related to the Monaco Editor to understand how to implement breakpoints and step-through debugging.
  7. Goals:

    • The main goal is to provide an enhanced user experience by allowing users to debug JavaScript expressions within the Elsa Workflow designer interactively.

Please note that this is a high-level overview, and the actual implementation will require detailed planning and development work. You would also need to consider error handling, security implications, and performance optimization as part of the development process.

This comment was generated by Glime.