diff --git a/packages/webui/components/chat/message-input.tsx b/packages/webui/components/chat/message-input.tsx index fe0309da..a7ae3992 100644 --- a/packages/webui/components/chat/message-input.tsx +++ b/packages/webui/components/chat/message-input.tsx @@ -6,6 +6,7 @@ import { client } from '@/ui/api/client' import { useAnnotationStore } from '@/ui/stores/annotation-store' import type { Annotation } from '@/ui/types' import { useMutation } from '@tanstack/react-query' +import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar' import { Skeleton } from '../ui/skeleton' import { useMemberStore } from '@/ui/stores/members' import { useTeamContextStore } from '@/ui/stores/team-context' @@ -158,6 +159,7 @@ export const ChatInput = React.forwardRef( const editorRef = useRef(null) const fileInputRef = useRef(null) const mentionRangeRef = useRef(null) + const mentionListRef = useRef(null) const { mutateAsync: uploadAttachment } = useMutation({ mutationFn: async ({ @@ -238,6 +240,22 @@ export const ChatInput = React.forwardRef( setHighlightedIndex(0) }, [mentionQuery, showMentionList, collapsedSections]) + // Keep the highlighted mention item visible when navigating with arrow keys + useEffect(() => { + mentionListRef.current + ?.querySelector(`[data-index="${highlightedIndex}"]`) + ?.scrollIntoView({ block: 'nearest' }) + }, [highlightedIndex]) + + const getInitials = (name: string) => { + return name + .split(' ') + .map((n) => n[0]) + .slice(0, 2) + .join('') + .toUpperCase() + } + const handleInput = () => { if (!editorRef.current) return setHasContent(!!editorRef.current.innerText.trim()) @@ -492,7 +510,7 @@ export const ChatInput = React.forwardRef( {showMentionList && (membersLoading || filteredAgents.length > 0 || filteredHumans.length > 0) && (
-
+
{membersLoading ? (
{/* Agents Skeleton */} @@ -534,7 +552,7 @@ export const ChatInput = React.forwardRef( e.stopPropagation() setCollapsedSections((prev) => ({ ...prev, bots: !prev.bots })) }} - className="w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border sticky top-0 flex items-center justify-between hover:bg-muted transition-colors" + className="w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors" > Agents ( return ( ) @@ -573,7 +601,7 @@ export const ChatInput = React.forwardRef( e.stopPropagation() setCollapsedSections((prev) => ({ ...prev, users: !prev.users })) }} - className="w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border sticky top-0 flex items-center justify-between hover:bg-muted transition-colors" + className="w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors" > Members ( return ( )