Scroll fix pt 2
This commit is contained in:
@@ -320,12 +320,14 @@ export default function App() {
|
||||
return stored.openai ?? PROVIDER_FALLBACK_MODELS.openai[0];
|
||||
});
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const transcriptContainerRef = useRef<HTMLDivElement>(null);
|
||||
const transcriptEndRef = useRef<HTMLDivElement>(null);
|
||||
const contextMenuRef = useRef<HTMLDivElement>(null);
|
||||
const selectedItemRef = useRef<SidebarSelection | null>(null);
|
||||
const pendingTitleGenerationRef = useRef<Set<string>>(new Set());
|
||||
const searchRunAbortRef = useRef<AbortController | null>(null);
|
||||
const searchRunCounterRef = useRef(0);
|
||||
const shouldAutoScrollRef = useRef(true);
|
||||
const wasSendingRef = useRef(false);
|
||||
const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null);
|
||||
const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false);
|
||||
@@ -506,6 +508,10 @@ export default function App() {
|
||||
|
||||
const selectedKey = selectedItem ? `${selectedItem.kind}:${selectedItem.id}` : null;
|
||||
|
||||
useEffect(() => {
|
||||
shouldAutoScrollRef.current = true;
|
||||
}, [draftKind, selectedItem?.kind, selectedKey]);
|
||||
|
||||
useEffect(() => {
|
||||
selectedItemRef.current = selectedItem;
|
||||
}, [selectedItem]);
|
||||
@@ -534,6 +540,7 @@ export default function App() {
|
||||
const wasSending = wasSendingRef.current;
|
||||
wasSendingRef.current = isSending;
|
||||
if (wasSending && !isSending) return;
|
||||
if (!shouldAutoScrollRef.current) return;
|
||||
transcriptEndRef.current?.scrollIntoView({ behavior: isSending ? "smooth" : "auto", block: "end" });
|
||||
}, [draftKind, selectedChat?.messages.length, isSending, selectedItem?.kind, selectedKey]);
|
||||
|
||||
@@ -1174,7 +1181,16 @@ export default function App() {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className={cn("flex-1 overflow-y-auto px-3 pt-6 md:px-10", isSearchMode ? "pb-6" : "pb-28 md:pb-40")}>
|
||||
<div
|
||||
ref={transcriptContainerRef}
|
||||
className={cn("flex-1 overflow-y-auto px-3 pt-6 md:px-10", isSearchMode ? "pb-6" : "pb-28 md:pb-40")}
|
||||
onScroll={() => {
|
||||
const container = transcriptContainerRef.current;
|
||||
if (!container) return;
|
||||
const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
|
||||
shouldAutoScrollRef.current = distanceFromBottom < 96;
|
||||
}}
|
||||
>
|
||||
{!isSearchMode ? (
|
||||
<ChatMessagesPanel messages={displayMessages} isLoading={isLoadingSelection} isSending={isSendingActiveChat} />
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user