From c048ceef286b3e4fd6a6e5efced6b22f2842a3df Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 11:17:56 +0800 Subject: [PATCH 1/7] feat(video): add timestamp support to comments --- src/api/file.test.ts | 10 +++--- src/dtos/asset.ts | 2 ++ src/services/asset/asset.test.ts | 22 ++++++++++++ src/services/asset/asset.ts | 1 + src/ui/components/chat/message-card.tsx | 19 ++++++++++- src/ui/components/chat/message-input.tsx | 34 ++++++++++++++++++- .../components/file-viewer-right-sidebar.tsx | 22 +++++++++--- src/ui/components/file-viewer.tsx | 11 +++++- src/ui/components/public-share-manager.tsx | 15 ++++++-- src/ui/components/viewers/utils.ts | 10 ++++++ src/ui/components/viewers/video-player.tsx | 6 ++++ .../projects/$projectId/files/$fileId.tsx | 26 ++++++++++---- 12 files changed, 158 insertions(+), 20 deletions(-) diff --git a/src/api/file.test.ts b/src/api/file.test.ts index 82d73911..bdb3e551 100644 --- a/src/api/file.test.ts +++ b/src/api/file.test.ts @@ -157,10 +157,11 @@ describe('file api', () => { it('POST /files/:fileId/comments', async () => { vi.mocked(assetService.createComment).mockResolvedValue({ id: 'comment-id', - assetId: 'test-id', + assetId: 'file-id', message: 'hello', annotations: null, - creator: { id: 'user1', name: 'user-name' }, + second: null, + creator: { id: 'user-id', name: 'Test User' }, replies: [], attachments: [], mentions: [], @@ -207,10 +208,11 @@ describe('file api', () => { data: [ { id: 'comment-id', - assetId: 'test-id', + assetId: 'file-id', message: 'hello', annotations: null, - creator: { id: 'user1', name: 'user-name' }, + second: null, + creator: { id: 'user-id', name: 'Test User' }, replies: [], attachments: [], mentions: [], diff --git a/src/dtos/asset.ts b/src/dtos/asset.ts index cee55d07..3faa3771 100644 --- a/src/dtos/asset.ts +++ b/src/dtos/asset.ts @@ -189,6 +189,7 @@ export type CommentInfo = { message: string | null // eslint-disable-next-line @typescript-eslint/no-explicit-any annotations: any + second: number | null creator: UserInfo replies: CommentInfo[] attachments: AttachmentInfo[] @@ -204,6 +205,7 @@ export const commentInfoSchema: z.ZodType = z.object({ message: z.string().nullable(), annotations: z.any(), + second: z.number().nullable(), creator: userInfoSchema, replies: z.array(z.lazy(() => commentInfoSchema)), attachments: z.array(attachmentInfoSchema), diff --git a/src/services/asset/asset.test.ts b/src/services/asset/asset.test.ts index 8b9aaa57..b91e0fdb 100644 --- a/src/services/asset/asset.test.ts +++ b/src/services/asset/asset.test.ts @@ -664,6 +664,28 @@ describe('AssetService', () => { expect(list.data[0].replies.length).toBe(1) }) + it('can create and retrieve comments with video timestamp', async () => { + const { user, assets } = await setupBasicAssets() + + const comment = await assetService.createComment({ + assetId: assets.fileA1.id, + userId: user.id, + message: 'Interesting point at 5.5s', + second: 5.5, + attachmentIds: [], + }) + + expect(comment.second).toBe(5.5) + + const retrieved = await assetService.getComment(comment.id) + expect(retrieved.second).toBe(5.5) + + const list = await assetService.listComments(assets.fileA1.id, { + first: 10, + }) + expect(list.data[0].second).toBe(5.5) + }) + it('correctly handles AI comments with agent identity', async () => { const { assets, project } = await setupBasicAssets() diff --git a/src/services/asset/asset.ts b/src/services/asset/asset.ts index fb4e15d9..e1e66396 100644 --- a/src/services/asset/asset.ts +++ b/src/services/asset/asset.ts @@ -1690,6 +1690,7 @@ export class AssetService { assetId: c.assetId, message: c.message, annotations: c.annotation, + second: c.second, creator, replies, attachments, diff --git a/src/ui/components/chat/message-card.tsx b/src/ui/components/chat/message-card.tsx index 8b6b37d5..fbe1b7dc 100644 --- a/src/ui/components/chat/message-card.tsx +++ b/src/ui/components/chat/message-card.tsx @@ -11,12 +11,13 @@ import { } from '@/ui/components/ui/dialog' import { Separator } from '@/ui/components/ui/separator' import { useQuery } from '@tanstack/react-query' -import { Download, File, Terminal } from 'lucide-react' +import { Download, File, Terminal, Clock } from 'lucide-react' import React from 'react' import { formatTimeAgo } from '@/ui/lib/time' import Markdown from 'react-markdown' import { Avatar, AvatarFallback } from '../ui/avatar' import { Skeleton } from '../ui/skeleton' +import { formatTimestamp } from '../viewers/utils' interface MessageCardProps { teamId?: string @@ -27,6 +28,8 @@ interface MessageCardProps { getUser: (id: string) => UserInfo onReply: (message: CommentInfo) => void onViewAttachment: (attachment: AttachmentInfo) => void + onTimestampClick?: (seconds: number) => void + frameRate?: number rootParentId?: string } @@ -48,6 +51,8 @@ export const MessageCard: React.FC = ({ getUser, onReply, onViewAttachment, + onTimestampClick, + frameRate, }) => { const isRunning = !!initialMessage.sessionId && @@ -153,6 +158,18 @@ export const MessageCard: React.FC = ({
{creator?.name || 'Unknown'} + {message.second !== null && message.second !== undefined && frameRate && ( + + )} {new Date(message.createdAt!).toLocaleTimeString([], { hour: '2-digit', diff --git a/src/ui/components/chat/message-input.tsx b/src/ui/components/chat/message-input.tsx index 014b64cc..e71dfda3 100644 --- a/src/ui/components/chat/message-input.tsx +++ b/src/ui/components/chat/message-input.tsx @@ -8,6 +8,7 @@ import { ArrowUp, Brush, ChevronDown, + Clock, FileIcon, Minus, Paperclip, @@ -24,6 +25,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover' import { useAnnotationStore } from '@/ui/stores/annotation-store' import type { Annotation } from '@/ui/types' import { useMutation } from '@tanstack/react-query' +import { formatTimestamp } from '../viewers/utils' type UploadingFile = { id: string // A unique ID for the file, e.g., timestamp + name @@ -40,6 +42,7 @@ interface ChatInputProps { attachmentIds: string[], annotations?: Annotation[], replyToId?: string | null, + second?: number | null, ) => void replyingTo?: CommentInfo | null onCancelReply?: () => void @@ -48,6 +51,8 @@ interface ChatInputProps { initialText?: string hideAnnotationControl?: boolean disableMentions?: boolean + currentTime?: number + frameRate?: number } const PREDEFINED_COLORS = [ @@ -76,11 +81,14 @@ export const ChatInput = React.forwardRef( initialText = '', hideAnnotationControl = false, disableMentions = false, + currentTime, + frameRate, }, ref, ) => { const [uploadingFiles, setUploadingFiles] = useState([]) const [viewingFile, setViewingFile] = useState(null) + const [isTimestampEnabled, setIsTimestampEnabled] = useState(true) // Annotation Store const { @@ -395,7 +403,13 @@ export const ChatInput = React.forwardRef( // Allow sending if annotations exist, even if text is empty if (!processedText && successfulAttachmentIds.length === 0 && annotations.length === 0) return - onSendMessage(processedText, successfulAttachmentIds, annotations, replyingTo?.id) + onSendMessage( + processedText, + successfulAttachmentIds, + annotations, + replyingTo?.id, + isTimestampEnabled ? currentTime : undefined, + ) // Reset editor editorRef.current.innerHTML = '' @@ -566,6 +580,15 @@ export const ChatInput = React.forwardRef(
)} + {isTimestampEnabled && currentTime !== undefined && frameRate !== undefined && ( +
+
+ + {formatTimestamp(currentTime, frameRate)} +
+
+ )} +
( multiple onChange={handleFileSelect} /> +
@@ -375,6 +387,8 @@ export function FileViewerRightSidebar({ bots={enabledBots} hideAnnotationControl={hideAnnotationControl} disableMentions={isPublic} + currentTime={currentTime} + frameRate={file?.media?.metadata?.frameRate || 30} />
diff --git a/src/ui/components/file-viewer.tsx b/src/ui/components/file-viewer.tsx index bea8cc0a..9d70bbc0 100644 --- a/src/ui/components/file-viewer.tsx +++ b/src/ui/components/file-viewer.tsx @@ -16,10 +16,18 @@ type FileViewerProps = { videoRef?: RefObject onPlay?: () => void onPause?: () => void + onTimeUpdate?: (time: number) => void annotations?: Annotation[] } -export function FileViewer({ file, videoRef, onPlay, onPause, annotations }: FileViewerProps) { +export function FileViewer({ + file, + videoRef, + onPlay, + onPause, + onTimeUpdate, + annotations, +}: FileViewerProps) { const { width: screenWidth } = useScreenSize() const isImage = file.mediaType?.startsWith('image/') const isVideo = file.mediaType?.startsWith('video/') @@ -186,6 +194,7 @@ export function FileViewer({ file, videoRef, onPlay, onPause, annotations }: Fil playerRef={videoRef} onPlay={onPlay} onPause={onPause} + onTimeUpdate={onTimeUpdate} annotations={displayAnnotations} /> )} diff --git a/src/ui/components/public-share-manager.tsx b/src/ui/components/public-share-manager.tsx index e3f9f4ad..f8438a74 100644 --- a/src/ui/components/public-share-manager.tsx +++ b/src/ui/components/public-share-manager.tsx @@ -89,6 +89,7 @@ export function PublicShareManager({ const [isRightSidebarCollapsed] = useState(false) const videoRef = useRef(null) const [annotations, setAnnotations] = useState([]) + const [currentTime, setCurrentTime] = useState(0) const { data: foldersData, @@ -257,11 +258,19 @@ export function PublicShareManager({ const newAnnotations = comment.annotations as Annotation[] if (newAnnotations && newAnnotations.length > 0) { setAnnotations(newAnnotations) + } else { + setAnnotations([]) + } + + if (comment.second !== null && comment.second !== undefined) { + if (videoRef.current) { + videoRef.current.currentTime(comment.second) + videoRef.current.pause() + } + } else if (newAnnotations && newAnnotations.length > 0) { if (videoRef.current) { videoRef.current.pause() } - } else { - setAnnotations([]) } } @@ -373,6 +382,7 @@ export function PublicShareManager({ file={viewingFileData} videoRef={videoRef} onPlay={handlePlay} + onTimeUpdate={setCurrentTime} annotations={annotations} /> )} @@ -430,6 +440,7 @@ export function PublicShareManager({ onCommentSelect={handleCommentSelect} isPublic={true} shareId={shareInfo.id} + currentTime={currentTime} />
diff --git a/src/ui/components/viewers/utils.ts b/src/ui/components/viewers/utils.ts index 0c5a4593..b20f9dd4 100644 --- a/src/ui/components/viewers/utils.ts +++ b/src/ui/components/viewers/utils.ts @@ -10,6 +10,16 @@ export const formatTime = (seconds: number): string => { return `${mm}:${ss}` } +export const formatTimestamp = (seconds: number, fps: number): string => { + if (isNaN(seconds)) return '00:00:00:00' + const hh = Math.floor(seconds / 3600) + const mm = Math.floor((seconds % 3600) / 60) + const ss = Math.floor(seconds % 60) + const ff = Math.floor((seconds % 1) * fps) + + return `${hh.toString().padStart(2, '0')}:${mm.toString().padStart(2, '0')}:${ss.toString().padStart(2, '0')}:${ff.toString().padStart(2, '0')}` +} + export const formatFrame = (seconds: number, fps: number): number => { if (isNaN(seconds) || !fps) return 0 return Math.floor(seconds * fps) diff --git a/src/ui/components/viewers/video-player.tsx b/src/ui/components/viewers/video-player.tsx index aae83806..9e8c4aa7 100644 --- a/src/ui/components/viewers/video-player.tsx +++ b/src/ui/components/viewers/video-player.tsx @@ -51,6 +51,7 @@ interface VideoPlayerProps { playerRef?: React.RefObject onPlay?: () => void onPause?: () => void + onTimeUpdate?: (time: number) => void annotations?: Annotation[] } @@ -299,6 +300,7 @@ const VideoPlayer: React.FC = ({ playerRef: passedPlayerRef, onPlay, onPause, + onTimeUpdate, annotations, }) => { const localPlayerRef = useRef(null) @@ -494,6 +496,10 @@ const VideoPlayer: React.FC = ({ duration: duration || prev.duration, progress: duration > 0 ? (current / duration) * 100 : 0, })) + + if (onTimeUpdate) { + onTimeUpdate(current) + } }) player.on('volumechange', () => { diff --git a/src/ui/routes/projects/$projectId/files/$fileId.tsx b/src/ui/routes/projects/$projectId/files/$fileId.tsx index 2f928103..15eb70a6 100644 --- a/src/ui/routes/projects/$projectId/files/$fileId.tsx +++ b/src/ui/routes/projects/$projectId/files/$fileId.tsx @@ -34,6 +34,7 @@ function FileViewPage() { const [leftSidebarWidth, setLeftSidebarWidth] = useState(280) const [rightSidebarWidth, setRightSidebarWidth] = useState(360) const [annotations, setAnnotations] = useState([]) + const [currentTime, setCurrentTime] = useState(0) const $patchMetadata = client.api.files[':fileId'].metadata.$patch const { mutate: patchMetadata } = useMutation< InferResponseType, @@ -197,11 +198,19 @@ function FileViewPage() { const newAnnotations = comment.annotations as Annotation[] if (newAnnotations && newAnnotations.length > 0) { setAnnotations(newAnnotations) + } else { + setAnnotations([]) + } + + if (comment.second !== null && comment.second !== undefined) { + if (videoRef.current) { + videoRef.current.currentTime(comment.second) + videoRef.current.pause() + } + } else if (newAnnotations && newAnnotations.length > 0) { if (videoRef.current) { videoRef.current.pause() } - } else { - setAnnotations([]) } } @@ -244,29 +253,32 @@ function FileViewPage() { file={fileData as unknown as AssetInfo} videoRef={videoRef} onPlay={handlePlay} + onTimeUpdate={setCurrentTime} annotations={annotations} /> - - {!isRightSidebarCollapsed && ( + + {!isRightSidebarCollapsed && ( <> { - setRightSidebarWidth((prev) => Math.max(240, Math.min(600, prev - delta))) + setRightSidebarWidth((prev) => Math.max(300, Math.min(600, prev - delta))) }} className="hidden md:block" />
- )} + )} + ) From b5ecf53998c0663464afb203b43a0a15931b4bc8 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 11:42:51 +0800 Subject: [PATCH 2/7] feat(comment): inline timestamp badge and auto-pause video on typing --- src/ui/components/chat/message-input.tsx | 41 +++++++++++-------- .../components/file-viewer-right-sidebar.tsx | 3 ++ src/ui/components/public-share-manager.tsx | 5 +++ src/ui/routes/__root.tsx | 8 ++-- .../projects/$projectId/files/$fileId.tsx | 12 ++++-- 5 files changed, 44 insertions(+), 25 deletions(-) diff --git a/src/ui/components/chat/message-input.tsx b/src/ui/components/chat/message-input.tsx index e71dfda3..bca4babd 100644 --- a/src/ui/components/chat/message-input.tsx +++ b/src/ui/components/chat/message-input.tsx @@ -1,8 +1,10 @@ -import { client } from '@/ui/api/client' -import type { CommentInfo } from '@/dtos/asset' -import type { UserInfo } from '@/dtos/team' +import type { CommentInfo, PostAttachmentRequest, PostAttachmentResponse } from '@/dtos/asset' import type { BotInfo } from '@/dtos/project' -import type { PostAttachmentRequest, PostAttachmentResponse } from '@/dtos/asset' +import type { UserInfo } from '@/dtos/team' +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 { ArrowLeft, ArrowUp, @@ -20,11 +22,8 @@ import { import React, { useCallback, useEffect, useRef, useState, type ChangeEvent } from 'react' import { Button } from '../ui/button' import { DrawAnnotation } from '../ui/icons' -import { ProgressCircle } from '../ui/progress-circle' import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover' -import { useAnnotationStore } from '@/ui/stores/annotation-store' -import type { Annotation } from '@/ui/types' -import { useMutation } from '@tanstack/react-query' +import { ProgressCircle } from '../ui/progress-circle' import { formatTimestamp } from '../viewers/utils' type UploadingFile = { @@ -53,6 +52,7 @@ interface ChatInputProps { disableMentions?: boolean currentTime?: number frameRate?: number + onTyping?: () => void } const PREDEFINED_COLORS = [ @@ -83,6 +83,7 @@ export const ChatInput = React.forwardRef( disableMentions = false, currentTime, frameRate, + onTyping, }, ref, ) => { @@ -198,6 +199,7 @@ export const ChatInput = React.forwardRef( const handleInput = () => { if (!editorRef.current) return setHasContent(!!editorRef.current.innerText.trim()) + onTyping?.() if (disableMentions) { setShowMentionList(false) @@ -580,16 +582,21 @@ export const ChatInput = React.forwardRef( )} - {isTimestampEnabled && currentTime !== undefined && frameRate !== undefined && ( -
-
- +
editorRef.current?.focus()} + className="w-full px-4 pt-1 pb-1 cursor-text flow-root max-h-60 overflow-y-auto" + > + {isTimestampEnabled && currentTime !== undefined && frameRate !== undefined && ( +
{ + e.stopPropagation() + editorRef.current?.focus() + }} + className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-0.5 mt-3 mr-2 rounded-sm text-xs font-mono font-bold flex items-center gap-1 cursor-text" + > {formatTimestamp(currentTime, frameRate)}
-
- )} - -
+ )}
( data-placeholder={ isDrawing ? 'Drawing active...' : replyingTo ? 'Reply...' : 'Message...' } - className="w-full bg-transparent border-none focus:ring-0 resize-none max-h-60 min-h-[40px] leading-relaxed py-2 focus:outline-none overflow-y-auto" + className={`bg-transparent border-none focus:ring-0 resize-none min-h-[40px] leading-relaxed py-2 focus:outline-none block ${isTimestampEnabled && currentTime !== undefined && frameRate !== undefined && !hasContent ? 'pl-[120px]' : ''}`} />
diff --git a/src/ui/components/file-viewer-right-sidebar.tsx b/src/ui/components/file-viewer-right-sidebar.tsx index b68e36c5..4b85cb70 100644 --- a/src/ui/components/file-viewer-right-sidebar.tsx +++ b/src/ui/components/file-viewer-right-sidebar.tsx @@ -28,6 +28,7 @@ interface FileViewerRightSidebarProps { isPublic?: boolean shareId?: string currentTime?: number + onTyping?: () => void } export function FileViewerRightSidebar({ @@ -43,6 +44,7 @@ export function FileViewerRightSidebar({ isPublic = false, shareId, currentTime, + onTyping, }: FileViewerRightSidebarProps) { const { fields, setFields } = useFieldStore() const queryClient = useQueryClient() @@ -389,6 +391,7 @@ export function FileViewerRightSidebar({ disableMentions={isPublic} currentTime={currentTime} frameRate={file?.media?.metadata?.frameRate || 30} + onTyping={onTyping} />
diff --git a/src/ui/components/public-share-manager.tsx b/src/ui/components/public-share-manager.tsx index f8438a74..31060194 100644 --- a/src/ui/components/public-share-manager.tsx +++ b/src/ui/components/public-share-manager.tsx @@ -441,6 +441,11 @@ export function PublicShareManager({ isPublic={true} shareId={shareInfo.id} currentTime={currentTime} + onTyping={() => { + if (videoRef.current) { + videoRef.current.pause() + } + }} />
diff --git a/src/ui/routes/__root.tsx b/src/ui/routes/__root.tsx index 0c3700be..b22b2295 100644 --- a/src/ui/routes/__root.tsx +++ b/src/ui/routes/__root.tsx @@ -8,10 +8,10 @@ import { useAuthStore } from '@/ui/stores/auth' import { useTeamContextStore } from '@/ui/stores/team-context' import { useUploadStore } from '@/ui/stores/upload' import { - createRootRouteWithContext, - Outlet, - useNavigate, - useRouterState, + createRootRouteWithContext, + Outlet, + useNavigate, + useRouterState, } from '@tanstack/react-router' import { useEffect } from 'react' diff --git a/src/ui/routes/projects/$projectId/files/$fileId.tsx b/src/ui/routes/projects/$projectId/files/$fileId.tsx index 15eb70a6..d1243b7c 100644 --- a/src/ui/routes/projects/$projectId/files/$fileId.tsx +++ b/src/ui/routes/projects/$projectId/files/$fileId.tsx @@ -256,8 +256,8 @@ function FileViewPage() { onTimeUpdate={setCurrentTime} annotations={annotations} /> -
- {!isRightSidebarCollapsed && ( + + {!isRightSidebarCollapsed && ( <> { @@ -274,11 +274,15 @@ function FileViewPage() { members={members} onCommentSelect={handleCommentSelect} currentTime={currentTime} + onTyping={() => { + if (videoRef.current) { + videoRef.current.pause() + } + }} /> - )} - + )} ) From 5b685cd0d392a4ed56b6581d7e090468434e11c0 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 14:56:13 +0800 Subject: [PATCH 3/7] feat(comment): move timestamp badge to the beginning of the comment content area --- src/ui/components/chat/message-card.tsx | 78 ++++++++++--------- .../components/file-viewer-right-sidebar.tsx | 16 ++-- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/ui/components/chat/message-card.tsx b/src/ui/components/chat/message-card.tsx index fbe1b7dc..56c64178 100644 --- a/src/ui/components/chat/message-card.tsx +++ b/src/ui/components/chat/message-card.tsx @@ -3,17 +3,17 @@ import type { UserInfo } from '@/dtos/team' import { client } from '@/ui/api/client' import { Button } from '@/ui/components/ui/button' import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, } from '@/ui/components/ui/dialog' import { Separator } from '@/ui/components/ui/separator' -import { useQuery } from '@tanstack/react-query' -import { Download, File, Terminal, Clock } from 'lucide-react' -import React from 'react' import { formatTimeAgo } from '@/ui/lib/time' +import { useQuery } from '@tanstack/react-query' +import { Download, File, Terminal } from 'lucide-react' +import React from 'react' import Markdown from 'react-markdown' import { Avatar, AvatarFallback } from '../ui/avatar' import { Skeleton } from '../ui/skeleton' @@ -138,9 +138,11 @@ export const MessageCard: React.FC = ({ } return ( -
+
{hasReplies && !isReply && ( -
+
)} {isReply && !isLastReply && ( @@ -158,18 +160,6 @@ export const MessageCard: React.FC = ({
{creator?.name || 'Unknown'} - {message.second !== null && message.second !== undefined && frameRate && ( - - )} {new Date(message.createdAt!).toLocaleTimeString([], { hour: '2-digit', @@ -178,21 +168,35 @@ export const MessageCard: React.FC = ({
- {showSkeleton ? ( -
- - - {loadingText} -
- ) : message.sessionId ? ( -
- {preprocessMarkdown(message.message!)} -
- ) : ( -
- {renderFormattedMessage(message.message!)} -
- )} +
+ {message.second !== null && message.second !== undefined && frameRate && ( + + )} + + {showSkeleton ? ( +
+ + + {loadingText} +
+ ) : message.sessionId ? ( +
+ {preprocessMarkdown(message.message!)} +
+ ) : ( +
+ {renderFormattedMessage(message.message!)} +
+ )} +
{/* Attachments */} {message.attachments && message.attachments.length > 0 && ( diff --git a/src/ui/components/file-viewer-right-sidebar.tsx b/src/ui/components/file-viewer-right-sidebar.tsx index 4b85cb70..de7a20b3 100644 --- a/src/ui/components/file-viewer-right-sidebar.tsx +++ b/src/ui/components/file-viewer-right-sidebar.tsx @@ -1,19 +1,19 @@ -import { type FieldInfo as MetadataFieldInfo } from '@/dtos/metadata' -import { client } from '@/ui/api/client' import type { AssetInfo, AttachmentInfo, CommentInfo, FieldValueInfo } from '@/dtos/asset' +import { type FieldInfo as MetadataFieldInfo } from '@/dtos/metadata' import type { UserInfo } from '@/dtos/team' +import { client } from '@/ui/api/client' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/ui/components/ui/tabs' import { useFieldStore } from '@/ui/stores/fields' -import { useInfiniteQuery, useQueryClient, useQuery, useMutation } from '@tanstack/react-query' +import type { Annotation } from '@/ui/types' +import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { XIcon } from 'lucide-react' import React, { useEffect, useMemo, useState } from 'react' import { useInView } from 'react-intersection-observer' import { MessageCard } from './chat/message-card' import { ChatInput } from './chat/message-input' import FieldRenderer from './field-renderer' -import { ScrollArea } from './ui/scroll-area' -import type { Annotation } from '@/ui/types' import { GuestIdentityPopup } from './guest-identity-popup' +import { ScrollArea } from './ui/scroll-area' interface FileViewerRightSidebarProps { teamId: string @@ -338,9 +338,9 @@ export function FileViewerRightSidebar({ Fields - - -
+ + +
{comments.map((comment) => (
onCommentSelect?.(comment)}> Date: Wed, 27 May 2026 15:27:28 +0800 Subject: [PATCH 4/7] 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) + }} + /> +
))}
))} From 23ef83a0b55aa313457c6bdc5ab234ede658889c Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 15:49:18 +0800 Subject: [PATCH 5/7] feat(comment): unselect comment card when starting video playback --- src/ui/components/chat/message-card.tsx | 10 +++++----- src/ui/components/file-viewer-right-sidebar.tsx | 5 ++--- src/ui/components/public-share-manager.tsx | 4 ++++ src/ui/routes/projects/$projectId/files/$fileId.tsx | 4 ++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/ui/components/chat/message-card.tsx b/src/ui/components/chat/message-card.tsx index 22c89600..e60221ea 100644 --- a/src/ui/components/chat/message-card.tsx +++ b/src/ui/components/chat/message-card.tsx @@ -3,11 +3,11 @@ import type { UserInfo } from '@/dtos/team' import { client } from '@/ui/api/client' import { Button } from '@/ui/components/ui/button' import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, } from '@/ui/components/ui/dialog' import { Separator } from '@/ui/components/ui/separator' import { formatTimeAgo } from '@/ui/lib/time' diff --git a/src/ui/components/file-viewer-right-sidebar.tsx b/src/ui/components/file-viewer-right-sidebar.tsx index 157db8eb..bd9ec72f 100644 --- a/src/ui/components/file-viewer-right-sidebar.tsx +++ b/src/ui/components/file-viewer-right-sidebar.tsx @@ -29,6 +29,7 @@ interface FileViewerRightSidebarProps { shareId?: string currentTime?: number onTyping?: () => void + selectedCommentId?: string | null } export function FileViewerRightSidebar({ @@ -45,6 +46,7 @@ export function FileViewerRightSidebar({ shareId, currentTime, onTyping, + selectedCommentId, }: FileViewerRightSidebarProps) { const { fields, setFields } = useFieldStore() const queryClient = useQueryClient() @@ -52,7 +54,6 @@ 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[] @@ -354,7 +355,6 @@ export function FileViewerRightSidebar({ frameRate={file?.media?.metadata?.frameRate || 30} isSelected={selectedCommentId === comment.id} onSelect={() => { - setSelectedCommentId(comment.id!) onCommentSelect?.(comment) }} /> @@ -372,7 +372,6 @@ export function FileViewerRightSidebar({ frameRate={file?.media?.metadata?.frameRate || 30} isSelected={selectedCommentId === reply.id} onSelect={() => { - setSelectedCommentId(reply.id!) onCommentSelect?.(reply) }} /> diff --git a/src/ui/components/public-share-manager.tsx b/src/ui/components/public-share-manager.tsx index 31060194..31d95d8d 100644 --- a/src/ui/components/public-share-manager.tsx +++ b/src/ui/components/public-share-manager.tsx @@ -90,6 +90,7 @@ export function PublicShareManager({ const videoRef = useRef(null) const [annotations, setAnnotations] = useState([]) const [currentTime, setCurrentTime] = useState(0) + const [selectedCommentId, setSelectedCommentId] = useState(null) const { data: foldersData, @@ -255,6 +256,7 @@ export function PublicShareManager({ } const handleCommentSelect = (comment: CommentInfo) => { + setSelectedCommentId(comment.id || null) const newAnnotations = comment.annotations as Annotation[] if (newAnnotations && newAnnotations.length > 0) { setAnnotations(newAnnotations) @@ -276,6 +278,7 @@ export function PublicShareManager({ const handlePlay = () => { setAnnotations([]) + setSelectedCommentId(null) } const { setProjectState, clearProjectState } = useTopNavStore() @@ -446,6 +449,7 @@ export function PublicShareManager({ videoRef.current.pause() } }} + selectedCommentId={selectedCommentId} />
diff --git a/src/ui/routes/projects/$projectId/files/$fileId.tsx b/src/ui/routes/projects/$projectId/files/$fileId.tsx index d1243b7c..ea8997a9 100644 --- a/src/ui/routes/projects/$projectId/files/$fileId.tsx +++ b/src/ui/routes/projects/$projectId/files/$fileId.tsx @@ -35,6 +35,7 @@ function FileViewPage() { const [rightSidebarWidth, setRightSidebarWidth] = useState(360) const [annotations, setAnnotations] = useState([]) const [currentTime, setCurrentTime] = useState(0) + const [selectedCommentId, setSelectedCommentId] = useState(null) const $patchMetadata = client.api.files[':fileId'].metadata.$patch const { mutate: patchMetadata } = useMutation< InferResponseType, @@ -195,6 +196,7 @@ function FileViewPage() { } const handleCommentSelect = (comment: CommentInfo) => { + setSelectedCommentId(comment.id || null) const newAnnotations = comment.annotations as Annotation[] if (newAnnotations && newAnnotations.length > 0) { setAnnotations(newAnnotations) @@ -216,6 +218,7 @@ function FileViewPage() { const handlePlay = () => { setAnnotations([]) + setSelectedCommentId(null) } return ( @@ -279,6 +282,7 @@ function FileViewPage() { videoRef.current.pause() } }} + selectedCommentId={selectedCommentId} />
From 1a8712175ead81b67a2decebe9b2ecf47745e9ea Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 15:56:24 +0800 Subject: [PATCH 6/7] fix(comment): set leading-none on badge to ensure second line wraps cleanly without pushing --- src/ui/components/chat/message-card.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ui/components/chat/message-card.tsx b/src/ui/components/chat/message-card.tsx index e60221ea..52f57a44 100644 --- a/src/ui/components/chat/message-card.tsx +++ b/src/ui/components/chat/message-card.tsx @@ -3,16 +3,16 @@ import type { UserInfo } from '@/dtos/team' import { client } from '@/ui/api/client' import { Button } from '@/ui/components/ui/button' import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, } from '@/ui/components/ui/dialog' import { Separator } from '@/ui/components/ui/separator' import { formatTimeAgo } from '@/ui/lib/time' import { useQuery } from '@tanstack/react-query' -import { Clock, Download, File, Terminal } from 'lucide-react' +import { Download, File, Terminal } from 'lucide-react' import React from 'react' import Markdown from 'react-markdown' import { Avatar, AvatarFallback } from '../ui/avatar' @@ -177,8 +177,7 @@ export const MessageCard: React.FC = ({
{message.second !== null && message.second !== undefined && frameRate && ( -
- +
{formatTimestamp(message.second, frameRate)}
)} From 08b9c7ae0ee7a34870b8cfc1558ef11881548cf6 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 16:13:38 +0800 Subject: [PATCH 7/7] fix(comment): restrict timestamp capture toggle and badges to video files --- src/ui/components/chat/message-card.tsx | 10 ++++----- src/ui/components/chat/message-input.tsx | 20 +++++++++-------- .../components/file-viewer-right-sidebar.tsx | 22 ++++++++++++++----- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/ui/components/chat/message-card.tsx b/src/ui/components/chat/message-card.tsx index 52f57a44..ae5b6245 100644 --- a/src/ui/components/chat/message-card.tsx +++ b/src/ui/components/chat/message-card.tsx @@ -3,11 +3,11 @@ import type { UserInfo } from '@/dtos/team' import { client } from '@/ui/api/client' import { Button } from '@/ui/components/ui/button' import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, } from '@/ui/components/ui/dialog' import { Separator } from '@/ui/components/ui/separator' import { formatTimeAgo } from '@/ui/lib/time' diff --git a/src/ui/components/chat/message-input.tsx b/src/ui/components/chat/message-input.tsx index bca4babd..20fdc124 100644 --- a/src/ui/components/chat/message-input.tsx +++ b/src/ui/components/chat/message-input.tsx @@ -709,15 +709,17 @@ export const ChatInput = React.forwardRef( multiple onChange={handleFileSelect} /> - + {currentTime !== undefined && frameRate !== undefined && ( + + )}
)} - + Comments @@ -352,7 +352,11 @@ export function FileViewerRightSidebar({ onReply={setReplyingTo} onViewAttachment={setViewingAttachment} hasReplies={!!comment.replies?.length} - frameRate={file?.media?.metadata?.frameRate || 30} + frameRate={ + file?.mediaType?.startsWith('video/') + ? file?.media?.metadata?.frameRate || 30 + : undefined + } isSelected={selectedCommentId === comment.id} onSelect={() => { onCommentSelect?.(comment) @@ -369,7 +373,11 @@ export function FileViewerRightSidebar({ onViewAttachment={setViewingAttachment} hasReplies={false} isLastReply={index === (comment.replies?.length ?? 0) - 1} - frameRate={file?.media?.metadata?.frameRate || 30} + frameRate={ + file?.mediaType?.startsWith('video/') + ? file?.media?.metadata?.frameRate || 30 + : undefined + } isSelected={selectedCommentId === reply.id} onSelect={() => { onCommentSelect?.(reply) @@ -398,8 +406,12 @@ export function FileViewerRightSidebar({ bots={enabledBots} hideAnnotationControl={hideAnnotationControl} disableMentions={isPublic} - currentTime={currentTime} - frameRate={file?.media?.metadata?.frameRate || 30} + currentTime={file?.mediaType?.startsWith('video/') ? currentTime : undefined} + frameRate={ + file?.mediaType?.startsWith('video/') + ? file?.media?.metadata?.frameRate || 30 + : undefined + } onTyping={onTyping} />