Skip to content

Add extended graph and dummy auto-layout #59#77

Open
handreyrc wants to merge 1 commit intoserverlessworkflow:mainfrom
handreyrc:add-graph
Open

Add extended graph and dummy auto-layout #59#77
handreyrc wants to merge 1 commit intoserverlessworkflow:mainfrom
handreyrc:add-graph

Conversation

@handreyrc
Copy link
Copy Markdown
Contributor

@handreyrc handreyrc commented Apr 13, 2026

Closes #59

Summary

This PR adds dummy auto-layout and extended graph types.

Changes

  • Added custom graph implementation with extended types to support:
    • Node size
    • Node position
    • Edge types (DEFAULT, ERROR and CONDITION)
    • Edge waypoints
  • Added buildGraph function to sdk wrapper
  • Added dummy auto-layout with fixed coordinates
  • Tests for extended graph types
  • Test for dummy auto-layout

Copilot AI review requested due to automatic review settings April 13, 2026 22:59
@handreyrc handreyrc changed the title Add extendended graph and dummy auto-layout #59 Add extended graph and dummy auto-layout #59 Apr 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SDK graph generation support to the diagram editor core by introducing extended graph types (node size/position, edge types/waypoints), exposing a buildGraph wrapper, and providing a dummy auto-layout implementation with accompanying tests/snapshots.

Changes:

  • Added extended graph type definitions and edge-type enrichment (solveEdgeTypes).
  • Exposed buildGraph via the core SDK wrapper and re-exported core modules.
  • Added a dummy applyAutoLayout implementation plus integration/unit tests and snapshots.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts Added new JSON/YAML workflow fixtures used by graph + auto-layout tests.
packages/serverless-workflow-diagram-editor/tests/core/workflowSdk.integration.test.ts Added integration coverage for buildGraph and extended graph typing/snapshot.
packages/serverless-workflow-diagram-editor/tests/core/graph.test.ts New unit tests for edge type enrichment across default/error/condition/nested cases.
packages/serverless-workflow-diagram-editor/tests/core/autoLayout.integration.test.ts New integration test verifying dummy auto-layout positions/sizes and snapshot.
packages/serverless-workflow-diagram-editor/tests/core/snapshots/workflowSdk.integration.test.ts.snap Snapshot for buildGraph result.
packages/serverless-workflow-diagram-editor/tests/core/snapshots/autoLayout.integration.test.ts.snap Snapshot for applyAutoLayout result.
packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts Switched to SDK namespace import; added buildGraph wrapper returning extended graph.
packages/serverless-workflow-diagram-editor/src/core/index.ts Re-exported graph and autoLayout modules.
packages/serverless-workflow-diagram-editor/src/core/graph.ts Added extended graph types and solveEdgeTypes.
packages/serverless-workflow-diagram-editor/src/core/autoLayout.ts Added dummy applyAutoLayout implementation to set size/position.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@lornakelly lornakelly left a comment

Choose a reason for hiding this comment

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

Thanks for PR Handrey, nice work. Just a few comments

}

export function buildGraph(model: sdk.Specification.Workflow): ExtendedGraph {
return solveEdgeTypes(sdk.buildGraph(model));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wondering should we wrap this in a try/catch in case sdk buildGraph throws and maybe worth splitting into 2 steps first call sdk.buildGraph(model) and get result and then pass to solveEdgeTypes? wdyt?

Copy link
Copy Markdown
Contributor Author

@handreyrc handreyrc Apr 14, 2026

Choose a reason for hiding this comment

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

@lornakelly,

The buildGraph is an extension of the original function in the SDK. A try/catch would just catch the exception and throw the same exception to the caller to be handled. I think we should leave the exception handling to the callers. Same as using the original method from the skd.
WDYT?

* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be good to have some negative test cases as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lornakelly
The code that builds the graph is actually in the sdk, so we should trust it from the perspective of the editor's components. We are just adding some properties on top of it.

WDYT?

Copilot AI review requested due to automatic review settings April 14, 2026 20:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings April 14, 2026 21:03
@handreyrc handreyrc requested a review from lornakelly April 14, 2026 21:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +95 to +96
const { model } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS);
expect(model).not.toBeNull();
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

This buildGraph integration test uses parseWorkflow but doesn't assert that errors is empty before calling buildGraph(model!). Since parseWorkflow includes SDK validation, the test should explicitly check there are no validation errors to avoid masking fixture/SDK regressions.

Suggested change
const { model } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS);
expect(model).not.toBeNull();
const { model, errors } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS);
expect(model).not.toBeNull();
expect(errors).toHaveLength(0);

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +25
const graph = buildGraph(result.model!);

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

In this test, parseWorkflow can return a non-null model and validation errors. Since the test is asserting behavior on a "valid" workflow graph, it should also assert result.errors is empty (and avoid relying on model!) to prevent silently passing with an invalid fixture/SDK validation failure.

Suggested change
const graph = buildGraph(result.model!);
expect(result.errors).toEqual([]);
expect(result.model).toBeDefined();
if (!result.model) {
throw new Error("Expected parseWorkflow to return a model for a valid workflow fixture.");
}
const graph = buildGraph(result.model);

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +33
const { model } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS);
expect(model).not.toBeNull();

const graph = buildGraph(model!);
expect(graph).not.toBeNull();
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

These tests treat the workflows as valid inputs to buildGraph, but they only check model and ignore parseWorkflow(...).errors. Since parseWorkflow performs SDK validation, please assert errors is empty (and only then call buildGraph) so the graph edge-type assertions don't pass when validation fails for the fixture.

Copilot uses AI. Check for mistakes.
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.

feat: Set up model to extendended graph structure generation and dummy auto-layout

3 participants