perf(webui): reduce repeated work and bound history rendering (#5703)
* perf(webui): reduce repeated work and bound history rendering * fix(webui): keep continuation reasoning with its answer * refactor(webui): reuse answer buffers and prepared copy text * perf(webui): restore conditional replay buffer initialization * fix(webui): remove code block pagination
This commit is contained in:
1 parent
1c451b5b5f
commit
1469d4811c
32 files changed
+1156
-361
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { useState } from "react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { ThinkingReasoningShell } from "@/components/thread/activity/ThinkingReasoningShell";
|
||||
@@ -22,6 +23,26 @@ function renderShell(expanded: boolean) {
|
||||
}
|
||||
|
||||
describe("ThinkingReasoningShell", () => {
|
||||
it("mounts details on first expansion and preserves their state across folding", () => {
|
||||
const mounted = vi.fn();
|
||||
function Details() {
|
||||
const [count, setCount] = useState(() => { mounted(); return 0; });
|
||||
return <button onClick={() => setCount(count + 1)}>Count {count}</button>;
|
||||
}
|
||||
const shell = (expanded: boolean) => (
|
||||
<ThinkingReasoningShell active={false} expanded={expanded} label="Thought"
|
||||
viewportRef={null} contentRef={null} fadeTop={false} fadeBottom={false}
|
||||
onToggle={() => {}} onScroll={() => {}}><Details /></ThinkingReasoningShell>
|
||||
);
|
||||
const view = render(shell(false));
|
||||
expect(mounted).toHaveBeenCalledTimes(0);
|
||||
view.rerender(shell(true));
|
||||
fireEvent.click(screen.getByText("Count 0"));
|
||||
view.rerender(shell(false));
|
||||
view.rerender(shell(true));
|
||||
expect(screen.getByRole("button", { name: "Count 1" })).toBeVisible();
|
||||
expect(mounted).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
it("makes collapsed descendants inert as well as visually hidden", () => {
|
||||
const { rerender } = renderShell(false);
|
||||
const disclosure = screen.getByRole("button", { name: "Thought" });
|
||||
|
||||
Reference in new issue
Block a user