eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.93k stars 2.49k forks source link

[Electron Playwright] Theia electron app loader opens the app with multi-root workspace #13325

Open Maddobun opened 8 months ago

Maddobun commented 8 months ago

One of the issues mentioned in the Electron Playwright PR was that the app would always be launched with a multi-root workspace that contains the electron app dir and the tmp workspace directory initialized by the Theiaworkspace class.

It appears that Playwright prepends two additional arguments to argv when invoking Electron. Our CLI expects the first two argvs to be the electron bin and the app dir, so it fails and interpret the two raw path as input to the WorkspaceCli.

TheiaElectronAppLoader expects electron to be called like this:

Launching Electron with options: {"executablePath":"../electron-app/node_modules/.bin/electron","args":["../electron-app","--no-cluster","--app-project-path=../electron-app","--plugins=local-dir:../plugins","/tmp/cloud-ws-KObxO6"]}

But the actual argv is this:

<absolute_path_to_node_modules>/electron/dist/electron,--inspect=0,--remote-debugging-port=0,../electron-app,--no-cluster,--app-project-path=../electron-app,--plugins=local-dir:../plugins,/tmp/cloud-ws-KObxO6

For reference, we slice the argv list here: https://github.com/eclipse-theia/theia/blob/69d7cd017c7509ee9867bd778ee180db20b513f4/dev-packages/application-manager/src/generator/backend-generator.ts#L149

So normally the only path parameter that's passed into the cli would be the tmp workspace dir, while if launched with playwright the ../electron-app path will also be in this list.

Any comments on how to handle this properly?

xai commented 8 months ago

Hello @Maddobun! Thanks for raising this issue!

We need something more dynamic here to handle the arguments injected by Playwright. So either we have to adjust the TheiaElectronAppLoader to handle and ignore known "playwright arguments" or maybe there is something we can do with the playwright configuration here.

We plan to address this issue as part of our work on Electron Playwright together with the current issues when running on Windows.

Maddobun commented 7 months ago

https://github.com/microsoft/playwright/issues/29198 should close this issue, once the PR goes out to playwright release.