Skip to content

The open alternative to Salesforce, designed for AI.

Show call recordings on record pages in the call recorder app (#28223)

nitinaeb474479865
diff --git a/packages/twenty-apps/public/call-recorder/README.md b/packages/twenty-apps/public/call-recorder/README.md
index 2437bfc8a2f..4df12896fcb 100644
--- a/packages/twenty-apps/public/call-recorder/README.md
+++ b/packages/twenty-apps/public/call-recorder/README.md
@@ -9,7 +9,7 @@
- **A per-meeting on/off switch**
- **Customizable in-meeting recording notices**
- **AI meeting summaries**
-- **Call participants on call recording pages**
+- **Call participants and recordings on record pages**
- **Built for AI & automation**
## 💳 Billing
@@ -37,14 +37,19 @@ happens once the meeting is within the seven-day scheduling window. Set it to
Off to skip a meeting. Past meetings the recorder never joined simply stay
blank.
-## 👥 Call participants
+## 👥 Calls on record pages
-A **Call participants** widget is added to the Home tab of call recording
-pages. It reads the meeting the recording belongs to, so nothing is copied onto
-the recording, and shows the meeting's attendees. People in your CRM open their
-record when clicked; workspace members are shown by name. Attendees that match
-no one are hidden unless the `CALL_RECORDER_SHOW_UNMATCHED_ATTENDEES` app
-variable is `true`.
+The app provides two record page widgets. Both read the meeting the recording
+belongs to, so nothing is copied onto the recording.
+
+- **Call participants** is added to the Home tab of call recording pages. It
+ shows the meeting's attendees.
+ People in your CRM open their record when clicked; workspace members are
+ shown by name. Attendees that match no one are hidden unless the
+ `CALL_RECORDER_SHOW_UNMATCHED_ATTENDEES` app variable is `true`.
+- **Call recordings** lists the 20 most recent recordings of meetings linked
+ to a person, company or opportunity. To show it, edit that record page's
+ layout and add the widget from the layout editor.
## 🗓️ Pausing the recorder
diff --git a/packages/twenty-apps/public/call-recorder/package.json b/packages/twenty-apps/public/call-recorder/package.json
index 589d42104a2..7e06973bdd9 100644
--- a/packages/twenty-apps/public/call-recorder/package.json
+++ b/packages/twenty-apps/public/call-recorder/package.json
@@ -1,6 +1,6 @@
{
"name": "@twentyhq/call-recorder",
- "version": "1.17.0",
+ "version": "1.18.0",
"license": "MIT",
"engines": {
"node": "^24.5.0",
diff --git a/packages/twenty-apps/public/call-recorder/src/__tests__/record-page-widgets.test.ts b/packages/twenty-apps/public/call-recorder/src/__tests__/record-page-widgets.test.ts
index 94db0587ffe..e9379b2df2d 100644
--- a/packages/twenty-apps/public/call-recorder/src/__tests__/record-page-widgets.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/__tests__/record-page-widgets.test.ts
@@ -5,14 +5,26 @@ import { STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS } from 'twenty-sdk/define';
import { CALL_PARTICIPANTS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
import callParticipantsFrontComponent from 'src/front-components/call-participants.front-component';
import callParticipantsOnCallRecordingPageLayoutWidget from 'src/page-layout-widgets/call-participants-on-call-recording.page-layout-widget';
+import callRecordingsFrontComponent from 'src/front-components/call-recordings.front-component';
+
+const recordPageWidgetFrontComponents = [
+ callParticipantsFrontComponent,
+ callRecordingsFrontComponent,
+];
describe('record page widgets', () => {
- it('passes the SDK manifest validation', () => {
- expect(callParticipantsFrontComponent.errors).toEqual([]);
+ it('pass the SDK manifest validation', () => {
+ for (const frontComponent of recordPageWidgetFrontComponents) {
+ expect(frontComponent.errors).toEqual([]);
+ }
});
- it('can be placed as a widget', () => {
- expect(callParticipantsFrontComponent.config.isHeadless).not.toBe(true);
+ // Users add these from the layout editor, which only offers rendered
+ // (non-headless) front components as widgets.
+ it('can be placed as widgets', () => {
+ for (const frontComponent of recordPageWidgetFrontComponents) {
+ expect(frontComponent.config.isHeadless).not.toBe(true);
+ }
});
it('adds call participants to the call recording Home tab', () => {
diff --git a/packages/twenty-apps/public/call-recorder/src/constants/universal-identifiers.ts b/packages/twenty-apps/public/call-recorder/src/constants/universal-identifiers.ts
index b310b124f83..f023dc6a60f 100644
--- a/packages/twenty-apps/public/call-recorder/src/constants/universal-identifiers.ts
+++ b/packages/twenty-apps/public/call-recorder/src/constants/universal-identifiers.ts
@@ -67,6 +67,9 @@ export const CALL_RECORDER_WAITING_ROOM_TIMEOUT_SECONDS_APP_VARIABLE_UNIVERSAL_I
export const CALL_RECORDING_AUDIO_FIELD_UNIVERSAL_IDENTIFIER =
'2eafc2d0-8fec-430c-a939-65ca5fbc0f08';
+export const CALL_RECORDINGS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER =
+ '67e22a78-b421-4fca-bdf9-962a1f4cd1af';
+
export const CALL_RECORDING_SUMMARIZER_AGENT_UNIVERSAL_IDENTIFIER =
'388543f3-ec85-4905-ad7d-99801337ed5c';
diff --git a/packages/twenty-apps/public/call-recorder/src/default-role.ts b/packages/twenty-apps/public/call-recorder/src/default-role.ts
index 4a3f4b4dcb6..d96cedf8fc5 100644
--- a/packages/twenty-apps/public/call-recorder/src/default-role.ts
+++ b/packages/twenty-apps/public/call-recorder/src/default-role.ts
@@ -11,7 +11,7 @@ export default defineApplicationRole({
universalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER,
label: `${APP_DISPLAY_NAME} default role`,
description:
- 'Reads calendar events to decide whether the call recorder should attend a meeting and sets their Recording Bot field; writes the resulting CallRecording records, uploads recording media, and fills transcripts and summaries.',
+ 'Reads calendar events to decide whether the call recorder should attend a meeting and sets their Recording Bot field; writes the resulting CallRecording records, uploads recording media, and fills transcripts and summaries. Also reads meeting participants and targets so record pages can show who was on a call and which calls involved a record.',
canReadAllObjectRecords: false,
canUpdateAllObjectRecords: false,
canSoftDeleteAllObjectRecords: false,
@@ -38,6 +38,15 @@ export default defineApplicationRole({
canSoftDeleteObjectRecords: false,
canDestroyObjectRecords: false,
},
+ {
+ objectUniversalIdentifier:
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.calendarEventTarget
+ .universalIdentifier,
+ canReadObjectRecords: true,
+ canUpdateObjectRecords: false,
+ canSoftDeleteObjectRecords: false,
+ canDestroyObjectRecords: false,
+ },
{
objectUniversalIdentifier:
STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.callRecording.universalIdentifier,
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/call-recordings.front-component.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/call-recordings.front-component.tsx
new file mode 100644
index 00000000000..9539a7c17b3
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/call-recordings.front-component.tsx
@@ -0,0 +1,12 @@
+import { defineFrontComponent } from 'twenty-sdk/define';
+
+import { CALL_RECORDINGS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
+import { CallRecordingsWidget } from 'src/front-components/components/CallRecordingsWidget';
+
+export default defineFrontComponent({
+ universalIdentifier: CALL_RECORDINGS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER,
+ name: 'Call recordings',
+ description:
+ 'Lists the most recent call recordings of the meetings linked to a person, company or opportunity.',
+ component: CallRecordingsWidget,
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRow.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRow.tsx
new file mode 100644
index 00000000000..3f8d7a592ad
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRow.tsx
@@ -0,0 +1,76 @@
+import styled from '@emotion/styled';
+import { isUndefined } from '@sniptt/guards';
+import { getPublicAssetUrl } from 'twenty-sdk/utils';
+import { Avatar, Chip, ChipVariant } from 'twenty-ui/data-display';
+import { IconCalendar } from 'twenty-ui/icon';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+import { CallRecordingRowMetadata } from 'src/front-components/components/CallRecordingRowMetadata';
+import { CallRecordingRowStatus } from 'src/front-components/components/CallRecordingRowStatus';
+import { StyledCallRecordingRowLayout } from 'src/front-components/components/StyledCallRecordingRowLayout';
+import { StyledChipButton } from 'src/front-components/components/StyledChipButton';
+import { type CallRecordingStatusTag } from 'src/front-components/types/call-recording-status-tag.type';
+import { openRecord } from 'src/front-components/utils/open-record.util';
+
+const StyledRightContent = styled.span`
+ align-items: center;
+ color: ${() => themeCssVariables.font.color.secondary};
+ display: flex;
+ flex-shrink: 0;
+ font-size: ${() => themeCssVariables.font.size.md};
+ gap: ${() => themeCssVariables.spacing[2]};
+ white-space: nowrap;
+`;
+
+type CallRecordingRowProps = {
+ callRecordingId: string;
+ title: string;
+ formattedDate: string | undefined;
+ formattedDuration: string | undefined;
+ statusTag: CallRecordingStatusTag | undefined;
+};
+
+export const CallRecordingRow = ({
+ callRecordingId,
+ title,
+ formattedDate,
+ formattedDuration,
+ statusTag,
+}: CallRecordingRowProps) => {
+ const handleClick = () => {
+ void openRecord({
+ objectNameSingular: 'callRecording',
+ recordId: callRecordingId,
+ });
+ };
+
+ return (
+ <StyledCallRecordingRowLayout>
+ <StyledChipButton type="button" onClick={handleClick}>
+ <Chip
+ label={title}
+ clickable
+ variant={ChipVariant.Highlighted}
+ leftComponent={
+ <Avatar
+ avatarUrl={getPublicAssetUrl('logo.svg')}
+ placeholder={title}
+ placeholderColorSeed={callRecordingId}
+ type="rounded"
+ size="sm"
+ />
+ }
+ />
+ </StyledChipButton>
+ <StyledRightContent>
+ <CallRecordingRowStatus
+ statusTag={statusTag}
+ formattedDuration={formattedDuration}
+ />
+ {!isUndefined(formattedDate) && (
+ <CallRecordingRowMetadata Icon={IconCalendar} text={formattedDate} />
+ )}
+ </StyledRightContent>
+ </StyledCallRecordingRowLayout>
+ );
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowMetadata.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowMetadata.tsx
new file mode 100644
index 00000000000..100ae0a41fc
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowMetadata.tsx
@@ -0,0 +1,33 @@
+import styled from '@emotion/styled';
+import { type IconComponent } from 'twenty-ui/icon';
+import { ICON } from 'twenty-ui/theme';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+const StyledMetadata = styled.span`
+ align-items: center;
+ display: flex;
+ gap: ${() => themeCssVariables.spacing['0.5']};
+`;
+
+const StyledMetadataIconContainer = styled.span`
+ align-items: center;
+ color: ${() => themeCssVariables.font.color.light};
+ display: flex;
+`;
+
+type CallRecordingRowMetadataProps = {
+ Icon: IconComponent;
+ text: string;
+};
+
+export const CallRecordingRowMetadata = ({
+ Icon,
+ text,
+}: CallRecordingRowMetadataProps) => (
+ <StyledMetadata>
+ <StyledMetadataIconContainer>
+ <Icon size={ICON.size.md} />
+ </StyledMetadataIconContainer>
+ {text}
+ </StyledMetadata>
+);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowSkeleton.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowSkeleton.tsx
new file mode 100644
index 00000000000..2da10728220
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowSkeleton.tsx
@@ -0,0 +1,31 @@
+import { keyframes } from '@emotion/react';
+import styled from '@emotion/styled';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+import { StyledCallRecordingRowLayout } from 'src/front-components/components/StyledCallRecordingRowLayout';
+
+const pulse = keyframes`
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.4; }
+`;
+
+const StyledSkeletonBlock = styled.span<{ $width: string }>`
+ animation: ${pulse} 1.5s ease-in-out infinite;
+ background: ${() => themeCssVariables.background.transparent.light};
+ border-radius: ${() => themeCssVariables.border.radius.sm};
+ flex-shrink: 0;
+ height: ${() => themeCssVariables.spacing[4]};
+ width: ${({ $width }) => $width};
+`;
+
+const StyledSkeletonSpacer = styled.span`
+ flex: 1;
+`;
+
+export const CallRecordingRowSkeleton = () => (
+ <StyledCallRecordingRowLayout aria-hidden>
+ <StyledSkeletonBlock $width="40%" />
+ <StyledSkeletonSpacer />
+ <StyledSkeletonBlock $width={themeCssVariables.spacing[20]} />
+ </StyledCallRecordingRowLayout>
+);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowStatus.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowStatus.tsx
new file mode 100644
index 00000000000..64ced4366a3
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingRowStatus.tsx
@@ -0,0 +1,26 @@
+import { isUndefined } from '@sniptt/guards';
+import { Tag } from 'twenty-ui/data-display';
+import { IconClock } from 'twenty-ui/icon';
+
+import { CallRecordingRowMetadata } from 'src/front-components/components/CallRecordingRowMetadata';
+import { type CallRecordingStatusTag } from 'src/front-components/types/call-recording-status-tag.type';
+
+type CallRecordingRowStatusProps = {
+ statusTag: CallRecordingStatusTag | undefined;
+ formattedDuration: string | undefined;
+};
+
+export const CallRecordingRowStatus = ({
+ statusTag,
+ formattedDuration,
+}: CallRecordingRowStatusProps) => {
+ if (!isUndefined(statusTag)) {
+ return <Tag color={statusTag.color} text={statusTag.text} />;
+ }
+
+ if (isUndefined(formattedDuration)) {
+ return null;
+ }
+
+ return <CallRecordingRowMetadata Icon={IconClock} text={formattedDuration} />;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx
new file mode 100644
index 00000000000..508923d8742
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx
@@ -0,0 +1,128 @@
+import 'twenty-ui/style.css';
+
+import { isUndefined } from '@sniptt/guards';
+import {
+ useLocale,
+ useSelectedObjectMetadata,
+ useSelectedRecordIds,
+} from 'twenty-sdk/front-component';
+
+import { CallRecordingRow } from 'src/front-components/components/CallRecordingRow';
+import { CallRecordingRowSkeleton } from 'src/front-components/components/CallRecordingRowSkeleton';
+import { FrontComponentThemeProvider } from 'src/front-components/components/FrontComponentThemeProvider';
+import { StyledCallRecordingCard } from 'src/front-components/components/StyledCallRecordingCard';
+import { WidgetEmptyState } from 'src/front-components/components/WidgetEmptyState';
+import { useCallRecordingsForRecord } from 'src/front-components/hooks/use-call-recordings-for-record';
+import { type CalendarEventTargetFieldName } from 'src/front-components/types/calendar-event-target-field-name.type';
+import { getCallRecordingDisplayDate } from 'src/front-components/utils/get-call-recording-display-date.util';
+import { formatCallRecordingDate } from 'src/front-components/utils/format-call-recording-date.util';
+import { formatCallRecordingDuration } from 'src/front-components/utils/format-call-recording-duration.util';
+import { getCallRecordingStatusTag } from 'src/front-components/utils/get-call-recording-status-tag.util';
+import { getCalendarEventTargetFieldName } from 'src/front-components/utils/get-calendar-event-target-field-name.util';
+import { resolveCallRecordingDisplayTitle } from 'src/front-components/utils/resolve-call-recording-display-title.util';
+
+const CALL_RECORDING_SKELETON_ROW_COUNT = 3;
+
+type CallRecordingListProps = {
+ calendarEventTargetFieldName: CalendarEventTargetFieldName;
+ recordId: string;
+};
+
+const CallRecordingList = ({
+ calendarEventTargetFieldName,
+ recordId,
+}: CallRecordingListProps) => {
+ const locale = useLocale();
+ const callRecordingsState = useCallRecordingsForRecord({
+ calendarEventTargetFieldName,
+ recordId,
+ });
+
+ switch (callRecordingsState.status) {
+ case 'loading':
+ return (
+ <StyledCallRecordingCard aria-busy aria-label="Loading call recordings">
+ {Array.from(
+ { length: CALL_RECORDING_SKELETON_ROW_COUNT },
+ (_, skeletonRowIndex) => (
+ <CallRecordingRowSkeleton key={skeletonRowIndex} />
+ ),
+ )}
+ </StyledCallRecordingCard>
+ );
+ case 'error':
+ return (
+ <WidgetEmptyState
+ title="Could Not Load Recordings"
+ description="Something went wrong while loading call recordings."
+ />
+ );
+ case 'loaded':
+ if (callRecordingsState.callRecordings.length === 0) {
+ return (
+ <WidgetEmptyState
+ title="No Call Recordings"
+ description="No calls with this record have been recorded yet."
+ />
+ );
+ }
+
+ return (
+ <StyledCallRecordingCard>
+ {callRecordingsState.callRecordings.map((callRecording) => (
+ <CallRecordingRow
+ key={callRecording.id}
+ callRecordingId={callRecording.id}
+ title={resolveCallRecordingDisplayTitle(callRecording)}
+ formattedDate={formatCallRecordingDate({
+ dateTime: getCallRecordingDisplayDate(callRecording),
+ locale,
+ })}
+ formattedDuration={formatCallRecordingDuration({
+ startedAt: callRecording.startedAt,
+ endedAt: callRecording.endedAt,
+ })}
+ statusTag={getCallRecordingStatusTag(callRecording.status)}
+ />
+ ))}
+ </StyledCallRecordingCard>
+ );
+ }
+};
+
+export const CallRecordingsWidget = () => {
+ const selectedRecordIds = useSelectedRecordIds();
+ const selectedObjectMetadata = useSelectedObjectMetadata();
+
+ const recordId =
+ selectedRecordIds.length === 1 ? selectedRecordIds[0] : undefined;
+ const calendarEventTargetFieldName = getCalendarEventTargetFieldName(
+ selectedObjectMetadata?.nameSingular,
+ );
+
+ const renderContent = () => {
+ if (isUndefined(calendarEventTargetFieldName)) {
+ return (
+ <WidgetEmptyState
+ title="Not Available Here"
+ description="Add this widget to a person, company or opportunity page."
+ />
+ );
+ }
+
+ if (isUndefined(recordId)) {
+ return <WidgetEmptyState title="No Record Selected" />;
+ }
+
+ return (
+ <CallRecordingList
+ calendarEventTargetFieldName={calendarEventTargetFieldName}
+ recordId={recordId}
+ />
+ );
+ };
+
+ return (
+ <FrontComponentThemeProvider>{renderContent()}</FrontComponentThemeProvider>
+ );
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/RecordPagesSection.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/RecordPagesSection.tsx
index 08f66801501..2e0862b7e25 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/RecordPagesSection.tsx
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/RecordPagesSection.tsx
@@ -33,7 +33,7 @@ export const RecordPagesSection = () => {
<Section>
<H2Title
title="Record pages"
- description="What the call participants widget shows on call recording pages."
+ description="What the call widgets show on people, companies, opportunities and recordings."
/>
<StyledSettingsCard>
<SettingsOptionCardContentToggle
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/StyledCallRecordingCard.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/StyledCallRecordingCard.tsx
new file mode 100644
index 00000000000..1f782948e62
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/StyledCallRecordingCard.tsx
@@ -0,0 +1,8 @@
+import styled from '@emotion/styled';
+
+export const StyledCallRecordingCard = styled.div`
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+`;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/StyledCallRecordingRowLayout.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/StyledCallRecordingRowLayout.tsx
new file mode 100644
index 00000000000..bf2b1944b51
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/StyledCallRecordingRowLayout.tsx
@@ -0,0 +1,12 @@
+import styled from '@emotion/styled';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+export const StyledCallRecordingRowLayout = styled.div`
+ align-items: center;
+ box-sizing: border-box;
+ display: flex;
+ gap: ${() => themeCssVariables.spacing[1]};
+ height: ${() => themeCssVariables.spacing[10]};
+ justify-content: space-between;
+ width: 100%;
+`;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-calendar-event-target-pages.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-calendar-event-target-pages.constant.ts
new file mode 100644
index 00000000000..7e9410f389f
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-calendar-event-target-pages.constant.ts
@@ -0,0 +1,2 @@
+// Bounds the lookup for records with many meetings but few or no recordings.
+export const CALL_RECORDINGS_WIDGET_MAX_CALENDAR_EVENT_TARGET_PAGES = 20;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-call-recordings-per-batch.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-call-recordings-per-batch.constant.ts
new file mode 100644
index 00000000000..a3a4a4d5a4d
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-call-recordings-per-batch.constant.ts
@@ -0,0 +1 @@
+export const CALL_RECORDINGS_WIDGET_MAX_CALL_RECORDINGS_PER_BATCH = 500;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-count.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-count.constant.ts
new file mode 100644
index 00000000000..0fa47ba6a17
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-max-count.constant.ts
@@ -0,0 +1 @@
+export const CALL_RECORDINGS_WIDGET_MAX_COUNT = 20;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-refresh-interval-milliseconds.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-refresh-interval-milliseconds.constant.ts
new file mode 100644
index 00000000000..bbfca06a6a7
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recordings-widget-refresh-interval-milliseconds.constant.ts
@@ -0,0 +1 @@
+export const CALL_RECORDINGS_WIDGET_REFRESH_INTERVAL_MILLISECONDS = 30_000;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/listed-call-recording-statuses.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/listed-call-recording-statuses.constant.ts
new file mode 100644
index 00000000000..90ac95c7118
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/listed-call-recording-statuses.constant.ts
@@ -0,0 +1,7 @@
+import { CallRecordingStatus } from 'src/logic-functions/constants/call-recording-status';
+
+export const LISTED_CALL_RECORDING_STATUSES = [
+ CallRecordingStatus.RECORDING,
+ CallRecordingStatus.PROCESSING,
+ CallRecordingStatus.COMPLETED,
+];
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/untitled-call-recording-title.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/untitled-call-recording-title.constant.ts
new file mode 100644
index 00000000000..d6dbd3cfb3d
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/untitled-call-recording-title.constant.ts
@@ -0,0 +1 @@
+export const UNTITLED_CALL_RECORDING_TITLE = 'Untitled call';
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts b/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts
new file mode 100644
index 00000000000..f98355ffce3
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts
@@ -0,0 +1,85 @@
+import { isUndefined } from '@sniptt/guards';
+import { useEffect, useState } from 'react';
+import { CoreApiClient } from 'twenty-client-sdk/core';
+
+import { CALL_RECORDINGS_WIDGET_MAX_COUNT } from 'src/front-components/constants/call-recordings-widget-max-count.constant';
+import { CALL_RECORDINGS_WIDGET_REFRESH_INTERVAL_MILLISECONDS } from 'src/front-components/constants/call-recordings-widget-refresh-interval-milliseconds.constant';
+import { type CalendarEventTargetFieldName } from 'src/front-components/types/calendar-event-target-field-name.type';
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+import { fetchCallRecordingsForRecord } from 'src/front-components/utils/fetch-call-recordings-for-record.util';
+import { isCallRecordingInProgress } from 'src/front-components/utils/is-call-recording-in-progress.util';
+
+type CallRecordingsForRecordState =
+ | { status: 'loading' }
+ | { status: 'error' }
+ | { status: 'loaded'; callRecordings: CallRecordingNode[] };
+
+export const useCallRecordingsForRecord = ({
+ calendarEventTargetFieldName,
+ recordId,
+}: {
+ calendarEventTargetFieldName: CalendarEventTargetFieldName;
+ recordId: string;
+}): CallRecordingsForRecordState => {
+ const [state, setState] = useState<CallRecordingsForRecordState>({
+ status: 'loading',
+ });
+
+ useEffect(() => {
+ let isCancelled = false;
+ let hasLoaded = false;
+ let refreshTimeout: ReturnType<typeof setTimeout> | undefined;
+
+ const scheduleRefresh = () => {
+ refreshTimeout = setTimeout(
+ loadCallRecordings,
+ CALL_RECORDINGS_WIDGET_REFRESH_INTERVAL_MILLISECONDS,
+ );
+ };
+
+ const loadCallRecordings = () => {
+ fetchCallRecordingsForRecord({
+ client: new CoreApiClient(),
+ calendarEventTargetFieldName,
+ recordId,
+ maxCount: CALL_RECORDINGS_WIDGET_MAX_COUNT,
+ })
+ .then((callRecordings) => {
+ if (isCancelled) {
+ return;
+ }
+
+ hasLoaded = true;
+ setState({ status: 'loaded', callRecordings });
+
+ if (callRecordings.some(isCallRecordingInProgress)) {
+ scheduleRefresh();
+ }
+ })
+ .catch(() => {
+ if (isCancelled) {
+ return;
+ }
+
+ if (hasLoaded) {
+ scheduleRefresh();
+ } else {
+ setState({ status: 'error' });
+ }
+ });
+ };
+
+ setState({ status: 'loading' });
+ loadCallRecordings();
+
+ return () => {
+ isCancelled = true;
+
+ if (!isUndefined(refreshTimeout)) {
+ clearTimeout(refreshTimeout);
+ }
+ };
+ }, [calendarEventTargetFieldName, recordId]);
+
+ return state;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/types/calendar-event-target-field-name.type.ts b/packages/twenty-apps/public/call-recorder/src/front-components/types/calendar-event-target-field-name.type.ts
new file mode 100644
index 00000000000..3a0e9114864
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/types/calendar-event-target-field-name.type.ts
@@ -0,0 +1,4 @@
+export type CalendarEventTargetFieldName =
+ | 'targetPersonId'
+ | 'targetCompanyId'
+ | 'targetOpportunityId';
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/types/call-recording-node.type.ts b/packages/twenty-apps/public/call-recorder/src/front-components/types/call-recording-node.type.ts
new file mode 100644
index 00000000000..e0d35deea6a
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/types/call-recording-node.type.ts
@@ -0,0 +1,14 @@
+export type CallRecordingNode = {
+ id: string;
+ title?: string | null;
+ status?: string | null;
+ startedAt?: string | null;
+ endedAt?: string | null;
+ createdAt?: string | null;
+ calendarEventId?: string | null;
+ calendarEvent?: {
+ id: string;
+ title?: string | null;
+ startsAt?: string | null;
+ } | null;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/types/call-recording-status-tag.type.ts b/packages/twenty-apps/public/call-recorder/src/front-components/types/call-recording-status-tag.type.ts
new file mode 100644
index 00000000000..838c92bb3de
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/types/call-recording-status-tag.type.ts
@@ -0,0 +1,4 @@
+export type CallRecordingStatusTag = {
+ text: string;
+ color: 'red' | 'orange';
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/fetch-call-recordings-for-record.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/fetch-call-recordings-for-record.test.ts
new file mode 100644
index 00000000000..3a5dae402f3
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/fetch-call-recordings-for-record.test.ts
@@ -0,0 +1,374 @@
+import { isUndefined } from '@sniptt/guards';
+import { describe, expect, it, type Mock, vi } from 'vitest';
+
+import { CALL_RECORDINGS_WIDGET_MAX_CALENDAR_EVENT_TARGET_PAGES } from 'src/front-components/constants/call-recordings-widget-max-calendar-event-target-pages.constant';
+import { fetchCallRecordingsForRecord } from 'src/front-components/utils/fetch-call-recordings-for-record.util';
+import { TWENTY_PAGE_SIZE } from 'src/logic-functions/constants/twenty-page-size';
+
+type QueryRequest = {
+ calendarEventTargets?: { __args: { orderBy: unknown } };
+ callRecordings?: {
+ __args: {
+ filter: { calendarEventId: { in: string[] }; status: unknown };
+ after?: string;
+ };
+ edges: { node: { calendarEvent?: unknown } };
+ };
+};
+
+const buildPermissionDeniedError = () =>
+ Object.assign(new Error('Permission denied'), {
+ errors: [
+ {
+ message: 'Permission denied',
+ extensions: { code: 'FORBIDDEN', subCode: 'PERMISSION_DENIED' },
+ },
+ ],
+ });
+
+const buildCalendarEventTargetConnection = (
+ calendarEventIds: Array<string | null>,
+ hasNextPage = false,
+) => ({
+ calendarEventTargets: {
+ pageInfo: {
+ hasNextPage,
+ endCursor: hasNextPage ? 'next-target-cursor' : null,
+ },
+ edges: calendarEventIds.map((calendarEventId, targetIndex) => ({
+ node: { id: `target-${targetIndex}`, calendarEventId },
+ })),
+ },
+});
+
+type CallRecordingFixture = {
+ id: string;
+ startedAt?: string | null;
+ createdAt?: string;
+ calendarEvent?: { id: string; startsAt: string } | null;
+};
+
+const buildCallRecordingConnection = (
+ callRecordings: CallRecordingFixture[],
+ hasNextPage = false,
+) => ({
+ callRecordings: {
+ pageInfo: {
+ hasNextPage,
+ endCursor: hasNextPage ? 'next-recording-cursor' : null,
+ },
+ edges: callRecordings.map((callRecording) => ({ node: callRecording })),
+ },
+});
+
+const isCalendarEventTargetQuery = (request: QueryRequest) =>
+ 'calendarEventTargets' in request;
+
+const getCallRecordingQueries = (query: Mock) =>
+ query.mock.calls
+ .map(([request]) => request as QueryRequest)
+ .flatMap((request) =>
+ isUndefined(request.callRecordings) ? [] : [request.callRecordings],
+ );
+
+const fetchForPerson = (query: Mock, maxCount = 20) =>
+ fetchCallRecordingsForRecord({
+ client: { query },
+ calendarEventTargetFieldName: 'targetPersonId',
+ recordId: 'person',
+ maxCount,
+ });
+
+describe('fetchCallRecordingsForRecord', () => {
+ it('returns nothing without querying recordings when the record has no meetings', async () => {
+ const query = vi
+ .fn()
+ .mockResolvedValueOnce(buildCalendarEventTargetConnection([]));
+
+ await expect(fetchForPerson(query)).resolves.toEqual([]);
+ expect(query).toHaveBeenCalledTimes(1);
+ });
+
+ it('finds listed recordings through the meetings that target the record', async () => {
+ const query = vi
+ .fn()
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection([
+ 'calendar-event-1',
+ 'calendar-event-2',
+ 'calendar-event-1',
+ null,
+ ]),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ { id: 'older', startedAt: '2026-01-01T10:00:00.000Z' },
+ { id: 'newer', startedAt: '2026-02-01T10:00:00.000Z' },
+ ]),
+ );
+
+ const callRecordings = await fetchCallRecordingsForRecord({
+ client: { query },
+ calendarEventTargetFieldName: 'targetCompanyId',
+ recordId: 'company',
+ maxCount: 20,
+ });
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'newer',
+ 'older',
+ ]);
+
+ const targetQueryArguments =
+ query.mock.calls[0][0].calendarEventTargets.__args;
+
+ expect(targetQueryArguments.filter).toEqual({
+ targetCompanyId: { eq: 'company' },
+ });
+ expect(targetQueryArguments.orderBy).toEqual([
+ { calendarEvent: { startsAt: 'DescNullsLast' } },
+ ]);
+
+ const [callRecordingQuery] = getCallRecordingQueries(query);
+
+ expect(callRecordingQuery.__args.filter).toEqual({
+ calendarEventId: { in: ['calendar-event-1', 'calendar-event-2'] },
+ status: { in: ['RECORDING', 'PROCESSING', 'COMPLETED'] },
+ });
+ expect(callRecordingQuery.edges.node.calendarEvent).toEqual({
+ id: true,
+ title: true,
+ startsAt: true,
+ });
+ });
+
+ it('reads every page of recordings so a live call without a start time is not cut', async () => {
+ const startedRecordings = Array.from(
+ { length: TWENTY_PAGE_SIZE },
+ (_, recordingIndex) => ({
+ id: `started-${recordingIndex}`,
+ startedAt: new Date(
+ Date.UTC(2026, 0, 1, 0, recordingIndex),
+ ).toISOString(),
+ }),
+ );
+ const query = vi
+ .fn()
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(['calendar-event-1']),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection(startedRecordings, true),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ {
+ id: 'live-call',
+ startedAt: null,
+ calendarEvent: {
+ id: 'calendar-event-1',
+ startsAt: '2026-06-01T10:00:00.000Z',
+ },
+ },
+ ]),
+ );
+
+ const callRecordings = await fetchForPerson(query, 3);
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'live-call',
+ `started-${TWENTY_PAGE_SIZE - 1}`,
+ `started-${TWENTY_PAGE_SIZE - 2}`,
+ ]);
+
+ const callRecordingQueries = getCallRecordingQueries(query);
+
+ expect(callRecordingQueries).toHaveLength(2);
+ expect(callRecordingQueries[1].__args.after).toBe('next-recording-cursor');
+ });
+
+ it('keeps reading meetings past ones without recordings until enough are found', async () => {
+ const upcomingMeetingIds = Array.from(
+ { length: TWENTY_PAGE_SIZE },
+ (_, calendarEventIndex) => `upcoming-${calendarEventIndex}`,
+ );
+ const query = vi
+ .fn()
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(upcomingMeetingIds, true),
+ )
+ .mockResolvedValueOnce(buildCallRecordingConnection([]))
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(
+ ['past-meeting', 'upcoming-0'],
+ true,
+ ),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ { id: 'recording', startedAt: '2026-01-01T10:00:00.000Z' },
+ ]),
+ );
+
+ const callRecordings = await fetchForPerson(query, 1);
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'recording',
+ ]);
+ expect(query).toHaveBeenCalledTimes(4);
+ expect(query.mock.calls[2][0].calendarEventTargets.__args.after).toBe(
+ 'next-target-cursor',
+ );
+ expect(
+ getCallRecordingQueries(query)[1].__args.filter.calendarEventId,
+ ).toEqual({ in: ['past-meeting'] });
+ });
+
+ it('stops reading meetings once the target page cap is reached', async () => {
+ let targetPageIndex = 0;
+ const query = vi.fn((request: QueryRequest) => {
+ if (!isCalendarEventTargetQuery(request)) {
+ return Promise.resolve(buildCallRecordingConnection([]));
+ }
+
+ targetPageIndex += 1;
+
+ return Promise.resolve(
+ buildCalendarEventTargetConnection(
+ Array.from(
+ { length: TWENTY_PAGE_SIZE },
+ (_, calendarEventIndex) =>
+ `calendar-event-${targetPageIndex}-${calendarEventIndex}`,
+ ),
+ true,
+ ),
+ );
+ });
+
+ await expect(fetchForPerson(query)).resolves.toEqual([]);
+ expect(targetPageIndex).toBe(
+ CALL_RECORDINGS_WIDGET_MAX_CALENDAR_EVENT_TARGET_PAGES,
+ );
+ });
+
+ it('skips the meeting join when meetings could not be used to order targets', async () => {
+ const query = vi
+ .fn()
+ .mockRejectedValueOnce(buildPermissionDeniedError())
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(['calendar-event-1']),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ { id: 'recording', startedAt: '2026-01-01T10:00:00.000Z' },
+ ]),
+ );
+
+ const callRecordings = await fetchForPerson(query);
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'recording',
+ ]);
+ expect(query).toHaveBeenCalledTimes(3);
+ expect(query.mock.calls[1][0].calendarEventTargets.__args.orderBy).toEqual([
+ { createdAt: 'DescNullsLast' },
+ ]);
+
+ const callRecordingQueries = getCallRecordingQueries(query);
+
+ expect(callRecordingQueries).toHaveLength(1);
+ expect(callRecordingQueries[0].edges.node.calendarEvent).toBeUndefined();
+ });
+
+ it('reads every meeting page when targets are ordered by creation date', async () => {
+ const query = vi
+ .fn()
+ .mockRejectedValueOnce(buildPermissionDeniedError())
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(['old-meeting'], true),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ { id: 'old-recording', startedAt: '2025-01-01T10:00:00.000Z' },
+ ]),
+ )
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(['new-meeting']),
+ )
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ { id: 'new-recording', startedAt: '2026-01-01T10:00:00.000Z' },
+ ]),
+ );
+
+ const callRecordings = await fetchForPerson(query, 1);
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'new-recording',
+ ]);
+ expect(query).toHaveBeenCalledTimes(5);
+ });
+
+ it('lists recordings without their meeting when the join is denied', async () => {
+ const query = vi
+ .fn()
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(['calendar-event-1']),
+ )
+ .mockRejectedValueOnce(buildPermissionDeniedError())
+ .mockResolvedValueOnce(
+ buildCallRecordingConnection([
+ { id: 'recording', startedAt: '2026-01-01T10:00:00.000Z' },
+ ]),
+ );
+
+ const callRecordings = await fetchForPerson(query);
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'recording',
+ ]);
+ expect(
+ query.mock.calls[2][0].callRecordings.edges.node.calendarEvent,
+ ).toBeUndefined();
+ });
+
+ it('fails when the recordings fallback query is denied too', async () => {
+ const query = vi
+ .fn()
+ .mockResolvedValueOnce(
+ buildCalendarEventTargetConnection(['calendar-event-1']),
+ )
+ .mockRejectedValueOnce(buildPermissionDeniedError())
+ .mockRejectedValueOnce(buildPermissionDeniedError());
+
+ await expect(fetchForPerson(query)).rejects.toThrow('Permission denied');
+ expect(query).toHaveBeenCalledTimes(3);
+ });
+
+ it.each([
+ ['target', [new Error('Network failure')]],
+ [
+ 'recording',
+ [
+ buildCalendarEventTargetConnection(['calendar-event-1']),
+ new Error('Network failure'),
+ ],
+ ],
+ ])(
+ 'rethrows a %s query error that is not a permission error without retrying',
+ async (_, responses) => {
+ const query = vi.fn();
+
+ for (const response of responses) {
+ if (response instanceof Error) {
+ query.mockRejectedValueOnce(response);
+ } else {
+ query.mockResolvedValueOnce(response);
+ }
+ }
+
+ await expect(fetchForPerson(query)).rejects.toThrow('Network failure');
+ expect(query).toHaveBeenCalledTimes(responses.length);
+ },
+ );
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/format-call-recording-date.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/format-call-recording-date.test.ts
new file mode 100644
index 00000000000..2ac3d8a7a0b
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/format-call-recording-date.test.ts
@@ -0,0 +1,76 @@
+import { describe, expect, it, vi } from 'vitest';
+
+import { formatCallRecordingDate } from 'src/front-components/utils/format-call-recording-date.util';
+
+describe('formatCallRecordingDate', () => {
+ it('leaves the year out for dates in the current year', () => {
+ expect(
+ formatCallRecordingDate({
+ dateTime: '2026-03-15T12:00:00.000Z',
+ locale: 'en-US',
+ now: new Date('2026-10-15T12:00:00.000Z'),
+ }),
+ ).toBe('Mar 15');
+ });
+
+ it('shows the year for dates in another year', () => {
+ expect(
+ formatCallRecordingDate({
+ dateTime: '2025-03-15T12:00:00.000Z',
+ locale: 'en-US',
+ now: new Date('2026-10-15T12:00:00.000Z'),
+ }),
+ ).toBe('Mar 15, 2025');
+ });
+
+ it('does not throw on a locale the runtime rejects', () => {
+ expect(
+ formatCallRecordingDate({
+ dateTime: '2026-03-15T12:00:00.000Z',
+ locale: 'not_a_locale!',
+ }),
+ ).toEqual(expect.any(String));
+ });
+
+ it.each([undefined, null, '', 'not a date'])(
+ 'returns nothing for %j',
+ (dateTime) => {
+ expect(
+ formatCallRecordingDate({ dateTime, locale: 'en-US' }),
+ ).toBeUndefined();
+ },
+ );
+
+ it('reuses one formatter per locale', () => {
+ let createdDateTimeFormatCount = 0;
+ const OriginalDateTimeFormat = Intl.DateTimeFormat;
+
+ class CountingDateTimeFormat extends OriginalDateTimeFormat {
+ constructor(...args: ConstructorParameters<typeof Intl.DateTimeFormat>) {
+ super(...args);
+ createdDateTimeFormatCount += 1;
+ }
+ }
+
+ vi.stubGlobal('Intl', { DateTimeFormat: CountingDateTimeFormat });
+
+ try {
+ formatCallRecordingDate({
+ dateTime: '2026-03-15T12:00:00.000Z',
+ locale: 'en-GB',
+ });
+ formatCallRecordingDate({
+ dateTime: '2026-03-16T12:00:00.000Z',
+ locale: 'en-GB',
+ });
+ formatCallRecordingDate({
+ dateTime: '2026-03-17T12:00:00.000Z',
+ locale: 'en-GB',
+ });
+ } finally {
+ vi.unstubAllGlobals();
+ }
+
+ expect(createdDateTimeFormatCount).toBe(1);
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/format-call-recording-duration.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/format-call-recording-duration.test.ts
new file mode 100644
index 00000000000..a4557cbca4a
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/format-call-recording-duration.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from 'vitest';
+
+import { formatCallRecordingDuration } from 'src/front-components/utils/format-call-recording-duration.util';
+
+const START = '2026-03-15T10:00:00.000Z';
+
+describe('formatCallRecordingDuration', () => {
+ it.each([
+ ['2026-03-15T10:00:00.000Z', '0s'],
+ ['2026-03-15T10:00:42.000Z', '42s'],
+ ['2026-03-15T10:00:59.600Z', '1m'],
+ ['2026-03-15T10:12:30.000Z', '12m'],
+ ['2026-03-15T10:59:59.000Z', '59m'],
+ ['2026-03-15T11:00:00.000Z', '1h 00m'],
+ ['2026-03-15T11:05:00.000Z', '1h 05m'],
+ ['2026-03-15T12:45:10.000Z', '2h 45m'],
+ ])('formats a call ending at %s as %s', (endedAt, expectedDuration) => {
+ expect(formatCallRecordingDuration({ startedAt: START, endedAt })).toBe(
+ expectedDuration,
+ );
+ });
+
+ it.each([
+ { startedAt: null, endedAt: '2026-03-15T11:00:00.000Z' },
+ { startedAt: START, endedAt: null },
+ { startedAt: START, endedAt: undefined },
+ { startedAt: 'not a date', endedAt: '2026-03-15T11:00:00.000Z' },
+ ])('omits the duration when it is unknown (%j)', (callRecording) => {
+ expect(formatCallRecordingDuration(callRecording)).toBeUndefined();
+ });
+
+ it('omits a negative duration', () => {
+ expect(
+ formatCallRecordingDuration({
+ startedAt: START,
+ endedAt: '2026-03-15T09:00:00.000Z',
+ }),
+ ).toBeUndefined();
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-calendar-event-target-field-name.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-calendar-event-target-field-name.test.ts
new file mode 100644
index 00000000000..fdc954ceee3
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-calendar-event-target-field-name.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, it } from 'vitest';
+
+import { getCalendarEventTargetFieldName } from 'src/front-components/utils/get-calendar-event-target-field-name.util';
+
+describe('getCalendarEventTargetFieldName', () => {
+ it.each([
+ ['person', 'targetPersonId'],
+ ['company', 'targetCompanyId'],
+ ['opportunity', 'targetOpportunityId'],
+ ])('maps %s to %s', (objectNameSingular, calendarEventTargetFieldName) => {
+ expect(getCalendarEventTargetFieldName(objectNameSingular)).toBe(
+ calendarEventTargetFieldName,
+ );
+ });
+
+ it.each([undefined, 'callRecording', 'task', 'constructor'])(
+ 'does not support %j',
+ (objectNameSingular) => {
+ expect(
+ getCalendarEventTargetFieldName(objectNameSingular),
+ ).toBeUndefined();
+ },
+ );
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-call-recording-status-tag.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-call-recording-status-tag.test.ts
new file mode 100644
index 00000000000..41bf33d3e65
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-call-recording-status-tag.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest';
+
+import { getCallRecordingStatusTag } from 'src/front-components/utils/get-call-recording-status-tag.util';
+
+describe('getCallRecordingStatusTag', () => {
+ it('tags a call that is still being recorded', () => {
+ expect(getCallRecordingStatusTag('RECORDING')).toEqual({
+ text: 'Recording',
+ color: 'red',
+ });
+ });
+
+ it('tags a call that is still being processed', () => {
+ expect(getCallRecordingStatusTag('PROCESSING')).toEqual({
+ text: 'Processing',
+ color: 'orange',
+ });
+ });
+
+ it.each(['COMPLETED', 'FAILED', 'SCHEDULED', null, undefined])(
+ 'shows no tag for %j, so the duration is shown instead',
+ (status) => {
+ expect(getCallRecordingStatusTag(status)).toBeUndefined();
+ },
+ );
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-most-recent-call-recordings.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-most-recent-call-recordings.test.ts
new file mode 100644
index 00000000000..4b109dcab0d
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-most-recent-call-recordings.test.ts
@@ -0,0 +1,81 @@
+import { describe, expect, it } from 'vitest';
+
+import { getMostRecentCallRecordings } from 'src/front-components/utils/get-most-recent-call-recordings.util';
+
+describe('getMostRecentCallRecordings', () => {
+ it('orders by the displayed date: start time, else meeting start, else creation', () => {
+ const callRecordings = getMostRecentCallRecordings({
+ callRecordings: [
+ {
+ id: 'started-january',
+ startedAt: '2026-01-01T10:00:00.000Z',
+ createdAt: '2026-05-01T10:00:00.000Z',
+ },
+ {
+ id: 'meeting-april',
+ startedAt: null,
+ createdAt: '2025-12-01T10:00:00.000Z',
+ calendarEvent: {
+ id: 'calendar-event',
+ startsAt: '2026-04-01T10:00:00.000Z',
+ },
+ },
+ {
+ id: 'created-march',
+ startedAt: null,
+ createdAt: '2026-03-01T10:00:00.000Z',
+ calendarEvent: null,
+ },
+ {
+ id: 'started-february',
+ startedAt: '2026-02-01T10:00:00.000Z',
+ createdAt: '2026-02-01T10:00:00.000Z',
+ },
+ ],
+ maxCount: 10,
+ });
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'meeting-april',
+ 'created-march',
+ 'started-february',
+ 'started-january',
+ ]);
+ });
+
+ it('puts recordings without any valid date last', () => {
+ const callRecordings = getMostRecentCallRecordings({
+ callRecordings: [
+ { id: 'invalid', startedAt: 'not a date' },
+ { id: 'valid', startedAt: '2026-01-01T10:00:00.000Z' },
+ ],
+ maxCount: 10,
+ });
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'valid',
+ 'invalid',
+ ]);
+ });
+
+ it('caps by the displayed date and drops duplicates returned by several batches', () => {
+ const callRecordings = getMostRecentCallRecordings({
+ callRecordings: [
+ { id: 'c', startedAt: '2026-01-01T10:00:00.000Z' },
+ { id: 'a', startedAt: '2026-01-03T10:00:00.000Z' },
+ {
+ id: 'b',
+ startedAt: null,
+ calendarEvent: { id: 'event', startsAt: '2026-01-02T10:00:00.000Z' },
+ },
+ { id: 'a', startedAt: '2026-01-03T10:00:00.000Z' },
+ ],
+ maxCount: 2,
+ });
+
+ expect(callRecordings.map((callRecording) => callRecording.id)).toEqual([
+ 'a',
+ 'b',
+ ]);
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/is-call-recording-in-progress.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/is-call-recording-in-progress.test.ts
new file mode 100644
index 00000000000..b4ae0b91b68
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/is-call-recording-in-progress.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest';
+
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+import { isCallRecordingInProgress } from 'src/front-components/utils/is-call-recording-in-progress.util';
+
+const buildCallRecording = (status: string | null): CallRecordingNode => ({
+ id: 'call-recording',
+ status,
+});
+
+describe('isCallRecordingInProgress', () => {
+ it.each(['RECORDING', 'PROCESSING'])('is true for %s', (status) => {
+ expect(isCallRecordingInProgress(buildCallRecording(status))).toBe(true);
+ });
+
+ it.each(['COMPLETED', null])('is false for %s', (status) => {
+ expect(isCallRecordingInProgress(buildCallRecording(status))).toBe(false);
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/resolve-call-recording-display-title.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/resolve-call-recording-display-title.test.ts
new file mode 100644
index 00000000000..6b8f85074be
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/resolve-call-recording-display-title.test.ts
@@ -0,0 +1,48 @@
+import { describe, expect, it } from 'vitest';
+
+import { RESTRICTED_FIELD_PLACEHOLDER } from 'src/logic-functions/constants/restricted-field-placeholder';
+import { resolveCallRecordingDisplayTitle } from 'src/front-components/utils/resolve-call-recording-display-title.util';
+
+describe('resolveCallRecordingDisplayTitle', () => {
+ it('uses the recording title', () => {
+ expect(
+ resolveCallRecordingDisplayTitle({
+ title: ' Weekly sync ',
+ calendarEvent: { id: 'event', title: 'Calendar title' },
+ }),
+ ).toBe('Weekly sync');
+ });
+
+ it('falls back to the meeting title', () => {
+ expect(
+ resolveCallRecordingDisplayTitle({
+ title: ' ',
+ calendarEvent: { id: 'event', title: 'Calendar title' },
+ }),
+ ).toBe('Calendar title');
+ });
+
+ it('ignores a meeting title the viewer is not allowed to see', () => {
+ expect(
+ resolveCallRecordingDisplayTitle({
+ title: null,
+ calendarEvent: { id: 'event', title: RESTRICTED_FIELD_PLACEHOLDER },
+ }),
+ ).toBe('Untitled call');
+ });
+
+ it('uses a short fallback without any title', () => {
+ expect(
+ resolveCallRecordingDisplayTitle({ title: null, calendarEvent: null }),
+ ).toBe('Untitled call');
+ });
+
+ it('ignores a recording title copied from a restricted meeting', () => {
+ expect(
+ resolveCallRecordingDisplayTitle({
+ title: RESTRICTED_FIELD_PLACEHOLDER,
+ calendarEvent: { id: 'event', title: 'Calendar title' },
+ }),
+ ).toBe('Calendar title');
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/fetch-call-recordings-for-record.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/fetch-call-recordings-for-record.util.ts
new file mode 100644
index 00000000000..67640c762db
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/fetch-call-recordings-for-record.util.ts
@@ -0,0 +1,239 @@
+import { isNonEmptyString, isString, isUndefined } from '@sniptt/guards';
+import { type CoreApiClient } from 'twenty-client-sdk/core';
+
+import { CALL_RECORDINGS_WIDGET_MAX_CALENDAR_EVENT_TARGET_PAGES } from 'src/front-components/constants/call-recordings-widget-max-calendar-event-target-pages.constant';
+import { CALL_RECORDINGS_WIDGET_MAX_CALL_RECORDINGS_PER_BATCH } from 'src/front-components/constants/call-recordings-widget-max-call-recordings-per-batch.constant';
+import { LISTED_CALL_RECORDING_STATUSES } from 'src/front-components/constants/listed-call-recording-statuses.constant';
+import { type CalendarEventTargetFieldName } from 'src/front-components/types/calendar-event-target-field-name.type';
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+import { getMostRecentCallRecordings } from 'src/front-components/utils/get-most-recent-call-recordings.util';
+import { isPermissionDeniedError } from 'src/front-components/utils/is-permission-denied-error.util';
+import { TWENTY_PAGE_SIZE } from 'src/logic-functions/constants/twenty-page-size';
+import {
+ fetchAllNodes,
+ type ConnectionPage,
+} from 'src/logic-functions/data/fetch-all-nodes.util';
+
+type QueryClient = Pick<CoreApiClient, 'query'>;
+
+type CalendarEventTargetNode = {
+ id: string;
+ calendarEventId?: string | null;
+};
+
+type CalendarEventTargetOrderBy = Array<Record<string, unknown>>;
+
+const BY_MEETING_DATE_ORDER_BY: CalendarEventTargetOrderBy = [
+ { calendarEvent: { startsAt: 'DescNullsLast' } },
+];
+
+const BY_TARGET_CREATION_ORDER_BY: CalendarEventTargetOrderBy = [
+ { createdAt: 'DescNullsLast' },
+];
+
+const fetchCalendarEventTargetPage = async ({
+ client,
+ calendarEventTargetFieldName,
+ recordId,
+ orderBy,
+ afterCursor,
+}: {
+ client: QueryClient;
+ calendarEventTargetFieldName: CalendarEventTargetFieldName;
+ recordId: string;
+ orderBy: CalendarEventTargetOrderBy;
+ afterCursor: string | undefined;
+}): Promise<ConnectionPage<CalendarEventTargetNode>> => {
+ const queryResult = await client.query({
+ calendarEventTargets: {
+ __args: {
+ filter: { [calendarEventTargetFieldName]: { eq: recordId } },
+ orderBy,
+ first: TWENTY_PAGE_SIZE,
+ ...(isUndefined(afterCursor) ? {} : { after: afterCursor }),
+ },
+ pageInfo: {
+ hasNextPage: true,
+ endCursor: true,
+ },
+ edges: {
+ node: {
+ id: true,
+ calendarEventId: true,
+ },
+ },
+ },
+ });
+
+ const connection = queryResult.calendarEventTargets as
+ | ConnectionPage<CalendarEventTargetNode>
+ | undefined;
+
+ if (isUndefined(connection)) {
+ throw new Error('Pagination query returned no connection');
+ }
+
+ return connection;
+};
+
+const fetchListedCallRecordingsForCalendarEventIds = async ({
+ client,
+ calendarEventIds,
+ isCalendarEventLoaded,
+}: {
+ client: QueryClient;
+ calendarEventIds: string[];
+ isCalendarEventLoaded: boolean;
+}): Promise<CallRecordingNode[]> => {
+ let fetchedCallRecordingCount = 0;
+
+ return fetchAllNodes<CallRecordingNode>(
+ async (afterCursor) => {
+ const queryResult = await client.query({
+ callRecordings: {
+ __args: {
+ filter: {
+ calendarEventId: { in: calendarEventIds },
+ status: { in: LISTED_CALL_RECORDING_STATUSES },
+ },
+ orderBy: [
+ { startedAt: 'DescNullsFirst' },
+ { createdAt: 'DescNullsLast' },
+ ],
+ first: TWENTY_PAGE_SIZE,
+ ...(isUndefined(afterCursor) ? {} : { after: afterCursor }),
+ },
+ pageInfo: {
+ hasNextPage: true,
+ endCursor: true,
+ },
+ edges: {
+ node: {
+ id: true,
+ title: true,
+ status: true,
+ startedAt: true,
+ endedAt: true,
+ createdAt: true,
+ calendarEventId: true,
+ ...(isCalendarEventLoaded
+ ? { calendarEvent: { id: true, title: true, startsAt: true } }
+ : {}),
+ },
+ },
+ },
+ });
+
+ const connection = queryResult.callRecordings as
+ | ConnectionPage<CallRecordingNode>
+ | undefined;
+
+ fetchedCallRecordingCount += connection?.edges?.length ?? 0;
+
+ return connection;
+ },
+ () =>
+ fetchedCallRecordingCount <
+ CALL_RECORDINGS_WIDGET_MAX_CALL_RECORDINGS_PER_BATCH,
+ );
+};
+
+// A record's newest meetings are often upcoming ones without a recording yet.
+export const fetchCallRecordingsForRecord = async ({
+ client,
+ calendarEventTargetFieldName,
+ recordId,
+ maxCount,
+}: {
+ client: QueryClient;
+ calendarEventTargetFieldName: CalendarEventTargetFieldName;
+ recordId: string;
+ maxCount: number;
+}): Promise<CallRecordingNode[]> => {
+ const seenCalendarEventIds = new Set<string>();
+ const callRecordings: CallRecordingNode[] = [];
+ let orderBy = BY_MEETING_DATE_ORDER_BY;
+ let isCalendarEventLoaded = true;
+ let afterCursor: string | undefined;
+ let hasNextPage = true;
+ let fetchedPageCount = 0;
+
+ const fetchTargetPage = () =>
+ fetchCalendarEventTargetPage({
+ client,
+ calendarEventTargetFieldName,
+ recordId,
+ orderBy,
+ afterCursor,
+ });
+
+ const fetchRecordings = (calendarEventIds: string[]) =>
+ fetchListedCallRecordingsForCalendarEventIds({
+ client,
+ calendarEventIds,
+ isCalendarEventLoaded,
+ });
+
+ // Target creation order is not meeting order, so the fallback reads every page.
+ const hasEnoughCallRecordings = () =>
+ orderBy === BY_MEETING_DATE_ORDER_BY && callRecordings.length >= maxCount;
+
+ while (
+ hasNextPage &&
+ !hasEnoughCallRecordings() &&
+ fetchedPageCount < CALL_RECORDINGS_WIDGET_MAX_CALENDAR_EVENT_TARGET_PAGES
+ ) {
+ let targetPage: ConnectionPage<CalendarEventTargetNode>;
+
+ try {
+ targetPage = await fetchTargetPage();
+ } catch (error) {
+ if (fetchedPageCount > 0 || !isPermissionDeniedError(error)) {
+ throw error;
+ }
+
+ // Ordering through the meeting needs read access to it.
+ orderBy = BY_TARGET_CREATION_ORDER_BY;
+ isCalendarEventLoaded = false;
+ targetPage = await fetchTargetPage();
+ }
+
+ fetchedPageCount += 1;
+
+ const newCalendarEventIds = [
+ ...new Set(
+ (targetPage.edges ?? [])
+ .map((edge) => edge.node.calendarEventId)
+ .filter(isNonEmptyString)
+ .filter(
+ (calendarEventId) => !seenCalendarEventIds.has(calendarEventId),
+ ),
+ ),
+ ];
+
+ newCalendarEventIds.forEach((calendarEventId) =>
+ seenCalendarEventIds.add(calendarEventId),
+ );
+
+ if (newCalendarEventIds.length > 0) {
+ try {
+ callRecordings.push(...(await fetchRecordings(newCalendarEventIds)));
+ } catch (error) {
+ if (!isCalendarEventLoaded || !isPermissionDeniedError(error)) {
+ throw error;
+ }
+
+ isCalendarEventLoaded = false;
+ callRecordings.push(...(await fetchRecordings(newCalendarEventIds)));
+ }
+ }
+
+ const endCursor = targetPage.pageInfo?.endCursor;
+
+ hasNextPage =
+ (targetPage.pageInfo?.hasNextPage ?? false) && isString(endCursor);
+ afterCursor = isString(endCursor) ? endCursor : undefined;
+ }
+
+ return getMostRecentCallRecordings({ callRecordings, maxCount });
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/format-call-recording-date.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/format-call-recording-date.util.ts
new file mode 100644
index 00000000000..9bdeddcd695
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/format-call-recording-date.util.ts
@@ -0,0 +1,77 @@
+import { isUndefined } from '@sniptt/guards';
+
+import { getTimestamp } from 'src/front-components/utils/get-timestamp.util';
+
+const CURRENT_YEAR_DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
+ month: 'short',
+ day: 'numeric',
+};
+
+const OTHER_YEAR_DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+};
+
+const dateTimeFormatByKey = new Map<string, Intl.DateTimeFormat>();
+
+const createDateTimeFormat = ({
+ locale,
+ formatOptions,
+}: {
+ locale: string | undefined;
+ formatOptions: Intl.DateTimeFormatOptions;
+}) => {
+ try {
+ return new Intl.DateTimeFormat(locale, formatOptions);
+ } catch {
+ // Host locales such as pseudo-locales are not always valid BCP 47 tags.
+ return new Intl.DateTimeFormat(undefined, formatOptions);
+ }
+};
+
+const getDateTimeFormat = ({
+ locale,
+ isCurrentYear,
+}: {
+ locale: string | undefined;
+ isCurrentYear: boolean;
+}) => {
+ const formatKey = `${locale ?? ''}:${isCurrentYear}`;
+ const cachedDateTimeFormat = dateTimeFormatByKey.get(formatKey);
+
+ if (!isUndefined(cachedDateTimeFormat)) {
+ return cachedDateTimeFormat;
+ }
+
+ const dateTimeFormat = createDateTimeFormat({
+ locale,
+ formatOptions: isCurrentYear
+ ? CURRENT_YEAR_DATE_FORMAT_OPTIONS
+ : OTHER_YEAR_DATE_FORMAT_OPTIONS,
+ });
+
+ dateTimeFormatByKey.set(formatKey, dateTimeFormat);
+
+ return dateTimeFormat;
+};
+
+export const formatCallRecordingDate = ({
+ dateTime,
+ locale,
+ now = new Date(),
+}: {
+ dateTime: string | null | undefined;
+ locale: string | undefined;
+ now?: Date;
+}): string | undefined => {
+ const timestamp = getTimestamp(dateTime);
+
+ if (isUndefined(timestamp)) {
+ return undefined;
+ }
+
+ const isCurrentYear = new Date(timestamp).getFullYear() === now.getFullYear();
+
+ return getDateTimeFormat({ locale, isCurrentYear }).format(timestamp);
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/format-call-recording-duration.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/format-call-recording-duration.util.ts
new file mode 100644
index 00000000000..41b9fc6deac
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/format-call-recording-duration.util.ts
@@ -0,0 +1,42 @@
+import { isUndefined } from '@sniptt/guards';
+
+import { getTimestamp } from 'src/front-components/utils/get-timestamp.util';
+
+const SECONDS_PER_MINUTE = 60;
+const SECONDS_PER_HOUR = 3600;
+
+export const formatCallRecordingDuration = ({
+ startedAt,
+ endedAt,
+}: {
+ startedAt: string | null | undefined;
+ endedAt: string | null | undefined;
+}): string | undefined => {
+ const startTimestamp = getTimestamp(startedAt);
+ const endTimestamp = getTimestamp(endedAt);
+
+ if (isUndefined(startTimestamp) || isUndefined(endTimestamp)) {
+ return undefined;
+ }
+
+ const durationInSeconds = Math.round((endTimestamp - startTimestamp) / 1000);
+
+ if (durationInSeconds < 0) {
+ return undefined;
+ }
+
+ if (durationInSeconds < SECONDS_PER_MINUTE) {
+ return `${durationInSeconds}s`;
+ }
+
+ if (durationInSeconds < SECONDS_PER_HOUR) {
+ return `${Math.floor(durationInSeconds / SECONDS_PER_MINUTE)}m`;
+ }
+
+ const hours = Math.floor(durationInSeconds / SECONDS_PER_HOUR);
+ const minutes = Math.floor(
+ (durationInSeconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE,
+ );
+
+ return `${hours}h ${minutes.toString().padStart(2, '0')}m`;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-calendar-event-target-field-name.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-calendar-event-target-field-name.util.ts
new file mode 100644
index 00000000000..407dabe89a5
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-calendar-event-target-field-name.util.ts
@@ -0,0 +1,16 @@
+import { type CalendarEventTargetFieldName } from 'src/front-components/types/calendar-event-target-field-name.type';
+
+export const getCalendarEventTargetFieldName = (
+ objectNameSingular: string | undefined,
+): CalendarEventTargetFieldName | undefined => {
+ switch (objectNameSingular) {
+ case 'person':
+ return 'targetPersonId';
+ case 'company':
+ return 'targetCompanyId';
+ case 'opportunity':
+ return 'targetOpportunityId';
+ default:
+ return undefined;
+ }
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-call-recording-display-date.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-call-recording-display-date.util.ts
new file mode 100644
index 00000000000..42913dc896a
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-call-recording-display-date.util.ts
@@ -0,0 +1,11 @@
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+
+export const getCallRecordingDisplayDate = (
+ callRecording: Pick<
+ CallRecordingNode,
+ 'startedAt' | 'createdAt' | 'calendarEvent'
+ >,
+): string | null | undefined =>
+ callRecording.startedAt ??
+ callRecording.calendarEvent?.startsAt ??
+ callRecording.createdAt;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-call-recording-status-tag.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-call-recording-status-tag.util.ts
new file mode 100644
index 00000000000..7f4b6e4bcf5
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-call-recording-status-tag.util.ts
@@ -0,0 +1,16 @@
+import { type CallRecordingStatusTag } from 'src/front-components/types/call-recording-status-tag.type';
+import { CallRecordingStatus } from 'src/logic-functions/constants/call-recording-status';
+
+// Same labels and colors as core's callRecording.status select options.
+export const getCallRecordingStatusTag = (
+ status: string | null | undefined,
+): CallRecordingStatusTag | undefined => {
+ switch (status) {
+ case CallRecordingStatus.RECORDING:
+ return { text: 'Recording', color: 'red' };
+ case CallRecordingStatus.PROCESSING:
+ return { text: 'Processing', color: 'orange' };
+ default:
+ return undefined;
+ }
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-most-recent-call-recordings.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-most-recent-call-recordings.util.ts
new file mode 100644
index 00000000000..bc90d8562dc
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-most-recent-call-recordings.util.ts
@@ -0,0 +1,42 @@
+import { isUndefined } from '@sniptt/guards';
+
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+import { getCallRecordingDisplayDate } from 'src/front-components/utils/get-call-recording-display-date.util';
+import { getTimestamp } from 'src/front-components/utils/get-timestamp.util';
+
+const compareCallRecordingsByDisplayDate = (
+ firstCallRecording: CallRecordingNode,
+ secondCallRecording: CallRecordingNode,
+): number => {
+ const firstTimestamp = getTimestamp(
+ getCallRecordingDisplayDate(firstCallRecording),
+ );
+ const secondTimestamp = getTimestamp(
+ getCallRecordingDisplayDate(secondCallRecording),
+ );
+
+ if (isUndefined(firstTimestamp) !== isUndefined(secondTimestamp)) {
+ return isUndefined(firstTimestamp) ? 1 : -1;
+ }
+
+ return (
+ (secondTimestamp ?? 0) - (firstTimestamp ?? 0) ||
+ firstCallRecording.id.localeCompare(secondCallRecording.id)
+ );
+};
+
+export const getMostRecentCallRecordings = ({
+ callRecordings,
+ maxCount,
+}: {
+ callRecordings: CallRecordingNode[];
+ maxCount: number;
+}): CallRecordingNode[] => {
+ const callRecordingsById = new Map(
+ callRecordings.map((callRecording) => [callRecording.id, callRecording]),
+ );
+
+ return [...callRecordingsById.values()]
+ .sort(compareCallRecordingsByDisplayDate)
+ .slice(0, maxCount);
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-timestamp.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-timestamp.util.ts
new file mode 100644
index 00000000000..c35ec4c6035
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-timestamp.util.ts
@@ -0,0 +1,13 @@
+import { isNonEmptyString } from '@sniptt/guards';
+
+export const getTimestamp = (
+ dateTime: string | null | undefined,
+): number | undefined => {
+ if (!isNonEmptyString(dateTime)) {
+ return undefined;
+ }
+
+ const timestamp = new Date(dateTime).getTime();
+
+ return Number.isNaN(timestamp) ? undefined : timestamp;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/is-call-recording-in-progress.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/is-call-recording-in-progress.util.ts
new file mode 100644
index 00000000000..5225b1f7522
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/is-call-recording-in-progress.util.ts
@@ -0,0 +1,9 @@
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+import { NON_TERMINAL_CALL_RECORDING_STATUSES } from 'src/logic-functions/constants/non-terminal-call-recording-statuses';
+
+export const isCallRecordingInProgress = (
+ callRecording: Pick<CallRecordingNode, 'status'>,
+) =>
+ NON_TERMINAL_CALL_RECORDING_STATUSES.some(
+ (status) => status === callRecording.status,
+ );
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/resolve-call-recording-display-title.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/resolve-call-recording-display-title.util.ts
new file mode 100644
index 00000000000..f7e468431d4
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/utils/resolve-call-recording-display-title.util.ts
@@ -0,0 +1,12 @@
+import { UNTITLED_CALL_RECORDING_TITLE } from 'src/front-components/constants/untitled-call-recording-title.constant';
+import { type CallRecordingNode } from 'src/front-components/types/call-recording-node.type';
+import { getFirstNonEmptyString } from 'src/front-components/utils/get-first-non-empty-string.util';
+import { stripRestrictedFieldValue } from 'src/logic-functions/data/strip-restricted-field-value.util';
+
+export const resolveCallRecordingDisplayTitle = (
+ callRecording: Pick<CallRecordingNode, 'title' | 'calendarEvent'>,
+): string =>
+ getFirstNonEmptyString([
+ stripRestrictedFieldValue(callRecording.title ?? undefined),
+ stripRestrictedFieldValue(callRecording.calendarEvent?.title ?? undefined),
+ ]) ?? UNTITLED_CALL_RECORDING_TITLE;