fix(会商滚动): 让第二、三步新消息与结构化进度即时定位到底部
- 为圆桌滚动钩子增加强制落底能力,阶段切换和布局变化不再被平滑滚动的旧高度截断。\n- 第二步用户发送消息后立即下滑到底部,不再等待模型首个输出。\n- 经典结果绘制与大屏对话面板接入内容高度观察,新增气泡、Markdown 和工具卡继续增高时保持跟随。\n- 保留用户手动上翻时的正常阅读行为,仅在新一轮发起或关键阶段切换时强制定位。
This commit is contained in:
1 parent
dd560ceb46
commit
74fc849241
4 files changed
+86
-9
No files matched your search
@@ -28,6 +28,8 @@ export function useAutoScroll<T extends HTMLElement>(
|
||||
atBottom: boolean;
|
||||
/** Force-scroll to the bottom and resume auto-follow. */
|
||||
scrollToBottom: () => void;
|
||||
/** Immediately jump to the bottom and resume auto-follow (for phase transitions). */
|
||||
forceScrollToBottom: () => void;
|
||||
} {
|
||||
const threshold = options.threshold ?? 32;
|
||||
const contentRef = options.contentRef;
|
||||
@@ -187,5 +189,21 @@ export function useAutoScroll<T extends HTMLElement>(
|
||||
setAtBottom(true);
|
||||
}, [ref]);
|
||||
|
||||
return { atBottom, scrollToBottom };
|
||||
// 阶段切换/用户刚发送消息时不能依赖 smooth 动画:下一帧可能还会插入校验卡、
|
||||
// Markdown 或工具步骤,动画目标会停在旧高度。这里直接写入 scrollTop,由内容
|
||||
// ResizeObserver 继续接管后续增高,保证关键阶段始终落在最新底部。
|
||||
const forceScrollToBottom = useCallback(() => {
|
||||
const el = ref.current;
|
||||
if (!el) return;
|
||||
programmaticScrollTargetRef.current = Math.max(
|
||||
0,
|
||||
el.scrollHeight - el.clientHeight,
|
||||
);
|
||||
el.scrollTop = el.scrollHeight;
|
||||
lastObservedScrollTopRef.current = el.scrollTop;
|
||||
atBottomRef.current = true;
|
||||
setAtBottom(true);
|
||||
}, [ref]);
|
||||
|
||||
return { atBottom, scrollToBottom, forceScrollToBottom };
|
||||
}
|
||||
Reference in new issue
Block a user