Skip to content

The agent that grows with you

refactor(desktop): drop the redundant WSL check from the ozone relaunch

Brooklyn Nicholson5c044552501c
diff --git a/apps/desktop/electron/entry.ts b/apps/desktop/electron/entry.ts
index da5b31fee98..63998750250 100644
--- a/apps/desktop/electron/entry.ts
+++ b/apps/desktop/electron/entry.ts
@@ -25,7 +25,7 @@ function configuredElectronFlags(env: NodeJS.ProcessEnv): string[] {
}
const electronFlags = process.platform === 'linux' ? configuredElectronFlags(process.env) : []
-const args = wslgLaunchArgs(process.argv.slice(1), process.env, process.platform, undefined, electronFlags)
+const args = wslgLaunchArgs(process.argv.slice(1), process.env, process.platform, electronFlags)
if (args) {
// Keep the launcher alive until the child exits: npm's concurrently must not
diff --git a/apps/desktop/electron/wslg-launch.test.ts b/apps/desktop/electron/wslg-launch.test.ts
index 844614fb314..1f756a793c4 100644
--- a/apps/desktop/electron/wslg-launch.test.ts
+++ b/apps/desktop/electron/wslg-launch.test.ts
@@ -34,7 +34,7 @@ describe('WSLg launch arguments', () => {
it('leaves other platforms, missing Wayland displays and forwarded sessions alone', () => {
expect(wslgLaunchArgs([], env, 'win32')).toBeNull()
expect(wslgLaunchArgs([], env, 'darwin')).toBeNull()
- expect(wslgLaunchArgs([], { DISPLAY: ':0' }, 'linux', false)).toBeNull()
+ expect(wslgLaunchArgs([], { DISPLAY: ':0' }, 'linux')).toBeNull()
expect(wslgLaunchArgs([], { WSL_DISTRO_NAME: 'Ubuntu' }, 'linux')).toBeNull()
expect(wslgLaunchArgs([], { ...env, SSH_CONNECTION: 'remote' }, 'linux')).toBeNull()
expect(wslgLaunchArgs([], { ...env, DISPLAY: 'localhost:10.0' }, 'linux')).toBeNull()
@@ -45,40 +45,40 @@ const nativeWayland = { XDG_SESSION_TYPE: 'wayland', WAYLAND_DISPLAY: 'wayland-0
describe('native Wayland launch arguments', () => {
it('appends wayland on a native Linux Wayland session when the user did not choose a platform', () => {
- expect(wslgLaunchArgs(['.'], nativeWayland, 'linux', false)).toEqual(['.', '--ozone-platform=wayland'])
- expect(wslgLaunchArgs([], { WAYLAND_DISPLAY: 'wayland-0', DISPLAY: ':0' }, 'linux', false)).toEqual([
+ expect(wslgLaunchArgs(['.'], nativeWayland, 'linux')).toEqual(['.', '--ozone-platform=wayland'])
+ expect(wslgLaunchArgs([], { WAYLAND_DISPLAY: 'wayland-0', DISPLAY: ':0' }, 'linux')).toEqual([
'--ozone-platform=wayland'
])
- expect(wslgLaunchArgs([], { XDG_SESSION_TYPE: 'wayland', DISPLAY: ':0' }, 'linux', false)).toEqual([
+ expect(wslgLaunchArgs([], { XDG_SESSION_TYPE: 'wayland', DISPLAY: ':0' }, 'linux')).toEqual([
'--ozone-platform=wayland'
])
- expect(wslgLaunchArgs(['--ozone-platform=wayland'], nativeWayland, 'linux', false)).toBeNull()
+ expect(wslgLaunchArgs(['--ozone-platform=wayland'], nativeWayland, 'linux')).toBeNull()
})
it('keeps an explicit x11 platform already on the command line', () => {
- expect(wslgLaunchArgs(['--ozone-platform=x11'], nativeWayland, 'linux', false)).toBeNull()
- expect(wslgLaunchArgs(['--ozone-platform', 'x11'], nativeWayland, 'linux', false)).toBeNull()
+ expect(wslgLaunchArgs(['--ozone-platform=x11'], nativeWayland, 'linux')).toBeNull()
+ expect(wslgLaunchArgs(['--ozone-platform', 'x11'], nativeWayland, 'linux')).toBeNull()
})
it('lets an x11 hint win over the automatic wayland platform', () => {
- expect(wslgLaunchArgs([], { ...nativeWayland, ELECTRON_OZONE_PLATFORM_HINT: 'x11' }, 'linux', false)).toEqual([
+ expect(wslgLaunchArgs([], { ...nativeWayland, ELECTRON_OZONE_PLATFORM_HINT: 'x11' }, 'linux')).toEqual([
'--ozone-platform=x11'
])
- expect(wslgLaunchArgs(['--ozone-platform-hint=x11'], nativeWayland, 'linux', false)).toEqual([
+ expect(wslgLaunchArgs(['--ozone-platform-hint=x11'], nativeWayland, 'linux')).toEqual([
'--ozone-platform-hint=x11',
'--ozone-platform=x11'
])
})
it('lets desktop.electron_flags choose the ozone platform instead of forcing wayland', () => {
- expect(wslgLaunchArgs([], nativeWayland, 'linux', false, ['--ozone-platform=x11'])).toEqual([
+ expect(wslgLaunchArgs([], nativeWayland, 'linux', ['--ozone-platform=x11'])).toEqual([
'--ozone-platform=x11'
])
- expect(wslgLaunchArgs(['.'], nativeWayland, 'linux', false, ['--disable-gpu'])).toEqual([
+ expect(wslgLaunchArgs(['.'], nativeWayland, 'linux', ['--disable-gpu'])).toEqual([
'.',
'--ozone-platform=wayland'
])
- expect(wslgLaunchArgs([], { XDG_SESSION_TYPE: 'x11', DISPLAY: ':0' }, 'linux', false)).toBeNull()
- expect(wslgLaunchArgs([], { ...nativeWayland, SSH_CONNECTION: 'remote' }, 'linux', false)).toBeNull()
+ expect(wslgLaunchArgs([], { XDG_SESSION_TYPE: 'x11', DISPLAY: ':0' }, 'linux')).toBeNull()
+ expect(wslgLaunchArgs([], { ...nativeWayland, SSH_CONNECTION: 'remote' }, 'linux')).toBeNull()
})
})
diff --git a/apps/desktop/electron/wslg-launch.ts b/apps/desktop/electron/wslg-launch.ts
index 5d47aa25469..e769344ec43 100644
--- a/apps/desktop/electron/wslg-launch.ts
+++ b/apps/desktop/electron/wslg-launch.ts
@@ -1,4 +1,4 @@
-import { detectRemoteDisplay, isWslEnvironment } from './bootstrap-platform'
+import { detectRemoteDisplay } from './bootstrap-platform'
// Ozone is selected before application JavaScript. Never appendSwitch here:
// that leaves the browser on X11 while GPU children receive Wayland.
@@ -6,7 +6,6 @@ export function wslgLaunchArgs(
argv: readonly string[],
env: NodeJS.ProcessEnv,
platform: NodeJS.Platform,
- isWsl = isWslEnvironment(env, platform),
electronFlags: readonly string[] = []
): string[] | null {
const displayEnv = { ...env, HERMES_DESKTOP_DISABLE_GPU: undefined }
@@ -18,14 +17,10 @@ export function wslgLaunchArgs(
return null
}
- const nativeWayland = env.XDG_SESSION_TYPE === 'wayland' || Boolean(env.WAYLAND_DISPLAY)
- const wslgWayland = Boolean(isWsl && env.WAYLAND_DISPLAY)
+ // WSLg always exports WAYLAND_DISPLAY, so it is covered by the same check.
+ const wayland = env.XDG_SESSION_TYPE === 'wayland' || Boolean(env.WAYLAND_DISPLAY)
- if (!nativeWayland && !wslgWayland) {
- return null
- }
-
- if (hasOzonePlatform(argv)) {
+ if (!wayland || hasOzonePlatform(argv)) {
return null
}