#Trying to edit machine in vs code visual editor, but it doesn't updates code.

1 messages · Page 1 of 1 (latest)

cunning grotto
#

I open visual editor in vs code, add some state, but code stays same. I recreated project several times with vite and reload vs code and extension several times, but no result. Do i miss something? I believe that while ago it was working right after i install extension

P.S. If i change actual code visual editor reacts and update its visual representation

prisma meteor
#

Is it possible for you to share a short recording of your problem (or some screenshots with explanations)?

I'm not sure I fully understand it 🤔

cunning grotto
prisma meteor
#

It looks like the extension breaks with the minimal create machine you're using const machine = createMachine({}); - I can verify that doesn't work on my machine either

#

If you add an id it should work:

const machine = createMachine({
  id: 'smallest possible machine',
});
#

But also we have the a cool snippet included with the extension you can try for creating machines. Try typing xsm and hitting tab, that should give you some boilerplate to get started

#

But thank you very much for this, we'll try to fix it in an upcoming version

cunning grotto
ashen quiver
#

hey @prisma meteor I stumbled upon this issue as well after working on a new machine in my codebase

#

other machines I had already built seem to edit fine

#

but I can't get a new machine to work, even using the xsm boilerplate code

#

its really odd, I managed to open the editor, edit the name of the inital state fine

#

but after trying to add a new state using the editor, the code stopped updating

#

im not sure if I broke something since the editor worked flawlessly when building other machines in the past (just a week ago)

prisma meteor
#

Sorry to hear that. Can you reproduce the error across VS Code restarts?

#

If you can I'd love to see a little recording, if possible, of what's going wrong

ashen quiver
#

yeah, sadly restarting VS code didn't help

#

give me a min I'll try to make a small reproduceable example

#

apparently now its not working at all

#

code changes make the editor react but not the other way around

#

let me know if the quality is too bad 😆

#

doesn't work either using your "smallest machine" snippet

#

but magically for older machine files it works perfectly

#

I can edit them using the editor and the code reflects the changes

#

I think it might have something to do with the /** @xstate-layout comment

#

I just tried copying an old machine's code into a new file

#
  • if I keep the same /** @xstate-layout comment from the old code, the editor works fine and it only edits the new file
  • if I delete the comment, it regenerates when starting the editor but it doesnt work
prisma meteor
#

Is this all happening inside the same project? Both old and new machines in the same project?

ashen quiver
#

yes same project

prisma meteor
#

is it a public repo, by any chance, so we can have a look?

ashen quiver
#

ok I think I found the issue

#

the problem is the position of the /** @xstate-layout comment

#

when making a new machine and opening the inspector, it places the comment inside the first object parameter of createMachine like this and it doesn't work:

#

now, if I put the createMachine in a new line and place the /** @xstate-layout comment between the nameofMachine = and createMachine like so:

#

it now works

#

I can write a GH issue with a little better explanation if that helps

prisma meteor
#

Thank you for the feedback. I'm going to use a life-line and call a friend - @wraith lodge do you have any idea of why this is happening?

ashen quiver
wraith lodge
#

@ashen quiver thanks for the issue - I will look into this, not sure why it doesn't work for you with the comment inside the object

ashen quiver
#

Awesome

#

Yeah its pretty odd, at first I though it was simply looking for the comment in another place but then I briefly looked at the extension's code and it seems to be expecting the comment to be inside the object as well. Not sure why it isnt finding it in my case

austere seal
#

I have the same issue, except the workaround doesn't help.

Extension version v1.14.1
VS Code version 1.77.3
Windows

The video is attached. The extension reports the following uncaught error:
Request applyMachineEdits failed with message: Unexpected token, expected "," (11:6)

It's my first time using xstate, so I don't have any old code to try this on.

Thanks!

ashen quiver
#

@wraith lodge I just now see your comment on the issue I opened, if you still need help debugging let me know and we can hop on a call

#

Please ping me here or dm me on discord, I don't keep up with github notifications that much

ashen quiver
austere seal
#

Hey @ashen quiver ! Tried just now - didn't help

ashen quiver
#

Dang, the extension still creates a secondary line?

wraith lodge
#

@ashen quiver @austere seal are any of you using, by any chance, a tab-based indentation?

ashen quiver
#

I'm using spaces: 2

untold stone