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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ All notable user-visible changes to Hunk are documented in this file.

### Fixed

- Smoothed mouse-wheel review scrolling so small diffs stay precise while sustained wheel gestures still speed up.

## [0.9.4] - 2026-04-14

### Added
Expand Down
8 changes: 7 additions & 1 deletion src/ui/components/panes/DiffPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
measureDiffSectionGeometry,
type DiffSectionGeometry,
} from "../../lib/diffSectionGeometry";
import { createReviewMouseWheelScrollAcceleration } from "../../lib/scrollAcceleration";
import {
buildFileSectionLayouts,
buildInStreamFileHeaderHeights,
Expand Down Expand Up @@ -182,6 +183,10 @@ export function DiffPane({
onViewportCenteredHunkChange?: (fileId: string, hunkIndex: number) => void;
}) {
const renderer = useRenderer();
const mouseWheelScrollAcceleration = useMemo(
() => createReviewMouseWheelScrollAcceleration(),
[],
);

const adjacentPrefetchFileIds = useMemo(
() => buildAdjacentPrefetchFileIds(files, selectedFileId),
Expand Down Expand Up @@ -977,7 +982,7 @@ export function DiffPane({
suppressViewportSelectionSync,
]);

// Configure scroll step size to scroll exactly 1 line per step
// Keep keyboard step scrolling at exactly one row while wheel scrolling uses its own multiplier.
useEffect(() => {
const scrollBox = scrollRef.current;
if (scrollBox) {
Expand Down Expand Up @@ -1020,6 +1025,7 @@ export function DiffPane({
viewportCulling={true}
focused={pagerMode}
onMouseScroll={handleMouseScroll}
scrollAcceleration={mouseWheelScrollAcceleration}
rootOptions={{ backgroundColor: theme.panel }}
wrapperOptions={{ backgroundColor: theme.panel }}
viewportOptions={{ backgroundColor: theme.panel }}
Expand Down
15 changes: 15 additions & 0 deletions src/ui/lib/scrollAcceleration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MacOSScrollAccel, type ScrollAcceleration } from "@opentui/core";

/**
* Keep the first wheel tick precise, then ramp up during sustained bursts.
*
* This matches the general pattern used by terminal UIs better than scaling by total diff size:
* short diffs stay controllable, while long repeated wheel gestures still speed up.
*/
export function createReviewMouseWheelScrollAcceleration(): ScrollAcceleration {
return new MacOSScrollAccel({
A: 0.4,
tau: 4,
maxMultiplier: 3,
});
}
Loading