diff --git a/js/src/features/compose/controls-indicator.tsx b/js/src/features/compose/controls-indicator.tsx index 42da631..f5a7605 100644 --- a/js/src/features/compose/controls-indicator.tsx +++ b/js/src/features/compose/controls-indicator.tsx @@ -2,17 +2,36 @@ import { Video, Mic } from "lucide-react"; import { cn } from "@/lib/utils"; import { useMediaSettingsStore } from "@/stores/media-settings-store"; import { Button } from "@/components/ui/button"; -import { PropsWithChildren } from "react"; -interface ControlsIndicatorProps extends PropsWithChildren { +interface ControlsIndicatorProps { type: "reply" | "new"; } -export default function ControlsIndicator({ type, children }: ControlsIndicatorProps) { +export default function ControlsIndicator({ type }: ControlsIndicatorProps) { const recordingMode = useMediaSettingsStore((s) => s.recordingMode); const setRecordingMode = useMediaSettingsStore((s) => s.setRecordingMode); return ( -
- {paragraphWords.map((word, i) => { +
+ {activeChunk.map((word, i) => { const isSpoken = activeWord !== null && word.start <= activeWord.end; diff --git a/js/src/hooks/use-transcript-playback.ts b/js/src/hooks/use-transcript-playback.ts index 33ae8fd..b047362 100644 --- a/js/src/hooks/use-transcript-playback.ts +++ b/js/src/hooks/use-transcript-playback.ts @@ -1,9 +1,11 @@ import { useMemo } from "react"; import type { Transcript } from "@/api/types"; +type Sentence = Transcript["paragraphs"][number]["sentences"][number]; + interface TranscriptPlaybackState { - /** The paragraph currently being spoken, or null if before/after speech */ - activeParagraph: Transcript["paragraphs"][number] | null; + /** The sentence currently being spoken, or null if between sentences */ + activeSentence: Sentence | null; /** Index of the active word within the transcript's flat words array */ activeWordIndex: number | null; } @@ -13,12 +15,19 @@ export function useTranscriptPlayback( currentTime: number, ): TranscriptPlaybackState { return useMemo(() => { - if (!transcript) return { activeParagraph: null, activeWordIndex: null }; + if (!transcript) return { activeSentence: null, activeWordIndex: null }; - const activeParagraph = - transcript.paragraphs.find( - (p) => currentTime >= p.start && currentTime <= p.end, - ) ?? null; + // Find the active sentence across all paragraphs + let activeSentence: Sentence | null = null; + for (const paragraph of transcript.paragraphs) { + const sentence = paragraph.sentences.find( + (s) => currentTime >= s.start && currentTime <= s.end, + ); + if (sentence) { + activeSentence = sentence; + break; + } + } // Binary search for active word const words = transcript.words; @@ -35,6 +44,6 @@ export function useTranscriptPlayback( } } - return { activeParagraph, activeWordIndex }; + return { activeSentence, activeWordIndex }; }, [transcript, currentTime]); }