Skip to content

Commit 1d8e048

Browse files
committed
fix(web): a first send held near the top is remembered as a reading position
1 parent 15855a3 commit 1d8e048

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎apps/web/src/components/chat/MessagesTimeline.test.tsx‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,34 @@ describe("MessagesTimeline", () => {
794794
}
795795
});
796796

797+
it("remembers a first send held near the top as a reading position", async () => {
798+
const { readTimelinePosition } = await import("./timelineScrollAnchoring");
799+
const timeline = stubFollowTimeline("environment-local:anchored-first-send");
800+
const { props } = timeline;
801+
timeline.scrollTop = 1300;
802+
let renderer: ReactTestRenderer | undefined;
803+
try {
804+
await act(() => {
805+
renderer = create(
806+
<MessagesTimeline
807+
{...props}
808+
timelineEntries={[buildUserTimelineEntry("First prompt")]}
809+
anchorMessageId={MessageId.make("message-1")}
810+
liveFollowEnabled
811+
/>,
812+
);
813+
});
814+
await timeline.flushFrame();
815+
816+
expect(readTimelinePosition(props.routeThreadKey)).toMatchObject({
817+
atEnd: false,
818+
scrollOffset: 1300,
819+
});
820+
} finally {
821+
await act(() => renderer?.unmount());
822+
}
823+
});
824+
797825
it("preserves arbitrary XML-like tags and comparisons in rendered user messages", async () => {
798826
const { MessagesTimeline } = await import("./MessagesTimeline");
799827
const markup = renderToStaticMarkup(

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
12031203
workGroupState: workGroupViewState,
12041204
},
12051205
},
1206-
liveFollowEnabled,
1206+
liveFollowEnabled && !anchoredEndSpace,
12071207
);
12081208
}
12091209
}
@@ -1257,6 +1257,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
12571257
rows,
12581258
listIdentityKey,
12591259
liveFollowEnabled,
1260+
anchoredEndSpace,
12601261
paintOnly,
12611262
restoringThreadPosition,
12621263
listRef,

0 commit comments

Comments
 (0)