From 93a11ddedf697c9b673dd59628cee3db48ac67d0 Mon Sep 17 00:00:00 2001 From: Israel Araújo de Oliveira Date: Mon, 9 Feb 2026 06:00:35 -0300 Subject: feat(desktop): add native Wayland toggle on Linux (#11971) Co-authored-by: Brendan Allan --- packages/app/src/components/settings-general.tsx | 44 ++++++++++++++++++++++-- packages/app/src/context/platform.tsx | 8 +++++ packages/app/src/i18n/en.ts | 6 ++++ packages/app/src/index.ts | 2 +- 4 files changed, 57 insertions(+), 3 deletions(-) (limited to 'packages/app/src') diff --git a/packages/app/src/components/settings-general.tsx b/packages/app/src/components/settings-general.tsx index b31cfb6cc..db057a4c4 100644 --- a/packages/app/src/components/settings-general.tsx +++ b/packages/app/src/components/settings-general.tsx @@ -1,8 +1,10 @@ -import { Component, createMemo, type JSX } from "solid-js" +import { Component, Show, createEffect, createMemo, createResource, type JSX } from "solid-js" import { createStore } from "solid-js/store" import { Button } from "@opencode-ai/ui/button" +import { Icon } from "@opencode-ai/ui/icon" import { Select } from "@opencode-ai/ui/select" import { Switch } from "@opencode-ai/ui/switch" +import { Tooltip } from "@opencode-ai/ui/tooltip" import { useTheme, type ColorScheme } from "@opencode-ai/ui/theme" import { showToast } from "@opencode-ai/ui/toast" import { useLanguage } from "@/context/language" @@ -40,6 +42,8 @@ export const SettingsGeneral: Component = () => { checking: false, }) + const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux") + const check = () => { if (!platform.checkUpdate) return setStore("checking", true) @@ -410,13 +414,49 @@ export const SettingsGeneral: Component = () => { + + + {(_) => { + const [valueResource, actions] = createResource(() => platform.getDisplayBackend?.()) + const value = () => (valueResource.state === "pending" ? undefined : valueResource.latest) + + const onChange = (checked: boolean) => + platform.setDisplayBackend?.(checked ? "wayland" : "auto").finally(() => actions.refetch()) + + return ( +
+

{language.t("settings.general.section.display")}

+ +
+ + {language.t("settings.general.row.wayland.title")} + + + + + +
+ } + description={language.t("settings.general.row.wayland.description")} + > +
+ +
+ +
+ + ) + }} +
) } interface SettingsRowProps { - title: string + title: string | JSX.Element description: string | JSX.Element children: JSX.Element } diff --git a/packages/app/src/context/platform.tsx b/packages/app/src/context/platform.tsx index 3fca502ba..7aa6c6554 100644 --- a/packages/app/src/context/platform.tsx +++ b/packages/app/src/context/platform.tsx @@ -57,6 +57,12 @@ export type Platform = { /** Set the default server URL to use on app startup (platform-specific) */ setDefaultServerUrl?(url: string | null): Promise | void + /** Get the preferred display backend (desktop only) */ + getDisplayBackend?(): Promise | DisplayBackend | null + + /** Set the preferred display backend (desktop only) */ + setDisplayBackend?(backend: DisplayBackend): Promise + /** Parse markdown to HTML using native parser (desktop only, returns unprocessed code blocks) */ parseMarkdown?(markdown: string): Promise @@ -70,6 +76,8 @@ export type Platform = { readClipboardImage?(): Promise } +export type DisplayBackend = "auto" | "wayland" + export const { use: usePlatform, provider: PlatformProvider } = createSimpleContext({ name: "Platform", init: (props: { value: Platform }) => { diff --git a/packages/app/src/i18n/en.ts b/packages/app/src/i18n/en.ts index 8fba6861b..f4f49f055 100644 --- a/packages/app/src/i18n/en.ts +++ b/packages/app/src/i18n/en.ts @@ -588,6 +588,7 @@ export const dict = { "settings.general.section.notifications": "System notifications", "settings.general.section.updates": "Updates", "settings.general.section.sounds": "Sound effects", + "settings.general.section.display": "Display", "settings.general.row.language.title": "Language", "settings.general.row.language.description": "Change the display language for OpenCode", @@ -598,6 +599,11 @@ export const dict = { "settings.general.row.font.title": "Font", "settings.general.row.font.description": "Customise the mono font used in code blocks", + "settings.general.row.wayland.title": "Use native Wayland", + "settings.general.row.wayland.description": "Disable X11 fallback on Wayland. Requires restart.", + "settings.general.row.wayland.tooltip": + "On Linux with mixed refresh-rate monitors, native Wayland can be more stable.", + "settings.general.row.releaseNotes.title": "Release notes", "settings.general.row.releaseNotes.description": "Show What's New popups after updates", diff --git a/packages/app/src/index.ts b/packages/app/src/index.ts index fb6682009..59e1431fa 100644 --- a/packages/app/src/index.ts +++ b/packages/app/src/index.ts @@ -1,3 +1,3 @@ -export { PlatformProvider, type Platform } from "./context/platform" +export { PlatformProvider, type Platform, type DisplayBackend } from "./context/platform" export { AppBaseProviders, AppInterface } from "./app" export { useCommand } from "./context/command" -- cgit v1.2.3