xstate-viz icon indicating copy to clipboard operation
xstate-viz copied to clipboard

running parent machine with 2 children through invoke duplicates first child displayed and the one invoked by parent is not interactive

Open mogarick opened this issue 2 years ago • 2 comments

Description Creating 1 parent machine and 2 children is making the viz create the 3 machines independently (without parent) first and then creating a new instance of the first child called from the parent but with this last one not being interactive. The viz shows the first child instance (without parent) but when viewing the invoked one (via Actors tab) such state chart cannot be interacted with.

Expected Result When creating a child machine and then invoking it from the parent, the same child machine instance should be used and it should be possible to interact with it.

Actual Result When creating a child machine and then invoking it from the parent, a new child machine instance is created and it's not possible to interact with it.

Reproduction

Given 2 children machines(authNavigationStateMachine and appNavStateMachine) and one parent appRuntimeStateMachine that invokes authNavigationStateMachine on init, the "Actors" tab shows 4, with the authNavigationStateMachine apparently duplicated:

-> authNavigationStateMachine (x:57) -> appNavStateMachine (x:58) -> appRuntimeStateMachine (x:59) -> appRuntimeStateMachine (x:59) → authNavigationStateMachine (x:61)

the viz shows authNavigationStateMachine (x:57) which is not the one invoked by appRuntimeStateMachine (x:59) so when clicking the event that transitions to the authNavigationStateMachine final state it doesn't get back to the parent.

Going to the "Actors" tab and clicking on "-> appRuntimeStateMachine (x:59) → authNavigationStateMachine (x:61)" shows the authNavigationStateMachine but clicking on any event doesn't work.

Additional context

Link to the viz file.

https://stately.ai/viz/dcd508c8-0915-4c3f-9ad3-d881a1f37d0f#

mogarick avatar Dec 10 '21 20:12 mogarick

Hello @mattpocock,

would you take a look at this issue or triage it to someone else please?

Thank you in advance. :)

mogarick avatar Jan 20 '22 19:01 mogarick

Hi @mogarick, I faced the same issue when trying to interact with a child actor: the events are not simulated.

Imho showing multiple instances of child actors (one "general" instance and child instances of other actors) might be useful though.

The issue of events to be not simulated seems to be caused by the underlying simulator to not taking child actors (which might be spawned/invoked dynamically) into account and searching through the "root" actors only.

I create a PR with a potential fix for this issue.

MarianPalkus avatar Feb 24 '22 19:02 MarianPalkus