Skip to content

Commit fdf1254

Browse files
committed
fix(web): reset follow state when incoming history is ready
1 parent 457c8a7 commit fdf1254

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,9 @@ const TYPE_TO_FOCUS_INTERACTIVE_SELECTOR = [
726726
'[role="switch"]',
727727
'[role="tab"]',
728728
].join(",");
729+
const TIMELINE_SPACE_ACTIVATION_SELECTOR = TYPE_TO_FOCUS_INTERACTIVE_SELECTOR.split(",")
730+
.filter((selector) => selector !== "a[href]")
731+
.join(",");
729732
// Popups match only while open or closing: some stay mounted when closed,
730733
// such as the chat header actions menu.
731734
const TYPE_TO_FOCUS_FLOATING_LAYER_SELECTOR = [
@@ -6537,6 +6540,11 @@ export default function ChatView(props: ChatViewProps) {
65376540
// (reading or selecting up there must hold position); clicking near
65386541
// the live edge keeps following.
65396542
const handlePointerDown = (event: PointerEvent) => {
6543+
if (
6544+
event.button === 1 &&
6545+
eventPathContainsSelector(event, `a[href],${TYPE_TO_FOCUS_EDITABLE_SELECTOR}`)
6546+
)
6547+
return;
65406548
if (event.target === scrollNode || event.button === 1) {
65416549
if (contentScrollsUp()) {
65426550
handleManualNavigation();
@@ -6568,6 +6576,8 @@ export default function ChatView(props: ChatViewProps) {
65686576
) {
65696577
return;
65706578
}
6579+
if (event.key === " " && eventPathContainsSelector(event, TIMELINE_SPACE_ACTIVATION_SELECTOR))
6580+
return;
65716581
const scrollKey = event.key === " " ? (event.shiftKey ? "PageUp" : "PageDown") : event.key;
65726582
if (!["PageUp", "Home", "ArrowUp", "PageDown", "End", "ArrowDown"].includes(scrollKey))
65736583
return;
@@ -6799,8 +6809,8 @@ export default function ChatView(props: ChatViewProps) {
67996809
activeTimelineAnchorIndexRef.current = null;
68006810
showScrollDebouncer.current.cancel();
68016811
setShowScrollToBottom(false);
6802-
// Environment identity is part of the scroll session too.
6803-
}, [routeThreadKey]);
6812+
// Readiness starts a fresh scroll session after an outgoing thread was held.
6813+
}, [timelineFollowEntryKey]);
68046814

68056815
useEffect(() => {
68066816
if (!activeThread?.id || terminalUiState.terminalOpen) return;

0 commit comments

Comments
 (0)