Skip to content

Conversation

@camielvs
Copy link
Collaborator

@camielvs camielvs commented Sep 19, 2025

Description

generateDynamicNodeCallbacks has now been replaced with convertNodeCallbacksToTaskCallbacks, which is much simpler in logic and has clearer typing.

This relates to the automatic generation of Task Callbacks during node creation, and, to make the distinction clearer, the input NodeData type has been separated from the internal TaskNodeData type.

Background explanation
A Task Node's callbacks are defined at the Flow-Canvas level in useNodeCallbacks and require the taskId and nodeId to be passed in so ReactFlow & ComponentSpec can be updated accordingly. However, within a task node, where these callbacks are executed, taskId and nodeId are already known and are static. Thus, we currently have a transform that occurs when Task Nodes are created to inject the known ids into the callback function. This saves us from having to manually pass in the ids when executing the callbacks within a node (e.g. in TaskNodeProvider).

This PR simplifies that conversion function significantly and institutes a clear division between the internal TaskNode data and the external node data needed to create the task node.

This PR is intended to start laying the groundwork for a node compatibility layer to be introduced, which will ultimately involve id generation at the task node creation level. Having simplified task creation code will make this process easier.

No change to app functionality.

Note/Follow-up:

  • Previously generateDynamicNodeCallbacks did the conversion dynamically. this new system requires the methods to be manually coded. Consider if there is a way to go back to a dynamic model so that any new methods don't need to be manually added

Related Issue and Pull requests

Closes https://github.com/Shopify/oasis-frontend/issues/334

Type of Change

  • Cleanup/Refactor

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

Test Instructions

  1. Create Task Nodes
  • Open a pipeline editor
  • Add multiple task nodes to the canvas
  • Verify nodes render correctly with proper positioning
  1. Test Node Callbacks
  • setArguments: Modify task arguments and verify they persist
  • setAnnotations: Move/resize nodes and verify position updates save
  • onDelete: Delete a task node and verify it's removed from the spec
  • onDuplicate: Duplicate a node (with/without selection) and verify the copy is created
  • onUpgrade: If applicable, upgrade a component and verify the node updates
  1. Create Input/Output Nodes
  • Create/verify input nodes render correctly
  • Create/verify output nodes render correctly
  • Connect task nodes to input/output nodes
  1. Edge Cases
  • Load a complex existing pipeline to verify node reconstruction works
  • Test with nodes that have no callbacks defined
  • Test with read-only nodes
  1. Regression Check
  • Run through a complete pipeline creation workflow
  • Save, reload, and verify state persistence
  • Execute a pipeline and verify it runs successfully

Expected Results
All functionality should behave identically to before the refactor. No visual or functional changes should be observed.

Additional Comments

Copy link
Collaborator Author

camielvs commented Sep 19, 2025

@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch 2 times, most recently from 9596f63 to 35a7502 Compare September 19, 2025 23:28
@camielvs camielvs changed the title Refactor TaskNode Callback Generation Refactor Dynamic Node Callbacks Sep 19, 2025
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 35a7502 to 0b3349b Compare September 19, 2025 23:42
This was referenced Sep 20, 2025
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 0b3349b to 87e51db Compare September 20, 2025 00:31
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 87e51db to b50521d Compare September 29, 2025 19:44
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from b50521d to 770419a Compare October 1, 2025 23:16
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 770419a to cbcb1f5 Compare October 7, 2025 22:53
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch 2 times, most recently from 55af5f0 to 62e8606 Compare October 10, 2025 18:08
This was referenced Oct 10, 2025
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 62e8606 to 97a70b0 Compare October 15, 2025 18:09
@camielvs camielvs marked this pull request as ready for review October 15, 2025 18:40
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 97a70b0 to 7051a11 Compare October 16, 2025 18:17
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 7051a11 to 3bdcabb Compare October 17, 2025 17:36
@camielvs camielvs requested a review from Mbeaulne October 17, 2025 18:45
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch 2 times, most recently from c426542 to 7bcc36b Compare October 23, 2025 16:35
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 7bcc36b to d9b0b7a Compare October 23, 2025 19:34
Comment on lines +12 to +13
readOnly?: boolean;
connectable?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

For future: do we have any instance of Graph to be readonly, BUT connectable? I feel that this is single property "readOnly".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's more the opposite scenario that's the concern: the graph is not readonly and node connection is disabled - specifically this lock button

image.png

I've been growing increasingly discontent with "readOnly" and how it's used specifically for the run route. I think in future we will want to take a look and properly make readOnly an actual read-only state regardless of the route.


export type TaskType = "task" | "input" | "output";

export interface NodeData extends Record<string, unknown> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For future: Do we need to have more arbitrary properties on this object? extending it from Record makes it harder to type causing weird code to appear down the road, e.g.

TaskNode:

const typedData = useMemo(() => data as TaskNodeData, [data]);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I vaguely recall trying to not extend and ReactFlow threw up a huge amount of type errors. There may be some larger changes need to our type structure to make this happen, but I do agree with the idea.

readOnly?: boolean;
isGhost?: boolean;
connectable?: boolean;
highlighted?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

For future: highlighted might not belong to the Node properties/data, but I'm not sure yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most likely the node overlay or highlighter you made would solve this but we haven't gotten around to looking into it.

Copy link
Collaborator

@maxy-shpfy maxy-shpfy left a comment

Choose a reason for hiding this comment

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

Tested, no immediate issues found

@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch 2 times, most recently from 5d5a668 to 0c9c20e Compare October 28, 2025 21:04
@maxy-shpfy maxy-shpfy marked this pull request as draft October 30, 2025 16:55
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 0c9c20e to 8a86e79 Compare October 30, 2025 19:10
@camielvs camielvs force-pushed the 09-19-refactor_tasknode_callback_generation branch from 8a86e79 to 9e0dc05 Compare October 31, 2025 00:23
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.

4 participants