From f65401bb0a4c32802159538a3889fd58c31cab5b Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 15:27:28 +0800 Subject: [PATCH] feat(comment): support selectable message card in comment list with custom select callbacks --- src/ui/components/chat/message-card.tsx | 26 ++++++------ .../components/file-viewer-right-sidebar.tsx | 42 ++++++++++++------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/ui/components/chat/message-card.tsx b/src/ui/components/chat/message-card.tsx index 56c64178..22c89600 100644 --- a/src/ui/components/chat/message-card.tsx +++ b/src/ui/components/chat/message-card.tsx @@ -12,7 +12,7 @@ import { import { Separator } from '@/ui/components/ui/separator' import { formatTimeAgo } from '@/ui/lib/time' import { useQuery } from '@tanstack/react-query' -import { Download, File, Terminal } from 'lucide-react' +import { Clock, Download, File, Terminal } from 'lucide-react' import React from 'react' import Markdown from 'react-markdown' import { Avatar, AvatarFallback } from '../ui/avatar' @@ -28,7 +28,8 @@ interface MessageCardProps { getUser: (id: string) => UserInfo onReply: (message: CommentInfo) => void onViewAttachment: (attachment: AttachmentInfo) => void - onTimestampClick?: (seconds: number) => void + isSelected?: boolean + onSelect?: () => void frameRate?: number rootParentId?: string } @@ -51,7 +52,8 @@ export const MessageCard: React.FC = ({ getUser, onReply, onViewAttachment, - onTimestampClick, + isSelected, + onSelect, frameRate, }) => { const isRunning = @@ -139,7 +141,12 @@ export const MessageCard: React.FC = ({ return (
{hasReplies && !isReply && (
@@ -170,15 +177,10 @@ export const MessageCard: React.FC = ({
{message.second !== null && message.second !== undefined && frameRate && ( - +
)} {showSkeleton ? ( diff --git a/src/ui/components/file-viewer-right-sidebar.tsx b/src/ui/components/file-viewer-right-sidebar.tsx index de7a20b3..157db8eb 100644 --- a/src/ui/components/file-viewer-right-sidebar.tsx +++ b/src/ui/components/file-viewer-right-sidebar.tsx @@ -52,6 +52,7 @@ export function FileViewerRightSidebar({ const [replyingTo, setReplyingTo] = useState(null) const [viewingAttachment, setViewingAttachment] = useState(null) const [isGuestPopupOpen, setIsGuestPopupOpen] = useState(false) + const [selectedCommentId, setSelectedCommentId] = useState(null) const [pendingComment, setPendingComment] = useState<{ text: string attachmentIds: string[] @@ -340,9 +341,9 @@ export function FileViewerRightSidebar({ -
+
{comments.map((comment) => ( -
onCommentSelect?.(comment)}> +
onCommentSelect?.({ ...comment, second: sec })} + isSelected={selectedCommentId === comment.id} + onSelect={() => { + setSelectedCommentId(comment.id!) + onCommentSelect?.(comment) + }} /> {comment.replies?.map((reply, index) => ( - onCommentSelect?.({ ...reply, second: sec })} - /> +
+ { + setSelectedCommentId(reply.id!) + onCommentSelect?.(reply) + }} + /> +
))}
))}