feat(FN-4327): complete Step 3 — anchor direct thread on scope switch

Fusion-Task-Id: FN-4327
Fusion-Task-Lineage: 8508cca0-c7ff-43da-bbf1-385f9bc095ff
This commit is contained in:
Fusion
2026-05-13 08:29:34 -07:00
committed by gsxdsm
parent 74a1d8af57
commit 24339f7d89

View File

@@ -959,6 +959,7 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
const mobileSessionMenuRef = useRef<HTMLDivElement>(null);
const isUserScrollingRef = useRef(false);
const lastAnchoredThreadStateRef = useRef<{ threadId: string; loaded: boolean; hasMessages: boolean } | null>(null);
const previousChatScopeRef = useRef<"direct" | "rooms" | null>(null);
const hideSkillMenuTimeoutRef = useRef<number | null>(null);
const messagesContainerRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLTextAreaElement>(null);
@@ -1295,6 +1296,28 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
};
}, [isMobile, activeSession]);
useEffect(() => {
const previousScope = previousChatScopeRef.current;
previousChatScopeRef.current = chatScope;
if (chatScope !== "direct") {
return;
}
if (previousScope !== null && previousScope !== "rooms") {
return;
}
const messagesContainer = messagesContainerRef.current;
if (!messagesContainer) {
return;
}
anchorToBottom(messagesContainer);
isUserScrollingRef.current = false;
setIsUserScrolling(false);
}, [chatScope, anchorToBottom]);
useEffect(() => {
if (!activeSession && !roomThreadActive) {
return;