fix(webui): respect middle-click autoscroll (#6612)

* fix(webui): respect middle-click autoscroll

Co-authored-by: ovo-agentx <351813579+ovo-agentx@users.noreply.github.com>

* fix(webui): arbitrate scrolling from actual viewport movement

Remove the middle-button gesture model. Attribute actual viewport movement at
the camera write boundary so native scrolling yields ownership without
predicting browser gesture state or nested scroll targets. Exclude layout
clamping, preserve application navigation, and reconcile pending scrolls before
geometry, animation, or history-anchor writes can overwrite them.

Co-authored-by: ovo-agentx <351813579+ovo-agentx@users.noreply.github.com>

---------

Co-authored-by: ovo-agentx <351813579+ovo-agentx@users.noreply.github.com>
This commit is contained in:
chengyongruandovo-agentx authored and GitHub committed 2026-11-09 18:34:48 +08:00
1 parent 86c98c8cf2
commit 5c72ced2fe
7 files changed
+227 -15

No files matched your search

@@ -520,6 +520,10 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
const content = messageContentRef.current;
const anchor = historyScrollAnchorRef.current;
if (!scroller || !content || !anchor) return false;
const maxScrollTop = Math.max(0, scroller.scrollHeight - scroller.clientHeight);
if (Math.abs(scroller.scrollTop - Math.min(anchor.scrollTop, maxScrollTop)) >= 0.5) {
return captureHistoryScrollAnchor();
}
const element = Array.from(
content.querySelectorAll<HTMLElement>("[data-thread-display-unit]"),
).find((candidate) => candidate.dataset.threadDisplayUnit === anchor.key);
@@ -534,12 +538,11 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
- (historySlotRef.current ? HISTORY_HOLD_PX : 0);
const delta = nextOffset - anchor.offsetTop;
if (Math.abs(delta) < 0.5) return true;
const maxScrollTop = Math.max(0, scroller.scrollHeight - scroller.clientHeight);
const nextTop = Math.min(maxScrollTop, Math.max(0, scroller.scrollTop + delta));
threadMotionRef.current?.jumpTo(nextTop);
anchor.scrollTop = scroller.scrollTop;
return true;
}, []);
}, [captureHistoryScrollAnchor]);
const resetHistoryHeader = useCallback(() => {
setHistorySlotKey(null);