statelyai / xstate-tools

Public monorepo for XState tooling
183 stars 40 forks source link

VSCode extension (1.7.2) does not show prompt for editor / inspector #96

Open mdpratt opened 2 years ago

mdpratt commented 2 years ago

The ability to open the visual editor or inspector is no longer working. I've validated that the issue is present all 1.7.x installs. I've downgraded to 1.6.0 for the time being, which is still working.

Version 1.6.0 image

Version 1.7.2 image

mattpocock commented 2 years ago

@mdpratt Can't repeat this on my machine, could you do two things:

  1. Give me info about your OS/node version
  2. Check the 'output' for XState in VSCode here. You might be able to spot some errors.

image

mdpratt commented 2 years ago

I'm using Remote-SSH to connect to an AWS EC2 instance that I develop from. As such, I'm not seeing an XState output in my list. Looking through other logs, I'm seeing a few things:

Log (Remote Exentsion)

[2022-03-07 11:26:52.546] [exthost] [info] ExtensionService#_doActivateExtension statelyai.stately-vscode, startup: false, activationEvent: 'onLanguage:typescript'

Remote host: OS:

NAME="Amazon Linux"
VERSION="2"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2:-:"
HOME_URL="https://amazonlinux.com/"

Local host:

mdpratt commented 2 years ago

Downgrading to v1.7.0 does produce this error though:

[2022-03-07 11:37:22.681] [exthost] [error] Activating extension statelyai.stately-vscode failed due to an error:
[2022-03-07 11:37:22.681] [exthost] [error] Error: Connection to server got closed. Server will not be restarted.
    at LanguageClient2.handleConnectionClosed (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:11926:43)
    at LanguageClient2.handleConnectionClosed (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:14324:15)
    at closeHandler (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:11900:16)
    at CallbackList.invoke (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3035:35)
    at Emitter.fire (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3086:34)
    at closeHandler (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:4181:24)
    at CallbackList.invoke (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3035:35)
    at Emitter.fire (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3086:34)
    at IPCMessageReader.fireClose (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3228:27)
    at ChildProcess.<anonymous> (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:5168:45)
    at ChildProcess.emit (events.js:327:22)
    at maybeClose (internal/child_process.js:1048:16)
    at Socket.<anonymous> (internal/child_process.js:439:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:673:12)
mdpratt commented 2 years ago

I've tried downgrading my Node to v16.14.0, and I've also tried using the extension only against a local project as well now, to no avail.

VillePakarinenPosti commented 2 years ago

I'm also experiencing similar issues with Versions 1.7.1 and 1.7.2. Using version 1.6.0 still shows the action buttons for opening visual editor and inspector same as in the issue description.

I'm currently running:

ProductName:    macOS
ProductVersion: 11.6
BuildVersion:   20G165

Node: v14.16.1

I also experimented downgrading to version 1.7.0 and that version will print out the following stacktrace to vscode output-console. This might be unrelated to the issue with the newer versions

internal/modules/cjs/loader.js:937
  throw err;

Error: Cannot find module 'prettier'
Require stack:
- /Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:934:15)
    at Module._load (internal/modules/cjs/loader.js:779:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:1006:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at ../../../packages/shared/dist/xstate-tools-shared.cjs.dev.js (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:88235:20)
    at __require (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:10:50)
    at ../../../packages/shared/dist/xstate-tools-shared.cjs.js (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:89006:25)
    at __require (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:10:50)
    at Object.<anonymous> (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:89015:36) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js'
  ]
}
[Info  - 12:17:37 PM] Connection to server got closed. Server will restart.
mattpocock commented 2 years ago

@VillePakarinenPosti The prettier issue is fixed by 1.7.1.

mattpocock commented 2 years ago

@VillePakarinenPosti @mdpratt Could you try downloading the VSIX from this GH action artifact?

https://github.com/statelyai/xstate-tools/actions/runs/1957631757

LMK if you need any help installing an extension from .vsix - it's available from the command palette in VSCode.

VillePakarinenPosti commented 2 years ago

@mattpocock Using the provided .vsix file fixed the issue for me.

mattpocock commented 2 years ago

Beautiful, thanks!

mdpratt commented 2 years ago

Unfortunately installing from the .vsix did not solve this issue for me. The machine causing this problem for me can be found here: https://codesandbox.io/s/jolly-shtern-sp9bnt?file=/src/import.ts

mattpocock commented 2 years ago

@mdpratt Thanks for the repro! I got pretty far with working out what's wrong.

It looks like we're failing at parsing a couple of things in your machine, and they're causing errors.

First, passing the key as a template literal is weirdly causing an error:

import { createMachine } from "xstate";

const machine = createMachine({
  key: `Nice`,
});

