Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): keep message paint stable while scrolling\n\n

Steven Enamakel8d88ed0d906e
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index ddd4d29e47..43944c72d5 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -638,7 +638,7 @@ const AssistantMessage: FC = () => {
data-slot="aui_assistant-message-root"
data-role="assistant"
data-testid="agent-message"
- className="fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]">
+ className="fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150">
{/*
* One vertical rhythm for the whole message, rather than each part
* bringing its own margin. Measured before this change the gaps ran
@@ -809,7 +809,7 @@ const UserMessage: FC = () => {
return (
<MessagePrimitive.Root
data-slot="aui_user-message-root"
- className="fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2"
+ className="fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [&:where(>*)]:col-start-2"
data-role="user">
<UserMessageAttachments />
@@ -852,9 +852,7 @@ const UserActionBar: FC = () => {
const EditComposer: FC = () => {
return (
- <MessagePrimitive.Root
- data-slot="aui_edit-composer-wrapper"
- className="flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]">
+ <MessagePrimitive.Root data-slot="aui_edit-composer-wrapper" className="flex flex-col px-2">
<ComposerPrimitive.Root className="aui-edit-composer-root border-border/60 dark:border-muted-foreground/15 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg)">
<ComposerPrimitive.Input
className="aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-hidden"
diff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsx
index 15e9d02bc4..50fc21e577 100644
--- a/app/src/pages/__tests__/Conversations.render.test.tsx
+++ b/app/src/pages/__tests__/Conversations.render.test.tsx
@@ -606,6 +606,15 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {
'Long agent output with enough structure to prefer a text view.'
);
expect(screen.getByText('Can you summarize this?')).toBeInTheDocument();
+ // Message rows must retain their measured layout/paint while off-screen.
+ // `content-visibility:auto` plus a guessed intrinsic height makes WebKit
+ // reveal/re-size rows as they cross the viewport, producing scroll flicker.
+ const assistantRoot = screen.getByTestId('agent-message');
+ const userRoot = document.querySelector('[data-slot="aui_user-message-root"]');
+ expect(assistantRoot.className).not.toContain('content-visibility');
+ expect(userRoot?.className).not.toContain('content-visibility');
+ expect(assistantRoot.className).not.toContain('contain-intrinsic-size');
+ expect(userRoot?.className).not.toContain('contain-intrinsic-size');
});
it("renders a past turn's process trail above the answer it produced (Phase 5)", async () => {
diff --git a/app/test/playwright/specs/chat-scroll-stability.spec.ts b/app/test/playwright/specs/chat-scroll-stability.spec.ts
new file mode 100644
index 0000000000..4195bbf9d4
--- /dev/null
+++ b/app/test/playwright/specs/chat-scroll-stability.spec.ts
@@ -0,0 +1,95 @@
+import { expect, test } from '@playwright/test';
+
+import {
+ bootAuthenticatedPage,
+ callCoreRpc,
+ dismissWalkthroughIfPresent,
+ waitForAppReady,
+} from '../helpers/core-rpc';
+
+const USER_ID = 'pw-chat-scroll-stability';
+const TURN_COUNT = 18;
+
+test.describe('Chat scroll paint stability', () => {
+ test('keeps every message laid out while scrolling a long transcript', async ({ page }) => {
+ let transcriptRpcCount = 0;
+ page.on('request', request => {
+ if (request.postData()?.includes('openhuman.threads_transcript_get')) {
+ transcriptRpcCount += 1;
+ }
+ });
+ await bootAuthenticatedPage(page, USER_ID, '/chat');
+
+ const created = await callCoreRpc<{ data: { id: string } }>('openhuman.threads_create_new');
+ const threadId = created.data.id;
+ const base = Date.parse('2026-08-31T12:00:00.000Z');
+ for (let turn = 0; turn < TURN_COUNT; turn += 1) {
+ for (const sender of ['user', 'agent'] as const) {
+ const index = turn * 2 + (sender === 'agent' ? 1 : 0);
+ await callCoreRpc('openhuman.threads_message_append', {
+ thread_id: threadId,
+ message: {
+ id: `scroll-${sender}-${turn}`,
+ sender,
+ type: 'text',
+ createdAt: new Date(base + index * 1000).toISOString(),
+ extraMetadata: {},
+ content:
+ sender === 'user'
+ ? `Question ${turn}: explain this part of the long transcript.`
+ : `Answer ${turn}\n\nThis paragraph has deliberately varied content so its measured height is not a guessed placeholder.\n\n- detail one\n- detail two\n- detail three`,
+ },
+ });
+ }
+ }
+
+ await page.reload();
+ await waitForAppReady(page);
+ await page.goto('/#/chat');
+ await dismissWalkthroughIfPresent(page);
+ const row = page.getByTestId(`thread-row-${threadId}`);
+ await expect(row).toBeVisible({ timeout: 20_000 });
+ await row.click({ force: true });
+
+ const roots = page.locator(
+ '[data-slot="aui_assistant-message-root"], [data-slot="aui_user-message-root"]'
+ );
+ await expect(roots).toHaveCount(TURN_COUNT * 2, { timeout: 20_000 });
+ expect(
+ await roots.evaluateAll(elements =>
+ elements.every(
+ element =>
+ !element.className.includes('content-visibility') &&
+ !element.className.includes('contain-intrinsic-size')
+ )
+ )
+ ).toBe(true);
+
+ const viewport = page.locator('[data-slot="aui_thread-viewport"]');
+ const initial = await viewport.evaluate(element => ({
+ height: element.scrollHeight,
+ messages: element.querySelectorAll(
+ '[data-slot="aui_assistant-message-root"], [data-slot="aui_user-message-root"]'
+ ).length,
+ }));
+ const rpcCountBeforeScroll = transcriptRpcCount;
+
+ for (const fraction of [0, 0.25, 0.5, 0.75, 1, 0.5, 0]) {
+ const metrics = await viewport.evaluate(async (element, nextFraction) => {
+ element.scrollTop = (element.scrollHeight - element.clientHeight) * nextFraction;
+ await new Promise<void>(resolve =>
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
+ );
+ return {
+ height: element.scrollHeight,
+ messages: element.querySelectorAll(
+ '[data-slot="aui_assistant-message-root"], [data-slot="aui_user-message-root"]'
+ ).length,
+ };
+ }, fraction);
+ expect(metrics).toEqual(initial);
+ await expect(page.getByText('Loading conversation…')).toHaveCount(0);
+ }
+ expect(transcriptRpcCount).toBe(rpcCountBeforeScroll);
+ });
+});