diff --git a/web/app/components/workflow/comment/thread.tsx b/web/app/components/workflow/comment/thread.tsx index e42e4fe6c7..338c4debda 100644 --- a/web/app/components/workflow/comment/thread.tsx +++ b/web/app/components/workflow/comment/thread.tsx @@ -2,6 +2,7 @@ import type { FC, ReactNode } from 'react' import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useParams } from 'next/navigation' import { useReactFlow, useViewport } from 'reactflow' import { useTranslation } from 'react-i18next' import { RiArrowDownSLine, RiArrowUpSLine, RiCheckboxCircleFill, RiCheckboxCircleLine, RiCloseLine, RiDeleteBinLine, RiMoreFill } from '@remixicon/react' @@ -16,6 +17,7 @@ import type { WorkflowCommentDetail, WorkflowCommentDetailReply } from '@/servic import { useAppContext } from '@/context/app-context' import { MentionInput } from './mention-input' import { getUserColor } from '@/app/components/workflow/collaboration/utils/user-color' +import { useStore } from '../store' type CommentThreadProps = { comment: WorkflowCommentDetail @@ -41,9 +43,9 @@ const ThreadMessage: FC<{ avatarUrl?: string | null createdAt: number content: string - mentionedNames?: string[] + mentionableNames: string[] className?: string -}> = ({ authorId, authorName, avatarUrl, createdAt, content, mentionedNames, className }) => { +}> = ({ authorId, authorName, avatarUrl, createdAt, content, mentionableNames, className }) => { const { formatTimeFromNow } = useFormatTimeFromNow() const { userProfile } = useAppContext() const currentUserId = userProfile?.id @@ -54,9 +56,11 @@ const ThreadMessage: FC<{ if (!content) return '' - const normalizedNames = Array.from(new Set((mentionedNames || []) + // Extract valid user names from mentionableNames, sorted by length (longest first) + const normalizedNames = Array.from(new Set(mentionableNames .map(name => name.trim()) .filter(Boolean))) + normalizedNames.sort((a, b) => b.length - a.length) if (normalizedNames.length === 0) return content @@ -111,7 +115,7 @@ const ThreadMessage: FC<{ segments.push({content.slice(cursor)}) return segments - }, [content, mentionedNames]) + }, [content, mentionableNames]) return (