Skip to content

The open alternative to Salesforce, designed for AI.

Call recorder: add recorder styles for the bot camera tile (#29498)

nitin80ba374c9574
diff --git a/packages/twenty-apps/public/call-recorder/package.json b/packages/twenty-apps/public/call-recorder/package.json
index c4fa01555d7..f64edc555d5 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.19.0",
+ "version": "1.20.0",
"license": "MIT",
"engines": {
"node": "^24.5.0",
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/minimal-not-recording.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/minimal-not-recording.jpg
new file mode 100644
index 00000000000..433ddb1bb67
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/minimal-not-recording.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/minimal-recording.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/minimal-recording.jpg
new file mode 100644
index 00000000000..5df3aa4bc89
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/minimal-recording.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/twenty-not-recording.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/twenty-not-recording.jpg
new file mode 100644
index 00000000000..eaf091daaa2
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/twenty-not-recording.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/twenty-recording.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/twenty-recording.jpg
new file mode 100644
index 00000000000..d5a6472abda
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/frames/twenty-recording.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/minimal.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/minimal.jpg
new file mode 100644
index 00000000000..5c3bc020f9d
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/minimal.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/none.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/none.jpg
new file mode 100644
index 00000000000..c53a7800aff
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/none.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/twenty.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/twenty.jpg
new file mode 100644
index 00000000000..36df4a4ca10
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/twenty.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpg b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpg
new file mode 100644
index 00000000000..9cd5568a0f3
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/previews/workspace.jpg differ
diff --git a/packages/twenty-apps/public/call-recorder/public/camera-tile/workspace-background.png b/packages/twenty-apps/public/call-recorder/public/camera-tile/workspace-background.png
new file mode 100644
index 00000000000..73a23901ab4
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/camera-tile/workspace-background.png differ
diff --git a/packages/twenty-apps/public/call-recorder/public/fonts/Inter-OFL.txt b/packages/twenty-apps/public/call-recorder/public/fonts/Inter-OFL.txt
new file mode 100644
index 00000000000..21f6aff9610
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/public/fonts/Inter-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/packages/twenty-apps/public/call-recorder/public/fonts/Inter-SemiBold.ttf b/packages/twenty-apps/public/call-recorder/public/fonts/Inter-SemiBold.ttf
new file mode 100644
index 00000000000..67fda287e7f
Binary files /dev/null and b/packages/twenty-apps/public/call-recorder/public/fonts/Inter-SemiBold.ttf differ
diff --git a/packages/twenty-apps/public/call-recorder/src/__tests__/application-config.test.ts b/packages/twenty-apps/public/call-recorder/src/__tests__/application-config.test.ts
index be2afd6e974..b16952616be 100644
--- a/packages/twenty-apps/public/call-recorder/src/__tests__/application-config.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/__tests__/application-config.test.ts
@@ -2,6 +2,8 @@ import { describe, expect, it } from 'vitest';
import applicationConfig from 'src/application-config';
import { CALL_RECORDER_MAPPED_VARIABLE_KEYS } from 'src/front-components/constants/call-recorder-settings-layout.constant';
+import { CALL_RECORDER_STYLE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-style-env-var-name';
+import { CALL_RECORDER_STYLES } from 'src/logic-functions/constants/call-recorder-styles';
import { CALL_RECORDER_TRANSCRIPT_PROVIDER_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-transcript-provider-env-var-name';
import { RECALL_ASYNC_TRANSCRIPT_PROVIDERS } from 'src/logic-functions/constants/recall-async-transcript-providers';
@@ -10,9 +12,26 @@ describe('application config', () => {
expect(applicationConfig.errors).toEqual([]);
});
- it('lays out every application variable in the settings component', () => {
+ it('lays out every non-deprecated application variable in the settings component', () => {
+ const activeVariableKeys = Object.entries(
+ applicationConfig.config.applicationVariables ?? {},
+ )
+ .filter(([, variable]) => variable.isDeprecated !== true)
+ .map(([key]) => key);
+
expect([...CALL_RECORDER_MAPPED_VARIABLE_KEYS].sort()).toEqual(
- Object.keys(applicationConfig.config.applicationVariables ?? {}).sort(),
+ activeVariableKeys.sort(),
+ );
+ });
+
+ it('offers every recorder style as a select option', () => {
+ const options =
+ applicationConfig.config.applicationVariables?.[
+ CALL_RECORDER_STYLE_ENV_VAR_NAME
+ ]?.options ?? [];
+
+ expect(options.map((option) => option.value).sort()).toEqual(
+ [...CALL_RECORDER_STYLES].sort(),
);
});
diff --git a/packages/twenty-apps/public/call-recorder/src/__tests__/call-recorder-lifecycle.integration-test.ts b/packages/twenty-apps/public/call-recorder/src/__tests__/call-recorder-lifecycle.integration-test.ts
index 74d95002ac1..e856123b486 100644
--- a/packages/twenty-apps/public/call-recorder/src/__tests__/call-recorder-lifecycle.integration-test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/__tests__/call-recorder-lifecycle.integration-test.ts
@@ -932,7 +932,7 @@ describe('call recorder app lifecycle (integration)', () => {
);
vi.stubEnv('RECALL_API_KEY', 'recall-api-key');
vi.stubEnv('RECALL_REGION', 'us-west-2');
- vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+ vi.stubEnv('CALL_RECORDER_STYLE', 'NONE');
// Logic functions normally run with an app access token; the workspace
// API key is a token with the same workspaceId claim.
vi.stubEnv(
diff --git a/packages/twenty-apps/public/call-recorder/src/application-config.ts b/packages/twenty-apps/public/call-recorder/src/application-config.ts
index 60d4d842a74..b2944c64fb7 100644
--- a/packages/twenty-apps/public/call-recorder/src/application-config.ts
+++ b/packages/twenty-apps/public/call-recorder/src/application-config.ts
@@ -3,11 +3,11 @@ import { defineApplication, FieldType } from 'twenty-sdk/define';
import { APP_DESCRIPTION } from 'src/constants/app-description';
import { APP_DISPLAY_NAME } from 'src/constants/app-display-name';
import { CALL_RECORDING_BILLABLE_OPERATION_NAME } from 'src/constants/call-recording-billable-operation-name';
+import { CALL_RECORDER_STYLE_OPTIONS } from 'src/constants/call-recorder-style-options';
import { CALL_RECORDER_TRANSCRIPT_PROVIDER_OPTIONS } from 'src/constants/call-recorder-transcript-provider-options';
import {
APPLICATION_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_ADDITIONAL_SUMMARY_PROMPT_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
- CALL_RECORDER_BOT_IMAGE_BACKGROUND_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_CALENDAR_BOT_SCHEDULING_ENABLED_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_EVERYONE_LEFT_TIMEOUT_SECONDS_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_JOIN_EARLY_MINUTES_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
@@ -15,12 +15,12 @@ import {
CALL_RECORDER_NOONE_JOINED_TIMEOUT_SECONDS_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_RECORDING_NOTICE_ENABLED_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_RECORDING_NOTICE_MESSAGE_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
+ CALL_RECORDER_STYLE_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_SUMMARY_ENABLED_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_TRANSCRIPT_PROVIDER_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_USE_WORKSPACE_LOGO_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
CALL_RECORDER_WAITING_ROOM_TIMEOUT_SECONDS_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
} from 'src/constants/universal-identifiers';
-import { CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-bot-image-background-env-var-name';
import { CALL_RECORDER_CALENDAR_BOT_SCHEDULING_ENABLED_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-calendar-bot-scheduling-enabled-env-var-name';
import { CALL_RECORDER_EVERYONE_LEFT_TIMEOUT_SECONDS } from 'src/logic-functions/constants/call-recorder-everyone-left-timeout-seconds';
import { CALL_RECORDER_EVERYONE_LEFT_TIMEOUT_SECONDS_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-everyone-left-timeout-seconds-env-var-name';
@@ -33,18 +33,19 @@ import { CALL_RECORDER_RECORDING_NOTICE_MAX_LENGTH } from 'src/logic-functions/c
import { CALL_RECORDER_RECORDING_NOTICE_MESSAGE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-recording-notice-message-env-var-name';
import { CALL_RECORDER_RECORDING_RETENTION_HOURS_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-recording-retention-hours-env-var-name';
import { CALL_RECORDER_ADDITIONAL_SUMMARY_PROMPT_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-additional-summary-prompt-env-var-name';
+import { CALL_RECORDER_STYLE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-style-env-var-name';
import { CALL_RECORDER_SUMMARY_ENABLED_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-summary-enabled-env-var-name';
import { CALL_RECORDER_TRANSCRIPT_PROVIDER_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-transcript-provider-env-var-name';
import { CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-use-workspace-logo-env-var-name';
import { CALL_RECORDER_WAITING_ROOM_TIMEOUT_SECONDS } from 'src/logic-functions/constants/call-recorder-waiting-room-timeout-seconds';
import { CALL_RECORDER_WAITING_ROOM_TIMEOUT_SECONDS_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-waiting-room-timeout-seconds-env-var-name';
-import { DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND } from 'src/logic-functions/constants/default-call-recorder-bot-image-background';
import { DEFAULT_CALL_RECORDER_CALENDAR_BOT_SCHEDULING_ENABLED } from 'src/logic-functions/constants/default-call-recorder-calendar-bot-scheduling-enabled';
import { DEFAULT_CALL_RECORDER_JOIN_EARLY_MINUTES } from 'src/logic-functions/constants/default-call-recorder-join-early-minutes';
import { DEFAULT_CALL_RECORDER_NAME } from 'src/logic-functions/constants/default-call-recorder-name';
import { DEFAULT_CALL_RECORDER_RECORDING_NOTICE_ENABLED } from 'src/logic-functions/constants/default-call-recorder-recording-notice-enabled';
import { DEFAULT_CALL_RECORDER_RECORDING_NOTICE_MESSAGE } from 'src/logic-functions/constants/default-call-recorder-recording-notice-message';
import { DEFAULT_CALL_RECORDER_RECORDING_RETENTION_HOURS } from 'src/logic-functions/constants/default-call-recorder-recording-retention-hours';
+import { DEFAULT_CALL_RECORDER_STYLE } from 'src/logic-functions/constants/default-call-recorder-style';
import { DEFAULT_CALL_RECORDER_SUMMARY_ENABLED } from 'src/logic-functions/constants/default-call-recorder-summary-enabled';
import { DEFAULT_CALL_RECORDER_TRANSCRIPT_PROVIDER } from 'src/logic-functions/constants/default-call-recorder-transcript-provider';
import { DEFAULT_CALL_RECORDER_USE_WORKSPACE_LOGO } from 'src/logic-functions/constants/default-call-recorder-use-workspace-logo';
@@ -179,26 +180,27 @@ export default defineApplication({
isSecret: false,
type: FieldType.RICH_TEXT,
},
+ [CALL_RECORDER_STYLE_ENV_VAR_NAME]: {
+ universalIdentifier:
+ CALL_RECORDER_STYLE_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
+ label: 'Recorder style',
+ description:
+ 'What the bot shows on its camera tile: Twenty branding, the workspace logo and name, the word Twenty alone, or no image.',
+ isSecret: false,
+ type: FieldType.SELECT,
+ options: CALL_RECORDER_STYLE_OPTIONS,
+ value: DEFAULT_CALL_RECORDER_STYLE,
+ },
[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME]: {
universalIdentifier:
CALL_RECORDER_USE_WORKSPACE_LOGO_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
label: 'Use workspace logo',
- description:
- 'Whether the bot displays the workspace logo on its camera tile while in a call. Set to false to disable.',
+ description: 'Replaced by the recorder style.',
isSecret: false,
+ isDeprecated: true,
type: FieldType.BOOLEAN,
value: DEFAULT_CALL_RECORDER_USE_WORKSPACE_LOGO,
},
- [CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME]: {
- universalIdentifier:
- CALL_RECORDER_BOT_IMAGE_BACKGROUND_APP_VARIABLE_UNIVERSAL_IDENTIFIER,
- label: 'Bot camera background color',
- description:
- 'Hex color (e.g. #ffffff) drawn behind the workspace logo on the bot camera tile. Defaults to dark gray when unset or invalid.',
- isSecret: false,
- type: FieldType.TEXT,
- value: DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND,
- },
},
serverVariables: {
[RECALL_API_KEY_ENV_VAR_NAME]: {
diff --git a/packages/twenty-apps/public/call-recorder/src/constants/call-recorder-style-options.ts b/packages/twenty-apps/public/call-recorder/src/constants/call-recorder-style-options.ts
new file mode 100644
index 00000000000..9017b832ddf
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/constants/call-recorder-style-options.ts
@@ -0,0 +1,11 @@
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+export const CALL_RECORDER_STYLE_OPTIONS: {
+ label: string;
+ value: CallRecorderStyle;
+}[] = [
+ { label: 'Twenty', value: 'TWENTY' },
+ { label: 'Workspace', value: 'WORKSPACE' },
+ { label: 'Minimal', value: 'MINIMAL' },
+ { label: 'None', value: 'NONE' },
+];
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 b1be9688cf5..3392f4dc8c7 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
@@ -19,9 +19,6 @@ export const CALL_PARTICIPANTS_ON_CALL_RECORDING_PAGE_LAYOUT_WIDGET_UNIVERSAL_ID
export const CALL_RECORDER_ADDITIONAL_SUMMARY_PROMPT_APP_VARIABLE_UNIVERSAL_IDENTIFIER =
'587ead10-c514-468c-944f-17050c88dcc1';
-export const CALL_RECORDER_BOT_IMAGE_BACKGROUND_APP_VARIABLE_UNIVERSAL_IDENTIFIER =
- 'fd0d9495-29ae-443e-84f9-4ec4d1f2d16a';
-
export const CALL_RECORDER_CALENDAR_BOT_SCHEDULING_ENABLED_APP_VARIABLE_UNIVERSAL_IDENTIFIER =
'e1cf956b-356f-468d-b5d9-044ed5fd9e5b';
@@ -49,6 +46,9 @@ export const CALL_RECORDER_RECORDING_NOTICE_ENABLED_APP_VARIABLE_UNIVERSAL_IDENT
export const CALL_RECORDER_RECORDING_NOTICE_MESSAGE_APP_VARIABLE_UNIVERSAL_IDENTIFIER =
'7103451a-2c46-4c16-bc2c-a9f28b329ee5';
+export const CALL_RECORDER_STYLE_APP_VARIABLE_UNIVERSAL_IDENTIFIER =
+ '55efa8ca-f9f6-49ec-a5fa-835310bbb3b2';
+
export const CALL_RECORDER_SUMMARY_ENABLED_APP_VARIABLE_UNIVERSAL_IDENTIFIER =
'1d7bf052-4338-44da-b373-23f6d291a50c';
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/AdornedHexInput.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/AdornedHexInput.tsx
deleted file mode 100644
index 9a0945bed3c..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/AdornedHexInput.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import styled from '@emotion/styled';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-import { SettingsColorSample } from 'src/front-components/components/SettingsColorSample';
-import { StyledSettingsTextInput } from 'src/front-components/components/StyledSettingsTextInput';
-
-const StyledContainer = styled.div`
- align-items: center;
- background-color: ${() => themeCssVariables.background.transparent.light};
- border: 1px solid ${() => themeCssVariables.border.color.medium};
- border-radius: ${() => themeCssVariables.border.radius.md};
- box-sizing: border-box;
- display: flex;
- height: 32px;
- width: 100%;
-
- &:focus-within {
- border-color: ${() => themeCssVariables.color.blue};
- }
-`;
-
-const StyledAdornmentContainer = styled.div`
- align-items: center;
- display: flex;
- padding: ${() => themeCssVariables.spacing[2]};
-`;
-
-const StyledAdornedInput = styled(StyledSettingsTextInput)`
- background-color: transparent;
- border: none;
- border-radius: 0;
- height: 100%;
-`;
-
-type AdornedHexInputProps = {
- id: string;
- value: string;
- swatchColor: string;
- onChange: (value: string) => void;
- onBlur?: () => void;
-};
-
-export const AdornedHexInput = ({
- id,
- value,
- swatchColor,
- onChange,
- onBlur,
-}: AdornedHexInputProps) => (
- <StyledContainer>
- <StyledAdornmentContainer>
- <SettingsColorSample colorName="gray" color={swatchColor} />
- </StyledAdornmentContainer>
- <StyledAdornedInput
- id={id}
- type="text"
- autoComplete="off"
- placeholder="#1d1d1d"
- value={value}
- onChange={(event) => onChange(event.target.value)}
- onBlur={onBlur}
- />
- </StyledContainer>
-);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CameraTileStyleOption.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CameraTileStyleOption.tsx
new file mode 100644
index 00000000000..085143e1e3e
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CameraTileStyleOption.tsx
@@ -0,0 +1,119 @@
+import styled from '@emotion/styled';
+import { useId } from 'react';
+import { getPublicAssetUrl } from 'twenty-sdk/utils';
+import { IconCheck } from 'twenty-ui/icon';
+import { Radio } from 'twenty-ui/primitives/input';
+import { THEME_COMMON, themeCssVariables } from 'twenty-ui/theme';
+
+import { CAMERA_TILE_PREVIEW_ASSET_PATHS } from 'src/front-components/constants/camera-tile-preview-asset-paths.constant';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+const StyledChoice = styled.label`
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+`;
+
+const StyledTile = styled.div`
+ border-radius: ${() => themeCssVariables.border.radius.md};
+ cursor: pointer;
+ display: block;
+ overflow: hidden;
+ position: relative;
+ width: 100%;
+
+ &::after {
+ border-radius: inherit;
+ box-shadow: inset 0 0 0 1px ${() => themeCssVariables.border.color.medium};
+ content: '';
+ inset: 0;
+ pointer-events: none;
+ position: absolute;
+ }
+
+ &:focus-visible {
+ outline: 2px solid ${() => themeCssVariables.color.blue};
+ outline-offset: 1px;
+ }
+`;
+
+const StyledCheckmark = styled.div`
+ align-items: center;
+ background-color: ${() => themeCssVariables.color.blue};
+ border-radius: ${() => themeCssVariables.border.radius.rounded};
+ bottom: ${() => themeCssVariables.spacing[2]};
+ color: ${() => themeCssVariables.grayScale.gray1};
+ corner-shape: round;
+ display: flex;
+ height: ${() => themeCssVariables.spacing[5]};
+ inset-inline-end: ${() => themeCssVariables.spacing[2]};
+ justify-content: center;
+ opacity: 0;
+ position: absolute;
+ transition:
+ opacity 0.3s ease-in-out,
+ visibility 0s linear 0.3s;
+ visibility: hidden;
+ width: ${() => themeCssVariables.spacing[5]};
+ z-index: 1;
+
+ &[data-checked] {
+ opacity: 1;
+ transition:
+ opacity 0.3s ease-in-out,
+ visibility 0s;
+ visibility: visible;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ &,
+ &[data-checked] {
+ transition: none;
+ }
+ }
+`;
+
+const StyledPreviewImage = styled.img`
+ aspect-ratio: 16 / 9;
+ display: block;
+ object-fit: cover;
+ width: 100%;
+`;
+
+const StyledChoiceLabel = styled.span`
+ color: ${() => themeCssVariables.font.color.secondary};
+ font-size: ${() => themeCssVariables.font.size.xs};
+ font-weight: ${() => themeCssVariables.font.weight.medium};
+ margin-top: ${() => themeCssVariables.spacing[2]};
+`;
+
+type CameraTileStyleOptionProps = {
+ style: CallRecorderStyle;
+ label: string;
+};
+
+export const CameraTileStyleOption = ({
+ style,
+ label,
+}: CameraTileStyleOptionProps) => {
+ const labelId = useId();
+
+ return (
+ <StyledChoice>
+ <Radio.Root
+ value={style}
+ aria-labelledby={labelId}
+ render={<StyledTile />}
+ >
+ <StyledPreviewImage
+ src={getPublicAssetUrl(CAMERA_TILE_PREVIEW_ASSET_PATHS[style])}
+ alt=""
+ />
+ <Radio.Indicator keepMounted aria-hidden render={<StyledCheckmark />}>
+ <IconCheck size={THEME_COMMON.icon.size.sm} />
+ </Radio.Indicator>
+ </Radio.Root>
+ <StyledChoiceLabel id={labelId}>{label}</StyledChoiceLabel>
+ </StyledChoice>
+ );
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CameraTileStylePicker.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CameraTileStylePicker.tsx
new file mode 100644
index 00000000000..73510235019
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CameraTileStylePicker.tsx
@@ -0,0 +1,52 @@
+import styled from '@emotion/styled';
+import { RadioGroup } from 'twenty-ui/primitives/input';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { CALL_RECORDER_STYLE_OPTIONS } from 'src/constants/call-recorder-style-options';
+import { CameraTileStyleOption } from 'src/front-components/components/CameraTileStyleOption';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+const TWO_COLUMN_MAX_WIDTH = '560px';
+
+const StyledChoices = styled.div`
+ && {
+ display: grid;
+ gap: ${() => themeCssVariables.spacing[4]};
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ width: 100%;
+ }
+
+ @media (max-width: ${TWO_COLUMN_MAX_WIDTH}) {
+ && {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+ }
+`;
+
+type CameraTileStylePickerProps = {
+ labelId: string;
+ value: CallRecorderStyle;
+ onChange: (style: CallRecorderStyle) => void;
+};
+
+export const CameraTileStylePicker = ({
+ labelId,
+ value,
+ onChange,
+}: CameraTileStylePickerProps) => (
+ <RadioGroup
+ orientation="horizontal"
+ render={<StyledChoices />}
+ aria-labelledby={labelId}
+ value={value}
+ onValueChange={onChange}
+ >
+ {CALL_RECORDER_STYLE_OPTIONS.map((option) => (
+ <CameraTileStyleOption
+ key={option.value}
+ style={option.value}
+ label={option.label}
+ />
+ ))}
+ </RadioGroup>
+);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/DropdownMenuSeparator.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/DropdownMenuSeparator.tsx
deleted file mode 100644
index 2161848b15b..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/DropdownMenuSeparator.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import styled from '@emotion/styled';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-const StyledDropdownMenuSeparator = styled.div`
- background-color: ${() => themeCssVariables.border.color.light};
- min-height: 1px;
- width: 100%;
-`;
-
-export const DropdownMenuSeparator = () => <StyledDropdownMenuSeparator />;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/LabelledSettingsField.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/LabelledSettingsField.tsx
index 6accac38cae..4cb443ed9f6 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/LabelledSettingsField.tsx
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/LabelledSettingsField.tsx
@@ -28,7 +28,8 @@ const StyledHint = styled.span`
type LabelledSettingsFieldProps = {
label: string;
- inputId: string;
+ inputId?: string;
+ labelId?: string;
hint?: string;
errorMessage?: string;
children: ReactNode;
@@ -37,12 +38,15 @@ type LabelledSettingsFieldProps = {
export const LabelledSettingsField = ({
label,
inputId,
+ labelId,
hint,
errorMessage,
children,
}: LabelledSettingsFieldProps) => (
<StyledField>
- <StyledLabel htmlFor={inputId}>{label}</StyledLabel>
+ <StyledLabel id={labelId} htmlFor={inputId}>
+ {label}
+ </StyledLabel>
{children}
{isNonEmptyString(errorMessage) && (
<StyledSettingsError>{errorMessage}</StyledSettingsError>
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/RecorderSection.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/RecorderSection.tsx
index 7703a6a0a2c..c73b270e668 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/RecorderSection.tsx
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/RecorderSection.tsx
@@ -1,101 +1,57 @@
-import { isUndefined } from '@sniptt/guards';
import { useId, useState } from 'react';
import { Section } from 'twenty-ui/components/layout';
-import { type ThemeColor } from 'twenty-ui/theme';
-import { AdornedHexInput } from 'src/front-components/components/AdornedHexInput';
+import { CameraTileStylePicker } from 'src/front-components/components/CameraTileStylePicker';
import { LabelledSettingsField } from 'src/front-components/components/LabelledSettingsField';
-import { SettingsOptionCardContentSelect } from 'src/front-components/components/SettingsOptionCardContentSelect';
-import { SettingsOptionCardContentToggle } from 'src/front-components/components/SettingsOptionCardContentToggle';
-import { StyledDimmable } from 'src/front-components/components/StyledDimmable';
-import { StyledSettingsCard } from 'src/front-components/components/StyledSettingsCard';
import { StyledSettingsSectionStack } from 'src/front-components/components/StyledSettingsSectionStack';
import { StyledSettingsTextInput } from 'src/front-components/components/StyledSettingsTextInput';
-import { TileBackgroundControl } from 'src/front-components/components/TileBackgroundControl';
import {
CALL_RECORDER_NAME_FIELD,
- CALL_RECORDER_TILE_BACKGROUND_ROW,
- CALL_RECORDER_USE_WORKSPACE_LOGO_ROW,
+ CALL_RECORDER_STYLE_DESCRIPTIONS,
+ CALL_RECORDER_STYLE_FIELD,
} from 'src/front-components/constants/call-recorder-settings-layout.constant';
-import { THEME_COLOR_HEX } from 'src/front-components/constants/theme-color-hex.constant';
import { useAutosaveApplicationVariable } from 'src/front-components/hooks/use-autosave-application-variable';
import { getApplicationVariableValue } from 'src/front-components/utils/get-application-variable-value.util';
-import { getNormalizedHexValue } from 'src/front-components/utils/get-normalized-hex-value.util';
-import { getThemeColorFromHex } from 'src/front-components/utils/get-theme-color-from-hex.util';
-import { normalizeHexColor } from 'src/front-components/utils/normalize-hex-color.util';
-import { DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND } from 'src/logic-functions/constants/default-call-recorder-bot-image-background';
+import { DEFAULT_CALL_RECORDER_STYLE } from 'src/logic-functions/constants/default-call-recorder-style';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+import { isCallRecorderStyle } from 'src/logic-functions/utils/is-call-recorder-style.util';
+
+const getInitialStyle = (): CallRecorderStyle => {
+ const value = getApplicationVariableValue(
+ CALL_RECORDER_STYLE_FIELD.variableKey,
+ ).trim();
+
+ return isCallRecorderStyle(value) ? value : DEFAULT_CALL_RECORDER_STYLE;
+};
export const RecorderSection = () => {
const nameInputId = useId();
- const hexInputId = useId();
+ const styleLabelId = useId();
const [nameValue, setNameValue] = useState(() =>
getApplicationVariableValue(CALL_RECORDER_NAME_FIELD.variableKey),
);
- const [isWorkspaceLogoEnabled, setIsWorkspaceLogoEnabled] = useState(
- () =>
- getApplicationVariableValue(
- CALL_RECORDER_USE_WORKSPACE_LOGO_ROW.variableKey,
- ) === 'true',
- );
- const [tileBackgroundValue, setTileBackgroundValue] = useState(() =>
- getApplicationVariableValue(CALL_RECORDER_TILE_BACKGROUND_ROW.variableKey),
- );
- const [isCustomHexOverride, setIsCustomHexOverride] = useState<
- boolean | undefined
- >(undefined);
+ const [style, setStyle] = useState(getInitialStyle);
const { saveDebounced: saveNameDebounced } = useAutosaveApplicationVariable({
variableKey: CALL_RECORDER_NAME_FIELD.variableKey,
});
- const { saveImmediately: saveWorkspaceLogoImmediately } =
+ const { saveImmediately: saveStyleImmediately } =
useAutosaveApplicationVariable({
- variableKey: CALL_RECORDER_USE_WORKSPACE_LOGO_ROW.variableKey,
+ variableKey: CALL_RECORDER_STYLE_FIELD.variableKey,
});
- const {
- saveDebounced: saveTileBackgroundDebounced,
- saveImmediately: saveTileBackgroundImmediately,
- } = useAutosaveApplicationVariable({
- variableKey: CALL_RECORDER_TILE_BACKGROUND_ROW.variableKey,
- });
-
- const selectedTileColor = getThemeColorFromHex(tileBackgroundValue);
- const isCustomHexSelected =
- isCustomHexOverride ?? isUndefined(selectedTileColor);
- const swatchColor =
- normalizeHexColor(tileBackgroundValue) ??
- DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND;
const handleNameChange = (value: string) => {
setNameValue(value);
saveNameDebounced(value);
};
- const handleWorkspaceLogoChange = (checked: boolean) => {
- const value = checked ? 'true' : 'false';
-
- setIsWorkspaceLogoEnabled(checked);
- saveWorkspaceLogoImmediately(value);
- };
-
- const handleSelectTileColor = (color: ThemeColor) => {
- const value = THEME_COLOR_HEX[color];
-
- setIsCustomHexOverride(false);
- setTileBackgroundValue(value);
- saveTileBackgroundImmediately(value);
- };
-
- const handleHexChange = (value: string) => {
- setTileBackgroundValue(value);
-
- const valueToSave = getNormalizedHexValue(value);
-
- if (isUndefined(valueToSave)) {
- saveTileBackgroundDebounced.cancel();
+ const handleStyleChange = (value: CallRecorderStyle) => {
+ if (value === style) {
return;
}
- saveTileBackgroundDebounced(valueToSave);
+ setStyle(value);
+ saveStyleImmediately(value);
};
return (
@@ -120,55 +76,17 @@ export const RecorderSection = () => {
onBlur={() => saveNameDebounced.flush()}
/>
</LabelledSettingsField>
- <StyledSettingsCard>
- <SettingsOptionCardContentToggle
- Icon={CALL_RECORDER_USE_WORKSPACE_LOGO_ROW.Icon}
- title={CALL_RECORDER_USE_WORKSPACE_LOGO_ROW.title}
- description={CALL_RECORDER_USE_WORKSPACE_LOGO_ROW.description}
- divider
- checked={isWorkspaceLogoEnabled}
- onChange={handleWorkspaceLogoChange}
+ <LabelledSettingsField
+ label={CALL_RECORDER_STYLE_FIELD.label}
+ labelId={styleLabelId}
+ hint={`${CALL_RECORDER_STYLE_DESCRIPTIONS[style]} ${CALL_RECORDER_STYLE_FIELD.hint}`}
+ >
+ <CameraTileStylePicker
+ labelId={styleLabelId}
+ value={style}
+ onChange={handleStyleChange}
/>
- <SettingsOptionCardContentSelect
- Icon={CALL_RECORDER_TILE_BACKGROUND_ROW.Icon}
- title={CALL_RECORDER_TILE_BACKGROUND_ROW.title}
- description={CALL_RECORDER_TILE_BACKGROUND_ROW.description}
- isDimmed={!isWorkspaceLogoEnabled}
- >
- <TileBackgroundControl
- swatchColor={swatchColor}
- selectedColor={
- isCustomHexSelected ? undefined : selectedTileColor
- }
- isCustomSelected={isCustomHexSelected}
- disabled={!isWorkspaceLogoEnabled}
- onSelectColor={handleSelectTileColor}
- onSelectCustom={() => setIsCustomHexOverride(true)}
- />
- </SettingsOptionCardContentSelect>
- </StyledSettingsCard>
- {isCustomHexSelected && (
- <StyledDimmable $dimmed={!isWorkspaceLogoEnabled}>
- <LabelledSettingsField
- label="Custom hex"
- inputId={hexInputId}
- hint="Six-digit hex, for example #1d1d1d."
- errorMessage={
- isUndefined(getNormalizedHexValue(tileBackgroundValue))
- ? 'Invalid hex colour'
- : undefined
- }
- >
- <AdornedHexInput
- id={hexInputId}
- value={tileBackgroundValue}
- swatchColor={swatchColor}
- onChange={handleHexChange}
- onBlur={() => saveTileBackgroundDebounced.flush()}
- />
- </LabelledSettingsField>
- </StyledDimmable>
- )}
+ </LabelledSettingsField>
</StyledSettingsSectionStack>
</Section.Root>
);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/SettingsColorSample.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/SettingsColorSample.tsx
deleted file mode 100644
index ca2567fb575..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/SettingsColorSample.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import styled from '@emotion/styled';
-import { ColorSample, type ColorSampleProps } from 'twenty-ui/primitives/data-display';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-type SettingsColorSampleProps = Omit<ColorSampleProps, 'variant'>;
-
-// The front-component style bridge does not preserve ColorSample's pill radius.
-const StyledContainer = styled.span`
- display: flex;
-
- > div {
- border-radius: ${() => themeCssVariables.border.radius.pill};
- corner-shape: round;
- }
-`;
-
-export const SettingsColorSample = (props: SettingsColorSampleProps) => (
- <StyledContainer>
- <ColorSample {...props} />
- </StyledContainer>
-);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/ThemeColorPickerMenu.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/ThemeColorPickerMenu.tsx
deleted file mode 100644
index 57dac979b7e..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/ThemeColorPickerMenu.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import styled from '@emotion/styled';
-import { DEFAULT_COLOR_LABELS } from 'twenty-ui/components/navigation';
-import { MAIN_COLOR_NAMES, type ThemeColor } from 'twenty-ui/theme';
-
-import { DropdownMenuItemsContainer } from 'src/front-components/components/DropdownMenuItemsContainer';
-import { DropdownMenuOption } from 'src/front-components/components/DropdownMenuOption';
-import { DropdownMenuSeparator } from 'src/front-components/components/DropdownMenuSeparator';
-import { SettingsColorSample } from 'src/front-components/components/SettingsColorSample';
-
-const StyledListbox = styled.div`
- min-height: 0;
- overflow-y: auto;
- width: 100%;
-`;
-
-type ThemeColorPickerMenuProps = {
- listboxId: string;
- selectedColor: ThemeColor | undefined;
- isCustomSelected: boolean;
- activeOption: ThemeColor | 'custom';
- getOptionId: (option: ThemeColor | 'custom') => string;
- onSelectColor: (color: ThemeColor) => void;
- onSelectCustom: () => void;
-};
-
-export const ThemeColorPickerMenu = ({
- listboxId,
- selectedColor,
- isCustomSelected,
- activeOption,
- getOptionId,
- onSelectColor,
- onSelectCustom,
-}: ThemeColorPickerMenuProps) => (
- <StyledListbox id={listboxId} role="listbox" aria-label="Tile background">
- <DropdownMenuItemsContainer>
- {MAIN_COLOR_NAMES.map((colorName) => (
- <DropdownMenuOption
- key={colorName}
- id={getOptionId(colorName)}
- onSelect={() => onSelectColor(colorName)}
- text={DEFAULT_COLOR_LABELS[colorName]}
- selected={colorName === selectedColor}
- isActive={colorName === activeOption}
- LeftComponent={<SettingsColorSample colorName={colorName} />}
- />
- ))}
- </DropdownMenuItemsContainer>
- <DropdownMenuSeparator />
- <DropdownMenuItemsContainer>
- <DropdownMenuOption
- id={getOptionId('custom')}
- text="Custom hex"
- selected={isCustomSelected}
- isActive={activeOption === 'custom'}
- onSelect={onSelectCustom}
- />
- </DropdownMenuItemsContainer>
- </StyledListbox>
-);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/TileBackgroundControl.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/TileBackgroundControl.tsx
deleted file mode 100644
index cfb7589141e..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/TileBackgroundControl.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-import { isUndefined } from '@sniptt/guards';
-import { useState } from 'react';
-import { DEFAULT_COLOR_LABELS } from 'twenty-ui/components/navigation';
-import { MAIN_COLOR_NAMES, type ThemeColor } from 'twenty-ui/theme';
-import { isDefined } from 'twenty-ui/utilities';
-
-import { SettingsSelectControl } from 'src/front-components/components/SettingsSelectControl';
-import { SettingsSelectMenu } from 'src/front-components/components/SettingsSelectMenu';
-import { SettingsColorSample } from 'src/front-components/components/SettingsColorSample';
-import { StyledSettingsSelectAnchor } from 'src/front-components/components/StyledSettingsSelectAnchor';
-import { ThemeColorPickerMenu } from 'src/front-components/components/ThemeColorPickerMenu';
-import {
- getNextActiveOptionIndex,
- type SettingsSelectNavigationKey,
-} from 'src/front-components/utils/get-next-active-option-index.util';
-
-// The control is capped at 120px, where "Custom hex" ellipsises to "Custom …".
-const CUSTOM_CONTROL_LABEL = 'Custom';
-const CUSTOM_OPTION_VALUE = 'custom';
-const FALLBACK_SWATCH_COLOR_NAME: ThemeColor = 'gray';
-const TILE_BACKGROUND_LISTBOX_ID = 'call-recorder-tile-background';
-
-type TileBackgroundOption = ThemeColor | typeof CUSTOM_OPTION_VALUE;
-
-// Built lazily: the SDK manifest extractor loads this module with twenty-ui
-// mocked, so module-scope iteration over MAIN_COLOR_NAMES would throw.
-const getTileBackgroundOptions = (): TileBackgroundOption[] => [
- ...MAIN_COLOR_NAMES,
- CUSTOM_OPTION_VALUE,
-];
-
-const getTileBackgroundOptionId = (option: TileBackgroundOption) =>
- `${TILE_BACKGROUND_LISTBOX_ID}-option-${option}`;
-
-type TileBackgroundControlProps = {
- swatchColor: string;
- selectedColor: ThemeColor | undefined;
- isCustomSelected: boolean;
- disabled: boolean;
- onSelectColor: (color: ThemeColor) => void;
- onSelectCustom: () => void;
-};
-
-export const TileBackgroundControl = ({
- swatchColor,
- selectedColor,
- isCustomSelected,
- disabled,
- onSelectColor,
- onSelectCustom,
-}: TileBackgroundControlProps) => {
- const [isMenuOpen, setIsMenuOpen] = useState(false);
- const [activeOptionIndex, setActiveOptionIndex] = useState(0);
-
- const tileBackgroundOptions = getTileBackgroundOptions();
-
- const label = isUndefined(selectedColor)
- ? CUSTOM_CONTROL_LABEL
- : (DEFAULT_COLOR_LABELS[selectedColor] ?? selectedColor);
-
- const selectedOption: TileBackgroundOption = isCustomSelected
- ? CUSTOM_OPTION_VALUE
- : (selectedColor ?? FALLBACK_SWATCH_COLOR_NAME);
-
- const handleMenuToggle = () => {
- if (!isMenuOpen) {
- setActiveOptionIndex(
- Math.max(tileBackgroundOptions.indexOf(selectedOption), 0),
- );
- }
-
- setIsMenuOpen((isOpen) => !isOpen);
- };
- const handleMenuClose = () => setIsMenuOpen(false);
-
- const handleNavigate = (key: SettingsSelectNavigationKey) => {
- setActiveOptionIndex((currentIndex) =>
- getNextActiveOptionIndex({
- key,
- currentIndex,
- optionCount: tileBackgroundOptions.length,
- }),
- );
- };
-
- const handleSelectActive = () => {
- const activeOption = tileBackgroundOptions[activeOptionIndex];
-
- if (activeOption === CUSTOM_OPTION_VALUE) {
- onSelectCustom();
- } else if (isDefined(activeOption)) {
- onSelectColor(activeOption);
- }
-
- handleMenuClose();
- };
-
- return (
- <StyledSettingsSelectAnchor>
- <SettingsSelectControl
- label={label}
- ariaLabel="Tile background"
- disabled={disabled}
- listboxId={TILE_BACKGROUND_LISTBOX_ID}
- activeDescendantId={getTileBackgroundOptionId(
- tileBackgroundOptions[activeOptionIndex] ?? CUSTOM_OPTION_VALUE,
- )}
- isExpanded={isMenuOpen}
- onNavigate={handleNavigate}
- onSelectActive={handleSelectActive}
- onEscape={handleMenuClose}
- adornment={
- <SettingsColorSample
- colorName={selectedColor ?? FALLBACK_SWATCH_COLOR_NAME}
- color={isCustomSelected ? swatchColor : undefined}
- />
- }
- onClick={handleMenuToggle}
- />
- <SettingsSelectMenu isOpen={isMenuOpen} onClose={handleMenuClose}>
- <ThemeColorPickerMenu
- listboxId={TILE_BACKGROUND_LISTBOX_ID}
- selectedColor={selectedColor}
- isCustomSelected={isCustomSelected}
- activeOption={
- tileBackgroundOptions[activeOptionIndex] ?? CUSTOM_OPTION_VALUE
- }
- getOptionId={getTileBackgroundOptionId}
- onSelectColor={(color) => {
- onSelectColor(color);
- handleMenuClose();
- }}
- onSelectCustom={() => {
- onSelectCustom();
- handleMenuClose();
- }}
- />
- </SettingsSelectMenu>
- </StyledSettingsSelectAnchor>
- );
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recorder-settings-layout.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recorder-settings-layout.constant.ts
index 6f8c69e3cc2..bfdccb47d77 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recorder-settings-layout.constant.ts
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/call-recorder-settings-layout.constant.ts
@@ -1,19 +1,16 @@
import {
IconCalendarEvent,
IconClockPlay,
- IconColorSwatch,
IconDoorEnter,
IconHourglassHigh,
IconLanguage,
IconMessage,
- IconPhoto,
IconPlayerStop,
IconSparkles,
type IconComponent,
} from 'twenty-ui/icon';
import { CALL_RECORDER_ADDITIONAL_SUMMARY_PROMPT_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-additional-summary-prompt-env-var-name';
-import { CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-bot-image-background-env-var-name';
import { CALL_RECORDER_CALENDAR_BOT_SCHEDULING_ENABLED_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-calendar-bot-scheduling-enabled-env-var-name';
import { CALL_RECORDER_EVERYONE_LEFT_TIMEOUT_SECONDS_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-everyone-left-timeout-seconds-env-var-name';
import { CALL_RECORDER_JOIN_EARLY_MINUTES_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-join-early-minutes-env-var-name';
@@ -22,10 +19,11 @@ import { CALL_RECORDER_NOONE_JOINED_TIMEOUT_SECONDS_ENV_VAR_NAME } from 'src/log
import { CALL_RECORDER_RECORDING_NOTICE_ENABLED_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-recording-notice-enabled-env-var-name';
import { CALL_RECORDER_RECORDING_NOTICE_MAX_LENGTH } from 'src/logic-functions/constants/call-recorder-recording-notice-max-length';
import { CALL_RECORDER_RECORDING_NOTICE_MESSAGE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-recording-notice-message-env-var-name';
+import { CALL_RECORDER_STYLE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-style-env-var-name';
import { CALL_RECORDER_SUMMARY_ENABLED_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-summary-enabled-env-var-name';
import { CALL_RECORDER_TRANSCRIPT_PROVIDER_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-transcript-provider-env-var-name';
-import { CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-use-workspace-logo-env-var-name';
import { CALL_RECORDER_WAITING_ROOM_TIMEOUT_SECONDS_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-waiting-room-timeout-seconds-env-var-name';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
export type CallRecorderCounterRow = {
variableKey: string;
@@ -97,18 +95,20 @@ export const CALL_RECORDER_SUMMARY_ENABLED_ROW = {
Icon: IconSparkles,
};
-export const CALL_RECORDER_USE_WORKSPACE_LOGO_ROW = {
- variableKey: CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME,
- title: 'Show workspace logo',
- description: 'Display your logo on the recorder camera tile.',
- Icon: IconPhoto,
+export const CALL_RECORDER_STYLE_FIELD = {
+ variableKey: CALL_RECORDER_STYLE_ENV_VAR_NAME,
+ label: 'Style',
+ hint: 'Applies to recorders scheduled after you change it.',
};
-export const CALL_RECORDER_TILE_BACKGROUND_ROW = {
- variableKey: CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME,
- title: 'Tile background',
- description: 'Colour drawn behind the logo on the camera tile.',
- Icon: IconColorSwatch,
+export const CALL_RECORDER_STYLE_DESCRIPTIONS: Record<
+ CallRecorderStyle,
+ string
+> = {
+ TWENTY: 'Shows the Twenty logo and name.',
+ WORKSPACE: 'Uses the workspace name and logo from Settings > General.',
+ MINIMAL: 'Shows the word Twenty, no logo.',
+ NONE: 'Sends no image. People only see the recorder name.',
};
export const CALL_RECORDER_NAME_FIELD = {
@@ -134,6 +134,5 @@ export const CALL_RECORDER_MAPPED_VARIABLE_KEYS: string[] = [
CALL_RECORDER_TRANSCRIPT_PROVIDER_ROW.variableKey,
CALL_RECORDER_SUMMARY_ENABLED_ROW.variableKey,
CALL_RECORDER_SUMMARY_PROMPT_FIELD.variableKey,
- CALL_RECORDER_USE_WORKSPACE_LOGO_ROW.variableKey,
- CALL_RECORDER_TILE_BACKGROUND_ROW.variableKey,
+ CALL_RECORDER_STYLE_FIELD.variableKey,
];
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/camera-tile-preview-asset-paths.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/camera-tile-preview-asset-paths.constant.ts
new file mode 100644
index 00000000000..aa27659740b
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/constants/camera-tile-preview-asset-paths.constant.ts
@@ -0,0 +1,11 @@
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+export const CAMERA_TILE_PREVIEW_ASSET_PATHS: Record<
+ CallRecorderStyle,
+ string
+> = {
+ TWENTY: 'camera-tile/previews/twenty.jpg',
+ WORKSPACE: 'camera-tile/previews/workspace.jpg',
+ MINIMAL: 'camera-tile/previews/minimal.jpg',
+ NONE: 'camera-tile/previews/none.jpg',
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/constants/theme-color-hex.constant.ts b/packages/twenty-apps/public/call-recorder/src/front-components/constants/theme-color-hex.constant.ts
deleted file mode 100644
index 194910f5c6f..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/constants/theme-color-hex.constant.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { type ThemeColor } from 'twenty-ui/theme';
-
-// twenty-ui's MAIN_COLORS_LIGHT holds display-p3 strings, which the hex
-// validator in get-bot-image-background rejects — it would silently fall back
-// to the default background. Named colours are stored as the sRGB equivalent
-// of the same Radix step instead.
-export const THEME_COLOR_HEX: Record<ThemeColor, string> = {
- red: '#e5484d',
- ruby: '#e54666',
- crimson: '#e93d82',
- tomato: '#e54d2e',
- orange: '#f76b15',
- amber: '#ffc53d',
- yellow: '#ffe629',
- lime: '#bdee63',
- grass: '#46a758',
- green: '#30a46c',
- jade: '#29a383',
- mint: '#86ead4',
- turquoise: '#12a594',
- cyan: '#00a2c7',
- sky: '#7ce2fe',
- blue: '#3e63dd',
- iris: '#5b5bd6',
- violet: '#6e56cf',
- purple: '#8e4ec6',
- plum: '#ab4aba',
- pink: '#d6409f',
- bronze: '#a18072',
- gold: '#978365',
- brown: '#ad7f58',
- gray: '#999999',
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-normalized-hex-value.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-normalized-hex-value.test.ts
deleted file mode 100644
index d3edee4c08f..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-normalized-hex-value.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { getNormalizedHexValue } from 'src/front-components/utils/get-normalized-hex-value.util';
-
-describe('getNormalizedHexValue', () => {
- it('normalizes valid hex values', () => {
- expect(getNormalizedHexValue('#1D1D1D')).toBe('#1d1d1d');
- expect(getNormalizedHexValue(' #abc ')).toBe('#aabbcc');
- });
-
- it('keeps an empty value so the variable can be cleared', () => {
- expect(getNormalizedHexValue('')).toBe('');
- expect(getNormalizedHexValue(' ')).toBe('');
- });
-
- it('returns undefined for values that are not hex colours', () => {
- expect(getNormalizedHexValue('#12')).toBeUndefined();
- expect(getNormalizedHexValue('1d1d1d')).toBeUndefined();
- expect(getNormalizedHexValue('red')).toBeUndefined();
- });
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-theme-color-from-hex.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-theme-color-from-hex.test.ts
deleted file mode 100644
index 520d11a4dac..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/get-theme-color-from-hex.test.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { THEME_COLOR_HEX } from 'src/front-components/constants/theme-color-hex.constant';
-import { getThemeColorFromHex } from 'src/front-components/utils/get-theme-color-from-hex.util';
-
-describe('getThemeColorFromHex', () => {
- it('maps a stored hex back to its theme colour name', () => {
- expect(getThemeColorFromHex('#3E63DD')).toBe('blue');
- expect(getThemeColorFromHex('#e5484d')).toBe('red');
- });
-
- it('returns undefined for a colour outside the palette', () => {
- expect(getThemeColorFromHex('#1d1d1d')).toBeUndefined();
- });
-
- it('stores every palette colour as a hex the bot image validator accepts', () => {
- const hexPattern = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
-
- for (const hex of Object.values(THEME_COLOR_HEX)) {
- expect(hex).toMatch(hexPattern);
- }
- });
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/normalize-hex-color.test.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/normalize-hex-color.test.ts
deleted file mode 100644
index 37dddd01ea4..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/utils/__tests__/normalize-hex-color.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { normalizeHexColor } from 'src/front-components/utils/normalize-hex-color.util';
-
-describe('normalizeHexColor', () => {
- it('expands short hex values', () => {
- expect(normalizeHexColor('#ABC')).toBe('#aabbcc');
- });
-
- it('lowercases long hex values', () => {
- expect(normalizeHexColor(' #1D1D1D ')).toBe('#1d1d1d');
- });
-
- it('rejects anything that is not a hex colour', () => {
- expect(
- normalizeHexColor('color(display-p3 0.83 0.329 0.324)'),
- ).toBeUndefined();
- expect(normalizeHexColor('red')).toBeUndefined();
- expect(normalizeHexColor('')).toBeUndefined();
- });
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-normalized-hex-value.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-normalized-hex-value.util.ts
deleted file mode 100644
index 694b4a3a0c5..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-normalized-hex-value.util.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { normalizeHexColor } from 'src/front-components/utils/normalize-hex-color.util';
-
-export const getNormalizedHexValue = (value: string): string | undefined => {
- if (value.trim() === '') {
- return '';
- }
-
- return normalizeHexColor(value);
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-theme-color-from-hex.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-theme-color-from-hex.util.ts
deleted file mode 100644
index 5a03a1f1bdd..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/utils/get-theme-color-from-hex.util.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { isUndefined } from '@sniptt/guards';
-import { MAIN_COLOR_NAMES, type ThemeColor } from 'twenty-ui/theme';
-
-import { THEME_COLOR_HEX } from 'src/front-components/constants/theme-color-hex.constant';
-import { normalizeHexColor } from 'src/front-components/utils/normalize-hex-color.util';
-
-export const getThemeColorFromHex = (value: string): ThemeColor | undefined => {
- const normalizedValue = normalizeHexColor(value);
-
- if (isUndefined(normalizedValue)) {
- return undefined;
- }
-
- return MAIN_COLOR_NAMES.find(
- (colorName) => THEME_COLOR_HEX[colorName] === normalizedValue,
- );
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/utils/normalize-hex-color.util.ts b/packages/twenty-apps/public/call-recorder/src/front-components/utils/normalize-hex-color.util.ts
deleted file mode 100644
index 4788647b990..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/utils/normalize-hex-color.util.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-const SHORT_HEX_PATTERN = /^#[0-9a-f]{3}$/;
-const LONG_HEX_PATTERN = /^#[0-9a-f]{6}$/;
-
-export const normalizeHexColor = (value: string): string | undefined => {
- const normalizedValue = value.trim().toLowerCase();
-
- if (SHORT_HEX_PATTERN.test(normalizedValue)) {
- return `#${normalizedValue
- .slice(1)
- .split('')
- .map((character) => `${character}${character}`)
- .join('')}`;
- }
-
- return LONG_HEX_PATTERN.test(normalizedValue) ? normalizedValue : undefined;
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts
index 4b68ec73f48..a948f84c2c1 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts
@@ -114,7 +114,7 @@ describe('scheduleRecallBotOnCallRecordingUpdateHandler', () => {
vi.stubGlobal('fetch', fetchMock);
vi.stubEnv('RECALL_API_KEY', 'recall-api-key');
vi.stubEnv('RECALL_REGION', 'us-west-2');
- vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+ vi.stubEnv('CALL_RECORDER_STYLE', 'NONE');
vi.stubEnv(
'TWENTY_APP_ACCESS_TOKEN',
buildAccessToken({ workspaceId: WORKSPACE_ID }),
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/__tests__/get-bot-image-background.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/__tests__/get-bot-image-background.test.ts
deleted file mode 100644
index 569a5cd8828..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/__tests__/get-bot-image-background.test.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { afterEach, describe, expect, it } from 'vitest';
-
-import { CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-bot-image-background-env-var-name';
-import { DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND } from 'src/logic-functions/constants/default-call-recorder-bot-image-background';
-import { getBotImageBackground } from 'src/logic-functions/constants/get-bot-image-background';
-
-const ORIGINAL_VALUE =
- process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME];
-
-const restore = () => {
- if (ORIGINAL_VALUE === undefined) {
- delete process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME];
-
- return;
- }
-
- process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME] = ORIGINAL_VALUE;
-};
-
-describe('getBotImageBackground', () => {
- afterEach(() => {
- restore();
- });
-
- it('returns the dark default when unset', () => {
- delete process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME];
-
- expect(getBotImageBackground()).toBe('#1d1d1d');
- });
-
- it('returns the default when set to an empty string', () => {
- process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME] = '';
-
- expect(getBotImageBackground()).toBe(
- DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND,
- );
- });
-
- it.each(['#000', '#000000', '#1B1B1B'])(
- 'accepts valid hex color %s',
- (color) => {
- process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME] = color;
-
- expect(getBotImageBackground()).toBe(color);
- },
- );
-
- it('trims surrounding whitespace from a valid hex color', () => {
- process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME] =
- ' #1B1B1B ';
-
- expect(getBotImageBackground()).toBe('#1B1B1B');
- });
-
- it.each(['white', '000000', '#xyzxyz', '#12345'])(
- 'falls back to the default for invalid value %s',
- (value) => {
- process.env[CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME] = value;
-
- expect(getBotImageBackground()).toBe(
- DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND,
- );
- },
- );
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/__tests__/is-workspace-logo-bot-image-enabled.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/__tests__/is-workspace-logo-bot-image-enabled.test.ts
deleted file mode 100644
index c61014f5be7..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/__tests__/is-workspace-logo-bot-image-enabled.test.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import { afterEach, describe, expect, it } from 'vitest';
-
-import { CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-use-workspace-logo-env-var-name';
-import { isWorkspaceLogoBotImageEnabled } from 'src/logic-functions/constants/is-workspace-logo-bot-image-enabled';
-
-const ORIGINAL_VALUE =
- process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME];
-
-const restore = () => {
- if (ORIGINAL_VALUE === undefined) {
- delete process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME];
-
- return;
- }
-
- process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME] = ORIGINAL_VALUE;
-};
-
-describe('isWorkspaceLogoBotImageEnabled', () => {
- afterEach(() => {
- restore();
- });
-
- it('defaults to enabled when unset', () => {
- delete process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME];
-
- expect(isWorkspaceLogoBotImageEnabled()).toBe(true);
- });
-
- it.each(['false', '0', 'no', 'off', 'FALSE', ' Off '])(
- 'is disabled for falsy value %s',
- (value) => {
- process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME] = value;
-
- expect(isWorkspaceLogoBotImageEnabled()).toBe(false);
- },
- );
-
- it.each(['true', '1', 'yes', 'on', 'TRUE'])(
- 'is enabled for truthy value %s',
- (value) => {
- process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME] = value;
-
- expect(isWorkspaceLogoBotImageEnabled()).toBe(true);
- },
- );
-
- it('defaults to enabled for an unrecognized value', () => {
- process.env[CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME] = 'maybe';
-
- expect(isWorkspaceLogoBotImageEnabled()).toBe(true);
- });
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-bot-image-background-env-var-name.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-bot-image-background-env-var-name.ts
deleted file mode 100644
index e9b9c932b76..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-bot-image-background-env-var-name.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export const CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME =
- 'CALL_RECORDER_BOT_IMAGE_BACKGROUND';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-style-env-var-name.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-style-env-var-name.ts
new file mode 100644
index 00000000000..d1e14f6eda8
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-style-env-var-name.ts
@@ -0,0 +1 @@
+export const CALL_RECORDER_STYLE_ENV_VAR_NAME = 'CALL_RECORDER_STYLE';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-styles-introduced-version.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-styles-introduced-version.ts
new file mode 100644
index 00000000000..d0a95ab973d
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-styles-introduced-version.ts
@@ -0,0 +1 @@
+export const CALL_RECORDER_STYLES_INTRODUCED_VERSION = '1.20.0';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-styles.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-styles.ts
new file mode 100644
index 00000000000..c7f22d0c7c9
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/call-recorder-styles.ts
@@ -0,0 +1,6 @@
+export const CALL_RECORDER_STYLES = [
+ 'TWENTY',
+ 'WORKSPACE',
+ 'MINIMAL',
+ 'NONE',
+] as const;
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-asset-paths.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-asset-paths.ts
new file mode 100644
index 00000000000..103fb79e13e
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-asset-paths.ts
@@ -0,0 +1,20 @@
+import { type PrebuiltCallRecorderStyle } from 'src/logic-functions/types/prebuilt-call-recorder-style.type';
+
+export const CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS: Record<
+ PrebuiltCallRecorderStyle,
+ { recording: string; notRecording: string }
+> = {
+ TWENTY: {
+ recording: 'camera-tile/frames/twenty-recording.jpg',
+ notRecording: 'camera-tile/frames/twenty-not-recording.jpg',
+ },
+ MINIMAL: {
+ recording: 'camera-tile/frames/minimal-recording.jpg',
+ notRecording: 'camera-tile/frames/minimal-not-recording.jpg',
+ },
+};
+
+export const CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH =
+ 'camera-tile/workspace-background.png';
+
+export const CAMERA_TILE_FONT_ASSET_PATH = 'fonts/Inter-SemiBold.ttf';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.ts
new file mode 100644
index 00000000000..0341b3a025c
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/camera-tile-config.ts
@@ -0,0 +1,30 @@
+export const CAMERA_TILE_BACKGROUND_COLOR = '#1d1d1d';
+export const CAMERA_TILE_TEXT_COLOR = '#ffffff';
+export const CAMERA_TILE_SECONDARY_TEXT_OPACITY = 0.6;
+export const CAMERA_TILE_FONT_FAMILY = 'Inter SemiBold';
+
+export const CAMERA_TILE_PLATE_TOP = 200;
+export const CAMERA_TILE_PLATE_SIZE = 200;
+export const CAMERA_TILE_PLATE_RADIUS = 48;
+export const CAMERA_TILE_PLATE_COLOR = '#ffffff';
+export const CAMERA_TILE_PLATE_STROKE_COLOR = '#2e2e2e';
+export const CAMERA_TILE_LOGO_BOX_SIZE = 132;
+export const CAMERA_TILE_INITIAL_COLOR = '#333333';
+export const CAMERA_TILE_INITIAL_FONT_SIZE = 96;
+
+export const CAMERA_TILE_TEXT_TOP = 445;
+export const CAMERA_TILE_TEXT_LINE_GAP = 10;
+export const CAMERA_TILE_SAFE_ZONE_WIDTH = 500;
+export const CAMERA_TILE_TITLE_FONT_SIZE = 44;
+export const CAMERA_TILE_TITLE_LINE_HEIGHT = 53;
+export const CAMERA_TILE_SUBTITLE_FONT_SIZE = 28;
+export const CAMERA_TILE_SUBTITLE_LINE_HEIGHT = 34;
+
+export const CAMERA_TILE_RECORDING_FONT_SIZE = 26;
+export const CAMERA_TILE_RECORDING_BOTTOM_INSET = 64;
+export const CAMERA_TILE_RECORDING_DOT_COLOR = '#e5484d';
+export const CAMERA_TILE_RECORDING_DOT_SIZE = 14;
+export const CAMERA_TILE_RECORDING_DOT_GAP = 12;
+
+export const CAMERA_TILE_RECORDING_LABEL = 'Recording';
+export const CAMERA_TILE_POWERED_BY_LABEL = 'Powered by twenty.com';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/default-call-recorder-bot-image-background.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/default-call-recorder-bot-image-background.ts
deleted file mode 100644
index b17fbefbd7f..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/default-call-recorder-bot-image-background.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND = '#1d1d1d';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/default-call-recorder-style.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/default-call-recorder-style.ts
new file mode 100644
index 00000000000..c4fe5980f13
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/default-call-recorder-style.ts
@@ -0,0 +1,3 @@
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+export const DEFAULT_CALL_RECORDER_STYLE: CallRecorderStyle = 'TWENTY';
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/get-bot-image-background.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/get-bot-image-background.ts
deleted file mode 100644
index cca17df419e..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/get-bot-image-background.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-bot-image-background-env-var-name';
-import { DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND } from 'src/logic-functions/constants/default-call-recorder-bot-image-background';
-import { getApplicationVariableValue } from 'src/logic-functions/utils/get-application-variable-value.util';
-import { isNonEmptyString } from 'src/logic-functions/utils/is-non-empty-string.util';
-
-const HEX_COLOR_PATTERN = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
-
-export const getBotImageBackground = (): string => {
- const rawValue = getApplicationVariableValue(
- CALL_RECORDER_BOT_IMAGE_BACKGROUND_ENV_VAR_NAME,
- );
-
- if (!isNonEmptyString(rawValue)) {
- return DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND;
- }
-
- const normalizedValue = rawValue.trim();
-
- return HEX_COLOR_PATTERN.test(normalizedValue)
- ? normalizedValue
- : DEFAULT_CALL_RECORDER_BOT_IMAGE_BACKGROUND;
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/is-workspace-logo-bot-image-enabled.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/is-workspace-logo-bot-image-enabled.ts
deleted file mode 100644
index 6f9d4b00557..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/is-workspace-logo-bot-image-enabled.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-use-workspace-logo-env-var-name';
-import { DEFAULT_CALL_RECORDER_USE_WORKSPACE_LOGO } from 'src/logic-functions/constants/default-call-recorder-use-workspace-logo';
-import { getBooleanApplicationVariableValue } from 'src/logic-functions/utils/get-boolean-application-variable-value.util';
-
-export const isWorkspaceLogoBotImageEnabled = (): boolean =>
- getBooleanApplicationVariableValue({
- applicationVariableName: CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME,
- defaultValue: DEFAULT_CALL_RECORDER_USE_WORKSPACE_LOGO,
- });
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recall-bot-image-config.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recall-bot-image-config.ts
index 4e93838800a..9024d66f273 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recall-bot-image-config.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recall-bot-image-config.ts
@@ -1,9 +1,5 @@
-// Meeting platforms cap the bot's camera output at 1280x720; the logo box stays
-// within a centered safezone so it survives adaptive participant tile cropping.
export const RECALL_BOT_IMAGE_WIDTH = 1280;
export const RECALL_BOT_IMAGE_HEIGHT = 720;
-export const RECALL_BOT_IMAGE_LOGO_MAX_WIDTH = 760;
-export const RECALL_BOT_IMAGE_LOGO_MAX_HEIGHT = 420;
export const RECALL_BOT_IMAGE_JPEG_QUALITY = 90;
export const RECALL_BOT_IMAGE_MIN_JPEG_QUALITY = 40;
// Recall rejects images above 1.3MB; stay just under it.
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recording-status-badge-config.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recording-status-badge-config.ts
deleted file mode 100644
index 0ed5cc060de..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/constants/recording-status-badge-config.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-export const RECORDING_STATUS_BADGE_HEIGHT = 48;
-export const RECORDING_STATUS_BADGE_INSET = 56;
-export const RECORDING_STATUS_BADGE_PADDING = 18;
-export const RECORDING_STATUS_BADGE_DOT_DIAMETER = 12;
-export const RECORDING_STATUS_BADGE_DOT_LABEL_GAP = 12;
-export const RECORDING_STATUS_BADGE_BACKGROUND = '#feebec';
-export const RECORDING_STATUS_BADGE_BACKGROUND_OPACITY = 0.96;
-export const RECORDING_STATUS_BADGE_COLOR = '#ce2c31';
-export const RECORDING_STATUS_BADGE_LABEL_CAP_HEIGHT = 14;
-
-// "REC" outlined from Inter SemiBold (14px cap height, 2px tracking); the app runtimes ship no fonts, so SVG <text> renders as boxes.
-export const RECORDING_STATUS_BADGE_LABEL_PATH =
- 'M3.92 14L1.38 14L1.38 0L6.63 0Q8.24 0 9.34 0.56Q10.44 1.12 11.00 2.13Q11.57 3.14 11.57 4.48L11.57 4.48Q11.57 5.82 11.00 6.81Q10.42 7.80 9.32 8.34Q8.21 8.87 6.60 8.87L6.60 8.87L2.86 8.87L2.86 6.77L6.25 6.77Q7.20 6.77 7.80 6.50Q8.40 6.24 8.69 5.73Q8.98 5.22 8.98 4.48L8.98 4.48Q8.98 3.73 8.69 3.20Q8.39 2.67 7.79 2.40Q7.19 2.12 6.24 2.12L6.24 2.12L3.92 2.12L3.92 14Z' +
- 'M5.84 7.66L8.61 7.66L12.08 14L9.25 14L5.84 7.66Z' +
- 'M25.06 14L15.90 14L15.90 0L25.01 0L25.01 2.13L18.44 2.13L18.44 5.93L24.54 5.93L24.54 8.05L18.44 8.05L18.44 11.87L25.06 11.87L25.06 14Z' +
- 'M41.58 4.72L41.58 4.72L39.03 4.72Q38.92 4.09 38.62 3.61Q38.33 3.12 37.89 2.78Q37.46 2.43 36.90 2.26Q36.34 2.08 35.70 2.08L35.70 2.08Q34.56 2.08 33.67 2.66Q32.79 3.23 32.29 4.32Q31.79 5.42 31.79 7L31.79 7Q31.79 8.61 32.30 9.70Q32.80 10.80 33.68 11.36Q34.56 11.92 35.69 11.92L35.69 11.92Q36.32 11.92 36.87 11.75Q37.42 11.58 37.86 11.25Q38.30 10.92 38.61 10.45Q38.91 9.97 39.03 9.35L39.03 9.35L41.58 9.37Q41.44 10.36 40.97 11.24Q40.49 12.11 39.72 12.78Q38.96 13.45 37.93 13.82Q36.91 14.19 35.66 14.19L35.66 14.19Q33.81 14.19 32.36 13.34Q30.91 12.48 30.08 10.87Q29.25 9.26 29.25 7L29.25 7Q29.25 4.74 30.09 3.13Q30.93 1.52 32.38 0.66Q33.83-0.19 35.66-0.19L35.66-0.19Q36.83-0.19 37.83 0.14Q38.84 0.46 39.62 1.10Q40.41 1.73 40.92 2.64Q41.43 3.55 41.58 4.72Z';
-
-export const RECORDING_STATUS_BADGE_LABEL_WIDTH = 42.53;
-
-export const RECORDING_STATUS_BADGE_LABEL_LEFT =
- RECORDING_STATUS_BADGE_PADDING +
- RECORDING_STATUS_BADGE_DOT_DIAMETER +
- RECORDING_STATUS_BADGE_DOT_LABEL_GAP;
-
-export const RECORDING_STATUS_BADGE_LABEL_TOP =
- (RECORDING_STATUS_BADGE_HEIGHT - RECORDING_STATUS_BADGE_LABEL_CAP_HEIGHT) / 2;
-
-export const RECORDING_STATUS_BADGE_WIDTH = Math.round(
- RECORDING_STATUS_BADGE_LABEL_LEFT +
- RECORDING_STATUS_BADGE_LABEL_WIDTH +
- RECORDING_STATUS_BADGE_PADDING,
-);
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/__tests__/get-workspace-branding.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/__tests__/get-workspace-branding.test.ts
new file mode 100644
index 00000000000..2546e0f2c6a
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/__tests__/get-workspace-branding.test.ts
@@ -0,0 +1,52 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { getWorkspaceBranding } from 'src/logic-functions/data/get-workspace-branding.util';
+
+const metadataQueryMock = vi.hoisted(() => vi.fn());
+
+vi.mock('twenty-client-sdk/metadata', () => ({
+ MetadataApiClient: class {
+ query = metadataQueryMock;
+ },
+}));
+
+const fetchMock = vi.fn();
+
+describe('getWorkspaceBranding', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ vi.spyOn(console, 'warn').mockImplementation(() => {});
+ vi.stubGlobal('fetch', fetchMock);
+ });
+
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.restoreAllMocks();
+ });
+
+ it('collapses line breaks in the workspace name onto one line', async () => {
+ metadataQueryMock.mockResolvedValue({
+ currentWorkspace: { logo: null, displayName: ' Acme\nInternal
Ops ' },
+ });
+
+ expect(await getWorkspaceBranding()).toEqual({
+ logo: undefined,
+ displayName: 'Acme Internal Ops',
+ });
+ });
+
+ it('keeps the workspace name when the logo download throws', async () => {
+ metadataQueryMock.mockResolvedValue({
+ currentWorkspace: {
+ logo: 'https://files.test/logo.png',
+ displayName: 'Acme',
+ },
+ });
+ fetchMock.mockRejectedValue(new Error('timed out'));
+
+ expect(await getWorkspaceBranding()).toEqual({
+ logo: undefined,
+ displayName: 'Acme',
+ });
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/fetch-prebuilt-camera-tile-frames-or-throw.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/fetch-prebuilt-camera-tile-frames-or-throw.util.ts
new file mode 100644
index 00000000000..dcb2b7cde9b
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/fetch-prebuilt-camera-tile-frames-or-throw.util.ts
@@ -0,0 +1,20 @@
+import { CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS } from 'src/logic-functions/constants/camera-tile-asset-paths';
+import { fetchPublicAssetOrThrow } from 'src/logic-functions/data/fetch-public-asset-or-throw.util';
+import { type CameraTileFrames } from 'src/logic-functions/types/camera-tile-frames.type';
+import { type PrebuiltCallRecorderStyle } from 'src/logic-functions/types/prebuilt-call-recorder-style.type';
+
+export const fetchPrebuiltCameraTileFramesOrThrow = async (
+ style: PrebuiltCallRecorderStyle,
+): Promise<CameraTileFrames> => {
+ const assetPaths = CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS[style];
+
+ const [recording, notRecording] = await Promise.all([
+ fetchPublicAssetOrThrow(assetPaths.recording),
+ fetchPublicAssetOrThrow(assetPaths.notRecording),
+ ]);
+
+ return {
+ recording: recording.toString('base64'),
+ notRecording: notRecording.toString('base64'),
+ };
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/fetch-public-asset-or-throw.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/fetch-public-asset-or-throw.util.ts
new file mode 100644
index 00000000000..06c884b0d29
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/fetch-public-asset-or-throw.util.ts
@@ -0,0 +1,34 @@
+import { getPublicAssetUrl, isDefined } from 'twenty-sdk/utils';
+
+import { fetchWithTimeout } from 'src/logic-functions/utils/fetch-with-timeout.util';
+
+const publicAssetCache = new Map<string, Promise<Buffer>>();
+
+const downloadPublicAssetOrThrow = async (path: string): Promise<Buffer> => {
+ const response = await fetchWithTimeout(getPublicAssetUrl(path));
+
+ if (!response.ok) {
+ throw new Error(
+ `failed to download public asset ${path}: status ${response.status}`,
+ );
+ }
+
+ return Buffer.from(await response.arrayBuffer());
+};
+
+export const fetchPublicAssetOrThrow = (path: string): Promise<Buffer> => {
+ const cachedAsset = publicAssetCache.get(path);
+
+ if (isDefined(cachedAsset)) {
+ return cachedAsset;
+ }
+
+ const asset = downloadPublicAssetOrThrow(path).catch((error: unknown) => {
+ publicAssetCache.delete(path);
+ throw error;
+ });
+
+ publicAssetCache.set(path, asset);
+
+ return asset;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-camera-tile-font-file-path-or-throw.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-camera-tile-font-file-path-or-throw.util.ts
new file mode 100644
index 00000000000..6d64bf81880
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-camera-tile-font-file-path-or-throw.util.ts
@@ -0,0 +1,40 @@
+import { writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { isDefined } from 'twenty-sdk/utils';
+
+import { CAMERA_TILE_FONT_ASSET_PATH } from 'src/logic-functions/constants/camera-tile-asset-paths';
+import { fetchPublicAssetOrThrow } from 'src/logic-functions/data/fetch-public-asset-or-throw.util';
+
+const FONT_FILE_PATH = join(
+ tmpdir(),
+ `call-recorder-inter-semibold-${process.pid}.ttf`,
+);
+
+const fontFilePathCache = new Map<string, Promise<string>>();
+
+const writeFontFileOrThrow = async (): Promise<string> => {
+ await writeFile(
+ FONT_FILE_PATH,
+ await fetchPublicAssetOrThrow(CAMERA_TILE_FONT_ASSET_PATH),
+ );
+
+ return FONT_FILE_PATH;
+};
+
+export const getCameraTileFontFilePathOrThrow = (): Promise<string> => {
+ const cachedFontFilePath = fontFilePathCache.get(FONT_FILE_PATH);
+
+ if (isDefined(cachedFontFilePath)) {
+ return cachedFontFilePath;
+ }
+
+ const fontFilePath = writeFontFileOrThrow().catch((error: unknown) => {
+ fontFilePathCache.delete(FONT_FILE_PATH);
+ throw error;
+ });
+
+ fontFilePathCache.set(FONT_FILE_PATH, fontFilePath);
+
+ return fontFilePath;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-workspace-branding.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-workspace-branding.util.ts
new file mode 100644
index 00000000000..95785d29a2d
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-workspace-branding.util.ts
@@ -0,0 +1,57 @@
+import { MetadataApiClient } from 'twenty-client-sdk/metadata';
+
+import { fetchWithTimeout } from 'src/logic-functions/utils/fetch-with-timeout.util';
+import { isNonEmptyString } from 'src/logic-functions/utils/is-non-empty-string.util';
+
+export type WorkspaceBranding = {
+ logo: Buffer | undefined;
+ displayName: string | undefined;
+};
+
+const downloadLogo = async (logoUrl: string): Promise<Buffer | undefined> => {
+ try {
+ const response = await fetchWithTimeout(logoUrl);
+
+ if (!response.ok) {
+ console.warn(
+ `[call-recorder] failed to download workspace logo: status ${response.status}`,
+ );
+
+ return undefined;
+ }
+
+ return Buffer.from(await response.arrayBuffer());
+ } catch (error) {
+ console.warn(
+ `[call-recorder] failed to download workspace logo: ${error instanceof Error ? error.message : String(error)}`,
+ );
+
+ return undefined;
+ }
+};
+
+export const getWorkspaceBranding = async (): Promise<WorkspaceBranding> => {
+ try {
+ const metadataClient = new MetadataApiClient();
+
+ const queryResult = await metadataClient.query({
+ currentWorkspace: { logo: true, displayName: true },
+ });
+
+ const logoUrl = queryResult.currentWorkspace?.logo;
+ const displayName = queryResult.currentWorkspace?.displayName
+ ?.replace(/\s+/gu, ' ')
+ .trim();
+
+ return {
+ logo: isNonEmptyString(logoUrl) ? await downloadLogo(logoUrl) : undefined,
+ displayName: isNonEmptyString(displayName) ? displayName : undefined,
+ };
+ } catch (error) {
+ console.warn(
+ `[call-recorder] failed to read workspace branding: ${error instanceof Error ? error.message : String(error)}`,
+ );
+
+ return { logo: undefined, displayName: undefined };
+ }
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-workspace-logo.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-workspace-logo.util.ts
deleted file mode 100644
index da6b1a4df42..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/data/get-workspace-logo.util.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { MetadataApiClient } from 'twenty-client-sdk/metadata';
-
-import { isNonEmptyString } from 'src/logic-functions/utils/is-non-empty-string.util';
-
-const LOGO_DOWNLOAD_TIMEOUT_MS = 30_000;
-
-// `currentWorkspace.logo` resolves to a signed, expiring file URL that we then download.
-export const getWorkspaceLogo = async (): Promise<Buffer | undefined> => {
- try {
- const metadataClient = new MetadataApiClient();
-
- const queryResult = await metadataClient.query({
- currentWorkspace: { logo: true },
- });
-
- const logoUrl = queryResult.currentWorkspace?.logo;
-
- if (!isNonEmptyString(logoUrl)) {
- return undefined;
- }
-
- const response = await fetch(logoUrl, {
- signal: AbortSignal.timeout(LOGO_DOWNLOAD_TIMEOUT_MS),
- });
-
- if (!response.ok) {
- console.warn(
- `[call-recorder] failed to download workspace logo: status ${response.status}`,
- );
-
- return undefined;
- }
-
- return Buffer.from(await response.arrayBuffer());
- } catch (error) {
- console.warn(
- `[call-recorder] failed to read workspace logo: ${error instanceof Error ? error.message : String(error)}`,
- );
-
- return undefined;
- }
-};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-bot-image.util.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-bot-image.util.test.ts
deleted file mode 100644
index 1afd4c057f3..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-bot-image.util.test.ts
+++ /dev/null
@@ -1,127 +0,0 @@
-import sharp from 'sharp';
-import { describe, expect, it } from 'vitest';
-
-import { buildBotImage } from 'src/logic-functions/domain/build-bot-image.util';
-import {
- RECALL_BOT_IMAGE_HEIGHT,
- RECALL_BOT_IMAGE_MAX_BYTES,
- RECALL_BOT_IMAGE_WIDTH,
-} from 'src/logic-functions/constants/recall-bot-image-config';
-import {
- RECORDING_STATUS_BADGE_HEIGHT,
- RECORDING_STATUS_BADGE_INSET,
- RECORDING_STATUS_BADGE_WIDTH,
-} from 'src/logic-functions/constants/recording-status-badge-config';
-
-const createLogo = (format: 'png' | 'gif' | 'jpeg'): Promise<Buffer> => {
- const image = sharp({
- create: {
- width: 200,
- height: 200,
- channels: 3,
- background: '#3b82f6',
- },
- });
-
- if (format === 'png') {
- return image.png().toBuffer();
- }
-
- if (format === 'gif') {
- return image.gif().toBuffer();
- }
-
- return image.jpeg().toBuffer();
-};
-
-describe('buildBotImage', () => {
- it.each(['png', 'gif', 'jpeg'] as const)(
- 'produces a 1280x720 JPEG under the size cap from a %s logo',
- async (format) => {
- const logoBuffer = await createLogo(format);
-
- const base64Jpeg = await buildBotImage({
- logoBuffer,
- background: '#ffffff',
- });
-
- expect(base64Jpeg).toBeDefined();
-
- const jpegBuffer = Buffer.from(base64Jpeg as string, 'base64');
-
- // JPEG SOI marker.
- expect(jpegBuffer[0]).toBe(0xff);
- expect(jpegBuffer[1]).toBe(0xd8);
- expect(jpegBuffer.byteLength).toBeLessThanOrEqual(
- RECALL_BOT_IMAGE_MAX_BYTES,
- );
-
- const metadata = await sharp(jpegBuffer).metadata();
-
- expect(metadata.width).toBe(RECALL_BOT_IMAGE_WIDTH);
- expect(metadata.height).toBe(RECALL_BOT_IMAGE_HEIGHT);
- expect(metadata.format).toBe('jpeg');
- },
- );
-
- it('produces a valid 1280x720 JPEG with the recording badge', async () => {
- const logoBuffer = await createLogo('png');
-
- const base64Jpeg = await buildBotImage({
- logoBuffer,
- background: '#ffffff',
- withRecordingStatusBadge: true,
- });
-
- expect(base64Jpeg).toBeDefined();
-
- const jpegBuffer = Buffer.from(base64Jpeg as string, 'base64');
-
- expect(jpegBuffer.byteLength).toBeLessThanOrEqual(
- RECALL_BOT_IMAGE_MAX_BYTES,
- );
-
- const metadata = await sharp(jpegBuffer).metadata();
-
- expect(metadata.width).toBe(RECALL_BOT_IMAGE_WIDTH);
- expect(metadata.height).toBe(RECALL_BOT_IMAGE_HEIGHT);
- expect(metadata.format).toBe('jpeg');
- });
-
- it('composites the recording badge at the badge inset', async () => {
- const logoBuffer = await createLogo('png');
-
- const readBadgeRegion = async (
- withRecordingStatusBadge: boolean,
- ): Promise<Buffer> => {
- const base64Jpeg = await buildBotImage({
- logoBuffer,
- background: '#ffffff',
- withRecordingStatusBadge,
- });
-
- return sharp(Buffer.from(base64Jpeg as string, 'base64'))
- .extract({
- top: RECORDING_STATUS_BADGE_INSET,
- left: RECORDING_STATUS_BADGE_INSET,
- width: RECORDING_STATUS_BADGE_WIDTH,
- height: RECORDING_STATUS_BADGE_HEIGHT,
- })
- .raw()
- .toBuffer();
- };
-
- expect(await readBadgeRegion(true)).not.toEqual(
- await readBadgeRegion(false),
- );
- });
-
- it('returns undefined when the source cannot be decoded', async () => {
- const result = await buildBotImage({
- logoBuffer: Buffer.from('not-an-image'),
- background: '#ffffff',
- });
-
- expect(result).toBeUndefined();
- });
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-camera-tile-text-block.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-camera-tile-text-block.test.ts
new file mode 100644
index 00000000000..d8d6875316e
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-camera-tile-text-block.test.ts
@@ -0,0 +1,47 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ CAMERA_TILE_TEXT_LINE_GAP,
+ CAMERA_TILE_TEXT_TOP,
+ CAMERA_TILE_TITLE_LINE_HEIGHT,
+} from 'src/logic-functions/constants/camera-tile-config';
+import { buildCameraTileTextBlock } from 'src/logic-functions/domain/build-camera-tile-text-block.util';
+
+const line = (width: number) => ({
+ input: Buffer.from([]),
+ width,
+ height: 30,
+});
+
+const tops = (composites: { top?: number }[]) =>
+ composites.map(({ top }) => top);
+
+describe('buildCameraTileTextBlock', () => {
+ it('places a title alone at the top of the text area', () => {
+ const { lineComposites } = buildCameraTileTextBlock({ title: line(200) });
+
+ expect(tops(lineComposites)).toEqual([CAMERA_TILE_TEXT_TOP]);
+ });
+
+ it('places the subtitle one title line and a gap below the title', () => {
+ const { lineComposites } = buildCameraTileTextBlock({
+ title: line(200),
+ subtitle: line(300),
+ });
+
+ expect(tops(lineComposites)).toEqual([
+ CAMERA_TILE_TEXT_TOP,
+ CAMERA_TILE_TEXT_TOP +
+ CAMERA_TILE_TITLE_LINE_HEIGHT +
+ CAMERA_TILE_TEXT_LINE_GAP,
+ ]);
+ });
+
+ it('moves a subtitle without a title up to the top of the text area', () => {
+ const { lineComposites } = buildCameraTileTextBlock({
+ subtitle: line(300),
+ });
+
+ expect(tops(lineComposites)).toEqual([CAMERA_TILE_TEXT_TOP]);
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-camera-tile-workspace-composites.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-camera-tile-workspace-composites.test.ts
new file mode 100644
index 00000000000..39f5b91bf2d
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-camera-tile-workspace-composites.test.ts
@@ -0,0 +1,63 @@
+import sharp from 'sharp';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { CAMERA_TILE_POWERED_BY_LABEL } from 'src/logic-functions/constants/camera-tile-config';
+import { buildCameraTileWorkspaceComposites } from 'src/logic-functions/domain/build-camera-tile-workspace-composites.util';
+import { type CameraTileTextRenderer } from 'src/logic-functions/types/camera-tile-text-renderer.type';
+
+const renderText = vi.fn<CameraTileTextRenderer>(async () => ({
+ input: Buffer.from([]),
+ width: 200,
+ height: 30,
+}));
+
+const renderedTexts = () => renderText.mock.calls.map(([{ text }]) => text);
+
+const buildLogo = () =>
+ sharp({
+ create: { width: 64, height: 64, channels: 3, background: '#f25f29' },
+ })
+ .png()
+ .toBuffer();
+
+describe('buildCameraTileWorkspaceComposites', () => {
+ beforeEach(() => {
+ renderText.mockClear();
+ });
+
+ it('draws the workspace name with Powered by twenty.com under it', async () => {
+ const composites = await buildCameraTileWorkspaceComposites({
+ sharp,
+ renderText,
+ branding: { logo: await buildLogo(), displayName: 'Acme Inc.' },
+ });
+
+ expect(composites).toBeDefined();
+ expect(renderedTexts()).toEqual([
+ 'Acme Inc.',
+ CAMERA_TILE_POWERED_BY_LABEL,
+ ]);
+ });
+
+ it('keeps Powered by twenty.com under a logo whose workspace name cannot be drawn', async () => {
+ const composites = await buildCameraTileWorkspaceComposites({
+ sharp,
+ renderText,
+ branding: { logo: await buildLogo(), displayName: '日本商事' },
+ });
+
+ expect(composites).toBeDefined();
+ expect(renderedTexts()).toEqual([CAMERA_TILE_POWERED_BY_LABEL]);
+ });
+
+ it('leaves the tile to the Twenty fallback without a logo or a drawable name', async () => {
+ const composites = await buildCameraTileWorkspaceComposites({
+ sharp,
+ renderText,
+ branding: { logo: undefined, displayName: '日本商事' },
+ });
+
+ expect(composites).toBeUndefined();
+ expect(renderText).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recall-bot-automatic-video-output.util.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recall-bot-automatic-video-output.util.test.ts
index 5fdb32923f7..12f2db751c5 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recall-bot-automatic-video-output.util.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recall-bot-automatic-video-output.util.test.ts
@@ -1,11 +1,25 @@
+import { readFile } from 'node:fs/promises';
+import { join } from 'node:path';
+import sharp from 'sharp';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { buildRecallBotAutomaticVideoOutput } from 'src/logic-functions/domain/build-recall-bot-automatic-video-output.util';
+import {
+ CAMERA_TILE_FONT_ASSET_PATH,
+ CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS,
+ CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH,
+} from 'src/logic-functions/constants/camera-tile-asset-paths';
+import {
+ RECALL_BOT_IMAGE_HEIGHT,
+ RECALL_BOT_IMAGE_MAX_BYTES,
+ RECALL_BOT_IMAGE_WIDTH,
+} from 'src/logic-functions/constants/recall-bot-image-config';
-const sharpMock = vi.hoisted(() => vi.fn());
const metadataQueryMock = vi.hoisted(() => vi.fn());
-vi.mock('sharp', () => ({ default: sharpMock }));
+vi.mock('twenty-sdk/utils', async (importOriginal) => ({
+ ...(await importOriginal<object>()),
+ getPublicAssetUrl: (path: string) => `https://assets.test/${path}`,
+}));
vi.mock('twenty-client-sdk/metadata', () => ({
MetadataApiClient: class {
@@ -13,81 +27,55 @@ vi.mock('twenty-client-sdk/metadata', () => ({
},
}));
-const RECORDING_JPEG_BASE64 = Buffer.from('RECORDING_JPEG').toString('base64');
-const PLAIN_JPEG_BASE64 = Buffer.from('PLAIN_JPEG').toString('base64');
+const ASSET_URL_PREFIX = 'https://assets.test/';
+const LOGO_URL = 'https://files.test/workspace-logo.png';
+const PUBLIC_DIRECTORY = join(__dirname, '..', '..', '..', '..', 'public');
const fetchMock = vi.fn();
-let badgeBuildFails = false;
-let jpegComposeFails = false;
+const requestedAssetPaths = () =>
+ fetchMock.mock.calls
+ .map(([url]) => String(url))
+ .filter((url) => url.startsWith(ASSET_URL_PREFIX))
+ .map((url) => url.slice(ASSET_URL_PREFIX.length));
-type FakeSharpPipeline = {
- resize: () => FakeSharpPipeline;
- png: () => FakeSharpPipeline;
- jpeg: () => FakeSharpPipeline;
- composite: (composites: unknown[]) => FakeSharpPipeline;
- toBuffer: () => Promise<Buffer>;
-};
+const readFrameMetadata = (base64: string) =>
+ sharp(Buffer.from(base64, 'base64')).metadata();
-const buildSharpPipeline = (
- produce: (composites: unknown[]) => Buffer,
-): FakeSharpPipeline => {
- let appliedComposites: unknown[] = [];
- const pipeline: FakeSharpPipeline = {
- resize: () => pipeline,
- png: () => pipeline,
- jpeg: () => pipeline,
- composite: (composites) => {
- appliedComposites = composites;
- return pipeline;
- },
- toBuffer: async () => produce(appliedComposites),
- };
+const readPublicAssetAsBase64 = async (path: string) =>
+ (await readFile(join(PUBLIC_DIRECTORY, path))).toString('base64');
+
+const buildOutput = async () => {
+ const { buildRecallBotAutomaticVideoOutput } =
+ await import('src/logic-functions/domain/build-recall-bot-automatic-video-output.util');
- return pipeline;
+ return buildRecallBotAutomaticVideoOutput();
};
describe('buildRecallBotAutomaticVideoOutput', () => {
- beforeEach(() => {
+ beforeEach(async () => {
+ vi.resetModules();
vi.clearAllMocks();
- vi.stubGlobal('fetch', fetchMock);
- vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'true');
- vi.stubEnv('CALL_RECORDER_BOT_IMAGE_BACKGROUND', '#ffffff');
vi.spyOn(console, 'warn').mockImplementation(() => {});
- badgeBuildFails = false;
- jpegComposeFails = false;
- metadataQueryMock.mockResolvedValue({
- currentWorkspace: {
- logo: 'https://files.example.com/workspace-logo.png',
- },
- });
- fetchMock.mockResolvedValue(
- new Response(Buffer.from('logo'), { status: 200 }),
- );
- sharpMock.mockImplementation((input?: unknown) => {
- if (Buffer.isBuffer(input) && input.toString('utf8').startsWith('<svg')) {
- return buildSharpPipeline(() => {
- if (badgeBuildFails) {
- throw new Error('badge rendering failed');
- }
-
- return Buffer.from('BADGE_PNG');
- });
- }
-
- if (Buffer.isBuffer(input)) {
- return buildSharpPipeline(() => Buffer.from('LOGO_PNG'));
- }
+ vi.stubGlobal('fetch', fetchMock);
- return buildSharpPipeline((composites) => {
- if (jpegComposeFails) {
- throw new Error('jpeg composition failed');
- }
+ const logo = await sharp({
+ create: { width: 64, height: 64, channels: 3, background: '#f25f29' },
+ })
+ .png()
+ .toBuffer();
- return Buffer.from(
- composites.length > 1 ? 'RECORDING_JPEG' : 'PLAIN_JPEG',
- );
- });
+ fetchMock.mockImplementation(async (url: string) =>
+ url.startsWith(ASSET_URL_PREFIX)
+ ? new Response(
+ await readFile(
+ join(PUBLIC_DIRECTORY, url.slice(ASSET_URL_PREFIX.length)),
+ ),
+ )
+ : new Response(logo),
+ );
+ metadataQueryMock.mockResolvedValue({
+ currentWorkspace: { logo: LOGO_URL, displayName: 'Acme Inc.' },
});
});
@@ -97,49 +85,180 @@ describe('buildRecallBotAutomaticVideoOutput', () => {
vi.restoreAllMocks();
});
- it('badges the recording state and leaves the not-recording state plain', async () => {
- const result = await buildRecallBotAutomaticVideoOutput();
+ it('sends no image for the None style', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'NONE');
+
+ expect(await buildOutput()).toBeUndefined();
+ expect(fetchMock).not.toHaveBeenCalled();
+ });
+
+ it.each(['TWENTY', 'MINIMAL'] as const)(
+ 'sends the prebuilt %s frames without rendering',
+ async (style) => {
+ vi.stubEnv('CALL_RECORDER_STYLE', style);
+ const assetPaths = CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS[style];
+
+ expect(await buildOutput()).toEqual({
+ in_call_recording: {
+ kind: 'jpeg',
+ b64_data: await readPublicAssetAsBase64(assetPaths.recording),
+ },
+ in_call_not_recording: {
+ kind: 'jpeg',
+ b64_data: await readPublicAssetAsBase64(assetPaths.notRecording),
+ },
+ });
+ expect(requestedAssetPaths()).not.toContain(CAMERA_TILE_FONT_ASSET_PATH);
+ expect(metadataQueryMock).not.toHaveBeenCalled();
+ },
+ );
+
+ it('defaults to the Twenty style when the variable is unset', async () => {
+ expect(await buildOutput()).toBeDefined();
+ expect(requestedAssetPaths()).toContain(
+ CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS.TWENTY.notRecording,
+ );
+ });
+
+ it.each(
+ Object.values(CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS).flatMap(
+ ({ recording, notRecording }) => [recording, notRecording],
+ ),
+ )('ships %s as a frame Recall accepts', async (path) => {
+ const frame = await readFile(join(PUBLIC_DIRECTORY, path));
- expect(result).toEqual({
- in_call_recording: { kind: 'jpeg', b64_data: RECORDING_JPEG_BASE64 },
- in_call_not_recording: { kind: 'jpeg', b64_data: PLAIN_JPEG_BASE64 },
+ expect(frame.byteLength).toBeLessThanOrEqual(RECALL_BOT_IMAGE_MAX_BYTES);
+ expect(await sharp(frame).metadata()).toMatchObject({
+ format: 'jpeg',
+ width: RECALL_BOT_IMAGE_WIDTH,
+ height: RECALL_BOT_IMAGE_HEIGHT,
});
});
- it('falls back to the plain image when the badged variant fails', async () => {
- badgeBuildFails = true;
+ it('renders distinct 1280x720 workspace frames for the recording states', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'WORKSPACE');
+
+ const output = await buildOutput();
- const result = await buildRecallBotAutomaticVideoOutput();
+ expect(output?.in_call_recording.b64_data).not.toEqual(
+ output?.in_call_not_recording.b64_data,
+ );
- expect(result).toEqual({
- in_call_recording: { kind: 'jpeg', b64_data: PLAIN_JPEG_BASE64 },
- in_call_not_recording: { kind: 'jpeg', b64_data: PLAIN_JPEG_BASE64 },
+ for (const frame of [
+ output?.in_call_recording,
+ output?.in_call_not_recording,
+ ]) {
+ expect(frame?.kind).toBe('jpeg');
+ expect(await readFrameMetadata(frame?.b64_data ?? '')).toMatchObject({
+ format: 'jpeg',
+ width: RECALL_BOT_IMAGE_WIDTH,
+ height: RECALL_BOT_IMAGE_HEIGHT,
+ });
+ }
+ expect(fetchMock).toHaveBeenCalledWith(LOGO_URL, expect.anything());
+ expect(requestedAssetPaths()).toContain(
+ CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH,
+ );
+ });
+
+ it('renders a workspace name wider than the safe zone', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'WORKSPACE');
+ metadataQueryMock.mockResolvedValue({
+ currentWorkspace: {
+ logo: LOGO_URL,
+ displayName:
+ 'A workspace name long enough to overflow the camera tile on its own line',
+ },
});
+
+ const output = await buildOutput();
+
+ expect(output).toBeDefined();
+ expect(console.warn).not.toHaveBeenCalled();
});
- it('returns undefined when the feature is disabled', async () => {
- vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+ it('keeps the workspace name when the logo download fails', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'WORKSPACE');
+ const assetFetch = fetchMock.getMockImplementation();
+
+ fetchMock.mockImplementation(async (url: string) => {
+ if (url === LOGO_URL) {
+ throw new Error('logo download timed out');
+ }
+
+ return assetFetch?.(url);
+ });
+
+ expect(await buildOutput()).toBeDefined();
+ expect(requestedAssetPaths()).toContain(
+ CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH,
+ );
+ });
- const result = await buildRecallBotAutomaticVideoOutput();
+ it('falls back to the Twenty style when the workspace has neither a logo nor a drawable name', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'WORKSPACE');
+ metadataQueryMock.mockResolvedValue({
+ currentWorkspace: { logo: null, displayName: '日本商事' },
+ });
- expect(result).toBeUndefined();
- expect(metadataQueryMock).not.toHaveBeenCalled();
+ expect(await buildOutput()).toBeDefined();
+ expect(requestedAssetPaths()).toContain(
+ CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS.TWENTY.notRecording,
+ );
+ expect(requestedAssetPaths()).not.toContain(
+ CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH,
+ );
});
- it('returns undefined when no workspace logo is set', async () => {
- metadataQueryMock.mockResolvedValue({ currentWorkspace: { logo: null } });
+ it('falls back to the Twenty frames when the workspace tile fails', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'WORKSPACE');
+ const assetFetch = fetchMock.getMockImplementation();
- const result = await buildRecallBotAutomaticVideoOutput();
+ fetchMock.mockImplementation(async (url: string) =>
+ url.endsWith(CAMERA_TILE_FONT_ASSET_PATH)
+ ? new Response(null, { status: 503 })
+ : assetFetch?.(url),
+ );
- expect(result).toBeUndefined();
- expect(sharpMock).not.toHaveBeenCalled();
+ expect(await buildOutput()).toEqual({
+ in_call_recording: {
+ kind: 'jpeg',
+ b64_data: await readPublicAssetAsBase64(
+ CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS.TWENTY.recording,
+ ),
+ },
+ in_call_not_recording: {
+ kind: 'jpeg',
+ b64_data: await readPublicAssetAsBase64(
+ CAMERA_TILE_PREBUILT_FRAME_ASSET_PATHS.TWENTY.notRecording,
+ ),
+ },
+ });
+ expect(console.warn).toHaveBeenCalledOnce();
});
- it('returns undefined when the image cannot be built', async () => {
- jpegComposeFails = true;
+ it('falls back to the plain frame when the recording frame fails', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'WORKSPACE');
+ vi.doMock('src/logic-functions/domain/build-bot-image.util', () => ({
+ buildBotImage: vi
+ .fn()
+ .mockResolvedValueOnce('PLAIN_FRAME')
+ .mockRejectedValueOnce(new Error('encode failed')),
+ }));
+
+ expect(await buildOutput()).toEqual({
+ in_call_recording: { kind: 'jpeg', b64_data: 'PLAIN_FRAME' },
+ in_call_not_recording: { kind: 'jpeg', b64_data: 'PLAIN_FRAME' },
+ });
+ expect(console.warn).toHaveBeenCalledOnce();
+
+ vi.doUnmock('src/logic-functions/domain/build-bot-image.util');
+ });
- const result = await buildRecallBotAutomaticVideoOutput();
+ it('sends no image when an asset cannot be downloaded', async () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', 'TWENTY');
+ fetchMock.mockResolvedValue(new Response(null, { status: 503 }));
- expect(result).toBeUndefined();
+ expect(await buildOutput()).toBeUndefined();
});
});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recording-status-badge.util.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recording-status-badge.util.test.ts
deleted file mode 100644
index ac9a6bccb47..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/build-recording-status-badge.util.test.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import sharp from 'sharp';
-import { describe, expect, it } from 'vitest';
-
-import {
- RECORDING_STATUS_BADGE_HEIGHT,
- RECORDING_STATUS_BADGE_LABEL_LEFT,
- RECORDING_STATUS_BADGE_WIDTH,
-} from 'src/logic-functions/constants/recording-status-badge-config';
-import {
- buildRecordingStatusBadge,
- buildRecordingStatusBadgeSvg,
-} from 'src/logic-functions/domain/build-recording-status-badge.util';
-
-describe('buildRecordingStatusBadge', () => {
- it('draws the label without depending on any system font', () => {
- const svg = buildRecordingStatusBadgeSvg();
-
- expect(svg).not.toContain('<text');
- expect(svg).not.toContain('font-family');
- });
-
- it('renders a badge sized to its contents', async () => {
- const metadata = await sharp(
- await buildRecordingStatusBadge(sharp),
- ).metadata();
-
- expect(metadata.width).toBe(RECORDING_STATUS_BADGE_WIDTH);
- expect(metadata.height).toBe(RECORDING_STATUS_BADGE_HEIGHT);
- });
-
- it('rasterizes label ink to the right of the dot', async () => {
- const { data, info } = await sharp(await buildRecordingStatusBadge(sharp))
- .ensureAlpha()
- .raw()
- .toBuffer({ resolveWithObject: true });
-
- let labelInkPixelCount = 0;
-
- for (let y = 0; y < info.height; y++) {
- for (let x = RECORDING_STATUS_BADGE_LABEL_LEFT; x < info.width; x++) {
- const offset = (y * info.width + x) * info.channels;
-
- if (
- data[offset] > 150 &&
- data[offset + 1] < 120 &&
- data[offset + 2] < 120
- ) {
- labelInkPixelCount++;
- }
- }
- }
-
- expect(labelInkPixelCount).toBeGreaterThan(100);
- });
-});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-camera-tile-text.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-camera-tile-text.test.ts
new file mode 100644
index 00000000000..2186d689763
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-camera-tile-text.test.ts
@@ -0,0 +1,46 @@
+import { join } from 'node:path';
+import sharp from 'sharp';
+import { describe, expect, it } from 'vitest';
+
+import { renderCameraTileText } from 'src/logic-functions/domain/render-camera-tile-text.util';
+
+const FONT_FILE_PATH = join(
+ __dirname,
+ '..',
+ '..',
+ '..',
+ '..',
+ 'public',
+ 'fonts',
+ 'Inter-SemiBold.ttf',
+);
+const MAX_WIDTH = 400;
+
+const render = ({ text, maxWidth }: { text: string; maxWidth?: number }) =>
+ renderCameraTileText({
+ sharp,
+ fontFilePath: FONT_FILE_PATH,
+ text,
+ fontSize: 44,
+ maxWidth,
+ });
+
+describe('renderCameraTileText', () => {
+ it('keeps text that fits at its natural size', async () => {
+ const natural = await render({ text: 'Acme' });
+ const constrained = await render({ text: 'Acme', maxWidth: MAX_WIDTH });
+
+ expect(constrained.width).toBe(natural.width);
+ expect(constrained.height).toBe(natural.height);
+ });
+
+ it('cuts text wider than the max width at its full size', async () => {
+ const text = 'A workspace name long enough to overflow the camera tile';
+ const natural = await render({ text });
+ const constrained = await render({ text, maxWidth: MAX_WIDTH });
+
+ expect(natural.width).toBeGreaterThan(MAX_WIDTH);
+ expect(constrained.width).toBeLessThanOrEqual(MAX_WIDTH);
+ expect(constrained.height).toBeGreaterThan(natural.height * 0.9);
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-truncated-camera-tile-text.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-truncated-camera-tile-text.test.ts
new file mode 100644
index 00000000000..6c4d702241a
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/__tests__/render-truncated-camera-tile-text.test.ts
@@ -0,0 +1,79 @@
+import { describe, expect, it } from 'vitest';
+
+import { renderTruncatedCameraTileText } from 'src/logic-functions/domain/render-truncated-camera-tile-text.util';
+
+const CHARACTER_WIDTH = 10;
+
+const graphemeSegmenter = new Intl.Segmenter(undefined, {
+ granularity: 'grapheme',
+});
+
+const renderMonospace = async (content: string) => ({
+ input: Buffer.from(content),
+ width:
+ Array.from(graphemeSegmenter.segment(content)).length * CHARACTER_WIDTH,
+ height: 20,
+});
+
+const truncate = async ({
+ text,
+ maxWidth,
+}: {
+ text: string;
+ maxWidth: number;
+}) =>
+ (
+ await renderTruncatedCameraTileText({
+ text,
+ maxWidth,
+ render: renderMonospace,
+ })
+ ).input.toString();
+
+describe('renderTruncatedCameraTileText', () => {
+ it('keeps the longest prefix that fits with the ellipsis', async () => {
+ expect(await truncate({ text: 'Acme International', maxWidth: 70 })).toBe(
+ 'Acme I…',
+ );
+ });
+
+ it('drops trailing spaces before the ellipsis', async () => {
+ expect(await truncate({ text: 'Acme International', maxWidth: 50 })).toBe(
+ 'Acme…',
+ );
+ });
+
+ it('keeps accented characters whole', async () => {
+ expect(await truncate({ text: 'Café Société', maxWidth: 50 })).toBe(
+ 'Café…',
+ );
+ });
+
+ it.each([
+ { text: 'Aq\u0303 Labs', maxCharacters: 3, expected: 'A…' },
+ {
+ text: 'Dev \u{1F469}\u200D\u{1F4BB} Team',
+ maxCharacters: 6,
+ expected: 'Dev…',
+ },
+ ])(
+ 'drops $text whole clusters rather than splitting them',
+ async ({ text, maxCharacters, expected }) => {
+ const truncated = await renderTruncatedCameraTileText({
+ text,
+ maxWidth: maxCharacters * CHARACTER_WIDTH,
+ render: async (content) => ({
+ input: Buffer.from(content),
+ width: Array.from(content).length * CHARACTER_WIDTH,
+ height: 20,
+ }),
+ });
+
+ expect(truncated.input.toString()).toBe(expected);
+ },
+ );
+
+ it('falls back to the ellipsis alone when nothing else fits', async () => {
+ expect(await truncate({ text: 'Acme', maxWidth: 5 })).toBe('…');
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-bot-image.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-bot-image.util.ts
index d8fc0bdcad8..13e1be9392e 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-bot-image.util.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-bot-image.util.ts
@@ -1,110 +1,51 @@
-import type { OverlayOptions } from 'sharp';
+import { type OverlayOptions } from 'sharp';
import {
- RECALL_BOT_IMAGE_HEIGHT,
RECALL_BOT_IMAGE_JPEG_QUALITY,
- RECALL_BOT_IMAGE_LOGO_MAX_HEIGHT,
- RECALL_BOT_IMAGE_LOGO_MAX_WIDTH,
RECALL_BOT_IMAGE_MAX_BYTES,
RECALL_BOT_IMAGE_MIN_JPEG_QUALITY,
- RECALL_BOT_IMAGE_WIDTH,
} from 'src/logic-functions/constants/recall-bot-image-config';
-import { RECORDING_STATUS_BADGE_INSET } from 'src/logic-functions/constants/recording-status-badge-config';
-import { buildRecordingStatusBadge } from 'src/logic-functions/domain/build-recording-status-badge.util';
+import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';
const JPEG_QUALITY_STEP = 10;
-type SharpFactory = typeof import('sharp').default;
+const JPEG_QUALITIES = Array.from(
+ {
+ length:
+ Math.floor(
+ (RECALL_BOT_IMAGE_JPEG_QUALITY - RECALL_BOT_IMAGE_MIN_JPEG_QUALITY) /
+ JPEG_QUALITY_STEP,
+ ) + 1,
+ },
+ (_, index) => RECALL_BOT_IMAGE_JPEG_QUALITY - index * JPEG_QUALITY_STEP,
+);
export const buildBotImage = async ({
- logoBuffer,
+ sharp,
background,
- withRecordingStatusBadge = false,
+ composites,
}: {
- logoBuffer: Buffer;
- background: string;
- withRecordingStatusBadge?: boolean;
+ sharp: SharpFactory;
+ background: Buffer;
+ composites: OverlayOptions[];
}): Promise<string | undefined> => {
- try {
- // Loaded on use so the native module isn't required when the manifest build
- // merely imports this module.
- const sharp = await loadSharp();
-
- // Animated sources collapse to their first frame, which is the intended tile.
- const logo = await sharp(logoBuffer)
- .resize(
- RECALL_BOT_IMAGE_LOGO_MAX_WIDTH,
- RECALL_BOT_IMAGE_LOGO_MAX_HEIGHT,
- { fit: 'inside', withoutEnlargement: true },
- )
- .png()
+ const composeJpeg = (quality: number) =>
+ sharp(background)
+ .composite(composites)
+ .jpeg({ quality, mozjpeg: true })
.toBuffer();
- const composites: OverlayOptions[] = [{ input: logo, gravity: 'center' }];
-
- if (withRecordingStatusBadge) {
- composites.push({
- input: await buildRecordingStatusBadge(sharp),
- top: RECORDING_STATUS_BADGE_INSET,
- left: RECORDING_STATUS_BADGE_INSET,
- });
- }
-
- let quality = RECALL_BOT_IMAGE_JPEG_QUALITY;
- let jpeg = await composeJpeg({ sharp, composites, background, quality });
-
- while (
- jpeg.byteLength > RECALL_BOT_IMAGE_MAX_BYTES &&
- quality - JPEG_QUALITY_STEP >= RECALL_BOT_IMAGE_MIN_JPEG_QUALITY
- ) {
- quality -= JPEG_QUALITY_STEP;
- jpeg = await composeJpeg({ sharp, composites, background, quality });
- }
-
- if (jpeg.byteLength > RECALL_BOT_IMAGE_MAX_BYTES) {
- console.warn(
- '[call-recorder] workspace logo could not be encoded under the Recall image size limit',
- );
+ for (const quality of JPEG_QUALITIES) {
+ const jpeg = await composeJpeg(quality);
- return undefined;
+ if (jpeg.byteLength <= RECALL_BOT_IMAGE_MAX_BYTES) {
+ return jpeg.toString('base64');
}
-
- return jpeg.toString('base64');
- } catch (error) {
- console.warn(
- `[call-recorder] failed to build bot image from workspace logo: ${error instanceof Error ? error.message : String(error)}`,
- );
-
- return undefined;
}
-};
-
-const composeJpeg = ({
- sharp,
- composites,
- background,
- quality,
-}: {
- sharp: SharpFactory;
- composites: OverlayOptions[];
- background: string;
- quality: number;
-}): Promise<Buffer> =>
- sharp({
- create: {
- width: RECALL_BOT_IMAGE_WIDTH,
- height: RECALL_BOT_IMAGE_HEIGHT,
- channels: 3,
- background,
- },
- })
- .composite(composites)
- .jpeg({ quality, mozjpeg: true })
- .toBuffer();
-const loadSharp = async (): Promise<SharpFactory> => {
- const sharpModule = await import('sharp');
+ console.warn(
+ '[call-recorder] camera tile could not be encoded under the Recall image size limit',
+ );
- return ((sharpModule.default as unknown as { default?: SharpFactory })
- .default ?? sharpModule.default) as SharpFactory;
+ return undefined;
};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-plate-svg.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-plate-svg.util.ts
new file mode 100644
index 00000000000..f710b3597f0
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-plate-svg.util.ts
@@ -0,0 +1,22 @@
+import {
+ CAMERA_TILE_PLATE_COLOR,
+ CAMERA_TILE_PLATE_RADIUS,
+ CAMERA_TILE_PLATE_SIZE,
+ CAMERA_TILE_PLATE_STROKE_COLOR,
+ CAMERA_TILE_PLATE_TOP,
+} from 'src/logic-functions/constants/camera-tile-config';
+import { RECALL_BOT_IMAGE_WIDTH } from 'src/logic-functions/constants/recall-bot-image-config';
+
+export const buildCameraTilePlateSvg = (): string => {
+ const left = (RECALL_BOT_IMAGE_WIDTH - CAMERA_TILE_PLATE_SIZE) / 2;
+ const plate = `x="${left}" y="${CAMERA_TILE_PLATE_TOP}" width="${CAMERA_TILE_PLATE_SIZE}" height="${CAMERA_TILE_PLATE_SIZE}" rx="${CAMERA_TILE_PLATE_RADIUS}"`;
+
+ return [
+ '<defs><filter id="shadow" x="-50%" y="-50%" width="200%" height="200%">',
+ '<feGaussianBlur in="SourceAlpha" stdDeviation="26"/><feOffset dy="16"/>',
+ '<feComponentTransfer><feFuncA type="linear" slope="0.55"/></feComponentTransfer>',
+ '</filter></defs>',
+ `<rect ${plate} fill="#000" filter="url(#shadow)"/>`,
+ `<rect ${plate} fill="${CAMERA_TILE_PLATE_COLOR}" stroke="${CAMERA_TILE_PLATE_STROKE_COLOR}" stroke-width="2"/>`,
+ ].join('');
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-recording-composites.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-recording-composites.util.ts
new file mode 100644
index 00000000000..b95dee338e2
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-recording-composites.util.ts
@@ -0,0 +1,59 @@
+import { type OverlayOptions } from 'sharp';
+
+import {
+ CAMERA_TILE_RECORDING_BOTTOM_INSET,
+ CAMERA_TILE_RECORDING_DOT_COLOR,
+ CAMERA_TILE_RECORDING_DOT_GAP,
+ CAMERA_TILE_RECORDING_DOT_SIZE,
+ CAMERA_TILE_RECORDING_FONT_SIZE,
+ CAMERA_TILE_RECORDING_LABEL,
+ CAMERA_TILE_SECONDARY_TEXT_OPACITY,
+} from 'src/logic-functions/constants/camera-tile-config';
+import {
+ RECALL_BOT_IMAGE_HEIGHT,
+ RECALL_BOT_IMAGE_WIDTH,
+} from 'src/logic-functions/constants/recall-bot-image-config';
+import { buildCameraTileScrimSvg } from 'src/logic-functions/domain/build-camera-tile-scrim-svg.util';
+import { renderCameraTileSvgLayer } from 'src/logic-functions/domain/render-camera-tile-svg-layer.util';
+import { type CameraTileTextRenderer } from 'src/logic-functions/types/camera-tile-text-renderer.type';
+import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';
+
+export const buildCameraTileRecordingComposites = async ({
+ sharp,
+ renderText,
+}: {
+ sharp: SharpFactory;
+ renderText: CameraTileTextRenderer;
+}): Promise<OverlayOptions[]> => {
+ const label = await renderText({
+ text: CAMERA_TILE_RECORDING_LABEL,
+ fontSize: CAMERA_TILE_RECORDING_FONT_SIZE,
+ opacity: CAMERA_TILE_SECONDARY_TEXT_OPACITY,
+ });
+
+ const left = Math.round(
+ (RECALL_BOT_IMAGE_WIDTH -
+ (CAMERA_TILE_RECORDING_DOT_SIZE +
+ CAMERA_TILE_RECORDING_DOT_GAP +
+ label.width)) /
+ 2,
+ );
+ const top =
+ RECALL_BOT_IMAGE_HEIGHT - CAMERA_TILE_RECORDING_BOTTOM_INSET - label.height;
+ const centerY = top + label.height / 2;
+
+ return [
+ await renderCameraTileSvgLayer({
+ sharp,
+ content:
+ buildCameraTileScrimSvg({ centerY, radiusX: 200, radiusY: 44 }) +
+ `<circle cx="${left + CAMERA_TILE_RECORDING_DOT_SIZE / 2}" cy="${centerY}" r="${CAMERA_TILE_RECORDING_DOT_SIZE / 2}" fill="${CAMERA_TILE_RECORDING_DOT_COLOR}"/>`,
+ }),
+ {
+ input: label.input,
+ left:
+ left + CAMERA_TILE_RECORDING_DOT_SIZE + CAMERA_TILE_RECORDING_DOT_GAP,
+ top,
+ },
+ ];
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-scrim-svg.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-scrim-svg.util.ts
new file mode 100644
index 00000000000..4333855f1b5
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-scrim-svg.util.ts
@@ -0,0 +1,19 @@
+import { CAMERA_TILE_BACKGROUND_COLOR } from 'src/logic-functions/constants/camera-tile-config';
+import { RECALL_BOT_IMAGE_WIDTH } from 'src/logic-functions/constants/recall-bot-image-config';
+
+export const buildCameraTileScrimSvg = ({
+ centerY,
+ radiusX,
+ radiusY,
+}: {
+ centerY: number;
+ radiusX: number;
+ radiusY: number;
+}): string =>
+ [
+ '<defs><radialGradient id="scrim" cx="50%" cy="50%" r="50%">',
+ `<stop offset="0.45" stop-color="${CAMERA_TILE_BACKGROUND_COLOR}" stop-opacity="0.94"/>`,
+ `<stop offset="1" stop-color="${CAMERA_TILE_BACKGROUND_COLOR}" stop-opacity="0"/>`,
+ '</radialGradient></defs>',
+ `<ellipse cx="${RECALL_BOT_IMAGE_WIDTH / 2}" cy="${centerY}" rx="${radiusX}" ry="${radiusY}" fill="url(#scrim)"/>`,
+ ].join('');
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-text-block.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-text-block.util.ts
new file mode 100644
index 00000000000..b82d66a29b0
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-text-block.util.ts
@@ -0,0 +1,47 @@
+import { type OverlayOptions } from 'sharp';
+import { isDefined } from 'twenty-sdk/utils';
+
+import {
+ CAMERA_TILE_SUBTITLE_LINE_HEIGHT,
+ CAMERA_TILE_TEXT_LINE_GAP,
+ CAMERA_TILE_TEXT_TOP,
+ CAMERA_TILE_TITLE_LINE_HEIGHT,
+} from 'src/logic-functions/constants/camera-tile-config';
+import { buildCameraTileScrimSvg } from 'src/logic-functions/domain/build-camera-tile-scrim-svg.util';
+import { centerCameraTileItem } from 'src/logic-functions/domain/center-camera-tile-item.util';
+import { type CameraTileText } from 'src/logic-functions/domain/render-camera-tile-text.util';
+
+export const buildCameraTileTextBlock = ({
+ title,
+ subtitle,
+}: {
+ title?: CameraTileText;
+ subtitle?: CameraTileText;
+}): { lineComposites: OverlayOptions[]; scrimSvg: string } => {
+ const subtitleTop = isDefined(title)
+ ? CAMERA_TILE_TEXT_TOP +
+ CAMERA_TILE_TITLE_LINE_HEIGHT +
+ CAMERA_TILE_TEXT_LINE_GAP
+ : CAMERA_TILE_TEXT_TOP;
+ const blockBottom = isDefined(subtitle)
+ ? subtitleTop + CAMERA_TILE_SUBTITLE_LINE_HEIGHT
+ : CAMERA_TILE_TEXT_TOP + CAMERA_TILE_TITLE_LINE_HEIGHT;
+ const blockHeight = blockBottom - CAMERA_TILE_TEXT_TOP;
+ const blockWidth = Math.max(title?.width ?? 0, subtitle?.width ?? 0);
+
+ return {
+ lineComposites: [
+ ...(isDefined(title)
+ ? [centerCameraTileItem({ item: title, top: CAMERA_TILE_TEXT_TOP })]
+ : []),
+ ...(isDefined(subtitle)
+ ? [centerCameraTileItem({ item: subtitle, top: subtitleTop })]
+ : []),
+ ],
+ scrimSvg: buildCameraTileScrimSvg({
+ centerY: CAMERA_TILE_TEXT_TOP + blockHeight / 2,
+ radiusX: blockWidth / 2 + 160,
+ radiusY: blockHeight / 2 + 50,
+ }),
+ };
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-workspace-composites.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-workspace-composites.util.ts
new file mode 100644
index 00000000000..90735f2ade1
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-camera-tile-workspace-composites.util.ts
@@ -0,0 +1,110 @@
+import { isUndefined } from '@sniptt/guards';
+import { type OverlayOptions } from 'sharp';
+import { isDefined } from 'twenty-sdk/utils';
+
+import {
+ CAMERA_TILE_INITIAL_COLOR,
+ CAMERA_TILE_INITIAL_FONT_SIZE,
+ CAMERA_TILE_PLATE_SIZE,
+ CAMERA_TILE_PLATE_TOP,
+ CAMERA_TILE_POWERED_BY_LABEL,
+ CAMERA_TILE_SAFE_ZONE_WIDTH,
+ CAMERA_TILE_SECONDARY_TEXT_OPACITY,
+ CAMERA_TILE_SUBTITLE_FONT_SIZE,
+ CAMERA_TILE_TITLE_FONT_SIZE,
+} from 'src/logic-functions/constants/camera-tile-config';
+import { type WorkspaceBranding } from 'src/logic-functions/data/get-workspace-branding.util';
+import { buildCameraTilePlateSvg } from 'src/logic-functions/domain/build-camera-tile-plate-svg.util';
+import { buildCameraTileTextBlock } from 'src/logic-functions/domain/build-camera-tile-text-block.util';
+import { centerCameraTileItem } from 'src/logic-functions/domain/center-camera-tile-item.util';
+import { renderCameraTileLogo } from 'src/logic-functions/domain/render-camera-tile-logo.util';
+import { renderCameraTileSvgLayer } from 'src/logic-functions/domain/render-camera-tile-svg-layer.util';
+import { type CameraTileTextRenderer } from 'src/logic-functions/types/camera-tile-text-renderer.type';
+import { canRenderWithCameraTileFont } from 'src/logic-functions/utils/can-render-with-camera-tile-font.util';
+import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';
+
+const renderInitial = async ({
+ renderText,
+ displayName,
+}: {
+ renderText: CameraTileTextRenderer;
+ displayName: string;
+}): Promise<OverlayOptions> => {
+ const initial = await renderText({
+ text: Array.from(displayName)[0].toLocaleUpperCase(),
+ fontSize: CAMERA_TILE_INITIAL_FONT_SIZE,
+ color: CAMERA_TILE_INITIAL_COLOR,
+ });
+
+ return centerCameraTileItem({
+ item: initial,
+ top: CAMERA_TILE_PLATE_TOP + (CAMERA_TILE_PLATE_SIZE - initial.height) / 2,
+ });
+};
+
+const renderPoweredBy = (renderText: CameraTileTextRenderer) =>
+ renderText({
+ text: CAMERA_TILE_POWERED_BY_LABEL,
+ fontSize: CAMERA_TILE_SUBTITLE_FONT_SIZE,
+ opacity: CAMERA_TILE_SECONDARY_TEXT_OPACITY,
+ });
+
+export const buildCameraTileWorkspaceComposites = async ({
+ sharp,
+ renderText,
+ branding,
+}: {
+ sharp: SharpFactory;
+ renderText: CameraTileTextRenderer;
+ branding: WorkspaceBranding | undefined;
+}): Promise<OverlayOptions[] | undefined> => {
+ const displayName =
+ isDefined(branding?.displayName) &&
+ canRenderWithCameraTileFont(branding.displayName)
+ ? branding.displayName
+ : undefined;
+
+ const logo = isDefined(branding?.logo)
+ ? await renderCameraTileLogo({ sharp, logo: branding.logo })
+ : undefined;
+
+ if (isUndefined(displayName)) {
+ if (isUndefined(logo)) {
+ return undefined;
+ }
+
+ const { lineComposites, scrimSvg } = buildCameraTileTextBlock({
+ subtitle: await renderPoweredBy(renderText),
+ });
+
+ return [
+ await renderCameraTileSvgLayer({
+ sharp,
+ content: scrimSvg + buildCameraTilePlateSvg(),
+ }),
+ logo,
+ ...lineComposites,
+ ];
+ }
+
+ const plateContent =
+ logo ?? (await renderInitial({ renderText, displayName }));
+
+ const { lineComposites, scrimSvg } = buildCameraTileTextBlock({
+ title: await renderText({
+ text: displayName,
+ fontSize: CAMERA_TILE_TITLE_FONT_SIZE,
+ maxWidth: CAMERA_TILE_SAFE_ZONE_WIDTH,
+ }),
+ subtitle: await renderPoweredBy(renderText),
+ });
+
+ return [
+ await renderCameraTileSvgLayer({
+ sharp,
+ content: scrimSvg + buildCameraTilePlateSvg(),
+ }),
+ plateContent,
+ ...lineComposites,
+ ];
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recall-bot-automatic-video-output.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recall-bot-automatic-video-output.util.ts
index 59b536f30cc..702df5d207e 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recall-bot-automatic-video-output.util.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recall-bot-automatic-video-output.util.ts
@@ -1,41 +1,53 @@
-import { isUndefined } from '@sniptt/guards';
-
-import { getBotImageBackground } from 'src/logic-functions/constants/get-bot-image-background';
-import { isWorkspaceLogoBotImageEnabled } from 'src/logic-functions/constants/is-workspace-logo-bot-image-enabled';
-import { getWorkspaceLogo } from 'src/logic-functions/data/get-workspace-logo.util';
-import { buildBotImage } from 'src/logic-functions/domain/build-bot-image.util';
+import { fetchPrebuiltCameraTileFramesOrThrow } from 'src/logic-functions/data/fetch-prebuilt-camera-tile-frames-or-throw.util';
+import { buildWorkspaceCameraTileFrames } from 'src/logic-functions/domain/build-workspace-camera-tile-frames.util';
+import { type CameraTileFrames } from 'src/logic-functions/types/camera-tile-frames.type';
import { type RecallBotAutomaticVideoOutput } from 'src/logic-functions/types/recall-bot-automatic-video-output.type';
+import { getCallRecorderStyle } from 'src/logic-functions/utils/get-call-recorder-style.util';
-export const buildRecallBotAutomaticVideoOutput = async (): Promise<
- RecallBotAutomaticVideoOutput | undefined
+const tryBuildWorkspaceCameraTileFrames = async (): Promise<
+ CameraTileFrames | undefined
> => {
- if (!isWorkspaceLogoBotImageEnabled()) {
+ try {
+ return await buildWorkspaceCameraTileFrames();
+ } catch (error) {
+ console.warn(
+ `[call-recorder] failed to build the workspace camera tile, falling back to the Twenty style: ${error instanceof Error ? error.message : String(error)}`,
+ );
+
return undefined;
}
+};
- const logoBuffer = await getWorkspaceLogo();
+export const buildRecallBotAutomaticVideoOutput = async (): Promise<
+ RecallBotAutomaticVideoOutput | undefined
+> => {
+ const style = getCallRecorderStyle();
- if (isUndefined(logoBuffer)) {
+ if (style === 'NONE') {
return undefined;
}
- const background = getBotImageBackground();
+ try {
+ const workspaceFrames =
+ style === 'WORKSPACE'
+ ? await tryBuildWorkspaceCameraTileFrames()
+ : undefined;
+
+ const frames =
+ workspaceFrames ??
+ (await fetchPrebuiltCameraTileFramesOrThrow(
+ style === 'MINIMAL' ? 'MINIMAL' : 'TWENTY',
+ ));
+
+ return {
+ in_call_recording: { kind: 'jpeg', b64_data: frames.recording },
+ in_call_not_recording: { kind: 'jpeg', b64_data: frames.notRecording },
+ };
+ } catch (error) {
+ console.warn(
+ `[call-recorder] failed to build the camera tile: ${error instanceof Error ? error.message : String(error)}`,
+ );
- const notRecordingImage = await buildBotImage({ logoBuffer, background });
-
- if (isUndefined(notRecordingImage)) {
return undefined;
}
-
- const recordingImage =
- (await buildBotImage({
- logoBuffer,
- background,
- withRecordingStatusBadge: true,
- })) ?? notRecordingImage;
-
- return {
- in_call_recording: { kind: 'jpeg', b64_data: recordingImage },
- in_call_not_recording: { kind: 'jpeg', b64_data: notRecordingImage },
- };
};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recording-status-badge.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recording-status-badge.util.ts
deleted file mode 100644
index 95f53b961a6..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-recording-status-badge.util.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import {
- RECORDING_STATUS_BADGE_BACKGROUND,
- RECORDING_STATUS_BADGE_BACKGROUND_OPACITY,
- RECORDING_STATUS_BADGE_COLOR,
- RECORDING_STATUS_BADGE_DOT_DIAMETER,
- RECORDING_STATUS_BADGE_HEIGHT,
- RECORDING_STATUS_BADGE_LABEL_LEFT,
- RECORDING_STATUS_BADGE_LABEL_PATH,
- RECORDING_STATUS_BADGE_LABEL_TOP,
- RECORDING_STATUS_BADGE_PADDING,
- RECORDING_STATUS_BADGE_WIDTH,
-} from 'src/logic-functions/constants/recording-status-badge-config';
-
-type SharpFactory = typeof import('sharp').default;
-
-export const buildRecordingStatusBadgeSvg = (): string => {
- const dotRadius = RECORDING_STATUS_BADGE_DOT_DIAMETER / 2;
-
- return [
- `<svg xmlns="http://www.w3.org/2000/svg" width="${RECORDING_STATUS_BADGE_WIDTH}" height="${RECORDING_STATUS_BADGE_HEIGHT}">`,
- `<rect width="${RECORDING_STATUS_BADGE_WIDTH}" height="${RECORDING_STATUS_BADGE_HEIGHT}" rx="${RECORDING_STATUS_BADGE_HEIGHT / 2}" fill="${RECORDING_STATUS_BADGE_BACKGROUND}" fill-opacity="${RECORDING_STATUS_BADGE_BACKGROUND_OPACITY}" />`,
- `<circle cx="${RECORDING_STATUS_BADGE_PADDING + dotRadius}" cy="${RECORDING_STATUS_BADGE_HEIGHT / 2}" r="${dotRadius}" fill="${RECORDING_STATUS_BADGE_COLOR}" />`,
- `<path d="${RECORDING_STATUS_BADGE_LABEL_PATH}" transform="translate(${RECORDING_STATUS_BADGE_LABEL_LEFT} ${RECORDING_STATUS_BADGE_LABEL_TOP})" fill="${RECORDING_STATUS_BADGE_COLOR}" />`,
- '</svg>',
- ].join('');
-};
-
-export const buildRecordingStatusBadge = (
- sharp: SharpFactory,
-): Promise<Buffer> =>
- sharp(Buffer.from(buildRecordingStatusBadgeSvg())).png().toBuffer();
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-workspace-camera-tile-frames.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-workspace-camera-tile-frames.util.ts
new file mode 100644
index 00000000000..83813fed38a
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/build-workspace-camera-tile-frames.util.ts
@@ -0,0 +1,63 @@
+import { isUndefined } from '@sniptt/guards';
+
+import { CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH } from 'src/logic-functions/constants/camera-tile-asset-paths';
+import { fetchPublicAssetOrThrow } from 'src/logic-functions/data/fetch-public-asset-or-throw.util';
+import { getCameraTileFontFilePathOrThrow } from 'src/logic-functions/data/get-camera-tile-font-file-path-or-throw.util';
+import { getWorkspaceBranding } from 'src/logic-functions/data/get-workspace-branding.util';
+import { buildBotImage } from 'src/logic-functions/domain/build-bot-image.util';
+import { buildCameraTileRecordingComposites } from 'src/logic-functions/domain/build-camera-tile-recording-composites.util';
+import { buildCameraTileWorkspaceComposites } from 'src/logic-functions/domain/build-camera-tile-workspace-composites.util';
+import { renderCameraTileText } from 'src/logic-functions/domain/render-camera-tile-text.util';
+import { type CameraTileFrames } from 'src/logic-functions/types/camera-tile-frames.type';
+import { type CameraTileTextRenderer } from 'src/logic-functions/types/camera-tile-text-renderer.type';
+import { loadSharp } from 'src/logic-functions/utils/load-sharp.util';
+
+export const buildWorkspaceCameraTileFrames = async (): Promise<
+ CameraTileFrames | undefined
+> => {
+ const sharp = await loadSharp();
+
+ const [fontFilePath, branding] = await Promise.all([
+ getCameraTileFontFilePathOrThrow(),
+ getWorkspaceBranding(),
+ ]);
+
+ const renderText: CameraTileTextRenderer = (options) =>
+ renderCameraTileText({ sharp, fontFilePath, ...options });
+
+ const composites = await buildCameraTileWorkspaceComposites({
+ sharp,
+ renderText,
+ branding,
+ });
+
+ if (isUndefined(composites)) {
+ return undefined;
+ }
+
+ const [background, recordingComposites] = await Promise.all([
+ fetchPublicAssetOrThrow(CAMERA_TILE_WORKSPACE_BACKGROUND_ASSET_PATH),
+ buildCameraTileRecordingComposites({ sharp, renderText }),
+ ]);
+
+ const notRecording = await buildBotImage({ sharp, background, composites });
+
+ if (isUndefined(notRecording)) {
+ return undefined;
+ }
+
+ const recording =
+ (await buildBotImage({
+ sharp,
+ background,
+ composites: [...composites, ...recordingComposites],
+ }).catch((error: unknown) => {
+ console.warn(
+ `[call-recorder] failed to build the recording camera tile, using the plain one: ${error instanceof Error ? error.message : String(error)}`,
+ );
+
+ return undefined;
+ })) ?? notRecording;
+
+ return { recording, notRecording };
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/center-camera-tile-item.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/center-camera-tile-item.util.ts
new file mode 100644
index 00000000000..71beca1f719
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/center-camera-tile-item.util.ts
@@ -0,0 +1,15 @@
+import { type OverlayOptions } from 'sharp';
+
+import { RECALL_BOT_IMAGE_WIDTH } from 'src/logic-functions/constants/recall-bot-image-config';
+
+export const centerCameraTileItem = ({
+ item,
+ top,
+}: {
+ item: { input: Buffer; width: number };
+ top: number;
+}): OverlayOptions => ({
+ input: item.input,
+ left: Math.round((RECALL_BOT_IMAGE_WIDTH - item.width) / 2),
+ top: Math.round(top),
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.ts
new file mode 100644
index 00000000000..023c1b9a31f
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-logo.util.ts
@@ -0,0 +1,37 @@
+import { type OverlayOptions } from 'sharp';
+
+import {
+ CAMERA_TILE_LOGO_BOX_SIZE,
+ CAMERA_TILE_PLATE_SIZE,
+ CAMERA_TILE_PLATE_TOP,
+} from 'src/logic-functions/constants/camera-tile-config';
+import { centerCameraTileItem } from 'src/logic-functions/domain/center-camera-tile-item.util';
+import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';
+
+export const renderCameraTileLogo = async ({
+ sharp,
+ logo,
+}: {
+ sharp: SharpFactory;
+ logo: Buffer;
+}): Promise<OverlayOptions | undefined> => {
+ try {
+ const { data, info } = await sharp(logo)
+ .resize(CAMERA_TILE_LOGO_BOX_SIZE, CAMERA_TILE_LOGO_BOX_SIZE, {
+ fit: 'inside',
+ })
+ .png()
+ .toBuffer({ resolveWithObject: true });
+
+ return centerCameraTileItem({
+ item: { input: data, width: info.width },
+ top: CAMERA_TILE_PLATE_TOP + (CAMERA_TILE_PLATE_SIZE - info.height) / 2,
+ });
+ } catch (error) {
+ console.warn(
+ `[call-recorder] failed to read workspace logo: ${error instanceof Error ? error.message : String(error)}`,
+ );
+
+ return undefined;
+ }
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-svg-layer.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-svg-layer.util.ts
new file mode 100644
index 00000000000..708bfaf2b3b
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-svg-layer.util.ts
@@ -0,0 +1,25 @@
+import { type OverlayOptions } from 'sharp';
+
+import {
+ RECALL_BOT_IMAGE_HEIGHT,
+ RECALL_BOT_IMAGE_WIDTH,
+} from 'src/logic-functions/constants/recall-bot-image-config';
+import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';
+
+export const renderCameraTileSvgLayer = async ({
+ sharp,
+ content,
+}: {
+ sharp: SharpFactory;
+ content: string;
+}): Promise<OverlayOptions> => ({
+ input: await sharp(
+ Buffer.from(
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${RECALL_BOT_IMAGE_WIDTH}" height="${RECALL_BOT_IMAGE_HEIGHT}">${content}</svg>`,
+ ),
+ )
+ .png()
+ .toBuffer(),
+ left: 0,
+ top: 0,
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-text.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-text.util.ts
new file mode 100644
index 00000000000..7e2cd1de11e
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-camera-tile-text.util.ts
@@ -0,0 +1,57 @@
+import { isUndefined } from '@sniptt/guards';
+
+import {
+ CAMERA_TILE_FONT_FAMILY,
+ CAMERA_TILE_TEXT_COLOR,
+} from 'src/logic-functions/constants/camera-tile-config';
+import { renderTruncatedCameraTileText } from 'src/logic-functions/domain/render-truncated-camera-tile-text.util';
+import { escapePangoMarkup } from 'src/logic-functions/utils/escape-pango-markup.util';
+import { type SharpFactory } from 'src/logic-functions/utils/load-sharp.util';
+
+export type CameraTileText = {
+ input: Buffer;
+ width: number;
+ height: number;
+};
+
+export const renderCameraTileText = async ({
+ sharp,
+ fontFilePath,
+ text,
+ fontSize,
+ color = CAMERA_TILE_TEXT_COLOR,
+ opacity = 1,
+ maxWidth,
+}: {
+ sharp: SharpFactory;
+ fontFilePath: string;
+ text: string;
+ fontSize: number;
+ color?: string;
+ opacity?: number;
+ maxWidth?: number;
+}): Promise<CameraTileText> => {
+ const render = async (content: string): Promise<CameraTileText> => {
+ const { data, info } = await sharp({
+ text: {
+ text: `<span foreground="${color}" alpha="${Math.round(opacity * 100)}%">${escapePangoMarkup(content)}</span>`,
+ font: `${CAMERA_TILE_FONT_FAMILY} ${fontSize}`,
+ fontfile: fontFilePath,
+ rgba: true,
+ dpi: 72,
+ },
+ })
+ .png()
+ .toBuffer({ resolveWithObject: true });
+
+ return { input: data, width: info.width, height: info.height };
+ };
+
+ const fullText = await render(text);
+
+ if (isUndefined(maxWidth) || fullText.width <= maxWidth) {
+ return fullText;
+ }
+
+ return renderTruncatedCameraTileText({ text, maxWidth, render });
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-truncated-camera-tile-text.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-truncated-camera-tile-text.util.ts
new file mode 100644
index 00000000000..201fe2accce
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/domain/render-truncated-camera-tile-text.util.ts
@@ -0,0 +1,53 @@
+import { type CameraTileText } from 'src/logic-functions/domain/render-camera-tile-text.util';
+
+const ELLIPSIS = '…';
+
+const graphemeSegmenter = new Intl.Segmenter(undefined, {
+ granularity: 'grapheme',
+});
+
+const findLongestFittingLength = async ({
+ low,
+ high,
+ fits,
+}: {
+ low: number;
+ high: number;
+ fits: (length: number) => Promise<boolean>;
+}): Promise<number> => {
+ if (low >= high) {
+ return low;
+ }
+
+ const middle = Math.ceil((low + high) / 2);
+
+ return (await fits(middle))
+ ? findLongestFittingLength({ low: middle, high, fits })
+ : findLongestFittingLength({ low, high: middle - 1, fits });
+};
+
+export const renderTruncatedCameraTileText = async ({
+ text,
+ maxWidth,
+ render,
+}: {
+ text: string;
+ maxWidth: number;
+ render: (content: string) => Promise<CameraTileText>;
+}): Promise<CameraTileText> => {
+ const characters = Array.from(
+ graphemeSegmenter.segment(text.normalize('NFC')),
+ ({ segment }) => segment,
+ );
+
+ const renderPrefix = (length: number) =>
+ render(`${characters.slice(0, length).join('').trimEnd()}${ELLIPSIS}`);
+
+ const fittingLength = await findLongestFittingLength({
+ low: 0,
+ high: characters.length - 1,
+ fits: async (length) => (await renderPrefix(length)).width <= maxWidth,
+ });
+
+ return renderPrefix(fittingLength);
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/migrate-legacy-workspace-logo-setting.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/migrate-legacy-workspace-logo-setting.test.ts
new file mode 100644
index 00000000000..6f447d81a21
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/migrate-legacy-workspace-logo-setting.test.ts
@@ -0,0 +1,73 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { migrateLegacyWorkspaceLogoSetting } from 'src/logic-functions/flows/migrate-legacy-workspace-logo-setting.util';
+
+const metadataMutationMock = vi.hoisted(() => vi.fn());
+
+vi.mock('twenty-client-sdk/metadata', () => ({
+ MetadataApiClient: class {
+ mutation = metadataMutationMock;
+ },
+}));
+
+const expectStyleSavedAs = (style: string) =>
+ expect(metadataMutationMock).toHaveBeenCalledWith({
+ updateOneApplicationVariable: {
+ __args: { key: 'CALL_RECORDER_STYLE', value: style },
+ },
+ });
+
+describe('migrateLegacyWorkspaceLogoSetting', () => {
+ beforeEach(() => {
+ metadataMutationMock.mockReset();
+ metadataMutationMock.mockResolvedValue({
+ updateOneApplicationVariable: true,
+ });
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
+ it('keeps the workspace logo for workspaces that showed it', async () => {
+ vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'true');
+
+ expect(await migrateLegacyWorkspaceLogoSetting('1.19.0')).toBe('WORKSPACE');
+ expectStyleSavedAs('WORKSPACE');
+ });
+
+ it('treats an unset legacy toggle as the old default, which showed the logo', async () => {
+ expect(await migrateLegacyWorkspaceLogoSetting('1.19.0')).toBe('WORKSPACE');
+ expectStyleSavedAs('WORKSPACE');
+ });
+
+ it('keeps the image off for workspaces that turned the logo off', async () => {
+ vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+
+ expect(await migrateLegacyWorkspaceLogoSetting('1.12.3')).toBe('NONE');
+ expectStyleSavedAs('NONE');
+ });
+
+ it('leaves the style alone when upgrading from a version that already had styles', async () => {
+ vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+
+ expect(await migrateLegacyWorkspaceLogoSetting('1.20.0')).toBeUndefined();
+ expect(metadataMutationMock).not.toHaveBeenCalled();
+ });
+
+ it('keeps a style that is already set, so a retried hook cannot overwrite it', async () => {
+ vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+ vi.stubEnv('CALL_RECORDER_STYLE', 'MINIMAL');
+
+ expect(await migrateLegacyWorkspaceLogoSetting('1.19.0')).toBeUndefined();
+ expect(metadataMutationMock).not.toHaveBeenCalled();
+ });
+
+ it('surfaces a failed save so the install hook can retry', async () => {
+ metadataMutationMock.mockRejectedValue(new Error('network down'));
+
+ await expect(migrateLegacyWorkspaceLogoSetting('1.19.0')).rejects.toThrow(
+ 'network down',
+ );
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/reconcile-call-recorder.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/reconcile-call-recorder.test.ts
index e9457364512..ce492047938 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/reconcile-call-recorder.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/reconcile-call-recorder.test.ts
@@ -307,7 +307,7 @@ describe('reconcileCallRecorderForCalendarEventIds', () => {
);
vi.stubEnv('RECALL_API_KEY', 'recall-api-key');
vi.stubEnv('RECALL_REGION', 'us-west-2');
- vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+ vi.stubEnv('CALL_RECORDER_STYLE', 'NONE');
enqueueJobsMock.mockReset();
fetchMock.mockReset();
fetchMock.mockImplementation(
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/schedule-recall-bot-for-call-recording.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/schedule-recall-bot-for-call-recording.test.ts
index 18f3110053e..4fcfa524123 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/schedule-recall-bot-for-call-recording.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/__tests__/schedule-recall-bot-for-call-recording.test.ts
@@ -125,7 +125,7 @@ describe('scheduleRecallBotForCallRecording', () => {
vi.stubGlobal('fetch', fetchMock);
vi.stubEnv('RECALL_API_KEY', 'recall-api-key');
vi.stubEnv('RECALL_REGION', 'us-west-2');
- vi.stubEnv('CALL_RECORDER_USE_WORKSPACE_LOGO', 'false');
+ vi.stubEnv('CALL_RECORDER_STYLE', 'NONE');
vi.stubEnv(
'TWENTY_APP_ACCESS_TOKEN',
buildAccessToken({ workspaceId: WORKSPACE_ID }),
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/migrate-legacy-workspace-logo-setting.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/migrate-legacy-workspace-logo-setting.util.ts
new file mode 100644
index 00000000000..8fe9b711c35
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/flows/migrate-legacy-workspace-logo-setting.util.ts
@@ -0,0 +1,40 @@
+import { MetadataApiClient } from 'twenty-client-sdk/metadata';
+
+import { CALL_RECORDER_STYLE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-style-env-var-name';
+import { CALL_RECORDER_STYLES_INTRODUCED_VERSION } from 'src/logic-functions/constants/call-recorder-styles-introduced-version';
+import { CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-use-workspace-logo-env-var-name';
+import { DEFAULT_CALL_RECORDER_STYLE } from 'src/logic-functions/constants/default-call-recorder-style';
+import { DEFAULT_CALL_RECORDER_USE_WORKSPACE_LOGO } from 'src/logic-functions/constants/default-call-recorder-use-workspace-logo';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+import { getBooleanApplicationVariableValue } from 'src/logic-functions/utils/get-boolean-application-variable-value.util';
+import { getCallRecorderStyle } from 'src/logic-functions/utils/get-call-recorder-style.util';
+import { isVersionLowerThan } from 'src/logic-functions/utils/is-version-lower-than.util';
+
+export const migrateLegacyWorkspaceLogoSetting = async (
+ previousVersion: string,
+): Promise<CallRecorderStyle | undefined> => {
+ if (
+ !isVersionLowerThan({
+ version: previousVersion,
+ targetVersion: CALL_RECORDER_STYLES_INTRODUCED_VERSION,
+ }) ||
+ getCallRecorderStyle() !== DEFAULT_CALL_RECORDER_STYLE
+ ) {
+ return undefined;
+ }
+
+ const style: CallRecorderStyle = getBooleanApplicationVariableValue({
+ applicationVariableName: CALL_RECORDER_USE_WORKSPACE_LOGO_ENV_VAR_NAME,
+ defaultValue: DEFAULT_CALL_RECORDER_USE_WORKSPACE_LOGO,
+ })
+ ? 'WORKSPACE'
+ : 'NONE';
+
+ await new MetadataApiClient().mutation({
+ updateOneApplicationVariable: {
+ __args: { key: CALL_RECORDER_STYLE_ENV_VAR_NAME, value: style },
+ },
+ });
+
+ return style;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/start-post-install-backfills.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/start-post-install-backfills.ts
index 9aff76b5a2f..68431bb8f59 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/start-post-install-backfills.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/start-post-install-backfills.ts
@@ -12,11 +12,16 @@ import {
import { enqueueLogicFunctionJobs } from 'src/logic-functions/data/enqueue-logic-function-jobs.util';
import { enqueueWorkspaceDistributedJob } from 'src/logic-functions/data/enqueue-workspace-distributed-job.util';
import { getCurrentWorkspaceId } from 'src/logic-functions/data/get-current-workspace-id.util';
+import { migrateLegacyWorkspaceLogoSetting } from 'src/logic-functions/flows/migrate-legacy-workspace-logo-setting.util';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
import { buildRetryableStepFailure } from 'src/logic-functions/utils/build-step-failure.util';
type StartPostInstallBackfillsResult =
| { calendarEventSweepOutcome: 'sweep-enqueued' }
- | { stuckRequestFollowUpDelayMs: number };
+ | {
+ stuckRequestFollowUpDelayMs: number;
+ migratedCallRecorderStyle: CallRecorderStyle | undefined;
+ };
// The async install hook is redelivered only for retryable failures.
export const startPostInstallBackfillsHandler = async ({
@@ -36,6 +41,15 @@ export const startPostInstallBackfillsHandler = async ({
return { calendarEventSweepOutcome: 'sweep-enqueued' };
}
+ const migratedCallRecorderStyle = await migrateLegacyWorkspaceLogoSetting(
+ previousVersion,
+ ).catch((error: unknown) => {
+ throw buildRetryableStepFailure(
+ 'post-upgrade recorder style migration',
+ error,
+ );
+ });
+
// Requests that got stuck under an earlier version never had a follow-up.
const workspaceId = getCurrentWorkspaceId();
@@ -50,7 +64,7 @@ export const startPostInstallBackfillsHandler = async ({
stepLabel: 'post-upgrade stuck request follow-up kickoff',
});
- return { stuckRequestFollowUpDelayMs: delayMs };
+ return { stuckRequestFollowUpDelayMs: delayMs, migratedCallRecorderStyle };
};
export default definePostInstallLogicFunction({
@@ -58,7 +72,7 @@ export default definePostInstallLogicFunction({
START_POST_INSTALL_BACKFILLS_LOGIC_FUNCTION_UNIVERSAL_IDENTIFIER,
name: 'start-post-install-backfills',
description:
- 'Schedules recording bots for upcoming meetings when the app is installed, and follows up on requests left stuck by an earlier version when it is upgraded.',
+ 'Schedules recording bots for upcoming meetings when the app is installed. On upgrade, carries the old workspace logo setting over to the recorder style and follows up on requests left stuck by an earlier version.',
timeoutSeconds: 30,
shouldRunOnVersionUpgrade: true,
handler: startPostInstallBackfillsHandler,
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/types/call-recorder-style.type.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/call-recorder-style.type.ts
new file mode 100644
index 00000000000..ec2030e69f6
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/call-recorder-style.type.ts
@@ -0,0 +1,3 @@
+import { type CALL_RECORDER_STYLES } from 'src/logic-functions/constants/call-recorder-styles';
+
+export type CallRecorderStyle = (typeof CALL_RECORDER_STYLES)[number];
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/types/camera-tile-frames.type.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/camera-tile-frames.type.ts
new file mode 100644
index 00000000000..8e8ff130c50
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/camera-tile-frames.type.ts
@@ -0,0 +1,4 @@
+export type CameraTileFrames = {
+ recording: string;
+ notRecording: string;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/types/camera-tile-text-renderer.type.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/camera-tile-text-renderer.type.ts
new file mode 100644
index 00000000000..b50f564e416
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/camera-tile-text-renderer.type.ts
@@ -0,0 +1,11 @@
+import {
+ type CameraTileText,
+ type renderCameraTileText,
+} from 'src/logic-functions/domain/render-camera-tile-text.util';
+
+export type CameraTileTextRenderer = (
+ options: Omit<
+ Parameters<typeof renderCameraTileText>[0],
+ 'sharp' | 'fontFilePath'
+ >,
+) => Promise<CameraTileText>;
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/types/prebuilt-call-recorder-style.type.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/prebuilt-call-recorder-style.type.ts
new file mode 100644
index 00000000000..08d3dc2fca1
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/types/prebuilt-call-recorder-style.type.ts
@@ -0,0 +1,6 @@
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+export type PrebuiltCallRecorderStyle = Extract<
+ CallRecorderStyle,
+ 'TWENTY' | 'MINIMAL'
+>;
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/can-render-with-camera-tile-font.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/can-render-with-camera-tile-font.test.ts
new file mode 100644
index 00000000000..17b397f2245
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/can-render-with-camera-tile-font.test.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it } from 'vitest';
+
+import { canRenderWithCameraTileFont } from 'src/logic-functions/utils/can-render-with-camera-tile-font.util';
+
+describe('canRenderWithCameraTileFont', () => {
+ it.each([
+ 'Acme Inc.',
+ 'Société Générale',
+ 'Straße & Co',
+ 'Αθήνα',
+ 'Яндекс',
+ 'R&D 2026',
+ ])('accepts %s', (text) => {
+ expect(canRenderWithCameraTileFont(text)).toBe(true);
+ });
+
+ it.each(['日本商事', 'شركة', 'Acme 🚀', 'Acme 🇫🇷', 'Team 1️⃣', 'שלום'])(
+ 'rejects %s',
+ (text) => {
+ expect(canRenderWithCameraTileFont(text)).toBe(false);
+ },
+ );
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/escape-pango-markup.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/escape-pango-markup.test.ts
new file mode 100644
index 00000000000..7cfdd362a3f
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/escape-pango-markup.test.ts
@@ -0,0 +1,11 @@
+import { describe, expect, it } from 'vitest';
+
+import { escapePangoMarkup } from 'src/logic-functions/utils/escape-pango-markup.util';
+
+describe('escapePangoMarkup', () => {
+ it('escapes characters that would break the markup', () => {
+ expect(escapePangoMarkup(`R&D <b>"Ops"</b> 'Team'`)).toBe(
+ 'R&amp;D &lt;b&gt;&quot;Ops&quot;&lt;/b&gt; &#39;Team&#39;',
+ );
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/get-call-recorder-style.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/get-call-recorder-style.test.ts
new file mode 100644
index 00000000000..42864ac2d59
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/get-call-recorder-style.test.ts
@@ -0,0 +1,24 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { getCallRecorderStyle } from 'src/logic-functions/utils/get-call-recorder-style.util';
+
+describe('getCallRecorderStyle', () => {
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
+ it('reads the configured style', () => {
+ vi.stubEnv('CALL_RECORDER_STYLE', ' WORKSPACE ');
+
+ expect(getCallRecorderStyle()).toBe('WORKSPACE');
+ });
+
+ it.each(['', 'workspace', 'LOGO'])(
+ 'falls back to the Twenty style for %j',
+ (value) => {
+ vi.stubEnv('CALL_RECORDER_STYLE', value);
+
+ expect(getCallRecorderStyle()).toBe('TWENTY');
+ },
+ );
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/is-version-lower-than.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/is-version-lower-than.test.ts
new file mode 100644
index 00000000000..c9adec41961
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/__tests__/is-version-lower-than.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from 'vitest';
+
+import { isVersionLowerThan } from 'src/logic-functions/utils/is-version-lower-than.util';
+
+describe('isVersionLowerThan', () => {
+ it.each([
+ ['1.19.0', '1.20.0', true],
+ ['1.9.9', '1.20.0', true],
+ ['0.30.0', '1.20.0', true],
+ ['1.20.0', '1.20.0', false],
+ ['1.20.1', '1.20.0', false],
+ ['2.0.0', '1.20.0', false],
+ ['1.20.0-rc.1', '1.20.0', false],
+ ['1.19', '1.20.0', true],
+ ])('compares %s with %s', (version, targetVersion, expected) => {
+ expect(isVersionLowerThan({ version, targetVersion })).toBe(expected);
+ });
+});
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/can-render-with-camera-tile-font.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/can-render-with-camera-tile-font.util.ts
new file mode 100644
index 00000000000..26cc9e3b3ad
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/can-render-with-camera-tile-font.util.ts
@@ -0,0 +1,7 @@
+const SUPPORTED_SCRIPTS_PATTERN =
+ /^[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Common}\p{Script=Inherited}]*$/u;
+const EMOJI_PATTERN =
+ /[\p{Extended_Pictographic}\p{Regional_Indicator}\u{20E3}]/u;
+
+export const canRenderWithCameraTileFont = (text: string): boolean =>
+ SUPPORTED_SCRIPTS_PATTERN.test(text) && !EMOJI_PATTERN.test(text);
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/escape-pango-markup.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/escape-pango-markup.util.ts
new file mode 100644
index 00000000000..b3113ffe035
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/escape-pango-markup.util.ts
@@ -0,0 +1,7 @@
+export const escapePangoMarkup = (text: string): string =>
+ text
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&#39;');
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/get-call-recorder-style.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/get-call-recorder-style.util.ts
new file mode 100644
index 00000000000..0e291868c8e
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/get-call-recorder-style.util.ts
@@ -0,0 +1,13 @@
+import { CALL_RECORDER_STYLE_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-style-env-var-name';
+import { DEFAULT_CALL_RECORDER_STYLE } from 'src/logic-functions/constants/default-call-recorder-style';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+import { getApplicationVariableValue } from 'src/logic-functions/utils/get-application-variable-value.util';
+import { isCallRecorderStyle } from 'src/logic-functions/utils/is-call-recorder-style.util';
+
+export const getCallRecorderStyle = (): CallRecorderStyle => {
+ const rawValue = getApplicationVariableValue(
+ CALL_RECORDER_STYLE_ENV_VAR_NAME,
+ )?.trim();
+
+ return isCallRecorderStyle(rawValue) ? rawValue : DEFAULT_CALL_RECORDER_STYLE;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/is-call-recorder-style.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/is-call-recorder-style.util.ts
new file mode 100644
index 00000000000..9716d1319bb
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/is-call-recorder-style.util.ts
@@ -0,0 +1,7 @@
+import { CALL_RECORDER_STYLES } from 'src/logic-functions/constants/call-recorder-styles';
+import { type CallRecorderStyle } from 'src/logic-functions/types/call-recorder-style.type';
+
+export const isCallRecorderStyle = (
+ value: string | undefined,
+): value is CallRecorderStyle =>
+ CALL_RECORDER_STYLES.some((style) => style === value);
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/is-version-lower-than.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/is-version-lower-than.util.ts
new file mode 100644
index 00000000000..634f577ee31
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/is-version-lower-than.util.ts
@@ -0,0 +1,27 @@
+const parseVersion = (version: string): number[] =>
+ version
+ .split(/[-+]/)[0]
+ .split('.')
+ .map((part) => Number.parseInt(part, 10) || 0);
+
+export const isVersionLowerThan = ({
+ version,
+ targetVersion,
+}: {
+ version: string;
+ targetVersion: string;
+}): boolean => {
+ const parts = parseVersion(version);
+ const targetParts = parseVersion(targetVersion);
+
+ for (let index = 0; index < 3; index++) {
+ const part = parts[index] ?? 0;
+ const targetPart = targetParts[index] ?? 0;
+
+ if (part !== targetPart) {
+ return part < targetPart;
+ }
+ }
+
+ return false;
+};
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/load-sharp.util.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/load-sharp.util.ts
new file mode 100644
index 00000000000..5f3fc65f47e
--- /dev/null
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/utils/load-sharp.util.ts
@@ -0,0 +1,8 @@
+export type SharpFactory = typeof import('sharp').default;
+
+export const loadSharp = async (): Promise<SharpFactory> => {
+ const sharpModule = await import('sharp');
+
+ return ((sharpModule.default as unknown as { default?: SharpFactory })
+ .default ?? sharpModule.default) as SharpFactory;
+};