settings-general.tsx 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. import { Component, Show, createMemo, createResource, onMount, type JSX } from "solid-js"
  2. import { Button } from "@opencode-ai/ui/button"
  3. import { Icon } from "@opencode-ai/ui/icon"
  4. import { Select } from "@opencode-ai/ui/select"
  5. import { Switch } from "@opencode-ai/ui/switch"
  6. import { TextField } from "@opencode-ai/ui/text-field"
  7. import { Tooltip } from "@opencode-ai/ui/tooltip"
  8. import { Tag } from "@opencode-ai/ui/v2/badge-v2"
  9. import { useTheme, type ColorScheme } from "@opencode-ai/ui/theme/context"
  10. import { useDialog } from "@opencode-ai/ui/context/dialog"
  11. import { useParams } from "@solidjs/router"
  12. import { useLanguage } from "@/context/language"
  13. import { usePermission } from "@/context/permission"
  14. import { usePlatform, type DisplayBackend } from "@/context/platform"
  15. import { useServerSync } from "@/context/server-sync"
  16. import { useServerSDK } from "@/context/server-sdk"
  17. import { useUpdaterAction } from "./updater-action"
  18. import {
  19. monoDefault,
  20. monoFontFamily,
  21. monoInput,
  22. sansDefault,
  23. sansFontFamily,
  24. sansInput,
  25. terminalDefault,
  26. terminalFontFamily,
  27. terminalInput,
  28. useSettings,
  29. } from "@/context/settings"
  30. import { decode64 } from "@/utils/base64"
  31. import { playSoundById, SOUND_OPTIONS } from "@/utils/sound"
  32. import { Link } from "./link"
  33. import { SettingsList } from "./settings-list"
  34. let demoSoundState = {
  35. cleanup: undefined as (() => void) | undefined,
  36. timeout: undefined as NodeJS.Timeout | undefined,
  37. run: 0,
  38. }
  39. type ThemeOption = {
  40. id: string
  41. name: string
  42. }
  43. type ShellOption = {
  44. path: string
  45. name: string
  46. acceptable: boolean
  47. }
  48. type ShellSelectOption = {
  49. id: string
  50. value: string
  51. label: string
  52. }
  53. // To prevent audio from overlapping/playing very quickly when navigating the settings menus,
  54. // delay the playback by 100ms during quick selection changes and pause existing sounds.
  55. const stopDemoSound = () => {
  56. demoSoundState.run += 1
  57. if (demoSoundState.cleanup) {
  58. demoSoundState.cleanup()
  59. }
  60. clearTimeout(demoSoundState.timeout)
  61. demoSoundState.cleanup = undefined
  62. }
  63. const playDemoSound = (id: string | undefined) => {
  64. stopDemoSound()
  65. if (!id) return
  66. const run = ++demoSoundState.run
  67. demoSoundState.timeout = setTimeout(() => {
  68. void playSoundById(id).then((cleanup) => {
  69. if (demoSoundState.run !== run) {
  70. cleanup?.()
  71. return
  72. }
  73. demoSoundState.cleanup = cleanup
  74. })
  75. }, 100)
  76. }
  77. export const SettingsGeneral: Component = () => {
  78. const theme = useTheme()
  79. const language = useLanguage()
  80. const permission = usePermission()
  81. const platform = usePlatform()
  82. const dialog = useDialog()
  83. const params = useParams()
  84. const settings = useSettings()
  85. const updater = useUpdaterAction()
  86. const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux")
  87. const dir = createMemo(() => decode64(params.dir))
  88. const accepting = createMemo(() => {
  89. const value = dir()
  90. if (!value) return false
  91. if (!params.id) return permission.isAutoAcceptingDirectory(value)
  92. return permission.isAutoAccepting(params.id, value)
  93. })
  94. const toggleAccept = (checked: boolean) => {
  95. const value = dir()
  96. if (!value) return
  97. if (!params.id) {
  98. if (permission.isAutoAcceptingDirectory(value) === checked) return
  99. permission.toggleAutoAcceptDirectory(value)
  100. return
  101. }
  102. if (checked) {
  103. permission.enableAutoAccept(params.id, value)
  104. return
  105. }
  106. permission.disableAutoAccept(params.id, value)
  107. }
  108. const desktop = createMemo(() => platform.platform === "desktop")
  109. const themeOptions = createMemo<ThemeOption[]>(() => theme.ids().map((id) => ({ id, name: theme.name(id) })))
  110. const serverSync = useServerSync()
  111. const serverSdk = useServerSDK()
  112. const [shells] = createResource(
  113. () =>
  114. serverSdk()
  115. .client.pty.shells()
  116. .then((res) => res.data ?? [])
  117. .catch(() => [] as ShellOption[]),
  118. { initialValue: [] as ShellOption[] },
  119. )
  120. const [displayBackend, { refetch: refetchDisplayBackend }] = createResource(
  121. () => (linux() && platform.getDisplayBackend ? true : false),
  122. () => Promise.resolve(platform.getDisplayBackend?.() ?? null).catch(() => null as DisplayBackend | null),
  123. { initialValue: null as DisplayBackend | null },
  124. )
  125. const [pinchZoom, { mutate: setPinchZoom }] = createResource(
  126. () => (desktop() && platform.getPinchZoomEnabled ? true : false),
  127. () => Promise.resolve(platform.getPinchZoomEnabled?.() ?? false).catch(() => false),
  128. { initialValue: false },
  129. )
  130. onMount(() => {
  131. void theme.loadThemes()
  132. })
  133. const autoOption = { id: "auto", value: "", label: language.t("settings.general.row.shell.autoDefault") }
  134. const currentShell = createMemo(() => serverSync().data.config.shell ?? "")
  135. const shellOptions = createMemo<ShellSelectOption[]>(() => {
  136. const list = shells.latest
  137. const current = serverSync().data.config.shell
  138. const nameCounts = new Map<string, number>()
  139. for (const s of list) {
  140. nameCounts.set(s.name, (nameCounts.get(s.name) || 0) + 1)
  141. }
  142. const options = [
  143. autoOption,
  144. ...list.map((s) => {
  145. const ambiguousName = (nameCounts.get(s.name) || 0) > 1
  146. const text = ambiguousName ? s.path : s.name
  147. const label = s.acceptable ? text : `${text} (${language.t("settings.general.row.shell.terminalOnly")})`
  148. return {
  149. id: s.path,
  150. // Prefer name over path - "bash" is much cleaner than the explicit full route even when it may change due to PATH.
  151. value: ambiguousName ? s.path : s.name,
  152. label,
  153. }
  154. }),
  155. ]
  156. if (current && !options.some((o) => o.value === current)) {
  157. options.push({ id: current, value: current, label: current })
  158. }
  159. return options
  160. })
  161. const onDisplayBackendChange = (checked: boolean) => {
  162. const update = platform.setDisplayBackend?.(checked ? "wayland" : "auto")
  163. if (!update) return
  164. void update.finally(() => {
  165. void refetchDisplayBackend()
  166. })
  167. }
  168. const onPinchZoomChange = (checked: boolean) => {
  169. setPinchZoom(checked)
  170. const update = platform.setPinchZoomEnabled?.(checked)
  171. if (!update) return
  172. void update.catch(() => setPinchZoom(!checked))
  173. }
  174. const colorSchemeOptions = createMemo((): { value: ColorScheme; label: string }[] => [
  175. { value: "system", label: language.t("theme.scheme.system") },
  176. { value: "light", label: language.t("theme.scheme.light") },
  177. { value: "dark", label: language.t("theme.scheme.dark") },
  178. ])
  179. const languageOptions = createMemo(() =>
  180. language.locales.map((locale) => ({
  181. value: locale,
  182. label: language.label(locale),
  183. })),
  184. )
  185. const noneSound = { id: "none", label: "sound.option.none" } as const
  186. const soundOptions = [noneSound, ...SOUND_OPTIONS]
  187. const mono = () => monoInput(settings.appearance.font())
  188. const sans = () => sansInput(settings.appearance.uiFont())
  189. const terminal = () => terminalInput(settings.appearance.terminalFont())
  190. const soundSelectProps = (
  191. enabled: () => boolean,
  192. current: () => string,
  193. setEnabled: (value: boolean) => void,
  194. set: (id: string) => void,
  195. ) => ({
  196. options: soundOptions,
  197. current: enabled() ? (soundOptions.find((o) => o.id === current()) ?? noneSound) : noneSound,
  198. value: (o: (typeof soundOptions)[number]) => o.id,
  199. label: (o: (typeof soundOptions)[number]) => language.t(o.label),
  200. onHighlight: (option: (typeof soundOptions)[number] | undefined) => {
  201. if (!option) return
  202. playDemoSound(option.id === "none" ? undefined : option.id)
  203. },
  204. onSelect: (option: (typeof soundOptions)[number] | undefined) => {
  205. if (!option) return
  206. if (option.id === "none") {
  207. setEnabled(false)
  208. stopDemoSound()
  209. return
  210. }
  211. setEnabled(true)
  212. set(option.id)
  213. playDemoSound(option.id)
  214. },
  215. variant: "secondary" as const,
  216. size: "small" as const,
  217. triggerVariant: "settings" as const,
  218. })
  219. const InterfaceSection = () => (
  220. <div class="flex flex-col gap-1">
  221. <SettingsList>
  222. <SettingsRow
  223. title={
  224. <span class="flex items-center gap-2">
  225. {language.t("settings.general.row.newInterface.title")}
  226. <Tag variant="accent">{language.t("settings.general.row.newInterface.badge")}</Tag>
  227. </span>
  228. }
  229. description={language.t("settings.general.row.newInterface.description")}
  230. >
  231. <div data-action="settings-new-layout-designs">
  232. <Switch
  233. checked={settings.general.newLayoutDesigns()}
  234. onChange={(checked) => {
  235. settings.general.setNewLayoutDesigns(checked)
  236. if (!checked) return
  237. void import("@/components/settings-v2").then((module) => {
  238. void dialog.show(() => <module.DialogSettings />)
  239. })
  240. }}
  241. />
  242. </div>
  243. </SettingsRow>
  244. </SettingsList>
  245. </div>
  246. )
  247. const InterfaceNoticeSection = () => (
  248. <div class="flex flex-col gap-1">
  249. <SettingsList>
  250. <SettingsRow
  251. title={language.t("settings.general.row.newInterfaceNotice.title")}
  252. description={language.t("settings.general.row.newInterfaceNotice.description")}
  253. >
  254. <Button size="small" variant="ghost" onClick={settings.general.dismissNewInterfaceNotice}>
  255. {language.t("settings.general.row.newInterfaceNotice.dismiss")}
  256. </Button>
  257. </SettingsRow>
  258. </SettingsList>
  259. </div>
  260. )
  261. const GeneralSection = () => (
  262. <div class="flex flex-col gap-1">
  263. <SettingsList>
  264. <SettingsRow
  265. title={language.t("settings.general.row.language.title")}
  266. description={language.t("settings.general.row.language.description")}
  267. >
  268. <Select
  269. data-action="settings-language"
  270. options={languageOptions()}
  271. current={languageOptions().find((o) => o.value === language.locale())}
  272. value={(o) => o.value}
  273. label={(o) => o.label}
  274. onSelect={(option) => option && language.setLocale(option.value)}
  275. variant="secondary"
  276. size="small"
  277. triggerVariant="settings"
  278. />
  279. </SettingsRow>
  280. <SettingsRow
  281. title={language.t("command.permissions.autoaccept.enable")}
  282. description={language.t("toast.permissions.autoaccept.on.description")}
  283. >
  284. <div data-action="settings-auto-accept-permissions">
  285. <Switch checked={accepting()} disabled={!dir()} onChange={toggleAccept} />
  286. </div>
  287. </SettingsRow>
  288. <SettingsRow
  289. title={language.t("settings.general.row.shell.title")}
  290. description={language.t("settings.general.row.shell.description")}
  291. >
  292. <Select
  293. data-action="settings-shell"
  294. options={shellOptions()}
  295. current={shellOptions().find((o) => o.value === currentShell()) ?? autoOption}
  296. value={(o) => o.id}
  297. label={(o) => o.label}
  298. onSelect={(option) => {
  299. if (!option) return
  300. if (option.value === currentShell()) return
  301. serverSync().updateConfig({ shell: option.value })
  302. }}
  303. variant="secondary"
  304. size="small"
  305. triggerVariant="settings"
  306. triggerStyle={{ "min-width": "180px" }}
  307. />
  308. </SettingsRow>
  309. <SettingsRow
  310. title={language.t("settings.general.row.reasoningSummaries.title")}
  311. description={language.t("settings.general.row.reasoningSummaries.description")}
  312. >
  313. <div data-action="settings-feed-reasoning-summaries">
  314. <Switch
  315. checked={settings.general.showReasoningSummaries()}
  316. onChange={(checked) => settings.general.setShowReasoningSummaries(checked)}
  317. />
  318. </div>
  319. </SettingsRow>
  320. <SettingsRow
  321. title={language.t("settings.general.row.shellToolPartsExpanded.title")}
  322. description={language.t("settings.general.row.shellToolPartsExpanded.description")}
  323. >
  324. <div data-action="settings-feed-shell-tool-parts-expanded">
  325. <Switch
  326. checked={settings.general.shellToolPartsExpanded()}
  327. onChange={(checked) => settings.general.setShellToolPartsExpanded(checked)}
  328. />
  329. </div>
  330. </SettingsRow>
  331. <SettingsRow
  332. title={language.t("settings.general.row.editToolPartsExpanded.title")}
  333. description={language.t("settings.general.row.editToolPartsExpanded.description")}
  334. >
  335. <div data-action="settings-feed-edit-tool-parts-expanded">
  336. <Switch
  337. checked={settings.general.editToolPartsExpanded()}
  338. onChange={(checked) => settings.general.setEditToolPartsExpanded(checked)}
  339. />
  340. </div>
  341. </SettingsRow>
  342. </SettingsList>
  343. </div>
  344. )
  345. const AdvancedSection = () => (
  346. <div class="flex flex-col gap-1">
  347. <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.advanced")}</h3>
  348. <SettingsList>
  349. <SettingsRow
  350. title={language.t("settings.general.row.showFileTree.title")}
  351. description={language.t("settings.general.row.showFileTree.description")}
  352. >
  353. <div data-action="settings-show-file-tree">
  354. <Switch
  355. checked={settings.general.showFileTree()}
  356. onChange={(checked) => settings.general.setShowFileTree(checked)}
  357. />
  358. </div>
  359. </SettingsRow>
  360. <SettingsRow
  361. title={language.t("settings.general.row.showNavigation.title")}
  362. description={language.t("settings.general.row.showNavigation.description")}
  363. >
  364. <div data-action="settings-show-navigation">
  365. <Switch
  366. checked={settings.general.showNavigation()}
  367. onChange={(checked) => settings.general.setShowNavigation(checked)}
  368. />
  369. </div>
  370. </SettingsRow>
  371. <SettingsRow
  372. title={language.t("settings.general.row.showSearch.title")}
  373. description={language.t("settings.general.row.showSearch.description")}
  374. >
  375. <div data-action="settings-show-search">
  376. <Switch
  377. checked={settings.general.showSearch()}
  378. onChange={(checked) => settings.general.setShowSearch(checked)}
  379. />
  380. </div>
  381. </SettingsRow>
  382. <SettingsRow
  383. title={language.t("settings.general.row.showStatus.title")}
  384. description={language.t("settings.general.row.showStatus.description")}
  385. >
  386. <div data-action="settings-show-status">
  387. <Switch
  388. checked={settings.general.showStatus()}
  389. onChange={(checked) => settings.general.setShowStatus(checked)}
  390. />
  391. </div>
  392. </SettingsRow>
  393. <SettingsRow
  394. title={language.t("settings.general.row.showCustomAgents.title")}
  395. description={language.t("settings.general.row.showCustomAgents.description")}
  396. >
  397. <div data-action="settings-show-custom-agents">
  398. <Switch
  399. checked={settings.general.showCustomAgents()}
  400. onChange={(checked) => settings.general.setShowCustomAgents(checked)}
  401. />
  402. </div>
  403. </SettingsRow>
  404. </SettingsList>
  405. </div>
  406. )
  407. const AppearanceSection = () => (
  408. <div class="flex flex-col gap-1">
  409. <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.appearance")}</h3>
  410. <SettingsList>
  411. <SettingsRow
  412. title={language.t("settings.general.row.colorScheme.title")}
  413. description={language.t("settings.general.row.colorScheme.description")}
  414. >
  415. <Select
  416. data-action="settings-color-scheme"
  417. options={colorSchemeOptions()}
  418. current={colorSchemeOptions().find((o) => o.value === theme.colorScheme())}
  419. value={(o) => o.value}
  420. label={(o) => o.label}
  421. onSelect={(option) => option && theme.setColorScheme(option.value)}
  422. variant="secondary"
  423. size="small"
  424. triggerVariant="settings"
  425. triggerStyle={{ "min-width": "220px" }}
  426. />
  427. </SettingsRow>
  428. <SettingsRow
  429. title={language.t("settings.general.row.theme.title")}
  430. description={
  431. <>
  432. {language.t("settings.general.row.theme.description")}{" "}
  433. <Link href="https://opencode.ai/docs/themes/">{language.t("common.learnMore")}</Link>
  434. </>
  435. }
  436. >
  437. <Select
  438. data-action="settings-theme"
  439. options={themeOptions()}
  440. current={themeOptions().find((o) => o.id === theme.themeId())}
  441. value={(o) => o.id}
  442. label={(o) => o.name}
  443. onSelect={(option) => {
  444. if (!option) return
  445. theme.setTheme(option.id)
  446. }}
  447. variant="secondary"
  448. size="small"
  449. triggerVariant="settings"
  450. />
  451. </SettingsRow>
  452. <SettingsRow
  453. title={language.t("settings.general.row.uiFont.title")}
  454. description={language.t("settings.general.row.uiFont.description")}
  455. >
  456. <div class="w-full sm:w-[220px]">
  457. <TextField
  458. data-action="settings-ui-font"
  459. label={language.t("settings.general.row.uiFont.title")}
  460. hideLabel
  461. type="text"
  462. value={sans()}
  463. onChange={(value) => settings.appearance.setUIFont(value)}
  464. placeholder={sansDefault}
  465. spellcheck={false}
  466. autocorrect="off"
  467. autocomplete="off"
  468. autocapitalize="off"
  469. class="text-12-regular"
  470. style={{ "font-family": sansFontFamily(settings.appearance.uiFont()) }}
  471. />
  472. </div>
  473. </SettingsRow>
  474. <SettingsRow
  475. title={language.t("settings.general.row.font.title")}
  476. description={language.t("settings.general.row.font.description")}
  477. >
  478. <div class="w-full sm:w-[220px]">
  479. <TextField
  480. data-action="settings-code-font"
  481. label={language.t("settings.general.row.font.title")}
  482. hideLabel
  483. type="text"
  484. value={mono()}
  485. onChange={(value) => settings.appearance.setFont(value)}
  486. placeholder={monoDefault}
  487. spellcheck={false}
  488. autocorrect="off"
  489. autocomplete="off"
  490. autocapitalize="off"
  491. class="text-12-regular"
  492. style={{ "font-family": monoFontFamily(settings.appearance.font()) }}
  493. />
  494. </div>
  495. </SettingsRow>
  496. <SettingsRow
  497. title={language.t("settings.general.row.terminalFont.title")}
  498. description={language.t("settings.general.row.terminalFont.description")}
  499. >
  500. <div class="w-full sm:w-[220px]">
  501. <TextField
  502. data-action="settings-terminal-font"
  503. label={language.t("settings.general.row.terminalFont.title")}
  504. hideLabel
  505. type="text"
  506. value={terminal()}
  507. onChange={(value) => settings.appearance.setTerminalFont(value)}
  508. placeholder={terminalDefault}
  509. spellcheck={false}
  510. autocorrect="off"
  511. autocomplete="off"
  512. autocapitalize="off"
  513. class="text-12-regular"
  514. style={{ "font-family": terminalFontFamily(settings.appearance.terminalFont()) }}
  515. />
  516. </div>
  517. </SettingsRow>
  518. </SettingsList>
  519. </div>
  520. )
  521. const NotificationsSection = () => (
  522. <div class="flex flex-col gap-1">
  523. <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.notifications")}</h3>
  524. <SettingsList>
  525. <SettingsRow
  526. title={language.t("settings.general.notifications.agent.title")}
  527. description={language.t("settings.general.notifications.agent.description")}
  528. >
  529. <div data-action="settings-notifications-agent">
  530. <Switch
  531. checked={settings.notifications.agent()}
  532. onChange={(checked) => settings.notifications.setAgent(checked)}
  533. />
  534. </div>
  535. </SettingsRow>
  536. <SettingsRow
  537. title={language.t("settings.general.notifications.permissions.title")}
  538. description={language.t("settings.general.notifications.permissions.description")}
  539. >
  540. <div data-action="settings-notifications-permissions">
  541. <Switch
  542. checked={settings.notifications.permissions()}
  543. onChange={(checked) => settings.notifications.setPermissions(checked)}
  544. />
  545. </div>
  546. </SettingsRow>
  547. <SettingsRow
  548. title={language.t("settings.general.notifications.errors.title")}
  549. description={language.t("settings.general.notifications.errors.description")}
  550. >
  551. <div data-action="settings-notifications-errors">
  552. <Switch
  553. checked={settings.notifications.errors()}
  554. onChange={(checked) => settings.notifications.setErrors(checked)}
  555. />
  556. </div>
  557. </SettingsRow>
  558. </SettingsList>
  559. </div>
  560. )
  561. const SoundsSection = () => (
  562. <div class="flex flex-col gap-1">
  563. <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.sounds")}</h3>
  564. <SettingsList>
  565. <SettingsRow
  566. title={language.t("settings.general.sounds.agent.title")}
  567. description={language.t("settings.general.sounds.agent.description")}
  568. >
  569. <Select
  570. data-action="settings-sounds-agent"
  571. {...soundSelectProps(
  572. () => settings.sounds.agentEnabled(),
  573. () => settings.sounds.agent(),
  574. (value) => settings.sounds.setAgentEnabled(value),
  575. (id) => settings.sounds.setAgent(id),
  576. )}
  577. />
  578. </SettingsRow>
  579. <SettingsRow
  580. title={language.t("settings.general.sounds.permissions.title")}
  581. description={language.t("settings.general.sounds.permissions.description")}
  582. >
  583. <Select
  584. data-action="settings-sounds-permissions"
  585. {...soundSelectProps(
  586. () => settings.sounds.permissionsEnabled(),
  587. () => settings.sounds.permissions(),
  588. (value) => settings.sounds.setPermissionsEnabled(value),
  589. (id) => settings.sounds.setPermissions(id),
  590. )}
  591. />
  592. </SettingsRow>
  593. <SettingsRow
  594. title={language.t("settings.general.sounds.errors.title")}
  595. description={language.t("settings.general.sounds.errors.description")}
  596. >
  597. <Select
  598. data-action="settings-sounds-errors"
  599. {...soundSelectProps(
  600. () => settings.sounds.errorsEnabled(),
  601. () => settings.sounds.errors(),
  602. (value) => settings.sounds.setErrorsEnabled(value),
  603. (id) => settings.sounds.setErrors(id),
  604. )}
  605. />
  606. </SettingsRow>
  607. </SettingsList>
  608. </div>
  609. )
  610. const UpdatesSection = () => (
  611. <div class="flex flex-col gap-1">
  612. <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.updates")}</h3>
  613. <SettingsList>
  614. <SettingsRow
  615. title={language.t("settings.general.row.releaseNotes.title")}
  616. description={language.t("settings.general.row.releaseNotes.description")}
  617. >
  618. <div data-action="settings-release-notes">
  619. <Switch
  620. checked={settings.general.releaseNotes()}
  621. onChange={(checked) => settings.general.setReleaseNotes(checked)}
  622. />
  623. </div>
  624. </SettingsRow>
  625. <SettingsRow
  626. title={language.t("settings.updates.row.check.title")}
  627. description={language.t("settings.updates.row.check.description")}
  628. >
  629. <Button size="small" variant="secondary" disabled={!updater.action().run} onClick={updater.run}>
  630. {language.t(updater.action().label)}
  631. </Button>
  632. </SettingsRow>
  633. </SettingsList>
  634. </div>
  635. )
  636. const DisplaySection = () => (
  637. <Show when={desktop()}>
  638. <div class="flex flex-col gap-1">
  639. <h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.display")}</h3>
  640. <SettingsList>
  641. <SettingsRow
  642. title={language.t("settings.general.row.pinchZoom.title")}
  643. description={language.t("settings.general.row.pinchZoom.description")}
  644. >
  645. <div data-action="settings-pinch-zoom">
  646. <Switch checked={pinchZoom.latest} onChange={onPinchZoomChange} />
  647. </div>
  648. </SettingsRow>
  649. <Show when={linux()}>
  650. <SettingsRow
  651. title={
  652. <div class="flex items-center gap-2">
  653. <span>{language.t("settings.general.row.wayland.title")}</span>
  654. <Tooltip value={language.t("settings.general.row.wayland.tooltip")} placement="top">
  655. <span class="text-text-weak">
  656. <Icon name="help" size="small" />
  657. </span>
  658. </Tooltip>
  659. </div>
  660. }
  661. description={language.t("settings.general.row.wayland.description")}
  662. >
  663. <div data-action="settings-wayland">
  664. <Switch checked={displayBackend.latest === "wayland"} onChange={onDisplayBackendChange} />
  665. </div>
  666. </SettingsRow>
  667. </Show>
  668. </SettingsList>
  669. </div>
  670. </Show>
  671. )
  672. return (
  673. <div class="flex flex-col h-full overflow-y-auto no-scrollbar px-4 pb-10 sm:px-10 sm:pb-10">
  674. <div class="sticky top-0 z-10 bg-[linear-gradient(to_bottom,var(--surface-stronger-non-alpha)_calc(100%_-_24px),transparent)]">
  675. <div class="flex flex-col gap-1 pt-6 pb-8">
  676. <h2 class="text-16-medium text-text-strong">{language.t("settings.tab.general")}</h2>
  677. </div>
  678. </div>
  679. <div class="flex flex-col gap-8 w-full">
  680. <Show when={settings.general.layoutTransitionAvailable()}>
  681. <InterfaceSection />
  682. </Show>
  683. <Show when={settings.general.newInterfaceNoticeVisible()}>
  684. <InterfaceNoticeSection />
  685. </Show>
  686. <GeneralSection />
  687. <AppearanceSection />
  688. <NotificationsSection />
  689. <SoundsSection />
  690. <UpdatesSection />
  691. <DisplaySection />
  692. <Show when={desktop()}>
  693. <AdvancedSection />
  694. </Show>
  695. </div>
  696. </div>
  697. )
  698. }
  699. interface SettingsRowProps {
  700. title: string | JSX.Element
  701. description: string | JSX.Element
  702. children: JSX.Element
  703. }
  704. const SettingsRow: Component<SettingsRowProps> = (props) => {
  705. return (
  706. <div class="flex flex-wrap items-center gap-4 py-3 border-b border-border-weak-base last:border-none sm:flex-nowrap">
  707. <div class="flex min-w-0 flex-1 flex-col gap-0.5">
  708. <span class="text-14-medium text-text-strong">{props.title}</span>
  709. <span class="text-12-regular text-text-weak">{props.description}</span>
  710. </div>
  711. <div class="flex w-full justify-end sm:w-auto sm:shrink-0">{props.children}</div>
  712. </div>
  713. )
  714. }