diff --git a/webui/src/components/ChatList.tsx b/webui/src/components/ChatList.tsx index 98490e5a2..c12afa717 100644 --- a/webui/src/components/ChatList.tsx +++ b/webui/src/components/ChatList.tsx @@ -107,7 +107,6 @@ export const ChatList = memo(function ChatList({ }: ChatListProps) { const { t } = useTranslation(); const [visibleLimit, setVisibleLimit] = useState(INITIAL_VISIBLE_SESSIONS); - const listContentRef = useRef(null); const activeRowRef = useRef(null); const labels = useMemo(() => ({ pinned: t("chat.groups.pinned"), @@ -188,8 +187,10 @@ export const ChatList = memo(function ChatList({ return (
-
@@ -408,13 +409,7 @@ export const ChatList = memo(function ChatList({
) : null} - -
+ ); }); diff --git a/webui/src/components/Sidebar.tsx b/webui/src/components/Sidebar.tsx index ae3227594..485727569 100644 --- a/webui/src/components/Sidebar.tsx +++ b/webui/src/components/Sidebar.tsx @@ -92,7 +92,6 @@ export function Sidebar(props: SidebarProps) { const collapsed = Boolean(props.collapsed); const toggleLabel = t("thread.header.toggleSidebar"); const newChatShortcut = newChatShortcutLabel(); - const actionListRef = useRef(null); const activeActionRef = useRef(null); const activeActionId = props.newChatActive ? "new-chat" @@ -150,8 +149,10 @@ export function Sidebar(props: SidebarProps) { )} -
} /> ) : null} - -
+
; +interface SidebarSelectionHighlightProps extends HTMLAttributes { targetRef: RefObject; activeId: string | null; scope: string; @@ -18,11 +18,13 @@ export const SIDEBAR_SELECTION_ACTION_ITEM_CLASS = "relative z-[1] transition-[width,padding,color] [transition-duration:300ms,300ms,150ms] ease-out motion-reduce:transition-none"; export function SidebarSelectionHighlight({ - containerRef, targetRef, activeId, scope, + children, + ...containerProps }: SidebarSelectionHighlightProps) { + const containerRef = useRef(null); const highlightRef = useRef(null); const positionedRef = useRef(false); @@ -30,11 +32,19 @@ export function SidebarSelectionHighlight({ const highlight = highlightRef.current; const container = containerRef.current; const target = targetRef.current; + if (!highlight) return; + if (!activeId || !container || !target) { + highlight.style.opacity = "0"; + positionedRef.current = false; + return; + } + let restoreTransitionFrame: number | null = null; const position = () => { - if (!highlight) return; - if (!activeId || !container || !target) { + const containerRect = container.getBoundingClientRect(); + const targetRect = target.getBoundingClientRect(); + if (targetRect.width === 0 || targetRect.height === 0) { highlight.style.opacity = "0"; positionedRef.current = false; return; @@ -43,8 +53,6 @@ export function SidebarSelectionHighlight({ const firstPosition = !positionedRef.current; if (firstPosition) highlight.style.transitionProperty = "none"; - const containerRect = container.getBoundingClientRect(); - const targetRect = target.getBoundingClientRect(); highlight.style.width = `${targetRect.width}px`; highlight.style.height = `${targetRect.height}px`; highlight.style.transform = `translate3d(${targetRect.left - containerRect.left}px, ${ @@ -64,8 +72,8 @@ export function SidebarSelectionHighlight({ position(); const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(position); - if (container) resizeObserver?.observe(container); - if (target) resizeObserver?.observe(target); + resizeObserver?.observe(container); + resizeObserver?.observe(target); window.addEventListener("resize", position); return () => { @@ -79,12 +87,15 @@ export function SidebarSelectionHighlight({ }); return ( -