Skip to content

The open alternative to Salesforce, designed for AI.

Align inbox conversation components (#28566)

RaphaΓ«l Bosi1b2d49d9a932
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/emoji-picker.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/emoji-picker.mdx
new file mode 100644
index 00000000000..4e339e025b8
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/emoji-picker.mdx
@@ -0,0 +1,56 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="autoFocus" type="boolean" default="false">
+ Focuses the search input when the picker mounts.
+</ParamField>
+
+<ParamField body="className" type="string">
+ Additional class name applied to the picker root div.
+</ParamField>
+
+<ParamField body="emojibaseUrl" type="string" required>
+ Base URL for caller-hosted Emojibase data. The picker loads data.json and messages.json from the selected locale directory.
+</ParamField>
+
+<ParamField body="emptyLabel" type="string" required>
+ Caller-supplied message displayed when no emoji matches the search.
+</ParamField>
+
+<ParamField body="loadingLabel" type="string" required>
+ Caller-supplied message displayed while emoji data loads.
+</ParamField>
+
+<ParamField body="locale" type="string" default="en">
+ Emoji catalogue locale. The caller must host its data and message files. Interface labels are supplied separately.
+</ParamField>
+
+<ParamField body="onEmojiSelect" type="(emoji: string) =&gt; void" required>
+ Called with the selected Unicode emoji string. The application owns the selected value, persistence, and popup visibility.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref for the picker root div.
+</ParamField>
+
+<ParamField body="searchLabel" type="string" required>
+ Accessible name for the search input. Also supplies its placeholder unless searchPlaceholder is set.
+</ParamField>
+
+<ParamField body="searchPlaceholder" type="string" default="searchLabel">
+ Optional placeholder overriding the search label.
+</ParamField>
+
+<ParamField body="style" type="CSSProperties">
+ Native inline styles applied to the picker root div.
+</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/count-pager.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/count-pager.mdx
new file mode 100644
index 00000000000..3505ce3f261
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/count-pager.mdx
@@ -0,0 +1,64 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="className" type="string">
+ CSS class applied to the root element.
+</ParamField>
+
+<ParamField body="count" type="number" required>
+ Number of items in the collection. Empty collections and invalid or noninteger counts disable navigation.
+</ParamField>
+
+<ParamField body="disabled" type="boolean" default="false">
+ Disables both navigation buttons without changing the position text.
+</ParamField>
+
+<ParamField body="index" type="number" required>
+ Controlled zero-based item index. Navigation is disabled when the index is not an integer within the collection bounds.
+</ParamField>
+
+<ParamField body="nextLabel" type="string" required>
+ Accessible name of the Next button.
+</ParamField>
+
+<ParamField body="onIndexChange" type="(index: number) =&gt; void" required>
+ Requests the neighboring index after activating Previous or Next. Prop changes do not call this callback or select a replacement item.
+</ParamField>
+
+<ParamField body="positionPlacement" type="&quot;between&quot; | &quot;start&quot;" default="between">
+ Places the position text between the buttons or at the start of the row. Start placement lets the text fill the available width.
+</ParamField>
+
+<ParamField body="positionText" type="string" required>
+ Caller-formatted position text, announced politely when it changes. The caller also supplies text for empty collections.
+</ParamField>
+
+<ParamField body="previousLabel" type="string" required>
+ Accessible name of the Previous button.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the root element.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Replaces the root element while preserving its props and contents.
+</ParamField>
+
+<ParamField body="role" type="AriaRole" default="group">
+ Root semantics. Defaults to a group; the caller supplies its accessible name.
+</ParamField>
+
+<ParamField body="style" type="CSSProperties">
+ Inline styles applied to the root element.
+</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/icon/catalog.mdx b/packages/twenty-docs/snippets/ui/generated/icon/catalog.mdx
index d13737c16f9..189f8ed7b3f 100644
--- a/packages/twenty-docs/snippets/ui/generated/icon/catalog.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/icon/catalog.mdx
@@ -123,6 +123,7 @@ Supported props: `color`, `size`, `stroke`, `title`. Native SVG attributes and r
- `IconCompass`
- `IconCopy`
- `IconCopyPlus`
+- `IconCornerDownRight`
- `IconCpu`
- `IconCreativeCommonsSa`
- `IconCreditCard`
@@ -220,6 +221,7 @@ Supported props: `color`, `size`, `stroke`, `title`. Native SVG attributes and r
- `IconFolderRoot`
- `IconFolderSymlink`
- `IconForbid`
+- `IconForms`
- `IconFrame`
- `IconFunction`
- `IconGauge`
@@ -310,6 +312,7 @@ Supported props: `color`, `size`, `stroke`, `title`. Native SVG attributes and r
- `IconMinimize`
- `IconMinus`
- `IconMoneybag`
+- `IconMoodPlus`
- `IconMoodSmile`
- `IconMoon`
- `IconMouse2`
diff --git a/packages/twenty-docs/ui/components/input/emoji-picker.mdx b/packages/twenty-docs/ui/components/input/emoji-picker.mdx
new file mode 100644
index 00000000000..df2791d05f6
--- /dev/null
+++ b/packages/twenty-docs/ui/components/input/emoji-picker.mdx
@@ -0,0 +1,73 @@
+---
+title: EmojiPicker
+description: Search and select an emoji using caller-hosted Emojibase data.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import EmojiPickerReference from '/snippets/ui/generated/components/input/emoji-picker.mdx';
+
+`EmojiPicker` provides emoji search, category browsing, and keyboard selection. Your application supplies its labels, emoji data location, and selection handler.
+
+<StoryEmbed
+ storyId="ui-input-emojipicker--display"
+ title="Search emojis and choose a reaction"
+ height={400}
+/>
+
+## Usage
+
+```tsx
+import { useState } from 'react';
+import { EmojiPicker } from 'twenty-ui/components/input';
+import { Text } from 'twenty-ui/primitives/typography';
+import { themeCssVariables } from 'twenty-ui/theme';
+import { isDefined } from 'twenty-ui/utilities';
+
+export const EmojiPickerExample = () => {
+ const [emoji, setEmoji] = useState<string | undefined>();
+
+ return (
+ <Text
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ gap: themeCssVariables.spacing[2],
+ width: 296,
+ }}
+ >
+ <EmojiPicker
+ emojibaseUrl="/emojibase"
+ searchLabel="Search emojis"
+ loadingLabel="Loading emojis"
+ emptyLabel="No emoji found"
+ onEmojiSelect={setEmoji}
+ />
+ <Text role="status">
+ {isDefined(emoji) ? `Selected emoji: ${emoji}` : 'Choose an emoji'}
+ </Text>
+ </Text>
+ );
+};
+```
+
+The preview uses a small fixture catalogue. The usage example expects your application to serve Emojibase data at `/emojibase`.
+
+## Data and labels
+
+`emojibaseUrl` is required. The picker loads both `${emojibaseUrl}/${locale}/data.json` and `${emojibaseUrl}/${locale}/messages.json`. Host those files from the Emojibase data package for each supported locale. The default locale is `en`; supplying translated interface labels does not change the emoji catalogue locale.
+
+Provide localized `searchLabel`, `loadingLabel`, and `emptyLabel`. `searchLabel` names the search field and supplies its placeholder unless `searchPlaceholder` overrides it. Emoji names, categories, and search tags come from the selected Emojibase locale.
+
+## Selection and composition
+
+`onEmojiSelect` receives the selected Unicode emoji string. The picker keeps its search and active emoji internally. Your application owns any selected value, reaction counts, message identifiers, permissions, persistence, and popup visibility. Compose it inside [Dropdown](/ui/components/navigation/dropdown) when it needs a popup.
+
+The picker uses eight columns and a 280px height. Set its container width to fit the grid. Native div attributes, handlers, styles, class names, and refs target its outer container.
+
+## Accessibility
+
+The search input has the supplied accessible name. Focus it with Tab, or set `autoFocus` when opening a popup. Arrow keys navigate the emoji grid, and Enter selects the active emoji. Each emoji has an accessible name from the selected catalogue. `autoFocus` defaults to `false`.
+
+## Props
+
+<EmojiPickerReference />
diff --git a/packages/twenty-docs/ui/components/navigation/count-pager.mdx b/packages/twenty-docs/ui/components/navigation/count-pager.mdx
new file mode 100644
index 00000000000..617db475d00
--- /dev/null
+++ b/packages/twenty-docs/ui/components/navigation/count-pager.mdx
@@ -0,0 +1,87 @@
+---
+title: CountPager
+description: Navigate a finite collection with previous and next controls and formatted position text.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import CountPagerReference from '/snippets/ui/generated/components/navigation/count-pager.mdx';
+
+`CountPager` combines previous and next buttons with caller-formatted position text. Use it to move through a small collection such as review items or requests.
+
+<StoryEmbed
+ storyId="ui-components-countpager--display"
+ title="Count pager example"
+ height={100}
+/>
+
+## Usage
+
+```tsx
+import { useState } from 'react';
+import { CountPager } from 'twenty-ui/components/navigation';
+
+export const ReviewPager = () => {
+ const [index, setIndex] = useState(0);
+
+ return (
+ <CountPager
+ aria-label="Review item"
+ index={index}
+ count={3}
+ onIndexChange={setIndex}
+ positionText={`${index + 1} of 3`}
+ previousLabel="Previous item"
+ nextLabel="Next item"
+ />
+ );
+};
+```
+
+## Controlled navigation
+
+Supply a zero-based `index`, the collection's `count`, and `onIndexChange`. Activating an available button requests the neighboring index. Your application updates the index and renders the corresponding content.
+
+Previous is disabled on the first item, and Next is disabled on the last item. Both buttons are disabled for an empty or single-item collection, when `disabled` is set, or when the supplied index or count is invalid. Counts must be nonnegative integers, and the index must be an integer within the collection bounds.
+
+Changing props never calls `onIndexChange`. When items disappear or the collection changes, your application chooses the next active item. Data loading, stable item identities, draft preservation, and executing the displayed item remain with the application.
+
+## Position text and placement
+
+`positionText` is required and stays under application control. Format numbers, units, and translations before passing it to the pager. For an empty collection, supply a meaningful value such as `No items`; the component does not invent an empty-state label.
+
+The default `positionPlacement="between"` shows Previous, position text, and Next. Set `positionPlacement="start"` to place the text before both buttons. The text then fills the available width so the actions align at the end of the row.
+
+```tsx
+import { useState } from 'react';
+import { CountPager } from 'twenty-ui/components/navigation';
+
+export const RequestPager = () => {
+ const [index, setIndex] = useState(0);
+
+ return (
+ <CountPager
+ aria-label="Pending requests"
+ index={index}
+ count={3}
+ onIndexChange={setIndex}
+ positionText={`Request ${index + 1} of 3`}
+ previousLabel="Previous request"
+ nextLabel="Next request"
+ positionPlacement="start"
+ style={{ width: 280, maxWidth: '100%' }}
+ />
+ );
+};
+```
+
+## Accessibility and composition
+
+The root defaults to a group. Supply a contextual accessible name with `aria-label` or `aria-labelledby`, plus `previousLabel` and `nextLabel` for the two icon buttons. Position text uses a polite live region so changes can be announced without moving focus.
+
+The controls use native buttons with the shared [LightIconButton](/ui/components/input/light-icon-button) presentation. Tab moves between enabled controls, and Enter or Space activates the focused button. Disabled controls cannot navigate. Pager clicks do not submit a surrounding form.
+
+Native attributes, `className`, `style`, and `ref` target the root. Use `render` to compose a different root element while preserving the supplied props and ref. Keep the buttons and their interaction semantics intact.
+
+## Props
+
+<CountPagerReference />
diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.json
index 78f63bd1d1b..7d28c9106e5 100644
--- a/packages/twenty-front/package.json
+++ b/packages/twenty-front/package.json
@@ -94,7 +94,6 @@
"deep-equal": "^2.2.2",
"file-saver": "^2.0.5",
"framer-motion": "^11.18.0",
- "frimousse": "^0.4.0",
"fuse.js": "^7.1.0",
"graphiql": "^5.2.3",
"graphql": "16.8.1",
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx b/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx
index 13256c8f8c3..1d881f8fff5 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatAskStatusRow.tsx
@@ -3,7 +3,7 @@ import { type ReactNode } from 'react';
import { type IconComponent } from 'twenty-ui/icon';
import { themeCssVariables, useTheme } from 'twenty-ui/theme';
-import { StyledAiChatAskStatusMessage } from '@/ai/components/AiChatAskStyledComponents';
+import { StyledAiChatAskStatusMessage } from '@/ai/components/StyledAiChatAskStatusMessage';
import { ShimmeringText } from '@/ai/components/ShimmeringText';
const StyledContainer = styled.div`
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatAskStyledComponents.tsx b/packages/twenty-front/src/modules/ai/components/AiChatAskStyledComponents.tsx
deleted file mode 100644
index 9ddad5f8bfb..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatAskStyledComponents.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { styled } from '@linaria/react';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-export const StyledAiChatAskCard = styled.div`
- background-color: ${themeCssVariables.background.transparent.lighter};
- border: 1px solid ${themeCssVariables.border.color.medium};
- border-radius: ${themeCssVariables.border.radius.sm};
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- width: 100%;
-`;
-
-export const StyledAiChatAskStatusMessage = styled.span`
- color: ${themeCssVariables.font.color.tertiary};
- font-size: ${themeCssVariables.font.size.md};
- font-weight: ${themeCssVariables.font.weight.medium};
-`;
-
-export const StyledAiChatAskStatusDetail = styled.span`
- color: ${themeCssVariables.font.color.secondary};
- font-size: ${themeCssVariables.font.size.sm};
- overflow-wrap: anywhere;
-`;
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatAssistantMessageRenderer.tsx b/packages/twenty-front/src/modules/ai/components/AiChatAssistantMessageRenderer.tsx
index 1e683ec8752..e392aa56ac8 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatAssistantMessageRenderer.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatAssistantMessageRenderer.tsx
@@ -38,14 +38,23 @@ const MessagePartRenderer = ({
part,
frontComponentIdByToolName,
isStreaming,
+ isUserMessage,
}: {
part: ExtendedUIMessagePart;
frontComponentIdByToolName: Map<string, string>;
isStreaming: boolean;
+ isUserMessage?: boolean;
}) => {
+ const displayMode = isUserMessage ? 'bubble' : 'chat';
+
switch (part.type) {
case 'text':
- return <LazyMarkdownContent text={part.text} />;
+ return (
+ <LazyMarkdownContent
+ text={part.text}
+ displayMode={isDefined(isUserMessage) ? displayMode : 'default'}
+ />
+ );
case 'data-compaction':
return <AiChatCompactionIndicator />;
case 'data-code-execution':
@@ -112,12 +121,14 @@ const MessagePartRenderer = ({
export const AiChatAssistantMessageRenderer = ({
messageParts,
isLastMessageStreaming,
+ isUserMessage,
hasError,
shouldHideThinkingSteps = false,
workDurationMs,
}: {
messageParts: ExtendedUIMessagePart[];
isLastMessageStreaming: boolean;
+ isUserMessage?: boolean;
hasError?: boolean;
shouldHideThinkingSteps?: boolean;
workDurationMs?: number | null;
@@ -211,6 +222,7 @@ export const AiChatAssistantMessageRenderer = ({
part={renderItem.part}
frontComponentIdByToolName={frontComponentIdByToolName}
isStreaming={isLastMessageStreaming}
+ isUserMessage={isUserMessage}
/>
),
)}
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatComposerQuotePreview.tsx b/packages/twenty-front/src/modules/ai/components/AiChatComposerQuotePreview.tsx
new file mode 100644
index 00000000000..6b3e91f0f2c
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/AiChatComposerQuotePreview.tsx
@@ -0,0 +1,43 @@
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { LightIconButton } from 'twenty-ui/components/input';
+import { IconX } from 'twenty-ui/icon';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { AiChatQuotedMessagePreview } from '@/ai/components/AiChatQuotedMessagePreview';
+import { type AiChatQuotedMessageSource } from '@/ai/types/AiChatQuotedMessageSource';
+
+const StyledPreview = styled.div`
+ align-items: flex-start;
+ background: ${themeCssVariables.background.transparent.lighter};
+ border-bottom: 1px solid ${themeCssVariables.border.color.light};
+ display: flex;
+ gap: ${themeCssVariables.spacing[2]};
+ padding: ${themeCssVariables.spacing[2]};
+`;
+
+type AiChatComposerQuotePreviewProps = {
+ source: AiChatQuotedMessageSource;
+ onRemove: () => void;
+ onNavigateToMessage?: (messageId: string) => void;
+};
+
+export const AiChatComposerQuotePreview = ({
+ source,
+ onRemove,
+ onNavigateToMessage,
+}: AiChatComposerQuotePreviewProps) => {
+ const { t } = useLingui();
+
+ return (
+ <StyledPreview>
+ <AiChatQuotedMessagePreview
+ source={source}
+ onNavigateToMessage={onNavigateToMessage}
+ />
+ <LightIconButton aria-label={t`Remove quote`} onClick={onRemove}>
+ <IconX />
+ </LightIconButton>
+ </StyledPreview>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatFormCard.tsx b/packages/twenty-front/src/modules/ai/components/AiChatFormCard.tsx
index 2ab2e7dced7..81b8f98b7d5 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatFormCard.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatFormCard.tsx
@@ -1,31 +1,12 @@
-import { styled } from '@linaria/react';
-import { useLingui } from '@lingui/react/macro';
import { useState } from 'react';
import {
type RequestFormField,
type RequestFormToolResult,
} from 'twenty-shared/ai';
import { isDefined } from 'twenty-shared/utils';
-import { Button } from 'twenty-ui/primitives/input';
-import { themeCssVariables } from 'twenty-ui/theme';
-import { StyledAiChatAskCard } from '@/ai/components/AiChatAskStyledComponents';
+import { AiChatFormCardContent } from '@/ai/components/AiChatFormCardContent';
import { useAnswerAgentChatToolCall } from '@/ai/hooks/useAnswerAgentChatToolCall';
-import { WorkflowFormFields } from '@/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowFormFields';
-
-const StyledFields = styled.div`
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[3]};
- padding: ${themeCssVariables.spacing[3]};
-`;
-
-const StyledActions = styled.div`
- border-top: 1px solid ${themeCssVariables.border.color.light};
- display: flex;
- justify-content: flex-end;
- padding: ${themeCssVariables.spacing[2]};
-`;
type AiChatFormCardProps = {
toolCallId: string;
@@ -33,13 +14,16 @@ type AiChatFormCardProps = {
};
export const AiChatFormCard = ({ toolCallId, fields }: AiChatFormCardProps) => {
- const { t } = useLingui();
const { answerAgentChatToolCall } = useAnswerAgentChatToolCall();
const [values, setValues] = useState<Record<string, unknown>>({});
const [error, setError] = useState<string | undefined>(undefined);
const [isSubmitting, setIsSubmitting] = useState(false);
const submit = async () => {
+ if (isSubmitting) {
+ return;
+ }
+
setIsSubmitting(true);
const isAnswered = await answerAgentChatToolCall({
@@ -51,39 +35,24 @@ export const AiChatFormCard = ({ toolCallId, fields }: AiChatFormCardProps) => {
},
});
- // The card goes once its call is closed, so it stays disabled until then.
if (!isAnswered) {
setIsSubmitting(false);
}
};
return (
- <StyledAiChatAskCard>
- <StyledFields>
- <WorkflowFormFields
- fields={fields}
- readonly={isSubmitting}
- onChange={(fieldName, value) =>
- setValues((previousValues) => ({
- ...previousValues,
- [fieldName]: value,
- }))
- }
- onError={setError}
- />
- </StyledFields>
- <StyledActions>
- <Button
- size="sm"
- variant="solid"
- color="accent"
- disabled={isSubmitting || isDefined(error)}
- loading={isSubmitting}
- onClick={() => void submit()}
- >
- {t`Submit`}
- </Button>
- </StyledActions>
- </StyledAiChatAskCard>
+ <AiChatFormCardContent
+ fields={fields}
+ isSubmitting={isSubmitting}
+ isSubmitDisabled={isDefined(error)}
+ onFieldChange={({ fieldName, value }) =>
+ setValues((previousValues) => ({
+ ...previousValues,
+ [fieldName]: value,
+ }))
+ }
+ onError={setError}
+ onSubmit={() => void submit()}
+ />
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatFormCardContent.tsx b/packages/twenty-front/src/modules/ai/components/AiChatFormCardContent.tsx
new file mode 100644
index 00000000000..d9b3601b6c9
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/AiChatFormCardContent.tsx
@@ -0,0 +1,137 @@
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { isNonEmptyString, isObject } from '@sniptt/guards';
+import { type RequestFormField } from 'twenty-shared/ai';
+import { isDefined } from 'twenty-shared/utils';
+import { IconForms } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { StyledAiChatAskCard } from '@/ai/components/StyledAiChatAskCard';
+import { isFieldValueEmpty } from '@/object-record/record-field/ui/utils/isFieldValueEmpty';
+import { WorkflowFormFields } from '@/workflow/workflow-steps/workflow-actions/form-action/components/WorkflowFormFields';
+
+const AI_CHAT_FORM_FIELD_MIN_WIDTH_PX = 240;
+
+const StyledHeader = styled.div`
+ align-items: center;
+ color: ${themeCssVariables.font.color.primary};
+ display: flex;
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ gap: ${themeCssVariables.spacing[2]};
+ min-height: ${themeCssVariables.spacing[6]};
+ padding-left: ${themeCssVariables.spacing[1]};
+`;
+
+const StyledFields = styled.div`
+ display: grid;
+ gap: ${themeCssVariables.spacing[3]} ${themeCssVariables.spacing[4]};
+ grid-template-columns: repeat(
+ auto-fit,
+ minmax(min(100%, ${AI_CHAT_FORM_FIELD_MIN_WIDTH_PX}px), 1fr)
+ );
+ padding: 0 ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[1]};
+
+ > :last-child:nth-child(odd) {
+ grid-column: 1 / -1;
+ }
+`;
+
+const StyledActions = styled.div`
+ align-items: center;
+ display: flex;
+ flex-wrap: wrap;
+ gap: ${themeCssVariables.spacing[2]};
+ justify-content: flex-end;
+ padding-left: ${themeCssVariables.spacing[1]};
+`;
+
+const StyledPrefillFeedback = styled.span`
+ color: ${themeCssVariables.font.color.light};
+ flex: 1;
+ font-size: ${themeCssVariables.font.size.sm};
+ min-width: 0;
+`;
+
+type AiChatFormCardContentProps = {
+ fields: RequestFormField[];
+ defaultValues?: Record<string, unknown>;
+ title?: string;
+ isSubmitting?: boolean;
+ isSubmitDisabled?: boolean;
+ onFieldChange: (fieldChange: { fieldName: string; value: unknown }) => void;
+ onError: (error: string | undefined) => void;
+ onSubmit: () => void;
+ onSkip?: () => void;
+};
+
+export const AiChatFormCardContent = ({
+ fields,
+ defaultValues,
+ title,
+ isSubmitting = false,
+ isSubmitDisabled = false,
+ onFieldChange,
+ onError,
+ onSubmit,
+ onSkip,
+}: AiChatFormCardContentProps) => {
+ const { t } = useLingui();
+ const prefilledCount = fields.filter(({ name, type }) => {
+ const value = defaultValues?.[name];
+
+ if (type === 'RECORD') {
+ return isObject(value) && 'id' in value && isNonEmptyString(value.id);
+ }
+
+ return !isFieldValueEmpty({ fieldDefinition: { type }, fieldValue: value });
+ }).length;
+ const fieldCount = fields.length;
+
+ return (
+ <StyledAiChatAskCard isPadded>
+ <StyledHeader>
+ <IconForms size={16} />
+ {title ?? t`Form`}
+ </StyledHeader>
+ <StyledFields>
+ <WorkflowFormFields
+ fields={
+ isDefined(defaultValues)
+ ? fields.map((field) => ({
+ ...field,
+ value: defaultValues[field.name],
+ }))
+ : fields
+ }
+ readonly={isSubmitting}
+ onChange={(fieldName, value) => onFieldChange({ fieldName, value })}
+ onError={onError}
+ />
+ </StyledFields>
+ <StyledActions>
+ {prefilledCount > 0 && (
+ <StyledPrefillFeedback>
+ {t`${prefilledCount} of ${fieldCount} fields prefilled`}
+ </StyledPrefillFeedback>
+ )}
+ {isDefined(onSkip) && (
+ <Button size="sm" disabled={isSubmitting} onClick={onSkip}>
+ {t`Skip`}
+ </Button>
+ )}
+ <Button
+ size="sm"
+ variant="solid"
+ color="accent"
+ disabled={isSubmitting || isSubmitDisabled}
+ loading={isSubmitting}
+ onClick={onSubmit}
+ >
+ {t`Submit`}
+ </Button>
+ </StyledActions>
+ </StyledAiChatAskCard>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatFormStatusRenderer.tsx b/packages/twenty-front/src/modules/ai/components/AiChatFormStatusRenderer.tsx
index 3099879ca0c..4f284c9492d 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatFormStatusRenderer.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatFormStatusRenderer.tsx
@@ -9,7 +9,7 @@ import { isDefined } from 'twenty-shared/utils';
import { IconListDetails } from 'twenty-ui/icon';
import { AiChatAskStatusRow } from '@/ai/components/AiChatAskStatusRow';
-import { StyledAiChatAskStatusDetail } from '@/ai/components/AiChatAskStyledComponents';
+import { StyledAiChatAskStatusDetail } from '@/ai/components/StyledAiChatAskStatusDetail';
export const AiChatFormStatusRenderer = ({
toolPart,
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatMessage.tsx b/packages/twenty-front/src/modules/ai/components/AiChatMessage.tsx
index 8d4171fc85a..46680807c29 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatMessage.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatMessage.tsx
@@ -13,11 +13,11 @@ import { AiChatAssistantMessageRenderer } from '@/ai/components/AiChatAssistantM
import { AiChatMessageHeader } from '@/ai/components/AiChatMessageHeader';
import { AiChatMessageReactionPicker } from '@/ai/components/AiChatMessageReactionPicker';
import { AiChatMessageReactions } from '@/ai/components/AiChatMessageReactions';
-import { AGENT_CHAT_ASSISTANT_NAME } from '@/ai/constants/AgentChatAssistantName';
import { AiChatErrorRenderer } from '@/ai/components/AiChatErrorRenderer';
import { agentChatFirstUnreadMessageIdSelector } from '@/ai/states/selectors/agentChatFirstUnreadMessageIdSelector';
import { agentChatIsMessageBeforeFirstUserMessageFamilySelector } from '@/ai/states/selectors/agentChatIsMessageBeforeFirstUserMessageFamilySelector';
import { agentChatMessageFamilySelector } from '@/ai/states/selectors/agentChatMessageFamilySelector';
+import { isAgentChatMessageOwn } from '@/ai/utils/isAgentChatMessageOwn';
import { getAgentChatSenderLabel } from '@/ai/utils/getAgentChatSenderLabel';
import { isSilentAgentChatMessage } from '@/ai/utils/isSilentAgentChatMessage';
import { getAgentChatMessageWorkDurationMs } from '@/ai/utils/getAgentChatMessageWorkDurationMs';
@@ -26,7 +26,7 @@ import { LightCopyIconButton } from '@/ui/input/components/LightCopyIconButton';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { isExtendedFileUIPart } from 'twenty-shared/ai';
-import { isDefined } from 'twenty-shared/utils';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
import { Avatar } from 'twenty-ui/primitives/data-display';
import { themeCssVariables } from 'twenty-ui/theme';
import { LabeledDivider } from '@/ui/layout/line/components/LabeledDivider';
@@ -45,20 +45,37 @@ const StyledMessageBubble = styled.div<{ isRightAligned: boolean }>`
position: relative;
width: 100%;
- &:hover .message-footer {
+ &:hover .message-actions,
+ &:focus-within .message-actions {
opacity: 1;
pointer-events: auto;
}
`;
-const StyledMessageText = styled.div<{ isUser?: boolean }>`
- background: ${({ isUser }) =>
- isUser ? themeCssVariables.background.tertiary : 'transparent'};
+const StyledMessageText = styled.div<{
+ isUser?: boolean;
+ isOtherMember?: boolean;
+}>`
+ background: ${({ isUser, isOtherMember }) => {
+ if (isOtherMember) {
+ return themeCssVariables.background.secondary;
+ }
+
+ if (isUser) {
+ return themeCssVariables.background.tertiary;
+ }
+
+ return 'transparent';
+ }};
+ border: ${({ isOtherMember }) =>
+ isOtherMember
+ ? `1px solid ${themeCssVariables.border.color.medium}`
+ : 'none'};
border-radius: ${({ isUser }) =>
isUser ? themeCssVariables.border.radius.lg : '0'};
color: ${themeCssVariables.font.color.primary};
font-weight: ${({ isUser }) => (isUser ? 500 : 400)};
- line-height: 1.4em;
+ line-height: ${themeCssVariables.spacing[6]};
max-width: 100%;
overflow-wrap: break-word;
padding: ${({ isUser }) =>
@@ -94,7 +111,7 @@ const StyledMessageText = styled.div<{ isUser?: boolean }>`
}
p {
- line-height: 1.4em;
+ line-height: inherit;
margin-block: ${({ isUser }) =>
isUser ? '0' : themeCssVariables.spacing[1]};
}
@@ -107,20 +124,39 @@ const StyledMessageText = styled.div<{ isUser?: boolean }>`
}
`;
-const StyledMessageFooter = styled.div<{ isSpreadOut: boolean }>`
+const StyledMessageFooter = styled.div<{
+ isSpreadOut: boolean;
+ isRightAligned: boolean;
+}>`
align-items: center;
color: ${themeCssVariables.font.color.secondary};
display: flex;
+ flex-direction: ${({ isRightAligned }) =>
+ isRightAligned ? 'row-reverse' : 'row'};
+ flex-wrap: wrap;
font-size: ${themeCssVariables.font.size.sm};
gap: ${themeCssVariables.spacing[1]};
justify-content: ${({ isSpreadOut }) =>
isSpreadOut ? 'space-between' : 'flex-start'};
- margin-top: ${themeCssVariables.spacing[1]};
+ margin-top: ${themeCssVariables.spacing[2]};
+ width: 100%;
+`;
+
+const StyledMessageActions = styled.div<{ isRightAligned: boolean }>`
+ align-items: center;
+ display: flex;
+ flex-direction: ${({ isRightAligned }) =>
+ isRightAligned ? 'row-reverse' : 'row'};
+ gap: ${themeCssVariables.spacing[1]};
opacity: 0;
pointer-events: none;
transition: opacity calc(${themeCssVariables.animation.duration.normal} * 1s)
ease-in-out;
- width: 100%;
+
+ @media (hover: none) {
+ opacity: 1;
+ pointer-events: auto;
+ }
`;
const StyledSender = styled.div`
@@ -150,16 +186,22 @@ const StyledFilesContainer = styled.div`
type AiChatUserMessageTextProps = {
messageId: string;
children: ReactNode;
+ isOtherMember: boolean;
};
const AiChatUserMessageText = ({
messageId,
children,
+ isOtherMember,
}: AiChatUserMessageTextProps) => {
const sentMessageHandOffRef = useAiChatSentMessageHandOff(messageId);
return (
- <StyledMessageText isUser ref={sentMessageHandOffRef}>
+ <StyledMessageText
+ isUser
+ isOtherMember={isOtherMember}
+ ref={sentMessageHandOffRef}
+ >
{children}
</StyledMessageText>
);
@@ -210,19 +252,29 @@ export const AiChatMessage = ({
const sender = currentWorkspaceMembers.find(
(member) => isDefined(senderId) && member.id === senderId,
);
- const senderLabel = getAgentChatSenderLabel({
- sender,
- isCurrentWorkspaceMember: senderId === currentWorkspaceMember?.id,
+ const isOwnMessage = isAgentChatMessageOwn({
+ message: agentChatMessage,
+ currentWorkspaceMemberId: currentWorkspaceMember?.id,
+ isSenderlessUserMessageOwn: !isAiChatInboxEnabled,
});
+ const senderLabel = isDefined(senderId)
+ ? getAgentChatSenderLabel({
+ sender,
+ isCurrentWorkspaceMember: isOwnMessage,
+ })
+ : t`Unknown sender`;
const isUser = agentChatMessage.role === AGENT_MESSAGE_ROLE.USER;
+ const isRightAligned = isAiChatInboxEnabled ? isOwnMessage : isUser;
+ const shouldMirrorMessageActions = isAiChatInboxEnabled && isOwnMessage;
const createdAt = agentChatMessage.metadata?.createdAt ?? new Date();
- const hasHeader = isAiChatInboxEnabled && (!isUser || isDefined(senderId));
+ const hasHeader = isAiChatInboxEnabled && !isOwnMessage;
const shouldShowError =
isDefined(error) && agentChatMessage.role === AGENT_MESSAGE_ROLE.ASSISTANT;
const fileParts = agentChatMessage.parts.filter(isExtendedFileUIPart);
const messageContent = (
<AiChatAssistantMessageRenderer
+ isUserMessage={isUser}
isLastMessageStreaming={isLastMessageStreaming}
messageParts={agentChatMessage.parts}
hasError={shouldShowError}
@@ -243,13 +295,13 @@ export const AiChatMessage = ({
noMargin
>{t`New`}</LabeledDivider>
)}
- <StyledMessageBubble isRightAligned={isUser && !isAiChatInboxEnabled}>
- {isAiChatInboxEnabled && isUser && isDefined(senderId) && (
+ <StyledMessageBubble isRightAligned={isRightAligned}>
+ {hasHeader && (isUser || isDefined(senderId)) && (
<AiChatMessageHeader
avatar={
<Avatar
src={getAbsoluteImageUrl(sender?.avatarUrl)}
- colorSeed={senderId}
+ colorSeed={senderId ?? messageId}
name={senderLabel}
size="sm"
shape="circle"
@@ -259,10 +311,10 @@ export const AiChatMessage = ({
createdAt={createdAt}
/>
)}
- {isAiChatInboxEnabled && !isUser && (
+ {hasHeader && !isUser && !isDefined(senderId) && (
<AiChatMessageHeader
avatar={<AiChatAssistantAvatar />}
- name={AGENT_CHAT_ASSISTANT_NAME}
+ name={t`Assistant`}
createdAt={createdAt}
/>
)}
@@ -271,13 +323,16 @@ export const AiChatMessage = ({
)}
<StyledMessageContainer isUser={isUser}>
{isUser ? (
- <AiChatUserMessageText messageId={messageId}>
+ <AiChatUserMessageText
+ messageId={messageId}
+ isOtherMember={isAiChatInboxEnabled && !isOwnMessage}
+ >
{messageContent}
</AiChatUserMessageText>
) : (
<StyledMessageText>{messageContent}</StyledMessageText>
)}
- {fileParts.length > 0 && (
+ {isNonEmptyArray(fileParts) && (
<StyledFilesContainer>
{fileParts.map((file) => (
<AgentChatFilePreview key={file.filename} file={file} />
@@ -285,29 +340,34 @@ export const AiChatMessage = ({
</StyledFilesContainer>
)}
{shouldShowError && <AiChatErrorRenderer error={error} />}
- {isAiChatInboxEnabled && (
- <AiChatMessageReactions messageId={messageId} />
- )}
</StyledMessageContainer>
- {agentChatMessage.parts.length > 0 && (
+ {isNonEmptyArray(agentChatMessage.parts) && (
<StyledMessageFooter
- className="message-footer"
isSpreadOut={!isAiChatInboxEnabled}
+ isRightAligned={shouldMirrorMessageActions}
>
+ {isAiChatInboxEnabled && (
+ <AiChatMessageReactions messageId={messageId} />
+ )}
{!hasHeader && (
<StyledMessageTimestamp>
{beautifyPastDateRelativeToNow(createdAt, localeCatalog)}
</StyledMessageTimestamp>
)}
- <LightCopyIconButton
- copyText={
- agentChatMessage.parts.find((part) => part.type === 'text')
- ?.text ?? ''
- }
- />
- {isAiChatInboxEnabled && !isLastMessageStreaming && (
- <AiChatMessageReactionPicker messageId={messageId} />
- )}
+ <StyledMessageActions
+ className="message-actions"
+ isRightAligned={shouldMirrorMessageActions}
+ >
+ {isAiChatInboxEnabled && !isLastMessageStreaming && (
+ <AiChatMessageReactionPicker messageId={messageId} />
+ )}
+ <LightCopyIconButton
+ copyText={
+ agentChatMessage.parts.find((part) => part.type === 'text')
+ ?.text ?? ''
+ }
+ />
+ </StyledMessageActions>
</StyledMessageFooter>
)}
</StyledMessageBubble>
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatMessageHeader.tsx b/packages/twenty-front/src/modules/ai/components/AiChatMessageHeader.tsx
index 8d92c3ad596..9b4287a44c3 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatMessageHeader.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatMessageHeader.tsx
@@ -1,5 +1,6 @@
import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
+import { Text } from 'twenty-ui/primitives/typography';
import { themeCssVariables } from 'twenty-ui/theme';
import { dateLocaleState } from '@/localization/states/dateLocaleState';
@@ -11,23 +12,12 @@ const StyledHeader = styled.div`
display: flex;
gap: ${themeCssVariables.spacing[1]};
height: ${themeCssVariables.spacing[4]};
- margin-bottom: ${themeCssVariables.spacing[2]};
+ margin-bottom: ${themeCssVariables.spacing[3]};
min-width: 0;
`;
-const StyledName = styled.span`
- color: ${themeCssVariables.font.color.primary};
- font-size: ${themeCssVariables.font.size.sm};
- font-weight: ${themeCssVariables.font.weight.medium};
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-`;
-
const StyledTime = styled.span`
- color: ${themeCssVariables.font.color.light};
flex-shrink: 0;
- font-size: ${themeCssVariables.font.size.sm};
`;
type AiChatMessageHeaderProps = {
@@ -46,10 +36,18 @@ export const AiChatMessageHeader = ({
return (
<StyledHeader>
{avatar}
- <StyledName>{name}</StyledName>
- <StyledTime>
+ <Text
+ render={<span />}
+ size="sm"
+ color="primary"
+ weight="medium"
+ truncate
+ >
+ {name}
+ </Text>
+ <Text render={<StyledTime />} size="sm" color="light">
{beautifyPastDateRelativeToNow(createdAt, localeCatalog)}
- </StyledTime>
+ </Text>
</StyledHeader>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPicker.tsx b/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPicker.tsx
index 29d0fb2ab8a..a4574b0dc06 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPicker.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPicker.tsx
@@ -1,100 +1,17 @@
-import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
-import { EmojiPicker } from 'frimousse';
-import { useId } from 'react';
+import { useId, useState } from 'react';
import { LightIconButton } from 'twenty-ui/components/input';
import { Dropdown } from 'twenty-ui/components/navigation';
import { IconMoodSmile } from 'twenty-ui/icon';
-import { themeCssVariables } from 'twenty-ui/theme';
-import { AGENT_CHAT_EMOJIBASE_URL } from '@/ai/constants/AgentChatEmojibaseUrl';
-import { AGENT_CHAT_QUICK_REACTION_EMOJIS } from '@/ai/constants/AgentChatQuickReactionEmojis';
+import { AiChatMessageReactionPickerContent } from '@/ai/components/AiChatMessageReactionPickerContent';
import { useToggleAgentChatMessageReaction } from '@/ai/hooks/useToggleAgentChatMessageReaction';
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
const AI_CHAT_MESSAGE_REACTION_PICKER_WIDTH_PX = 296;
-
-const StyledQuickReactions = styled.div`
- border-bottom: 1px solid ${themeCssVariables.border.color.light};
- display: flex;
- justify-content: space-between;
- padding: ${themeCssVariables.spacing[1]};
-`;
-
-const StyledEmojiButton = styled.button`
- align-items: center;
- background: none;
- border: none;
- border-radius: ${themeCssVariables.border.radius.sm};
- cursor: pointer;
- display: flex;
- font-size: ${themeCssVariables.font.size.lg};
- height: ${themeCssVariables.spacing[8]};
- justify-content: center;
- width: ${themeCssVariables.spacing[8]};
-
- &:hover {
- background: ${themeCssVariables.background.transparent.light};
- }
-`;
-
-const StyledEmojiPicker = styled.div`
- [frimousse-root] {
- display: flex;
- flex-direction: column;
- height: 280px;
- }
-
- [frimousse-search] {
- background: ${themeCssVariables.background.transparent.lighter};
- border: 1px solid ${themeCssVariables.border.color.medium};
- border-radius: ${themeCssVariables.border.radius.sm};
- color: ${themeCssVariables.font.color.primary};
- font-family: inherit;
- font-size: ${themeCssVariables.font.size.md};
- margin: ${themeCssVariables.spacing[2]};
- padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
- }
-
- [frimousse-viewport] {
- flex: 1;
- outline: none;
- }
-
- [frimousse-category-header] {
- background: ${themeCssVariables.background.primary};
- color: ${themeCssVariables.font.color.tertiary};
- font-size: ${themeCssVariables.font.size.xs};
- padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
- }
-
- [frimousse-row] {
- padding: 0 ${themeCssVariables.spacing[1]};
- }
-
- [frimousse-emoji] {
- background: none;
- border: none;
- border-radius: ${themeCssVariables.border.radius.sm};
- cursor: pointer;
- font-size: ${themeCssVariables.font.size.lg};
- height: ${themeCssVariables.spacing[8]};
- width: ${themeCssVariables.spacing[8]};
-
- &[data-active] {
- background: ${themeCssVariables.background.transparent.light};
- }
- }
-`;
-
-const StyledPickerMessage = styled.div`
- color: ${themeCssVariables.font.color.tertiary};
- font-size: ${themeCssVariables.font.size.sm};
- padding: ${themeCssVariables.spacing[3]};
- text-align: center;
-`;
+const AI_CHAT_QUICK_REACTIONS_WIDTH_PX = 249;
type AiChatMessageReactionPickerProps = {
messageId: string;
@@ -105,6 +22,7 @@ export const AiChatMessageReactionPicker = ({
}: AiChatMessageReactionPickerProps) => {
const { t } = useLingui();
const instanceId = useId();
+ const [isEmojiPickerOpen, setIsEmojiPickerOpen] = useState(false);
const dropdownId = `ai-chat-message-reaction-picker-${instanceId}`;
const { closeDropdown } = useCloseDropdown();
const { toggleAgentChatMessageReaction } =
@@ -116,7 +34,11 @@ export const AiChatMessageReactionPicker = ({
};
return (
- <DropdownRoot dropdownId={dropdownId} type="panel">
+ <DropdownRoot
+ dropdownId={dropdownId}
+ type="panel"
+ onOpenChange={() => setIsEmojiPickerOpen(false)}
+ >
<Dropdown.Trigger
render={
<LightIconButton aria-label={t`Add reaction`}>
@@ -125,42 +47,21 @@ export const AiChatMessageReactionPicker = ({
}
/>
<DropdownContent
- width={AI_CHAT_MESSAGE_REACTION_PICKER_WIDTH_PX}
- side="top"
+ width={
+ isEmojiPickerOpen
+ ? AI_CHAT_MESSAGE_REACTION_PICKER_WIDTH_PX
+ : AI_CHAT_QUICK_REACTIONS_WIDTH_PX
+ }
+ side="bottom"
align="start"
sideOffset={4}
aria-label={t`Add reaction`}
>
- <StyledQuickReactions>
- {AGENT_CHAT_QUICK_REACTION_EMOJIS.map((emoji) => (
- <StyledEmojiButton
- key={emoji}
- type="button"
- aria-label={emoji}
- onClick={() => react(emoji)}
- >
- {emoji}
- </StyledEmojiButton>
- ))}
- </StyledQuickReactions>
- <StyledEmojiPicker>
- <EmojiPicker.Root
- emojibaseUrl={AGENT_CHAT_EMOJIBASE_URL}
- columns={8}
- onEmojiSelect={({ emoji }) => react(emoji)}
- >
- <EmojiPicker.Search placeholder={t`Search emojis`} />
- <EmojiPicker.Viewport>
- <EmojiPicker.Loading>
- <StyledPickerMessage>{t`Loading emojis`}</StyledPickerMessage>
- </EmojiPicker.Loading>
- <EmojiPicker.Empty>
- <StyledPickerMessage>{t`No emoji found`}</StyledPickerMessage>
- </EmojiPicker.Empty>
- <EmojiPicker.List />
- </EmojiPicker.Viewport>
- </EmojiPicker.Root>
- </StyledEmojiPicker>
+ <AiChatMessageReactionPickerContent
+ isEmojiPickerOpen={isEmojiPickerOpen}
+ onEmojiSelect={react}
+ onShowMore={() => setIsEmojiPickerOpen(true)}
+ />
</DropdownContent>
</DropdownRoot>
);
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPickerContent.tsx b/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPickerContent.tsx
new file mode 100644
index 00000000000..2386d6a8b76
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/AiChatMessageReactionPickerContent.tsx
@@ -0,0 +1,77 @@
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { EmojiPicker, LightIconButton } from 'twenty-ui/components/input';
+import { IconMoodPlus } from 'twenty-ui/icon';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { AGENT_CHAT_EMOJIBASE_URL } from '@/ai/constants/AgentChatEmojibaseUrl';
+import { AGENT_CHAT_QUICK_REACTION_EMOJIS } from '@/ai/constants/AgentChatQuickReactionEmojis';
+
+const StyledQuickReactions = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[0.5]};
+ padding: ${themeCssVariables.spacing[1]};
+`;
+
+const StyledEmoji = styled.span`
+ font-size: ${themeCssVariables.font.size.lg};
+`;
+
+const StyledDivider = styled.div`
+ background: ${themeCssVariables.border.color.medium};
+ flex-shrink: 0;
+ height: ${themeCssVariables.spacing[4]};
+ width: 1px;
+`;
+
+type AiChatMessageReactionPickerContentProps = {
+ isEmojiPickerOpen: boolean;
+ onEmojiSelect: (emoji: string) => void;
+ onShowMore: () => void;
+};
+
+export const AiChatMessageReactionPickerContent = ({
+ isEmojiPickerOpen,
+ onEmojiSelect,
+ onShowMore,
+}: AiChatMessageReactionPickerContentProps) => {
+ const { t } = useLingui();
+
+ if (isEmojiPickerOpen) {
+ return (
+ <EmojiPicker
+ emojibaseUrl={AGENT_CHAT_EMOJIBASE_URL}
+ searchLabel={t`Search emojis`}
+ loadingLabel={t`Loading emojis`}
+ emptyLabel={t`No emoji found`}
+ autoFocus
+ onEmojiSelect={onEmojiSelect}
+ />
+ );
+ }
+
+ return (
+ <StyledQuickReactions>
+ {AGENT_CHAT_QUICK_REACTION_EMOJIS.map((emoji) => (
+ <LightIconButton
+ key={emoji}
+ size="md"
+ aria-label={emoji}
+ onClick={() => onEmojiSelect(emoji)}
+ >
+ <StyledEmoji aria-hidden>{emoji}</StyledEmoji>
+ </LightIconButton>
+ ))}
+ <StyledDivider />
+ <LightIconButton
+ size="md"
+ aria-label={t`More reactions`}
+ tooltip={t`More reactions`}
+ onClick={onShowMore}
+ >
+ <IconMoodPlus />
+ </LightIconButton>
+ </StyledQuickReactions>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatMessageReactions.tsx b/packages/twenty-front/src/modules/ai/components/AiChatMessageReactions.tsx
index c544649f62f..0162dd38d53 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatMessageReactions.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatMessageReactions.tsx
@@ -2,6 +2,7 @@ import { styled } from '@linaria/react';
import { plural } from '@lingui/core/macro';
import { useLingui } from '@lingui/react/macro';
import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
+import { ReactionButton } from 'twenty-ui/components/input';
import { themeCssVariables } from 'twenty-ui/theme';
import { AGENT_CHAT_ASSISTANT_NAME } from '@/ai/constants/AgentChatAssistantName';
@@ -17,33 +18,6 @@ const StyledReactions = styled.div`
display: flex;
flex-wrap: wrap;
gap: ${themeCssVariables.spacing[1]};
- margin-top: ${themeCssVariables.spacing[2]};
-`;
-
-const StyledReaction = styled.button<{ isSelected: boolean }>`
- align-items: center;
- background: ${({ isSelected }) =>
- isSelected
- ? themeCssVariables.accent.tertiary
- : themeCssVariables.background.transparent.lighter};
- border: 1px solid
- ${({ isSelected }) =>
- isSelected
- ? themeCssVariables.border.color.blue
- : themeCssVariables.border.color.medium};
- border-radius: ${themeCssVariables.border.radius.pill};
- color: ${themeCssVariables.font.color.secondary};
- cursor: pointer;
- display: flex;
- font-family: inherit;
- font-size: ${themeCssVariables.font.size.sm};
- gap: ${themeCssVariables.spacing[1]};
- height: ${themeCssVariables.spacing[6]};
- padding: 0 ${themeCssVariables.spacing[2]};
-
- &:hover {
- background: ${themeCssVariables.background.transparent.light};
- }
`;
type AiChatMessageReactionsProps = {
@@ -65,7 +39,7 @@ export const AiChatMessageReactions = ({
const { toggleAgentChatMessageReaction } =
useToggleAgentChatMessageReaction();
- if (agentChatMessageReactions.length === 0) {
+ if (!isNonEmptyArray(agentChatMessageReactions)) {
return null;
}
@@ -103,20 +77,17 @@ export const AiChatMessageReactions = ({
(hasAssistantReacted ? 1 : 0);
return (
- <StyledReaction
+ <ReactionButton
key={emoji}
- type="button"
- isSelected={isSelected}
- aria-pressed={isSelected}
+ emoji={emoji}
+ count={reactionCount}
+ pressed={isSelected}
title={reactorNames}
aria-label={t`${emoji} by ${reactorNames}`}
- onClick={() =>
- toggleAgentChatMessageReaction({ messageId, emoji })
+ onPressedChange={() =>
+ void toggleAgentChatMessageReaction({ messageId, emoji })
}
- >
- <span aria-hidden>{emoji}</span>
- <span aria-hidden>{reactionCount}</span>
- </StyledReaction>
+ />
);
},
)}
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatPendingAskGate.tsx b/packages/twenty-front/src/modules/ai/components/AiChatPendingAskGate.tsx
index 2a5946915e8..8d0d59a4a46 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatPendingAskGate.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatPendingAskGate.tsx
@@ -1,8 +1,7 @@
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { type ReactNode, useState } from 'react';
-import { LightIconButton } from 'twenty-ui/components/input';
-import { IconChevronLeft, IconChevronRight } from 'twenty-ui/icon';
+import { CountPager } from 'twenty-ui/components/navigation';
import { themeCssVariables } from 'twenty-ui/theme';
import { AiChatAskCard } from '@/ai/components/AiChatAskCard';
@@ -18,18 +17,9 @@ const StyledGate = styled.div`
`;
const StyledStepper = styled.div`
- align-items: center;
- display: flex;
- gap: ${themeCssVariables.spacing[1]};
padding: 0 ${themeCssVariables.spacing[1]};
`;
-const StyledStepperLabel = styled.span`
- color: ${themeCssVariables.font.color.light};
- flex: 1;
- font-size: ${themeCssVariables.font.size.sm};
-`;
-
type AiChatPendingAskGateProps = {
children: ReactNode;
};
@@ -96,25 +86,16 @@ export const AiChatPendingAskGate = ({
<StyledGate>
{requestCount > 1 && (
<StyledStepper>
- <StyledStepperLabel>
- {t`Request ${requestNumber} of ${requestCount}`}
- </StyledStepperLabel>
- <LightIconButton
- size="sm"
- disabled={currentIndex === 0}
- onClick={() => selectRequest(currentIndex - 1)}
- aria-label={t`Previous request`}
- >
- <IconChevronLeft />
- </LightIconButton>
- <LightIconButton
- size="sm"
- disabled={currentIndex === requestCount - 1}
- onClick={() => selectRequest(currentIndex + 1)}
- aria-label={t`Next request`}
- >
- <IconChevronRight />
- </LightIconButton>
+ <CountPager
+ aria-label={t`Pending requests`}
+ index={currentIndex}
+ count={requestCount}
+ onIndexChange={selectRequest}
+ positionText={t`Request ${requestNumber} of ${requestCount}`}
+ positionPlacement="start"
+ previousLabel={t`Previous request`}
+ nextLabel={t`Next request`}
+ />
</StyledStepper>
)}
{pendingToolCalls.map((pendingToolCall, index) => (
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx
index f1b5e138b5d..e5effc52b62 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatQuestionCard.tsx
@@ -9,10 +9,9 @@ import {
} from 'twenty-shared/ai';
import { isDefined } from 'twenty-shared/utils';
import { IconButton, LightIconButton } from 'twenty-ui/components/input';
+import { CountPager } from 'twenty-ui/components/navigation';
import {
IconArrowUp,
- IconChevronLeft,
- IconChevronRightPipe,
type IconComponent,
IconInfoCircle,
IconSquareNumber1,
@@ -25,10 +24,11 @@ import {
IconSquareNumber8,
IconSquareNumber9,
} from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
-import { StyledAiChatAskCard } from '@/ai/components/AiChatAskStyledComponents';
+import { StyledAiChatAskCard } from '@/ai/components/StyledAiChatAskCard';
import { TextWithChatReferences } from '@/ai/components/TextWithChatReferences';
import { AiChatComposerActionsRow } from '@/ai/components/internal/AiChatComposerActionsRow';
import { AiChatQuestionOtherOption } from '@/ai/components/internal/AiChatQuestionOtherOption';
@@ -78,18 +78,6 @@ const StyledQuestionText = styled.p`
overflow-wrap: anywhere;
`;
-const StyledPager = styled.div`
- align-items: center;
- display: flex;
- flex-shrink: 0;
- gap: ${themeCssVariables.spacing[1]};
-`;
-
-const StyledPagerLabel = styled.span`
- color: ${themeCssVariables.font.color.light};
- font-size: ${themeCssVariables.font.size.sm};
-`;
-
const StyledOptionsList = styled.div`
display: flex;
flex-direction: column;
@@ -177,10 +165,12 @@ const areAllQuestionsAnswered = (
type AiChatQuestionCardProps = {
pendingQuestion: AgentChatPendingQuestion;
+ onSkip?: () => void;
};
export const AiChatQuestionCard = ({
pendingQuestion,
+ onSkip,
}: AiChatQuestionCardProps) => {
const { t } = useLingui();
const theme = useTheme();
@@ -388,33 +378,15 @@ export const AiChatQuestionCard = ({
<TextWithChatReferences text={currentQuestion.question} />
</StyledQuestionText>
{hasMultipleQuestions && (
- <StyledPager>
- <LightIconButton
- size="sm"
- disabled={currentIndex === 0}
- onClick={() =>
- setCurrentIndex((index) => Math.max(0, index - 1))
- }
- aria-label={t`Previous`}
- >
- <IconChevronLeft />
- </LightIconButton>
- <StyledPagerLabel>
- {currentIndex + 1}/{questions.length}
- </StyledPagerLabel>
- <LightIconButton
- size="sm"
- disabled={isLastQuestion}
- onClick={() =>
- setCurrentIndex((index) =>
- Math.min(questions.length - 1, index + 1),
- )
- }
- aria-label={t`Next question`}
- >
- <IconChevronRightPipe />
- </LightIconButton>
- </StyledPager>
+ <CountPager
+ aria-label={t`Questions`}
+ index={currentIndex}
+ count={questions.length}
+ onIndexChange={setCurrentIndex}
+ positionText={`${currentIndex + 1}/${questions.length}`}
+ previousLabel={t`Previous`}
+ nextLabel={t`Next question`}
+ />
)}
</StyledQuestionHeaderRow>
@@ -495,6 +467,13 @@ export const AiChatQuestionCard = ({
<StyledComposerSection>
<AiChatComposerActionsRow
+ leftActions={
+ isDefined(onSkip) ? (
+ <Button size="sm" disabled={isSubmitting} onClick={onSkip}>
+ {t`Skip`}
+ </Button>
+ ) : undefined
+ }
modelTierDropdownId={`ai-chat-question-model-tier-dropdown-${toolCallId}`}
sendButton={
<IconButton
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQuestionStatusRenderer.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQuestionStatusRenderer.tsx
index 98c50ffa57d..5fe45185939 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatQuestionStatusRenderer.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatQuestionStatusRenderer.tsx
@@ -13,10 +13,8 @@ import { AiChatAskStatusRow } from '@/ai/components/AiChatAskStatusRow';
import { TextWithChatReferences } from '@/ai/components/TextWithChatReferences';
import { getAskedQuestionEntries } from '@/ai/utils/getAskedQuestionEntries';
import { getChatReferenceSegments } from '@/ai/utils/getChatReferenceSegments';
-import {
- StyledAiChatAskStatusDetail,
- StyledAiChatAskStatusMessage,
-} from '@/ai/components/AiChatAskStyledComponents';
+import { StyledAiChatAskStatusDetail } from '@/ai/components/StyledAiChatAskStatusDetail';
+import { StyledAiChatAskStatusMessage } from '@/ai/components/StyledAiChatAskStatusMessage';
const StyledAnswersCard = styled.div`
background-color: ${themeCssVariables.background.transparent.lighter};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessageList.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessageList.tsx
new file mode 100644
index 00000000000..5186e39219b
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessageList.tsx
@@ -0,0 +1,182 @@
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { useId, useState } from 'react';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
+import { Avatar } from 'twenty-ui/primitives/data-display';
+import { LightIconButton } from 'twenty-ui/components/input';
+import {
+ IconChevronDown,
+ IconChevronUp,
+ IconCornerDownRight,
+ IconTrash,
+} from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const COLLAPSED_QUEUED_MESSAGE_COUNT = 3;
+
+const StyledQueue = styled.div`
+ background: ${themeCssVariables.background.transparent.lighter};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-bottom: none;
+ border-radius: ${themeCssVariables.border.radius.md}
+ ${themeCssVariables.border.radius.md} 0 0;
+ display: flex;
+ flex-direction: column;
+ gap: ${themeCssVariables.spacing[1]};
+ margin-inline: ${themeCssVariables.spacing[2]};
+ padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[2]}
+ ${themeCssVariables.spacing[1]};
+`;
+
+const StyledHeader = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[1]};
+ min-height: ${themeCssVariables.spacing[6]};
+ padding-left: ${themeCssVariables.spacing[1]};
+`;
+
+const StyledTitleContainer = styled.span`
+ flex: 1;
+`;
+
+const StyledItems = styled.div`
+ display: flex;
+ flex-direction: column;
+ gap: ${themeCssVariables.spacing['0.5']};
+`;
+
+const StyledItem = styled.div`
+ align-items: center;
+ border-radius: ${themeCssVariables.border.radius.sm};
+ color: ${themeCssVariables.font.color.secondary};
+ display: flex;
+ gap: ${themeCssVariables.spacing[2]};
+ min-height: ${themeCssVariables.spacing[8]};
+ padding-inline: ${themeCssVariables.spacing[1]};
+
+ &:hover,
+ &:focus-within {
+ background: ${themeCssVariables.background.transparent.light};
+ }
+`;
+
+const StyledIcon = styled.div`
+ align-items: center;
+ color: ${themeCssVariables.font.color.tertiary};
+ display: flex;
+ flex-shrink: 0;
+`;
+
+const StyledTextContainer = styled.span`
+ flex: 1;
+ min-width: 0;
+`;
+
+const StyledMoreButtonContainer = styled.div`
+ display: flex;
+ justify-content: flex-start;
+`;
+
+type AiChatQueuedMessageListProps = {
+ messages: {
+ id: string;
+ text: string;
+ isRemovable: boolean;
+ sender?: { id: string; name: string; avatarUrl?: string };
+ }[];
+ onRemove?: (messageId: string) => void;
+};
+
+export const AiChatQueuedMessageList = ({
+ messages,
+ onRemove,
+}: AiChatQueuedMessageListProps) => {
+ const { t } = useLingui();
+ const [isExpanded, setIsExpanded] = useState(false);
+ const itemsId = useId();
+
+ if (!isNonEmptyArray(messages)) {
+ return null;
+ }
+
+ const remainingCount = messages.length - COLLAPSED_QUEUED_MESSAGE_COUNT;
+ const visibleMessages = isExpanded
+ ? messages
+ : messages.slice(0, COLLAPSED_QUEUED_MESSAGE_COUNT);
+
+ return (
+ <StyledQueue aria-label={t`Queued messages`}>
+ <StyledHeader>
+ <Text
+ render={<StyledTitleContainer />}
+ size="md"
+ weight="medium"
+ color="primary"
+ >
+ {t`Queued`}
+ </Text>
+ <Text render={<span />} size="sm" color="light">
+ {messages.length}
+ </Text>
+ </StyledHeader>
+ <StyledItems id={itemsId}>
+ {visibleMessages.map((message) => (
+ <StyledItem key={message.id}>
+ <StyledIcon>
+ {isDefined(message.sender) ? (
+ <Avatar
+ src={message.sender.avatarUrl}
+ colorSeed={message.sender.id}
+ name={message.sender.name}
+ size="sm"
+ shape="circle"
+ />
+ ) : (
+ <IconCornerDownRight size={16} />
+ )}
+ </StyledIcon>
+ <Text
+ render={<StyledTextContainer />}
+ size="md"
+ color="secondary"
+ truncate
+ title={message.text}
+ >
+ {isDefined(message.sender) && `${message.sender.name} Β· `}
+ {message.text}
+ </Text>
+ {message.isRemovable && isDefined(onRemove) && (
+ <LightIconButton
+ onClick={() => onRemove(message.id)}
+ size="sm"
+ aria-label={t`Remove queued message`}
+ >
+ <IconTrash />
+ </LightIconButton>
+ )}
+ </StyledItem>
+ ))}
+ </StyledItems>
+ {remainingCount > 0 && (
+ <StyledMoreButtonContainer>
+ <Button
+ size="md"
+ variant="ghost"
+ color="neutral"
+ startIcon={isExpanded ? <IconChevronUp /> : <IconChevronDown />}
+ aria-controls={itemsId}
+ aria-expanded={isExpanded}
+ onClick={() =>
+ setIsExpanded((previousIsExpanded) => !previousIsExpanded)
+ }
+ >
+ {isExpanded ? t`Show less` : t`${remainingCount} more`}
+ </Button>
+ </StyledMoreButtonContainer>
+ )}
+ </StyledQueue>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessages.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessages.tsx
index fc42d785c52..0deb74fb206 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessages.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatQueuedMessages.tsx
@@ -1,89 +1,104 @@
-import { useIsCurrentAiChatThreadReadOnly } from '@/ai/hooks/useIsCurrentAiChatThreadReadOnly';
+import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
+import { currentWorkspaceMembersState } from '@/auth/states/currentWorkspaceMembersState';
+import { isAgentChatMessageOwn } from '@/ai/utils/isAgentChatMessageOwn';
+import { isAgentChatQueuedMessageRemovable } from '@/ai/utils/isAgentChatQueuedMessageRemovable';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
+import { FeatureFlagKey } from '~/generated-metadata/graphql';
+import { getAgentChatSenderLabel } from '@/ai/utils/getAgentChatSenderLabel';
+import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
+import { AiChatQueuedMessageList } from '@/ai/components/AiChatQueuedMessageList';
import { StyledAiChatContentContainer } from '@/ai/components/StyledAiChatContentContainer';
-import { styled } from '@linaria/react';
-import { plural, t } from '@lingui/core/macro';
-
import { useDeleteQueuedMessage } from '@/ai/hooks/useDeleteQueuedMessage';
+import { useIsCurrentAiChatThreadReadOnly } from '@/ai/hooks/useIsCurrentAiChatThreadReadOnly';
import { agentChatQueuedMessagesFamilyState } from '@/ai/states/agentChatQueuedMessagesFamilyState';
import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';
+import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilyStateValue';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { isDefined } from 'twenty-shared/utils';
-import { LightIconButton } from 'twenty-ui/components/input';
-import { IconX } from 'twenty-ui/icon';
+import { styled } from '@linaria/react';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
-import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilyStateValue';
const StyledQueueContainer = styled(StyledAiChatContentContainer)`
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[1]};
padding: 0 ${themeCssVariables.spacing[3]};
`;
-const StyledQueueLabel = styled.div`
- color: ${themeCssVariables.font.color.light};
- font-size: ${themeCssVariables.font.size.xs};
- padding-left: ${themeCssVariables.spacing[1]};
-`;
-
-const StyledQueuedItem = styled.div`
- align-items: center;
- background: ${themeCssVariables.background.tertiary};
- border-radius: ${themeCssVariables.border.radius.sm};
- color: ${themeCssVariables.font.color.secondary};
- display: flex;
- font-size: ${themeCssVariables.font.size.md};
- gap: ${themeCssVariables.spacing[2]};
- justify-content: space-between;
- padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
-`;
-
-const StyledQueuedText = styled.span`
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-`;
-
export const AiChatQueuedMessages = () => {
const isReadOnly = useIsCurrentAiChatThreadReadOnly();
+ const isAiChatInboxEnabled = useIsFeatureEnabled(
+ FeatureFlagKey.IS_AI_CHAT_INBOX_ENABLED,
+ );
const currentAiChatThread = useAtomStateValue(currentAiChatThreadState);
+ const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);
+ const currentWorkspaceMembers = useAtomStateValue(
+ currentWorkspaceMembersState,
+ );
const agentChatQueuedMessages = useAtomFamilyStateValue(
agentChatQueuedMessagesFamilyState,
{ threadId: currentAiChatThread },
);
const { deleteQueuedMessage } = useDeleteQueuedMessage();
- if (!isDefined(currentAiChatThread) || agentChatQueuedMessages.length === 0) {
+ if (
+ !isDefined(currentAiChatThread) ||
+ !isNonEmptyArray(agentChatQueuedMessages)
+ ) {
return null;
}
+ const hasOtherSenders = agentChatQueuedMessages.some(
+ (message) =>
+ isDefined(message.metadata?.senderWorkspaceMemberId) &&
+ !isAgentChatMessageOwn({
+ message,
+ currentWorkspaceMemberId: currentWorkspaceMember?.id,
+ isSenderlessUserMessageOwn: !isAiChatInboxEnabled,
+ }),
+ );
+ const messages = agentChatQueuedMessages.map((message) => {
+ const senderId = message.metadata?.senderWorkspaceMemberId;
+ const isCurrentWorkspaceMember = isAgentChatMessageOwn({
+ message,
+ currentWorkspaceMemberId: currentWorkspaceMember?.id,
+ isSenderlessUserMessageOwn: !isAiChatInboxEnabled,
+ });
+ const queuedMessage = {
+ id: message.id,
+ text: message.parts.find((part) => part.type === 'text')?.text ?? '',
+ isRemovable: isAgentChatQueuedMessageRemovable({
+ message,
+ currentWorkspaceMemberId: currentWorkspaceMember?.id,
+ isAiChatInboxEnabled,
+ isReadOnly,
+ }),
+ };
+
+ if (!hasOtherSenders || !isDefined(senderId)) {
+ return queuedMessage;
+ }
+
+ const sender = currentWorkspaceMembers.find(
+ (member) => member.id === senderId,
+ );
+
+ return {
+ ...queuedMessage,
+ sender: {
+ id: senderId,
+ name: getAgentChatSenderLabel({
+ sender,
+ isCurrentWorkspaceMember,
+ }),
+ avatarUrl: getAbsoluteImageUrl(sender?.avatarUrl),
+ },
+ };
+ });
+
return (
<StyledQueueContainer>
- <StyledQueueLabel>
- {plural(agentChatQueuedMessages.length, {
- one: '# Queued',
- other: '# Queued',
- })}
- </StyledQueueLabel>
- {agentChatQueuedMessages.map((message) => {
- const textPart = message.parts?.find((part) => part.type === 'text');
- const displayText = textPart && 'text' in textPart ? textPart.text : '';
-
- return (
- <StyledQueuedItem key={message.id}>
- <StyledQueuedText>{displayText}</StyledQueuedText>
- {!isReadOnly && (
- <LightIconButton
- onClick={() => deleteQueuedMessage(message.id)}
- size="sm"
- aria-label={t`Remove queued message`}
- >
- <IconX />
- </LightIconButton>
- )}
- </StyledQueuedItem>
- );
- })}
+ <AiChatQueuedMessageList
+ messages={messages}
+ onRemove={isReadOnly ? undefined : deleteQueuedMessage}
+ />
</StyledQueueContainer>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQuotedMessagePreview.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQuotedMessagePreview.tsx
new file mode 100644
index 00000000000..506ac405559
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/AiChatQuotedMessagePreview.tsx
@@ -0,0 +1,80 @@
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { isDefined } from 'twenty-shared/utils';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+import { IconArrowUpRight } from 'twenty-ui/icon';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { LazyMarkdownRenderer } from '@/ai/components/LazyMarkdownRenderer';
+import { type AiChatQuotedMessageSource } from '@/ai/types/AiChatQuotedMessageSource';
+
+const StyledQuote = styled.div`
+ border-left: 2px solid ${themeCssVariables.border.color.medium};
+ color: ${themeCssVariables.font.color.secondary};
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ font-size: ${themeCssVariables.font.size.sm};
+ gap: ${themeCssVariables.spacing[1]};
+ min-width: 0;
+ overflow-wrap: anywhere;
+ padding: ${themeCssVariables.spacing[1]} ${themeCssVariables.spacing[2]};
+`;
+
+const StyledHeader = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[1]};
+ min-width: 0;
+`;
+
+const StyledNavigation = styled.div`
+ align-self: flex-start;
+`;
+
+type AiChatQuotedMessagePreviewProps = {
+ source: AiChatQuotedMessageSource;
+ onNavigateToMessage?: (messageId: string) => void;
+};
+
+export const AiChatQuotedMessagePreview = ({
+ source,
+ onNavigateToMessage,
+}: AiChatQuotedMessagePreviewProps) => {
+ const { t } = useLingui();
+
+ if (source.status === 'unavailable') {
+ return (
+ <StyledQuote>
+ <Text size="sm" color="tertiary">
+ {t`Original message unavailable`}
+ </Text>
+ </StyledQuote>
+ );
+ }
+
+ return (
+ <StyledQuote>
+ <StyledHeader>
+ {source.authorAvatar}
+ <Text size="sm" weight="medium" color="primary" truncate>
+ {source.authorName}
+ </Text>
+ </StyledHeader>
+ <LazyMarkdownRenderer text={source.excerpt} noImage />
+ {isDefined(onNavigateToMessage) && (
+ <StyledNavigation>
+ <Button
+ size="sm"
+ variant="ghost"
+ startIcon={<IconArrowUpRight />}
+ onClick={() => onNavigateToMessage(source.messageId)}
+ >
+ {t`View original message`}
+ </Button>
+ </StyledNavigation>
+ )}
+ </StyledQuote>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatToolCallApprovalStatusRenderer.tsx b/packages/twenty-front/src/modules/ai/components/AiChatToolCallApprovalStatusRenderer.tsx
index 8ffbf680f31..50e5b522aa0 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatToolCallApprovalStatusRenderer.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatToolCallApprovalStatusRenderer.tsx
@@ -9,7 +9,7 @@ import { isDefined } from 'twenty-shared/utils';
import { IconMail, IconTool } from 'twenty-ui/icon';
import { AiChatAskStatusRow } from '@/ai/components/AiChatAskStatusRow';
-import { StyledAiChatAskStatusDetail } from '@/ai/components/AiChatAskStyledComponents';
+import { StyledAiChatAskStatusDetail } from '@/ai/components/StyledAiChatAskStatusDetail';
import { TextWithChatReferences } from '@/ai/components/TextWithChatReferences';
export const AiChatToolCallApprovalStatusRenderer = ({
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatTypingIndicator.tsx b/packages/twenty-front/src/modules/ai/components/AiChatTypingIndicator.tsx
new file mode 100644
index 00000000000..3327cc07fd2
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/AiChatTypingIndicator.tsx
@@ -0,0 +1,68 @@
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { isNonEmptyArray } from 'twenty-shared/utils';
+import { Avatar } from 'twenty-ui/primitives/data-display';
+import { Text } from 'twenty-ui/primitives/typography';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { formatDisplayList } from '~/utils/format/formatDisplayList';
+
+const StyledIndicator = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing['1.5']};
+ min-width: 0;
+`;
+
+const StyledAvatars = styled.div`
+ align-items: center;
+ display: flex;
+ flex-shrink: 0;
+ gap: ${themeCssVariables.spacing[1]};
+`;
+
+type AiChatTypingIndicatorProps = {
+ participants: {
+ id: string;
+ name: string;
+ avatarUrl?: string;
+ }[];
+};
+
+export const AiChatTypingIndicator = ({
+ participants,
+}: AiChatTypingIndicatorProps) => {
+ const { t } = useLingui();
+
+ if (!isNonEmptyArray(participants)) {
+ return null;
+ }
+
+ const participantNames = formatDisplayList(
+ participants.map(({ name }) => name),
+ );
+ const label =
+ participants.length === 1
+ ? t`${participantNames} is typing…`
+ : t`${participantNames} are typing…`;
+
+ return (
+ <StyledIndicator role="status" aria-live="polite" aria-atomic>
+ <StyledAvatars aria-hidden>
+ {participants.map(({ id, name, avatarUrl }) => (
+ <Avatar
+ key={id}
+ colorSeed={id}
+ name={name}
+ src={avatarUrl}
+ size="sm"
+ shape="circle"
+ />
+ ))}
+ </StyledAvatars>
+ <Text size="sm" color="tertiary" truncate>
+ {label}
+ </Text>
+ </StyledIndicator>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx
index f99c6441b0b..73145f3ba25 100644
--- a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx
+++ b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx
@@ -5,6 +5,7 @@ import {
} from '@/ai/components/LazyMarkdownRendererStyledComponents';
import { MarkdownRenderer } from '@/ai/components/MarkdownRenderer';
import { EMPTY_MARKDOWN_BLOCK_SPLIT_CACHE } from '@/ai/constants/EmptyMarkdownBlockSplitCache';
+import { type MarkdownDisplayMode } from '@/ai/types/MarkdownDisplayMode';
import { getMarkdownBlocksIncrementally } from '@/ai/utils/getMarkdownBlocksIncrementally';
import { protectChatReferencesForMarkdown } from '@/ai/utils/protectChatReferencesForMarkdown';
import { memo, Suspense, useRef } from 'react';
@@ -35,11 +36,13 @@ const MemoizedMarkdownBlock = memo(
type LazyMarkdownContentProps = {
text: string;
noImage?: boolean;
+ displayMode?: MarkdownDisplayMode;
};
export const LazyMarkdownContent = ({
text,
noImage,
+ displayMode = 'default',
}: LazyMarkdownContentProps) => {
// Not state: only caches the previous split so streaming appends skip settled blocks.
// oxlint-disable-next-line twenty/no-state-useref
@@ -55,6 +58,7 @@ export const LazyMarkdownContent = ({
return (
<StyledMarkdownContainer
className="markdown-section"
+ displayMode={displayMode}
data-replay-ignore-mutations="true"
>
{markdownBlocks.map((blockText, blockIndex) => (
@@ -73,8 +77,13 @@ type LazyMarkdownRendererProps = LazyMarkdownContentProps;
export const LazyMarkdownRenderer = ({
text,
noImage,
+ displayMode,
}: LazyMarkdownRendererProps) => (
<Suspense fallback={<MarkdownLoadingSkeleton />}>
- <LazyMarkdownContent text={text} noImage={noImage} />
+ <LazyMarkdownContent
+ text={text}
+ noImage={noImage}
+ displayMode={displayMode}
+ />
</Suspense>
);
diff --git a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRendererStyledComponents.tsx b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRendererStyledComponents.tsx
index ef589b03cca..9f2bc23ec7f 100644
--- a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRendererStyledComponents.tsx
+++ b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRendererStyledComponents.tsx
@@ -1,10 +1,17 @@
+import { type MarkdownDisplayMode } from '@/ai/types/MarkdownDisplayMode';
import { styled } from '@linaria/react';
import { themeCssVariables } from 'twenty-ui/theme';
-export const StyledMarkdownContainer = styled.div`
+export const StyledMarkdownContainer = styled.div<{
+ displayMode: MarkdownDisplayMode;
+}>`
border-radius: ${themeCssVariables.border.radius.sm};
- line-height: 150%;
- margin: ${themeCssVariables.spacing['1.5']} 0;
+ line-height: ${({ displayMode }) =>
+ displayMode === 'default'
+ ? `calc(${themeCssVariables.text.lineHeight.lg} * 100%)`
+ : themeCssVariables.spacing[6]};
+ margin: ${({ displayMode }) =>
+ displayMode === 'bubble' ? '0' : `${themeCssVariables.spacing['1.5']} 0`};
overflow-x: auto;
position: relative;
scroll-margin-bottom: ${themeCssVariables.spacing[10]};
diff --git a/packages/twenty-front/src/modules/ai/components/StyledAiChatAskCard.tsx b/packages/twenty-front/src/modules/ai/components/StyledAiChatAskCard.tsx
new file mode 100644
index 00000000000..44284e40885
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/StyledAiChatAskCard.tsx
@@ -0,0 +1,14 @@
+import { styled } from '@linaria/react';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+export const StyledAiChatAskCard = styled.div<{ isPadded?: boolean }>`
+ background-color: ${themeCssVariables.background.transparent.lighter};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ gap: ${({ isPadded }) => (isPadded ? themeCssVariables.spacing[2] : '0')};
+ padding: ${({ isPadded }) => (isPadded ? themeCssVariables.spacing[2] : '0')};
+ width: 100%;
+`;
diff --git a/packages/twenty-front/src/modules/ai/components/StyledAiChatAskStatusDetail.tsx b/packages/twenty-front/src/modules/ai/components/StyledAiChatAskStatusDetail.tsx
new file mode 100644
index 00000000000..362637bfcdf
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/StyledAiChatAskStatusDetail.tsx
@@ -0,0 +1,8 @@
+import { styled } from '@linaria/react';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+export const StyledAiChatAskStatusDetail = styled.span`
+ color: ${themeCssVariables.font.color.secondary};
+ font-size: ${themeCssVariables.font.size.sm};
+ overflow-wrap: anywhere;
+`;
diff --git a/packages/twenty-front/src/modules/ai/components/StyledAiChatAskStatusMessage.tsx b/packages/twenty-front/src/modules/ai/components/StyledAiChatAskStatusMessage.tsx
new file mode 100644
index 00000000000..50b6ae36dd0
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/StyledAiChatAskStatusMessage.tsx
@@ -0,0 +1,8 @@
+import { styled } from '@linaria/react';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+export const StyledAiChatAskStatusMessage = styled.span`
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.md};
+ font-weight: ${themeCssVariables.font.weight.medium};
+`;
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatComposerQuotePreview.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatComposerQuotePreview.stories.tsx
new file mode 100644
index 00000000000..955ccd604c8
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatComposerQuotePreview.stories.tsx
@@ -0,0 +1,76 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { Avatar } from 'twenty-ui/primitives/data-display';
+import { Text } from 'twenty-ui/primitives/typography';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+import { AiChatComposerQuotePreview } from '@/ai/components/AiChatComposerQuotePreview';
+import { type AiChatQuotedMessageSource } from '@/ai/types/AiChatQuotedMessageSource';
+import { RootDecorator } from '~/testing/decorators/RootDecorator';
+
+const quotedSource: AiChatQuotedMessageSource = {
+ status: 'available',
+ messageId: 'security-review',
+ authorName: 'Marco Rossi',
+ authorAvatar: (
+ <Avatar name="Marco Rossi" colorSeed="marco" size="sm" shape="circle" />
+ ),
+ excerpt: 'Their procurement asked for a **security review**.',
+};
+
+const meta: Meta<typeof AiChatComposerQuotePreview> = {
+ title: 'Modules/AI/AiChatComposerQuotePreview',
+ component: AiChatComposerQuotePreview,
+ decorators: [ComponentDecorator, RootDecorator],
+ parameters: { container: { width: 400 } },
+ args: { source: quotedSource, onRemove: fn() },
+};
+
+export default meta;
+type Story = StoryObj<typeof AiChatComposerQuotePreview>;
+
+export const SelectedQuote: Story = {};
+
+const RemoveQuoteFixture = ({ onRemove }: { onRemove: () => void }) => {
+ const [hasQuote, setHasQuote] = useState(true);
+
+ if (!hasQuote) {
+ return <Text>No quoted message</Text>;
+ }
+
+ return (
+ <AiChatComposerQuotePreview
+ source={quotedSource}
+ onRemove={() => {
+ setHasQuote(false);
+ onRemove();
+ }}
+ />
+ );
+};
+
+export const RemoveQuote: Story = {
+ render: ({ onRemove }) => <RemoveQuoteFixture onRemove={onRemove} />,
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Remove quote' }));
+ await expect(args.onRemove).toHaveBeenCalledTimes(1);
+ await expect(canvas.getByText('No quoted message')).toBeVisible();
+ await expect(canvas.queryByText('Marco Rossi')).not.toBeInTheDocument();
+ },
+};
+
+export const UnavailableSource: Story = {
+ args: { source: { status: 'unavailable' } },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByText('Original message unavailable'),
+ ).toBeVisible();
+ await userEvent.click(canvas.getByRole('button', { name: 'Remove quote' }));
+ await expect(args.onRemove).toHaveBeenCalledTimes(1);
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCard.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCard.stories.tsx
index 2f7af4a69fc..ab437372b27 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCard.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCard.stories.tsx
@@ -1,6 +1,6 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { useStore } from 'jotai';
-import { type ReactNode, useEffect } from 'react';
+import { useEffect } from 'react';
import { FieldMetadataType } from 'twenty-shared/types';
import { ComponentDecorator } from 'twenty-ui/testing';
@@ -18,7 +18,7 @@ const StyledContainer = styled.div`
padding: 24px;
`;
-const StoreSeeder = ({ children }: { children: ReactNode }) => {
+const StoreSeederEffect = () => {
const store = useStore();
useEffect(() => {
@@ -26,7 +26,7 @@ const StoreSeeder = ({ children }: { children: ReactNode }) => {
store.set(agentChatDisplayedThreadState.atom, 'thread-1');
}, [store]);
- return <>{children}</>;
+ return null;
};
const meta: Meta<typeof AiChatFormCard> = {
@@ -34,11 +34,10 @@ const meta: Meta<typeof AiChatFormCard> = {
component: AiChatFormCard,
decorators: [
(Story) => (
- <StoreSeeder>
- <StyledContainer>
- <Story />
- </StyledContainer>
- </StoreSeeder>
+ <StyledContainer>
+ <StoreSeederEffect />
+ <Story />
+ </StyledContainer>
),
ToastDecorator,
ComponentDecorator,
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCardContent.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCardContent.stories.tsx
new file mode 100644
index 00000000000..dd687b290a6
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatFormCardContent.stories.tsx
@@ -0,0 +1,119 @@
+import { styled } from '@linaria/react';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { FieldMetadataType } from 'twenty-shared/types';
+import { ComponentDecorator } from 'twenty-ui/testing';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { AiChatFormCardContent } from '@/ai/components/AiChatFormCardContent';
+import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
+import { RootDecorator } from '~/testing/decorators/RootDecorator';
+
+const AI_CHAT_FORM_CARD_STORY_WIDTH_PX = 640;
+
+const StyledContainer = styled.div`
+ padding: ${themeCssVariables.spacing[6]};
+ width: ${AI_CHAT_FORM_CARD_STORY_WIDTH_PX}px;
+`;
+
+const meta = {
+ title: 'Modules/AiChat/AiChatFormCardContent',
+ component: AiChatFormCardContent,
+ decorators: [
+ (Story) => (
+ <StyledContainer>
+ <Story />
+ </StyledContainer>
+ ),
+ ComponentDecorator,
+ MemoryRouterDecorator,
+ RootDecorator,
+ ],
+ args: {
+ title: 'Log call with Stripe',
+ fields: [
+ {
+ name: 'amount',
+ label: 'Amount (USD)',
+ type: FieldMetadataType.NUMBER,
+ },
+ {
+ name: 'outcome',
+ label: 'Outcome',
+ type: FieldMetadataType.TEXT,
+ },
+ {
+ name: 'nextStep',
+ label: 'Next step',
+ type: FieldMetadataType.TEXT,
+ placeholder: 'What happens next?',
+ },
+ ],
+ defaultValues: { amount: 50000, outcome: 'Positive' },
+ onFieldChange: fn(),
+ onError: fn(),
+ onSubmit: fn(),
+ onSkip: fn(),
+ },
+} satisfies Meta<typeof AiChatFormCardContent>;
+
+export default meta;
+
+type Story = StoryObj<typeof meta>;
+
+export const Prefilled: Story = {
+ play: async ({ args, canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(await canvas.findByText('2 of 3 fields prefilled')).toBeVisible();
+ expect(
+ await canvas.findByRole('textbox', { name: 'Outcome' }),
+ ).toHaveTextContent('Positive');
+ const nextStep = await canvas.findByRole('textbox', { name: 'Next step' });
+
+ await userEvent.type(nextStep, 'Security review');
+ expect(args.onFieldChange).toHaveBeenLastCalledWith({
+ fieldName: 'nextStep',
+ value: 'Security review',
+ });
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Submit' }));
+ expect(args.onSubmit).toHaveBeenCalledOnce();
+ },
+};
+
+export const Skip: Story = {
+ play: async ({ args, canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(await canvas.findByRole('button', { name: 'Skip' }));
+ expect(args.onSkip).toHaveBeenCalledOnce();
+ expect(args.onSubmit).not.toHaveBeenCalled();
+ expect(canvas.getByText('Log call with Stripe')).toBeVisible();
+ },
+};
+
+export const Submitting: Story = {
+ args: { isSubmitting: true },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByRole('button', { name: 'Submit' }),
+ ).toBeDisabled();
+ expect(canvas.getByRole('button', { name: 'Skip' })).toBeDisabled();
+ },
+};
+
+export const WithoutPrefillOrSkip: Story = {
+ args: { defaultValues: undefined, onSkip: undefined },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(await canvas.findByRole('button', { name: 'Submit' })).toBeVisible();
+ expect(
+ canvas.queryByRole('button', { name: 'Skip' }),
+ ).not.toBeInTheDocument();
+ expect(canvas.queryByText(/fields prefilled/)).not.toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx
index fb1040ffcf6..8388e171cd8 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx
@@ -6,11 +6,21 @@ import {
type StoryObj,
} from '@storybook/react-vite';
import { Suspense, useEffect } from 'react';
-import { userEvent, within } from 'storybook/test';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
import { type ExtendedUIMessage } from 'twenty-shared/ai';
import { ComponentDecorator } from 'twenty-ui/testing';
import { AiChatMessage } from '@/ai/components/AiChatMessage';
+import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
+import { currentWorkspaceMembersState } from '@/auth/states/currentWorkspaceMembersState';
+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
+import { agentChatThreadVisitState } from '@/ai/states/agentChatThreadVisitState';
+import { agentChatMessageReactionsFamilyState } from '@/ai/states/agentChatMessageReactionsFamilyState';
+import { FeatureFlagKey } from '~/generated-metadata/graphql';
+import {
+ mockCurrentWorkspace,
+ mockedWorkspaceMemberData,
+} from '~/testing/mock-data/users';
import { MarkdownLoadingSkeleton } from '@/ai/components/LazyMarkdownRenderer';
import { agentChatDisplayedThreadState } from '@/ai/states/agentChatDisplayedThreadState';
@@ -42,6 +52,7 @@ const mockUserMessage: ExtendedUIMessage = {
],
metadata: {
createdAt: getMockedDateWithOffset({ minutes: -2 }),
+ senderWorkspaceMemberId: mockedWorkspaceMemberData.id,
},
};
@@ -271,6 +282,47 @@ const mockAnsweredForm: ExtendedUIMessage = {
},
};
+const mockTeammate = {
+ ...mockedWorkspaceMemberData,
+ id: 'teammate-marco',
+ name: { firstName: 'Marco', lastName: 'Rossi' },
+ avatarUrl: null,
+};
+
+const mockTeammateMessage: ExtendedUIMessage = {
+ id: 'msg-teammate',
+ role: 'user',
+ parts: [{ type: 'text', text: 'I will handle the security review.' }],
+ metadata: {
+ createdAt: getMockedDateWithOffset({ minutes: -1 }),
+ senderWorkspaceMemberId: mockTeammate.id,
+ },
+};
+
+const mockFormerMemberMessage: ExtendedUIMessage = {
+ ...mockTeammateMessage,
+ id: 'msg-former-member',
+ parts: [{ type: 'text', text: 'The proposal is ready for review.' }],
+ metadata: {
+ createdAt: MOCKED_DATE,
+ senderWorkspaceMemberId: 'former-member',
+ },
+};
+
+const mockUnknownSenderMessage: ExtendedUIMessage = {
+ ...mockTeammateMessage,
+ id: 'msg-unknown-sender',
+ parts: [{ type: 'text', text: 'A message without sender metadata.' }],
+ metadata: { createdAt: MOCKED_DATE },
+};
+
+const mockNamedAssistantMessage: ExtendedUIMessage = {
+ ...mockTeammateMessage,
+ id: 'msg-named-assistant',
+ role: 'assistant',
+ parts: [{ type: 'text', text: 'The recorded sender remains visible.' }],
+};
+
const allMockMessages = [
mockUserMessage,
mockAssistantWithCodeExecution,
@@ -281,32 +333,88 @@ const allMockMessages = [
mockThinkingStepsStreaming,
mockThinkingStepsDone,
mockAnsweredForm,
+ mockTeammateMessage,
+ mockFormerMemberMessage,
+ mockUnknownSenderMessage,
+ mockNamedAssistantMessage,
];
const AgentChatMessagesSetterEffect = ({
messages,
+ isInboxEnabled,
}: {
messages: ExtendedUIMessage[];
+ isInboxEnabled: boolean;
}) => {
const store = useStore();
useEffect(() => {
- const currentThreadId = store.get(currentAiChatThreadState.atom);
+ const currentThreadId = 'conversation-presentation-story';
+ const previousCurrentThread = store.get(currentAiChatThreadState.atom);
+ const previousDisplayedThread = store.get(
+ agentChatDisplayedThreadState.atom,
+ );
+ const previousWorkspace = store.get(currentWorkspaceState.atom);
+ const previousMember = store.get(currentWorkspaceMemberState.atom);
+ const previousMembers = store.get(currentWorkspaceMembersState.atom);
+ const previousVisit = store.get(agentChatThreadVisitState.atom);
+ const messagesAtom = agentChatMessagesFamilyState.atomFamily({
+ threadId: currentThreadId,
+ });
+ const reactionsAtom = agentChatMessageReactionsFamilyState.atomFamily({
+ messageId: mockTeammateMessage.id,
+ });
+ store.set(currentAiChatThreadState.atom, currentThreadId);
store.set(agentChatDisplayedThreadState.atom, currentThreadId);
-
- store.set(
- agentChatMessagesFamilyState.atomFamily({ threadId: currentThreadId }),
- messages,
- );
- }, [messages, store]);
+ store.set(currentWorkspaceMemberState.atom, mockedWorkspaceMemberData);
+ store.set(currentWorkspaceMembersState.atom, [
+ mockedWorkspaceMemberData,
+ mockTeammate,
+ ]);
+ store.set(currentWorkspaceState.atom, {
+ ...mockCurrentWorkspace,
+ featureFlags: [
+ { key: FeatureFlagKey.IS_AI_CHAT_INBOX_ENABLED, value: isInboxEnabled },
+ ],
+ });
+ store.set(agentChatThreadVisitState.atom, {
+ threadId: currentThreadId,
+ isUnread: true,
+ isKeptUnread: false,
+ lastReadAt: getMockedDateWithOffset({ seconds: -90 }),
+ });
+ store.set(messagesAtom, messages);
+ store.set(reactionsAtom, [
+ {
+ emoji: 'πŸ‘',
+ workspaceMemberIds: [mockedWorkspaceMemberData.id],
+ agentIds: [],
+ hasAssistantReacted: false,
+ },
+ ]);
+
+ return () => {
+ store.set(currentAiChatThreadState.atom, previousCurrentThread);
+ store.set(agentChatDisplayedThreadState.atom, previousDisplayedThread);
+ store.set(currentWorkspaceState.atom, previousWorkspace);
+ store.set(currentWorkspaceMemberState.atom, previousMember);
+ store.set(currentWorkspaceMembersState.atom, previousMembers);
+ store.set(agentChatThreadVisitState.atom, previousVisit);
+ store.set(messagesAtom, []);
+ store.set(reactionsAtom, []);
+ };
+ }, [messages, isInboxEnabled, store]);
return null;
};
-const AgentChatMessagesDecorator: Decorator = (Story) => (
+const AgentChatMessagesDecorator: Decorator = (Story, { parameters }) => (
<>
- <AgentChatMessagesSetterEffect messages={allMockMessages} />
+ <AgentChatMessagesSetterEffect
+ messages={parameters.messages ?? allMockMessages}
+ isInboxEnabled={parameters.isInboxEnabled ?? false}
+ />
<Suspense fallback={<MarkdownLoadingSkeleton />}>
<Story />
</Suspense>
@@ -382,3 +490,52 @@ export const ThinkingStepsDoneExpanded: Story = {
export const AnsweredForm: Story = {
render: () => <AiChatMessage messageId={mockAnsweredForm.id} />,
};
+
+export const MultiplayerConversation: Story = {
+ parameters: {
+ isInboxEnabled: true,
+ messages: [mockUserMessage, mockTeammateMessage, mockSimpleTextResponse],
+ },
+ render: () => (
+ <StyledConversationContainer>
+ <AiChatMessage messageId={mockUserMessage.id} />
+ <AiChatMessage messageId={mockTeammateMessage.id} />
+ <AiChatMessage messageId={mockSimpleTextResponse.id} />
+ </StyledConversationContainer>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(await canvas.findByText('Marco Rossi')).toBeVisible();
+ await expect(await canvas.findByText('Assistant')).toBeVisible();
+ await expect(canvas.getByText('New')).toBeVisible();
+ const selectedReaction = canvas.getByRole('button', { name: 'πŸ‘ by You' });
+ await expect(selectedReaction).toBeVisible();
+ selectedReaction.focus();
+ await userEvent.tab();
+ const addReactionButton = canvas.getAllByRole('button', {
+ name: 'Add reaction',
+ })[1];
+ await expect(addReactionButton).toHaveFocus();
+ await waitFor(() => expect(addReactionButton).toBeVisible());
+ },
+};
+
+export const SenderFallbacks: Story = {
+ parameters: { isInboxEnabled: true },
+ render: () => (
+ <StyledConversationContainer>
+ <AiChatMessage messageId={mockFormerMemberMessage.id} />
+ <AiChatMessage messageId={mockUnknownSenderMessage.id} />
+ <AiChatMessage messageId={mockNamedAssistantMessage.id} />
+ </StyledConversationContainer>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(await canvas.findByText('Former member')).toBeVisible();
+ await expect(canvas.getByText('Unknown sender')).toBeVisible();
+ await expect(canvas.getByText('Marco Rossi')).toBeVisible();
+ await expect(canvas.queryByText('Ada')).not.toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessageReactionPicker.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessageReactionPicker.stories.tsx
new file mode 100644
index 00000000000..02c1242aea7
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessageReactionPicker.stories.tsx
@@ -0,0 +1,178 @@
+import { styled } from '@linaria/react';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useStore } from 'jotai';
+import { graphql, http, HttpResponse, passthrough } from 'msw';
+import { useEffect } from 'react';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { ComponentDecorator } from 'twenty-ui/testing';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { AiChatMessageReactionPicker } from '@/ai/components/AiChatMessageReactionPicker';
+import { AiChatMessageReactions } from '@/ai/components/AiChatMessageReactions';
+import { AGENT_CHAT_EMOJIBASE_URL } from '@/ai/constants/AgentChatEmojibaseUrl';
+import { agentChatMessageReactionsFamilyState } from '@/ai/states/agentChatMessageReactionsFamilyState';
+import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
+import { RootDecorator } from '~/testing/decorators/RootDecorator';
+import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
+import { graphqlMocks } from '~/testing/graphqlMocks';
+import { mockedWorkspaceMemberData } from '~/testing/mock-data/users';
+
+const MESSAGE_ID = '20202020-f838-4ff1-a1b0-9dcf71e2e1cd';
+const addReaction = fn();
+const removeReaction = fn();
+
+const StyledReactions = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[1]};
+`;
+
+const ReactionStateEffect = () => {
+ const store = useStore();
+
+ useEffect(() => {
+ const previousMember = store.get(currentWorkspaceMemberState.atom);
+ const reactionsAtom = agentChatMessageReactionsFamilyState.atomFamily({
+ messageId: MESSAGE_ID,
+ });
+
+ store.set(currentWorkspaceMemberState.atom, mockedWorkspaceMemberData);
+ store.set(reactionsAtom, []);
+
+ return () => {
+ store.set(currentWorkspaceMemberState.atom, previousMember);
+ store.set(reactionsAtom, []);
+ };
+ }, [store]);
+
+ return null;
+};
+
+const meta: Meta<typeof AiChatMessageReactionPicker> = {
+ title: 'Modules/AI/AiChatMessageReactionPicker',
+ component: AiChatMessageReactionPicker,
+ decorators: [
+ (Story) => (
+ <>
+ <ReactionStateEffect />
+ <StyledReactions>
+ <AiChatMessageReactions messageId={MESSAGE_ID} />
+ <Story />
+ </StyledReactions>
+ </>
+ ),
+ ToastDecorator,
+ RootDecorator,
+ ComponentDecorator,
+ ],
+ args: { messageId: MESSAGE_ID },
+ beforeEach: () => {
+ addReaction.mockClear();
+ removeReaction.mockClear();
+ },
+ parameters: {
+ container: { width: 400, height: 380 },
+ msw: {
+ handlers: [
+ http.all(`${AGENT_CHAT_EMOJIBASE_URL}/en/:filename`, () =>
+ passthrough(),
+ ),
+ graphql.mutation('AddAgentChatMessageReaction', ({ variables }) => {
+ addReaction(variables);
+
+ return HttpResponse.json({
+ data: {
+ addAgentChatMessageReaction: [
+ {
+ emoji: variables.emoji,
+ workspaceMemberIds: [mockedWorkspaceMemberData.id],
+ agentIds: [],
+ hasAssistantReacted: false,
+ },
+ ],
+ },
+ });
+ }),
+ graphql.mutation('RemoveAgentChatMessageReaction', ({ variables }) => {
+ removeReaction(variables);
+
+ return HttpResponse.json({
+ data: { removeAgentChatMessageReaction: [] },
+ });
+ }),
+ ...graphqlMocks.handlers,
+ ],
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof AiChatMessageReactionPicker>;
+
+export const ToggleQuickReaction: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Add reaction' }));
+ const picker = within(
+ await body.findByRole('dialog', { name: 'Add reaction' }),
+ );
+
+ expect(
+ picker.queryByPlaceholderText('Search emojis'),
+ ).not.toBeInTheDocument();
+ await userEvent.click(picker.getByRole('button', { name: 'βœ…' }));
+ await waitFor(() =>
+ expect(addReaction).toHaveBeenCalledWith({
+ messageId: MESSAGE_ID,
+ emoji: 'βœ…',
+ }),
+ );
+
+ const reaction = await canvas.findByRole('button', { name: 'βœ… by You' });
+ expect(reaction).toHaveAttribute('aria-pressed', 'true');
+ expect(reaction).toHaveTextContent('βœ…1');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+
+ await userEvent.click(reaction);
+ await waitFor(() =>
+ expect(removeReaction).toHaveBeenCalledWith({
+ messageId: MESSAGE_ID,
+ emoji: 'βœ…',
+ }),
+ );
+ expect(
+ canvas.queryByRole('button', { name: 'βœ… by You' }),
+ ).not.toBeInTheDocument();
+ },
+};
+
+export const MoreReactions: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const trigger = canvas.getByRole('button', { name: 'Add reaction' });
+
+ await userEvent.click(trigger);
+ await userEvent.click(
+ await body.findByRole('button', { name: 'More reactions' }),
+ );
+ const search = await body.findByPlaceholderText('Search emojis');
+
+ await expect(search).toHaveFocus();
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ await userEvent.click(trigger);
+ await expect(
+ await body.findByRole('button', { name: 'More reactions' }),
+ ).toBeVisible();
+ expect(
+ body.queryByPlaceholderText('Search emojis'),
+ ).not.toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuestionCard.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuestionCard.stories.tsx
index 3e12955d538..89fd431b9a7 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuestionCard.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuestionCard.stories.tsx
@@ -1,7 +1,7 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { useStore } from 'jotai';
-import { type ReactNode, useEffect } from 'react';
-import { expect, userEvent, within } from 'storybook/test';
+import { useEffect } from 'react';
+import { expect, fn, userEvent, within } from 'storybook/test';
import { ComponentDecorator } from 'twenty-ui/testing';
import { AiChatQuestionCard } from '@/ai/components/AiChatQuestionCard';
@@ -86,7 +86,7 @@ const multiSelectQuestion: AgentChatPendingQuestion = {
},
};
-const StoreSeeder = ({ children }: { children: ReactNode }) => {
+const StoreSeederEffect = () => {
const store = useStore();
useEffect(() => {
@@ -94,7 +94,7 @@ const StoreSeeder = ({ children }: { children: ReactNode }) => {
store.set(agentChatDisplayedThreadState.atom, 'thread-1');
}, [store]);
- return <>{children}</>;
+ return null;
};
const meta: Meta<typeof AiChatQuestionCard> = {
@@ -102,11 +102,10 @@ const meta: Meta<typeof AiChatQuestionCard> = {
component: AiChatQuestionCard,
decorators: [
(Story) => (
- <StoreSeeder>
- <StyledContainer>
- <Story />
- </StyledContainer>
- </StoreSeeder>
+ <StyledContainer>
+ <StoreSeederEffect />
+ <Story />
+ </StyledContainer>
),
ToastDecorator,
ComponentDecorator,
@@ -125,6 +124,37 @@ export const SingleQuestion: Story = {
export const MultipleQuestions: Story = {
args: { pendingQuestion: multipleQuestions },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const previous = await canvas.findByRole('button', { name: 'Previous' });
+ const next = canvas.getByRole('button', { name: 'Next question' });
+
+ expect(previous).toBeDisabled();
+ expect(canvas.getByText('1/2')).toBeVisible();
+ await userEvent.type(
+ canvas.getByPlaceholderText('Type your own answer here'),
+ 'Welcome email draft',
+ );
+ await userEvent.click(next);
+
+ expect(canvas.getByText(TONE_QUESTION.question)).toBeVisible();
+ expect(canvas.getByText('2/2')).toBeVisible();
+ expect(next).toBeDisabled();
+ await userEvent.type(
+ canvas.getByPlaceholderText('Type your own answer here'),
+ 'Friendly tone draft',
+ );
+ await userEvent.click(previous);
+
+ expect(canvas.getByText(EMAIL_TYPE_QUESTION.question)).toBeVisible();
+ expect(
+ canvas.getByPlaceholderText('Type your own answer here'),
+ ).toHaveValue('Welcome email draft');
+ await userEvent.click(next);
+ expect(
+ canvas.getByPlaceholderText('Type your own answer here'),
+ ).toHaveValue('Friendly tone draft');
+ },
};
export const LongQuestion: Story = {
@@ -157,3 +187,14 @@ export const MultiSelectQuestion: Story = {
expect(otherOption).toHaveAttribute('aria-pressed', 'true');
},
};
+
+export const SkipQuestion: Story = {
+ args: { pendingQuestion: singleQuestion, onSkip: fn() },
+ play: async ({ args, canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(await canvas.findByRole('button', { name: 'Skip' }));
+ expect(args.onSkip).toHaveBeenCalledOnce();
+ expect(canvas.getByText(EMAIL_TYPE_QUESTION.question)).toBeVisible();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQueuedMessageList.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQueuedMessageList.stories.tsx
new file mode 100644
index 00000000000..b40b5396fd1
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQueuedMessageList.stories.tsx
@@ -0,0 +1,184 @@
+import { styled } from '@linaria/react';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { ComponentDecorator } from 'twenty-ui/testing';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { AiChatQueuedMessageList } from '@/ai/components/AiChatQueuedMessageList';
+import { RootDecorator } from '~/testing/decorators/RootDecorator';
+
+const StyledContainer = styled.div`
+ padding: ${themeCssVariables.spacing[6]};
+ width: 560px;
+`;
+
+const meta = {
+ title: 'Modules/AiChat/AiChatQueuedMessageList',
+ component: AiChatQueuedMessageList,
+ decorators: [
+ (Story) => (
+ <StyledContainer>
+ <Story />
+ </StyledContainer>
+ ),
+ ComponentDecorator,
+ RootDecorator,
+ ],
+ args: {
+ messages: [
+ {
+ id: 'queued-1',
+ isRemovable: true,
+ text: 'Skip anything already in a closed-lost opportunity',
+ },
+ {
+ id: 'queued-2',
+ isRemovable: true,
+ text: 'Also add the account owner for each one',
+ },
+ {
+ id: 'queued-3',
+ isRemovable: true,
+ text: 'Then draft a check-in email for the top 5',
+ },
+ ],
+ onRemove: fn(),
+ },
+} satisfies Meta<typeof AiChatQueuedMessageList>;
+
+export default meta;
+
+type Story = StoryObj<typeof meta>;
+
+export const Default: Story = {
+ render: function Render(args) {
+ const [messages, setMessages] = useState(args.messages);
+
+ return (
+ <AiChatQueuedMessageList
+ messages={messages}
+ onRemove={(messageId) => {
+ args.onRemove?.(messageId);
+ setMessages((previousMessages) =>
+ previousMessages.filter((message) => message.id !== messageId),
+ );
+ }}
+ />
+ );
+ },
+ play: async ({ args, canvasElement }) => {
+ const canvas = within(canvasElement);
+ const removeButtons = await canvas.findAllByRole('button', {
+ name: 'Remove queued message',
+ });
+
+ await userEvent.click(removeButtons[0]);
+ expect(args.onRemove).toHaveBeenCalledWith('queued-1');
+ expect(
+ canvas.queryByText('Skip anything already in a closed-lost opportunity'),
+ ).not.toBeInTheDocument();
+ expect(canvas.getByText('2')).toBeVisible();
+ },
+};
+
+export const ReadOnly: Story = {
+ args: { onRemove: undefined },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(await canvas.findByText('Queued')).toBeVisible();
+ expect(
+ canvas.queryByRole('button', { name: 'Remove queued message' }),
+ ).not.toBeInTheDocument();
+ },
+};
+
+export const Empty: Story = {
+ args: { messages: [] },
+ play: async ({ canvasElement }) => {
+ expect(within(canvasElement).queryByText('Queued')).not.toBeInTheDocument();
+ },
+};
+
+export const SharedQueue: Story = {
+ args: {
+ messages: [
+ {
+ id: 'queued-own',
+ text: 'Add the account owner',
+ isRemovable: true,
+ sender: { id: 'member-own', name: 'You' },
+ },
+ {
+ id: 'queued-other',
+ text: 'Include the latest activity',
+ isRemovable: false,
+ sender: { id: 'member-other', name: 'Sarah' },
+ },
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByText('Sarah Β· Include the latest activity'),
+ ).toBeVisible();
+ expect(
+ canvas.getAllByRole('button', { name: 'Remove queued message' }),
+ ).toHaveLength(1);
+ },
+};
+
+export const Overflow: Story = {
+ args: {
+ messages: [
+ ...meta.args.messages,
+ {
+ id: 'queued-4',
+ text: 'Include last quarter for comparison',
+ isRemovable: true,
+ },
+ {
+ id: 'queued-5',
+ text: 'Highlight changes in deal size',
+ isRemovable: true,
+ },
+ ],
+ },
+ play: async ({ args, canvasElement }) => {
+ const canvas = within(canvasElement);
+ const moreButton = await canvas.findByRole('button', { name: '2 more' });
+
+ expect(moreButton).toHaveAttribute('aria-expanded', 'false');
+ expect(
+ canvas.getAllByRole('button', { name: 'Remove queued message' }),
+ ).toHaveLength(3);
+ expect(
+ canvas.queryByText('Include last quarter for comparison'),
+ ).not.toBeInTheDocument();
+
+ await userEvent.click(moreButton);
+
+ expect(
+ canvas.getByText('Include last quarter for comparison'),
+ ).toBeVisible();
+ expect(canvas.getByText('Highlight changes in deal size')).toBeVisible();
+ expect(
+ canvas.getAllByRole('button', { name: 'Remove queued message' }),
+ ).toHaveLength(5);
+
+ const lessButton = canvas.getByRole('button', { name: 'Show less' });
+ expect(lessButton).toHaveAttribute('aria-expanded', 'true');
+ await userEvent.click(lessButton);
+
+ expect(
+ canvas.queryByText('Highlight changes in deal size'),
+ ).not.toBeInTheDocument();
+ expect(canvas.getByRole('button', { name: '2 more' })).toHaveAttribute(
+ 'aria-expanded',
+ 'false',
+ );
+ expect(args.onRemove).not.toHaveBeenCalled();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuotedMessagePreview.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuotedMessagePreview.stories.tsx
new file mode 100644
index 00000000000..50729c94846
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatQuotedMessagePreview.stories.tsx
@@ -0,0 +1,72 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { Avatar } from 'twenty-ui/primitives/data-display';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+import { AiChatQuotedMessagePreview } from '@/ai/components/AiChatQuotedMessagePreview';
+import { RootDecorator } from '~/testing/decorators/RootDecorator';
+
+const meta: Meta<typeof AiChatQuotedMessagePreview> = {
+ title: 'Modules/AI/AiChatQuotedMessagePreview',
+ component: AiChatQuotedMessagePreview,
+ decorators: [ComponentDecorator, RootDecorator],
+ parameters: { container: { width: 400 } },
+ args: { onNavigateToMessage: fn() },
+};
+
+export default meta;
+type Story = StoryObj<typeof AiChatQuotedMessagePreview>;
+
+export const LinkedQuote: Story = {
+ args: {
+ source: {
+ status: 'available',
+ messageId: 'security-review',
+ authorName: 'Marco Rossi',
+ authorAvatar: (
+ <Avatar name="Marco Rossi" colorSeed="marco" size="sm" shape="circle" />
+ ),
+ excerpt: 'Their procurement asked for a **security review**.',
+ },
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await expect(await canvas.findByText('security review')).toBeVisible();
+ await expect(canvas.getByText('Marco Rossi')).toBeVisible();
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole('button', { name: 'View original message' }),
+ ).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onNavigateToMessage).toHaveBeenCalledWith(
+ 'security-review',
+ );
+ },
+};
+
+export const UnavailableSource: Story = {
+ args: { source: { status: 'unavailable' } },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByText('Original message unavailable'),
+ ).toBeVisible();
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
+ await expect(args.onNavigateToMessage).not.toHaveBeenCalled();
+ },
+};
+
+export const LongQuote: Story = {
+ args: {
+ source: {
+ status: 'available',
+ messageId: 'long-source',
+ authorName: 'A colleague with a longer display name',
+ excerpt:
+ 'The procurement team asked for a security review before the renewal. Please include the latest documentation and the account owner in the next update.',
+ },
+ },
+ parameters: { container: { width: 280 } },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatTypingIndicator.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatTypingIndicator.stories.tsx
new file mode 100644
index 00000000000..7f2aa5f9956
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatTypingIndicator.stories.tsx
@@ -0,0 +1,60 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, userEvent, within } from 'storybook/test';
+import { Button } from 'twenty-ui/primitives/input';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+import { AiChatTypingIndicator } from '@/ai/components/AiChatTypingIndicator';
+
+const meta: Meta<typeof AiChatTypingIndicator> = {
+ title: 'Modules/AI/AiChatTypingIndicator',
+ component: AiChatTypingIndicator,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 400 } },
+};
+
+export default meta;
+type Story = StoryObj<typeof AiChatTypingIndicator>;
+
+export const OneParticipant: Story = {
+ args: { participants: [{ id: 'sarah', name: 'Sarah' }] },
+};
+
+export const MultipleParticipants: Story = {
+ args: {
+ participants: [
+ { id: 'sarah', name: 'Sarah' },
+ { id: 'marco', name: 'Marco' },
+ ],
+ },
+};
+
+export const Empty: Story = {
+ args: { participants: [] },
+};
+
+const TypingEndsFixture = () => {
+ const [participants, setParticipants] = useState([
+ { id: 'sarah', name: 'Sarah' },
+ ]);
+
+ return (
+ <>
+ <AiChatTypingIndicator participants={participants} />
+ <Button onClick={() => setParticipants([])}>Stop typing</Button>
+ </>
+ );
+};
+
+export const TypingEnds: Story = {
+ render: () => <TypingEndsFixture />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Sarah is typing…',
+ );
+ await userEvent.click(canvas.getByRole('button', { name: 'Stop typing' }));
+ await expect(canvas.queryByRole('status')).not.toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatMessage.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatMessage.test.tsx
index 796868bad81..851e943f021 100644
--- a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatMessage.test.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatMessage.test.tsx
@@ -4,6 +4,7 @@ import { render, screen } from '@testing-library/react';
import { Provider as JotaiProvider } from 'jotai';
import { type ExtendedUIMessage } from 'twenty-shared/ai';
import { SOURCE_LOCALE } from 'twenty-shared/translations';
+import { isDefined } from 'twenty-shared/utils';
import { AiChatMessage } from '@/ai/components/AiChatMessage';
import { agentChatDisplayedThreadState } from '@/ai/states/agentChatDisplayedThreadState';
@@ -17,7 +18,10 @@ import {
} from '@/ui/utilities/state/jotai/jotaiStore';
import { FeatureFlagKey } from '~/generated-metadata/graphql';
import { messages } from '~/locales/generated/en';
-import { mockCurrentWorkspace } from '~/testing/mock-data/users';
+import {
+ mockCurrentWorkspace,
+ mockedWorkspaceMemberData,
+} from '~/testing/mock-data/users';
i18n.load({ [SOURCE_LOCALE]: messages });
i18n.activate(SOURCE_LOCALE);
@@ -68,6 +72,15 @@ const ASSISTANT_MESSAGE: ExtendedUIMessage = {
metadata: { createdAt: '2026-10-15T08:00:05.000Z' },
};
+const NAMED_ASSISTANT_MESSAGE: ExtendedUIMessage = {
+ ...ASSISTANT_MESSAGE,
+ id: 'named-assistant-message',
+ metadata: {
+ ...ASSISTANT_MESSAGE.metadata,
+ senderWorkspaceMemberId: MEMBER_ID,
+ },
+};
+
const SILENT_MESSAGE: ExtendedUIMessage = {
id: 'silent-message',
role: 'assistant',
@@ -93,12 +106,20 @@ const MESSAGE_WITHOUT_SENDER: ExtendedUIMessage = {
const renderMessage = ({
messageId,
isAiChatInboxEnabled,
+ currentWorkspaceMemberId,
error,
}: {
messageId: string;
isAiChatInboxEnabled: boolean;
+ currentWorkspaceMemberId?: string;
error?: Error;
}) => {
+ jotaiStore.set(
+ currentWorkspaceMemberState.atom,
+ isDefined(currentWorkspaceMemberId)
+ ? { ...mockedWorkspaceMemberData, id: currentWorkspaceMemberId }
+ : null,
+ );
jotaiStore.set(currentWorkspaceState.atom, {
...mockCurrentWorkspace,
featureFlags: [
@@ -122,7 +143,13 @@ const renderMessage = ({
jotaiStore.set(agentChatDisplayedThreadState.atom, THREAD_ID);
jotaiStore.set(
agentChatMessagesFamilyState.atomFamily({ threadId: THREAD_ID }),
- [USER_MESSAGE, ASSISTANT_MESSAGE, SILENT_MESSAGE, MESSAGE_WITHOUT_SENDER],
+ [
+ USER_MESSAGE,
+ ASSISTANT_MESSAGE,
+ NAMED_ASSISTANT_MESSAGE,
+ SILENT_MESSAGE,
+ MESSAGE_WITHOUT_SENDER,
+ ],
);
return render(
@@ -149,25 +176,74 @@ describe('AiChatMessage', () => {
).toBeInTheDocument();
});
- it('heads an assistant answer with the assistant name', () => {
+ it('shows the current member inbox message time without a sender header', () => {
+ renderMessage({
+ messageId: USER_MESSAGE.id,
+ isAiChatInboxEnabled: true,
+ currentWorkspaceMemberId: MEMBER_ID,
+ });
+
+ expect(
+ screen.getByText('Which deals close this week?'),
+ ).toBeInTheDocument();
+ expect(screen.queryByText('You')).not.toBeInTheDocument();
+ expect(screen.queryByText('Julia Martin')).not.toBeInTheDocument();
+ expect(screen.getAllByText(/ago$/)).toHaveLength(1);
+ });
+
+ it('keeps another member name and one timestamp when signed in', () => {
+ renderMessage({
+ messageId: USER_MESSAGE.id,
+ isAiChatInboxEnabled: true,
+ currentWorkspaceMemberId: 'other-workspace-member',
+ });
+
+ expect(screen.getByText('Julia Martin')).toBeInTheDocument();
+ expect(screen.getAllByText(/ago$/)).toHaveLength(1);
+ });
+
+ it('keeps the current member message time outside the inbox', () => {
+ renderMessage({
+ messageId: USER_MESSAGE.id,
+ isAiChatInboxEnabled: false,
+ currentWorkspaceMemberId: MEMBER_ID,
+ });
+
+ expect(
+ screen.getByText('Which deals close this week?'),
+ ).toBeInTheDocument();
+ expect(screen.getAllByText(/ago$/)).toHaveLength(1);
+ });
+
+ it('uses a neutral label when an assistant sender is not identified', () => {
renderMessage({
messageId: ASSISTANT_MESSAGE.id,
isAiChatInboxEnabled: true,
});
- expect(screen.getByText('Ada')).toBeInTheDocument();
+ expect(screen.getByText('Assistant')).toBeInTheDocument();
expect(
screen.getByText('Five deals are in the final stage.'),
).toBeInTheDocument();
});
+ it('preserves a known sender on an assistant-role message', () => {
+ renderMessage({
+ messageId: NAMED_ASSISTANT_MESSAGE.id,
+ isAiChatInboxEnabled: true,
+ });
+
+ expect(screen.getByText('Julia Martin')).toBeInTheDocument();
+ expect(screen.queryByText('Assistant')).not.toBeInTheDocument();
+ });
+
it('keeps the assistant unnamed without the inbox', () => {
renderMessage({
messageId: ASSISTANT_MESSAGE.id,
isAiChatInboxEnabled: false,
});
- expect(screen.queryByText('Ada')).not.toBeInTheDocument();
+ expect(screen.queryByText('Assistant')).not.toBeInTheDocument();
});
it('keeps the time of a member message whose sender is unknown', () => {
@@ -179,6 +255,7 @@ describe('AiChatMessage', () => {
expect(
screen.getByText('Draft the October newsletter'),
).toBeInTheDocument();
+ expect(screen.getByText('Unknown sender')).toBeInTheDocument();
expect(screen.getByText(/ago$/)).toBeInTheDocument();
});
diff --git a/packages/twenty-front/src/modules/ai/components/internal/AiChatToolCallApprovalCardLayout.tsx b/packages/twenty-front/src/modules/ai/components/internal/AiChatToolCallApprovalCardLayout.tsx
index f36ea3128d7..254ff3d17c4 100644
--- a/packages/twenty-front/src/modules/ai/components/internal/AiChatToolCallApprovalCardLayout.tsx
+++ b/packages/twenty-front/src/modules/ai/components/internal/AiChatToolCallApprovalCardLayout.tsx
@@ -4,7 +4,7 @@ import { type ReactNode } from 'react';
import { LightButton } from 'twenty-ui/components/input';
import { themeCssVariables } from 'twenty-ui/theme';
-import { StyledAiChatAskCard } from '@/ai/components/AiChatAskStyledComponents';
+import { StyledAiChatAskCard } from '@/ai/components/StyledAiChatAskCard';
import { TextWithChatReferences } from '@/ai/components/TextWithChatReferences';
import { AiChatToolCallApprovalFeedbackInput } from '@/ai/components/internal/AiChatToolCallApprovalFeedbackInput';
import { useAiChatAskCardFieldFocus } from '@/ai/hooks/useAiChatAskCardFieldFocus';
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatQuickReactionEmojis.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatQuickReactionEmojis.ts
index b843627eb29..13d0016be99 100644
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatQuickReactionEmojis.ts
+++ b/packages/twenty-front/src/modules/ai/constants/AgentChatQuickReactionEmojis.ts
@@ -1,8 +1,8 @@
export const AGENT_CHAT_QUICK_REACTION_EMOJIS = [
'πŸ‘',
- '❀️',
- 'πŸ˜‚',
- 'πŸŽ‰',
'πŸ‘€',
+ 'βœ…',
+ 'πŸŽ‰',
'πŸ™',
+ 'πŸ˜‚',
];
diff --git a/packages/twenty-front/src/modules/ai/states/selectors/agentChatFirstUnreadMessageIdSelector.ts b/packages/twenty-front/src/modules/ai/states/selectors/agentChatFirstUnreadMessageIdSelector.ts
index 43bcab0a8d9..1f930196c79 100644
--- a/packages/twenty-front/src/modules/ai/states/selectors/agentChatFirstUnreadMessageIdSelector.ts
+++ b/packages/twenty-front/src/modules/ai/states/selectors/agentChatFirstUnreadMessageIdSelector.ts
@@ -5,6 +5,7 @@ import { agentChatDisplayedThreadState } from '@/ai/states/agentChatDisplayedThr
import { agentChatThreadVisitState } from '@/ai/states/agentChatThreadVisitState';
import { agentChatDisplayedThreadMessagesSelector } from '@/ai/states/selectors/agentChatDisplayedThreadMessagesSelector';
import { agentChatThreadRecordFamilySelector } from '@/ai/states/selectors/agentChatThreadRecordFamilySelector';
+import { isAgentChatMessageOwn } from '@/ai/utils/isAgentChatMessageOwn';
import { isSilentAgentChatMessage } from '@/ai/utils/isSilentAgentChatMessage';
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
import { createAtomSelector } from '@/ui/utilities/state/jotai/utils/createAtomSelector';
@@ -53,12 +54,11 @@ export const agentChatFirstUnreadMessageIdSelector = createAtomSelector<
}
if (message.role === AGENT_MESSAGE_ROLE.USER) {
- const senderWorkspaceMemberId =
- message.metadata?.senderWorkspaceMemberId;
-
- const isOwnMessage = isDefined(senderWorkspaceMemberId)
- ? senderWorkspaceMemberId === currentWorkspaceMember?.id
- : isSenderlessMessageOwn;
+ const isOwnMessage = isAgentChatMessageOwn({
+ message,
+ currentWorkspaceMemberId: currentWorkspaceMember?.id,
+ isSenderlessUserMessageOwn: isSenderlessMessageOwn,
+ });
if (isOwnMessage) {
return false;
diff --git a/packages/twenty-front/src/modules/ai/types/AiChatQuotedMessageSource.ts b/packages/twenty-front/src/modules/ai/types/AiChatQuotedMessageSource.ts
new file mode 100644
index 00000000000..089cdd5cf14
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/types/AiChatQuotedMessageSource.ts
@@ -0,0 +1,11 @@
+import { type ReactNode } from 'react';
+
+export type AiChatQuotedMessageSource =
+ | {
+ status: 'available';
+ messageId: string;
+ authorName: string;
+ authorAvatar?: ReactNode;
+ excerpt: string;
+ }
+ | { status: 'unavailable' };
diff --git a/packages/twenty-front/src/modules/ai/types/MarkdownDisplayMode.ts b/packages/twenty-front/src/modules/ai/types/MarkdownDisplayMode.ts
new file mode 100644
index 00000000000..da881527057
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/types/MarkdownDisplayMode.ts
@@ -0,0 +1 @@
+export type MarkdownDisplayMode = 'default' | 'chat' | 'bubble';
diff --git a/packages/twenty-front/src/modules/ai/utils/__tests__/isAgentChatMessageOwn.test.ts b/packages/twenty-front/src/modules/ai/utils/__tests__/isAgentChatMessageOwn.test.ts
new file mode 100644
index 00000000000..e67da1f64ce
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/utils/__tests__/isAgentChatMessageOwn.test.ts
@@ -0,0 +1,77 @@
+import { type ExtendedUIMessage } from 'twenty-shared/ai';
+
+import { isAgentChatMessageOwn } from '@/ai/utils/isAgentChatMessageOwn';
+
+const CURRENT_WORKSPACE_MEMBER_ID = 'current-workspace-member';
+const OTHER_WORKSPACE_MEMBER_ID = 'other-workspace-member';
+
+type MessageOwnershipTestCase = {
+ name: string;
+ role: ExtendedUIMessage['role'];
+ senderWorkspaceMemberId?: string | null;
+ isSenderlessUserMessageOwn: boolean;
+ expected: boolean;
+};
+
+const TEST_CASES: MessageOwnershipTestCase[] = [
+ {
+ name: 'retains ownership of legacy user messages when the fallback is enabled',
+ role: 'user',
+ isSenderlessUserMessageOwn: true,
+ expected: true,
+ },
+ {
+ name: 'keeps unknown inbox senders distinct from the current member',
+ role: 'user',
+ senderWorkspaceMemberId: null,
+ isSenderlessUserMessageOwn: false,
+ expected: false,
+ },
+ {
+ name: 'does not assign unidentified assistant messages to the current member',
+ role: 'assistant',
+ isSenderlessUserMessageOwn: true,
+ expected: false,
+ },
+ {
+ name: 'does not override another member with the legacy fallback',
+ role: 'user',
+ senderWorkspaceMemberId: OTHER_WORKSPACE_MEMBER_ID,
+ isSenderlessUserMessageOwn: true,
+ expected: false,
+ },
+ {
+ name: 'recognizes a known current-member sender in the inbox',
+ role: 'user',
+ senderWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isSenderlessUserMessageOwn: false,
+ expected: true,
+ },
+ {
+ name: 'preserves known authorship on assistant-role messages',
+ role: 'assistant',
+ senderWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isSenderlessUserMessageOwn: false,
+ expected: true,
+ },
+];
+
+describe('isAgentChatMessageOwn', () => {
+ it.each(TEST_CASES)(
+ '$name',
+ ({
+ role,
+ senderWorkspaceMemberId,
+ isSenderlessUserMessageOwn,
+ expected,
+ }) => {
+ expect(
+ isAgentChatMessageOwn({
+ message: { role, metadata: { senderWorkspaceMemberId } },
+ currentWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isSenderlessUserMessageOwn,
+ }),
+ ).toBe(expected);
+ },
+ );
+});
diff --git a/packages/twenty-front/src/modules/ai/utils/__tests__/isAgentChatQueuedMessageRemovable.test.ts b/packages/twenty-front/src/modules/ai/utils/__tests__/isAgentChatQueuedMessageRemovable.test.ts
new file mode 100644
index 00000000000..5d5c7b727de
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/utils/__tests__/isAgentChatQueuedMessageRemovable.test.ts
@@ -0,0 +1,115 @@
+import { type ExtendedUIMessage } from 'twenty-shared/ai';
+
+import { isAgentChatQueuedMessageRemovable } from '@/ai/utils/isAgentChatQueuedMessageRemovable';
+
+const CURRENT_WORKSPACE_MEMBER_ID = 'current-workspace-member';
+const OWN_MESSAGE = {
+ role: 'user',
+ metadata: { senderWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID },
+} satisfies Pick<ExtendedUIMessage, 'role' | 'metadata'>;
+const OTHER_MEMBER_MESSAGE = {
+ role: 'user',
+ metadata: { senderWorkspaceMemberId: 'other-workspace-member' },
+} satisfies Pick<ExtendedUIMessage, 'role' | 'metadata'>;
+const SENDERLESS_MESSAGE = {
+ role: 'user',
+} satisfies Pick<ExtendedUIMessage, 'role' | 'metadata'>;
+
+type QueuedMessageRemovalTestCase = Parameters<
+ typeof isAgentChatQueuedMessageRemovable
+>[0] & {
+ description: string;
+ expected: boolean;
+};
+
+const TEST_CASES: QueuedMessageRemovalTestCase[] = [
+ {
+ description: 'allows an inbox writer to remove their own queued message',
+ message: OWN_MESSAGE,
+ currentWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isAiChatInboxEnabled: true,
+ isReadOnly: false,
+ expected: true,
+ },
+ {
+ description:
+ 'prevents an inbox writer from removing another member message',
+ message: OTHER_MEMBER_MESSAGE,
+ currentWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isAiChatInboxEnabled: true,
+ isReadOnly: false,
+ expected: false,
+ },
+ {
+ description: 'keeps senderless inbox messages non-removable',
+ message: SENDERLESS_MESSAGE,
+ currentWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isAiChatInboxEnabled: true,
+ isReadOnly: false,
+ expected: false,
+ },
+ {
+ description:
+ 'requires a known current member before allowing inbox removal',
+ message: OWN_MESSAGE,
+ currentWorkspaceMemberId: undefined,
+ isAiChatInboxEnabled: true,
+ isReadOnly: false,
+ expected: false,
+ },
+ {
+ description: 'preserves legacy writer removal for another member message',
+ message: OTHER_MEMBER_MESSAGE,
+ currentWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isAiChatInboxEnabled: false,
+ isReadOnly: false,
+ expected: true,
+ },
+ {
+ description: 'preserves legacy writer removal without sender metadata',
+ message: SENDERLESS_MESSAGE,
+ currentWorkspaceMemberId: undefined,
+ isAiChatInboxEnabled: false,
+ isReadOnly: false,
+ expected: true,
+ },
+ {
+ description:
+ 'prevents a read-only inbox member from removing their own message',
+ message: OWN_MESSAGE,
+ currentWorkspaceMemberId: CURRENT_WORKSPACE_MEMBER_ID,
+ isAiChatInboxEnabled: true,
+ isReadOnly: true,
+ expected: false,
+ },
+ {
+ description: 'prevents read-only removal when the inbox is disabled',
+ message: SENDERLESS_MESSAGE,
+ currentWorkspaceMemberId: undefined,
+ isAiChatInboxEnabled: false,
+ isReadOnly: true,
+ expected: false,
+ },
+];
+
+describe('isAgentChatQueuedMessageRemovable', () => {
+ it.each(TEST_CASES)(
+ '$description',
+ ({
+ message,
+ currentWorkspaceMemberId,
+ isAiChatInboxEnabled,
+ isReadOnly,
+ expected,
+ }) => {
+ expect(
+ isAgentChatQueuedMessageRemovable({
+ message,
+ currentWorkspaceMemberId,
+ isAiChatInboxEnabled,
+ isReadOnly,
+ }),
+ ).toBe(expected);
+ },
+ );
+});
diff --git a/packages/twenty-front/src/modules/ai/utils/isAgentChatMessageOwn.ts b/packages/twenty-front/src/modules/ai/utils/isAgentChatMessageOwn.ts
new file mode 100644
index 00000000000..2f17592354c
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/utils/isAgentChatMessageOwn.ts
@@ -0,0 +1,22 @@
+import { type ExtendedUIMessage } from 'twenty-shared/ai';
+import { isDefined } from 'twenty-shared/utils';
+
+import { AGENT_MESSAGE_ROLE } from '@/ai/constants/AgentMessageRole';
+
+export const isAgentChatMessageOwn = ({
+ message,
+ currentWorkspaceMemberId,
+ isSenderlessUserMessageOwn,
+}: {
+ message: Pick<ExtendedUIMessage, 'role' | 'metadata'>;
+ currentWorkspaceMemberId: string | undefined;
+ isSenderlessUserMessageOwn: boolean;
+}) => {
+ const senderWorkspaceMemberId = message.metadata?.senderWorkspaceMemberId;
+
+ if (isDefined(senderWorkspaceMemberId)) {
+ return senderWorkspaceMemberId === currentWorkspaceMemberId;
+ }
+
+ return message.role === AGENT_MESSAGE_ROLE.USER && isSenderlessUserMessageOwn;
+};
diff --git a/packages/twenty-front/src/modules/ai/utils/isAgentChatQueuedMessageRemovable.ts b/packages/twenty-front/src/modules/ai/utils/isAgentChatQueuedMessageRemovable.ts
new file mode 100644
index 00000000000..0f042e8f3bd
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/utils/isAgentChatQueuedMessageRemovable.ts
@@ -0,0 +1,31 @@
+import { type ExtendedUIMessage } from 'twenty-shared/ai';
+
+import { isAgentChatMessageOwn } from '@/ai/utils/isAgentChatMessageOwn';
+
+type IsAgentChatQueuedMessageRemovableParams = {
+ message: Pick<ExtendedUIMessage, 'role' | 'metadata'>;
+ currentWorkspaceMemberId: string | undefined;
+ isAiChatInboxEnabled: boolean;
+ isReadOnly: boolean;
+};
+
+export const isAgentChatQueuedMessageRemovable = ({
+ message,
+ currentWorkspaceMemberId,
+ isAiChatInboxEnabled,
+ isReadOnly,
+}: IsAgentChatQueuedMessageRemovableParams) => {
+ if (isReadOnly) {
+ return false;
+ }
+
+ if (!isAiChatInboxEnabled) {
+ return true;
+ }
+
+ return isAgentChatMessageOwn({
+ message,
+ currentWorkspaceMemberId,
+ isSenderlessUserMessageOwn: false,
+ });
+};
diff --git a/packages/twenty-ui/.size-limit.json b/packages/twenty-ui/.size-limit.json
index 155f70b8ef8..fad71533081 100644
--- a/packages/twenty-ui/.size-limit.json
+++ b/packages/twenty-ui/.size-limit.json
@@ -13,7 +13,7 @@
{
"name": "components",
"path": "dist/components.mjs",
- "limit": "161 kB"
+ "limit": "166 kB"
},
{
"name": "components/code-editor",
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 226ecd774d8..e0865613eb3 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -9,6 +9,7 @@ import { COUNTRY_SELECT_PROP_DESCRIPTIONS } from './countrySelectPropDescription
import { COUNTRY_SELECT_PART_PROP_DESCRIPTIONS } from './countrySelectPartPropDescriptions';
import { CURRENCY_PICKER_PART_PROP_DESCRIPTIONS } from './currencyPickerPartPropDescriptions';
import { CURRENCY_PICKER_PROP_DESCRIPTIONS } from './currencyPickerPropDescriptions';
+import { COUNT_PAGER_PROP_DESCRIPTIONS } from './countPagerPropDescriptions';
import { OVERFLOWING_LIST_PROP_DESCRIPTIONS } from './overflowingListPropDescriptions';
import { METRIC_ROW_PROP_DESCRIPTIONS } from './metricRowPropDescriptions';
import { DETAILS_ROW_PROP_DESCRIPTIONS } from './detailsRowPropDescriptions';
@@ -68,6 +69,7 @@ import { SEPARATOR_PROP_DESCRIPTIONS } from './separatorPropDescriptions';
import { ICON_BUTTON_PROP_DESCRIPTIONS } from './iconButtonPropDescriptions';
import { LIGHT_BUTTON_PROP_DESCRIPTIONS } from './lightButtonPropDescriptions';
import { REACTION_BUTTON_PROP_DESCRIPTIONS } from './reactionButtonPropDescriptions';
+import { EMOJI_PICKER_PROP_DESCRIPTIONS } from './emojiPickerPropDescriptions';
import { LIGHT_ICON_BUTTON_PROP_DESCRIPTIONS } from './lightIconButtonPropDescriptions';
import { LOADER_PROP_DESCRIPTIONS } from './loaderPropDescriptions';
import { SKELETON_PROP_DESCRIPTIONS } from './skeletonPropDescriptions';
@@ -343,6 +345,18 @@ export const DOCUMENTED_COMPONENTS = [
propDescriptions: LIGHT_BUTTON_PROP_DESCRIPTIONS,
propDefaults: { variant: 'ghost', size: 'sm' },
},
+ {
+ name: 'EmojiPicker',
+ source: 'components/input/EmojiPicker/EmojiPicker.tsx',
+ entryPoint: 'twenty-ui/components/input',
+ slug: 'components/input/emoji-picker',
+ propDescriptions: EMOJI_PICKER_PROP_DESCRIPTIONS,
+ propDefaults: {
+ locale: 'en',
+ searchPlaceholder: 'searchLabel',
+ autoFocus: 'false',
+ },
+ },
{
name: 'ReactionButton',
source: 'components/input/ReactionButton/ReactionButton.tsx',
@@ -921,6 +935,18 @@ export const DOCUMENTED_COMPONENTS = [
},
propDefaults: { type: 'button', disabled: 'false' },
},
+ {
+ name: 'CountPager',
+ source: 'components/navigation/CountPager/CountPager.tsx',
+ entryPoint: 'twenty-ui/components/navigation',
+ slug: 'components/navigation/count-pager',
+ propDescriptions: COUNT_PAGER_PROP_DESCRIPTIONS,
+ propDefaults: {
+ disabled: 'false',
+ positionPlacement: 'between',
+ role: 'group',
+ },
+ },
{
name: 'TabButton',
source: 'components/navigation/TabButton/TabButton.tsx',
diff --git a/packages/twenty-ui/docs/countPagerPropDescriptions.ts b/packages/twenty-ui/docs/countPagerPropDescriptions.ts
new file mode 100644
index 00000000000..7e5c63505c8
--- /dev/null
+++ b/packages/twenty-ui/docs/countPagerPropDescriptions.ts
@@ -0,0 +1,23 @@
+import { type CountPagerProps } from '../src/components/navigation/CountPager/types/CountPagerProps';
+
+export const COUNT_PAGER_PROP_DESCRIPTIONS = {
+ index:
+ 'Controlled zero-based item index. Navigation is disabled when the index is not an integer within the collection bounds.',
+ count:
+ 'Number of items in the collection. Empty collections and invalid or noninteger counts disable navigation.',
+ onIndexChange:
+ 'Requests the neighboring index after activating Previous or Next. Prop changes do not call this callback or select a replacement item.',
+ positionText:
+ 'Caller-formatted position text, announced politely when it changes. The caller also supplies text for empty collections.',
+ previousLabel: 'Accessible name of the Previous button.',
+ nextLabel: 'Accessible name of the Next button.',
+ disabled:
+ 'Disables both navigation buttons without changing the position text.',
+ positionPlacement:
+ 'Places the position text between the buttons or at the start of the row. Start placement lets the text fill the available width.',
+ render: 'Replaces the root element while preserving its props and contents.',
+ ref: 'Ref to the root element.',
+ className: 'CSS class applied to the root element.',
+ style: 'Inline styles applied to the root element.',
+ role: 'Root semantics. Defaults to a group; the caller supplies its accessible name.',
+} satisfies Partial<Record<keyof CountPagerProps, string>>;
diff --git a/packages/twenty-ui/docs/emojiPickerPropDescriptions.ts b/packages/twenty-ui/docs/emojiPickerPropDescriptions.ts
new file mode 100644
index 00000000000..05030a82bfb
--- /dev/null
+++ b/packages/twenty-ui/docs/emojiPickerPropDescriptions.ts
@@ -0,0 +1,20 @@
+import { type EmojiPickerProps } from '../src/components/input/EmojiPicker/types/EmojiPickerProps';
+
+export const EMOJI_PICKER_PROP_DESCRIPTIONS = {
+ emojibaseUrl:
+ 'Base URL for caller-hosted Emojibase data. The picker loads data.json and messages.json from the selected locale directory.',
+ locale:
+ 'Emoji catalogue locale. The caller must host its data and message files. Interface labels are supplied separately.',
+ searchLabel:
+ 'Accessible name for the search input. Also supplies its placeholder unless searchPlaceholder is set.',
+ searchPlaceholder: 'Optional placeholder overriding the search label.',
+ loadingLabel: 'Caller-supplied message displayed while emoji data loads.',
+ emptyLabel:
+ 'Caller-supplied message displayed when no emoji matches the search.',
+ onEmojiSelect:
+ 'Called with the selected Unicode emoji string. The application owns the selected value, persistence, and popup visibility.',
+ autoFocus: 'Focuses the search input when the picker mounts.',
+ className: 'Additional class name applied to the picker root div.',
+ style: 'Native inline styles applied to the picker root div.',
+ ref: 'Ref for the picker root div.',
+} satisfies Partial<Record<keyof EmojiPickerProps, string>>;
diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.md
index a97c7283e3f..3be15a87128 100644
--- a/packages/twenty-ui/docs/label-ownership.md
+++ b/packages/twenty-ui/docs/label-ownership.md
@@ -11,10 +11,12 @@ This covers production exports under components, primitives, and icons, includin
| CurrencyPicker | Caller-owned catalogue, option content, selected content, placeholders, and trigger and popup names. `searchLabel` defaults to `Search`; native `searchProps` can override its attributes. `emptyLabel` defaults to `No results`. The listbox inherits the registered Dropdown title or trigger name; `listLabel` names only that selection listbox. Native Options accessible labels stay on its own wrapper div. |
| Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Badge. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button hints use the shared Shortcut presentation and remain decorative. `shortcutJoinLabel` supplies the sequence join label. |
| IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |
+| CountPager | Caller-owned `positionText`, `previousLabel`, `nextLabel`, and native group names. Position text is announced politely when it changes. The caller formats counts, supplies empty-state text, and owns translations. |
| ReactionButton | Caller-supplied emoji, count formatting, accessible name, and optional native title or composed Tooltip content. The emoji and count are decorative; `pressed` supplies the accessible selection state. |
| SearchInput | Caller-owned placeholder, native accessible name and action labels. Referenced labels take precedence over explicit labels and placeholder fallback. |
| CountrySelect | Root owns caller-supplied country labels and `noCountryLabel` (default `No country`). Trigger accepts `label`, native accessible names, and custom children. Options owns `searchLabel` (default `Search`) and `noResultsLabel` (default `No results`). The shorthand exposes the same labels. Applications own translations, stable identifiers, and persistence conversions. |
| PhoneCountryPicker | Callers supply country labels and the trigger name. The selected label describes the trigger; the popup uses its trigger name unless named explicitly. Options defaults are `Search` (`searchLabel`), `Countries` (`listLabel`) and `No results` (`emptyLabel`), also available through shorthand `optionsProps`. Calling codes omit the plus sign in caller data and display with LTR isolation. |
+| EmojiPicker | Caller-supplied `searchLabel`, `searchPlaceholder`, `loadingLabel`, and `emptyLabel`. Emoji names, categories, and search tags come from the caller-selected Emojibase locale. Applications supply the data URL, translations, selection handling, and popup lifecycle. |
| ImageInput | `uploadLabel`, `removeLabel`, and `abortLabel` default to `Upload`, `Remove`, and `Abort`. The upload label names the visible upload button, preview button, and hidden file input. Native accessible attributes can supply names and descriptions for the file input. Applications supply `helperText` and `errorMessage`, including validation instructions and translated strings. |
| Toast and Toaster | Caller-owned children, description, icon, action, and `cancelLabel` nodes (default `Cancel`), plus `iconLabel` and `closeLabel` (default `Close`). Live updates replace only supplied fields. Toaster accepts native accessible attributes over its `Notifications` region default. Multiple Toasters mirror one provider-owned notification lifecycle; each region owns its accessible name. |
| Chip and Avatar | Chip content, translated fallbacks and interactive accessible names belong to the caller. Missing children add no label. Avatar's image and default fallback are decorative. `name` supplies the visual initial and colors. Explicit `imageProps.alt` labels the image and default fallback; caller fallback semantics take precedence. Composed buttons and links own their labels and interaction handlers. |
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index d08b3dbd2eb..d7b4830a381 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -52,10 +52,12 @@
"CodeEditor",
"CodeEditorHeader",
"CommandBlock",
+ "CountPager",
"CountrySelect",
"CurrencyPicker",
"DetailsRow",
"Dropdown",
+ "EmojiPicker",
"FormFieldRow",
"IconButton",
"ImageInput",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 9cb0ab562d8..e43dc826c48 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -92,6 +92,7 @@
"values": {
"CountrySelect": "components/input/CountrySelect/CountrySelect",
"CurrencyPicker": "components/input/CurrencyPicker/CurrencyPicker",
+ "EmojiPicker": "components/input/EmojiPicker/EmojiPicker",
"FormFieldRow": "components/input/FormFieldRow/FormFieldRow",
"IconButton": "components/input/IconButton/IconButton",
"ImageInput": "components/input/ImageInput/ImageInput",
@@ -118,6 +119,7 @@
"CurrencyPickerRootProps": "components/input/CurrencyPicker/types/CurrencyPickerRootProps",
"CurrencyPickerState": "components/input/CurrencyPicker/types/CurrencyPickerState",
"CurrencyPickerTriggerProps": "components/input/CurrencyPicker/types/CurrencyPickerTriggerProps",
+ "EmojiPickerProps": "components/input/EmojiPicker/types/EmojiPickerProps",
"FormFieldRowProps": "components/input/FormFieldRow/types/FormFieldRowProps",
"IconButtonProps": "components/input/IconButton/types/IconButtonProps",
"IconButtonSize": "components/input/IconButton/types/IconButtonSize",
@@ -155,6 +157,7 @@
"components/navigation": {
"reExports": [],
"values": {
+ "CountPager": "components/navigation/CountPager/CountPager",
"DEFAULT_COLOR_LABELS": "components/navigation/MenuItem/constants/DefaultColorLabels",
"Dropdown": "components/navigation/Dropdown/Dropdown",
"ListItemButton": "components/navigation/ListItemButton/ListItemButton",
@@ -163,6 +166,7 @@
},
"types": {
"ColorLabels": "components/navigation/MenuItem/types/ColorLabels",
+ "CountPagerProps": "components/navigation/CountPager/types/CountPagerProps",
"DropdownActionItemProps": "components/navigation/Dropdown/types/DropdownActionItemProps",
"DropdownCloseProps": "components/navigation/Dropdown/types/DropdownCloseProps",
"DropdownContentProps": "components/navigation/Dropdown/types/DropdownContentProps",
@@ -317,6 +321,7 @@
"IconCompass": "icon/components/TablerIcons",
"IconCopy": "icon/components/TablerIcons",
"IconCopyPlus": "icon/components/TablerIcons",
+ "IconCornerDownRight": "icon/components/TablerIcons",
"IconCpu": "icon/components/TablerIcons",
"IconCreativeCommonsSa": "icon/components/TablerIcons",
"IconCreditCard": "icon/components/TablerIcons",
@@ -414,6 +419,7 @@
"IconFolderRoot": "icon/components/TablerIcons",
"IconFolderSymlink": "icon/components/TablerIcons",
"IconForbid": "icon/components/TablerIcons",
+ "IconForms": "icon/components/TablerIcons",
"IconFrame": "icon/components/TablerIcons",
"IconFunction": "icon/components/TablerIcons",
"IconGauge": "icon/components/TablerIcons",
@@ -512,6 +518,7 @@
"IconMinus": "icon/components/TablerIcons",
"IconModelClaude": "icon/components/IconModelClaude",
"IconMoneybag": "icon/components/TablerIcons",
+ "IconMoodPlus": "icon/components/TablerIcons",
"IconMoodSmile": "icon/components/TablerIcons",
"IconMoon": "icon/components/TablerIcons",
"IconMouse2": "icon/components/TablerIcons",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 81d57232849..25b998cfa7b 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -3239,6 +3239,90 @@
}
]
},
+ {
+ "name": "EmojiPicker",
+ "entryPoint": "twenty-ui/components/input",
+ "slug": "components/input/emoji-picker",
+ "props": [
+ {
+ "name": "autoFocus",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Focuses the search input when the picker mounts."
+ },
+ {
+ "name": "className",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Additional class name applied to the picker root div."
+ },
+ {
+ "name": "emojibaseUrl",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Base URL for caller-hosted Emojibase data. The picker loads data.json and messages.json from the selected locale directory."
+ },
+ {
+ "name": "emptyLabel",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Caller-supplied message displayed when no emoji matches the search."
+ },
+ {
+ "name": "loadingLabel",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Caller-supplied message displayed while emoji data loads."
+ },
+ {
+ "name": "locale",
+ "type": "string",
+ "required": false,
+ "defaultValue": "en",
+ "description": "Emoji catalogue locale. The caller must host its data and message files. Interface labels are supplied separately."
+ },
+ {
+ "name": "onEmojiSelect",
+ "type": "(emoji: string) => void",
+ "required": true,
+ "defaultValue": null,
+ "description": "Called with the selected Unicode emoji string. The application owns the selected value, persistence, and popup visibility."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref for the picker root div."
+ },
+ {
+ "name": "searchLabel",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Accessible name for the search input. Also supplies its placeholder unless searchPlaceholder is set."
+ },
+ {
+ "name": "searchPlaceholder",
+ "type": "string",
+ "required": false,
+ "defaultValue": "searchLabel",
+ "description": "Optional placeholder overriding the search label."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
+ "required": false,
+ "defaultValue": null,
+ "description": "Native inline styles applied to the picker root div."
+ }
+ ]
+ },
{
"name": "ReactionButton",
"entryPoint": "twenty-ui/components/input",
@@ -13796,6 +13880,104 @@
}
]
},
+ {
+ "name": "CountPager",
+ "entryPoint": "twenty-ui/components/navigation",
+ "slug": "components/navigation/count-pager",
+ "props": [
+ {
+ "name": "className",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the root element."
+ },
+ {
+ "name": "count",
+ "type": "number",
+ "required": true,
+ "defaultValue": null,
+ "description": "Number of items in the collection. Empty collections and invalid or noninteger counts disable navigation."
+ },
+ {
+ "name": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Disables both navigation buttons without changing the position text."
+ },
+ {
+ "name": "index",
+ "type": "number",
+ "required": true,
+ "defaultValue": null,
+ "description": "Controlled zero-based item index. Navigation is disabled when the index is not an integer within the collection bounds."
+ },
+ {
+ "name": "nextLabel",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Accessible name of the Next button."
+ },
+ {
+ "name": "onIndexChange",
+ "type": "(index: number) => void",
+ "required": true,
+ "defaultValue": null,
+ "description": "Requests the neighboring index after activating Previous or Next. Prop changes do not call this callback or select a replacement item."
+ },
+ {
+ "name": "positionPlacement",
+ "type": "\"between\" | \"start\"",
+ "required": false,
+ "defaultValue": "between",
+ "description": "Places the position text between the buttons or at the start of the row. Start placement lets the text fill the available width."
+ },
+ {
+ "name": "positionText",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Caller-formatted position text, announced politely when it changes. The caller also supplies text for empty collections."
+ },
+ {
+ "name": "previousLabel",
+ "type": "string",
+ "required": true,
+ "defaultValue": null,
+ "description": "Accessible name of the Previous button."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the root element."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Replaces the root element while preserving its props and contents."
+ },
+ {
+ "name": "role",
+ "type": "AriaRole",
+ "required": false,
+ "defaultValue": "group",
+ "description": "Root semantics. Defaults to a group; the caller supplies its accessible name."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
+ "required": false,
+ "defaultValue": null,
+ "description": "Inline styles applied to the root element."
+ }
+ ]
+ },
{
"name": "TabButton",
"entryPoint": "twenty-ui/components/navigation",
diff --git a/packages/twenty-ui/generated/icons.docs.json b/packages/twenty-ui/generated/icons.docs.json
index e7dcef5ef13..35247283bd6 100644
--- a/packages/twenty-ui/generated/icons.docs.json
+++ b/packages/twenty-ui/generated/icons.docs.json
@@ -109,6 +109,7 @@
"IconCompass",
"IconCopy",
"IconCopyPlus",
+ "IconCornerDownRight",
"IconCpu",
"IconCreativeCommonsSa",
"IconCreditCard",
@@ -206,6 +207,7 @@
"IconFolderRoot",
"IconFolderSymlink",
"IconForbid",
+ "IconForms",
"IconFrame",
"IconFunction",
"IconGauge",
@@ -296,6 +298,7 @@
"IconMinimize",
"IconMinus",
"IconMoneybag",
+ "IconMoodPlus",
"IconMoodSmile",
"IconMoon",
"IconMouse2",
diff --git a/packages/twenty-ui/package.json b/packages/twenty-ui/package.json
index d5a431ce843..46a9b7b6c6e 100644
--- a/packages/twenty-ui/package.json
+++ b/packages/twenty-ui/package.json
@@ -51,6 +51,7 @@
"@vitejs/plugin-react-swc": "^4.3.1",
"@vitest/browser-playwright": "^4.1.0",
"esbuild": "^0.28.1",
+ "frimousse": "^0.4.0",
"glob": "^11.1.0",
"jsdom": "^30.0.1",
"lightningcss": "^1.32.0",
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.module.scss b/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.module.scss
new file mode 100644
index 00000000000..ee98f5f140d
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.module.scss
@@ -0,0 +1,50 @@
+.root {
+ display: flex;
+ flex-direction: column;
+ height: 280px;
+ width: 100%;
+
+ [frimousse-category-header] {
+ background: var(--t-background-primary);
+ color: var(--t-font-color-secondary);
+ font-size: var(--t-font-size-xs);
+ padding: var(--t-spacing-1) var(--t-spacing-2);
+ }
+
+ [frimousse-row] {
+ padding: 0 var(--t-spacing-1);
+ }
+
+ [frimousse-emoji] {
+ background: none;
+ border: none;
+ border-radius: var(--t-border-radius-sm);
+ cursor: pointer;
+ font-size: var(--t-font-size-lg);
+ height: var(--t-spacing-8);
+ width: var(--t-spacing-8);
+
+ &[data-active] {
+ background: var(--t-background-transparent-light);
+ }
+ }
+}
+
+.search {
+ margin: var(--t-spacing-2);
+}
+
+.viewport {
+ @include focus-ring;
+
+ flex: 1;
+ min-height: 0;
+}
+
+.message {
+ color: var(--t-font-color-secondary);
+ display: block;
+ font-size: var(--t-font-size-sm);
+ padding: var(--t-spacing-3);
+ text-align: center;
+}
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.module.scss.d.ts b/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.module.scss.d.ts
new file mode 100644
index 00000000000..fbd0e0616f5
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.module.scss.d.ts
@@ -0,0 +1,7 @@
+declare const classNames: {
+ readonly root: 'root';
+ readonly search: 'search';
+ readonly viewport: 'viewport';
+ readonly message: 'message';
+};
+export default classNames;
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.tsx
new file mode 100644
index 00000000000..5634cb1ed6c
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/EmojiPicker.tsx
@@ -0,0 +1,65 @@
+import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
+import { clsx } from 'clsx';
+import { EmojiPicker as FrimousseEmojiPicker } from 'frimousse';
+import { useRef } from 'react';
+
+import { Input } from '@ui/primitives/input/Input/Input';
+
+import styles from './EmojiPicker.module.scss';
+import { EmojiPickerEmoji } from './internal/EmojiPickerEmoji';
+import { EmojiPickerRow } from './internal/EmojiPickerRow';
+import { EmojiPickerScrollEffect } from './internal/EmojiPickerScrollEffect';
+import { type EmojiPickerProps } from './types/EmojiPickerProps';
+
+const EMOJI_PICKER_COLUMNS = 8;
+
+export const EmojiPicker = ({
+ emojibaseUrl,
+ locale = 'en',
+ searchLabel,
+ searchPlaceholder = searchLabel,
+ loadingLabel,
+ emptyLabel,
+ onEmojiSelect,
+ autoFocus = false,
+ className,
+ ref,
+ ...props
+}: EmojiPickerProps) => {
+ const rootRef = useRef<HTMLDivElement>(null);
+ const mergedRef = useMergedRefs(rootRef, ref);
+
+ return (
+ <FrimousseEmojiPicker.Root
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...props}
+ ref={mergedRef}
+ className={clsx(styles.root, className)}
+ emojibaseUrl={emojibaseUrl}
+ locale={locale}
+ columns={EMOJI_PICKER_COLUMNS}
+ onEmojiSelect={({ emoji }) => onEmojiSelect(emoji)}
+ >
+ <div className={styles.search}>
+ <Input
+ render={<FrimousseEmojiPicker.Search />}
+ aria-label={searchLabel}
+ placeholder={searchPlaceholder}
+ autoFocus={autoFocus}
+ />
+ </div>
+ <FrimousseEmojiPicker.Viewport className={styles.viewport} tabIndex={0}>
+ <FrimousseEmojiPicker.Loading className={styles.message}>
+ {loadingLabel}
+ </FrimousseEmojiPicker.Loading>
+ <FrimousseEmojiPicker.Empty className={styles.message}>
+ {emptyLabel}
+ </FrimousseEmojiPicker.Empty>
+ <FrimousseEmojiPicker.List
+ components={{ Row: EmojiPickerRow, Emoji: EmojiPickerEmoji }}
+ />
+ </FrimousseEmojiPicker.Viewport>
+ <EmojiPickerScrollEffect rootRef={rootRef} />
+ </FrimousseEmojiPicker.Root>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.interactions.stories.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.interactions.stories.tsx
new file mode 100644
index 00000000000..a313e846c29
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.interactions.stories.tsx
@@ -0,0 +1,96 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+
+import { ComponentDecorator } from '@ui/testing';
+
+import { EmojiPickerExample } from './EmojiPickerExample';
+import { mockEmojiPickerStoryData } from './mockEmojiPickerStoryData';
+
+const meta: Meta<typeof EmojiPickerExample> = {
+ id: 'ui-input-emojipicker-interactions',
+ title: 'UI/Components/Input/EmojiPicker/Interactions',
+ component: EmojiPickerExample,
+ tags: ['!autodocs'],
+ decorators: [ComponentDecorator],
+ beforeEach: () => mockEmojiPickerStoryData(),
+ args: { onEmojiSelect: fn() },
+};
+
+export default meta;
+type Story = StoryObj<typeof EmojiPickerExample>;
+
+export const SearchAndPointerSelection: Story = {
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const search = canvas.getByRole('searchbox', { name: 'Search emojis' });
+
+ const firstEmoji = await canvas.findByRole('gridcell', {
+ name: 'Thumbs up',
+ });
+
+ await expect(firstEmoji).toHaveAttribute('aria-colindex', '1');
+ await expect(firstEmoji.closest('[role="row"]')).toHaveAttribute(
+ 'aria-rowindex',
+ '1',
+ );
+ await userEvent.type(search, 'celebrate');
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('gridcell', { name: 'Thumbs up' }),
+ ).not.toBeInTheDocument(),
+ );
+ const partyPopper = canvas.getByRole('gridcell', { name: 'Party popper' });
+ await userEvent.click(partyPopper);
+ await expect(args.onEmojiSelect).toHaveBeenCalledOnce();
+ await expect(args.onEmojiSelect).toHaveBeenCalledWith('πŸŽ‰');
+ await expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Selected emoji: πŸŽ‰',
+ );
+ },
+};
+
+export const KeyboardSelection: Story = {
+ args: { autoFocus: true },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const search = canvas.getByRole('searchbox', { name: 'Search emojis' });
+
+ await expect(search).toHaveFocus();
+ await canvas.findByRole('gridcell', { name: 'Thumbs up' });
+ await userEvent.type(search, 'eyes');
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('gridcell', { name: 'Thumbs up' }),
+ ).not.toBeInTheDocument(),
+ );
+ await userEvent.keyboard('{ArrowDown}{Enter}');
+ await expect(args.onEmojiSelect).toHaveBeenCalledOnce();
+ await expect(args.onEmojiSelect).toHaveBeenCalledWith('πŸ‘€');
+ await expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Selected emoji: πŸ‘€',
+ );
+ },
+};
+
+export const EmptyResultsAndLabels: Story = {
+ args: {
+ searchLabel: 'Find a reaction',
+ searchPlaceholder: 'Search by name',
+ loadingLabel: 'Preparing reactions',
+ emptyLabel: 'No matching reactions',
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const search = canvas.getByRole('searchbox', { name: 'Find a reaction' });
+
+ await expect(search).toHaveAttribute('placeholder', 'Search by name');
+ await canvas.findByRole('gridcell', { name: 'Thumbs up' });
+ await userEvent.type(search, 'unknown-reaction');
+ await expect(
+ await canvas.findByText('No matching reactions'),
+ ).toBeVisible();
+ await expect(canvas.queryAllByRole('gridcell')).toHaveLength(0);
+ await userEvent.keyboard('{ArrowDown}{Enter}');
+ await expect(args.onEmojiSelect).not.toHaveBeenCalled();
+ },
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.scrolling.stories.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.scrolling.stories.tsx
new file mode 100644
index 00000000000..096d805b078
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.scrolling.stories.tsx
@@ -0,0 +1,181 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+
+import { ComponentDecorator } from '@ui/testing';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { EmojiPickerExample } from './EmojiPickerExample';
+import { type EMOJI_PICKER_STORY_DATA } from './emojiPickerStoryData';
+import { mockEmojiPickerStoryData } from './mockEmojiPickerStoryData';
+
+const EMOJI_PICKER_SCROLL_STORY_EMOJIBASE_URL = '/emoji-picker-scroll-story';
+const EMOJI_PICKER_SCROLL_STORY_EMOJI_COUNT = 80;
+const EMOJI_PICKER_SCROLL_STORY_FIRST_EMOJI_CODE_POINT = 0x1f600;
+const EMOJI_PICKER_SCROLL_STORY_ACTIVE_ROW_LABELS = [
+ 'Reaction 9',
+ 'Reaction 17',
+ 'Reaction 25',
+ 'Reaction 33',
+ 'Reaction 41',
+ 'Reaction 49',
+ 'Reaction 57',
+ 'Reaction 65',
+ 'Reaction 73',
+];
+const EMOJI_PICKER_SCROLL_STORY_EMOJIS: typeof EMOJI_PICKER_STORY_DATA.emojis =
+ [];
+
+for (const index of new Array<number>(
+ EMOJI_PICKER_SCROLL_STORY_EMOJI_COUNT,
+).keys()) {
+ const codePoint = EMOJI_PICKER_SCROLL_STORY_FIRST_EMOJI_CODE_POINT + index;
+
+ const isPeopleAndBodyCategory =
+ index < EMOJI_PICKER_SCROLL_STORY_EMOJI_COUNT / 2;
+
+ EMOJI_PICKER_SCROLL_STORY_EMOJIS.push({
+ emoji: String.fromCodePoint(codePoint),
+ label: `reaction ${index + 1}`,
+ hexcode: codePoint.toString(16).toUpperCase(),
+ group: isPeopleAndBodyCategory ? 1 : 6,
+ subgroup: isPeopleAndBodyCategory ? 19 : 60,
+ version: 1,
+ type: 1,
+ order: index,
+ text: '',
+ tags: ['reaction'],
+ });
+}
+
+const meta: Meta<typeof EmojiPickerExample> = {
+ id: 'ui-input-emojipicker-scrolling',
+ title: 'UI/Components/Input/EmojiPicker/Scrolling',
+ component: EmojiPickerExample,
+ tags: ['!autodocs'],
+ decorators: [ComponentDecorator],
+ beforeEach: () =>
+ mockEmojiPickerStoryData({
+ emojibaseUrl: EMOJI_PICKER_SCROLL_STORY_EMOJIBASE_URL,
+ emojis: EMOJI_PICKER_SCROLL_STORY_EMOJIS,
+ }),
+ args: {
+ emojibaseUrl: EMOJI_PICKER_SCROLL_STORY_EMOJIBASE_URL,
+ onEmojiSelect: fn(),
+ autoFocus: true,
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof EmojiPickerExample>;
+
+export const KeyboardScrollsActiveRowIntoView: Story = {
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const search = canvas.getByRole('searchbox', { name: 'Search emojis' });
+
+ const firstEmoji = await canvas.findByRole('gridcell', {
+ name: 'Reaction 1',
+ });
+
+ const viewport = firstEmoji.closest<HTMLElement>('[frimousse-viewport]');
+
+ await expect(viewport).toBeInTheDocument();
+
+ if (!isDefined(viewport)) {
+ return;
+ }
+
+ await userEvent.click(search);
+ await expect(search).toHaveFocus();
+ await userEvent.tab();
+ await expect(viewport).toHaveFocus();
+ await userEvent.keyboard('{ArrowLeft}');
+ await waitFor(() =>
+ expect(firstEmoji).toHaveAttribute('aria-selected', 'true'),
+ );
+
+ const expectActiveEmojiToBeVisible = async (name: string) => {
+ const activeEmoji = await canvas.findByRole('gridcell', { name });
+
+ await waitFor(() => {
+ expect(activeEmoji).toHaveAttribute('aria-selected', 'true');
+
+ const emojiBounds = activeEmoji.getBoundingClientRect();
+ const viewportBounds = viewport.getBoundingClientRect();
+ const categoryHeaderHeight = Number.parseFloat(
+ getComputedStyle(viewport).getPropertyValue(
+ '--frimousse-category-header-height',
+ ),
+ );
+
+ expect(emojiBounds.top).toBeGreaterThanOrEqual(
+ viewportBounds.top + categoryHeaderHeight,
+ );
+ expect(emojiBounds.bottom).toBeLessThanOrEqual(viewportBounds.bottom);
+ expect(emojiBounds.left).toBeGreaterThanOrEqual(viewportBounds.left);
+ expect(emojiBounds.right).toBeLessThanOrEqual(viewportBounds.right);
+ });
+ };
+
+ for (const name of EMOJI_PICKER_SCROLL_STORY_ACTIVE_ROW_LABELS) {
+ await userEvent.keyboard('{ArrowDown}');
+ await expectActiveEmojiToBeVisible(name);
+
+ if (name === 'Reaction 41') {
+ await userEvent.keyboard('{ArrowLeft}');
+ await expectActiveEmojiToBeVisible('Reaction 40');
+ await userEvent.keyboard('{ArrowRight}');
+ await expectActiveEmojiToBeVisible('Reaction 41');
+ }
+ }
+
+ const lastRowFirstEmoji = await canvas.findByRole('gridcell', {
+ name: 'Reaction 73',
+ });
+
+ await expect(lastRowFirstEmoji).toHaveAttribute('aria-colindex', '1');
+ await expect(lastRowFirstEmoji.closest('[role="row"]')).toHaveAttribute(
+ 'aria-rowindex',
+ '10',
+ );
+
+ await userEvent.keyboard('{ArrowDown>3/}');
+ await expectActiveEmojiToBeVisible('Reaction 73');
+ await userEvent.keyboard('{ArrowRight>7/}');
+ await expectActiveEmojiToBeVisible('Reaction 80');
+
+ const lastEmoji = await canvas.findByRole('gridcell', {
+ name: 'Reaction 80',
+ });
+
+ await new Promise<void>((resolve) => {
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
+ });
+ viewport.scrollTop -= lastEmoji.getBoundingClientRect().height / 2;
+ const scrollTopBeforeHover = viewport.scrollTop;
+
+ await userEvent.hover(lastEmoji);
+ await expect(viewport.scrollTop).toBe(scrollTopBeforeHover);
+ await expect(lastEmoji.getBoundingClientRect().bottom).toBeGreaterThan(
+ viewport.getBoundingClientRect().bottom,
+ );
+ await userEvent.keyboard('{ArrowRight>3/}');
+ await expectActiveEmojiToBeVisible('Reaction 80');
+ await userEvent.keyboard('{ArrowLeft>7/}');
+ await expectActiveEmojiToBeVisible('Reaction 73');
+
+ const previousRowLabels = [
+ ...EMOJI_PICKER_SCROLL_STORY_ACTIVE_ROW_LABELS.slice(0, -1).reverse(),
+ 'Reaction 1',
+ ];
+
+ for (const name of previousRowLabels) {
+ await userEvent.keyboard('{ArrowUp}');
+ await expectActiveEmojiToBeVisible(name);
+ }
+
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onEmojiSelect).toHaveBeenCalledOnce();
+ await expect(args.onEmojiSelect).toHaveBeenCalledWith('πŸ˜€');
+ },
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.stories.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.stories.tsx
new file mode 100644
index 00000000000..1f3b71ea978
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPicker.stories.tsx
@@ -0,0 +1,30 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { fn } from 'storybook/test';
+
+import { ComponentDecorator } from '@ui/testing';
+
+import { EmojiPickerExample } from './EmojiPickerExample';
+import { mockEmojiPickerStoryData } from './mockEmojiPickerStoryData';
+
+const meta: Meta<typeof EmojiPickerExample> = {
+ id: 'ui-input-emojipicker',
+ title: 'UI/Components/Input/EmojiPicker',
+ component: EmojiPickerExample,
+ decorators: [ComponentDecorator],
+ beforeEach: () => mockEmojiPickerStoryData(),
+ args: {
+ searchLabel: 'Search emojis',
+ loadingLabel: 'Loading emojis',
+ emptyLabel: 'No emoji found',
+ onEmojiSelect: fn(),
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof EmojiPickerExample>;
+
+export const Display: Story = {};
+
+export const Dark: Story = {
+ globals: { colorScheme: 'dark' },
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPickerExample.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPickerExample.tsx
new file mode 100644
index 00000000000..dfffad55fe3
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/EmojiPickerExample.tsx
@@ -0,0 +1,63 @@
+import { useState } from 'react';
+
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { themeCssVariables } from '@ui/theme';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { EmojiPicker } from '../EmojiPicker';
+import { type EmojiPickerProps } from '../types/EmojiPickerProps';
+import { EMOJI_PICKER_STORY_EMOJIBASE_URL } from './emojiPickerStoryEmojibaseUrl';
+
+const EMOJI_PICKER_STORY_WIDTH_PX = 296;
+
+type EmojiPickerExampleProps = Partial<
+ Pick<
+ EmojiPickerProps,
+ | 'emojibaseUrl'
+ | 'searchLabel'
+ | 'searchPlaceholder'
+ | 'loadingLabel'
+ | 'emptyLabel'
+ | 'autoFocus'
+ | 'onEmojiSelect'
+ >
+>;
+
+export const EmojiPickerExample = ({
+ emojibaseUrl = EMOJI_PICKER_STORY_EMOJIBASE_URL,
+ searchLabel = 'Search emojis',
+ searchPlaceholder,
+ loadingLabel = 'Loading emojis',
+ emptyLabel = 'No emoji found',
+ autoFocus = false,
+ onEmojiSelect,
+}: EmojiPickerExampleProps) => {
+ const [emoji, setEmoji] = useState<string | undefined>();
+
+ return (
+ <Text
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ gap: themeCssVariables.spacing[2],
+ width: EMOJI_PICKER_STORY_WIDTH_PX,
+ }}
+ >
+ <EmojiPicker
+ emojibaseUrl={emojibaseUrl}
+ searchLabel={searchLabel}
+ searchPlaceholder={searchPlaceholder}
+ loadingLabel={loadingLabel}
+ emptyLabel={emptyLabel}
+ autoFocus={autoFocus}
+ onEmojiSelect={(selectedEmoji) => {
+ setEmoji(selectedEmoji);
+ onEmojiSelect?.(selectedEmoji);
+ }}
+ />
+ <Text role="status">
+ {isDefined(emoji) ? `Selected emoji: ${emoji}` : 'Choose an emoji'}
+ </Text>
+ </Text>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/emojiPickerStoryData.ts b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/emojiPickerStoryData.ts
new file mode 100644
index 00000000000..0bacb654821
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/emojiPickerStoryData.ts
@@ -0,0 +1,58 @@
+export const EMOJI_PICKER_STORY_DATA = {
+ emojis: [
+ {
+ emoji: 'πŸ‘',
+ label: 'thumbs up',
+ hexcode: '1F44D',
+ group: 1,
+ subgroup: 19,
+ version: 1,
+ type: 1,
+ order: 0,
+ text: '',
+ tags: ['approve', 'good', 'thumb', 'up'],
+ },
+ {
+ emoji: 'πŸ‘€',
+ label: 'eyes',
+ hexcode: '1F440',
+ group: 1,
+ subgroup: 22,
+ version: 1,
+ type: 1,
+ order: 1,
+ text: '',
+ tags: ['look', 'watch'],
+ },
+ {
+ emoji: 'πŸŽ‰',
+ label: 'party popper',
+ hexcode: '1F389',
+ group: 6,
+ subgroup: 60,
+ version: 1,
+ type: 1,
+ order: 2,
+ text: '',
+ tags: ['celebrate', 'celebration', 'party'],
+ },
+ ],
+ messages: {
+ groups: [
+ { key: 'people-body', message: 'people & body', order: 1 },
+ { key: 'activities', message: 'activities', order: 6 },
+ ],
+ subgroups: [
+ { key: 'hand-fingers-closed', message: 'fingers closed', order: 19 },
+ { key: 'body-parts', message: 'body parts', order: 22 },
+ { key: 'event', message: 'events & holidays', order: 60 },
+ ],
+ skinTones: [
+ { key: 'light', message: 'light skin tone' },
+ { key: 'medium-light', message: 'medium-light skin tone' },
+ { key: 'medium', message: 'medium skin tone' },
+ { key: 'medium-dark', message: 'medium-dark skin tone' },
+ { key: 'dark', message: 'dark skin tone' },
+ ],
+ },
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/emojiPickerStoryEmojibaseUrl.ts b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/emojiPickerStoryEmojibaseUrl.ts
new file mode 100644
index 00000000000..9383b759e95
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/emojiPickerStoryEmojibaseUrl.ts
@@ -0,0 +1 @@
+export const EMOJI_PICKER_STORY_EMOJIBASE_URL = '/emoji-picker-story';
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/mockEmojiPickerStoryData.ts b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/mockEmojiPickerStoryData.ts
new file mode 100644
index 00000000000..f051e320731
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/__stories__/mockEmojiPickerStoryData.ts
@@ -0,0 +1,46 @@
+import { spyOn } from 'storybook/test';
+
+import { EMOJI_PICKER_STORY_DATA } from './emojiPickerStoryData';
+import { EMOJI_PICKER_STORY_EMOJIBASE_URL } from './emojiPickerStoryEmojibaseUrl';
+
+export const mockEmojiPickerStoryData = ({
+ emojibaseUrl = EMOJI_PICKER_STORY_EMOJIBASE_URL,
+ emojis = EMOJI_PICKER_STORY_DATA.emojis,
+}: {
+ emojibaseUrl?: string;
+ emojis?: typeof EMOJI_PICKER_STORY_DATA.emojis;
+} = {}) => {
+ const dataPath = `${emojibaseUrl}/en/data.json`;
+ const messagesPath = `${emojibaseUrl}/en/messages.json`;
+ const originalFetch = globalThis.fetch;
+ const mockedFetch = spyOn(globalThis, 'fetch').mockImplementation(
+ (...parameters: Parameters<typeof fetch>) => {
+ const [request] = parameters;
+ const requestUrl = new URL(
+ request instanceof Request ? request.url : request,
+ window.location.origin,
+ );
+ const isStoryDataRequest =
+ requestUrl.origin === window.location.origin &&
+ (requestUrl.pathname === dataPath ||
+ requestUrl.pathname === messagesPath);
+
+ if (!isStoryDataRequest) {
+ return originalFetch(...parameters);
+ }
+
+ const responseBody =
+ requestUrl.pathname === dataPath
+ ? emojis
+ : EMOJI_PICKER_STORY_DATA.messages;
+
+ return Promise.resolve(
+ Response.json(responseBody, {
+ headers: { ETag: '"emoji-picker-story"' },
+ }),
+ );
+ },
+ );
+
+ return () => mockedFetch.mockRestore();
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerEmoji.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerEmoji.tsx
new file mode 100644
index 00000000000..8e987e7b0c2
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerEmoji.tsx
@@ -0,0 +1,19 @@
+import { type EmojiPickerListEmojiProps } from 'frimousse';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+export const EmojiPickerEmoji = ({
+ emoji,
+ 'aria-colindex': columnIndex,
+ ...props
+}: EmojiPickerListEmojiProps) => (
+ <button
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...props}
+ type="button"
+ role="gridcell"
+ aria-colindex={isDefined(columnIndex) ? columnIndex + 1 : undefined}
+ >
+ {emoji.emoji}
+ </button>
+);
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerRow.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerRow.tsx
new file mode 100644
index 00000000000..c7478c15a20
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerRow.tsx
@@ -0,0 +1,14 @@
+import { type EmojiPickerListRowProps } from 'frimousse';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+export const EmojiPickerRow = ({
+ 'aria-rowindex': rowIndex,
+ ...props
+}: EmojiPickerListRowProps) => (
+ <div
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...props}
+ aria-rowindex={isDefined(rowIndex) ? rowIndex + 1 : undefined}
+ />
+);
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerScrollEffect.tsx b/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerScrollEffect.tsx
new file mode 100644
index 00000000000..1bca6a78af4
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/internal/EmojiPickerScrollEffect.tsx
@@ -0,0 +1,81 @@
+import { type RefObject, useEffect } from 'react';
+
+import { doNotTranslate } from '@ui/utilities/internal/doNotTranslate';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { scrollActiveEmojiIntoView } from './scrollActiveEmojiIntoView';
+
+const EMOJI_PICKER_ARROW_KEY_PREFIX = doNotTranslate('Arrow');
+const EMOJI_PICKER_KEY_DOWN_EVENT = doNotTranslate('keydown');
+const EMOJI_PICKER_POINTER_OVER_EVENT = doNotTranslate('pointerover');
+
+type EmojiPickerScrollEffectProps = {
+ rootRef: RefObject<HTMLDivElement | null>;
+};
+
+export const EmojiPickerScrollEffect = ({
+ rootRef,
+}: EmojiPickerScrollEffectProps) => {
+ useEffect(() => {
+ const rootElement = rootRef.current;
+
+ if (!isDefined(rootElement)) {
+ return;
+ }
+
+ let animationFrame: number | undefined;
+
+ const cancelScroll = () => {
+ if (!isDefined(animationFrame)) {
+ return;
+ }
+
+ cancelAnimationFrame(animationFrame);
+ animationFrame = undefined;
+ };
+
+ const handleKeyDown = (event: KeyboardEvent) => {
+ if (
+ event.defaultPrevented ||
+ !event.key.startsWith(EMOJI_PICKER_ARROW_KEY_PREFIX)
+ ) {
+ return;
+ }
+
+ cancelScroll();
+ animationFrame = requestAnimationFrame(() => {
+ animationFrame = requestAnimationFrame(() => {
+ animationFrame = undefined;
+ scrollActiveEmojiIntoView(rootElement);
+ });
+ });
+ };
+
+ rootElement.addEventListener(
+ EMOJI_PICKER_KEY_DOWN_EVENT,
+ handleKeyDown,
+ true,
+ );
+ rootElement.addEventListener(
+ EMOJI_PICKER_POINTER_OVER_EVENT,
+ cancelScroll,
+ true,
+ );
+
+ return () => {
+ cancelScroll();
+ rootElement.removeEventListener(
+ EMOJI_PICKER_KEY_DOWN_EVENT,
+ handleKeyDown,
+ true,
+ );
+ rootElement.removeEventListener(
+ EMOJI_PICKER_POINTER_OVER_EVENT,
+ cancelScroll,
+ true,
+ );
+ };
+ }, [rootRef]);
+
+ return null;
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/internal/scrollActiveEmojiIntoView.ts b/packages/twenty-ui/src/components/input/EmojiPicker/internal/scrollActiveEmojiIntoView.ts
new file mode 100644
index 00000000000..78825ff9d41
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/internal/scrollActiveEmojiIntoView.ts
@@ -0,0 +1,40 @@
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+const EMOJI_PICKER_VIEWPORT_SELECTOR = '[frimousse-viewport]';
+const EMOJI_PICKER_ACTIVE_EMOJI_SELECTOR = '[frimousse-emoji][data-active]';
+const EMOJI_PICKER_CATEGORY_HEADER_HEIGHT_PROPERTY =
+ '--frimousse-category-header-height';
+
+export const scrollActiveEmojiIntoView = (rootElement: HTMLElement) => {
+ const viewport = rootElement.querySelector<HTMLElement>(
+ EMOJI_PICKER_VIEWPORT_SELECTOR,
+ );
+ const activeEmoji = viewport?.querySelector<HTMLElement>(
+ EMOJI_PICKER_ACTIVE_EMOJI_SELECTOR,
+ );
+
+ if (!isDefined(viewport) || !isDefined(activeEmoji)) {
+ return;
+ }
+
+ const viewportBounds = viewport.getBoundingClientRect();
+ const emojiBounds = activeEmoji.getBoundingClientRect();
+ const categoryHeaderHeight = Number.parseFloat(
+ getComputedStyle(viewport).getPropertyValue(
+ EMOJI_PICKER_CATEGORY_HEADER_HEIGHT_PROPERTY,
+ ),
+ );
+ const topOverflow =
+ emojiBounds.top - viewportBounds.top - categoryHeaderHeight;
+
+ if (topOverflow < 0) {
+ viewport.scrollTop += topOverflow;
+ return;
+ }
+
+ const bottomOverflow = emojiBounds.bottom - viewportBounds.bottom;
+
+ if (bottomOverflow > 0) {
+ viewport.scrollTop += bottomOverflow;
+ }
+};
diff --git a/packages/twenty-ui/src/components/input/EmojiPicker/types/EmojiPickerProps.ts b/packages/twenty-ui/src/components/input/EmojiPicker/types/EmojiPickerProps.ts
new file mode 100644
index 00000000000..be357aedeab
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/EmojiPicker/types/EmojiPickerProps.ts
@@ -0,0 +1,15 @@
+import { type ComponentPropsWithRef } from 'react';
+
+export type EmojiPickerProps = Omit<
+ ComponentPropsWithRef<'div'>,
+ 'children'
+> & {
+ emojibaseUrl: string;
+ locale?: string;
+ searchLabel: string;
+ searchPlaceholder?: string;
+ loadingLabel: string;
+ emptyLabel: string;
+ onEmojiSelect: (emoji: string) => void;
+ autoFocus?: boolean;
+};
diff --git a/packages/twenty-ui/src/components/input/index.ts b/packages/twenty-ui/src/components/input/index.ts
index dded60d27ce..43f28c8f5fc 100644
--- a/packages/twenty-ui/src/components/input/index.ts
+++ b/packages/twenty-ui/src/components/input/index.ts
@@ -22,6 +22,8 @@ export type { CurrencyPickerProps } from './CurrencyPicker/types/CurrencyPickerP
export type { CurrencyPickerRootProps } from './CurrencyPicker/types/CurrencyPickerRootProps';
export type { CurrencyPickerState } from './CurrencyPicker/types/CurrencyPickerState';
export type { CurrencyPickerTriggerProps } from './CurrencyPicker/types/CurrencyPickerTriggerProps';
+export { EmojiPicker } from './EmojiPicker/EmojiPicker';
+export type { EmojiPickerProps } from './EmojiPicker/types/EmojiPickerProps';
export { FormFieldRow } from './FormFieldRow/FormFieldRow';
export type { FormFieldRowProps } from './FormFieldRow/types/FormFieldRowProps';
export { IconButton } from './IconButton/IconButton';
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/CountPager.module.scss b/packages/twenty-ui/src/components/navigation/CountPager/CountPager.module.scss
new file mode 100644
index 00000000000..8de2b7ab565
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/CountPager.module.scss
@@ -0,0 +1,25 @@
+.pager {
+ align-items: center;
+ display: inline-flex;
+ flex-shrink: 0;
+ gap: var(--t-spacing-1);
+ min-inline-size: 0;
+
+ &[data-position-placement='start'] {
+ display: flex;
+
+ .position {
+ flex: 1;
+ }
+ }
+}
+
+.position {
+ color: var(--t-font-color-secondary);
+ font-size: var(--t-font-size-sm);
+ overflow-wrap: anywhere;
+}
+
+.icon:dir(rtl) {
+ transform: scaleX(-1);
+}
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/CountPager.tsx b/packages/twenty-ui/src/components/navigation/CountPager/CountPager.tsx
new file mode 100644
index 00000000000..800292dc69e
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/CountPager.tsx
@@ -0,0 +1,73 @@
+import { useRender } from '@base-ui/react/use-render';
+import { isInteger } from '@sniptt/guards';
+import { clsx } from 'clsx';
+
+import { LightIconButton } from '@ui/components/input/LightIconButton/LightIconButton';
+import { IconChevronLeft, IconChevronRight } from '@ui/icon';
+import { Text } from '@ui/primitives/typography/Text/Text';
+
+import styles from './CountPager.module.scss';
+import { type CountPagerProps } from './types/CountPagerProps';
+
+export const CountPager = ({
+ index,
+ count,
+ onIndexChange,
+ positionText,
+ previousLabel,
+ nextLabel,
+ disabled = false,
+ positionPlacement = 'between',
+ render,
+ ref,
+ className,
+ ...props
+}: CountPagerProps) => {
+ const isIndexInRange =
+ isInteger(index) && isInteger(count) && index >= 0 && index < count;
+ const isPreviousDisabled = disabled || !isIndexInRange || index === 0;
+ const isNextDisabled = disabled || !isIndexInRange || index === count - 1;
+ const position = (
+ <Text
+ render={<span />}
+ className={styles.position}
+ aria-live="polite"
+ aria-atomic="true"
+ >
+ {positionText}
+ </Text>
+ );
+
+ return useRender({
+ render,
+ ref,
+ props: {
+ role: 'group',
+ ...props,
+ className: clsx(styles.pager, className),
+ 'data-position-placement': positionPlacement,
+ children: (
+ <>
+ {positionPlacement === 'start' && position}
+ <LightIconButton
+ size="sm"
+ disabled={isPreviousDisabled}
+ onClick={() => onIndexChange(index - 1)}
+ aria-label={previousLabel}
+ >
+ <IconChevronLeft className={styles.icon} />
+ </LightIconButton>
+ {positionPlacement === 'between' && position}
+ <LightIconButton
+ size="sm"
+ disabled={isNextDisabled}
+ onClick={() => onIndexChange(index + 1)}
+ aria-label={nextLabel}
+ >
+ <IconChevronRight className={styles.icon} />
+ </LightIconButton>
+ </>
+ ),
+ },
+ });
+};
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPager.interactions.stories.tsx b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPager.interactions.stories.tsx
new file mode 100644
index 00000000000..78664dcf571
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPager.interactions.stories.tsx
@@ -0,0 +1,168 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { ComponentDecorator } from '@ui/testing';
+import { themeCssVariables } from '@ui/theme';
+
+import { CountPager } from '../CountPager';
+import { CountPagerCollectionExample } from './CountPagerCollectionExample';
+import { CountPagerExample } from './CountPagerExample';
+
+const meta: Meta<typeof CountPager> = {
+ id: 'ui-components-countpager-interactions',
+ title: 'UI/Components/Navigation/CountPager/Interactions',
+ component: CountPager,
+ decorators: [ComponentDecorator],
+ args: {
+ 'aria-label': 'Review item',
+ index: 1,
+ count: 3,
+ positionText: '2 of 3',
+ previousLabel: 'Previous item',
+ nextLabel: 'Next item',
+ onIndexChange: fn(),
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof CountPager>;
+
+export const ControlledRequest: Story = {
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const previous = canvas.getByRole('button', { name: 'Previous item' });
+ const next = canvas.getByRole('button', { name: 'Next item' });
+
+ await userEvent.click(previous);
+ await expect(args.onIndexChange).toHaveBeenNthCalledWith(1, 0);
+ await userEvent.click(next);
+ await expect(args.onIndexChange).toHaveBeenNthCalledWith(2, 2);
+ await expect(args.onIndexChange).toHaveBeenCalledTimes(2);
+ await expect(
+ canvas.getByRole('group', { name: 'Review item' }),
+ ).toHaveTextContent('2 of 3');
+ await expect(previous).toHaveAttribute('type', 'button');
+ await expect(next).toHaveAttribute('type', 'button');
+ },
+};
+
+export const KeyboardNavigation: Story = {
+ render: () => <CountPagerExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const previous = canvas.getByRole('button', { name: 'Previous item' });
+ const next = canvas.getByRole('button', { name: 'Next item' });
+ const pager = canvas.getByRole('group', { name: 'Review item' });
+
+ await expect(previous).toBeDisabled();
+ next.focus();
+ await expect(next).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(pager).toHaveTextContent('2 of 3');
+ await expect(previous).toBeEnabled();
+ await userEvent.keyboard(' ');
+ await expect(pager).toHaveTextContent('3 of 3');
+ await expect(next).toBeDisabled();
+ previous.focus();
+ await userEvent.keyboard(' ');
+ await expect(pager).toHaveTextContent('2 of 3');
+ await userEvent.tab();
+ await expect(next).toHaveFocus();
+ },
+};
+
+export const DisabledStates: Story = {
+ render: (args) => (
+ <Text style={{ display: 'grid', gap: themeCssVariables.spacing[3] }}>
+ <CountPager
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ aria-label="Empty collection"
+ index={0}
+ count={0}
+ positionText="0 of 0"
+ />
+ <CountPager
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ aria-label="Single item"
+ index={0}
+ count={1}
+ positionText="1 of 1"
+ />
+ <CountPager
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ aria-label="Disabled collection"
+ disabled
+ />
+ <CountPager
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ aria-label="Stale selection"
+ index={3}
+ />
+ </Text>
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ for (const name of [
+ 'Empty collection',
+ 'Single item',
+ 'Disabled collection',
+ 'Stale selection',
+ ]) {
+ const pager = within(canvas.getByRole('group', { name }));
+
+ for (const button of pager.getAllByRole('button')) {
+ await expect(button).toBeDisabled();
+ await userEvent.click(button);
+ }
+ }
+
+ await expect(args.onIndexChange).not.toHaveBeenCalled();
+ },
+};
+
+export const ReplacementSelection: Story = {
+ render: ({ onIndexChange }) => (
+ <CountPagerCollectionExample onIndexChange={onIndexChange} />
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const pager = canvas.getByRole('group', { name: 'Review item' });
+
+ await expect(pager).toHaveTextContent('2 of 3');
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Replace collection' }),
+ );
+ await expect(pager).toHaveTextContent('1 of 1');
+ await expect(
+ canvas.getByRole('button', { name: 'Previous item' }),
+ ).toBeDisabled();
+ await expect(
+ canvas.getByRole('button', { name: 'Next item' }),
+ ).toBeDisabled();
+ await expect(args.onIndexChange).not.toHaveBeenCalled();
+ },
+};
+
+export const LeadingPosition: Story = {
+ args: { positionPlacement: 'start', positionText: 'Request 2 of 3' },
+ parameters: { container: { width: 320 } },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const position = canvas.getByText('Request 2 of 3');
+ const previous = canvas.getByRole('button', { name: 'Previous item' });
+ const next = canvas.getByRole('button', { name: 'Next item' });
+
+ await expect(position.getBoundingClientRect().left).toBeLessThan(
+ previous.getBoundingClientRect().left,
+ );
+ await expect(previous.getBoundingClientRect().left).toBeLessThan(
+ next.getBoundingClientRect().left,
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPager.stories.tsx b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPager.stories.tsx
new file mode 100644
index 00000000000..6b26dffd48e
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPager.stories.tsx
@@ -0,0 +1,104 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { fn } from 'storybook/test';
+
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { ComponentDecorator, GroupedCatalog } from '@ui/testing';
+
+import { CountPager } from '../CountPager';
+import { type CountPagerProps } from '../types/CountPagerProps';
+import { CountPagerExample } from './CountPagerExample';
+
+const meta: Meta<typeof CountPager> = {
+ id: 'ui-components-countpager',
+ title: 'UI/Components/Navigation/CountPager',
+ component: CountPager,
+ decorators: [ComponentDecorator],
+ args: {
+ 'aria-label': 'Review item',
+ index: 0,
+ count: 3,
+ positionText: '1 of 3',
+ previousLabel: 'Previous item',
+ nextLabel: 'Next item',
+ onIndexChange: fn(),
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof CountPager>;
+
+export const Display: Story = {
+ argTypes: {
+ index: { control: false },
+ count: { control: false },
+ positionText: { control: false },
+ previousLabel: { control: false },
+ nextLabel: { control: false },
+ 'aria-label': { control: false },
+ },
+ render: ({ disabled, positionPlacement }) => (
+ <CountPagerExample
+ disabled={disabled}
+ positionPlacement={positionPlacement}
+ />
+ ),
+};
+
+const PAGER_EXAMPLES: {
+ label: string;
+ props: Pick<CountPagerProps, 'index' | 'count' | 'positionText'> &
+ Partial<Pick<CountPagerProps, 'disabled' | 'positionPlacement'>>;
+}[] = [
+ {
+ label: 'First item',
+ props: { index: 0, count: 3, positionText: '1 of 3' },
+ },
+ { label: 'Last item', props: { index: 2, count: 3, positionText: '3 of 3' } },
+ { label: 'Empty', props: { index: 0, count: 0, positionText: '0 of 0' } },
+ {
+ label: 'Single item',
+ props: { index: 0, count: 1, positionText: '1 of 1' },
+ },
+ {
+ label: 'Disabled',
+ props: { index: 1, count: 3, positionText: '2 of 3', disabled: true },
+ },
+ {
+ label: 'Leading position',
+ props: {
+ index: 1,
+ count: 3,
+ positionText: 'Request 2 of 3',
+ positionPlacement: 'start',
+ },
+ },
+];
+
+export const Catalog: Story = {
+ parameters: { container: { width: 540 } },
+ render: (args) => (
+ <GroupedCatalog
+ groups={[{ label: 'Positions and states', examples: PAGER_EXAMPLES }]}
+ renderExample={({ label, props }) => (
+ <>
+ <Text>{label}</Text>
+ <CountPager
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ aria-label={label}
+ index={props.index}
+ count={props.count}
+ positionText={props.positionText}
+ disabled={props.disabled}
+ positionPlacement={props.positionPlacement}
+ style={{ width: 200 }}
+ />
+ </>
+ )}
+ />
+ ),
+};
+
+export const RightToLeft: Story = {
+ args: { dir: 'rtl', index: 1, positionText: '2 of 3' },
+};
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPagerCollectionExample.tsx b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPagerCollectionExample.tsx
new file mode 100644
index 00000000000..e1e3295eb91
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPagerCollectionExample.tsx
@@ -0,0 +1,41 @@
+import { useState } from 'react';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { themeCssVariables } from '@ui/theme';
+
+import { CountPager } from '../CountPager';
+
+export const CountPagerCollectionExample = ({
+ onIndexChange,
+}: {
+ onIndexChange: (index: number) => void;
+}) => {
+ const [selection, setSelection] = useState({ index: 1, count: 3 });
+
+ return (
+ <Text
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: themeCssVariables.spacing[4],
+ }}
+ >
+ <CountPager
+ aria-label="Review item"
+ index={selection.index}
+ count={selection.count}
+ onIndexChange={(index) => {
+ onIndexChange(index);
+ setSelection({ ...selection, index });
+ }}
+ positionText={`${selection.index + 1} of ${selection.count}`}
+ previousLabel="Previous item"
+ nextLabel="Next item"
+ />
+ <Button size="sm" onClick={() => setSelection({ index: 0, count: 1 })}>
+ Replace collection
+ </Button>
+ </Text>
+ );
+};
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPagerExample.tsx b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPagerExample.tsx
new file mode 100644
index 00000000000..3e6130f5f44
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/__stories__/CountPagerExample.tsx
@@ -0,0 +1,25 @@
+import { useState } from 'react';
+
+import { CountPager } from '../CountPager';
+import { type CountPagerProps } from '../types/CountPagerProps';
+
+export const CountPagerExample = ({
+ disabled,
+ positionPlacement,
+}: Pick<CountPagerProps, 'disabled' | 'positionPlacement'>) => {
+ const [index, setIndex] = useState(0);
+
+ return (
+ <CountPager
+ aria-label="Review item"
+ index={index}
+ count={3}
+ onIndexChange={setIndex}
+ positionText={`${index + 1} of 3`}
+ previousLabel="Previous item"
+ nextLabel="Next item"
+ disabled={disabled}
+ positionPlacement={positionPlacement}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/__tests__/CountPager.test.tsx b/packages/twenty-ui/src/components/navigation/CountPager/__tests__/CountPager.test.tsx
new file mode 100644
index 00000000000..3538ee26002
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/__tests__/CountPager.test.tsx
@@ -0,0 +1,22 @@
+import { vi } from 'vitest';
+
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { CountPager } from '../CountPager';
+import styles from '../CountPager.module.scss';
+
+runComponentConformance({
+ name: 'CountPager',
+ element: (
+ <CountPager
+ index={0}
+ count={3}
+ positionText="1 of 3"
+ previousLabel="Previous item"
+ nextLabel="Next item"
+ onIndexChange={vi.fn()}
+ />
+ ),
+ refInstanceOf: HTMLDivElement,
+ ownClassName: styles.pager,
+});
diff --git a/packages/twenty-ui/src/components/navigation/CountPager/types/CountPagerProps.ts b/packages/twenty-ui/src/components/navigation/CountPager/types/CountPagerProps.ts
new file mode 100644
index 00000000000..0bcb2eb217c
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/CountPager/types/CountPagerProps.ts
@@ -0,0 +1,15 @@
+import { type useRender } from '@base-ui/react/use-render';
+
+export type CountPagerProps = Omit<
+ useRender.ComponentProps<'div'>,
+ 'children'
+> & {
+ index: number;
+ count: number;
+ onIndexChange: (index: number) => void;
+ positionText: string;
+ previousLabel: string;
+ nextLabel: string;
+ disabled?: boolean;
+ positionPlacement?: 'between' | 'start';
+};
diff --git a/packages/twenty-ui/src/components/navigation/index.ts b/packages/twenty-ui/src/components/navigation/index.ts
index 8e7eae5dcde..f3911d394c4 100644
--- a/packages/twenty-ui/src/components/navigation/index.ts
+++ b/packages/twenty-ui/src/components/navigation/index.ts
@@ -7,6 +7,8 @@
* |___/
*/
+export { CountPager } from './CountPager/CountPager';
+export type { CountPagerProps } from './CountPager/types/CountPagerProps';
export { Dropdown } from './Dropdown/Dropdown';
export { useDropdownPage } from './Dropdown/hooks/useDropdownPage';
export type { DropdownActionItemProps } from './Dropdown/types/DropdownActionItemProps';
diff --git a/packages/twenty-ui/src/icon/components/TablerIcons.ts b/packages/twenty-ui/src/icon/components/TablerIcons.ts
index 7d1eae7070d..d2cfbe27858 100644
--- a/packages/twenty-ui/src/icon/components/TablerIcons.ts
+++ b/packages/twenty-ui/src/icon/components/TablerIcons.ts
@@ -109,6 +109,7 @@ export {
IconMessageCircle as IconComment,
IconCopy,
IconCopyPlus,
+ IconCornerDownRight,
IconCpu,
IconCreativeCommonsSa,
IconCreditCard,
@@ -203,6 +204,7 @@ export {
IconFolder,
IconFolderOpen,
IconFolderPlus,
+ IconForms,
IconFolderRoot,
IconFolderSymlink,
IconForbid,
@@ -295,6 +297,7 @@ export {
IconMinimize,
IconMinus,
IconMoneybag,
+ IconMoodPlus,
IconMoodSmile,
IconMoon,
IconMouse2,
diff --git a/packages/twenty-ui/src/icon/index.ts b/packages/twenty-ui/src/icon/index.ts
index 511538c24a1..2d716fcdb32 100644
--- a/packages/twenty-ui/src/icon/index.ts
+++ b/packages/twenty-ui/src/icon/index.ts
@@ -165,6 +165,7 @@ export {
IconComment,
IconCopy,
IconCopyPlus,
+ IconCornerDownRight,
IconCpu,
IconCreativeCommonsSa,
IconCreditCard,
@@ -259,6 +260,7 @@ export {
IconFolder,
IconFolderOpen,
IconFolderPlus,
+ IconForms,
IconFolderRoot,
IconFolderSymlink,
IconForbid,
@@ -351,6 +353,7 @@ export {
IconMinimize,
IconMinus,
IconMoneybag,
+ IconMoodPlus,
IconMoodSmile,
IconMoon,
IconMouse2,
diff --git a/yarn.lock b/yarn.lock
index 8f477196814..4c5dd688b2e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -50932,7 +50932,6 @@ __metadata:
esbuild: "npm:^0.28.1"
file-saver: "npm:^2.0.5"
framer-motion: "npm:^11.18.0"
- frimousse: "npm:^0.4.0"
fuse.js: "npm:^7.1.0"
graphiql: "npm:^5.2.3"
graphql: "npm:16.8.1"
@@ -51391,6 +51390,7 @@ __metadata:
"@vitest/browser-playwright": "npm:^4.1.0"
clsx: "npm:^2.1.1"
esbuild: "npm:^0.28.1"
+ frimousse: "npm:^0.4.0"
glob: "npm:^11.1.0"
jsdom: "npm:^30.0.1"
lightningcss: "npm:^1.32.0"