Fix savings chat autoscroll
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
buildSourcesFromToolTrace,
|
||||
buildReasoningSteps,
|
||||
getToolTraceSummary,
|
||||
scrollConversationToBottom,
|
||||
} from "./agentChatModel";
|
||||
|
||||
const assistantMessage: AgentChatMessage = {
|
||||
@@ -31,6 +32,17 @@ const assistantMessage: AgentChatMessage = {
|
||||
};
|
||||
|
||||
describe("AgentChat phase 1 components", () => {
|
||||
test("scrolls the conversation container directly to the bottom", () => {
|
||||
const container = {
|
||||
scrollTop: 0,
|
||||
scrollHeight: 1200,
|
||||
};
|
||||
|
||||
scrollConversationToBottom(container);
|
||||
|
||||
expect(container.scrollTop).toBe(1200);
|
||||
});
|
||||
|
||||
test("summarizes tool traces for compact agent transparency", () => {
|
||||
expect(getToolTraceSummary(undefined)).toBe("Keine Werkzeuge");
|
||||
expect(getToolTraceSummary([])).toBe("Keine Werkzeuge");
|
||||
|
||||
@@ -54,3 +54,10 @@ export function buildSourcesFromToolTrace(toolTrace: AgentToolTrace[] | undefine
|
||||
description: tool.resultSummary,
|
||||
}));
|
||||
}
|
||||
|
||||
export function scrollConversationToBottom(
|
||||
container: Pick<HTMLDivElement, "scrollHeight" | "scrollTop"> | null,
|
||||
) {
|
||||
if (!container) return;
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
AgentPromptInput,
|
||||
type AgentChatMessage,
|
||||
} from "@/components/chat/AgentChat";
|
||||
import { scrollConversationToBottom } from "@/components/chat/agentChatModel";
|
||||
import { ChatHistory, type ChatHistoryItem } from "@/components/chat/ChatHistory";
|
||||
import { toast } from "sonner";
|
||||
|
||||
@@ -278,7 +279,7 @@ export function SavingsChatPage() {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
listRef.current?.lastElementChild?.scrollIntoView({ behavior: "smooth" });
|
||||
scrollConversationToBottom(listRef.current);
|
||||
}, [displayMessages.length, activeSessionId]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user