The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Synchronize call recording transcripts with video playback (#24519)
nitine13dac6cf293
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptBody.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptBody.tsxindex 6f4709a7eb1..3994fe452a9 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptBody.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptBody.tsx@@ -3,15 +3,17 @@ import { CallRecordingWidgetForbiddenDisplay } from '@/page-layout/widgets/calenimport { type CalendarEventCallRecordingCandidate } from '@/page-layout/widgets/calendar-event-call-recording/types/CalendarEventCallRecordingCandidate';import { CallRecordingTranscriptContent } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptContent';import { CallRecordingVideoPlayer } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingVideoPlayer';+import { CallRecordingTranscriptPlaybackEffect } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptPlaybackEffect';+import { INITIAL_CALL_RECORDING_TRANSCRIPT_PLAYBACK_POSITION } from '@/page-layout/widgets/call-recording-transcript/constants/InitialCallRecordingTranscriptPlaybackPosition';import { PageLayoutWidgetErrorDisplay } from '@/page-layout/widgets/components/PageLayoutWidgetErrorDisplay';import { WidgetSkeletonLoader } from '@/page-layout/widgets/components/WidgetSkeletonLoader';import { useCurrentWidget } from '@/page-layout/widgets/hooks/useCurrentWidget';import { type WidgetAccessDenialInfo } from '@/page-layout/widgets/types/WidgetAccessDenialInfo';import { styled } from '@linaria/react';import { t } from '@lingui/core/macro';+import { useState } from 'react';import { type CallRecordingParsedTranscriptEntry } from 'twenty-shared/types';import { isDefined } from 'twenty-shared/utils';-import { themeCssVariables } from 'twenty-ui/theme-constants';const StyledRecordingLayout = styled.div`display: grid;@@ -20,15 +22,6 @@ const StyledRecordingLayout = styled.div`min-height: 0;`;-const StyledPlayerSection = styled.div`- padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[6]} 0;-`;--const StyledTranscriptScrollContainer = styled.div`- min-height: 0;- overflow-y: auto;-`;-type CallRecordingTranscriptBodyProps = {callRecording: CalendarEventCallRecordingCandidate | undefined;transcriptEntries: CallRecordingParsedTranscriptEntry[] | undefined;@@ -49,6 +42,13 @@ export const CallRecordingTranscriptBody = ({refetchCallRecording,}: CallRecordingTranscriptBodyProps) => {const widget = useCurrentWidget();+ const [videoElement, setVideoElement] = useState<HTMLVideoElement | null>(+ null,+ );++ const [entryPlaybackPosition, setEntryPlaybackPosition] = useState(+ INITIAL_CALL_RECORDING_TRANSCRIPT_PLAYBACK_POSITION,+ );if (isDefined(restriction)) {return <CallRecordingWidgetForbiddenDisplay restriction={restriction} />;@@ -81,21 +81,34 @@ export const CallRecordingTranscriptBody = ({);}+ const playback = isDefined(videoElement)+ ? {+ position: entryPlaybackPosition,+ videoElement,+ onSeek: (startSeconds: number) => {+ videoElement.currentTime = startSeconds;+ },+ }+ : undefined;+return (<StyledRecordingLayout>- <StyledPlayerSection>- <CallRecordingVideoPlayer- key={videoFileUrl}- src={videoFileUrl}- onRetry={refetchCallRecording}- />- </StyledPlayerSection>- <StyledTranscriptScrollContainer>- <CallRecordingTranscriptContent- callRecording={callRecording}- transcriptEntries={transcriptEntries}- />- </StyledTranscriptScrollContainer>+ <CallRecordingTranscriptPlaybackEffect+ videoElement={videoElement}+ timedItems={transcriptEntries}+ onPlaybackPositionChange={setEntryPlaybackPosition}+ />+ <CallRecordingVideoPlayer+ key={videoFileUrl}+ ref={setVideoElement}+ src={videoFileUrl}+ onRetry={refetchCallRecording}+ />+ <CallRecordingTranscriptContent+ callRecording={callRecording}+ transcriptEntries={transcriptEntries}+ playback={playback}+ /></StyledRecordingLayout>);};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptContent.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptContent.tsxindex 4dca8791782..4d11ccce6be 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptContent.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptContent.tsx@@ -3,48 +3,68 @@ import { type CalendarEventCallRecordingCandidate } from '@/page-layout/widgets/import { isCallRecordingTranscriptFailed } from '@/page-layout/widgets/calendar-event-call-recording/utils/isCallRecordingTranscriptFailed';import { isCallRecordingTranscriptPending } from '@/page-layout/widgets/calendar-event-call-recording/utils/isCallRecordingTranscriptPending';import { CallRecordingTranscriptEntryList } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryList';+import { type CallRecordingTranscriptPlayback } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlayback';+import { styled } from '@linaria/react';import { t } from '@lingui/core/macro';import { type CallRecordingParsedTranscriptEntry } from 'twenty-shared/types';import { isNonEmptyArray } from 'twenty-shared/utils';+const StyledEmptyStateScrollContainer = styled.div`+ min-height: 0;+ overflow-y: auto;+`;+type CallRecordingTranscriptContentProps = {callRecording: CalendarEventCallRecordingCandidate;transcriptEntries: CallRecordingParsedTranscriptEntry[] | undefined;+ playback?: CallRecordingTranscriptPlayback;};export const CallRecordingTranscriptContent = ({callRecording,transcriptEntries,+ playback,}: CallRecordingTranscriptContentProps) => {if (isNonEmptyArray(transcriptEntries)) {- return <CallRecordingTranscriptEntryList entries={transcriptEntries} />;+ return (+ <CallRecordingTranscriptEntryList+ entries={transcriptEntries}+ playback={playback}+ />+ );}if (isCallRecordingTranscriptPending(callRecording)) {return (- <CallRecordingWidgetEmptyStateDisplay- animatedPlaceholderType="loadingMessages"- title={t`Preparing Transcript`}- subTitle={t`Transcript is being prepared…`}- />+ <StyledEmptyStateScrollContainer>+ <CallRecordingWidgetEmptyStateDisplay+ animatedPlaceholderType="loadingMessages"+ title={t`Preparing Transcript`}+ subTitle={t`Transcript is being prepared…`}+ />+ </StyledEmptyStateScrollContainer>);}if (isCallRecordingTranscriptFailed(callRecording)) {return (- <CallRecordingWidgetEmptyStateDisplay- animatedPlaceholderType="errorIndex"- title={t`Transcript Failed`}- subTitle={t`The transcript could not be generated.`}- />+ <StyledEmptyStateScrollContainer>+ <CallRecordingWidgetEmptyStateDisplay+ animatedPlaceholderType="errorIndex"+ title={t`Transcript Failed`}+ subTitle={t`The transcript could not be generated.`}+ />+ </StyledEmptyStateScrollContainer>);}return (- <CallRecordingWidgetEmptyStateDisplay- animatedPlaceholderType="noMatchRecord"- title={t`No Transcript`}- subTitle={t`No transcript is available for this recording.`}- />+ <StyledEmptyStateScrollContainer>+ <CallRecordingWidgetEmptyStateDisplay+ animatedPlaceholderType="noMatchRecord"+ title={t`No Transcript`}+ subTitle={t`No transcript is available for this recording.`}+ />+ </StyledEmptyStateScrollContainer>);};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryList.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryList.tsxindex 2e8f5107e14..e76816d4bb6 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryList.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryList.tsx@@ -1,27 +1,157 @@import { CallRecordingTranscriptEntryListItem } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem';+import { CallRecordingTranscriptFollowScrollEffect } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptFollowScrollEffect';+import { type CallRecordingTranscriptPlayback } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlayback';+import { getCallRecordingTranscriptEntryPlaybackPhase } from '@/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptEntryPlaybackPhase';import { styled } from '@linaria/react';-import { themeCssVariables } from 'twenty-ui/theme-constants';+import { t } from '@lingui/core/macro';+import {+ useCallback,+ useRef,+ useState,+ type KeyboardEvent,+ type PointerEvent,+} from 'react';import { type CallRecordingParsedTranscriptEntry } from 'twenty-shared/types';+import { isDefined } from 'twenty-shared/utils';+import { Button } from 'twenty-ui/input';+import { themeCssVariables } from 'twenty-ui/theme-constants';-const StyledEntryList = styled.ul`+const StyledTranscriptContainer = styled.div`+ height: 100%;+ min-height: 0;+ position: relative;+`;++const StyledTranscriptScrollContainer = styled.div`+ height: 100%;+ min-height: 0;+ overflow-y: auto;+`;++const StyledEntryList = styled.ul<{ hasPlaybackControls: boolean }>`display: flex;flex-direction: column;gap: ${themeCssVariables.spacing[6]};list-style: none;margin: 0;- padding: ${themeCssVariables.spacing[6]};+ padding: ${({ hasPlaybackControls }) =>+ hasPlaybackControls+ ? `${themeCssVariables.spacing[4]} 0 ${themeCssVariables.spacing[10]}`+ : '0'};+`;++const StyledResumeFollowButton = styled.div`+ bottom: ${themeCssVariables.spacing[3]};+ left: 50%;+ position: absolute;+ transform: translateX(-50%);`;+const MANUAL_SCROLL_KEYS = [+ 'ArrowDown',+ 'ArrowUp',+ 'End',+ 'Home',+ 'PageDown',+ 'PageUp',+ ' ',+];+type CallRecordingTranscriptEntryListProps = {entries: CallRecordingParsedTranscriptEntry[];+ playback?: CallRecordingTranscriptPlayback;};export const CallRecordingTranscriptEntryList = ({entries,-}: CallRecordingTranscriptEntryListProps) => (- <StyledEntryList>- {entries.map((entry, entryIndex) => (- <CallRecordingTranscriptEntryListItem key={entryIndex} entry={entry} />- ))}- </StyledEntryList>-);+ playback,+}: CallRecordingTranscriptEntryListProps) => {+ const scrollContainerElementRef = useRef<HTMLDivElement>(null);+ const activeEntryElementRef = useRef<HTMLLIElement>(null);+ const [isFollowingPlayback, setIsFollowingPlayback] = useState(true);++ const resumeFollowingPlayback = useCallback(() => {+ setIsFollowingPlayback(true);+ }, []);++ const selectTranscriptEntry = (entryStartSeconds: number) => {+ resumeFollowingPlayback();+ playback?.onSeek(entryStartSeconds);+ };++ const stopFollowingPlayback = () => {+ setIsFollowingPlayback(false);+ };++ const handleScrollContainerPointerDown = (+ event: PointerEvent<HTMLDivElement>,+ ) => {+ if (event.target === event.currentTarget) {+ stopFollowingPlayback();+ }+ };++ const handleScrollContainerKeyDown = (+ event: KeyboardEvent<HTMLDivElement>,+ ) => {+ if (MANUAL_SCROLL_KEYS.includes(event.key)) {+ stopFollowingPlayback();+ }+ };++ const hasPlayback = isDefined(playback);++ return (+ <StyledTranscriptContainer>+ <CallRecordingTranscriptFollowScrollEffect+ activeEntryElementRef={activeEntryElementRef}+ isFollowingPlayback={isFollowingPlayback}+ scrollContainerElementRef={scrollContainerElementRef}+ videoElement={playback?.videoElement}+ onVideoSeeking={resumeFollowingPlayback}+ />+ <StyledTranscriptScrollContainer+ ref={scrollContainerElementRef}+ aria-label={t`Transcript`}+ role="region"+ tabIndex={0}+ onKeyDown={handleScrollContainerKeyDown}+ onPointerDown={handleScrollContainerPointerDown}+ onTouchMove={stopFollowingPlayback}+ onWheel={stopFollowingPlayback}+ >+ <StyledEntryList hasPlaybackControls={hasPlayback}>+ {entries.map((entry, entryIndex) => {+ const playbackPhase = getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex,+ playbackPosition: playback?.position,+ });+ const isActive = playbackPhase === 'speaking';++ return (+ <CallRecordingTranscriptEntryListItem+ key={entryIndex}+ entry={entry}+ entryElementRef={isActive ? activeEntryElementRef : undefined}+ playbackPhase={playbackPhase}+ videoElement={playback?.videoElement}+ onSelect={hasPlayback ? selectTranscriptEntry : undefined}+ />+ );+ })}+ </StyledEntryList>+ </StyledTranscriptScrollContainer>+ {hasPlayback && !isFollowingPlayback && (+ <StyledResumeFollowButton>+ <Button+ ariaLabel={t`Jump to current`}+ size="small"+ title={t`Jump to current`}+ variant="secondary"+ onClick={resumeFollowingPlayback}+ />+ </StyledResumeFollowButton>+ )}+ </StyledTranscriptContainer>+ );+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsxindex f94e422c786..4fb4c489bc9 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx@@ -1,15 +1,37 @@+import { CallRecordingTranscriptEntryWords } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryWords';+import { type CallRecordingTranscriptEntryPlaybackPhase } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptEntryPlaybackPhase';import { formatCallRecordingTranscriptTimestamp } from '@/page-layout/widgets/call-recording-transcript/utils/formatCallRecordingTranscriptTimestamp';import { styled } from '@linaria/react';import { t } from '@lingui/core/macro';+import { type Ref } from 'react';+import { type CallRecordingParsedTranscriptEntry } from 'twenty-shared/types';+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';import { Avatar, Chip, ChipVariant } from 'twenty-ui/data-display';import { themeCssVariables } from 'twenty-ui/theme-constants';-import { type CallRecordingParsedTranscriptEntry } from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';-const StyledEntry = styled.li`+const StyledEntry = styled.li<{+ hasPlaybackControls: boolean;+ isActive: boolean;+ isSelectable: boolean;+}>`+ background: ${({ isActive }) =>+ isActive ? themeCssVariables.background.transparent.blue : 'transparent'};+ border-radius: ${themeCssVariables.border.radius.sm};+ cursor: ${({ isSelectable }) => (isSelectable ? 'pointer' : 'default')};display: flex;flex-direction: column;gap: ${themeCssVariables.spacing[2]};+ padding: ${({ hasPlaybackControls }) =>+ hasPlaybackControls ? themeCssVariables.spacing[2] : 0};++ &:hover {+ background: ${({ isActive, isSelectable }) =>+ isActive+ ? themeCssVariables.background.transparent.blue+ : isSelectable+ ? themeCssVariables.background.transparent.lighter+ : 'transparent'};+ }`;const StyledEntryHeader = styled.div`@@ -20,31 +42,87 @@ const StyledEntryHeader = styled.div``;const StyledTimestamp = styled.span`+ background: transparent;+ border: 0;+ border-radius: ${themeCssVariables.border.radius.sm};color: ${themeCssVariables.font.color.tertiary};+ font-family: inherit;font-size: ${themeCssVariables.font.size.xs};font-variant-numeric: tabular-nums;+ padding: 0;++ &:is(button) {+ cursor: pointer;+ }++ &:focus-visible {+ outline: 2px solid ${themeCssVariables.border.color.blue};+ outline-offset: 2px;+ }`;-const StyledText = styled.p`- color: ${themeCssVariables.font.color.primary};+const StyledText = styled.p<{ isUpcoming: boolean }>`+ color: ${({ isUpcoming }) =>+ isUpcoming+ ? themeCssVariables.font.color.secondary+ : themeCssVariables.font.color.primary};font-size: ${themeCssVariables.font.size.md};line-height: ${themeCssVariables.text.lineHeight.lg};margin: 0;overflow-wrap: break-word;+ transition: color calc(${themeCssVariables.animation.duration.fast} * 1s) ease;white-space: pre-wrap;`;type CallRecordingTranscriptEntryListItemProps = {entry: CallRecordingParsedTranscriptEntry;+ playbackPhase?: CallRecordingTranscriptEntryPlaybackPhase;+ videoElement?: HTMLVideoElement;+ entryElementRef?: Ref<HTMLLIElement>;+ onSelect?: (entryStartSeconds: number) => void;};export const CallRecordingTranscriptEntryListItem = ({entry,+ playbackPhase,+ videoElement,+ entryElementRef,+ onSelect,}: CallRecordingTranscriptEntryListItemProps) => {const speakerName = entry.speakerName ?? t`Unknown speaker`;+ const entryStartSeconds = entry.startSeconds;+ const isSelectable = isDefined(entryStartSeconds) && isDefined(onSelect);+ const isActive = playbackPhase === 'speaking';+ const hasPlaybackControls = isDefined(playbackPhase) || isDefined(onSelect);+ const hasSpokenWordHighlight =+ isActive && isDefined(videoElement) && isNonEmptyArray(entry.words);+ const formattedStartTimestamp = isDefined(entryStartSeconds)+ ? formatCallRecordingTranscriptTimestamp(entryStartSeconds)+ : undefined;++ const handleEntryClick = () => {+ if (!isDefined(entryStartSeconds) || !isDefined(onSelect)) {+ return;+ }++ // A click that ends a text selection must not seek away from it.+ const selection = window.getSelection();+ if (isDefined(selection) && !selection.isCollapsed) {+ return;+ }++ onSelect(entryStartSeconds);+ };return (- <StyledEntry>+ <StyledEntry+ ref={entryElementRef}+ aria-current={isActive ? 'true' : undefined}+ hasPlaybackControls={hasPlaybackControls}+ isActive={isActive}+ isSelectable={isSelectable}+ onClick={isSelectable ? handleEntryClick : undefined}+ ><StyledEntryHeader><Chipclickable={false}@@ -59,13 +137,29 @@ export const CallRecordingTranscriptEntryListItem = ({/>}/>- {isDefined(entry.startSeconds) && (- <StyledTimestamp>- {formatCallRecordingTranscriptTimestamp(entry.startSeconds)}+ {isDefined(formattedStartTimestamp) && (+ <StyledTimestamp+ as={isSelectable ? 'button' : undefined}+ aria-label={+ isSelectable+ ? t`Seek recording to ${formattedStartTimestamp}`+ : undefined+ }+ >+ {formattedStartTimestamp}</StyledTimestamp>)}</StyledEntryHeader>- <StyledText>{entry.text}</StyledText>+ <StyledText isUpcoming={playbackPhase === 'upcoming'}>+ {hasSpokenWordHighlight ? (+ <CallRecordingTranscriptEntryWords+ words={entry.words}+ videoElement={videoElement}+ />+ ) : (+ entry.text+ )}+ </StyledText></StyledEntry>);};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryWords.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryWords.tsxnew file mode 100644index 00000000000..607cafa1402--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryWords.tsx@@ -0,0 +1,52 @@+import { CallRecordingTranscriptPlaybackEffect } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptPlaybackEffect';+import { CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE } from '@/page-layout/widgets/call-recording-transcript/constants/CallRecordingTranscriptCurrentSpokenWordDataAttribute';+import { INITIAL_CALL_RECORDING_TRANSCRIPT_PLAYBACK_POSITION } from '@/page-layout/widgets/call-recording-transcript/constants/InitialCallRecordingTranscriptPlaybackPosition';+import { styled } from '@linaria/react';+import { useState } from 'react';+import { type CallRecordingParsedTranscriptWord } from 'twenty-shared/types';+import { themeCssVariables } from 'twenty-ui/theme-constants';++const StyledWord = styled.span<{ isSpoken: boolean }>`+ color: ${({ isSpoken }) =>+ isSpoken+ ? themeCssVariables.font.color.primary+ : themeCssVariables.font.color.secondary};+ transition: color calc(${themeCssVariables.animation.duration.fast} * 1s) ease;+`;++type CallRecordingTranscriptEntryWordsProps = {+ words: CallRecordingParsedTranscriptWord[];+ videoElement: HTMLVideoElement;+};++export const CallRecordingTranscriptEntryWords = ({+ words,+ videoElement,+}: CallRecordingTranscriptEntryWordsProps) => {+ const [wordPlaybackPosition, setWordPlaybackPosition] = useState(+ INITIAL_CALL_RECORDING_TRANSCRIPT_PLAYBACK_POSITION,+ );++ return (+ <>+ <CallRecordingTranscriptPlaybackEffect+ videoElement={videoElement}+ timedItems={words}+ onPlaybackPositionChange={setWordPlaybackPosition}+ />+ {words.map((word, wordIndex) => (+ <StyledWord+ key={wordIndex}+ {...{+ [CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE]:+ wordIndex === wordPlaybackPosition.activeIndex || undefined,+ }}+ isSpoken={wordIndex <= wordPlaybackPosition.lastStartedIndex}+ >+ {wordIndex > 0 ? ' ' : ''}+ {word.text}+ </StyledWord>+ ))}+ </>+ );+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptFollowScrollEffect.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptFollowScrollEffect.tsxnew file mode 100644index 00000000000..8393b9d28fd--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptFollowScrollEffect.tsx@@ -0,0 +1,51 @@+import { watchCallRecordingTranscriptFollowScroll } from '@/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptFollowScroll';+import { useEffect, type RefObject } from 'react';+import { isDefined } from 'twenty-shared/utils';++type CallRecordingTranscriptFollowScrollEffectProps = {+ activeEntryElementRef: RefObject<HTMLLIElement | null>;+ isFollowingPlayback: boolean;+ scrollContainerElementRef: RefObject<HTMLDivElement | null>;+ videoElement?: HTMLVideoElement;+ onVideoSeeking: () => void;+};++export const CallRecordingTranscriptFollowScrollEffect = ({+ activeEntryElementRef,+ isFollowingPlayback,+ scrollContainerElementRef,+ videoElement,+ onVideoSeeking,+}: CallRecordingTranscriptFollowScrollEffectProps) => {+ useEffect(() => {+ const scrollContainerElement = scrollContainerElementRef.current;++ if (!isDefined(videoElement)) {+ return;+ }++ videoElement.addEventListener('seeking', onVideoSeeking);++ const stopWatchingFollowScroll =+ isFollowingPlayback && isDefined(scrollContainerElement)+ ? watchCallRecordingTranscriptFollowScroll({+ videoElement,+ scrollContainerElement,+ getActiveEntryElement: () => activeEntryElementRef.current,+ })+ : undefined;++ return () => {+ videoElement.removeEventListener('seeking', onVideoSeeking);+ stopWatchingFollowScroll?.();+ };+ }, [+ activeEntryElementRef,+ isFollowingPlayback,+ onVideoSeeking,+ scrollContainerElementRef,+ videoElement,+ ]);++ return null;+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptPlaybackEffect.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptPlaybackEffect.tsxnew file mode 100644index 00000000000..1b4da736184--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptPlaybackEffect.tsx@@ -0,0 +1,42 @@+import { type CallRecordingTranscriptPlaybackPosition } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition';+import { type CallRecordingTranscriptTimedItem } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimedItem';+import { buildCallRecordingTranscriptTimePoints } from '@/page-layout/widgets/call-recording-transcript/utils/buildCallRecordingTranscriptTimePoints';+import { watchCallRecordingTranscriptPlayback } from '@/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptPlayback';+import { useEffect, useMemo } from 'react';+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';++type CallRecordingTranscriptPlaybackEffectProps = {+ videoElement: HTMLVideoElement | null;+ timedItems: CallRecordingTranscriptTimedItem[] | undefined;+ onPlaybackPositionChange: (+ playbackPosition: CallRecordingTranscriptPlaybackPosition,+ ) => void;+};++export const CallRecordingTranscriptPlaybackEffect = ({+ videoElement,+ timedItems,+ onPlaybackPositionChange,+}: CallRecordingTranscriptPlaybackEffectProps) => {+ const timePoints = useMemo(+ () =>+ isDefined(timedItems)+ ? buildCallRecordingTranscriptTimePoints(timedItems)+ : [],+ [timedItems],+ );++ useEffect(() => {+ if (!isDefined(videoElement) || !isNonEmptyArray(timePoints)) {+ return;+ }++ return watchCallRecordingTranscriptPlayback({+ videoElement,+ timePoints,+ onPlaybackPositionChange,+ });+ }, [videoElement, timePoints, onPlaybackPositionChange]);++ return null;+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingVideoPlayer.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingVideoPlayer.tsxindex 15617d4ee83..47a7ca51c0b 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingVideoPlayer.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingVideoPlayer.tsx@@ -1,6 +1,6 @@import { styled } from '@linaria/react';import { t } from '@lingui/core/macro';-import { useState } from 'react';+import { useState, type Ref } from 'react';import { CircularProgressBar } from 'twenty-ui/feedback';import { Button } from 'twenty-ui/input';import { themeCssVariables } from 'twenty-ui/theme-constants';@@ -80,11 +80,13 @@ const StyledPlaybackErrorDescription = styled.span``;type CallRecordingVideoPlayerProps = {+ ref?: Ref<HTMLVideoElement>;src: string;onRetry: () => Promise<unknown>;};export const CallRecordingVideoPlayer = ({+ ref,src,onRetry,}: CallRecordingVideoPlayerProps) => {@@ -146,6 +148,7 @@ export const CallRecordingVideoPlayer = ({return (<StyledVideoViewport><StyledVideo+ ref={ref}isFirstFrameReady={loadState === 'ready'}controlsplaysInlinediff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptBody.stories.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptBody.stories.tsxindex f8b58b1e96d..11b37c95cdc 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptBody.stories.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptBody.stories.tsx@@ -6,11 +6,19 @@ import { type CalendarEventCallRecordingCandidate } from '@/page-layout/widgets/import { getCallRecordingVideoFileUrl } from '@/page-layout/widgets/calendar-event-call-recording/utils/getCallRecordingVideoFileUrl';import { CallRecordingTranscriptBody } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptBody';import { CallRecordingTranscriptHeaderDataEffect } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptHeaderDataEffect';+import { CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE } from '@/page-layout/widgets/call-recording-transcript/constants/CallRecordingTranscriptCurrentSpokenWordDataAttribute';import { WidgetHeaderCountEffect } from '@/page-layout/widgets/components/WidgetHeaderCountEffect';import { type Meta, type StoryObj } from '@storybook/react-vite';-import { delay, http } from 'msw';import { useState, type ComponentProps } from 'react';-import { expect, fn, spyOn, userEvent, waitFor, within } from 'storybook/test';+import {+ expect,+ fireEvent,+ fn,+ spyOn,+ userEvent,+ waitFor,+ within,+} from 'storybook/test';import {isDefined,parseCallRecordingTranscriptEntries,@@ -24,10 +32,11 @@ import {import { CallRecordingStatus } from '~/generated/graphql';import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';+import { MOCK_CALL_RECORDING_VIDEO_DATA_URI } from './mockCallRecordingVideo';const TRANSCRIPT_WIDGET_ID = 'transcript-widget';const CALL_RECORDING_TAB_ID = 'call-recording-tab';-const VIDEO_URL = '/storybook/call-recording.mp4';+const VIDEO_URL = MOCK_CALL_RECORDING_VIDEO_DATA_URI;const transcriptWidget: PageLayoutWidget = {__typename: 'PageLayoutWidget',@@ -108,31 +117,116 @@ const failedCallRecording: CalendarEventCallRecordingCandidate = {transcript: null,};-const rawTranscript = [- {- participant: { name: 'Ada Lovelace' },- words: [- {- text: 'Thanks for joining, let us walk through the quarterly numbers.',- start_timestamp: { relative: 12 },- end_timestamp: { relative: 21 },+const makeMockTranscriptEntry = ({+ speakerName,+ text,+ startSeconds,+ endSeconds,+}: {+ speakerName: string;+ text: string;+ startSeconds: number;+ endSeconds: number;+}) => {+ const wordTexts = text.split(' ');+ const wordDurationSeconds = (endSeconds - startSeconds) / wordTexts.length;++ return {+ participant: { name: speakerName },+ words: wordTexts.map((wordText, wordIndex) => ({+ text: wordText,+ start_timestamp: {+ relative: startSeconds + wordIndex * wordDurationSeconds,},- ],- },- {- participant: { name: 'Grace Hopper' },- words: [- {- text: 'Happy to. Pipeline grew twenty percent since the last call.',- start_timestamp: { relative: 24 },- end_timestamp: { relative: 40 },+ end_timestamp: {+ relative: startSeconds + (wordIndex + 1) * wordDurationSeconds,},- ],- },- {- participant: {},- words: [{ text: 'Inaudible segment.' }],- },+ })),+ };+};++const setVideoCurrentTime = ({+ videoElement,+ currentTimeSeconds,+}: {+ videoElement: HTMLVideoElement;+ currentTimeSeconds: number;+}) => {+ videoElement.currentTime = currentTimeSeconds;+ fireEvent.timeUpdate(videoElement);+};++// Seeking before metadata is loaded would be reverted by the player's+// first-frame fragment seek once metadata arrives.+const waitForVideoMetadata = async (videoElement: HTMLVideoElement) => {+ await waitFor(() =>+ expect(videoElement.readyState).toBeGreaterThanOrEqual(+ HTMLMediaElement.HAVE_METADATA,+ ),+ );+};++const rawTranscript = [+ makeMockTranscriptEntry({+ speakerName: 'Ada Lovelace',+ text: "Welcome everyone, let's start with a quick project update.",+ startSeconds: 1,+ endSeconds: 5,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Grace Hopper',+ text: 'The first milestone is complete and ready for review.',+ startSeconds: 6,+ endSeconds: 10,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Alan Turing',+ text: 'I tested the playback controls across several browsers.',+ startSeconds: 11,+ endSeconds: 15,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Ada Lovelace',+ text: 'Great, did seeking keep the transcript synchronized?',+ startSeconds: 16,+ endSeconds: 20,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Alan Turing',+ text: 'Yes, the active entry followed every position change.',+ startSeconds: 21,+ endSeconds: 25,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Grace Hopper',+ text: 'Word highlighting stayed smooth during normal playback.',+ startSeconds: 26,+ endSeconds: 30,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Ada Lovelace',+ text: 'How does the player behave after a loading error?',+ startSeconds: 31,+ endSeconds: 35,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Grace Hopper',+ text: 'Retrying refreshes the recording and restores the player.',+ startSeconds: 36,+ endSeconds: 40,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Alan Turing',+ text: 'The header actions are available for every recording.',+ startSeconds: 41,+ endSeconds: 45,+ }),+ makeMockTranscriptEntry({+ speakerName: 'Ada Lovelace',+ text: "Perfect, let's gather final feedback and wrap up.",+ startSeconds: 46,+ endSeconds: 51,+ }),];const readableCallRecording: CalendarEventCallRecordingCandidate = {@@ -145,8 +239,8 @@ const recordedCallRecording: CalendarEventCallRecordingCandidate = {video: [{fileId: 'video-file-id',- label: 'recording.mp4',- extension: 'mp4',+ label: 'recording.webm',+ extension: 'webm',url: VIDEO_URL,},],@@ -240,7 +334,6 @@ const meta: Meta<typeof CallRecordingTranscriptBodyStory> = {],parameters: {layout: 'centered',- msw: { handlers: [http.get(VIDEO_URL, () => delay('infinite'))] },},render: CallRecordingTranscriptBodyStory,args: {@@ -261,11 +354,18 @@ export const Ready: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);- await canvas.findByText('Ada Lovelace');- await canvas.findByText(- 'Happy to. Pipeline grew twenty percent since the last call.',- );- await canvas.findByText('Inaudible segment.');+ expect(await canvas.findAllByText('Ada Lovelace')).toHaveLength(4);+ expect(await canvas.findAllByText('Alan Turing')).toHaveLength(3);++ const transcriptRegion = canvas.getByRole('region', {+ name: 'Transcript',+ });++ fireEvent.wheel(transcriptRegion);++ expect(+ canvas.queryByRole('button', { name: 'Jump to current' }),+ ).not.toBeInTheDocument();},};@@ -278,9 +378,21 @@ export const WithVideo: Story = {},play: async ({ canvasElement }) => {const canvas = within(canvasElement);+ const transcriptRegion = await canvas.findByRole('region', {+ name: 'Transcript',+ });+ const videoElement = canvasElement.querySelector('video');++ if (!isDefined(videoElement)) {+ throw new Error('Video player was not rendered');+ }++ expect(transcriptRegion).toBeVisible();+ expect(videoElement.currentTime).toBeLessThan(1);+ expect(+ canvasElement.querySelector('[aria-current="true"]'),+ ).not.toBeInTheDocument();- expect(await canvas.findByText('Transcript')).toBeVisible();- expect(canvasElement.querySelector('video')).not.toBeNull();const copyTranscriptButton = await canvas.findByRole('button', {name: 'Copy transcript',});@@ -295,7 +407,9 @@ export const WithVideo: Story = {await userEvent.click(copyTranscriptButton);expect(writeText).toHaveBeenLastCalledWith(- 'Ada Lovelace (0:12)\nThanks for joining, let us walk through the quarterly numbers.\n\nGrace Hopper (0:24)\nHappy to. Pipeline grew twenty percent since the last call.\n\nUnknown speaker\nInaudible segment.',+ expect.stringContaining(+ "Ada Lovelace (0:01)\nWelcome everyone, let's start with a quick project update.",+ ),);await userEvent.click(copyVideoLinkButton);@@ -312,6 +426,24 @@ export const WithVideo: Story = {'href',expect.stringContaining('calendar-event-id'),);++ await waitForVideoMetadata(videoElement);++ setVideoCurrentTime({ videoElement, currentTimeSeconds: 1.5 });++ await waitFor(() =>+ expect(+ canvasElement.querySelector('[aria-current="true"]'),+ ).toHaveTextContent("Welcome everyone, let's start"),+ );++ setVideoCurrentTime({ videoElement, currentTimeSeconds: 5.5 });++ await waitFor(() =>+ expect(+ canvasElement.querySelector('[aria-current="true"]'),+ ).not.toBeInTheDocument(),+ );},};@@ -341,6 +473,95 @@ export const PlaybackError: Story = {},};+export const WithVideoInteractions: Story = {+ tags: ['!dev', '!autodocs'],+ args: {+ callRecording: recordedCallRecording,+ loading: false,+ error: undefined,+ restriction: undefined,+ },+ play: async ({ canvasElement, userEvent }) => {+ const canvas = within(canvasElement);++ expect(await canvas.findAllByText('Ada Lovelace')).toHaveLength(4);++ const transcriptRegion = await canvas.findByRole('region', {+ name: 'Transcript',+ });+ const videoElement = canvasElement.querySelector('video');++ if (!isDefined(videoElement)) {+ throw new Error('Video player was not rendered');+ }++ await waitForVideoMetadata(videoElement);++ setVideoCurrentTime({ videoElement, currentTimeSeconds: 48 });++ await waitFor(() => {+ const activeEntry = canvasElement.querySelector('[aria-current="true"]');++ expect(activeEntry).toHaveTextContent(+ "Perfect, let's gather final feedback and wrap up.",+ );+ expect(transcriptRegion.scrollTop).toBeGreaterThan(0);+ });++ fireEvent.wheel(transcriptRegion, { deltaY: -100 });++ expect(+ await canvas.findByRole('button', { name: 'Jump to current' }),+ ).toBeVisible();++ videoElement.currentTime = 22;+ fireEvent.seeking(videoElement);+ fireEvent.seeked(videoElement);+ fireEvent.timeUpdate(videoElement);++ await waitFor(() => {+ const activeEntry = canvasElement.querySelector('[aria-current="true"]');+ const currentSpokenWordRectangle = canvasElement+ .querySelector(+ `[${CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE}]`,+ )+ ?.getBoundingClientRect();+ const transcriptRegionRectangle =+ transcriptRegion.getBoundingClientRect();++ expect(activeEntry).toHaveTextContent(+ 'Yes, the active entry followed every position change.',+ );+ expect(+ canvas.queryByRole('button', { name: 'Jump to current' }),+ ).not.toBeInTheDocument();+ expect(currentSpokenWordRectangle?.top).toBeGreaterThanOrEqual(+ transcriptRegionRectangle.top,+ );+ expect(currentSpokenWordRectangle?.bottom).toBeLessThanOrEqual(+ transcriptRegionRectangle.bottom,+ );+ });++ const transcriptEntryButton = canvas.getByRole('button', {+ name: 'Seek recording to 0:06',+ });++ await userEvent.click(transcriptEntryButton);+ fireEvent.timeUpdate(videoElement);++ await waitFor(() => {+ expect(canvasElement.querySelector('video')).toBe(videoElement);+ expect(videoElement.currentTime).toBeCloseTo(6);+ expect(+ canvasElement.querySelector('[aria-current="true"]'),+ ).toHaveTextContent(+ 'The first milestone is complete and ready for review.',+ );+ });+ },+};+export const Loading: Story = {args: {callRecording: undefined,diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptEntryListItem.stories.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptEntryListItem.stories.tsxindex 38f460d8548..66f9078c792 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptEntryListItem.stories.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/CallRecordingTranscriptEntryListItem.stories.tsx@@ -1,6 +1,6 @@import { CallRecordingTranscriptEntryListItem } from '@/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem';import { type Meta, type StoryObj } from '@storybook/react-vite';-import { within } from 'storybook/test';+import { expect, within } from 'storybook/test';import { ComponentDecorator } from 'twenty-ui/testing';const meta: Meta<typeof CallRecordingTranscriptEntryListItem> = {@@ -54,6 +54,57 @@ export const WithHourLongTimestamp: Story = {},};+export const SpeakingDuringPlayback: Story = {+ args: {+ entry: {+ speakerName: 'Ada Lovelace',+ startSeconds: 10,+ endSeconds: 14,+ text: 'Thanks for joining everyone',+ words: [+ { text: 'Thanks', startSeconds: 10, endSeconds: 11 },+ { text: 'for', startSeconds: 11, endSeconds: 12 },+ { text: 'joining', startSeconds: 12, endSeconds: 13 },+ { text: 'everyone', startSeconds: 13, endSeconds: 14 },+ ],+ },+ playbackPhase: 'speaking',+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await canvas.findByText('Thanks for joining everyone');++ expect(+ canvasElement.querySelector('[aria-current="true"]'),+ ).toBeInTheDocument();+ },+};++export const UpcomingDuringPlayback: Story = {+ args: {+ entry: {+ speakerName: 'Grace Hopper',+ startSeconds: 24,+ endSeconds: 40,+ text: 'Happy to. Pipeline grew twenty percent since the last call.',+ words: [],+ },+ playbackPhase: 'upcoming',+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await canvas.findByText(+ 'Happy to. Pipeline grew twenty percent since the last call.',+ );++ expect(+ canvasElement.querySelector('[aria-current="true"]'),+ ).not.toBeInTheDocument();+ },+};+export const WithoutSpeaker: Story = {args: {entry: {diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/mockCallRecordingVideo.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/mockCallRecordingVideo.tsnew file mode 100644index 00000000000..255244a8440--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/__stories__/mockCallRecordingVideo.ts@@ -0,0 +1,5 @@+// 59s black 64x36 VP8 WebM generated for playback stories. A data URI keeps+// the media fully seekable: files served through the msw service worker+// passthrough end up with an empty seekable range in Chromium.+export const MOCK_CALL_RECORDING_VIDEO_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AB/eBAfGCFrW7EAAAELOCnEC3EAAAB/eBAfGCF4y7EAAAELOCr8i3EAAAB/eBAfGCGFa7EAAAELOCw1C3EAAAB/eBAfGCGS27EAAAELOC1ti3EAAAB/eBAfGCGfY=';diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/constants/CallRecordingTranscriptCurrentSpokenWordDataAttribute.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/constants/CallRecordingTranscriptCurrentSpokenWordDataAttribute.tsnew file mode 100644index 00000000000..7dcc2d6a3d3--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/constants/CallRecordingTranscriptCurrentSpokenWordDataAttribute.ts@@ -0,0 +1,2 @@+export const CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE =+ 'data-current-spoken-word';diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/constants/InitialCallRecordingTranscriptPlaybackPosition.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/constants/InitialCallRecordingTranscriptPlaybackPosition.tsnew file mode 100644index 00000000000..0e0f24f46d4--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/constants/InitialCallRecordingTranscriptPlaybackPosition.ts@@ -0,0 +1,7 @@+import { type CallRecordingTranscriptPlaybackPosition } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition';++export const INITIAL_CALL_RECORDING_TRANSCRIPT_PLAYBACK_POSITION: CallRecordingTranscriptPlaybackPosition =+ {+ activeIndex: -1,+ lastStartedIndex: -1,+ };diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptEntryPlaybackPhase.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptEntryPlaybackPhase.tsnew file mode 100644index 00000000000..8626ecc2c7f--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptEntryPlaybackPhase.ts@@ -0,0 +1,4 @@+export type CallRecordingTranscriptEntryPlaybackPhase =+ | 'spoken'+ | 'speaking'+ | 'upcoming';diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlayback.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlayback.tsnew file mode 100644index 00000000000..e552b5a58dd--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlayback.ts@@ -0,0 +1,7 @@+import { type CallRecordingTranscriptPlaybackPosition } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition';++export type CallRecordingTranscriptPlayback = {+ position: CallRecordingTranscriptPlaybackPosition;+ videoElement: HTMLVideoElement;+ onSeek: (startSeconds: number) => void;+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition.tsnew file mode 100644index 00000000000..1d4be620dfe--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition.ts@@ -0,0 +1,4 @@+export type CallRecordingTranscriptPlaybackPosition = {+ activeIndex: number;+ lastStartedIndex: number;+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimePoint.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimePoint.tsnew file mode 100644index 00000000000..0623247e19a--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimePoint.ts@@ -0,0 +1,5 @@+export type CallRecordingTranscriptTimePoint = {+ startSeconds: number;+ endSeconds?: number;+ index: number;+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimedItem.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimedItem.tsnew file mode 100644index 00000000000..dd21c662da8--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimedItem.ts@@ -0,0 +1,4 @@+export type CallRecordingTranscriptTimedItem = {+ startSeconds: number | undefined;+ endSeconds?: number;+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/buildCallRecordingTranscriptTimePoints.test.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/buildCallRecordingTranscriptTimePoints.test.tsnew file mode 100644index 00000000000..c10a322d86d--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/buildCallRecordingTranscriptTimePoints.test.ts@@ -0,0 +1,51 @@+import { buildCallRecordingTranscriptTimePoints } from '@/page-layout/widgets/call-recording-transcript/utils/buildCallRecordingTranscriptTimePoints';++describe('buildCallRecordingTranscriptTimePoints', () => {+ it('should map timed items to points keeping their original indexes', () => {+ const timePoints = buildCallRecordingTranscriptTimePoints([+ { startSeconds: 1, endSeconds: 2 },+ { startSeconds: 4.5, endSeconds: 6 },+ { startSeconds: 9, endSeconds: undefined },+ ]);++ expect(timePoints).toEqual([+ { startSeconds: 1, endSeconds: 2, index: 0 },+ { startSeconds: 4.5, endSeconds: 6, index: 1 },+ { startSeconds: 9, index: 2 },+ ]);+ });++ it('should skip untimed items without shifting the indexes of timed ones', () => {+ const timePoints = buildCallRecordingTranscriptTimePoints([+ { startSeconds: undefined },+ { startSeconds: 2 },+ { startSeconds: undefined },+ { startSeconds: 7 },+ ]);++ expect(timePoints).toEqual([+ { startSeconds: 2, index: 1 },+ { startSeconds: 7, index: 3 },+ ]);+ });++ it('should return an empty array when no item is timed', () => {+ expect(+ buildCallRecordingTranscriptTimePoints([{ startSeconds: undefined }]),+ ).toEqual([]);+ });++ it('should sort out-of-order items by start time keeping original indexes', () => {+ expect(+ buildCallRecordingTranscriptTimePoints([+ { startSeconds: 9 },+ { startSeconds: 2 },+ { startSeconds: 5 },+ ]),+ ).toEqual([+ { startSeconds: 2, index: 1 },+ { startSeconds: 5, index: 2 },+ { startSeconds: 9, index: 0 },+ ]);+ });+});diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/countStartedCallRecordingTranscriptTimePoints.test.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/countStartedCallRecordingTranscriptTimePoints.test.tsnew file mode 100644index 00000000000..682774a9ae0--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/countStartedCallRecordingTranscriptTimePoints.test.ts@@ -0,0 +1,63 @@+import { countStartedCallRecordingTranscriptTimePoints } from '@/page-layout/widgets/call-recording-transcript/utils/countStartedCallRecordingTranscriptTimePoints';++const TIME_POINTS = [+ { startSeconds: 1, index: 0 },+ { startSeconds: 4.5, index: 1 },+ { startSeconds: 9, index: 2 },+];++describe('countStartedCallRecordingTranscriptTimePoints', () => {+ it('should return zero before the first point starts', () => {+ expect(+ countStartedCallRecordingTranscriptTimePoints({+ timePoints: TIME_POINTS,+ currentTimeSeconds: 0.5,+ }),+ ).toBe(0);+ });++ it('should count a point as started within the seek tolerance before its start', () => {+ expect(+ countStartedCallRecordingTranscriptTimePoints({+ timePoints: TIME_POINTS,+ currentTimeSeconds: 0.995,+ }),+ ).toBe(1);+ });++ it('should count a point as started at its exact start time', () => {+ expect(+ countStartedCallRecordingTranscriptTimePoints({+ timePoints: TIME_POINTS,+ currentTimeSeconds: 4.5,+ }),+ ).toBe(2);+ });++ it('should count points between two starts', () => {+ expect(+ countStartedCallRecordingTranscriptTimePoints({+ timePoints: TIME_POINTS,+ currentTimeSeconds: 5,+ }),+ ).toBe(2);+ });++ it('should count every point after the last start', () => {+ expect(+ countStartedCallRecordingTranscriptTimePoints({+ timePoints: TIME_POINTS,+ currentTimeSeconds: 3600,+ }),+ ).toBe(3);+ });++ it('should return zero for an empty point list', () => {+ expect(+ countStartedCallRecordingTranscriptTimePoints({+ timePoints: [],+ currentTimeSeconds: 10,+ }),+ ).toBe(0);+ });+});diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/getCallRecordingTranscriptEntryPlaybackPhase.test.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/getCallRecordingTranscriptEntryPlaybackPhase.test.tsnew file mode 100644index 00000000000..80fc4e2ec5e--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/getCallRecordingTranscriptEntryPlaybackPhase.test.ts@@ -0,0 +1,57 @@+import { getCallRecordingTranscriptEntryPlaybackPhase } from '@/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptEntryPlaybackPhase';++describe('getCallRecordingTranscriptEntryPlaybackPhase', () => {+ it('should return undefined without playback', () => {+ expect(+ getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex: 0,+ playbackPosition: undefined,+ }),+ ).toBeUndefined();+ });++ it('should return undefined before the first entry starts', () => {+ expect(+ getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex: 0,+ playbackPosition: { activeIndex: -1, lastStartedIndex: -1 },+ }),+ ).toBeUndefined();+ });++ it('should mark the active entry as speaking', () => {+ expect(+ getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex: 2,+ playbackPosition: { activeIndex: 2, lastStartedIndex: 2 },+ }),+ ).toBe('speaking');+ });++ it('should mark entries up to the last started one as spoken', () => {+ expect(+ getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex: 1,+ playbackPosition: { activeIndex: 2, lastStartedIndex: 2 },+ }),+ ).toBe('spoken');+ });++ it('should mark the started entry as spoken in a silence gap', () => {+ expect(+ getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex: 2,+ playbackPosition: { activeIndex: -1, lastStartedIndex: 2 },+ }),+ ).toBe('spoken');+ });++ it('should mark entries after the last started one as upcoming', () => {+ expect(+ getCallRecordingTranscriptEntryPlaybackPhase({+ entryIndex: 3,+ playbackPosition: { activeIndex: 2, lastStartedIndex: 2 },+ }),+ ).toBe('upcoming');+ });+});diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/getCallRecordingTranscriptFollowScrollTop.test.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/getCallRecordingTranscriptFollowScrollTop.test.tsnew file mode 100644index 00000000000..70a294e56d2--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/getCallRecordingTranscriptFollowScrollTop.test.ts@@ -0,0 +1,39 @@+import { getCallRecordingTranscriptFollowScrollTop } from '@/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptFollowScrollTop';++describe('getCallRecordingTranscriptFollowScrollTop', () => {+ it('does not scroll when the active entry is inside the follow area', () => {+ expect(+ getCallRecordingTranscriptFollowScrollTop({+ followTargetBottom: 700,+ followTargetTop: 300,+ scrollContainerClientHeight: 1000,+ scrollContainerScrollTop: 400,+ scrollContainerTop: 100,+ }),+ ).toBeUndefined();+ });++ it('positions an entry outside the follow area at the scroll target', () => {+ expect(+ getCallRecordingTranscriptFollowScrollTop({+ followTargetBottom: 950,+ followTargetTop: 850,+ scrollContainerClientHeight: 1000,+ scrollContainerScrollTop: 400,+ scrollContainerTop: 100,+ }),+ ).toBe(800);+ });++ it('does not return a negative scroll position', () => {+ expect(+ getCallRecordingTranscriptFollowScrollTop({+ followTargetBottom: 150,+ followTargetTop: 50,+ scrollContainerClientHeight: 1000,+ scrollContainerScrollTop: 0,+ scrollContainerTop: 100,+ }),+ ).toBe(0);+ });+});diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/watchCallRecordingTranscriptFollowScroll.test.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/watchCallRecordingTranscriptFollowScroll.test.tsnew file mode 100644index 00000000000..87558b80d7f--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/watchCallRecordingTranscriptFollowScroll.test.ts@@ -0,0 +1,161 @@+import { watchCallRecordingTranscriptFollowScroll } from '@/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptFollowScroll';++class FakeVideoElement extends EventTarget {}++const makeElementWithRect = (top: number, bottom: number) => ({+ getBoundingClientRect: () => ({ top, bottom }),+});++const makeActiveEntryElement = ({+ currentSpokenWordElement = null,+ top = 0,+ bottom = 0,+}: {+ currentSpokenWordElement?: ReturnType<typeof makeElementWithRect> | null;+ top?: number;+ bottom?: number;+}) => ({+ getBoundingClientRect: () => ({ top, bottom }),+ querySelector: () => currentSpokenWordElement,+});++const makeScrollContainerElement = () => {+ const scrollToCalls: ScrollToOptions[] = [];++ const scrollContainerElement = {+ clientHeight: 100,+ scrollTop: 0,+ getBoundingClientRect: () => ({ top: 0, bottom: 100 }),+ scrollTo: (options: ScrollToOptions) => {+ scrollToCalls.push(options);+ },+ };++ return { scrollContainerElement, scrollToCalls };+};++describe('watchCallRecordingTranscriptFollowScroll', () => {+ const originalMatchMedia = window.matchMedia;+ let fakeVideoElement: FakeVideoElement;++ beforeEach(() => {+ jest.useFakeTimers();+ fakeVideoElement = new FakeVideoElement();+ Object.defineProperty(window, 'matchMedia', {+ configurable: true,+ value: () => ({ matches: false }),+ });+ });++ afterEach(() => {+ jest.useRealTimers();+ jest.clearAllMocks();+ Object.defineProperty(window, 'matchMedia', {+ configurable: true,+ value: originalMatchMedia,+ });+ });++ const startWatching = ({+ scrollContainerElement,+ activeEntryElement = null,+ }: {+ scrollContainerElement: ReturnType<+ typeof makeScrollContainerElement+ >['scrollContainerElement'];+ activeEntryElement?: ReturnType<typeof makeActiveEntryElement> | null;+ }) =>+ watchCallRecordingTranscriptFollowScroll({+ videoElement: fakeVideoElement,+ scrollContainerElement,+ getActiveEntryElement: () => activeEntryElement,+ });++ it('should scroll the current word into the reading band when it drifts below', () => {+ const { scrollContainerElement, scrollToCalls } =+ makeScrollContainerElement();++ const stopWatching = startWatching({+ scrollContainerElement,+ activeEntryElement: makeActiveEntryElement({+ currentSpokenWordElement: makeElementWithRect(90, 95),+ }),+ });++ fakeVideoElement.dispatchEvent(new Event('timeupdate'));+ jest.advanceTimersByTime(20);++ expect(scrollToCalls).toEqual([{ behavior: 'smooth', top: 55 }]);++ stopWatching();+ });++ it('should not scroll while the current word stays inside the reading band', () => {+ const { scrollContainerElement, scrollToCalls } =+ makeScrollContainerElement();++ const stopWatching = startWatching({+ scrollContainerElement,+ activeEntryElement: makeActiveEntryElement({+ currentSpokenWordElement: makeElementWithRect(40, 45),+ }),+ });++ fakeVideoElement.dispatchEvent(new Event('timeupdate'));+ jest.advanceTimersByTime(20);++ expect(scrollToCalls).toEqual([]);++ stopWatching();+ });++ it('should fall back to the active entry element when no word is marked', () => {+ const { scrollContainerElement, scrollToCalls } =+ makeScrollContainerElement();++ const stopWatching = startWatching({+ scrollContainerElement,+ activeEntryElement: makeActiveEntryElement({ top: 120, bottom: 160 }),+ });++ fakeVideoElement.dispatchEvent(new Event('timeupdate'));+ jest.advanceTimersByTime(20);++ expect(scrollToCalls).toEqual([{ behavior: 'smooth', top: 85 }]);++ stopWatching();+ });++ it('should not scroll without an active entry', () => {+ const { scrollContainerElement, scrollToCalls } =+ makeScrollContainerElement();++ const stopWatching = startWatching({ scrollContainerElement });++ fakeVideoElement.dispatchEvent(new Event('timeupdate'));+ jest.advanceTimersByTime(20);++ expect(scrollToCalls).toEqual([]);++ stopWatching();+ });++ it('should stop following after the returned cleanup runs', () => {+ const { scrollContainerElement, scrollToCalls } =+ makeScrollContainerElement();++ const stopWatching = startWatching({+ scrollContainerElement,+ activeEntryElement: makeActiveEntryElement({+ currentSpokenWordElement: makeElementWithRect(90, 95),+ }),+ });++ stopWatching();++ fakeVideoElement.dispatchEvent(new Event('timeupdate'));+ jest.advanceTimersByTime(20);++ expect(scrollToCalls).toEqual([]);+ });+});diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/watchCallRecordingTranscriptPlayback.test.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/watchCallRecordingTranscriptPlayback.test.tsnew file mode 100644index 00000000000..ddce1bddeaf--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/__tests__/watchCallRecordingTranscriptPlayback.test.ts@@ -0,0 +1,248 @@+import { watchCallRecordingTranscriptPlayback } from '@/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptPlayback';++class FakeVideoElement extends EventTarget {+ currentTime = 0;+ paused = true;+ seeking = false;+ playbackRate = 1;+}++const TIME_POINTS = [+ { startSeconds: 1, index: 0 },+ { startSeconds: 2, index: 1 },+ { startSeconds: 10, index: 2 },+];++const BOUNDED_TIME_POINTS = [+ { startSeconds: 1, endSeconds: 2, index: 0 },+ { startSeconds: 4, endSeconds: 5, index: 1 },+];++describe('watchCallRecordingTranscriptPlayback', () => {+ let fakeVideoElement: FakeVideoElement;+ let onPlaybackPositionChange: jest.Mock;++ const startWatching = (timePoints = TIME_POINTS) =>+ watchCallRecordingTranscriptPlayback({+ videoElement: fakeVideoElement,+ timePoints,+ onPlaybackPositionChange,+ });++ beforeEach(() => {+ jest.useFakeTimers();+ fakeVideoElement = new FakeVideoElement();+ onPlaybackPositionChange = jest.fn();+ });++ afterEach(() => {+ jest.useRealTimers();+ jest.clearAllMocks();+ });++ it('should notify the current index immediately on start', () => {+ fakeVideoElement.currentTime = 5;++ const stopWatching = startWatching();++ expect(onPlaybackPositionChange).toHaveBeenCalledTimes(1);+ expect(onPlaybackPositionChange).toHaveBeenCalledWith({+ activeIndex: 1,+ lastStartedIndex: 1,+ });++ stopWatching();+ });++ it('should notify -1 before the first point starts', () => {+ const stopWatching = startWatching();++ expect(onPlaybackPositionChange).toHaveBeenCalledWith({+ activeIndex: -1,+ lastStartedIndex: -1,+ });++ stopWatching();+ });++ it('should notify -1 after the current point ends', () => {+ fakeVideoElement.currentTime = 3;++ const stopWatching = startWatching(BOUNDED_TIME_POINTS);++ expect(onPlaybackPositionChange).toHaveBeenCalledWith({+ activeIndex: -1,+ lastStartedIndex: 0,+ });++ stopWatching();+ });++ it('should not notify again when the index is unchanged', () => {+ fakeVideoElement.currentTime = 5;++ const stopWatching = startWatching();++ fakeVideoElement.currentTime = 6;+ fakeVideoElement.dispatchEvent(new Event('timeupdate'));++ expect(onPlaybackPositionChange).toHaveBeenCalledTimes(1);++ stopWatching();+ });++ it('should follow a backward seek', () => {+ fakeVideoElement.currentTime = 5;++ const stopWatching = startWatching();++ fakeVideoElement.currentTime = 1.5;+ fakeVideoElement.dispatchEvent(new Event('seeked'));++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 0,+ lastStartedIndex: 0,+ });++ stopWatching();+ });++ it('should cross the next boundary between timeupdate events while playing', () => {+ fakeVideoElement.currentTime = 1.5;+ fakeVideoElement.paused = false;++ const stopWatching = startWatching();++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 0,+ lastStartedIndex: 0,+ });++ fakeVideoElement.currentTime = 2.1;+ jest.advanceTimersByTime(600);++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 1,+ lastStartedIndex: 1,+ });++ stopWatching();+ });++ it('should clear the current index at its end boundary while playing', () => {+ fakeVideoElement.currentTime = 1.5;+ fakeVideoElement.paused = false;++ const stopWatching = startWatching(BOUNDED_TIME_POINTS);++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 0,+ lastStartedIndex: 0,+ });++ fakeVideoElement.currentTime = 2.1;+ jest.advanceTimersByTime(600);++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: -1,+ lastStartedIndex: 0,+ });++ stopWatching();+ });++ it('should schedule the boundary wake-up against the playback rate', () => {+ fakeVideoElement.currentTime = 1.5;+ fakeVideoElement.paused = false;+ fakeVideoElement.playbackRate = 2;++ const stopWatching = startWatching();++ fakeVideoElement.currentTime = 2.1;+ jest.advanceTimersByTime(300);++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 1,+ lastStartedIndex: 1,+ });++ stopWatching();+ });++ it('should not schedule a boundary wake-up while paused', () => {+ fakeVideoElement.currentTime = 1.5;++ const stopWatching = startWatching();++ expect(jest.getTimerCount()).toBe(0);++ stopWatching();+ });++ it.each([+ { bufferingEventName: 'waiting', resumeEventName: 'playing' },+ { bufferingEventName: 'stalled', resumeEventName: 'canplay' },+ ])(+ 'should suspend boundary wake-ups on $bufferingEventName and resume on $resumeEventName',+ ({ bufferingEventName, resumeEventName }) => {+ fakeVideoElement.currentTime = 1.99;+ fakeVideoElement.paused = false;++ const stopWatching = startWatching();++ expect(jest.getTimerCount()).toBe(1);++ fakeVideoElement.dispatchEvent(new Event(bufferingEventName));++ expect(jest.getTimerCount()).toBe(0);++ jest.advanceTimersByTime(100);++ expect(onPlaybackPositionChange).toHaveBeenCalledTimes(1);++ fakeVideoElement.currentTime = 2.1;+ fakeVideoElement.dispatchEvent(new Event(resumeEventName));++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 1,+ lastStartedIndex: 1,+ });++ stopWatching();+ },+ );++ it('should resume after stalled playback advances without a resume event', () => {+ fakeVideoElement.currentTime = 1.99;+ fakeVideoElement.paused = false;++ const stopWatching = startWatching();++ fakeVideoElement.dispatchEvent(new Event('stalled'));++ expect(jest.getTimerCount()).toBe(0);++ fakeVideoElement.currentTime = 2.1;+ fakeVideoElement.dispatchEvent(new Event('timeupdate'));++ expect(onPlaybackPositionChange).toHaveBeenLastCalledWith({+ activeIndex: 1,+ lastStartedIndex: 1,+ });+ expect(jest.getTimerCount()).toBe(1);++ stopWatching();+ });++ it('should stop notifying after the returned cleanup runs', () => {+ const stopWatching = startWatching();++ stopWatching();++ fakeVideoElement.currentTime = 5;+ fakeVideoElement.dispatchEvent(new Event('timeupdate'));+ jest.runAllTimers();++ expect(onPlaybackPositionChange).toHaveBeenCalledTimes(1);+ });+});diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/buildCallRecordingTranscriptTimePoints.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/buildCallRecordingTranscriptTimePoints.tsnew file mode 100644index 00000000000..e1ff90f20fc--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/buildCallRecordingTranscriptTimePoints.ts@@ -0,0 +1,20 @@+import { type CallRecordingTranscriptTimePoint } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimePoint';+import { type CallRecordingTranscriptTimedItem } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimedItem';+import { isDefined } from 'twenty-shared/utils';++export const buildCallRecordingTranscriptTimePoints = (+ timedItems: CallRecordingTranscriptTimedItem[],+): CallRecordingTranscriptTimePoint[] =>+ timedItems+ .flatMap((timedItem, index) =>+ isDefined(timedItem.startSeconds)+ ? [+ {+ startSeconds: timedItem.startSeconds,+ endSeconds: timedItem.endSeconds,+ index,+ },+ ]+ : [],+ )+ .toSorted((left, right) => left.startSeconds - right.startSeconds);diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/countStartedCallRecordingTranscriptTimePoints.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/countStartedCallRecordingTranscriptTimePoints.tsnew file mode 100644index 00000000000..d4ef7637116--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/countStartedCallRecordingTranscriptTimePoints.ts@@ -0,0 +1,18 @@+import { type CallRecordingTranscriptTimePoint } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimePoint';++// Media timebase rounding can land an exact-start seek a hair before the+// point; counting it as started keeps the seeked-to point the active one.+const TIME_POINT_START_TOLERANCE_SECONDS = 0.01;++export const countStartedCallRecordingTranscriptTimePoints = ({+ timePoints,+ currentTimeSeconds,+}: {+ timePoints: CallRecordingTranscriptTimePoint[];+ currentTimeSeconds: number;+}): number =>+ timePoints.findLastIndex(+ (timePoint) =>+ timePoint.startSeconds <=+ currentTimeSeconds + TIME_POINT_START_TOLERANCE_SECONDS,+ ) + 1;diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptEntryPlaybackPhase.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptEntryPlaybackPhase.tsnew file mode 100644index 00000000000..3722c58bee1--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptEntryPlaybackPhase.ts@@ -0,0 +1,28 @@+import { type CallRecordingTranscriptEntryPlaybackPhase } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptEntryPlaybackPhase';+import { type CallRecordingTranscriptPlaybackPosition } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition';+import { isDefined } from 'twenty-shared/utils';++export const getCallRecordingTranscriptEntryPlaybackPhase = ({+ entryIndex,+ playbackPosition,+}: {+ entryIndex: number;+ playbackPosition: CallRecordingTranscriptPlaybackPosition | undefined;+}): CallRecordingTranscriptEntryPlaybackPhase | undefined => {+ if (+ !isDefined(playbackPosition) ||+ playbackPosition.lastStartedIndex === -1+ ) {+ return undefined;+ }++ if (entryIndex === playbackPosition.activeIndex) {+ return 'speaking';+ }++ if (entryIndex <= playbackPosition.lastStartedIndex) {+ return 'spoken';+ }++ return 'upcoming';+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptFollowScrollTop.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptFollowScrollTop.tsnew file mode 100644index 00000000000..61334a92bfc--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptFollowScrollTop.ts@@ -0,0 +1,39 @@+const FOLLOW_TARGET_VISIBLE_AREA_TOP_RATIO = 0.2;+const FOLLOW_TARGET_VISIBLE_AREA_BOTTOM_RATIO = 0.8;+const FOLLOW_TARGET_SCROLL_TARGET_RATIO = 0.35;++export const getCallRecordingTranscriptFollowScrollTop = ({+ followTargetBottom,+ followTargetTop,+ scrollContainerClientHeight,+ scrollContainerScrollTop,+ scrollContainerTop,+}: {+ followTargetBottom: number;+ followTargetTop: number;+ scrollContainerClientHeight: number;+ scrollContainerScrollTop: number;+ scrollContainerTop: number;+}): number | undefined => {+ const visibleAreaTop =+ scrollContainerTop ++ scrollContainerClientHeight * FOLLOW_TARGET_VISIBLE_AREA_TOP_RATIO;+ const visibleAreaBottom =+ scrollContainerTop ++ scrollContainerClientHeight * FOLLOW_TARGET_VISIBLE_AREA_BOTTOM_RATIO;++ if (+ followTargetTop >= visibleAreaTop &&+ followTargetBottom <= visibleAreaBottom+ ) {+ return undefined;+ }++ return Math.max(+ 0,+ scrollContainerScrollTop ++ followTargetTop -+ scrollContainerTop -+ scrollContainerClientHeight * FOLLOW_TARGET_SCROLL_TARGET_RATIO,+ );+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptFollowScroll.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptFollowScroll.tsnew file mode 100644index 00000000000..655b60800fe--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptFollowScroll.ts@@ -0,0 +1,100 @@+import { CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE } from '@/page-layout/widgets/call-recording-transcript/constants/CallRecordingTranscriptCurrentSpokenWordDataAttribute';+import { getCallRecordingTranscriptFollowScrollTop } from '@/page-layout/widgets/call-recording-transcript/utils/getCallRecordingTranscriptFollowScrollTop';+import { isDefined } from 'twenty-shared/utils';++const FOLLOW_SCROLL_SYNC_EVENT_NAMES = [+ 'seeking',+ 'seeked',+ 'timeupdate',+] as const;++const CURRENT_SPOKEN_WORD_SELECTOR = `[${CALL_RECORDING_TRANSCRIPT_CURRENT_SPOKEN_WORD_DATA_ATTRIBUTE}]`;++type FollowScrollTargetElement = {+ getBoundingClientRect: () => Pick<DOMRect, 'bottom' | 'top'>;+};++type FollowScrollActiveEntryElement = FollowScrollTargetElement & {+ querySelector: (selector: string) => FollowScrollTargetElement | null;+};++type FollowScrollContainerElement = FollowScrollTargetElement & {+ clientHeight: number;+ scrollTop: number;+ scrollTo: (options: ScrollToOptions) => void;+};++type WatchCallRecordingTranscriptFollowScrollParams = {+ videoElement: Pick<EventTarget, 'addEventListener' | 'removeEventListener'>;+ scrollContainerElement: FollowScrollContainerElement;+ getActiveEntryElement: () => FollowScrollActiveEntryElement | null;+};++export const watchCallRecordingTranscriptFollowScroll = ({+ videoElement,+ scrollContainerElement,+ getActiveEntryElement,+}: WatchCallRecordingTranscriptFollowScrollParams) => {+ let animationFrameId: number | undefined;++ const followPlaybackPosition = () => {+ const activeEntryElement = getActiveEntryElement();+ const followTargetElement =+ activeEntryElement?.querySelector(CURRENT_SPOKEN_WORD_SELECTOR) ??+ activeEntryElement;++ if (!isDefined(followTargetElement)) {+ return;+ }++ const followTargetRectangle = followTargetElement.getBoundingClientRect();+ const scrollContainerRectangle =+ scrollContainerElement.getBoundingClientRect();+ const scrollTop = getCallRecordingTranscriptFollowScrollTop({+ followTargetBottom: followTargetRectangle.bottom,+ followTargetTop: followTargetRectangle.top,+ scrollContainerClientHeight: scrollContainerElement.clientHeight,+ scrollContainerScrollTop: scrollContainerElement.scrollTop,+ scrollContainerTop: scrollContainerRectangle.top,+ });++ if (!isDefined(scrollTop)) {+ return;+ }++ const prefersReducedMotion = window.matchMedia(+ '(prefers-reduced-motion: reduce)',+ ).matches;++ scrollContainerElement.scrollTo({+ behavior: prefersReducedMotion ? 'auto' : 'smooth',+ top: scrollTop,+ });+ };++ // Measured on the next frame so React has committed the word marker for the+ // playback position that triggered the event.+ const scheduleFollowScroll = () => {+ if (isDefined(animationFrameId)) {+ cancelAnimationFrame(animationFrameId);+ }++ animationFrameId = requestAnimationFrame(followPlaybackPosition);+ };++ for (const eventName of FOLLOW_SCROLL_SYNC_EVENT_NAMES) {+ videoElement.addEventListener(eventName, scheduleFollowScroll);+ }++ scheduleFollowScroll();++ return () => {+ if (isDefined(animationFrameId)) {+ cancelAnimationFrame(animationFrameId);+ }++ for (const eventName of FOLLOW_SCROLL_SYNC_EVENT_NAMES) {+ videoElement.removeEventListener(eventName, scheduleFollowScroll);+ }+ };+};diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptPlayback.ts b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptPlayback.tsnew file mode 100644index 00000000000..589bf0c50b3--- /dev/null+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/utils/watchCallRecordingTranscriptPlayback.ts@@ -0,0 +1,163 @@+import { type CallRecordingTranscriptPlaybackPosition } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptPlaybackPosition';+import { type CallRecordingTranscriptTimePoint } from '@/page-layout/widgets/call-recording-transcript/types/CallRecordingTranscriptTimePoint';+import { countStartedCallRecordingTranscriptTimePoints } from '@/page-layout/widgets/call-recording-transcript/utils/countStartedCallRecordingTranscriptTimePoints';+import { isDefined } from 'twenty-shared/utils';++const PLAYBACK_SYNC_EVENT_NAMES = [+ 'play',+ 'pause',+ 'seeking',+ 'seeked',+ 'ratechange',+] as const;++const PLAYBACK_BUFFERING_EVENT_NAMES = ['waiting', 'stalled'] as const;+const PLAYBACK_RESUME_EVENT_NAMES = ['playing', 'canplay'] as const;++const MINIMUM_BOUNDARY_DELAY_IN_MS = 10;++type WatchCallRecordingTranscriptPlaybackParams = {+ videoElement: Pick<EventTarget, 'addEventListener' | 'removeEventListener'> &+ Pick<+ HTMLMediaElement,+ 'currentTime' | 'paused' | 'playbackRate' | 'seeking'+ >;+ timePoints: CallRecordingTranscriptTimePoint[];+ onPlaybackPositionChange: (+ playbackPosition: CallRecordingTranscriptPlaybackPosition,+ ) => void;+};++// timeupdate only fires ~4 times per second, too coarse for word-level sync;+// while playing, a timeout aimed at the next boundary fills the gaps. Every+// wake re-reads currentTime, so seeks and rate changes self-correct.+export const watchCallRecordingTranscriptPlayback = ({+ videoElement,+ timePoints,+ onPlaybackPositionChange,+}: WatchCallRecordingTranscriptPlaybackParams) => {+ let lastNotifiedActiveIndex: number | undefined;+ let lastNotifiedLastStartedIndex: number | undefined;+ let boundaryTimeoutId: ReturnType<typeof setTimeout> | undefined;+ let bufferingStartTimeSeconds: number | undefined;++ const clearBoundaryTimeout = () => {+ clearTimeout(boundaryTimeoutId);+ boundaryTimeoutId = undefined;+ };++ const syncPlaybackPosition = () => {+ clearBoundaryTimeout();++ const startedTimePointCount = countStartedCallRecordingTranscriptTimePoints(+ {+ timePoints,+ currentTimeSeconds: videoElement.currentTime,+ },+ );++ const lastStartedTimePoint = timePoints[startedTimePointCount - 1];+ const lastStartedIndex = !isDefined(lastStartedTimePoint)+ ? -1+ : lastStartedTimePoint.index;+ const activeIndex =+ !isDefined(lastStartedTimePoint) ||+ (isDefined(lastStartedTimePoint.endSeconds) &&+ videoElement.currentTime >= lastStartedTimePoint.endSeconds)+ ? -1+ : lastStartedTimePoint.index;++ if (+ activeIndex !== lastNotifiedActiveIndex ||+ lastStartedIndex !== lastNotifiedLastStartedIndex+ ) {+ lastNotifiedActiveIndex = activeIndex;+ lastNotifiedLastStartedIndex = lastStartedIndex;+ onPlaybackPositionChange({ activeIndex, lastStartedIndex });+ }++ const nextTimePoint = timePoints[startedTimePointCount];+ const currentTimePointEndSeconds = lastStartedTimePoint?.endSeconds;+ const nextBoundarySeconds =+ isDefined(currentTimePointEndSeconds) &&+ currentTimePointEndSeconds > videoElement.currentTime &&+ (!isDefined(nextTimePoint) ||+ currentTimePointEndSeconds < nextTimePoint.startSeconds)+ ? currentTimePointEndSeconds+ : nextTimePoint?.startSeconds;++ if (+ videoElement.paused ||+ videoElement.seeking ||+ isDefined(bufferingStartTimeSeconds) ||+ !isDefined(nextBoundarySeconds)+ ) {+ return;+ }++ const mediaSecondsUntilBoundary =+ nextBoundarySeconds - videoElement.currentTime;+ const wallClockDelayInMs =+ (mediaSecondsUntilBoundary / (videoElement.playbackRate || 1)) * 1000;++ boundaryTimeoutId = setTimeout(+ syncPlaybackPosition,+ Math.max(wallClockDelayInMs, MINIMUM_BOUNDARY_DELAY_IN_MS),+ );+ };++ const suspendPlaybackSynchronization = () => {+ bufferingStartTimeSeconds = videoElement.currentTime;+ clearBoundaryTimeout();+ };++ const resumePlaybackSynchronization = () => {+ bufferingStartTimeSeconds = undefined;+ syncPlaybackPosition();+ };++ const synchronizeOnTimeUpdate = () => {+ if (+ isDefined(bufferingStartTimeSeconds) &&+ videoElement.currentTime > bufferingStartTimeSeconds+ ) {+ bufferingStartTimeSeconds = undefined;+ }++ syncPlaybackPosition();+ };++ for (const eventName of PLAYBACK_SYNC_EVENT_NAMES) {+ videoElement.addEventListener(eventName, syncPlaybackPosition);+ }+ for (const eventName of PLAYBACK_BUFFERING_EVENT_NAMES) {+ videoElement.addEventListener(eventName, suspendPlaybackSynchronization);+ }+ for (const eventName of PLAYBACK_RESUME_EVENT_NAMES) {+ videoElement.addEventListener(eventName, resumePlaybackSynchronization);+ }+ videoElement.addEventListener('timeupdate', synchronizeOnTimeUpdate);++ syncPlaybackPosition();++ return () => {+ clearBoundaryTimeout();++ for (const eventName of PLAYBACK_SYNC_EVENT_NAMES) {+ videoElement.removeEventListener(eventName, syncPlaybackPosition);+ }+ for (const eventName of PLAYBACK_BUFFERING_EVENT_NAMES) {+ videoElement.removeEventListener(+ eventName,+ suspendPlaybackSynchronization,+ );+ }+ for (const eventName of PLAYBACK_RESUME_EVENT_NAMES) {+ videoElement.removeEventListener(+ eventName,+ resumePlaybackSynchronization,+ );+ }+ videoElement.removeEventListener('timeupdate', synchronizeOnTimeUpdate);+ };+};