Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(web): returning to a thread reuses its measured row sizes #17123

Closedflamboh(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/17123/headopened View on GitHub

Showing 4 changed files with 146 additions and 8 deletions (loading 1).

x
0 of 4 viewed, 4 left
69 additions and 0 deletionsapps/web/src/components/chat/MessagesTimeline.test.tsxModified
View file
@@ -669,6 +669,75 @@
​
+ it("remembers the median row size of the thread it leaves", async () => {
+ const { ChatCanvasContext } = await import("./ChatCanvasContext");
+ const { readTimelinePosition, rememberTimelinePosition } =
+ await import("./timelineScrollAnchoring");
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ vi.stubGlobal(
+ "ResizeObserver",
+ class {
+ observe() {}
+ disconnect() {}
+ },
+ );
+ const props = { ...buildProps(), routeThreadKey: "environment-local:measured-departure" };
+ const entries = ["short", "code-block", "medium"].map((id) => {
+ const entry = buildUserTimelineEntry(id);
+ return { ...entry, id, message: { ...entry.message, id: MessageId.make(id) } };
+ });
+ const sizes = new Map([
+ ["short", 60],
+ ["code-block", 3000],
+ ["medium", 80],
+ ["row-from-another-thread", 20],
+ ]);
+ props.listRef.current = {
+ getScrollableNode: () => null,
+ getState: () => ({ sizes }),