fix(会商滚动): 让第二、三步新消息与结构化进度即时定位到底部

- 为圆桌滚动钩子增加强制落底能力,阶段切换和布局变化不再被平滑滚动的旧高度截断。\n- 第二步用户发送消息后立即下滑到底部,不再等待模型首个输出。\n- 经典结果绘制与大屏对话面板接入内容高度观察,新增气泡、Markdown 和工具卡继续增高时保持跟随。\n- 保留用户手动上翻时的正常阅读行为,仅在新一轮发起或关键阶段切换时强制定位。
This commit is contained in:
董宏凯 committed 2026-08-30 21:24:08 +08:00
1 parent dd560ceb46
commit 74fc849241
4 files changed
+86 -9

No files matched your search

@@ -225,11 +225,40 @@ export function Step2Panel(props: Step2PanelProps) {
// contentRef 与 Step1Panel 同款:消息内容(markdown/代码高亮/折叠卡/write_file 预览)在
// 状态更新之后才继续长高,deps 效果抓不到,靠 ResizeObserver 跟随实际内容高度。
const step2ContentRef = useRef<HTMLDivElement>(null);
const { atBottom: step2AtBottom, scrollToBottom: scrollStep2ToBottom } =
const {
atBottom: step2AtBottom,
scrollToBottom: scrollStep2ToBottom,
forceScrollToBottom: forceStep2ToBottom,
} =
useAutoScroll(step2ScrollRef, [step2RoundtableDialogues], {
contentRef: step2ContentRef,
});
const latestUserDialogueId = useMemo(() => {
for (let index = step2RoundtableDialogues.length - 1; index >= 0; index -= 1) {
const dialogue = step2RoundtableDialogues[index];
if (dialogue.avatarType === "human") {
return dialogue.id;
}
}
return null;
}, [step2RoundtableDialogues]);
const previousUserDialogueIdRef = useRef<number | null>(latestUserDialogueId);
// 用户消息入列后立即定位到底部,不等待后续模型流式消息触发滚动。
useEffect(() => {
if (
latestUserDialogueId === null ||
latestUserDialogueId === previousUserDialogueIdRef.current
) {
return;
}
previousUserDialogueIdRef.current = latestUserDialogueId;
const frameId = window.requestAnimationFrame(forceStep2ToBottom);
return () => window.cancelAnimationFrame(frameId);
}, [forceStep2ToBottom, latestUserDialogueId]);
// 「回答速度指示器」—— 与主页面共用全局开关 streamSpeedMeterEnabled。
// 度量始终计算(成本低、便于中途开启时也有时长基线),仅展示按开关门控。
const [localSettings] = useLocalSettings();
@@ -270,8 +299,8 @@ export function Step2Panel(props: Step2PanelProps) {
// scrollHeight 会突变、scrollTop 被浏览器 clamp → useAutoScroll 误判成「用户上滚」而停跟随
// (表现为并行时自动下滑失效)。这里在这些布局切换点**重新拉到底部 + 恢复自动跟随**。
useEffect(() => {
scrollStep2ToBottom();
}, [isParallelRunning, selectedParallelSeats, scrollStep2ToBottom]);
forceStep2ToBottom();
}, [forceStep2ToBottom, isParallelRunning, selectedParallelSeats]);
const resolveAgentName = useCallback(
(idOrName: string) =>