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
@@ -39,6 +39,33 @@ vi.mock("react-syntax-highlighter/dist/esm/styles/prism/one-light", () => ({
|
||||
}));
|
||||
|
||||
describe("CodeBlock", () => {
|
||||
it("renders and copies a large code block in full without pagination", async () => {
|
||||
const user = userEvent.setup();
|
||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||
Object.defineProperty(navigator, "clipboard", {
|
||||
configurable: true,
|
||||
value: { writeText },
|
||||
});
|
||||
const source = Array.from({ length: 1200 }, (_, i) => `const value${i} = ${i};`).join("\n");
|
||||
|
||||
try {
|
||||
render(<CodeBlock code={source} language="typescript" showLineNumbers />);
|
||||
expect((await screen.findByTestId("highlighted-code")).textContent).toBe(source);
|
||||
expect(screen.getAllByRole("button")).toHaveLength(1);
|
||||
await user.click(screen.getByRole("button", { name: "Copy code" }));
|
||||
expect(writeText).toHaveBeenCalledWith(source);
|
||||
} finally {
|
||||
Reflect.deleteProperty(navigator, "clipboard");
|
||||
}
|
||||
});
|
||||
|
||||
it("renders long plain text with Unicode in full", () => {
|
||||
const source = "x".repeat(23999) + "😀tail";
|
||||
render(<CodeBlock code={source} highlight={false} />);
|
||||
expect(screen.getByTestId("plain-code-fallback").textContent).toBe(source);
|
||||
expect(screen.getAllByRole("button")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("renders plain code without mounting the highlighter when highlighting is disabled", () => {
|
||||
render(
|
||||
<ThemeProvider theme="dark">
|
||||
|
||||
Reference in new issue
Block a user