Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: re-importing breaks logic in stately.ai v5 beta #207

Open
nickerlan opened this issue Jul 16, 2023 · 3 comments
Open

Bug: re-importing breaks logic in stately.ai v5 beta #207

nickerlan opened this issue Jul 16, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@nickerlan
Copy link

Description

v4 export - import works fine:

import {createMachine} from 'xstate'

export const machine = createMachine({
  "id": "Test Machine",
  "context": {},
  "initial": "Incomming message",
  "states": {
    "Incomming message": {
      "always": [
        {
          "target": "Admin-Group",
          "cond": "Mode: First"
        },
        {
          "target": "Client-bot",
          "cond": "Mode: Second"
        }
      ]
    },
    "Admin-Group": {
      "initial": "Idle",
      "states": {
        "Idle": {}
      }
    },
    "Client-bot": {
      "initial": "Main Menu",
      "states": {
        "Main Menu": {}
      }
    }
  },
  "predictableActionArguments": true,
  "preserveActionOrder": true
}, {
          actions: {},
          services: {},
          guards: {"Mode: First": (context, event) => false,
"Mode: Second": (context, event) => false},
          delays: {},
        })

v5 export - import breaks guard condition:

import {createMachine} from 'xstate'

export const machine = createMachine({
  "id": "Test Machine",
  "context": {},
  "initial": "Incomming message",
  "states": {
    "Incomming message": {
      "always": [
        {
          "target": "Admin-Group",
          "guard": "Mode: First"
        },
        {
          "target": "Client-bot",
          "guard": "Mode: Second"
        }
      ]
    },
    "Admin-Group": {
      "initial": "Idle",
      "states": {
        "Idle": {}
      }
    },
    "Client-bot": {
      "initial": "Main Menu",
      "states": {
        "Main Menu": {}
      }
    }
  }
}, {
          actions: {},
          actors: {},
          guards: {"Mode: First": ({ context, event }) => false,
"Mode: Second": ({ context, event }) => false},
          delays: {},
        })

Expected result

I expect to have kind of interop with my implementation to have a way both to make changes in code and on the chart.

Actual result

Re-imporing treats Else statement as never reachable. First "always" action lost its Guard.

Reproduction

https://stately.ai/viz/209cd168-afb1-4168-b967-85c078ee7229

Additional context

No response

@nickerlan nickerlan added the bug Something isn't working label Jul 16, 2023
@davidkpiano
Copy link
Member

Where are you exporting and importing v4 and v5?

@inverted-capital
Copy link

I see the same, if I try to import code in v5, it losses my guard definitions. I haven't figured out what the repro is, since I can take a functioning studio project, export in v5 and then re-import in v5, but I have a specific project that loses the guards. The machine is here: https://github.com/dreamcatcher-tech/ether-dream/blob/d8e45d66764a6e7a6d439ca56227ff54ce109303/test/multi/multiMachine.js

Sorry I can't be more use - that is a big machine, and it was exported using v5, now I can't re-import it.

@davidkpiano
Copy link
Member

I see the same, if I try to import code in v5, it losses my guard definitions. I haven't figured out what the repro is, since I can take a functioning studio project, export in v5 and then re-import in v5, but I have a specific project that loses the guards. The machine is here: https://github.com/dreamcatcher-tech/ether-dream/blob/d8e45d66764a6e7a6d439ca56227ff54ce109303/test/multi/multiMachine.js

Sorry I can't be more use - that is a big machine, and it was exported using v5, now I can't re-import it.

A fix for this is in progress (cc. @farskid)

@davidkpiano davidkpiano transferred this issue from statelyai/xstate Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants