From b5ecf53998c0663464afb203b43a0a15931b4bc8 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 27 May 2026 11:42:51 +0800 Subject: [PATCH] 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() + } + }} /> - )} - + )} )