Second, declaring 'after' as an array is also causing an error:

import { createMachine } from "xstate";

const machine = createMachine({
  after: [
    {
      delay: 400,
    },
  ],
});

Both of these errors are swallowed, meaning you don't get any indication in the UI that something is wrong.

@mdpratt Could you confirm that if you create a new file with createMachine({}), the code lens options show up?

mdpratt commented 2 years ago

This worked for me. I can also confirm that the latest v1.7.3 also appears to work. Sometimes I have to close the tab and open it a few times to get it registering, but core functionality appears to be restored.

mattpocock commented 2 years ago

Fantastic, closing but @VillePakarinenPosti feel free to reopen if it doesn't work for you any more.

VillePakarinenPosti commented 2 years ago

Unfortunately the 1.7.3 didn't resolve the issue for me.

I'm not seeing any new errors with the latest version but it seems like my issue doesn't have anything to do with the parsing-phase since the extension fails even for the empty machine.

Custom 1.7.2 .vsix

image

Latest 1.7.3

image
mattpocock commented 2 years ago

@VillePakarinenPosti Any output in the output area of the extension?

Is there anything else in those files?

VillePakarinenPosti commented 2 years ago

Is there anything else in those files?

No. I just created an empty file to test if the issue was somehow related to the parsing you mentioned in https://github.com/statelyai/xstate-tools/issues/96#issuecomment-1063909271

Any output in the output area of the extension?

Unfortunately not. I would like to help debugging this further if you can provide a build which would be more verbose.

VSCode info:
Version: 1.65.2
Commit: c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
Date: 2022-03-10T14:33:49.188Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0
mattpocock commented 2 years ago

@VillePakarinenPosti Could you try putting your machine's code into this site:

https://xstate-parser-example-site.vercel.app/

To see if it parses correctly.

VillePakarinenPosti commented 2 years ago

Yeah it does and here is the parsed result for one of the machines:

[
  {
    "id": "LiveAgentMachine",
    "initial": "idle",
    "states": {
      "idle": {
        "always": {
          "target": "loading"
        }
      },
      "loading": {
        "invoke": {
          "src": "16ejqm",
          "id": "loadEmbbeddedService",
          "onDone": {
            "target": "success"
          },
          "onError": {
            "target": "failure",
            "actions": [
              "setError",
              "removeScript"
            ]
          }
        }
      },
      "success": {
        "initial": "boot",
        "exit": "cleanUpConnections",
        "states": {
          "boot": {
            "always": [
              {
                "target": "bootstrapped",
                "cond": "embeddedServiceRendered"
              },
              {
                "target": "idle"
              }
            ]
          },
          "idle": {
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          },
          "initializing": {
            "entry": "setChatOptions",
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            },
            "invoke": {
              "src": "initializeEmbeddedService",
              "id": "intializeEmbeddedService",
              "onDone": {
                "target": "initialized",
                "actions": "setAvailability"
              },
              "onError": {
                "target": "initializeFailed",
                "actions": "setError"
              }
            }
          },
          "initialized": {
            "on": {
              "AVAILABILITY_CHANGE": {
                "target": "initialized",
                "actions": "setAvailability"
              },
              "START_CHAT": {
                "target": "bootstrapping",
                "cond": "agentIsAvailable"
              },
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          },
          "initializeFailed": {
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          },
          "bootstrapping": {
            "after": {
              "60000": {
                "target": "bootstrappingFailed",
                "actions": "setError"
              }
            },
            "invoke": {
              "src": "1ch3grd",
              "id": "startChat",
              "onDone": {
                "target": "bootstrapped",
                "actions": "addAfterDestroyCleanup"
              },
              "onError": {
                "target": "bootstrappingFailed",
                "actions": "setError"
              }
            }
          },
          "bootstrapped": {
            "on": {
              "END_CHAT": {
                "target": "idle"
              }
            }
          },
          "bootstrappingFailed": {
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          }
        }
      },
      "failure": {}
    }
  }
]

I'm also using "@xstate/cli": "^0.1.3", which parses the machine correctly and generates the proper types. So the issue doesn't seem to be machine related.

mattpocock commented 2 years ago

@VillePakarinenPosti Apologies for letting this issue go a little cold. Can you confirm that with the latest builds, things aren't showing?

VillePakarinenPosti commented 2 years ago

Just installed the latest version v1.7.5 & updated vscode to version 1.66.2. Still facing the issue and no new findings from any of the output sources.

The custom .vsix build https://github.com/statelyai/xstate-tools/actions/runs/1957631757 still works.

Andarist commented 2 years ago

@VillePakarinenPosti would you be willing to schedule a call with me so we could figure out together what's going on there?