vscode: New version 1.69 has missing `app_id` under wayland
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.69.0
- OS Version: Linux wayland backend
Steps to Reproduce:
- Under any wayland desktop
- Force wayland backend for vscode
$ cat ~/.config/code-flags.conf
--enable-features=UseOzonePlatform
--ozone-platform=wayland
- Any top level window under wayland is identified by
app_idwhich used to be equal to “code” and now it is an empty string.
This bug is probably caused by switching to electron 18, https://github.com/electron/electron/issues/33578
app_id is the only real way to differentiate windows under wayland if you are using a tiling window manager and want to pin some applications to some workspaces.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 31
- Comments: 26
Commits related to this issue
- vscodium: Workaround attempt 2 https://github.com/microsoft/vscode/issues/154693#issuecomment-1420923233 — committed to tennox/nixpkgs by deleted user a year ago
- vscodium: Workaround attempt 2 https://github.com/microsoft/vscode/issues/154693#issuecomment-1420923233 — committed to tennox/nixpkgs by deleted user a year ago
Can confirm this issue is still unaddressed in 1.80.0.
Can confirm. When launching VS Code on Wayland with the
--enable-features=UseOzonePlatformand--ozone-platform=waylandlaunch options the running app is displayed as a separate, unstyled app icon in my dock. This is still an issue in v1.69.2A workaround in KDE Plasma is to define a new window rule that matches window class
code-url-handler, and forces the desktop file name (app id) toCode. Feels a bit less hacky than editing the desktop file, and won’t break again when VSCode properly fixes this issue.We’ve fully addressed this issue in the Solus package. The key is to update the
.namefield in the package.json to match the name of the .desktop file without the.desktopsuffix, and to update the.desktopNamefield to match the full name of the .desktop file including the suffix. The reason this issue occurs is because of the following lines inbuild/gulpfile.vscode.js:This causes the resulting package.json to be generated with a
.desktopNamevalue ofcode-oss-url-handler.desktop. Electron reads from this field in order to set the app_id under Wayland (it will use the.namefield if.desktopNameisn’t set) and so the resulting Wayland window will have acode-oss-url-handlerapp_id. If on the other hand you override these values in the package install phase you can fix the issue:(Our .desktop file is
code-oss.desktop)As far as I can tell this has no side-effects on our package. VSCode windows startup with the correct app_id and are correctly associated with the .desktop launchers on both GNOME and Plasma.
Hell, it even fixes the “open file/folder” windows opening behind VSCode as they should now start with the correct app_id as well and so correctly be placed in front of the existing VScode window.
This is a poor solution that only works on GNOME. GNOME adds the value of the
StartupWMClassfield to the mapping of .desktop files to application windows. This is not standards-compliant and should be considered a hack at best. According to the FreeDesktop standards ONLY the name of the .desktop file is to be considered for window associations and this is how it is implemented on Plasma and wlroots-based compositors. So updating theStartupWMClasswould only “fix” it on GNOME, whereas the above solution will fix it on all DEs as it is actually updating the app_id to be the package-specified value.I can also reproduce it on VSCodium. Also I found as a workaround that changing the
codium.deskop(orcode.desktop) desktop file’sStartupWMClasstocodium-url-handler(orcode-url-handlerfor vscode) “fixes” the problem.Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.69.0. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!
I have the same problem of @EncryptedCicada. I set into
/home/my-user/.config/code-flags.conf:--enable-features=WaylandWindowDecorations --ozone-platform-hint=autoand when I start vscode from the pinned icon in the bottom bar, it starts a new process called Visual Studio Code - URL Handler. If i edit code.desktop and change theStartupWMClasstocode-url-handler, it starts the normal process. But I have to remove/rename desktop entry on each update. It’s a bit annoying. I’m on GNOME 44.2 and vscode 1.79.2Another way that worked for me is to override the
code.desktopandcode-url-handler.desktopfiles.In
~/.local/share/applicationsHave the original
code-url-handler.desktoprenamed to, for examplecode-url.desktopSymlink
code-url-handler.desktoptocode.desktopSet the handler for
x-scheme-handler/vscodetocode-url.desktopI had to override those files anyway to add
--ozone-platform-hint=autoAlso missing under wayland:
wmclass- so the app won’t have an icon.No, because I’m not familiar with the build system from the perspective of the people who develop VSCode with it. My changes to the
package.jsonhappen after the build server is finished building. The.desktopNamefield also has to match the primary .desktop file that is shipped by the distribution (assuming a build of code-oss or vscodium), so it’s not really something that can just be fixed once and that would fix all distributions since the file name of the .desktop file could easily be different.Presumably this line could be changed to
.desktopinstead of-url-handler.desktop, though I’m not familiar enough with the build to understand:Another approach would be for a VSCode developer to add a post-build step to fix the
.desktopNamefield. This would be sufficient to work around the issue in the official .deb/.rpm/.tar distributions of VSCode, although fixing the code referenced above would probably be the better solution (assuming that whatever that code is trying to work around still works, or even if why that code is that way is still known since it doesn’t have comments indicating why).If you are on a distribution and that distribution builds code-oss or VScodium please point them to my above comment. They’ll be able to use that information to work around this in their packages.
If you’re a VSCode developer interested in fixing the official distributions I recommend doing the following to test this:
desktopFileNameproperty is when running in Wayland-native mode and what theresourceClassproperty is when running under xwayland. The values of these needs to be identical and needs to match the name of the VSCode desktop file sans the.desktopextension. If you’ve done this then you’ve fixed this issue on all DEs.I am using 1.75.0 and still experiencing this issue. When Visual Studio Code is opened under Wayland, it’s another application called “Visual Studio Code - URL Handler” that actually shows up. It is not a huge deal but it’s always annoying to see two identical icons, as well as the window instances under the “URL Handler” on my dock.
Well the issue is a little bit different now. VS Code launches with the flags --enable-features=WaylandWindowDecorations and --ozone-platform-hint=auto albeit after several tries but reports the window title as “Visual Studio Code - URL Handler” instead of just Visual Studio Code. Also, the running application icon is separated from the pinned icon in the gnome dock whereas other pinned applications running just have the same icon with a little dot under the icon to indicate they are running.
same here with the incorrect code-url-handler app_id.
I updated to VS Code v1.71.0 today (with Electron 19) and this still is an issue.
Still an issue, Insiders 1.79.0, GNOME.