From e95e417cc8b74c97bc8555e4e1b222338b62c317 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Mon, 27 Apr 2026 01:19:05 +0530 Subject: [PATCH] feat: implement smooth scrolling for provider sidebar in ModelSelector --- .../components/new-chat/model-selector.tsx | 92 ++++++++++++++++--- 1 file changed, 80 insertions(+), 12 deletions(-) diff --git a/surfsense_web/components/new-chat/model-selector.tsx b/surfsense_web/components/new-chat/model-selector.tsx index 130637c96..3f5a5fa8c 100644 --- a/surfsense_web/components/new-chat/model-selector.tsx +++ b/surfsense_web/components/new-chat/model-selector.tsx @@ -320,6 +320,30 @@ export function ModelSelector({ [isMobile] ); + const scrollProviderSidebar = useCallback( + (direction: "backward" | "forward") => { + const el = providerSidebarRef.current; + if (!el) return; + const delta = isMobile + ? Math.max(56, Math.floor(el.clientWidth * 0.5)) + : Math.max(44, Math.floor(el.clientHeight * 0.4)); + + if (isMobile) { + el.scrollBy({ + left: direction === "backward" ? -delta : delta, + behavior: "smooth", + }); + return; + } + + el.scrollBy({ + top: direction === "backward" ? -delta : delta, + behavior: "smooth", + }); + }, + [isMobile] + ); + // Cmd/Ctrl+M shortcut (desktop only) useEffect(() => { if (isMobile) return; @@ -716,17 +740,40 @@ export function ModelSelector({ return (
- {!isMobile && sidebarScrollPos !== "top" && ( -
- + {!isMobile && ( +
+
)} - {isMobile && sidebarScrollPos !== "top" && ( -
+ {isMobile && ( +
)} @@ -802,13 +849,34 @@ export function ModelSelector({ ); })}
- {!isMobile && sidebarScrollPos !== "bottom" && ( -
- + {!isMobile && ( +
+
)} - {isMobile && sidebarScrollPos !== "bottom" && ( -
+ {isMobile && ( +
)}