From 7a82e17bbbdb28404cef662c698dc446f0a66c7a Mon Sep 17 00:00:00 2001 From: "santasri.pachhal" Date: Wed, 8 Jul 2026 17:24:20 +0530 Subject: [PATCH] feat(results): add live annotation overlay on raw video playback --- .../results/hooks/useVideoResults.ts | 21 +- .../(modules)/results/queries/videoKeys.ts | 4 + .../TicketClassDetectionPreview.tsx | 4 +- .../components/TicketInlineAnalysisVideo.tsx | 68 +++++ .../components/TicketOverviewCard.tsx | 39 ++- .../annotation/boundingBoxOverlay.tsx | 8 +- .../video/annotatedDetectionImage.tsx | 15 +- src/components/video/annotatedVideoPlayer.tsx | 11 +- .../video/useVideoAnnotationPlayback.ts | 242 ++++++++++++++++++ src/components/videoPlayerSection.tsx | 114 ++++++--- src/constants/apiRoutes.ts | 2 + src/services/api/video.service.ts | 19 +- src/types/detection.ts | 50 ++++ 13 files changed, 540 insertions(+), 57 deletions(-) create mode 100644 src/app/(modules)/ticket/[ticketId]/components/TicketInlineAnalysisVideo.tsx create mode 100644 src/components/video/useVideoAnnotationPlayback.ts diff --git a/src/app/(modules)/results/hooks/useVideoResults.ts b/src/app/(modules)/results/hooks/useVideoResults.ts index cbde463..7c74af9 100644 --- a/src/app/(modules)/results/hooks/useVideoResults.ts +++ b/src/app/(modules)/results/hooks/useVideoResults.ts @@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { videoService } from '@/services/api'; +import type { VideoAnnotationFramesParams } from '@/types'; import { videoKeys } from '../queries/videoKeys'; @@ -18,6 +19,20 @@ export function useVideoResultsQuery(videoId: string | undefined) { }); } +export function useVideoAnnotationFramesQuery( + videoId: string | undefined, + params: VideoAnnotationFramesParams, +) { + return useQuery({ + queryKey: videoKeys.annotationFrames(videoId ?? '', params), + queryFn: () => + videoService.getVideoAnnotationFrames(videoId as string, params), + enabled: Boolean(videoId), + staleTime: 1000 * 60 * 5, + gcTime: 1000 * 60 * 30, + }); +} + /** * Download the annotated video through the authenticated axios client and * expose a local object URL that the native `