The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Polish AI model settings (#25810)
Thomas des Francs9883fc9f33e0
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx b/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsxindex cf4c0fef9a2..aaa5ff79fac 100644--- a/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx+++ b/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx@@ -141,7 +141,7 @@ const StyledLeftButtonsContainer = styled.div`const StyledRightButtonsContainer = styled.div`align-items: center;display: flex;- gap: ${themeCssVariables.spacing[1]};+ gap: ${themeCssVariables.spacing[2]};`;export const AiChatEditorSection = () => {diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsxindex ab0f5cd346a..364782cf1b8 100644--- a/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx+++ b/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx@@ -177,7 +177,7 @@ const StyledLeftActions = styled.div`const StyledRightActions = styled.div`align-items: center;display: flex;- gap: ${themeCssVariables.spacing[1]};+ gap: ${themeCssVariables.spacing[2]};`;const areAllQuestionsAnswered = (diff --git a/packages/twenty-front/src/modules/ai/components/AiModelPicker.tsx b/packages/twenty-front/src/modules/ai/components/AiModelPicker.tsxindex e992d50e13d..d576ca3960e 100644--- a/packages/twenty-front/src/modules/ai/components/AiModelPicker.tsx+++ b/packages/twenty-front/src/modules/ai/components/AiModelPicker.tsx@@ -104,7 +104,7 @@ export const AiModelPicker = ({<AiModelPinSelectdropdownId="ai-model-picker-pinned-model"label={t`Pin a specific model`}- description={t`Overrides the tier above until you switch back to automatic`}+ description={t`Overrides the mode above until you switch back to automatic`}modelId={hasPinnedModel ? modelId : null}onChange={(pinnedModelId) =>onModelIdChange(diff --git a/packages/twenty-front/src/modules/ai/components/AiModelTierBars.tsx b/packages/twenty-front/src/modules/ai/components/AiModelTierBars.tsxindex d33ca3c91b6..193d4f46d5e 100644--- a/packages/twenty-front/src/modules/ai/components/AiModelTierBars.tsx+++ b/packages/twenty-front/src/modules/ai/components/AiModelTierBars.tsx@@ -1,9 +1,8 @@import { styled } from '@linaria/react';-import { AI_MODEL_TIERS, type AiModelTier } from 'twenty-shared/ai';+import { type AiModelTier } from 'twenty-shared/ai';import { themeCssVariables } from 'twenty-ui/theme-constants';-const BAR_WIDTH_PX = 3;-const BAR_HEIGHT_PX = 10;+import { AiModelTierIndicator } from '@/ai/components/AiModelTierIndicator';const StyledButton = styled.button<{ disabled: boolean }>`align-items: center;@@ -12,7 +11,6 @@ const StyledButton = styled.button<{ disabled: boolean }>`border-radius: ${themeCssVariables.border.radius.sm};cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')};display: flex;- gap: 2px;height: 24px;opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};padding: 0 ${themeCssVariables.spacing[1]};@@ -25,39 +23,18 @@ const StyledButton = styled.button<{ disabled: boolean }>`}`;-const StyledBar = styled.span<{ isReached: boolean }>`- background: ${({ isReached }) =>- isReached- ? themeCssVariables.font.color.tertiary- : themeCssVariables.background.tertiary};- border-radius: ${BAR_WIDTH_PX / 2}px;- display: block;- height: ${BAR_HEIGHT_PX}px;- width: ${BAR_WIDTH_PX}px;-`;-type AiModelTierBarsProps = {selectedTier: AiModelTier;label: string;disabled?: boolean;};-// One bar per tier, filled up to the selected one, so the composer shows the-// level without spending the space a label would take. A native button, like-// every other dropdown trigger, so it is focusable and ignores clicks when-// disabled; the dropdown's wrapper is not.export const AiModelTierBars = ({selectedTier,label,disabled = false,-}: AiModelTierBarsProps) => {- const selectedStep = AI_MODEL_TIERS.indexOf(selectedTier);-- return (- <StyledButton type="button" aria-label={label} disabled={disabled}>- {AI_MODEL_TIERS.map((tier, index) => (- <StyledBar key={tier} isReached={index <= selectedStep} />- ))}- </StyledButton>- );-};+}: AiModelTierBarsProps) => (+ <StyledButton type="button" aria-label={label} disabled={disabled}>+ <AiModelTierIndicator tier={selectedTier} />+ </StyledButton>+);diff --git a/packages/twenty-front/src/modules/ai/components/AiModelTierDropdown.tsx b/packages/twenty-front/src/modules/ai/components/AiModelTierDropdown.tsxindex 84b288de20e..aae0050ef26 100644--- a/packages/twenty-front/src/modules/ai/components/AiModelTierDropdown.tsx+++ b/packages/twenty-front/src/modules/ai/components/AiModelTierDropdown.tsx@@ -14,7 +14,7 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';-const SLIDER_DROPDOWN_WIDTH_PX = 286;+const SLIDER_DROPDOWN_WIDTH_PX = 240;const StyledSliderContainer = styled.div`padding: ${themeCssVariables.spacing[3]};@@ -67,7 +67,7 @@ export const AiModelTierDropdown = ({<DropdownContent widthInPixels={SLIDER_DROPDOWN_WIDTH_PX}><StyledSliderContainerrole="group"- aria-label={t`Choose a model tier`}+ aria-label={t`Choose a model mode`}><AiModelTierSliderselectedTier={selectedTier}diff --git a/packages/twenty-front/src/modules/ai/components/AiModelTierIndicator.tsx b/packages/twenty-front/src/modules/ai/components/AiModelTierIndicator.tsxnew file mode 100644index 00000000000..1d6a227d4fe--- /dev/null+++ b/packages/twenty-front/src/modules/ai/components/AiModelTierIndicator.tsx@@ -0,0 +1,38 @@+import { styled } from '@linaria/react';+import { AI_MODEL_TIERS, type AiModelTier } from 'twenty-shared/ai';+import { themeCssVariables } from 'twenty-ui/theme-constants';++const StyledIndicator = styled.span`+ align-items: center;+ display: inline-flex;+ flex-shrink: 0;+ gap: 2px;+ height: 12px;+ width: 24px;+`;++const StyledBar = styled.span<{ isReached: boolean }>`+ background: ${({ isReached }) =>+ isReached+ ? themeCssVariables.font.color.secondary+ : themeCssVariables.font.color.extraLight};+ border-radius: 4px;+ flex: 1;+ height: 8px;+`;++type AiModelTierIndicatorProps = {+ tier: AiModelTier;+};++export const AiModelTierIndicator = ({ tier }: AiModelTierIndicatorProps) => {+ const selectedStep = AI_MODEL_TIERS.indexOf(tier);++ return (+ <StyledIndicator aria-hidden="true">+ {AI_MODEL_TIERS.map((modelTier, index) => (+ <StyledBar key={modelTier} isReached={index <= selectedStep} />+ ))}+ </StyledIndicator>+ );+};diff --git a/packages/twenty-front/src/modules/ai/components/AiModelTierSlider.tsx b/packages/twenty-front/src/modules/ai/components/AiModelTierSlider.tsxindex 56a7d763c5a..edbcf8882a1 100644--- a/packages/twenty-front/src/modules/ai/components/AiModelTierSlider.tsx+++ b/packages/twenty-front/src/modules/ai/components/AiModelTierSlider.tsx@@ -1,23 +1,28 @@import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';import { type ChangeEvent, useContext, useId } from 'react';-import { AI_MODEL_TIERS, type AiModelTier } from 'twenty-shared/ai';+import {+ AI_MODEL_TIERS,+ type AiModelTier,+ isAiModelEffort,+} from 'twenty-shared/ai';import { isDefined } from 'twenty-shared/utils';-import { IconBolt, IconBrain, IconCoins } from 'twenty-ui/icon';import { AppTooltip, TooltipDelay } from 'twenty-ui/surfaces';import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';import { useAiModelTiers } from '@/ai/hooks/useAiModelTiers';-import { formatPercentDelta } from '@/ai/utils/formatPercentDelta';-import { formatNumber } from '~/utils/format/formatNumber';+import { getAiModelEffortLabel } from '@/ai/utils/getAiModelEffortLabel';+import { formatMetricDelta } from '@/ai/utils/formatMetricDelta';+import { getAiModelModeDescription } from '@/settings/ai/utils/getAiModelModeDescription';+import { getModelIcon } from '@/settings/ai/utils/getModelIcon';+import { getAiModelTierMetrics } from '@/ai/utils/getAiModelTierMetrics';const TRACK_HEIGHT_PX = 24;-const TRACK_INSET_PX = 2;+const TRACK_INSET_PX = 0;const DOT_CENTER_INSET_PX = 18;const HANDLE_WIDTH_PX = 12;const HANDLE_HEIGHT_PX = 28;const LAST_STEP = AI_MODEL_TIERS.length - 1;-const BALANCED_STEP = AI_MODEL_TIERS.indexOf('balanced');const StyledContainer = styled.div`display: flex;@@ -57,8 +62,8 @@ const StyledMetric = styled.span<{ isInherited: boolean }>`: themeCssVariables.font.color.tertiary};display: flex;font-size: ${themeCssVariables.font.size.sm};- font-weight: ${themeCssVariables.font.weight.medium};- gap: 2px;+ font-weight: ${themeCssVariables.font.weight.regular};+ gap: ${themeCssVariables.spacing[1]};`;const StyledTrack = styled.div<{ disabled: boolean }>`@@ -86,10 +91,15 @@ const StyledFill = styled.div`left: ${TRACK_INSET_PX}px;position: absolute;top: ${TRACK_INSET_PX}px;+ transition: width 180ms cubic-bezier(0.22, 1, 0.36, 1);width: calc(${DOT_CENTER_INSET_PX - TRACK_INSET_PX + HANDLE_WIDTH_PX / 2}px +var(--slider-step) * (100% - ${2 * DOT_CENTER_INSET_PX}px) / ${LAST_STEP});++ @media (prefers-reduced-motion: reduce) {+ transition: none;+ }`;const StyledDots = styled.div`@@ -104,16 +114,22 @@ const StyledDot = styled.span<{ isReached: boolean }>`align-self: center;background: ${({ isReached }) =>isReached- ? themeCssVariables.background.primary+ ? // oxlint-disable-next-line twenty/no-hardcoded-colors -- Dots must remain translucent white over the blue track in both themes.+ 'rgba(255, 255, 255, 0.386)': themeCssVariables.border.color.strong};border-radius: ${themeCssVariables.border.radius.rounded};corner-shape: round;height: 4px;+ transition: background-color 180ms ease-out;width: 4px;++ @media (prefers-reduced-motion: reduce) {+ transition: none;+ }`;const StyledHandle = styled.div`- background: ${themeCssVariables.background.primary};+ background: white;border-radius: ${themeCssVariables.border.radius.md};box-shadow: ${themeCssVariables.boxShadow.light};corner-shape: round;@@ -167,40 +183,17 @@ export const AiModelTierSlider = ({? t` Not measured at this effort yet, so this is the base model's reading.`: '';- // Below Balanced the gain is speed, above it intelligence; cost moves with- // both, so each side shows the two figures that explain the trade.- const metrics = [- ...(selectedStep < BALANCED_STEP- ? [- {- key: 'speed',- Icon: IconBolt,- deltaPercent: resolvedTier.speedDeltaPercent,- description: t`${formatNumber(model?.outputTokensPerSecond ?? 0)} tokens per second`,- },- ]- : []),- ...(selectedStep !== BALANCED_STEP- ? [- {- key: 'cost',- Icon: IconCoins,- deltaPercent: resolvedTier.costDeltaPercent,- description: t`cost per task`,- },- ]- : []),- ...(selectedStep > BALANCED_STEP- ? [- {- key: 'intelligence',- Icon: IconBrain,- deltaPercent: resolvedTier.intelligenceDeltaPercent,- description: t`intelligence index ${formatNumber(model?.intelligenceIndex ?? 0)}`,- },- ]- : []),- ].filter((metric) => isDefined(metric.deltaPercent));+ const modelEffort = model?.effort;+ const modelName = getAiModelModeDescription(resolvedTier, {+ showAutomatic: false,+ showEffort: false,+ });+ const reasoningEffort =+ isDefined(modelEffort) && isAiModelEffort(modelEffort)+ ? getAiModelEffortLabel(modelEffort)+ : t`Default`;++ const metrics = getAiModelTierMetrics(resolvedTier);const handleChange = (event: ChangeEvent<HTMLInputElement>) => {const tier = AI_MODEL_TIERS[Number(event.target.value)];@@ -213,7 +206,7 @@ export const AiModelTierSlider = ({return (<StyledContainer><StyledHeader>- <StyledTitle title={model?.label}>+ <StyledTitle id={`ai-model-tier-name-${tooltipId}`}>{title ?? resolvedTier.label}</StyledTitle><StyledMetrics>@@ -223,8 +216,8 @@ export const AiModelTierSlider = ({id={`ai-model-tier-${key}-${tooltipId}`}isInherited={isBenchmarkInherited}>- <Icon size={theme.icon.size.md} />- {formatPercentDelta(deltaPercent ?? 0)}+ <Icon size={theme.icon.size.sm} />+ {formatMetricDelta(deltaPercent)}</StyledMetric>))}</StyledMetrics>@@ -254,15 +247,26 @@ export const AiModelTierSlider = ({/></StyledTrack>{isDefined(model) &&- metrics.map(({ key, description }) => (+ metrics.map(({ key, description, tooltipTitle }) => (<AppTooltipkey={key}anchorSelect={`#ai-model-tier-${key}-${tooltipId}`}- title={`${t`${model.label}: ${description}, compared with the Balanced tier.`}${inheritedNote}`}+ title={tooltipTitle ?? modelName}+ description={`${description}${inheritedNote}`}delay={TooltipDelay.shortDelay}place="bottom"/>))}+ {isDefined(model) && (+ <AppTooltip+ anchorSelect={`#ai-model-tier-name-${tooltipId}`}+ Icon={getModelIcon(model.modelFamily, model.providerName)}+ title={modelName}+ description={t`Reasoning effort: ${reasoningEffort}`}+ delay={TooltipDelay.shortDelay}+ place="bottom"+ />+ )}</StyledContainer>);};diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiModelTierBars.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiModelTierBars.test.tsxnew file mode 100644index 00000000000..7fedde268c1--- /dev/null+++ b/packages/twenty-front/src/modules/ai/components/__tests__/AiModelTierBars.test.tsx@@ -0,0 +1,17 @@+import { render, screen } from '@testing-library/react';++import { AiModelTierBars } from '@/ai/components/AiModelTierBars';++describe('AiModelTierBars', () => {+ it('preserves the accessible button label', () => {+ render(<AiModelTierBars selectedTier="fast" label="Fast mode" />);++ expect(screen.getByRole('button', { name: 'Fast mode' })).toBeEnabled();+ });++ it('preserves the disabled state', () => {+ render(<AiModelTierBars selectedTier="fast" label="Fast mode" disabled />);++ expect(screen.getByRole('button', { name: 'Fast mode' })).toBeDisabled();+ });+});diff --git a/packages/twenty-front/src/modules/ai/utils/__tests__/formatMetricDelta.test.ts b/packages/twenty-front/src/modules/ai/utils/__tests__/formatMetricDelta.test.tsnew file mode 100644index 00000000000..be0c0b92c46--- /dev/null+++ b/packages/twenty-front/src/modules/ai/utils/__tests__/formatMetricDelta.test.ts@@ -0,0 +1,18 @@+import { formatMetricDelta } from '@/ai/utils/formatMetricDelta';++describe('formatMetricDelta', () => {+ it.each([+ [1678, '17.8×'],+ [100, '2×'],+ [31, '+31%'],+ [6, '+6%'],+ [99, '+99%'],+ [131, '2.3×'],+ [-94, '-94%'],+ [0, '0%'],+ [-50, '-50%'],+ [-100, '-100%'],+ ])('formats a %s percent change as %s', (delta, expected) => {+ expect(formatMetricDelta(delta)).toBe(expected);+ });+});diff --git a/packages/twenty-front/src/modules/ai/utils/__tests__/getAiModelTierMetrics.test.ts b/packages/twenty-front/src/modules/ai/utils/__tests__/getAiModelTierMetrics.test.tsnew file mode 100644index 00000000000..33e6cb3c09b--- /dev/null+++ b/packages/twenty-front/src/modules/ai/utils/__tests__/getAiModelTierMetrics.test.ts@@ -0,0 +1,72 @@+import { type ResolvedAiModelTier } from '@/ai/types/ResolvedAiModelTier';+import { getAiModelTierMetrics } from '@/ai/utils/getAiModelTierMetrics';++const tier: ResolvedAiModelTier = {+ tier: 'smart',+ label: 'Smart',+ model: {+ modelId: 'test',+ label: 'Test',+ intelligenceIndex: 51,+ outputTokensPerSecond: 113,+ },+ isPinned: false,+ speedDeltaPercent: 10,+ costDeltaPercent: -23,+ intelligenceDeltaPercent: 8,+};++describe('getAiModelTierMetrics', () => {+ it('shows cost and intelligence above Balanced', () => {+ expect(getAiModelTierMetrics(tier)).toEqual([+ expect.objectContaining({+ key: 'cost',+ description: '23% lower cost than Balanced.',+ }),+ expect.objectContaining({+ key: 'intelligence',+ tooltipTitle: 'Intelligence score: 51',+ description: '8% higher score than Balanced',+ }),+ ]);+ });++ it('shows speed and cost below Balanced', () => {+ expect(+ getAiModelTierMetrics({ ...tier, tier: 'fast' }).map(({ key }) => key),+ ).toEqual(['speed', 'cost']);+ });++ it('shows no comparison for Balanced', () => {+ expect(getAiModelTierMetrics({ ...tier, tier: 'balanced' })).toEqual([]);+ });++ it('omits missing readings while preserving measured ties', () => {+ expect(+ getAiModelTierMetrics({+ ...tier,+ costDeltaPercent: undefined,+ intelligenceDeltaPercent: 0,+ }),+ ).toEqual([+ expect.objectContaining({+ key: 'intelligence',+ deltaPercent: 0,+ description: 'Same score as Balanced',+ }),+ ]);+ });++ it('uses multipliers for increases of at least 100 percent', () => {+ expect(+ getAiModelTierMetrics({+ ...tier,+ costDeltaPercent: 100,+ intelligenceDeltaPercent: 150,+ }),+ ).toEqual([+ expect.objectContaining({ description: '2× the cost of Balanced.' }),+ expect.objectContaining({ description: '2.5× the score of Balanced' }),+ ]);+ });+});diff --git a/packages/twenty-front/src/modules/ai/utils/formatMetricDelta.ts b/packages/twenty-front/src/modules/ai/utils/formatMetricDelta.tsnew file mode 100644index 00000000000..2fe49926893--- /dev/null+++ b/packages/twenty-front/src/modules/ai/utils/formatMetricDelta.ts@@ -0,0 +1,11 @@+import { formatPercentDelta } from '@/ai/utils/formatPercentDelta';++export const formatMetricDelta = (deltaPercent: number): string => {+ if (deltaPercent < 100) {+ return formatPercentDelta(deltaPercent);+ }++ const multiplier = 1 + deltaPercent / 100;++ return `${Math.round(multiplier * 10) / 10}×`;+};diff --git a/packages/twenty-front/src/modules/ai/utils/getAiModelEffortLabel.ts b/packages/twenty-front/src/modules/ai/utils/getAiModelEffortLabel.tsnew file mode 100644index 00000000000..d7847e4747f--- /dev/null+++ b/packages/twenty-front/src/modules/ai/utils/getAiModelEffortLabel.ts@@ -0,0 +1,16 @@+import { t } from '@lingui/core/macro';+import { type AiModelEffort } from 'twenty-shared/ai';++export const getAiModelEffortLabel = (effort: AiModelEffort): string => {+ const labels: Record<AiModelEffort, string> = {+ none: t`None`,+ minimal: t`Minimal`,+ low: t`Low`,+ medium: t`Medium`,+ high: t`High`,+ xhigh: t`Very High`,+ max: t`Max`,+ };++ return labels[effort];+};diff --git a/packages/twenty-front/src/modules/ai/utils/getAiModelTierMetrics.ts b/packages/twenty-front/src/modules/ai/utils/getAiModelTierMetrics.tsnew file mode 100644index 00000000000..2dba23e798c--- /dev/null+++ b/packages/twenty-front/src/modules/ai/utils/getAiModelTierMetrics.ts@@ -0,0 +1,99 @@+import { t } from '@lingui/core/macro';+import { AI_MODEL_TIERS } from 'twenty-shared/ai';+import { isDefined } from 'twenty-shared/utils';+import {+ IconBolt,+ IconBrain,+ IconCoins,+ type IconComponent,+} from 'twenty-ui/icon';++import { type ResolvedAiModelTier } from '@/ai/types/ResolvedAiModelTier';+import { formatMetricDelta } from '@/ai/utils/formatMetricDelta';+import { formatNumber } from '~/utils/format/formatNumber';++const BALANCED_STEP = AI_MODEL_TIERS.indexOf('balanced');++type TierMetric = {+ key: string;+ Icon: IconComponent;+ deltaPercent: number | undefined;+ tooltipTitle?: string;+ description: string;+};++const getComparison = (+ delta: number,+ labels: { multiplier: string; lower: string; higher: string; equal: string },+) => {+ if (delta >= 100) return labels.multiplier;+ if (delta < 0) return labels.lower;+ if (delta === 0) return labels.equal;+ return labels.higher;+};++const hasDeltaToShow = (+ metric: TierMetric,+): metric is TierMetric & { deltaPercent: number } =>+ isDefined(metric.deltaPercent);++export const getAiModelTierMetrics = (resolvedTier: ResolvedAiModelTier) => {+ const selectedStep = AI_MODEL_TIERS.indexOf(resolvedTier.tier);+ const model = resolvedTier.model;++ const intelligenceDelta = resolvedTier.intelligenceDeltaPercent ?? 0;+ const intelligenceComparison = getComparison(intelligenceDelta, {+ multiplier: t`${formatMetricDelta(intelligenceDelta)} the score of Balanced`,+ lower: t`${formatNumber(Math.abs(intelligenceDelta))}% lower score than Balanced`,+ higher: t`${formatNumber(intelligenceDelta)}% higher score than Balanced`,+ equal: t`Same score as Balanced`,+ });+ const intelligenceScore = t`Intelligence score: ${formatNumber(model?.intelligenceIndex ?? 0)}`;+ const costDelta = resolvedTier.costDeltaPercent ?? 0;+ const costComparison = getComparison(costDelta, {+ multiplier: t`${formatMetricDelta(costDelta)} the cost of Balanced.`,+ lower: t`${formatNumber(Math.abs(costDelta))}% lower cost than Balanced.`,+ higher: t`${formatNumber(costDelta)}% higher cost than Balanced.`,+ equal: t`Same cost as Balanced.`,+ });+ // Below Balanced the gain is speed, above it intelligence; cost moves with+ // both, so each side shows the two figures that explain the trade.+ const candidateMetrics: TierMetric[] = [+ ...(selectedStep < BALANCED_STEP+ ? [+ {+ key: 'speed',+ Icon: IconBolt,+ deltaPercent: resolvedTier.speedDeltaPercent,+ description:+ (resolvedTier.speedDeltaPercent ?? 0) >= 100+ ? t`${formatNumber(model?.outputTokensPerSecond ?? 0)} tokens/s, ${formatMetricDelta(resolvedTier.speedDeltaPercent ?? 0)} the speed of Balanced Mode.`+ : t`${formatNumber(model?.outputTokensPerSecond ?? 0)} tokens/s, a ${formatMetricDelta(resolvedTier.speedDeltaPercent ?? 0)} change in speed compared with Balanced Mode.`,+ },+ ]+ : []),+ ...(selectedStep !== BALANCED_STEP+ ? [+ {+ key: 'cost',+ Icon: IconCoins,+ deltaPercent: resolvedTier.costDeltaPercent,+ description: costComparison,+ },+ ]+ : []),+ ...(selectedStep > BALANCED_STEP+ ? [+ {+ key: 'intelligence',+ Icon: IconBrain,+ deltaPercent: resolvedTier.intelligenceDeltaPercent,+ tooltipTitle: intelligenceScore,+ description: intelligenceComparison,+ },+ ]+ : []),+ ];++ return candidateMetrics.filter(hasDeltaToShow);+};diff --git a/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx b/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsxindex 6a36074b0d0..4fca618ef16 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx@@ -197,7 +197,7 @@ export const SettingsAdminAI = () => {<Section><H2Titletitle={t`Default Models`}- description={t`The model behind each tier for every workspace. Workspaces can pin their own.`}+ description={t`The model behind each mode for every workspace. Workspaces can pin their own.`}/><Card rounded>diff --git a/packages/twenty-front/src/modules/settings/ai/components/AiModelPinSelect.tsx b/packages/twenty-front/src/modules/settings/ai/components/AiModelPinSelect.tsxindex c495c870a0b..4830925620b 100644--- a/packages/twenty-front/src/modules/settings/ai/components/AiModelPinSelect.tsx+++ b/packages/twenty-front/src/modules/settings/ai/components/AiModelPinSelect.tsx@@ -1,15 +1,13 @@import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';import { type ComponentProps } from 'react';-import {- AI_MODEL_EFFORT_LABELS,- isAiModelEffort,- parseAiModelVariantId,-} from 'twenty-shared/ai';+import { isAiModelEffort, parseAiModelVariantId } from 'twenty-shared/ai';import { isDefined } from 'twenty-shared/utils';+import { IconWand } from 'twenty-ui/icon';import { themeCssVariables } from 'twenty-ui/theme-constants';import { AUTOMATIC_MODEL_PIN } from '@/settings/ai/constants/AutomaticModelPin';+import { getAiModelEffortLabel } from '@/ai/utils/getAiModelEffortLabel';import { type PinnableAiModel } from '@/settings/ai/types/PinnableAiModel';import { getAiModelPinOptions } from '@/settings/ai/utils/getAiModelPinOptions';import { Select } from '@/ui/input/components/Select';@@ -17,10 +15,12 @@ import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/Geneconst DEFAULT_EFFORT = '';-const StyledRow = styled.div`+const StyledRow = styled.div<{ hasEffortSelect: boolean }>`align-items: flex-end;- display: flex;+ display: grid;gap: ${themeCssVariables.spacing[2]};+ grid-template-columns: ${({ hasEffortSelect }) =>+ hasEffortSelect ? 'minmax(0, 1fr) 96px' : 'minmax(0, 1fr)'};`;type AiModelPinSelectProps = {@@ -76,19 +76,26 @@ export const AiModelPinSelect = ({};return (- <StyledRow>+ <StyledRow hasEffortSelect={efforts.length > 0}><SelectdropdownId={dropdownId}label={label}description={description}value={isDefined(modelId) ? baseModelId : AUTOMATIC_MODEL_PIN}onChange={handleModelChange}- options={getAiModelPinOptions({ aiModels, keepModelId: baseModelId })}- emptyOption={- isDefined(emptyOptionLabel)- ? { value: AUTOMATIC_MODEL_PIN, label: emptyOptionLabel }- : undefined- }+ showIconInControl={isDefined(modelId)}+ options={[+ ...(isDefined(emptyOptionLabel)+ ? [+ {+ value: AUTOMATIC_MODEL_PIN,+ label: emptyOptionLabel,+ Icon: IconWand,+ },+ ]+ : []),+ ...getAiModelPinOptions({ aiModels, keepModelId: baseModelId }),+ ]}withSearchInputdisabled={disabled}selectSizeVariant={selectSizeVariant}@@ -100,10 +107,15 @@ export const AiModelPinSelect = ({value={effort ?? DEFAULT_EFFORT}onChange={handleEffortChange}options={[- { value: DEFAULT_EFFORT, label: t`Default reasoning` },+ {+ value: DEFAULT_EFFORT,+ label: t`Default`,+ fullLabel: t`Reasoning: Default`,+ },...efforts.map((availableEffort) => ({value: availableEffort,- label: AI_MODEL_EFFORT_LABELS[availableEffort],+ label: getAiModelEffortLabel(availableEffort),+ fullLabel: t`Reasoning: ${getAiModelEffortLabel(availableEffort)}`,})),]}disabled={disabled}diff --git a/packages/twenty-front/src/modules/settings/ai/utils/__tests__/getAiModelModeDescription.test.ts b/packages/twenty-front/src/modules/settings/ai/utils/__tests__/getAiModelModeDescription.test.tsnew file mode 100644index 00000000000..3f2e8a3e756--- /dev/null+++ b/packages/twenty-front/src/modules/settings/ai/utils/__tests__/getAiModelModeDescription.test.ts@@ -0,0 +1,84 @@+import { getAiModelModeDescription } from '@/settings/ai/utils/getAiModelModeDescription';++const model = {+ modelId: 'openai/astra@high',+ label: 'GPT-6 Astra (high reasoning)',+ effort: 'high',+};++describe('getAiModelModeDescription', () => {+ it('handles an unavailable model', () => {+ expect(+ getAiModelModeDescription({ model: undefined, isPinned: false }),+ ).toBe('No model available');+ });++ it('replaces the matching effort suffix with a readable effort label', () => {+ expect(getAiModelModeDescription({ model, isPinned: false })).toBe(+ 'GPT-6 Astra · High (Auto)',+ );+ });++ it('adds the effort when the model label has no suffix', () => {+ expect(+ getAiModelModeDescription({+ model: { ...model, label: 'GPT-6 Astra' },+ isPinned: true,+ }),+ ).toBe('GPT-6 Astra · High');+ });++ it.each([undefined, null, '', 'unsupported'])(+ 'preserves the model label when effort is %s',+ (effort) => {+ expect(+ getAiModelModeDescription({+ model: { ...model, effort },+ isPinned: true,+ }),+ ).toBe(model.label);+ },+ );++ it('preserves a suffix that does not match the effort', () => {+ expect(+ getAiModelModeDescription({+ model: { ...model, label: 'GPT-6 Astra (custom)' },+ isPinned: true,+ }),+ ).toBe('GPT-6 Astra (custom) · High');+ });++ it('does not mark a pinned model as automatic', () => {+ expect(getAiModelModeDescription({ model, isPinned: true })).toBe(+ 'GPT-6 Astra · High',+ );+ });++ it('can hide the automatic marker', () => {+ expect(+ getAiModelModeDescription(+ { model, isPinned: false },+ { showAutomatic: false },+ ),+ ).toBe('GPT-6 Astra · High');+ });++ it('can hide effort while retaining the automatic marker', () => {+ expect(+ getAiModelModeDescription(+ { model, isPinned: false },+ { showEffort: false },+ ),+ ).toBe('GPT-6 Astra (Auto)');+ });++ it('can show only the model name', () => {+ expect(+ getAiModelModeDescription(+ { model, isPinned: false },+ { showAutomatic: false, showEffort: false },+ ),+ ).toBe('GPT-6 Astra');+ });+});diff --git a/packages/twenty-front/src/modules/settings/ai/utils/getAiModelModeDescription.ts b/packages/twenty-front/src/modules/settings/ai/utils/getAiModelModeDescription.tsnew file mode 100644index 00000000000..1ac0209ac9b--- /dev/null+++ b/packages/twenty-front/src/modules/settings/ai/utils/getAiModelModeDescription.ts@@ -0,0 +1,35 @@+import { t } from '@lingui/core/macro';+import { AI_MODEL_EFFORT_LABELS, isAiModelEffort } from 'twenty-shared/ai';+import { isDefined } from 'twenty-shared/utils';++import { type ResolvedAiModelTier } from '@/ai/types/ResolvedAiModelTier';+import { getAiModelEffortLabel } from '@/ai/utils/getAiModelEffortLabel';++export const getAiModelModeDescription = (+ { model, isPinned }: Pick<ResolvedAiModelTier, 'model' | 'isPinned'>,+ {+ showAutomatic = true,+ showEffort = true,+ }: { showAutomatic?: boolean; showEffort?: boolean } = {},+) => {+ if (!isDefined(model)) {+ return t`No model available`;+ }++ const effort = model.effort;+ const validEffort =+ isDefined(effort) && isAiModelEffort(effort) ? effort : undefined;+ const suffix = isDefined(validEffort)+ ? ` (${AI_MODEL_EFFORT_LABELS[validEffort]})`+ : '';+ const modelName =+ isDefined(validEffort) && model.label.endsWith(suffix)+ ? model.label.slice(0, -suffix.length)+ : model.label;+ const label =+ showEffort && isDefined(validEffort)+ ? `${modelName} · ${getAiModelEffortLabel(validEffort)}`+ : modelName;++ return isPinned || !showAutomatic ? label : t`${label} (Auto)`;+};diff --git a/packages/twenty-front/src/modules/settings/components/SettingsOptions/NestedSettingsRow.tsx b/packages/twenty-front/src/modules/settings/components/SettingsOptions/NestedSettingsRow.tsxnew file mode 100644index 00000000000..c1a1ed6d76d--- /dev/null+++ b/packages/twenty-front/src/modules/settings/components/SettingsOptions/NestedSettingsRow.tsx@@ -0,0 +1,63 @@+import { styled } from '@linaria/react';+import { type ReactNode } from 'react';+import { themeCssVariables } from 'twenty-ui/theme-constants';++type NestedSettingsRowProps = {+ children: ReactNode;+ isLast?: boolean;+ guideOffset?: string;+};++const StyledNestedRow = styled.div`+ margin-left: ${themeCssVariables.spacing[8]};+ padding-left: ${themeCssVariables.spacing[4]};+ position: relative;+`;++const StyledGuide = styled.div<{+ isLast: boolean;+ guideOffset: string;+}>`+ bottom: 0;+ left: 0;+ pointer-events: none;+ position: absolute;+ top: 0;+ width: ${themeCssVariables.spacing[4]};++ &::before {+ background: ${themeCssVariables.border.color.strong};+ bottom: 0;+ content: '';+ display: ${({ isLast }) => (isLast ? 'none' : 'block')};+ left: 0;+ position: absolute;+ top: 0;+ width: 1px;+ }++ &::after {+ border-bottom: 1px solid ${themeCssVariables.border.color.strong};+ border-bottom-left-radius: ${themeCssVariables.border.radius.sm};+ border-left: 1px solid ${themeCssVariables.border.color.strong};+ box-sizing: border-box;+ content: '';+ height: ${({ guideOffset }) => guideOffset};+ left: 0;+ position: absolute;+ top: 0;+ width: 100%;+ }+`;++// Settings rows own their top padding, so the guide covers that inset too.+export const NestedSettingsRow = ({+ children,+ isLast = false,+ guideOffset = '50%',+}: NestedSettingsRowProps) => (+ <StyledNestedRow>+ <StyledGuide aria-hidden="true" isLast={isLast} guideOffset={guideOffset} />+ {children}+ </StyledNestedRow>+);diff --git a/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSelect.tsx b/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSelect.tsxindex 78148089e23..a6d0f8ba8d5 100644--- a/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSelect.tsx+++ b/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSelect.tsx@@ -9,10 +9,13 @@ import { Separator } from '@/settings/components/Separator';import { SettingsOptionIconCustomizer } from '@/settings/components/SettingsOptions/SettingsOptionIconCustomizer';import { styled } from '@linaria/react';import { type IconComponent } from 'twenty-ui/icon';+import { isDefined } from 'twenty-shared/utils';import { OverflowingTextWithTooltip } from 'twenty-ui/surfaces';+import { themeCssVariables } from 'twenty-ui/theme-constants';type SettingsOptionCardContentSelectProps = {Icon?: IconComponent;+ LeftComponent?: React.ReactNode;title: React.ReactNode;description?: string;divider?: boolean;@@ -24,11 +27,31 @@ const StyledSelectContainer = styled.div`flex-shrink: 0;justify-content: flex-end;margin-left: auto;- max-width: 120px;+ max-width: var(--settings-select-control-width, 120px);+ width: var(--settings-select-control-width, auto);++ @container settings-select-group (max-width: 520px) {+ max-width: 100%;+ }+`;++const StyledSelectRow = styled(StyledSettingsCardContent)`+ @container settings-select-group (max-width: 520px) {+ flex-wrap: wrap;+ }+`;++const StyledSelectText = styled(StyledSettingsCardTextContainer)`+ @container settings-select-group (max-width: 520px) {+ flex-basis: calc(+ 100% - ${themeCssVariables.spacing[8]} - ${themeCssVariables.spacing[3]}+ );+ }`;export const SettingsOptionCardContentSelect = ({Icon,+ LeftComponent,title,description,divider,@@ -37,22 +60,23 @@ export const SettingsOptionCardContentSelect = ({}: SettingsOptionCardContentSelectProps) => {return (<>- <StyledSettingsCardContent disabled={disabled}>- {Icon && (+ <StyledSelectRow disabled={disabled}>+ {(isDefined(LeftComponent) || isDefined(Icon)) && (<StyledSettingsCardIcon>- <SettingsOptionIconCustomizer Icon={Icon} />+ {LeftComponent ??+ (Icon && <SettingsOptionIconCustomizer Icon={Icon} />)}</StyledSettingsCardIcon>)}- <StyledSettingsCardTextContainer>+ <StyledSelectText><StyledSettingsCardTitle>{title}</StyledSettingsCardTitle>{description && (<StyledSettingsCardDescription><OverflowingTextWithTooltip text={description} /></StyledSettingsCardDescription>)}- </StyledSettingsCardTextContainer>+ </StyledSelectText><StyledSelectContainer>{children}</StyledSelectContainer>- </StyledSettingsCardContent>+ </StyledSelectRow>{divider && <Separator />}</>);diff --git a/packages/twenty-front/src/modules/settings/components/SettingsOptions/StyledSettingsSelectGroup.tsx b/packages/twenty-front/src/modules/settings/components/SettingsOptions/StyledSettingsSelectGroup.tsxnew file mode 100644index 00000000000..0f166284a08--- /dev/null+++ b/packages/twenty-front/src/modules/settings/components/SettingsOptions/StyledSettingsSelectGroup.tsx@@ -0,0 +1,7 @@+import { styled } from '@linaria/react';++export const StyledSettingsSelectGroup = styled.div<{ controlWidth: number }>`+ --settings-select-control-width: ${({ controlWidth }) => controlWidth}px;+ container-name: settings-select-group;+ container-type: inline-size;+`;diff --git a/packages/twenty-front/src/modules/ui/input/components/Select.tsx b/packages/twenty-front/src/modules/ui/input/components/Select.tsxindex 723526a1d78..714a54a15ca 100644--- a/packages/twenty-front/src/modules/ui/input/components/Select.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/Select.tsx@@ -56,6 +56,7 @@ export type SelectProps<Value extends SelectValue> = {dropdownOffset?: DropdownOffset;hasRightElement?: boolean;showContextualTextInControl?: boolean;+ showIconInControl?: boolean;isDropdownInModal?: boolean;variant?: FormFieldInputVariant;};@@ -99,6 +100,7 @@ export const Select = <Value extends SelectValue>({dropdownOffset,hasRightElement,showContextualTextInControl = true,+ showIconInControl = true,isDropdownInModal = false,variant = 'default',}: SelectProps<Value>) => {@@ -169,14 +171,18 @@ export const Select = <Value extends SelectValue>({const { setSelectedItemId } = useSelectableList(dropdownId);const controlSelectedOption = useMemo(() => {- if (!isDefined(selectedOption) || showContextualTextInControl) {+ if (!isDefined(selectedOption)) {return selectedOption;}- const { contextualText: _, ...rest } = selectedOption;-- return rest;- }, [selectedOption, showContextualTextInControl]);+ return {+ ...selectedOption,+ contextualText: showContextualTextInControl+ ? selectedOption.contextualText+ : undefined,+ Icon: showIconInControl ? selectedOption.Icon : undefined,+ };+ }, [selectedOption, showContextualTextInControl, showIconInControl]);const handleDropdownOpen = () => {if (@@ -240,6 +246,7 @@ export const Select = <Value extends SelectValue>({<DropdownMenuItemsContainer scrollable={false}><MenuItemSelectLeftIcon={pinnedOption.Icon}+ LeftComponent={pinnedOption.LeftComponent}leftIconColor={pinnedOption.iconThemeColor}text={pinnedOption.label}contextualText={pinnedOption.contextualText}@@ -277,6 +284,7 @@ export const Select = <Value extends SelectValue>({><MenuItemSelectLeftIcon={option.Icon}+ LeftComponent={option.LeftComponent}leftIconColor={option.iconThemeColor}text={option.label}contextualText={option.contextualText}diff --git a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsxindex dbe78ff6c68..8aa6f7c2e4d 100644--- a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx@@ -77,6 +77,12 @@ export const StyledControlContainer = styled.div<{text-align: left;`;+const StyledLeadingContent = styled.div`+ align-items: center;+ display: flex;+ gap: ${themeCssVariables.spacing[1]};+`;+const StyledIconChevronDownWrapper = styled.div<{disabled?: boolean;}>`@@ -107,10 +113,14 @@ export const SelectControl = ({variant = 'default',}: SelectControlProps) => {const { theme } = useContext(ThemeContext);+ const hasLeadingContent =+ isDefined(LeftComponent) ||+ isDefined(selectedOption.Icon) ||+ isDefined(selectedOption.LeftComponent);return (<StyledControlContainerdisabled={isDisabled}- hasIcon={isDefined(LeftComponent) || isDefined(selectedOption?.Icon)}+ hasIcon={hasLeadingContent}selectSizeVariant={selectSizeVariant}textAccent={textAccent}hasRightElement={hasRightElement}@@ -119,23 +129,28 @@ export const SelectControl = ({>{isDefined(LeftComponent) ? (LeftComponent- ) : isDefined(selectedOption?.Icon) ? (- isDefined(selectedOption.iconThemeColor) ? (- <TintedIconTile- Icon={selectedOption.Icon}- color={selectedOption.iconThemeColor}- size={theme.icon.size.md}- stroke={theme.icon.stroke.sm}- />- ) : (- <selectedOption.Icon- color={- isDisabled ? theme.font.color.light : theme.font.color.primary- }- size={theme.icon.size.md}- stroke={theme.icon.stroke.sm}- />- )+ ) : hasLeadingContent ? (+ <StyledLeadingContent>+ {isDefined(selectedOption?.Icon) ? (+ isDefined(selectedOption.iconThemeColor) ? (+ <TintedIconTile+ Icon={selectedOption.Icon}+ color={selectedOption.iconThemeColor}+ size={theme.icon.size.md}+ stroke={theme.icon.stroke.sm}+ />+ ) : (+ <selectedOption.Icon+ color={+ isDisabled ? theme.font.color.light : theme.font.color.primary+ }+ size={theme.icon.size.md}+ stroke={theme.icon.stroke.sm}+ />+ )+ ) : null}+ {selectedOption.LeftComponent}+ </StyledLeadingContent>) : null}<OverflowingTextWithTooltiptext={diff --git a/packages/twenty-front/src/modules/ui/input/components/__tests__/SelectControl.test.tsx b/packages/twenty-front/src/modules/ui/input/components/__tests__/SelectControl.test.tsxnew file mode 100644index 00000000000..4ee33dc6112--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/__tests__/SelectControl.test.tsx@@ -0,0 +1,37 @@+import { render, screen } from '@testing-library/react';+import { IconBolt } from 'twenty-ui/icon';++import { SelectControl } from '@/ui/input/components/SelectControl';++describe('SelectControl', () => {+ it('renders an icon and custom leading content together', () => {+ render(+ <SelectControl+ selectedOption={{+ label: 'Fast',+ value: 'fast',+ Icon: IconBolt,+ LeftComponent: <span aria-label="Fast mode indicator" />,+ }}+ />,+ );++ expect(screen.getByLabelText('Fast mode indicator')).toBeVisible();+ expect(screen.getByText('Fast')).toBeVisible();+ });++ it('renders custom leading content for the selected option', () => {+ render(+ <SelectControl+ selectedOption={{+ label: 'Fast',+ value: 'fast',+ LeftComponent: <span aria-label="Fast mode indicator" />,+ }}+ />,+ );++ expect(screen.getByLabelText('Fast mode indicator')).toBeVisible();+ expect(screen.getByText('Fast')).toBeVisible();+ });+});diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/constants/DropdownMenuItemsContainerMaxHeight.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/constants/DropdownMenuItemsContainerMaxHeight.tsindex 23a6872c30f..a57c52c325f 100644--- a/packages/twenty-front/src/modules/ui/layout/dropdown/constants/DropdownMenuItemsContainerMaxHeight.ts+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/constants/DropdownMenuItemsContainerMaxHeight.ts@@ -1 +1 @@-export const DROPDOWN_MENU_ITEMS_CONTAINER_MAX_HEIGHT = 168;+export const DROPDOWN_MENU_ITEMS_CONTAINER_MAX_HEIGHT = 176;diff --git a/packages/twenty-front/src/pages/settings/ai/SettingsAI.tsx b/packages/twenty-front/src/pages/settings/ai/SettingsAI.tsxindex 013c0543cf0..66b466be618 100644--- a/packages/twenty-front/src/pages/settings/ai/SettingsAI.tsx+++ b/packages/twenty-front/src/pages/settings/ai/SettingsAI.tsx@@ -21,6 +21,7 @@ import { Section } from 'twenty-ui/layout';import { UndecoratedLink } from 'twenty-ui/navigation';import { SettingsAgentSkillsTab } from '~/pages/settings/ai/components/SettingsAgentSkillsTab';import { SettingsAgentToolsTab } from '~/pages/settings/ai/components/SettingsAgentToolsTab';+import { SettingsAiSystemPromptsSection } from '~/pages/settings/ai/components/SettingsAiSystemPromptsSection';import { SettingsAiModelsTab } from '~/pages/settings/ai/components/SettingsAiModelsTab';import { SettingsAiOverviewTab } from '~/pages/settings/ai/components/SettingsAiOverviewTab';import { SettingsAiUsageTab } from '~/pages/settings/ai/components/SettingsAiUsageTab';@@ -113,24 +114,31 @@ export const SettingsAI = () => {]}><SettingsPageContainer>- <Section>- <SettingsDiscoveryHeroCard- lightSrc={AI_HERO_LIGHT}- darkSrc={AI_HERO_DARK}- instanceIdPrefix={SETTINGS_AI_HERO_INSTANCE_ID_PREFIX}- tabs={[- {- id: 'ai_walkthrough',- title: t`Walkthrough`,- Icon: IconSparkle2,- vimeoId: '1217964358',- hasSound: true,- },- ]}- playButtonAriaLabel={t`Watch AI demo`}- />- </Section>- {isOverviewTab && <SettingsAiOverviewTab />}+ {!isModelsTab && (+ <Section>+ <SettingsDiscoveryHeroCard+ lightSrc={AI_HERO_LIGHT}+ darkSrc={AI_HERO_DARK}+ instanceIdPrefix={SETTINGS_AI_HERO_INSTANCE_ID_PREFIX}+ tabs={[+ {+ id: 'ai_walkthrough',+ title: t`Walkthrough`,+ Icon: IconSparkle2,+ vimeoId: '1217964358',+ hasSound: true,+ },+ ]}+ playButtonAriaLabel={t`Watch AI demo`}+ />+ </Section>+ )}+ {isOverviewTab && (+ <>+ <SettingsAiOverviewTab />+ <SettingsAiSystemPromptsSection />+ </>+ )}{isModelsTab && <SettingsAiModelsTab />}{isSkillsTab && <SettingsAgentSkillsTab />}{isToolsTab && <SettingsAgentToolsTab />}diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsxindex 9f641e9644a..accd255e47c 100644--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx@@ -6,17 +6,18 @@ import { Section } from 'twenty-ui/layout';import { AppTooltip, TooltipDelay } from 'twenty-ui/surfaces';import { themeCssVariables } from 'twenty-ui/theme-constants';+import { AiModelTierIndicator } from '@/ai/components/AiModelTierIndicator';import { useAiModelTiers } from '@/ai/hooks/useAiModelTiers';-import { hasCostPerTaskForEveryModel } from '@/ai/utils/hasCostPerTaskForEveryModel';import { type ResolvedAiModelTier } from '@/ai/types/ResolvedAiModelTier';-import { getAiModelBlendedCostPerMillionTokens } from '@/settings/ai/utils/getAiModelBlendedCostPerMillionTokens';+import { getAiModelModeDescription } from '@/settings/ai/utils/getAiModelModeDescription';+import { getModelIcon } from '@/settings/ai/utils/getModelIcon';import { Table } from '@/ui/layout/table/components/Table';import { TableCell } from '@/ui/layout/table/components/TableCell';import { TableHeader } from '@/ui/layout/table/components/TableHeader';import { TableRow } from '@/ui/layout/table/components/TableRow';import { formatNumber } from '~/utils/format/formatNumber';-const GRID_TEMPLATE_COLUMNS = '1fr 1fr 1fr 1fr 1.4fr';+const GRID_TEMPLATE_COLUMNS = '1fr 1fr 1fr 1fr';const EMPTY_VALUE = '–';const StyledInheritedValue = styled.span`@@ -46,69 +47,82 @@ const formatIntelligence = (tier: ResolvedAiModelTier) =>? formatNumber(tier.model.intelligenceIndex, { decimals: 0 }): EMPTY_VALUE;-// Artificial Analysis measures a cost per task at the same time as the index.-// The column only uses it when every tier has one; otherwise the rows would-// mix a price per task with a price per million tokens and stop comparing.-const formatCost = ({- tier,- hasCostPerTaskForEveryTier,-}: {- tier: ResolvedAiModelTier;- hasCostPerTaskForEveryTier: boolean;-}) => {- if (!isDefined(tier.model)) {- return EMPTY_VALUE;- }-- if (hasCostPerTaskForEveryTier && isDefined(tier.model.costPerTask)) {- return t`$${formatNumber(tier.model.costPerTask, { decimals: 2 })} / task`;- }+const formatCost = (tier: ResolvedAiModelTier) =>+ isDefined(tier.model?.outputCostPerMillionTokens) &&+ tier.model.outputCostPerMillionTokens > 0+ ? t`$${formatNumber(tier.model.outputCostPerMillionTokens, { decimals: 2 })} / 1M`+ : EMPTY_VALUE;- const blendedCost = getAiModelBlendedCostPerMillionTokens(tier.model);+const StyledMode = styled.span`+ align-items: center;+ display: inline-flex;+ gap: ${themeCssVariables.spacing[2]};+ white-space: nowrap;+`;- return isDefined(blendedCost)- ? t`$${formatNumber(blendedCost, { decimals: 2 })} / 1M tokens`- : EMPTY_VALUE;-};+const StyledTable = styled(Table)`+ border-bottom: 1px solid ${themeCssVariables.border.color.light};+`;export const SettingsAiModelTiersPreview = () => {const tiers = useAiModelTiers();- const hasCostPerTaskForEveryTier = hasCostPerTaskForEveryModel(- tiers.map((tier) => tier.model),- );return (<Section><H2Titletitle={t`Preview`}- description={t`The tiers people and agents choose between`}+ description={t`The modes people and agents choose between`}/>- <Table>+ <StyledTable><TableRow gridTemplateColumns={GRID_TEMPLATE_COLUMNS}>- <TableHeader>{t`Tier`}</TableHeader>- <TableHeader>{t`Model`}</TableHeader>+ <TableHeader>{t`Mode`}</TableHeader><TableHeader align="right">{t`Speed`}</TableHeader><TableHeader align="right">{t`Intelligence`}</TableHeader>- <TableHeader align="right">{t`Cost`}</TableHeader>+ <TableHeader align="right">{t`Output cost`}</TableHeader></TableRow>{tiers.map((tier) => (<TableRow key={tier.tier} gridTemplateColumns={GRID_TEMPLATE_COLUMNS}><TableCell color={themeCssVariables.font.color.primary}>- {tier.label}+ <StyledMode+ data-tooltip-id={`ai-model-mode-${tier.tier}`}+ tabIndex={0}+ >+ <AiModelTierIndicator tier={tier.tier} />+ {tier.label}+ </StyledMode>+ <AppTooltip+ anchorSelect={`[data-tooltip-id="ai-model-mode-${tier.tier}"]`}+ Icon={+ isDefined(tier.model)+ ? getModelIcon(+ tier.model.modelFamily,+ tier.model.providerName,+ )+ : undefined+ }+ title={getAiModelModeDescription(tier, {+ showAutomatic: false,+ })}+ description={+ !isDefined(tier.model)+ ? t`No model is available for this mode.`+ : tier.isPinned+ ? t`Manually selected for this mode.`+ : t`Automatically selected by Twenty for this mode.`+ }+ delay={TooltipDelay.shortDelay}+ /></TableCell>- <TableCell>{tier.model?.label ?? EMPTY_VALUE}</TableCell><TableCell align="right">{renderBenchmarkValue(tier, formatSpeed(tier))}</TableCell><TableCell align="right">{renderBenchmarkValue(tier, formatIntelligence(tier))}</TableCell>- <TableCell align="right">- {formatCost({ tier, hasCostPerTaskForEveryTier })}- </TableCell>+ <TableCell align="right">{formatCost(tier)}</TableCell></TableRow>))}- </Table>+ </StyledTable>{tiers.some((tier) => tier.model?.isBenchmarkInherited ?? false) && (<AppTooltipanchorSelect={`.${INHERITED_BENCHMARK_CLASS_NAME}`}diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelsTab.tsxindex 20f6e594ec4..3281bce07c4 100644--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelsTab.tsx+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelsTab.tsx@@ -1,45 +1,30 @@-import { styled } from '@linaria/react';-import { useContext } from 'react';-import { useQuery } from '@apollo/client/react';import { t } from '@lingui/core/macro';import { AI_MODEL_TIERS, type AiModelTier } from 'twenty-shared/ai';-import { SettingsPath } from 'twenty-shared/types';-import { getSettingsPath, isDefined } from 'twenty-shared/utils';-import {- IconMessage,- IconPrompt,- IconRefresh,- IconRobot,-} from 'twenty-ui/icon';+import { IconMessage, IconRobot, IconWand } from 'twenty-ui/icon';import { H2Title } from 'twenty-ui/typography';import { Section } from 'twenty-ui/layout';-import { UndecoratedLink } from 'twenty-ui/navigation';import { Card } from 'twenty-ui/surfaces';-import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';+import { themeCssVariables } from 'twenty-ui/theme-constants';+import { AiModelTierIndicator } from '@/ai/components/AiModelTierIndicator';import { useAiModelTiers } from '@/ai/hooks/useAiModelTiers';import { useWorkspaceAiModelTiers } from '@/ai/hooks/useWorkspaceAiModelTiers';import { getAiModelTierLabel } from '@/ai/utils/getAiModelTierLabel';import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';import { aiModelsState } from '@/client-config/states/aiModelsState';import { AiModelPinSelect } from '@/settings/ai/components/AiModelPinSelect';-import { SettingsCard } from '@/settings/components/SettingsCard';+import { getAiModelModeDescription } from '@/settings/ai/utils/getAiModelModeDescription';+import { NestedSettingsRow } from '@/settings/components/SettingsOptions/NestedSettingsRow';import { SettingsOptionCardContentSelect } from '@/settings/components/SettingsOptions/SettingsOptionCardContentSelect';import { SettingsOptionCardContentSwitch } from '@/settings/components/SettingsOptions/SettingsOptionCardContentSwitch';+import { StyledSettingsSelectGroup } from '@/settings/components/SettingsOptions/StyledSettingsSelectGroup';import { Select } from '@/ui/input/components/Select';import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';-import { GetAiSystemPromptPreviewDocument } from '~/generated-metadata/graphql';import { SettingsAiModelTiersPreview } from '~/pages/settings/ai/components/SettingsAiModelTiersPreview';import { useSettingsAiModelsActions } from '~/pages/settings/ai/hooks/useSettingsAiModelsActions';-import { formatNumber } from '~/utils/format/formatNumber';--const StyledPinnedModelsContainer = styled.div`- padding-top: ${themeCssVariables.spacing[4]};-`;export const SettingsAiModelsTab = () => {- const { theme } = useContext(ThemeContext);const currentWorkspace = useAtomStateValue(currentWorkspaceState);const aiModels = useAtomStateValue(aiModelsState);const tiers = useAiModelTiers();@@ -51,17 +36,6 @@ export const SettingsAiModelsTab = () => {handlePinnedModelChange,} = useSettingsAiModelsActions();- const { data: previewData } = useQuery(GetAiSystemPromptPreviewDocument);-- const systemPromptTokenCount =- previewData?.getAiSystemPromptPreview.estimatedTokenCount;- const systemPromptDescription = isDefined(systemPromptTokenCount)- ? t`Read the system prompts to understand how the AI works (~${formatNumber(- systemPromptTokenCount,- { abbreviate: true, decimals: 1 },- )} tokens)`- : t`Read the system prompts to understand how the AI works`;-const isAutoModelSelectionEnabled =currentWorkspace?.isAutoModelSelectionEnabled ?? true;const aiModelIdByTier: Partial<Record<AiModelTier, string>> =@@ -70,6 +44,7 @@ export const SettingsAiModelsTab = () => {const tierOptions = AI_MODEL_TIERS.map((tier) => ({value: tier,label: getAiModelTierLabel(tier),+ LeftComponent: <AiModelTierIndicator tier={tier} />,}));return (@@ -77,94 +52,79 @@ export const SettingsAiModelsTab = () => {<Section><H2Titletitle={t`Models`}- description={t`Which level of model people and agents get by default`}+ description={t`Choose the default modes for people and agents`}/>- <Card rounded>- <SettingsOptionCardContentSelect- Icon={IconMessage}- title={t`AI chat`}- description={t`Model used when you chat with Twenty`}- divider- >- <Select- dropdownId="models-tab-chat-tier-select"- value={chatTier}- onChange={handleChatTierChange}- options={tierOptions}- selectSizeVariant="small"- />- </SettingsOptionCardContentSelect>- <SettingsOptionCardContentSelect- Icon={IconRobot}- title={t`Agents`}- description={t`Model agents use when they run on their own`}- divider- >- <Select- dropdownId="models-tab-agent-tier-select"- value={agentTier}- onChange={handleAgentTierChange}- options={tierOptions}- selectSizeVariant="small"- />- </SettingsOptionCardContentSelect>+ <Card rounded backgroundColor={themeCssVariables.background.secondary}>+ <StyledSettingsSelectGroup controlWidth={160}>+ <SettingsOptionCardContentSelect+ Icon={IconMessage}+ title={t`AI chat`}+ description={t`Model used when you chat with Twenty`}+ divider+ >+ <Select+ dropdownId="models-tab-chat-tier-select"+ value={chatTier}+ onChange={handleChatTierChange}+ options={tierOptions}+ selectSizeVariant="small"+ />+ </SettingsOptionCardContentSelect>+ <SettingsOptionCardContentSelect+ Icon={IconRobot}+ title={t`Agents`}+ description={t`Model agents use when they run on their own`}+ divider+ >+ <Select+ dropdownId="models-tab-agent-tier-select"+ value={agentTier}+ onChange={handleAgentTierChange}+ options={tierOptions}+ selectSizeVariant="small"+ />+ </SettingsOptionCardContentSelect>+ </StyledSettingsSelectGroup><SettingsOptionCardContentSwitch- Icon={IconRefresh}+ Icon={IconWand}title={t`Choose automatically`}description={t`Twenty fills each level with the best model that meets your requirements`}checked={isAutoModelSelectionEnabled}onChange={handleAutoModelSelectionToggle}/>- </Card>-- {!isAutoModelSelectionEnabled && (- <StyledPinnedModelsContainer>- <Card rounded>+ {!isAutoModelSelectionEnabled && (+ <StyledSettingsSelectGroup controlWidth={260}>{tiers.map((tier, index) => (- <SettingsOptionCardContentSelect+ <NestedSettingsRowkey={tier.tier}- title={tier.label}- description={- tier.isPinned- ? t`Pinned`- : isDefined(tier.model)- ? t`Automatic: ${tier.model.label}`- : t`No model available`- }- divider={index < tiers.length - 1}+ isLast={index === tiers.length - 1}>- <AiModelPinSelect- dropdownId={`models-tab-pinned-model-select-${tier.tier}`}- modelId={aiModelIdByTier[tier.tier] ?? null}- onChange={(modelId) =>- handlePinnedModelChange(tier.tier, modelId)- }- aiModels={aiModels}- emptyOptionLabel={t`Automatic`}- selectSizeVariant="small"- dropdownWidth={GenericDropdownContentWidth.ExtraLarge}- />- </SettingsOptionCardContentSelect>+ <SettingsOptionCardContentSelect+ LeftComponent={<AiModelTierIndicator tier={tier.tier} />}+ title={tier.label}+ description={getAiModelModeDescription(tier)}+ divider={index < tiers.length - 1}+ >+ <AiModelPinSelect+ dropdownId={`models-tab-pinned-model-select-${tier.tier}`}+ modelId={aiModelIdByTier[tier.tier] ?? null}+ onChange={(modelId) =>+ handlePinnedModelChange(tier.tier, modelId)+ }+ aiModels={aiModels}+ emptyOptionLabel={t`Automatic`}+ selectSizeVariant="small"+ dropdownWidth={GenericDropdownContentWidth.ExtraLarge}+ />+ </SettingsOptionCardContentSelect>+ </NestedSettingsRow>))}- </Card>- </StyledPinnedModelsContainer>- )}+ </StyledSettingsSelectGroup>+ )}+ </Card></Section><SettingsAiModelTiersPreview />-- <Section>- <H2Title- title={t`System Prompt`}- description={systemPromptDescription}- />- <UndecoratedLink to={getSettingsPath(SettingsPath.AiPrompts)}>- <SettingsCard- Icon={<IconPrompt size={theme.icon.size.md} />}- title={t`Read system prompts`}- />- </UndecoratedLink>- </Section></>);};diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiSystemPromptsSection.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiSystemPromptsSection.tsxnew file mode 100644index 00000000000..ddd17dc0edd--- /dev/null+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiSystemPromptsSection.tsx@@ -0,0 +1,39 @@+import { useQuery } from '@apollo/client/react';+import { t } from '@lingui/core/macro';+import { useContext } from 'react';+import { SettingsPath } from 'twenty-shared/types';+import { getSettingsPath, isDefined } from 'twenty-shared/utils';+import { IconPrompt } from 'twenty-ui/icon';+import { Section } from 'twenty-ui/layout';+import { UndecoratedLink } from 'twenty-ui/navigation';+import { H2Title } from 'twenty-ui/typography';+import { ThemeContext } from 'twenty-ui/theme-constants';+import { SettingsCard } from '@/settings/components/SettingsCard';+import { GetAiSystemPromptPreviewDocument } from '~/generated-metadata/graphql';+import { formatNumber } from '~/utils/format/formatNumber';++export const SettingsAiSystemPromptsSection = () => {+ const { theme } = useContext(ThemeContext);+ const { data: previewData } = useQuery(GetAiSystemPromptPreviewDocument);++ const systemPromptTokenCount =+ previewData?.getAiSystemPromptPreview.estimatedTokenCount;+ const systemPromptDescription = isDefined(systemPromptTokenCount)+ ? t`Read the system prompts to understand how the AI works (~${formatNumber(+ systemPromptTokenCount,+ { abbreviate: true, decimals: 1 },+ )} tokens)`+ : t`Read the system prompts to understand how the AI works`;++ return (+ <Section>+ <H2Title title={t`System Prompt`} description={systemPromptDescription} />+ <UndecoratedLink to={getSettingsPath(SettingsPath.AiPrompts)}>+ <SettingsCard+ Icon={<IconPrompt size={theme.icon.size.md} />}+ title={t`Read system prompts`}+ />+ </UndecoratedLink>+ </Section>+ );+};diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.spec.tsnew file mode 100644index 00000000000..7ad02150215--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.spec.ts@@ -0,0 +1,106 @@+import { Test } from '@nestjs/testing';++import { CustomAiProviderAccessService } from 'src/engine/core-modules/enterprise/services/custom-ai-provider-access.service';+import { ConfigGroupHashService } from 'src/engine/core-modules/twenty-config/services/config-group-hash.service';+import { AiModelPreferencesService } from 'src/engine/metadata-modules/ai/ai-models/services/ai-model-preferences.service';+import { AiModelRegistryService } from 'src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service';+import { ProviderConfigService } from 'src/engine/metadata-modules/ai/ai-models/services/provider-config.service';+import { SdkProviderFactoryService } from 'src/engine/metadata-modules/ai/ai-models/services/sdk-provider-factory.service';++describe('AiModelRegistryService effort catalog', () => {+ let registry: AiModelRegistryService;+ const getDisabledModelIds = jest.fn((): string[] => []);++ beforeEach(async () => {+ getDisabledModelIds.mockReturnValue([]);+ const module = await Test.createTestingModule({+ providers: [+ AiModelRegistryService,+ {+ provide: ProviderConfigService,+ useValue: {+ getResolvedProviders: () => ({+ openai: {+ npm: '@ai-sdk/openai',+ apiKey: 'test-key',+ models: ['sol', 'astra'].map((name) => ({+ name,+ label: name,+ efforts: ['medium', 'high'],+ benchmarkByEffort: {+ medium: { intelligenceIndex: 42 },+ },+ })),+ },+ }),+ },+ },+ {+ provide: SdkProviderFactoryService,+ useValue: {+ clearCache: jest.fn(),+ createProvider: () => ({ createModel: () => ({}) }),+ },+ },+ {+ provide: AiModelPreferencesService,+ useValue: {+ getDisabledModelIds,+ getDefaultModelIdsForTier: () => ['openai/sol@high'],+ },+ },+ {+ provide: ConfigGroupHashService,+ useValue: { computeHash: () => 'test' },+ },+ {+ provide: CustomAiProviderAccessService,+ useValue: { getCachedHasAccess: () => true },+ },+ ],+ }).compile();++ registry = module.get(AiModelRegistryService);+ });++ it('lists every selectable effort before any variant is requested', () => {+ expect(+ registry.getAdminFilteredModels().map(({ modelId }) => modelId),+ ).toEqual(+ expect.arrayContaining([+ 'openai/sol@medium',+ 'openai/sol@high',+ 'openai/astra@medium',+ 'openai/astra@high',+ ]),+ );+ expect(registry.getModelConfig('openai/astra@medium')?.benchmark).toEqual({+ intelligenceIndex: 42,+ });+ expect(registry.getModel('openai/astra@low')).toBeUndefined();+ });++ it('excludes all efforts of an admin-disabled model', () => {+ getDisabledModelIds.mockReturnValue(['openai/astra']);++ expect(+ registry+ .getAdminFilteredModels()+ .some(({ modelId }) => modelId.startsWith('openai/astra')),+ ).toBe(false);+ });++ it('exposes only base models in provider management after resolving variants', () => {+ registry.getModelConfig('openai/astra@medium');++ expect(+ registry.getAllModelsWithStatus().map(({ modelConfig, name }) => ({+ modelId: modelConfig.modelId,+ name,+ })),+ ).toEqual([+ { modelId: 'openai/sol', name: 'sol' },+ { modelId: 'openai/astra', name: 'astra' },+ ]);+ });+});diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.tsindex 7348093c900..91a7f411310 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts@@ -126,7 +126,7 @@ export class AiModelRegistryService {});this.registerModelsFromProviders(providers);- this.registerConfiguredVariants();+ this.registerSupportedVariants();}private registerModelsFromProviders(providers: AiProvidersConfig): void {@@ -187,12 +187,12 @@ export class AiModelRegistryService {}}- private registerConfiguredVariants(): void {- for (const tier of AI_MODEL_TIERS) {- for (const variantId of this.preferencesService.getDefaultModelIdsForTier(- tier,- )) {- this.registerVariant(variantId);+ private registerSupportedVariants(): void {+ // The client catalog must resolve every selectable effort before a pin is+ // saved, not only variants that have already been used by the server.+ for (const modelConfig of Array.from(this.modelConfigCache.values())) {+ for (const effort of getAvailableEfforts(modelConfig)) {+ this.registerVariant(`${modelConfig.modelId}@${effort}`);}}}@@ -636,18 +636,21 @@ export class AiModelRegistryService {}> {this.ensureFresh();- return Array.from(this.modelConfigCache.values()).map((modelConfig) => {- const registered = this.modelRegistry.get(modelConfig.modelId);- const cached = this.providerModelDefCache.get(modelConfig.modelId);-- return {- modelConfig,- isAvailable: !!registered,- isAdminEnabled: this.isModelAdminAllowed(modelConfig.modelId),- providerName: registered?.providerName ?? cached?.providerName,- name: cached?.modelDef.name,- };- });+ // Effort variants share the base model's management and deletion target.+ return Array.from(this.modelConfigCache.values())+ .filter((modelConfig) => !isDefined(modelConfig.effort))+ .map((modelConfig) => {+ const registered = this.modelRegistry.get(modelConfig.modelId);+ const cached = this.providerModelDefCache.get(modelConfig.modelId);++ return {+ modelConfig,+ isAvailable: !!registered,+ isAdminEnabled: this.isModelAdminAllowed(modelConfig.modelId),+ providerName: registered?.providerName ?? cached?.providerName,+ name: cached?.modelDef.name,+ };+ });}async setModelAdminEnabled(modelId: string, enabled: boolean): Promise<void> {diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/default-ai-catalog.service.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/default-ai-catalog.service.tsindex 28b82adadc2..bca92c2c4f2 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/default-ai-catalog.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/default-ai-catalog.service.ts@@ -5,15 +5,17 @@ import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twentimport defaultAiProviders from 'src/engine/metadata-modules/ai/ai-models/ai-providers.json';import { aiProvidersConfigSchema } from 'src/engine/metadata-modules/ai/ai-models/types/ai-providers-config.schema';import { type AiProvidersConfig } from 'src/engine/metadata-modules/ai/ai-models/types/ai-providers-config.type';+import { inheritCatalogReadings } from 'src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util';import { normalizeAiProviders } from 'src/engine/metadata-modules/ai/ai-models/utils/normalize-ai-providers.util';import { streamToBuffer } from 'src/utils/stream-to-buffer';@Injectable()export class DefaultAiCatalogService implements OnModuleInit {private readonly logger = new Logger(DefaultAiCatalogService.name);- private catalog: AiProvidersConfig = normalizeAiProviders(+ private readonly builtInCatalog: AiProvidersConfig = normalizeAiProviders(defaultAiProviders as AiProvidersConfig,);+ private catalog: AiProvidersConfig = this.builtInCatalog;constructor(private readonly twentyConfigService: TwentyConfigService,@@ -34,7 +36,13 @@ export class DefaultAiCatalogService implements OnModuleInit {try {const raw = await this.fetchCatalog(catalogPath);- this.catalog = normalizeAiProviders(raw);+ // A stored catalog carries the credentials, labels and prices of one+ // deployment, not the efforts and benchmarks the sync measures, so it+ // lists the models and the built-in catalog describes the ones it knows.+ this.catalog = inheritCatalogReadings({+ catalog: this.builtInCatalog,+ providers: normalizeAiProviders(raw),+ });this.logger.log(`Loaded AI catalog from storage: ${catalogPath}`);} catch (error: unknown) {const message = error instanceof Error ? error.message : String(error);diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/__tests__/merge-custom-providers-into-catalog.util.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/__tests__/merge-custom-providers-into-catalog.util.spec.tsindex 6eebd63b237..1d3238dc827 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/__tests__/merge-custom-providers-into-catalog.util.spec.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/__tests__/merge-custom-providers-into-catalog.util.spec.ts@@ -1,5 +1,8 @@import { type AiProvidersConfig } from 'src/engine/metadata-modules/ai/ai-models/types/ai-providers-config.type';-import { mergeCustomProvidersIntoCatalog } from 'src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util';+import {+ inheritCatalogReadings,+ mergeCustomProvidersIntoCatalog,+} from 'src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util';const catalog: AiProvidersConfig = {openai: {@@ -195,3 +198,34 @@ describe('mergeCustomProvidersIntoCatalog', () => {});});});++describe('inheritCatalogReadings', () => {+ it('keeps only the providers it is given, with the catalog readings', () => {+ const providers = inheritCatalogReadings({+ catalog,+ providers: {+ 'azure-foundry': {+ npm: '@ai-sdk/azure',+ label: 'Azure',+ apiKey: 'azure-key',+ models: [+ {+ name: 'gpt-5.6-luna',+ label: 'Luna on Azure',+ inputCostPerMillionTokens: 0.25,+ outputCostPerMillionTokens: 1.4,+ },+ ],+ },+ },+ });++ expect(Object.keys(providers)).toEqual(['azure-foundry']);+ expect(providers['azure-foundry'].models?.[0]).toMatchObject({+ label: 'Luna on Azure',+ efforts: ['low', 'medium', 'high'],+ benchmark: { intelligenceIndex: 37.5 },+ inputCostPerMillionTokens: 0.25,+ });+ });+});diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util.tsindex cc920b94803..e4cb18f4d7f 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/utils/merge-custom-providers-into-catalog.util.ts@@ -36,7 +36,7 @@ const routeCandidates = (modelName: string): string[] => {return segments.map((_, index) => segments.slice(index).join('.'));};-const withCatalogReadings = ({+const withCatalogModelReadings = ({catalogModel,customModel,}: {@@ -68,7 +68,7 @@ const mergeModels = ({);return isDefined(catalogModel)- ? withCatalogReadings({+ ? withCatalogModelReadings({catalogModel,customModel: { ...catalogModel, ...customModel },})@@ -102,46 +102,58 @@ const withReadingsFromAnyProvider = ({.find(isDefined);return isDefined(catalogModel)- ? withCatalogReadings({ catalogModel, customModel })+ ? withCatalogModelReadings({ catalogModel, customModel }): customModel;});};-// A custom entry replaces the catalog provider of the same name, but an entry-// written before the catalog carried efforts and benchmarks would then strip-// both from every model it lists, and the tier chains could no longer name-// an effort on it. A model the catalog knows keeps the catalog fields it does-// not set itself; the custom entry still decides which models exist.-export const mergeCustomProvidersIntoCatalog = ({+// A provider written before the catalog carried efforts and benchmarks would+// strip both from every model it lists, and the tier chains could no longer+// name an effort on it. A model the catalog knows keeps the catalog fields the+// entry does not set itself; the entry still decides which models exist.+export const inheritCatalogReadings = ({catalog,- custom,+ providers,}: {catalog: AiProvidersConfig;- custom: AiProvidersConfig;+ providers: AiProvidersConfig;}): AiProvidersConfig => {- const merged: AiProvidersConfig = { ...catalog };+ const result: AiProvidersConfig = {};- for (const [providerName, customProvider] of Object.entries(custom)) {+ for (const [providerName, provider] of Object.entries(providers)) {const catalogProvider: AiProviderConfig | undefined = catalog[providerName];- if (!isDefined(customProvider.models)) {- merged[providerName] = customProvider;+ if (!isDefined(provider.models)) {+ result[providerName] = provider;continue;}- merged[providerName] = {- ...customProvider,+ result[providerName] = {+ ...provider,models: isDefined(catalogProvider)? mergeModels({catalogModels: catalogProvider.models ?? [],- customModels: customProvider.models,+ customModels: provider.models,}): withReadingsFromAnyProvider({catalog,- customModels: customProvider.models,+ customModels: provider.models,}),};}- return merged;+ return result;};++// A custom entry replaces the catalog provider of the same name; providers it+// does not name stay as the catalog has them.+export const mergeCustomProvidersIntoCatalog = ({+ catalog,+ custom,+}: {+ catalog: AiProvidersConfig;+ custom: AiProvidersConfig;+}): AiProvidersConfig => ({+ ...catalog,+ ...inheritCatalogReadings({ catalog, providers: custom }),+});diff --git a/packages/twenty-ui/src/input/types/SelectOption.ts b/packages/twenty-ui/src/input/types/SelectOption.tsindex d43434868cc..376d4c2ec07 100644--- a/packages/twenty-ui/src/input/types/SelectOption.ts+++ b/packages/twenty-ui/src/input/types/SelectOption.ts@@ -1,10 +1,12 @@import { type IconComponent } from '@ui/icon';import { type ThemeColor } from '@ui/theme';+import { type ReactNode } from 'react';export type SelectOption<Value extends string | number | boolean | null = string,> = {Icon?: IconComponent | null;+ LeftComponent?: ReactNode;iconThemeColor?: ThemeColor | null;label: string;fullLabel?: string;diff --git a/packages/twenty-ui/src/navigation/MenuItemSelect/MenuItemSelect.tsx b/packages/twenty-ui/src/navigation/MenuItemSelect/MenuItemSelect.tsxindex c1745559341..174ca14e302 100644--- a/packages/twenty-ui/src/navigation/MenuItemSelect/MenuItemSelect.tsx+++ b/packages/twenty-ui/src/navigation/MenuItemSelect/MenuItemSelect.tsx@@ -45,6 +45,7 @@ export const StyledMenuItemSelect = forwardRef<StyledMenuItemSelect.displayName = 'StyledMenuItemSelect';type MenuItemSelectProps = {+ LeftComponent?: ReactNode;LeftIcon?: IconComponent | null | undefined;leftIconColor?: ThemeColor | null;withIconContainer?: boolean;@@ -61,6 +62,7 @@ type MenuItemSelectProps = {};export const MenuItemSelect = ({+ LeftComponent,LeftIcon,leftIconColor,withIconContainer = false,@@ -88,6 +90,7 @@ export const MenuItemSelect = ({aria-disabled={disabled}><MenuItemLeftContent+ LeftComponent={LeftComponent}LeftIcon={LeftIcon}iconThemeColor={leftIconColor}text={text}diff --git a/packages/twenty-ui/src/navigation/MenuItemSelect/__tests__/MenuItemSelect.test.tsx b/packages/twenty-ui/src/navigation/MenuItemSelect/__tests__/MenuItemSelect.test.tsxnew file mode 100644index 00000000000..e68c06f9ec7--- /dev/null+++ b/packages/twenty-ui/src/navigation/MenuItemSelect/__tests__/MenuItemSelect.test.tsx@@ -0,0 +1,36 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { describe, expect, it, vi } from 'vitest';++import { MenuItemSelect } from '@ui/navigation/MenuItemSelect/MenuItemSelect';++describe('MenuItemSelect', () => {+ it('renders custom leading content and keeps the option selectable', async () => {+ const onClick = vi.fn();+ const user = userEvent.setup();++ render(+ <MenuItemSelect+ text="Fast"+ selected={false}+ LeftComponent={<span role="img" aria-label="Speed indicator" />}+ onClick={onClick}+ />,+ );++ expect(screen.getByRole('img', { name: 'Speed indicator' })).toBeVisible();+ const option = screen.getByRole('option', { name: 'Speed indicator Fast' });+ expect(option).toHaveAttribute('aria-selected', 'false');+ await user.click(option);+ expect(onClick).toHaveBeenCalledOnce();+ });++ it('preserves text-only selected options', () => {+ render(<MenuItemSelect text="Balanced" selected />);++ expect(screen.getByRole('option', { name: 'Balanced' })).toHaveAttribute(+ 'aria-selected',+ 'true',+ );+ });+});