fix(webui): avoid phantom reasoning on empty streams

This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-12 17:34:07 +08:00
1 parent c3403e6a6f
commit b49218b6a3
8 files changed
+299 -50

No files matched your search

+19
View File
@@ -2494,6 +2494,25 @@ describe("ThreadViewport", () => {
expect(visible).toHaveLength(INITIAL_HISTORY_WINDOW + 2);
});
it.each([false, true])("keeps an activity cluster together across an empty answer frame (streaming=%s)", (isStreaming) => {
const activity: UIMessage[] = [
{ id: "prompt", role: "user", content: "question", createdAt: 1 },
{ id: "first", role: "tool", kind: "trace", content: "first()", createdAt: 2 },
{ id: "empty", role: "assistant", content: "", turnPhase: "answer", isStreaming, createdAt: 3 },
{ id: "second", role: "tool", kind: "trace", content: "second()", createdAt: 4 },
];
expect(windowMessages(activity, 1).map((message) => message.id)).toEqual(["first", "empty", "second"]);
});
it("keeps compaction notices as activity window boundaries", () => {
const activity: UIMessage[] = [
{ id: "first", role: "tool", kind: "trace", content: "first()", createdAt: 1 },
{ id: "compact", role: "assistant", kind: "compaction", content: "", compaction: { id: "compact", phase: "started" }, createdAt: 2 },
{ id: "second", role: "tool", kind: "trace", content: "second()", createdAt: 3 },
];
expect(windowMessages(activity, 1).map((message) => message.id)).toEqual(["second"]);
});
it("resets to the bottom when opening a different conversation", async () => {
const scrollTo = vi.fn();
const { container, rerender } = render(