From 39f30f10b2db71a1097452b61c1aa2672655314f Mon Sep 17 00:00:00 2001 From: ved015 <122012786+ved015@users.noreply.github.com> Date: Mon, 18 May 2026 16:37:40 +0000 Subject: [PATCH] fix auto scroll bug and mobile responsiveness (#965) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes a bug in auto scroll after the first msg auto scroll was not working properly it is fixed now It also tightens Support & Help on small screens: slightly reduced card/title spacing and stacked-button gaps, and replaces fixed-height pills with responsive vertical padding so label text is not flush with the pill edges on mobile devices ## Before Screenshot 2026-05-18 at 6 56 48 PM ## After Screenshot 2026-05-18 at 6 57 04 PM --- apps/web/components/chat/index.tsx | 29 ++++++++++++++---------- apps/web/components/settings/support.tsx | 8 +++---- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/web/components/chat/index.tsx b/apps/web/components/chat/index.tsx index 9f108d84..faef8554 100644 --- a/apps/web/components/chat/index.tsx +++ b/apps/web/components/chat/index.tsx @@ -219,6 +219,7 @@ export function ChatSidebar({ ) const messagesContainerRef = useRef(null) const isScrolledToBottomRef = useRef(true) + const userJustSentRef = useRef(false) const sentQueuedMessageRef = useRef(null) const pendingHighlightReplyRef = useRef(null) const awaitingHighlightInjectionRef = useRef(false) @@ -364,6 +365,7 @@ export function ChatSidebar({ analytics.chatMessageSent({ source: "typed" }) sendMessage({ text: input }) setInput("") + userJustSentRef.current = true scrollToBottom() } @@ -374,6 +376,7 @@ export function ChatSidebar({ analytics.chatSuggestedQuestionClicked() analytics.chatMessageSent({ source: "suggested" }) sendMessage({ text: suggestion }) + userJustSentRef.current = true scrollToBottom() }, [ @@ -691,13 +694,11 @@ export function ChatSidebar({ useEffect(() => { const lastMessage = messages[messages.length - 1] if (lastMessage?.role === "user" && messagesContainerRef.current) { - messagesContainerRef.current.scrollTop = - messagesContainerRef.current.scrollHeight - setIsScrolledToBottom(true) + scrollToBottom() + } else { + checkIfScrolledToBottom() } - // Always check scroll position when messages change - checkIfScrolledToBottom() - }, [messages, checkIfScrolledToBottom]) + }, [messages, checkIfScrolledToBottom, scrollToBottom]) useEffect(() => { const isStreaming = status === "streaming" @@ -707,7 +708,7 @@ export function ChatSidebar({ if ( isStreaming && isLastMessageFromAssistant && - isScrolledToBottomRef.current + (isScrolledToBottomRef.current || userJustSentRef.current) ) { scrollToBottom() } @@ -717,11 +718,14 @@ export function ChatSidebar({ const container = messagesContainerRef.current if (!container) return - const isStreaming = status === "streaming" - if (!isStreaming) return + const isStreaming = status === "streaming" || status === "submitted" + if (!isStreaming) { + userJustSentRef.current = false + return + } const mutationObserver = new MutationObserver(() => { - if (isScrolledToBottomRef.current) { + if (isScrolledToBottomRef.current || userJustSentRef.current) { requestAnimationFrame(() => { scrollToBottom() }) @@ -747,16 +751,17 @@ export function ChatSidebar({ const handleScroll = () => { requestAnimationFrame(() => { checkIfScrolledToBottom() + if (!isScrolledToBottomRef.current) { + userJustSentRef.current = false + } }) } container.addEventListener("scroll", handleScroll, { passive: true }) - // Initial check with a small delay to ensure DOM is ready setTimeout(() => { checkIfScrolledToBottom() }, 100) - // Also observe resize to detect content height changes const resizeObserver = new ResizeObserver(() => { requestAnimationFrame(() => { checkIfScrolledToBottom() diff --git a/apps/web/components/settings/support.tsx b/apps/web/components/settings/support.tsx index 5868f356..f5f7508d 100644 --- a/apps/web/components/settings/support.tsx +++ b/apps/web/components/settings/support.tsx @@ -32,7 +32,7 @@ function SectionTitle({ children }: { children: React.ReactNode }) {

{children} @@ -44,7 +44,7 @@ function SupportCard({ children }: { children: React.ReactNode }) { return (

@@ -69,7 +69,7 @@ function PillButton({ className={cn( "relative flex items-center justify-center gap-2", "bg-[#0D121A]", - "rounded-full h-11 px-4 flex-1", + "rounded-full py-3 sm:py-2.5 px-4 flex-1", "cursor-pointer transition-opacity hover:opacity-80", "shadow-[inset_1.5px_1.5px_4.5px_rgba(0,0,0,0.7)]", dmSans125ClassName(), @@ -128,7 +128,7 @@ export default function Support() { reach us.

-
+
Message us on X