feat(desktop): add smooth scrolling setting on linux (#66622)

This commit is contained in:
Filip Hejmowski 2026-11-26 16:09:14 +01:00 • committed by GitHub
parent 44159132a5
commit c39ad3b75c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 85 additions and 4 deletions

View file

@ -1251,6 +1251,9 @@ export const dict = {
"settings.general.row.pinchZoom.description": "Allow trackpad pinch and Ctrl-scroll gestures to zoom",
"settings.general.row.spellcheck.title": "Spellcheck",
"settings.general.row.spellcheck.description": "Underline misspelled words while typing",
"settings.general.row.smoothScrolling.title": "Smooth scrolling",
"settings.general.row.smoothScrolling.description":
"Animate mouse-wheel scrolling. Applies after restarting OpenCode",
"sound.option.none": "None",
"sound.option.alert01": "Alert 01",

View file

@ -140,6 +140,12 @@ type PlatformBase = {
/** Turn the native spellchecker on or off (desktop only) */
setSpellcheckEnabled?(enabled: boolean): Promise<void>
/** Get whether mouse-wheel scrolling animates; read at launch (desktop on Linux only) */
getSmoothScrollingEnabled?(): Promise<boolean>
/** Save whether mouse-wheel scrolling animates; applies after a relaunch (desktop on Linux only) */
setSmoothScrollingEnabled?(enabled: boolean): Promise<void>
/** Run a desktop-only menu action from the app chrome */
runDesktopMenuAction?(action: DesktopMenuAction): Promise<void> | void

View file

@ -263,6 +263,7 @@ export const SettingsGeneral: Component = () => {
const settings = useSettings()
const mobile = createMediaQuery("(max-width: 767px)")
const desktop = createMemo(() => platform.platform === "desktop")
const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux")
const pinchZoom = createOptimisticSetting({
source: () => (desktop() && "getPinchZoomEnabled" in platform) || undefined,
@ -280,6 +281,14 @@ export const SettingsGeneral: Component = () => {
write: (checked) => platform.setSpellcheckEnabled?.(checked),
})
const smoothScrolling = createOptimisticSetting({
source: () => (linux() && "getSmoothScrollingEnabled" in platform) || undefined,
initial: false,
initialMeta: undefined,
load: async () => ({ value: (await platform.getSmoothScrollingEnabled?.()) ?? false, meta: undefined }),
write: (checked) => platform.setSmoothScrollingEnabled?.(checked),
})
const GeneralSection = () => (
<div class="settings-section">
<h3 class="settings-section-title">{language.t("settings.general.section.general")}</h3>
@ -336,6 +345,17 @@ export const SettingsGeneral: Component = () => {
</SettingsRow>
</Show>
<Show when={linux()}>
<SettingsRow
title={language.t("settings.general.row.smoothScrolling.title")}
description={language.t("settings.general.row.smoothScrolling.description")}
>
<div data-action="settings-smooth-scrolling">
<Switch checked={smoothScrolling.value()} onChange={smoothScrolling.select} />
</div>
</SettingsRow>
</Show>
<PluginSettingsSections page="general" section="general" />
<Show when={mobile()}>

View file

@ -12,7 +12,7 @@ type Entry<Tab> = {
description?: Label
section?: Label
subtab?: "mcps" | "plugins" | "skills" | "lsps"
available?: "desktop" | "browser" | "mobile"
available?: "desktop" | "linux" | "browser" | "mobile"
}
export const clientSettings: Entry<SettingsRootTab>[] = [
@ -82,6 +82,13 @@ export const clientSettings: Entry<SettingsRootTab>[] = [
keywords: "spelling spell check dictionary",
available: "desktop",
},
{
tab: "general",
label: "settings.general.row.smoothScrolling.title",
target: "settings-smooth-scrolling",
keywords: "scroll wheel mouse animation smooth",
available: "linux",
},
{
tab: "general",
label: "settings.general.row.mobileTitlebarBottom.title",

View file

@ -22,6 +22,7 @@ export function settingsSearchIndex(input: {
/** The server per-server pages show; only its settings and projects are indexed. */
selected?: string
desktop: boolean
linux: boolean
browser: boolean
mobile: boolean
translate: ReturnType<typeof useLanguage>["t"]
@ -94,6 +95,8 @@ export function settingsSearchIndex(input: {
clientSettings.forEach((entry) => {
if (entry.available === "desktop" && !input.desktop) return
if (entry.available === "linux" && !input.linux) return
if (entry.available === "browser" && !input.browser) return
if (entry.available === "mobile" && !input.mobile) return

View file

@ -18,6 +18,7 @@ function index(input: Partial<Parameters<typeof settingsSearchIndex>[0]> = {}) {
servers,
selected: "local",
desktop: false,
linux: false,
browser: false,
mobile: false,
translate: (key) => strings.get(key) ?? key,
@ -57,6 +58,8 @@ describe("settings search index", () => {
expect(targets({})).toContain("settings-tab-layout")
expect(targets({ desktop: true })).toContain("settings-pinch-zoom")
expect(targets({ desktop: true })).toContain("settings-zoom")
expect(targets({ desktop: true })).not.toContain("settings-smooth-scrolling")
expect(targets({ desktop: true, linux: true })).toContain("settings-smooth-scrolling")
expect(targets({ browser: true })).not.toContain("settings-experimental-browser")
expect(targets({})).not.toContain("settings-show-project-icon")
expect(targets({})).not.toContain("settings-mobile-titlebar-bottom")

View file

@ -274,6 +274,7 @@ export function createSettingsSearchCatalog() {
servers: inventory(),
selected: surface.server()?.key,
desktop: platform.platform === "desktop",
linux: platform.platform === "desktop" && platform.os === "linux",
browser: platform.platform === "desktop",
mobile: mobile(),
translate: language.t,

View file

@ -5,6 +5,7 @@ import { AppRpcs } from "../../shared/ipc-rpc"
import { checkAppExists, resolveAppPath } from "../files/apps"
import { setForceFocus } from "../native/debug"
import { DesktopLogging, scoped } from "../native/logging"
import { getSmoothScrollingEnabled, setSmoothScrollingEnabled } from "../native/smooth-scrolling"
import { getSpellcheckEnabled, setSpellcheckEnabled } from "../native/spellcheck"
import { setNativeTranslations } from "../native/translations"
import { IpcPortHandoff } from "../ipc-transport"
@ -44,6 +45,8 @@ export const appHandlers = AppRpcs.toLayer(
AppSetBackgroundColor: ({ color }) => Effect.sync(() => setBackgroundColor(color)),
AppGetSpellcheckEnabled: () => Effect.sync(getSpellcheckEnabled),
AppSetSpellcheckEnabled: ({ enabled }) => Effect.sync(() => setSpellcheckEnabled(enabled)),
AppGetSmoothScrollingEnabled: () => Effect.sync(getSmoothScrollingEnabled),
AppSetSmoothScrollingEnabled: ({ enabled }) => Effect.sync(() => setSmoothScrollingEnabled(enabled)),
AppExportDebugLogs: () => logging.exportDebug,
AppSetForceFocus: ({ enabled }, context) => promise(() => setForceFocus(sender(handoff, context), enabled)),
AppRecordFatalRendererError: ({ error }) =>

View file

@ -7,6 +7,7 @@ import { app } from "electron"
import { debugBuild, memoryLogInterval } from "@opencode/gui-plugins/debug/options"
import { APP_ID, APP_NAME, APP_USER_MODEL_ID, CHANNEL } from "../constants"
import { debuggingSwitches } from "../diagnostics/options"
import { applySmoothScrolling } from "../native/smooth-scrolling"
const testOnboarding = process.env.OPENCODE_TEST_ONBOARDING === "1"
@ -28,9 +29,6 @@ export function configureApplication() {
const features = app.commandLine.getSwitchValue("enable-features")
app.commandLine.appendSwitch("enable-features", features ? `${jsCallStackFeature},${features}` : jsCallStackFeature)
// Chromium animates each mouse-wheel notch on Linux; native Linux apps scroll by the full delta immediately.
if (process.platform === "linux") app.commandLine.appendSwitch("disable-smooth-scrolling")
const build = { packaged: app.isPackaged, channel: CHANNEL }
const debug = debuggingSwitches(build, process.env.OPENCODE_DESKTOP_REMOTE_DEBUGGING_PORT,
@ -61,6 +59,9 @@ export function configureApplication() {
app.setPath("sessionData", path.join(customUserData, "session"))
}
// Reads the settings store, so it runs once userData is set.
applySmoothScrolling()
if (testRoot) {
app.setPath("sessionData", path.join(testRoot, "session"))

View file

@ -0,0 +1,18 @@
import { app } from "electron"
import { SMOOTH_SCROLLING_ENABLED_KEY } from "../storage/keys"
import { getStore } from "../storage/store"
// Chromium animates each mouse-wheel notch on Linux; native Linux apps scroll by the full delta immediately,
// so animated scrolling is opt-in there. Chromium reads the switch at launch, so a change applies after a relaunch.
export function applySmoothScrolling() {
if (process.platform === "linux" && !getSmoothScrollingEnabled())
app.commandLine.appendSwitch("disable-smooth-scrolling")
}
export function getSmoothScrollingEnabled() {
return getStore().get(SMOOTH_SCROLLING_ENABLED_KEY) === true
}
export function setSmoothScrollingEnabled(enabled: boolean) {
getStore().set(SMOOTH_SCROLLING_ENABLED_KEY, enabled)
}

View file

@ -10,6 +10,8 @@ export const SPELLCHECK_ENABLED_KEY = "spellcheckEnabled"
export const SPELLCHECK_LANGUAGES_KEY = "spellcheckLanguages"
export const SMOOTH_SCROLLING_ENABLED_KEY = "smoothScrollingEnabled"
export const BACKGROUND_COLOR_KEY = "backgroundColor"
export const WINDOW_IDS_KEY = "windowIds"

View file

@ -86,6 +86,8 @@ export type ElectronAPI = {
setForceFocus(enabled: boolean): Promise<void>
getSpellcheckEnabled(): Promise<boolean>
setSpellcheckEnabled(enabled: boolean): Promise<void>
getSmoothScrollingEnabled(): Promise<boolean>
setSmoothScrollingEnabled(enabled: boolean): Promise<void>
recordFatalRendererError(error: FatalRendererError): Promise<void>
setNativeTranslations(bundle: DesktopNativeBundle): Promise<void>
}

View file

@ -93,6 +93,8 @@ export const api: ElectronAPI = {
setForceFocus: (enabled) => invoke("AppSetForceFocus", { enabled }),
getSpellcheckEnabled: () => invoke("AppGetSpellcheckEnabled"),
setSpellcheckEnabled: (enabled) => invoke("AppSetSpellcheckEnabled", { enabled }),
getSmoothScrollingEnabled: () => invoke("AppGetSmoothScrollingEnabled"),
setSmoothScrollingEnabled: (enabled) => invoke("AppSetSmoothScrollingEnabled", { enabled }),
recordFatalRendererError: (error) => invoke("AppRecordFatalRendererError", { error }),
setNativeTranslations: (bundle) => invoke("AppSetNativeTranslations", { value: bundle }),
}

View file

@ -48,6 +48,8 @@ export function createDesktopPlatform(api: ElectronAPI, windowState: DesktopWind
setPinchZoomEnabled,
getSpellcheckEnabled: () => api.getSpellcheckEnabled(),
setSpellcheckEnabled: (enabled) => api.setSpellcheckEnabled(enabled),
getSmoothScrollingEnabled: () => api.getSmoothScrollingEnabled(),
setSmoothScrollingEnabled: (enabled) => api.setSmoothScrollingEnabled(enabled),
onDeepLinks,
onDragCancel: (callback) => {
window.addEventListener(DragCancelEvent, callback)

View file

@ -63,6 +63,12 @@ export const AppSetSpellcheckEnabled = Rpc.make("AppSetSpellcheckEnabled", {
payload: { enabled: Schema.Boolean },
})
export const AppGetSmoothScrollingEnabled = Rpc.make("AppGetSmoothScrollingEnabled", { success: Schema.Boolean })
export const AppSetSmoothScrollingEnabled = Rpc.make("AppSetSmoothScrollingEnabled", {
payload: { enabled: Schema.Boolean },
})
export const AppSetNativeTranslations = Rpc.make("AppSetNativeTranslations", {
payload: { value: Schema.Unknown },
})
@ -83,6 +89,8 @@ export const AppRpcs = RpcGroup.make(
AppSetForceFocus,
AppGetSpellcheckEnabled,
AppSetSpellcheckEnabled,
AppGetSmoothScrollingEnabled,
AppSetSmoothScrollingEnabled,
AppRecordFatalRendererError,
AppSetNativeTranslations,
AppRelaunch,