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];
|
return stored.openai ?? PROVIDER_FALLBACK_MODELS.openai[0];
|
||||||
});
|
});
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const transcriptContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const transcriptEndRef = useRef<HTMLDivElement>(null);
|
const transcriptEndRef = useRef<HTMLDivElement>(null);
|
||||||
const contextMenuRef = useRef<HTMLDivElement>(null);
|
const contextMenuRef = useRef<HTMLDivElement>(null);
|
||||||
const selectedItemRef = useRef<SidebarSelection | null>(null);
|
const selectedItemRef = useRef<SidebarSelection | null>(null);
|
||||||
const pendingTitleGenerationRef = useRef<Set<string>>(new Set());
|
const pendingTitleGenerationRef = useRef<Set<string>>(new Set());
|
||||||
const searchRunAbortRef = useRef<AbortController | null>(null);
|
const searchRunAbortRef = useRef<AbortController | null>(null);
|
||||||
const searchRunCounterRef = useRef(0);
|
const searchRunCounterRef = useRef(0);
|
||||||
|
const shouldAutoScrollRef = useRef(true);
|
||||||
const wasSendingRef = useRef(false);
|
const wasSendingRef = useRef(false);
|
||||||
const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null);
|
const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null);
|
||||||
const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false);
|
const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false);
|
||||||
@@ -506,6 +508,10 @@ export default function App() {
|
|||||||
|
|
||||||
const selectedKey = selectedItem ? `${selectedItem.kind}:${selectedItem.id}` : null;
|
const selectedKey = selectedItem ? `${selectedItem.kind}:${selectedItem.id}` : null;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
shouldAutoScrollRef.current = true;
|
||||||
|
}, [draftKind, selectedItem?.kind, selectedKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
selectedItemRef.current = selectedItem;
|
selectedItemRef.current = selectedItem;
|
||||||
}, [selectedItem]);
|
}, [selectedItem]);
|
||||||
@@ -534,6 +540,7 @@ export default function App() {
|
|||||||
const wasSending = wasSendingRef.current;
|
const wasSending = wasSendingRef.current;
|
||||||
wasSendingRef.current = isSending;
|
wasSendingRef.current = isSending;
|
||||||
if (wasSending && !isSending) return;
|
if (wasSending && !isSending) return;
|
||||||
|
if (!shouldAutoScrollRef.current) return;
|
||||||
transcriptEndRef.current?.scrollIntoView({ behavior: isSending ? "smooth" : "auto", block: "end" });
|
transcriptEndRef.current?.scrollIntoView({ behavior: isSending ? "smooth" : "auto", block: "end" });
|
||||||
}, [draftKind, selectedChat?.messages.length, isSending, selectedItem?.kind, selectedKey]);
|
}, [draftKind, selectedChat?.messages.length, isSending, selectedItem?.kind, selectedKey]);
|
||||||
|
|
||||||
@@ -1174,7 +1181,16 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</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 ? (
|
{!isSearchMode ? (
|
||||||
<ChatMessagesPanel messages={displayMessages} isLoading={isLoadingSelection} isSending={isSendingActiveChat} />
|
<ChatMessagesPanel messages={displayMessages} isLoading={isLoadingSelection} isSending={isSendingActiveChat} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user