|
1 | | -import { Component, createMemo, type JSX } from "solid-js" |
| 1 | +import { Component, Show, createEffect, createMemo, createResource, type JSX } from "solid-js" |
2 | 2 | import { createStore } from "solid-js/store" |
3 | 3 | import { Button } from "@opencode-ai/ui/button" |
| 4 | +import { Icon } from "@opencode-ai/ui/icon" |
4 | 5 | import { Select } from "@opencode-ai/ui/select" |
5 | 6 | import { Switch } from "@opencode-ai/ui/switch" |
| 7 | +import { Tooltip } from "@opencode-ai/ui/tooltip" |
6 | 8 | import { useTheme, type ColorScheme } from "@opencode-ai/ui/theme" |
7 | 9 | import { showToast } from "@opencode-ai/ui/toast" |
8 | 10 | import { useLanguage } from "@/context/language" |
@@ -40,6 +42,8 @@ export const SettingsGeneral: Component = () => { |
40 | 42 | checking: false, |
41 | 43 | }) |
42 | 44 |
|
| 45 | + const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux") |
| 46 | + |
43 | 47 | const check = () => { |
44 | 48 | if (!platform.checkUpdate) return |
45 | 49 | setStore("checking", true) |
@@ -410,13 +414,49 @@ export const SettingsGeneral: Component = () => { |
410 | 414 | </SettingsRow> |
411 | 415 | </div> |
412 | 416 | </div> |
| 417 | + |
| 418 | + <Show when={linux()}> |
| 419 | + {(_) => { |
| 420 | + const [valueResource, actions] = createResource(() => platform.getDisplayBackend?.()) |
| 421 | + const value = () => (valueResource.state === "pending" ? undefined : valueResource.latest) |
| 422 | + |
| 423 | + const onChange = (checked: boolean) => |
| 424 | + platform.setDisplayBackend?.(checked ? "wayland" : "auto").finally(() => actions.refetch()) |
| 425 | + |
| 426 | + return ( |
| 427 | + <div class="flex flex-col gap-1"> |
| 428 | + <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.display")}</h3> |
| 429 | + |
| 430 | + <div class="bg-surface-raised-base px-4 rounded-lg"> |
| 431 | + <SettingsRow |
| 432 | + title={ |
| 433 | + <div class="flex items-center gap-2"> |
| 434 | + <span>{language.t("settings.general.row.wayland.title")}</span> |
| 435 | + <Tooltip value={language.t("settings.general.row.wayland.tooltip")} placement="top"> |
| 436 | + <span class="text-text-weak"> |
| 437 | + <Icon name="help" size="small" /> |
| 438 | + </span> |
| 439 | + </Tooltip> |
| 440 | + </div> |
| 441 | + } |
| 442 | + description={language.t("settings.general.row.wayland.description")} |
| 443 | + > |
| 444 | + <div data-action="settings-wayland"> |
| 445 | + <Switch checked={value() === "wayland"} onChange={onChange} /> |
| 446 | + </div> |
| 447 | + </SettingsRow> |
| 448 | + </div> |
| 449 | + </div> |
| 450 | + ) |
| 451 | + }} |
| 452 | + </Show> |
413 | 453 | </div> |
414 | 454 | </div> |
415 | 455 | ) |
416 | 456 | } |
417 | 457 |
|
418 | 458 | interface SettingsRowProps { |
419 | | - title: string |
| 459 | + title: string | JSX.Element |
420 | 460 | description: string | JSX.Element |
421 | 461 | children: JSX.Element |
422 | 462 | } |
|
0 commit comments