Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/webview/e2e/browser-smoke.e2e.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const webviewDir = fileURLToPath(new URL('..', import.meta.url));
const daemonDir = fileURLToPath(new URL('../../daemon', import.meta.url));
const viteCli = fileURLToPath(new URL('../../bin/vite.js', import.meta.resolve('vite')));
const mockThreadTitle = 'Wire the workbench to the daemon';
const longThreadTitle = 'Long thread · navigation testbed';

interface ViteServer {
child: ChildProcess;
Expand Down Expand Up @@ -63,6 +64,34 @@ async function sendPrompt(page: Page, prompt: string, appErrors: string[]): Prom
assertNoApplicationErrors(appErrors);
}

async function verifyLongThreadVirtualization(page: Page): Promise<void> {
await page.locator('[data-thread-title]', { hasText: longThreadTitle }).click();
await page.locator('[data-conversation-title]', { hasText: longThreadTitle }).waitFor();
await page.waitForFunction(() => {
const scroll = document.querySelector('[role="log"]')?.firstElementChild;
const virtualizer = scroll?.firstElementChild?.firstElementChild;
return (
scroll instanceof HTMLElement &&
scroll.scrollHeight > scroll.clientHeight &&
(virtualizer?.childElementCount ?? Number.POSITIVE_INFINITY) < 10
);
});

const metrics = await page.getByRole('log').evaluate((root) => {
const scroll = root.firstElementChild as HTMLElement;
const virtualizer = scroll.firstElementChild?.firstElementChild;
return {
bottomDifference: scroll.scrollHeight - scroll.clientHeight - scroll.scrollTop,
mountedRows: virtualizer?.childElementCount,
};
});
assert.ok(
metrics.bottomDifference <= 2,
`Long thread opened ${metrics.bottomDifference}px above bottom`,
);
assert.ok((metrics.mountedRows ?? 0) < 10, `Long thread mounted ${metrics.mountedRows} rows`);
}

async function main(): Promise<void> {
let browser: Awaited<ReturnType<typeof chromium.launch>> | undefined;

Expand Down Expand Up @@ -159,6 +188,7 @@ async function verifyMockEntry(browser: Browser): Promise<void> {
await selectMockThread(page);
const recoveryPrompt = `${firstPrompt}-after-reload`;
await sendPrompt(page, recoveryPrompt, appErrors);
await verifyLongThreadVirtualization(page);
assertNoApplicationErrors(appErrors);
await page.close();

Expand Down
2 changes: 1 addition & 1 deletion apps/webview/src/shell/web-workbench-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function WebWorkbenchShell({

return (
<div className="grid h-full min-h-0 grid-cols-[minmax(0,1fr)_auto] overflow-hidden bg-background">
<div className="h-full min-w-0">
<div className="h-full min-h-0 min-w-0">
<ShellFrame
{...props}
showPlanInPromptDock={!resourcesSurfaceOpen}
Expand Down
8 changes: 7 additions & 1 deletion packages/presentation/ui/src/chat/conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ export function ConversationContent<T>({
// The browser's own scroll anchoring fights both scroll owners.
scrollClassName="[overflow-anchor:none]"
>
<Virtualizer data={data} onScroll={onScroll} ref={virtualizerRef} scrollRef={scrollRef}>
<Virtualizer
data={data}
itemSize={300}
onScroll={onScroll}
ref={virtualizerRef}
scrollRef={scrollRef}
>
{children}
</Virtualizer>
{trailing}
Expand Down