char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Linting & Formatting scripts (#26819)92d1bb0c9

char/aliceai-t5-moe
1.4 KiB38 linesraw
1// Guards the lazy-body behaviour of the shared collapsible wrappers.
2//
3// bits-ui's Collapsible.Content renders its children unconditionally and only
4// sets `hidden`, so before this was gated a collapsed tool result kept its whole
5// body in the DOM and re-rendered it on every streamed token (measured at
6// ~41ms/section/token for a 200KB result). These tests pin the fix: closed means
7// not rendered, and opening still mounts the body.
8
9import CollapsibleLazyBodyHarness from './components/CollapsibleLazyBodyHarness.svelte';
10import { tick } from 'svelte';
11import { describe, expect, it } from 'vitest';
12import { render } from 'vitest-browser-svelte';
13
14const MARKER = 'collapsible-body-marker';
15
16describe('collapsible wrappers render their body lazily', () => {
17	for (const variant of ['content', 'terminal'] as const) {
18		it(`${variant}: body is absent while closed and present once open`, async () => {
19			const screen = render(CollapsibleLazyBodyHarness, { open: false, variant });
20
21			await tick();
22
23			expect(document.body.textContent).not.toContain(MARKER);
24
25			await screen.rerender({ open: true, variant });
26			await tick();
27
28			expect(document.body.textContent).toContain(MARKER);
29
30			// And it unmounts again on close, so a collapsed block stops costing
31			// anything during streaming.
32			await screen.rerender({ open: false, variant });
33			await tick();
34
35			expect(document.body.textContent).not.toContain(MARKER);
36		});
37	}
38});