Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): threads open at the newest message, not thousands of pixels above it #19663

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/19663/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 106 additions and 2 deletions.

x
0 of 2 viewed, 2 left
87 additions and 1 deletionapps/web/src/components/chat/MessagesTimeline.browser.test.tsxModified
View file
@@ -838,6 +838,72 @@
expect(onOpenThread).toHaveBeenCalledWith("thread-parent");
});
​
+ it("opens a thread at its newest message after an empty pane and restores it on return", async () => {
+ const props = baseProps();
+ const entries = Array.from({ length: 12 }, (_, index) =>
+ message(
+ Array.from({ length: 60 }, (_, line) => `Paragraph ${index}.${line}`).join("\n\n"),
+ { role: "assistant" },
+ `message-${index}`,
+ ),
+ );
+ await renderTimeline([], {
+ ...props,
+ routeThreadKey: `${props.routeThreadKey}-loading`,
+ hideEmptyPlaceholder: true,
+ });
+​
+ // Each row is much taller than LegendList's estimate.
+ await act(async () =>
+ roots.at(-1)!.render(<MessagesTimeline {...props} timelineEntries={entries} />),
+ );
+ const viewport = props.listRef.current!.getScrollableNode();
+ await vi.waitFor(() => {
+ expect(viewport.scrollHeight).toBeGreaterThan(viewport.clientHeight);
+ expect(text()).toContain("Paragraph 11.59");
+ expect(
+ viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop,
+ ).toBeLessThanOrEqual(1);