Skip to content

desktop: chat scrollbar thumb jumps when dragging (verticalScrollAdjustment ignored) #64090

Open

Description

@Sn4k3r

Summary

In OpenCode Desktop, dragging the chat timeline scrollbar thumb makes it jump: the thumb position no longer matches the scroll offset, and the content jumps backwards/forwards while dragging. It happens once verticalScrollAdjustment becomes non-zero, which is normal during streaming when rows above the viewport resize.

Environment

  • opencode version: 2.3.0 (OpenCode Desktop 2.3.0, CLI opencode v2.3.0)
  • OS: Ubuntu 24.04.5 LTS, kernel 6.8.0-147-generic, X11 + KDE Plasma 5.27 (scale factor 1)
  • Terminal: N/A (desktop app, Electron 44.9.1)
  • Shell: /bin/bash
  • Install/channel: .deb desktop build, latest channel, package-type=deb
  • Active plugins: none

Reproduction

  1. Open OpenCode Desktop and open a session with long chat history.
  2. Send a prompt that produces a long streaming answer, so the timeline virtualizer adjusts scroll offsets (scrollAdjustment becomes non-zero).
  3. Grab the vertical scrollbar thumb on the right and drag it up/down.

Expected Behavior

The thumb follows the pointer 1:1 and the content stays anchored to the thumb position.

Actual Behavior

The thumb jumps relative to the content: the scroll position lags or overshoots the pointer, so dragging feels like it "snaps". The further you drag, the bigger the offset. Dragging after the adjustment returns to 0 (e.g. after scrolling to the end) behaves correctly.

Additional Context

Root cause is in the ScrollView component (out/renderer/assets/main-CEQaLS28.js, function names $Z, helper w8t).

Thumb rendering accounts for verticalScrollAdjustment:

let t = verticalScrollAdjustment ?? 0
let r = scrollHeight + t
let i = Math.max(0, thumbContainer.clientHeight - 16)
let a = Math.min(i, Math.max(clientHeight / r * i, 32))   // thumb size
let s = r - clientHeight                                   // scrollable range
let c = i - a
verticalThumbStart = 8 + (scrollTop + t) / s * c

Thumb dragging does not:

// w8t(position, trackLen, scrollHeight, thumbSize, clientHeight, rtl)
function w8t(e, t, n, r, i, a) {
  let o = t - 16 - r
  if (o <= 0) return 0
  let s = Math.max(0, Math.min(e - 8, o))
  return (a ? 1 - s / o : s / o) * Math.max(0, n - i)
}
// call site: n = viewport.scrollHeight, i = viewport.clientHeight, no adjustment
viewport.scrollTop = w8t(...)

So rendering maps scrollTop + adjustment into the track, while dragging inverts only scrollTop. As soon as scrollAdjustment != 0, the two mappings differ and the thumb jumps.

Suggested fix (verified locally by patching the bundle, behaviour becomes correct):

const adj = vertical ? (props.verticalScrollAdjustment ?? 0) : 0
const pos = w8t(pointerPos, trackLen, vertical ? scrollHeight + adj : scrollWidth,
                thumbSize, vertical ? clientHeight : clientWidth, rtl)
viewport.scrollTop = pos - adj

Note: w8t's call site must pass the adjusted total length so the returned range equals (scrollHeight + adj) - clientHeight; subtracting adj afterwards converts it back to a real scrollTop.

Frequency: consistently reproducible whenever content above the viewport changes size (streaming answers, expanding/collapsing tool output, lazy-loaded markdown).

Workaround for users: scroll with the wheel or keyboard; the thumb is correct until it is dragged.

Activity

  1. opencodejr commented on Nov 15, 2026

    @opencodejr
    Contributor

    Thanks for the detailed analysis! I couldn't run OpenCode Desktop here, so I haven't been able to reproduce the jump myself.

    From reading the current dev source (d432a06), the mismatch you point out is there. In packages/ui/src/components/scroll-view.tsx, updateThumb adds verticalScrollAdjustment when it places the thumb, but onThumbPointerMove works out scrollTop from the plain scrollHeight and doesn't take the adjustment into account.

    What I couldn't confirm is the trigger. In the timeline code I read, the adjustment only builds up while a touch or momentum scroll is in progress (the deferred iOS-style path). It is reset to 0 once scrolling settles, and pressing on the thumb ends that deferral. A maintainer with the desktop app will need to check when it actually shows up. It would help if you could say:

    • whether you're scrolling with a touchscreen, a touchpad or a mouse wheel;
    • whether the jump happens even when you grab the thumb without scrolling first, or only right after you've scrolled the timeline some other way.

    You can reply here with the details, or edit the issue and then leave a short comment saying you've updated it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions