From 3d4eba8afc79a0476824b99cf9690e5a8c4cf8ea Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Thu, 13 Nov 2025 15:50:05 +0100 Subject: [PATCH 1/3] add support for scroll_acceleration field. use scroll_speed config field --- .../src/cli/cmd/tui/routes/session/index.tsx | 31 ++++++++++++++++++- packages/opencode/src/config/config.ts | 6 ++++ packages/sdk/js/src/gen/types.gen.ts | 9 ++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index 4c3dd96ff5e5..e3d199ee4092 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -17,7 +17,14 @@ import { useRoute, useRouteData } from "@tui/context/route" import { useSync } from "@tui/context/sync" import { SplitBorder } from "@tui/component/border" import { useTheme } from "@tui/context/theme" -import { BoxRenderable, ScrollBoxRenderable, TextAttributes, addDefaultParsers } from "@opentui/core" +import { + BoxRenderable, + ScrollBoxRenderable, + TextAttributes, + addDefaultParsers, + MacOSScrollAccel, + type ScrollAcceleration, +} from "@opentui/core" import { Prompt, type PromptRef } from "@tui/component/prompt" import type { AssistantMessage, Part, ToolPart, UserMessage, TextPart, ReasoningPart } from "@opencode-ai/sdk" import { useLocal } from "@tui/context/local" @@ -62,6 +69,16 @@ import { LSP } from "@/lsp/index.ts" addDefaultParsers(parsers.parsers) +class CustomSpeedScroll implements ScrollAcceleration { + constructor(private speed: number) {} + + tick(_now?: number): number { + return this.speed + } + + reset(): void {} +} + const context = createContext<{ width: number conceal: () => boolean @@ -95,6 +112,17 @@ export function Session() { const sidebarVisible = createMemo(() => sidebar() === "show" || (sidebar() === "auto" && wide())) const contentWidth = createMemo(() => dimensions().width - (sidebarVisible() ? 42 : 0) - 4) + const scrollAcceleration = createMemo(() => { + const tui = sync.data.config.tui + if (tui?.scroll_acceleration?.enabled) { + return new MacOSScrollAccel() + } + if (tui?.scroll_speed) { + return new CustomSpeedScroll(tui.scroll_speed) + } + return undefined + }) + createEffect(async () => { await sync.session .sync(route.sessionID) @@ -684,6 +712,7 @@ export function Session() { stickyScroll={true} stickyStart="bottom" flexGrow={1} + scrollAcceleration={scrollAcceleration()} > {(message, index) => ( diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index e6bed238ff7b..168dbb0013b1 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -438,6 +438,12 @@ export namespace Config { export const TUI = z.object({ scroll_speed: z.number().min(1).optional().default(2).describe("TUI scroll speed"), + scroll_acceleration: z + .object({ + enabled: z.boolean().describe("Enable scroll acceleration"), + }) + .optional() + .describe("Scroll acceleration settings"), }) export const Layout = z.enum(["auto", "stretch"]).meta({ diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 3e64fc9a01a8..1d90fe106fab 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -301,6 +301,15 @@ export type Config = { * TUI scroll speed */ scroll_speed?: number + /** + * Scroll acceleration settings + */ + scroll_acceleration?: { + /** + * Enable scroll acceleration + */ + enabled: boolean + } } /** * Command configuration, see https://opencode.ai/docs/commands From 822e1745f0a88bf9ba5ab1abd67b7403f5cb933d Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Thu, 13 Nov 2025 15:51:15 +0100 Subject: [PATCH 2/3] update scroll docs --- packages/web/src/content/docs/config.mdx | 10 +++++++++- packages/web/src/content/docs/tui.mdx | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/web/src/content/docs/config.mdx b/packages/web/src/content/docs/config.mdx index c02edd2fff9b..549506b87c7b 100644 --- a/packages/web/src/content/docs/config.mdx +++ b/packages/web/src/content/docs/config.mdx @@ -93,11 +93,19 @@ You can configure TUI-specific settings through the `tui` option. { "$schema": "https://opencode.ai/config.json", "tui": { - "scroll_speed": 3 + "scroll_speed": 3, + "scroll_acceleration": { + "enabled": true + } } } ``` +Available options: + +- `scroll_acceleration.enabled` - Enable macOS-style scroll acceleration. **Takes precedence over `scroll_speed`.** +- `scroll_speed` - Custom scroll speed multiplier (default: `2`, minimum: `1`). Ignored if `scroll_acceleration.enabled` is `true`. + [Learn more about using the TUI here](/docs/tui). --- diff --git a/packages/web/src/content/docs/tui.mdx b/packages/web/src/content/docs/tui.mdx index 4dd7608be661..4cc806a51c56 100644 --- a/packages/web/src/content/docs/tui.mdx +++ b/packages/web/src/content/docs/tui.mdx @@ -336,11 +336,15 @@ You can customize TUI behavior through your OpenCode config file. { "$schema": "https://opencode.ai/config.json", "tui": { - "scroll_speed": 3 + "scroll_speed": 3, + "scroll_acceleration": { + "enabled": true + } } } ``` ### Options -- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (default: `2`, minimum: `1`) +- `scroll_acceleration` - Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements. **This setting takes precedence over `scroll_speed` and overrides it when enabled.** +- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (default: `2`, minimum: `1`). **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.** From 7f0fd367709a1433c2f100c1741b5667bdb58b07 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Thu, 13 Nov 2025 16:56:49 +0100 Subject: [PATCH 3/3] set scroll speed default to 1 --- packages/opencode/src/config/config.ts | 2 +- packages/web/src/content/docs/config.mdx | 2 +- packages/web/src/content/docs/tui.mdx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 168dbb0013b1..3ca8c25de2fa 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -437,7 +437,7 @@ export namespace Config { }) export const TUI = z.object({ - scroll_speed: z.number().min(1).optional().default(2).describe("TUI scroll speed"), + scroll_speed: z.number().min(1).optional().default(1).describe("TUI scroll speed"), scroll_acceleration: z .object({ enabled: z.boolean().describe("Enable scroll acceleration"), diff --git a/packages/web/src/content/docs/config.mdx b/packages/web/src/content/docs/config.mdx index 549506b87c7b..a27acc7796b7 100644 --- a/packages/web/src/content/docs/config.mdx +++ b/packages/web/src/content/docs/config.mdx @@ -104,7 +104,7 @@ You can configure TUI-specific settings through the `tui` option. Available options: - `scroll_acceleration.enabled` - Enable macOS-style scroll acceleration. **Takes precedence over `scroll_speed`.** -- `scroll_speed` - Custom scroll speed multiplier (default: `2`, minimum: `1`). Ignored if `scroll_acceleration.enabled` is `true`. +- `scroll_speed` - Custom scroll speed multiplier (default: `1`, minimum: `1`). Ignored if `scroll_acceleration.enabled` is `true`. [Learn more about using the TUI here](/docs/tui). diff --git a/packages/web/src/content/docs/tui.mdx b/packages/web/src/content/docs/tui.mdx index 4cc806a51c56..f50409c41034 100644 --- a/packages/web/src/content/docs/tui.mdx +++ b/packages/web/src/content/docs/tui.mdx @@ -347,4 +347,4 @@ You can customize TUI behavior through your OpenCode config file. ### Options - `scroll_acceleration` - Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements. **This setting takes precedence over `scroll_speed` and overrides it when enabled.** -- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (default: `2`, minimum: `1`). **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.** +- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (default: `1`, minimum: `1`). **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.**