Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Clipboard } from "@tui/util/clipboard"
import { createSignal } from "solid-js"
import { Installation } from "@/installation"
import { win32FlushInputBuffer } from "../win32"
import { getScrollAcceleration } from "../util/scroll"

export function ErrorComponent(props: {
error: Error
Expand Down Expand Up @@ -82,7 +83,7 @@ export function ErrorComponent(props: {
<text fg={colors.bg}>Exit</text>
</box>
</box>
<scrollbox height={Math.floor(term().height * 0.7)}>
<scrollbox height={Math.floor(term().height * 0.7)} scrollAcceleration={getScrollAcceleration()}>
<text fg={colors.muted}>{props.error.stack}</text>
</scrollbox>
<text fg={colors.text}>{props.error.message}</text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { createMemo, createResource, createEffect, onMount, onCleanup, Index, Sh
import { createStore } from "solid-js/store"
import { useSDK } from "@tui/context/sdk"
import { useSync } from "@tui/context/sync"
import { getScrollAcceleration } from "../../util/scroll"
import { useTuiConfig } from "../../context/tui-config"
import { useTheme, selectedForeground } from "@tui/context/theme"
import { SplitBorder } from "@tui/component/border"
import { useCommandDialog } from "@tui/component/dialog-command"
Expand Down Expand Up @@ -81,6 +83,7 @@ export function Autocomplete(props: {
const { theme } = useTheme()
const dimensions = useTerminalDimensions()
const frecency = useFrecency()
const tuiConfig = useTuiConfig()

const [store, setStore] = createStore({
index: 0,
Expand Down Expand Up @@ -605,6 +608,7 @@ export function Autocomplete(props: {
})

let scroll: ScrollBoxRenderable
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))

return (
<box
Expand All @@ -622,6 +626,7 @@ export function Autocomplete(props: {
backgroundColor={theme.backgroundMenu}
height={height()}
scrollbarOptions={{ visible: false }}
scrollAcceleration={scrollAcceleration()}
>
<Index
each={options()}
Expand Down
23 changes: 2 additions & 21 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,7 @@ import { UI } from "@/cli/ui.ts"
import { useTuiConfig } from "../../context/tui-config"

addDefaultParsers(parsers.parsers)

class CustomSpeedScroll implements ScrollAcceleration {
constructor(private speed: number) {}

tick(_now?: number): number {
return this.speed
}

reset(): void {}
}
import { getScrollAcceleration } from "../../util/scroll"

Comment on lines 82 to 86
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s now an import after the addDefaultParsers(...) statement. Consider moving getScrollAcceleration up with the other imports for consistency, and remove the now-unused MacOSScrollAccel / ScrollAcceleration imports from @opentui/core since the logic moved to util/scroll.

Copilot uses AI. Check for mistakes.
const context = createContext<{
width: number
Expand Down Expand Up @@ -168,17 +159,7 @@ export function Session() {
const showTimestamps = createMemo(() => timestamps() === "show")
const contentWidth = createMemo(() => dimensions().width - (sidebarVisible() ? 42 : 0) - 4)

const scrollAcceleration = createMemo(() => {
const tui = tuiConfig
if (tui?.scroll_acceleration?.enabled) {
return new MacOSScrollAccel()
}
if (tui?.scroll_speed) {
return new CustomSpeedScroll(tui.scroll_speed)
}

return new CustomSpeedScroll(3)
})
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))

createEffect(() => {
if (session()?.workspaceID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Keybind } from "@/util/keybind"
import { Locale } from "@/util/locale"
import { Global } from "@/global"
import { useDialog } from "../../ui/dialog"
import { getScrollAcceleration } from "../../util/scroll"
import { useTuiConfig } from "../../context/tui-config"

type PermissionStage = "permission" | "always" | "reject"
Expand Down Expand Up @@ -62,12 +63,14 @@ function EditBody(props: { request: PermissionRequest }) {
})

const ft = createMemo(() => filetype(filepath()))
const scrollAcceleration = createMemo(() => getScrollAcceleration(config))

return (
<box flexDirection="column" gap={1}>
<Show when={diff()}>
<scrollbox
height="100%"
scrollAcceleration={scrollAcceleration()}
verticalScrollbarOptions={{
trackOptions: {
backgroundColor: theme.background,
Expand Down
6 changes: 6 additions & 0 deletions packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useSync } from "@tui/context/sync"
import { createMemo, Show } from "solid-js"
import { useTheme } from "../../context/theme"
import { useTuiConfig } from "../../context/tui-config"
import { Installation } from "@/installation"
import { TuiPluginRuntime } from "../../plugin"

import { getScrollAcceleration } from "../../util/scroll"

export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
const sync = useSync()
const { theme } = useTheme()
const tuiConfig = useTuiConfig()
const session = createMemo(() => sync.session.get(props.sessionID))
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))

return (
<Show when={session()}>
Expand All @@ -23,6 +28,7 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
>
<scrollbox
flexGrow={1}
scrollAcceleration={scrollAcceleration()}
verticalScrollbarOptions={{
trackOptions: {
backgroundColor: theme.background,
Expand Down
8 changes: 8 additions & 0 deletions packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { useDialog, type DialogContext } from "@tui/ui/dialog"
import { useKeybind } from "@tui/context/keybind"
import { Keybind } from "@/util/keybind"
import { Locale } from "@/util/locale"
import { useSync } from "@tui/context/sync"
import { getScrollAcceleration } from "../util/scroll"
import { useTuiConfig } from "../context/tui-config"

export interface DialogSelectProps<T> {
title: string
Expand Down Expand Up @@ -50,6 +53,10 @@ export type DialogSelectRef<T> = {
export function DialogSelect<T>(props: DialogSelectProps<T>) {
const dialog = useDialog()
const { theme } = useTheme()
const sync = useSync()
const tuiConfig = useTuiConfig()
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))
Comment on lines 54 to +58
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sync is declared but never used in this component. This can fail typecheck when noUnusedLocals is enabled; remove the useSync() call and its import if it’s no longer needed.

Copilot uses AI. Check for mistakes.

const [store, setStore] = createStore({
selected: 0,
filter: "",
Expand Down Expand Up @@ -276,6 +283,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
paddingLeft={1}
paddingRight={1}
scrollbarOptions={{ visible: false }}
scrollAcceleration={scrollAcceleration()}
ref={(r: ScrollBoxRenderable) => (scroll = r)}
maxHeight={height()}
>
Expand Down
23 changes: 23 additions & 0 deletions packages/opencode/src/cli/cmd/tui/util/scroll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MacOSScrollAccel, type ScrollAcceleration } from "@opentui/core"
import { TuiConfig } from "@/config/tui"
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TuiConfig is only used for the TuiConfig.Info type. To match existing usage (e.g. packages/opencode/src/cli/cmd/tui/context/keybind.tsx:4) and avoid a runtime import, switch this to a type-only import.

Suggested change
import { TuiConfig } from "@/config/tui"
import type { TuiConfig } from "@/config/tui"

Copilot uses AI. Check for mistakes.

export class CustomSpeedScroll implements ScrollAcceleration {
constructor(private speed: number) {}

tick(_now?: number): number {
return this.speed
}

reset(): void {}
}

export function getScrollAcceleration(tuiConfig?: TuiConfig.Info): ScrollAcceleration {
if (tuiConfig?.scroll_acceleration?.enabled) {
return new MacOSScrollAccel()
}
if (tuiConfig?.scroll_speed) {
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (tuiConfig?.scroll_speed) relies on truthiness. It’s safer to check explicitly for a number/defined value (e.g. !== undefined) so valid values like 0 (or future schema changes) don’t accidentally fall back to the default speed.

Suggested change
if (tuiConfig?.scroll_speed) {
if (tuiConfig?.scroll_speed !== undefined) {

Copilot uses AI. Check for mistakes.
return new CustomSpeedScroll(tuiConfig.scroll_speed)
}

return new CustomSpeedScroll(3)
}
Loading