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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user