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
23 changes: 23 additions & 0 deletions apps/web/src/components/chat/MessagesTimeline.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,29 @@ describe("MessagesTimeline messages", () => {
expect(maxNestedCommits).toBeLessThan(20);
});

it("keeps reporting overflow while the composer inset changes", async () => {
setup();
const props = baseProps();
const overflowReports: boolean[] = [];
const replies = Array.from({ length: 40 }, (_, index) =>
message(`Reply ${index}\n\n${"line\n\n".repeat(8)}`, { role: "assistant" }, `r-${index}`),
);
const timeline = (inset: number) => (
<MessagesTimeline
{...props}
timelineEntries={replies}
contentInsetEndAdjustment={inset}
onContentOverflowChange={(overflows) => overflowReports.push(overflows)}
/>
);
await using screen = await renderElement(timeline(110));
await vi.waitFor(() => expect(overflowReports.at(-1)).toBe(true));
overflowReports.length = 0;
// The resting composer resizes with overflow; a false report here flips it back.
await screen.rerender(timeline(148));
expect(overflowReports).not.toContain(false);
});

it("keeps the first and last message headings reachable from either end", async () => {
setup();
const props = baseProps();
Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/components/chat/MessagesTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,9 @@ const ConversationTimeline = memo(function ConversationTimeline({

const canvas = useChatCanvas();
const registerTimeline = canvas?.registerTimeline;
const setTimelineList = (list: LegendListRef | null) => {
// Stable so the list attaches once per mount. A re-attach reports no overflow for a frame,
// which flips the resting composer, resizes it, and re-renders this list again.
const setTimelineList = useStableCallback((list: LegendListRef | null) => {
listRef.current = list;
const scrollNode: HTMLElement | null = list?.getScrollableNode() ?? null;
registerTimeline?.(scrollNode);
Expand Down Expand Up @@ -1190,7 +1192,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
listRef.current = null;
registerTimeline?.(null);
};
};
});

useThreadFindPositionReader({
threadKey: listIdentityKey,
Expand Down
Loading