Skip to content

The open alternative to Salesforce, designed for AI.

Keep inbox rows compact (#28656)

Raphaël Bosi1bcaa9de349f
diff --git a/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx b/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
index 29d051c60e2..e7536286b04 100644
--- a/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
@@ -15,6 +15,10 @@
Trailing content, such as buttons, rendered after the content.
</ParamField>
+<ParamField body="actionsPlacement" type="&quot;auto&quot; | &quot;end&quot;" default="auto">
+ Keeps actions beside the content at every width when set to `end`. The default `auto` preserves responsive wrapping. Hidden end actions do not reserve width on devices without touch.
+</ParamField>
+
<ParamField body="actionsVisibility" type="&quot;always&quot; | &quot;hover&quot;" default="hover">
When trailing actions are visible: on hover and focus, or always.
</ParamField>
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadActionsDropdown.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadActionsDropdown.tsx
index e8a8cec8d18..542dfae6845 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadActionsDropdown.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatThreadActionsDropdown.tsx
@@ -33,6 +33,7 @@ type AiChatThreadActionsDropdownProps = {
onRenameRequested: () => void;
onDetach?: () => void;
shouldShowTriageActions?: boolean;
+ shouldShowMore?: boolean;
};
export const AiChatThreadActionsDropdown = ({
@@ -41,6 +42,7 @@ export const AiChatThreadActionsDropdown = ({
onRenameRequested,
onDetach,
shouldShowTriageActions = false,
+ shouldShowMore = true,
}: AiChatThreadActionsDropdownProps) => {
const { t } = useLingui();
const { upsertRecordsInStore } = useUpsertRecordsInStore();
@@ -82,66 +84,68 @@ export const AiChatThreadActionsDropdown = ({
{shouldShowTriageActions && !isDeleted && (
<AiChatThreadRowTriage threadId={thread.id} />
)}
- <DropdownRoot
- dropdownId={getCommandMenuDropdownIdFromCommandMenuId(instanceId)}
- type="menu"
- onOpenChange={(isOpen) => {
- if (isOpen) {
- targetAiChatThreadsInContextStore({
- contextStoreInstanceId: instanceId,
- threadIds: [thread.id],
- });
- upsertRecordsInStore({
- partialRecords: [
- {
- __typename: 'AgentChatThread',
- id: thread.id,
- title: thread.title ?? null,
- deletedAt: thread.deletedAt ?? null,
- ...(isDefined(thread.lastActivityAt)
- ? { lastActivityAt: thread.lastActivityAt }
- : {}),
- },
- ],
- });
- void refreshAgentChatThreadPermissions([thread.id]);
- }
- }}
- >
- <Dropdown.Trigger
- render={
- <LightIconButton aria-label={t`Chat actions`} emphasis="subtle">
- <IconDotsVertical />
- </LightIconButton>
- }
- />
- <DropdownContent align="end" aria-label={t`Chat actions`}>
- <Dropdown.Section>
- {isDefined(onDetach) && canUpdate && (
- <Dropdown.ActionItem
- startIcon={<IconUnlink />}
- onClick={handleDetach}
+ {shouldShowMore && (
+ <DropdownRoot
+ dropdownId={getCommandMenuDropdownIdFromCommandMenuId(instanceId)}
+ type="menu"
+ onOpenChange={(isOpen) => {
+ if (isOpen) {
+ targetAiChatThreadsInContextStore({
+ contextStoreInstanceId: instanceId,
+ threadIds: [thread.id],
+ });
+ upsertRecordsInStore({
+ partialRecords: [
+ {
+ __typename: 'AgentChatThread',
+ id: thread.id,
+ title: thread.title ?? null,
+ deletedAt: thread.deletedAt ?? null,
+ ...(isDefined(thread.lastActivityAt)
+ ? { lastActivityAt: thread.lastActivityAt }
+ : {}),
+ },
+ ],
+ });
+ void refreshAgentChatThreadPermissions([thread.id]);
+ }
+ }}
+ >
+ <Dropdown.Trigger
+ render={
+ <LightIconButton aria-label={t`Chat actions`} emphasis="subtle">
+ <IconDotsVertical />
+ </LightIconButton>
+ }
+ />
+ <DropdownContent align="end" aria-label={t`Chat actions`}>
+ <Dropdown.Section>
+ {isDefined(onDetach) && canUpdate && (
+ <Dropdown.ActionItem
+ startIcon={<IconUnlink />}
+ onClick={handleDetach}
+ >
+ {t`Detach`}
+ </Dropdown.ActionItem>
+ )}
+ {canUpdate && !isDeleted && (
+ <Dropdown.ActionItem
+ startIcon={<IconPencil />}
+ onClick={handleRename}
+ >
+ {t`Rename`}
+ </Dropdown.ActionItem>
+ )}
+ <CommandMenuContextProvider
+ displayType="dropdownItem"
+ containerType={CommandMenuItemContainerType.IndexPageDropdown}
>
- {t`Detach`}
- </Dropdown.ActionItem>
- )}
- {canUpdate && !isDeleted && (
- <Dropdown.ActionItem
- startIcon={<IconPencil />}
- onClick={handleRename}
- >
- {t`Rename`}
- </Dropdown.ActionItem>
- )}
- <CommandMenuContextProvider
- displayType="dropdownItem"
- containerType={CommandMenuItemContainerType.IndexPageDropdown}
- >
- <AiChatThreadCommandMenuItems />
- </CommandMenuContextProvider>
- </Dropdown.Section>
- </DropdownContent>
- </DropdownRoot>
+ <AiChatThreadCommandMenuItems />
+ </CommandMenuContextProvider>
+ </Dropdown.Section>
+ </DropdownContent>
+ </DropdownRoot>
+ )}
</CommandMenuComponentInstanceContext.Provider>
</ContextStoreComponentInstanceContext.Provider>
);
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadListItem.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadListItem.tsx
index 0eba8ef3d73..c873269fa46 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadListItem.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatThreadListItem.tsx
@@ -13,6 +13,7 @@ import { AiChatThreadRow } from '@/ai/components/AiChatThreadRow';
import { AiChatThreadSubtitle } from '@/ai/components/AiChatThreadSubtitle';
import { AiChatThreadTitle } from '@/ai/components/AiChatThreadTitle';
import { useAiChatThreadRename } from '@/ai/hooks/useAiChatThreadRename';
+import { useAiChatThreadTriage } from '@/ai/hooks/useAiChatThreadTriage';
import { type AgentChatThreadRecord } from '@/ai/types/AgentChatThreadRecord';
import { getCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getCommandMenuDropdownIdFromCommandMenuId';
import { TextInput } from '@/ui/input/components/TextInput';
@@ -70,6 +71,12 @@ export const AiChatThreadListItem = ({
isDropdownOpenComponentState,
itemMenuDropdownId,
);
+ const { status: triageStatus } = useAiChatThreadTriage(thread.id);
+ const shouldShowMore =
+ isDefined(onDetach) ||
+ isDefined(thread.deletedAt) ||
+ !isDefined(triageStatus) ||
+ triageStatus === 'open';
return (
<AiChatThreadRow
@@ -138,6 +145,7 @@ export const AiChatThreadListItem = ({
onRenameRequested={startRename}
onDetach={onDetach}
shouldShowTriageActions
+ shouldShowMore={shouldShowMore}
/>
}
/>
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadRow.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadRow.tsx
index 112e83bb787..73c0e80cf09 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadRow.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatThreadRow.tsx
@@ -58,6 +58,7 @@ const StyledHeading = styled.div`
align-items: center;
display: flex;
gap: ${themeCssVariables.spacing[2]};
+ line-height: ${themeCssVariables.spacing[4]};
min-width: 0;
`;
@@ -71,10 +72,11 @@ const StyledTime = styled.div<{
$isActionMenuOpen: boolean;
$hasActions: boolean;
}>`
+ display: block;
flex-shrink: 0;
white-space: nowrap;
- @media (hover: hover) {
+ @media (hover: hover) and (not (any-pointer: coarse)) {
display: ${({ $isActionMenuOpen, $hasActions }) =>
$isActionMenuOpen && $hasActions ? 'none' : 'block'};
@@ -83,36 +85,25 @@ const StyledTime = styled.div<{
display: ${({ $hasActions }) => ($hasActions ? 'none' : 'block')};
}
}
-
- @container (max-width: 480px) {
- &,
- ${StyledRow}:hover &,
- ${StyledRow}:focus-within & {
- display: block;
- }
- }
`;
const StyledActions = styled.div`
align-items: center;
display: flex;
- flex-wrap: wrap;
gap: ${themeCssVariables.spacing[1]};
- margin-top: ${themeCssVariables.spacing[1]};
-
- @container (max-width: 480px) {
- margin-top: 0;
- padding-left: calc(
- ${themeCssVariables.spacing[6]} + ${themeCssVariables.spacing[4]}
- );
- }
+ height: ${themeCssVariables.spacing[8]};
`;
const StyledDescription = styled.div`
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[2]};
+ line-height: calc(
+ ${themeCssVariables.spacing[4]} - ${themeCssVariables.spacing[0.5]}
+ );
min-width: 0;
+ overflow: hidden;
+`;
+
+const StyledRequestActions = styled.div`
+ margin-top: ${themeCssVariables.spacing[2]};
`;
type AiChatThreadRowProps = {
@@ -161,6 +152,7 @@ export const AiChatThreadRow = ({
selected={isChecked}
selectionAppearance="accent"
descriptionPlacement="below"
+ actionsPlacement="end"
actionsVisibility={isActionMenuOpen ? 'always' : 'hover'}
render={
<StyledRow
@@ -217,18 +209,18 @@ export const AiChatThreadRow = ({
</StyledLeading>
}
description={
- <StyledDescription>
- {subtitle}
+ <>
+ <StyledDescription>{subtitle}</StyledDescription>
{isDefined(children) && (
- <div
+ <StyledRequestActions
data-select-disable
onClick={stopPropagation}
onContextMenu={stopPropagation}
>
{children}
- </div>
+ </StyledRequestActions>
)}
- </StyledDescription>
+ </>
}
actions={
isDefined(actions) && (
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadRowTriage.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadRowTriage.tsx
index 7c933b810ec..8c871a08eed 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadRowTriage.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatThreadRowTriage.tsx
@@ -1,27 +1,9 @@
-import { useLocation } from 'react-router-dom';
import { isDefined } from 'twenty-shared/utils';
import { AiChatThreadTriageButtons } from '@/ai/components/AiChatThreadTriageButtons';
+import { useAiChatThreadTriage } from '@/ai/hooks/useAiChatThreadTriage';
import { useExecuteAgentChatThreadInboxAction } from '@/ai/hooks/useExecuteAgentChatThreadInboxAction';
-import { agentChatThreadParticipantsState } from '@/ai/states/agentChatThreadParticipantsState';
-import { agentChatShownChannelViewSelector } from '@/ai/states/selectors/agentChatShownChannelViewSelector';
-import { agentChatThreadInboxStatusByThreadIdFamilySelector } from '@/ai/states/selectors/agentChatThreadInboxStatusByThreadIdFamilySelector';
-import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
-import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
-import {
- AgentChatInboxAction,
- FeatureFlagKey,
- PermissionFlagType,
-} from '~/generated-metadata/graphql';
-import { isAiChatInboxPath } from '~/utils/isAiChatInboxPath';
-
-const TRIAGE_STATUS_BY_SCOPE = {
- INBOX: 'open',
- SNOOZED: 'snoozed',
- ARCHIVED: 'done',
-} as const;
+import { AgentChatInboxAction } from '~/generated-metadata/graphql';
type AiChatThreadRowTriageProps = {
threadId: string;
@@ -30,36 +12,11 @@ type AiChatThreadRowTriageProps = {
export const AiChatThreadRowTriage = ({
threadId,
}: AiChatThreadRowTriageProps) => {
- const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
- const isInboxEnabled = useIsFeatureEnabled(
- FeatureFlagKey.IS_AI_CHAT_INBOX_ENABLED,
- );
- const agentChatThreadParticipants = useAtomStateValue(
- agentChatThreadParticipantsState,
- );
- const location = useLocation();
- const agentChatShownChannelView = useAtomStateValue(
- agentChatShownChannelViewSelector,
- );
- const { [threadId]: inboxStatus } = useAtomFamilySelectorValue(
- agentChatThreadInboxStatusByThreadIdFamilySelector,
- {
- threadIds: [threadId],
- channelId: isAiChatInboxPath(location.pathname)
- ? (agentChatShownChannelView?.channelId ?? null)
- : null,
- },
- );
+ const { status, isInChannel } = useAiChatThreadTriage(threadId);
const { executeAgentChatThreadInboxAction, isPending } =
useExecuteAgentChatThreadInboxAction();
- if (
- !hasAiPermission ||
- !isInboxEnabled ||
- !isDefined(agentChatThreadParticipants) ||
- !isDefined(inboxStatus) ||
- inboxStatus.scope === 'NONE'
- ) {
+ if (!isDefined(status)) {
return null;
}
@@ -67,13 +24,13 @@ export const AiChatThreadRowTriage = ({
void executeAgentChatThreadInboxAction({
threadIds: [threadId],
action,
- isInChannel: inboxStatus.isChannelCopy,
+ isInChannel,
});
};
return (
<AiChatThreadTriageButtons
- status={TRIAGE_STATUS_BY_SCOPE[inboxStatus.scope]}
+ status={status}
isPending={isPending}
onSnooze={() => executeInboxAction(AgentChatInboxAction.SNOOZE)}
onDone={() => executeInboxAction(AgentChatInboxAction.ARCHIVE)}
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatThreadRow.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatThreadRow.stories.tsx
index 89c9b1e4a87..2995270f51c 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatThreadRow.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatThreadRow.stories.tsx
@@ -1,6 +1,7 @@
import { styled } from '@linaria/react';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { isDefined } from 'twenty-shared/utils';
import { Avatar } from 'twenty-ui/primitives/data-display';
import { Input } from 'twenty-ui/primitives/input';
import { Text } from 'twenty-ui/primitives/typography';
@@ -226,14 +227,44 @@ export const NarrowDraft: Story = {
'Quote the annual plan and include the renewal details',
);
+ await expect(row.getBoundingClientRect().height).toBe(65);
+ await expect(activityTime).toBeVisible();
await userEvent.tab();
await expect(row).toHaveFocus();
const doneButton = canvas.getByRole('button', { name: 'Done' });
await waitFor(() => expect(doneButton).toBeVisible());
- await expect(activityTime).toBeVisible();
- await expect(doneButton.getBoundingClientRect().top).toBeGreaterThanOrEqual(
+ await expect(activityTime).not.toBeVisible();
+ await expect(row.getBoundingClientRect().height).toBe(65);
+ await expect(doneButton.getBoundingClientRect().top).toBeLessThan(
subtitle.getBoundingClientRect().bottom,
);
+ const preview = subtitle.parentElement;
+
+ if (!isDefined(preview)) {
+ throw new Error('Chat preview container is missing');
+ }
+
+ const draftBadge = canvas.getByText('Draft');
+ let visibleDraftRight = draftBadge.getBoundingClientRect().right;
+
+ for (
+ let ancestor = draftBadge.parentElement;
+ isDefined(ancestor);
+ ancestor = ancestor.parentElement
+ ) {
+ if (getComputedStyle(ancestor).overflowX === 'visible') {
+ continue;
+ }
+
+ visibleDraftRight = Math.min(
+ visibleDraftRight,
+ ancestor.getBoundingClientRect().right,
+ );
+ }
+
+ await expect(visibleDraftRight).toBeLessThanOrEqual(
+ preview.getBoundingClientRect().right,
+ );
await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
await userEvent.tab();
await expect(
@@ -243,10 +274,11 @@ export const NarrowDraft: Story = {
const snoozeButton = canvas.getByRole('button', { name: 'Snooze' });
await expect(snoozeButton).toHaveFocus();
await waitFor(() => expect(snoozeButton).toBeVisible());
- await expect(activityTime).toBeVisible();
- await expect(
- snoozeButton.getBoundingClientRect().top,
- ).toBeGreaterThanOrEqual(subtitle.getBoundingClientRect().bottom);
+ await expect(activityTime).not.toBeVisible();
+ await expect(row.getBoundingClientRect().height).toBe(65);
+ await expect(snoozeButton.getBoundingClientRect().top).toBeLessThan(
+ subtitle.getBoundingClientRect().bottom,
+ );
await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
},
};
@@ -285,6 +317,60 @@ export const Snoozed: Story = {
},
};
+export const CompactSnoozed: Story = {
+ ...Snoozed,
+ tags: ['!dev'],
+ parameters: { container: { width: 400 } },
+ play: async ({ canvasElement }) => {
+ const { userEvent: trustedUserEvent } = await import('vitest/browser');
+ const canvas = within(canvasElement);
+ const row = canvas.getByRole('group', { name: 'Q3 renewal outreach' });
+ const activityTime = canvas.getByText('Thu · 09:00');
+ const title = canvas.getByText('Q3 renewal outreach');
+ const subtitle = canvas.getByText(
+ 'Sarah: I drafted five check-in emails for the October renewals.',
+ );
+ const canHoverWithoutTouch = window.matchMedia(
+ '(hover: hover) and (not (any-pointer: coarse))',
+ ).matches;
+
+ await trustedUserEvent.unhover(row);
+ await expect(row.getBoundingClientRect().height).toBe(65);
+ await expect(activityTime).toBeVisible();
+ await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
+ await trustedUserEvent.hover(row);
+ const changeButton = canvas.getByRole('button', { name: 'Change' });
+ const wakeButton = canvas.getByRole('button', { name: 'Wake now' });
+ await waitFor(() => expect(changeButton).toBeVisible());
+ await expect(wakeButton).toBeVisible();
+ await expect(activityTime.getBoundingClientRect().width > 0).toBe(
+ !canHoverWithoutTouch,
+ );
+ await expect(row.getBoundingClientRect().height).toBe(65);
+ await expect(changeButton.getBoundingClientRect().height).toBe(24);
+ await expect(wakeButton.getBoundingClientRect().height).toBe(24);
+ await expect(changeButton.getBoundingClientRect().top).toBe(
+ wakeButton.getBoundingClientRect().top,
+ );
+ await expect(
+ changeButton.getBoundingClientRect().top,
+ ).toBeGreaterThanOrEqual(title.getBoundingClientRect().top);
+ await expect(wakeButton.getBoundingClientRect().bottom).toBeLessThanOrEqual(
+ subtitle.getBoundingClientRect().bottom,
+ );
+ await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
+ await trustedUserEvent.unhover(row);
+ await userEvent.tab();
+ await expect(row).toHaveFocus();
+ await waitFor(() => expect(changeButton).toBeVisible());
+ await expect(activityTime.getBoundingClientRect().width > 0).toBe(
+ !canHoverWithoutTouch,
+ );
+ await expect(row.getBoundingClientRect().height).toBe(65);
+ await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
+ },
+};
+
export const Done: Story = {
args: {
actions: (
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItem.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItem.test.tsx
index 7ef3b8e4c76..dc43013d46c 100644
--- a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItem.test.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItem.test.tsx
@@ -4,6 +4,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { type ComponentProps } from 'react';
import { Provider as JotaiProvider } from 'jotai';
+import { MemoryRouter } from 'react-router-dom';
import { SOURCE_LOCALE } from 'twenty-shared/translations';
import { serializePlainTextAsAdvancedTextEditorDocument } from '@/advanced-text-editor/utils/serializePlainTextAsAdvancedTextEditorDocument';
@@ -64,29 +65,29 @@ const SALES_CHANNEL = {
roleIds: [],
};
-const renderListItem = (
- thread: AgentChatThreadRecord,
- {
- isChecked = false,
- onClick = jest.fn(),
- onCheckboxClick,
- }: Pick<
- ComponentProps<typeof AiChatThreadListItem>,
- 'isChecked' | 'onCheckboxClick'
- > &
- Partial<Pick<ComponentProps<typeof AiChatThreadListItem>, 'onClick'>> = {},
-) =>
+const renderListItem = ({
+ thread,
+ isChecked = false,
+ onClick = jest.fn(),
+ onCheckboxClick,
+}: Pick<
+ ComponentProps<typeof AiChatThreadListItem>,
+ 'thread' | 'isChecked' | 'onCheckboxClick'
+> &
+ Partial<Pick<ComponentProps<typeof AiChatThreadListItem>, 'onClick'>>) =>
render(
<JotaiProvider store={jotaiStore}>
- <I18nProvider i18n={i18n}>
- <AiChatThreadListItem
- thread={thread}
- isSelected={false}
- isChecked={isChecked}
- onClick={onClick}
- onCheckboxClick={onCheckboxClick}
- />
- </I18nProvider>
+ <MemoryRouter initialEntries={['/inbox']}>
+ <I18nProvider i18n={i18n}>
+ <AiChatThreadListItem
+ thread={thread}
+ isSelected={false}
+ isChecked={isChecked}
+ onClick={onClick}
+ onCheckboxClick={onCheckboxClick}
+ />
+ </I18nProvider>
+ </MemoryRouter>
</JotaiProvider>,
);
@@ -101,30 +102,30 @@ describe('AiChatThreadListItem', () => {
});
it('shows the last message under the title', () => {
- renderListItem(buildThread({}));
+ renderListItem({ thread: buildThread({}) });
expect(screen.getByText('Which plan should I quote?')).toBeInTheDocument();
expect(screen.queryByText('Needs input')).not.toBeInTheDocument();
});
it('shows that the chat needs input while a question waits on an answer', () => {
- renderListItem(
- buildThread({
+ renderListItem({
+ thread: buildThread({
pendingQuestionMessageId: '0b6e3f1a-2c4d-4b8e-9a7f-1d3c5e7a9b20',
}),
- );
+ });
expect(screen.getByText('Needs input')).toBeInTheDocument();
expect(screen.getByText('Which plan should I quote?')).toBeInTheDocument();
});
it('does not ask for input on a deleted chat', () => {
- renderListItem(
- buildThread({
+ renderListItem({
+ thread: buildThread({
deletedAt: '2026-09-08T00:00:00.000Z',
pendingQuestionMessageId: '0b6e3f1a-2c4d-4b8e-9a7f-1d3c5e7a9b20',
}),
- );
+ });
expect(screen.queryByText('Needs input')).not.toBeInTheDocument();
});
@@ -138,7 +139,7 @@ describe('AiChatThreadListItem', () => {
),
});
- renderListItem(thread);
+ renderListItem({ thread });
expect(screen.getByText('Draft')).toBeInTheDocument();
expect(screen.getByText('Quote the **annual** plan')).toBeInTheDocument();
@@ -152,14 +153,14 @@ describe('AiChatThreadListItem', () => {
jotaiStore.set(agentChatDraftsByThreadIdState.atom, { [thread.id]: '' });
- renderListItem(thread);
+ renderListItem({ thread });
expect(screen.queryByText('Draft')).not.toBeInTheDocument();
expect(screen.getByText('Which plan should I quote?')).toBeInTheDocument();
});
it('has no checkbox where chats cannot be selected', () => {
- renderListItem(buildThread({}));
+ renderListItem({ thread: buildThread({}) });
expect(
screen.queryByRole('checkbox', { name: 'Select chat' }),
@@ -171,7 +172,7 @@ describe('AiChatThreadListItem', () => {
const onCheckboxClick = jest.fn();
const thread = buildThread({});
- renderListItem(thread, { onClick, onCheckboxClick });
+ renderListItem({ thread, onClick, onCheckboxClick });
await userEvent.click(
screen.getByRole('checkbox', { name: 'Select chat' }),
@@ -183,7 +184,8 @@ describe('AiChatThreadListItem', () => {
});
it('shows a checked chat as checked', () => {
- renderListItem(buildThread({}), {
+ renderListItem({
+ thread: buildThread({}),
isChecked: true,
onCheckboxClick: jest.fn(),
});
@@ -194,7 +196,7 @@ describe('AiChatThreadListItem', () => {
it('shows the channel a chat belongs to next to its time', () => {
jotaiStore.set(agentChatChannelsState.atom, [SALES_CHANNEL]);
- renderListItem(buildThread({ channelId: SALES_CHANNEL.id }));
+ renderListItem({ thread: buildThread({ channelId: SALES_CHANNEL.id }) });
expect(screen.getByTitle('Sales')).toBeInTheDocument();
expect(screen.getByText('In Sales')).toBeInTheDocument();
@@ -203,7 +205,7 @@ describe('AiChatThreadListItem', () => {
it('shows no channel for a chat outside channels', () => {
jotaiStore.set(agentChatChannelsState.atom, [SALES_CHANNEL]);
- renderListItem(buildThread({ channelId: null }));
+ renderListItem({ thread: buildThread({ channelId: null }) });
expect(screen.queryByTitle('Sales')).not.toBeInTheDocument();
});
@@ -216,7 +218,7 @@ describe('AiChatThreadListItem', () => {
assignment: AgentChatChannelAssignmentFilter.ANY,
});
- renderListItem(buildThread({ channelId: SALES_CHANNEL.id }));
+ renderListItem({ thread: buildThread({ channelId: SALES_CHANNEL.id }) });
expect(screen.queryByTitle('Sales')).not.toBeInTheDocument();
});
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItemActions.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItemActions.test.tsx
new file mode 100644
index 00000000000..471e8f68a15
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadListItemActions.test.tsx
@@ -0,0 +1,327 @@
+import { i18n } from '@lingui/core';
+import { I18nProvider } from '@lingui/react';
+import { render, screen } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import { SOURCE_LOCALE } from 'twenty-shared/translations';
+import { isDefined } from 'twenty-shared/utils';
+
+import { AiChatThreadListItem } from '@/ai/components/AiChatThreadListItem';
+import { agentChatChannelViewState } from '@/ai/states/agentChatChannelViewState';
+import { agentChatChannelsState } from '@/ai/states/agentChatChannelsState';
+import { agentChatThreadParticipantsState } from '@/ai/states/agentChatThreadParticipantsState';
+import { setAgentChatThreadPermissions } from '@/ai/testing/setAgentChatThreadPermissions';
+import { type AgentChatThreadRecord } from '@/ai/types/AgentChatThreadRecord';
+import { currentUserWorkspaceState } from '@/auth/states/currentUserWorkspaceState';
+import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
+import { currentWorkspaceMembersState } from '@/auth/states/currentWorkspaceMembersState';
+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
+import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
+import {
+ AgentChatChannelAssignmentFilter,
+ AgentChatChannelThreadStatus,
+ FeatureFlagKey,
+ PermissionFlagType,
+} from '~/generated-metadata/graphql';
+import { messages } from '~/locales/generated/en';
+import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
+import {
+ mockCurrentWorkspace,
+ mockedUserData,
+ mockedWorkspaceMemberData,
+} from '~/testing/mock-data/users';
+import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
+import { getTestEnrichedObjectMetadataItemsMock } from '~/testing/utils/getTestEnrichedObjectMetadataItemsMock';
+
+const THREAD_ID = '20202020-0000-4000-8000-0000000000aa';
+const THREAD_TITLE = 'Qualify the lead';
+const THREAD_ACTIVITY_AT = '2026-10-21T09:00:00.000Z';
+const INBOX_EVENT_AT = '2026-10-22T09:00:00.000Z';
+const SNOOZED_UNTIL = '2026-10-30T09:00:00.000Z';
+const SALES_CHANNEL = {
+ id: '3d8a1f5c-6b2e-4c9d-8e7f-0a1b2c3d4e5f',
+ name: 'Sales',
+ icon: 'IconCoins',
+ color: 'green',
+ position: 1,
+ isCustom: true,
+ isAccessible: true,
+ roleIds: [],
+};
+
+const CHAT_OBJECT_METADATA_ITEM = {
+ ...getMockObjectMetadataItemOrThrow('note'),
+ id: 'chat-object',
+ nameSingular: 'agentChatThread',
+ namePlural: 'agentChatThreads',
+ fields: [],
+ readableFields: [],
+ updatableFields: [],
+ indexMetadatas: [],
+};
+
+type ThreadScope = 'INBOX' | 'SNOOZED' | 'ARCHIVED';
+
+jest.mock('@/ai/hooks/useAiChatThreadRename', () => ({
+ useAiChatThreadRename: () => ({
+ isRenaming: false,
+ draftTitle: '',
+ setDraftTitle: jest.fn(),
+ startRename: jest.fn(),
+ cancelRename: jest.fn(),
+ commitRename: jest.fn(),
+ }),
+}));
+
+jest.mock('@/ai/hooks/useExecuteAgentChatThreadInboxAction', () => ({
+ useExecuteAgentChatThreadInboxAction: () => ({
+ executeAgentChatThreadInboxAction: jest.fn(),
+ isPending: false,
+ }),
+}));
+
+const renderThread = async ({
+ scope = 'SNOOZED',
+ hasAiPermission = true,
+ isInboxEnabled = true,
+ isDeleted = false,
+ channelStatus,
+ pathname = '/inbox',
+ onDetach,
+}: {
+ scope?: ThreadScope;
+ hasAiPermission?: boolean;
+ isInboxEnabled?: boolean;
+ isDeleted?: boolean;
+ channelStatus?: AgentChatChannelThreadStatus;
+ pathname?: string;
+ onDetach?: () => void;
+} = {}) => {
+ const thread: AgentChatThreadRecord = {
+ __typename: 'AgentChatThread',
+ id: THREAD_ID,
+ title: THREAD_TITLE,
+ createdAt: THREAD_ACTIVITY_AT,
+ updatedAt: THREAD_ACTIVITY_AT,
+ lastActivityAt: THREAD_ACTIVITY_AT,
+ deletedAt: isDeleted ? INBOX_EVENT_AT : null,
+ lastMessageText: 'Prepare the next step',
+ workspaceMemberId: mockedWorkspaceMemberData.id,
+ channelId: isDefined(channelStatus) ? SALES_CHANNEL.id : null,
+ channelArchivedAt:
+ isDefined(channelStatus) &&
+ channelStatus !== AgentChatChannelThreadStatus.OPEN
+ ? INBOX_EVENT_AT
+ : null,
+ channelSnoozedUntil:
+ channelStatus === AgentChatChannelThreadStatus.SNOOZED
+ ? SNOOZED_UNTIL
+ : null,
+ };
+ const Wrapper = getJestMetadataAndApolloMocksWrapper({
+ objectMetadataItems: [
+ ...getTestEnrichedObjectMetadataItemsMock(),
+ CHAT_OBJECT_METADATA_ITEM,
+ ],
+ onInitializeJotaiStore: (store) => {
+ store.set(currentWorkspaceState.atom, {
+ ...mockCurrentWorkspace,
+ featureFlags: [
+ {
+ key: FeatureFlagKey.IS_AI_CHAT_INBOX_ENABLED,
+ value: isInboxEnabled,
+ },
+ ],
+ });
+ store.set(currentUserWorkspaceState.atom, {
+ ...mockedUserData.currentUserWorkspace,
+ permissionFlags: hasAiPermission ? [PermissionFlagType.AI] : [],
+ });
+ store.set(currentWorkspaceMemberState.atom, mockedWorkspaceMemberData);
+ store.set(currentWorkspaceMembersState.atom, [mockedWorkspaceMemberData]);
+ store.set(
+ agentChatChannelsState.atom,
+ isDefined(channelStatus) ? [SALES_CHANNEL] : [],
+ );
+ store.set(
+ agentChatChannelViewState.atom,
+ isDefined(channelStatus)
+ ? {
+ channelId: SALES_CHANNEL.id,
+ channelStatus,
+ assignment: AgentChatChannelAssignmentFilter.ANY,
+ }
+ : null,
+ );
+ setAgentChatThreadPermissions(store, THREAD_ID, {
+ canRead: true,
+ canUpdate: true,
+ canDelete: true,
+ canSoftDelete: true,
+ });
+ store.set(recordStoreFamilyState.atomFamily(THREAD_ID), thread);
+ store.set(agentChatThreadParticipantsState.atom, {
+ [THREAD_ID]: {
+ __typename: 'AgentChatThreadParticipant',
+ id: '20202020-0000-4000-8000-0000000000bb',
+ threadId: THREAD_ID,
+ isSubscribed: true,
+ archivedAt: scope === 'INBOX' ? null : INBOX_EVENT_AT,
+ snoozedUntil: scope === 'SNOOZED' ? SNOOZED_UNTIL : null,
+ lastReadAt: THREAD_ACTIVITY_AT,
+ updatedAt: INBOX_EVENT_AT,
+ },
+ });
+ },
+ });
+
+ render(
+ <Wrapper>
+ <MemoryRouter initialEntries={[pathname]}>
+ <I18nProvider i18n={i18n}>
+ <AiChatThreadListItem
+ thread={thread}
+ isSelected={false}
+ onClick={jest.fn()}
+ onDetach={onDetach}
+ />
+ </I18nProvider>
+ </MemoryRouter>
+ </Wrapper>,
+ );
+
+ await screen.findByRole('group', { name: THREAD_TITLE });
+};
+
+describe('AiChatThreadListItem action availability', () => {
+ beforeAll(() => {
+ i18n.load({ [SOURCE_LOCALE]: messages });
+ i18n.activate(SOURCE_LOCALE);
+ });
+
+ it.each([
+ {
+ reason: 'AI permission is missing',
+ scope: 'SNOOZED',
+ hasAiPermission: false,
+ },
+ {
+ reason: 'the inbox flag is disabled',
+ scope: 'ARCHIVED',
+ isInboxEnabled: false,
+ },
+ ] satisfies {
+ reason: string;
+ scope: ThreadScope;
+ hasAiPermission?: boolean;
+ isInboxEnabled?: boolean;
+ }[])('keeps More when $reason', async (options) => {
+ await renderThread(options);
+
+ expect(
+ screen.getByRole('button', { name: 'Chat actions' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Change' }),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Wake now' }),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Reopen' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('shows Change and Wake now without More for an available snoozed chat', async () => {
+ await renderThread();
+
+ expect(screen.getByRole('button', { name: 'Change' })).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'Wake now' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Chat actions' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('shows Reopen without More for an available archived chat', async () => {
+ await renderThread({ scope: 'ARCHIVED' });
+
+ expect(screen.getByRole('button', { name: 'Reopen' })).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Chat actions' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('keeps More for a linked snoozed chat with a Detach action', async () => {
+ await renderThread({ onDetach: jest.fn() });
+
+ expect(
+ screen.getByRole('button', { name: 'Chat actions' }),
+ ).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Change' })).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'Wake now' }),
+ ).toBeInTheDocument();
+ });
+
+ it('keeps More without triage actions for a deleted archived chat', async () => {
+ await renderThread({ scope: 'ARCHIVED', isDeleted: true });
+
+ expect(
+ screen.getByRole('button', { name: 'Chat actions' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Reopen' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('shows open channel actions when the personal copy is snoozed', async () => {
+ await renderThread({
+ scope: 'SNOOZED',
+ channelStatus: AgentChatChannelThreadStatus.OPEN,
+ });
+
+ expect(screen.getByRole('button', { name: 'Snooze' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Done' })).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'Chat actions' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Wake now' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('shows done channel actions when the personal copy is open', async () => {
+ await renderThread({
+ scope: 'INBOX',
+ channelStatus: AgentChatChannelThreadStatus.DONE,
+ });
+
+ expect(screen.getByRole('button', { name: 'Reopen' })).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Chat actions' }),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Snooze' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('uses the personal copy outside the inbox despite a selected done channel', async () => {
+ await renderThread({
+ scope: 'SNOOZED',
+ channelStatus: AgentChatChannelThreadStatus.DONE,
+ pathname: '/companies',
+ });
+
+ expect(screen.getByRole('button', { name: 'Change' })).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'Wake now' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Reopen' }),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Chat actions' }),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/twenty-front/src/modules/ai/hooks/useAiChatThreadTriage.ts b/packages/twenty-front/src/modules/ai/hooks/useAiChatThreadTriage.ts
new file mode 100644
index 00000000000..e4c757888b0
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/hooks/useAiChatThreadTriage.ts
@@ -0,0 +1,49 @@
+import { useLocation } from 'react-router-dom';
+import { isDefined } from 'twenty-shared/utils';
+
+import { agentChatThreadParticipantsState } from '@/ai/states/agentChatThreadParticipantsState';
+import { agentChatShownChannelViewSelector } from '@/ai/states/selectors/agentChatShownChannelViewSelector';
+import { agentChatThreadInboxStatusByThreadIdFamilySelector } from '@/ai/states/selectors/agentChatThreadInboxStatusByThreadIdFamilySelector';
+import { getAiChatThreadTriageStatus } from '@/ai/utils/getAiChatThreadTriageStatus';
+import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
+import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
+import {
+ FeatureFlagKey,
+ PermissionFlagType,
+} from '~/generated-metadata/graphql';
+import { isAiChatInboxPath } from '~/utils/isAiChatInboxPath';
+
+export const useAiChatThreadTriage = (threadId: string) => {
+ const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
+ const isInboxEnabled = useIsFeatureEnabled(
+ FeatureFlagKey.IS_AI_CHAT_INBOX_ENABLED,
+ );
+ const agentChatThreadParticipants = useAtomStateValue(
+ agentChatThreadParticipantsState,
+ );
+ const location = useLocation();
+ const agentChatShownChannelView = useAtomStateValue(
+ agentChatShownChannelViewSelector,
+ );
+ const { [threadId]: inboxStatus } = useAtomFamilySelectorValue(
+ agentChatThreadInboxStatusByThreadIdFamilySelector,
+ {
+ threadIds: [threadId],
+ channelId: isAiChatInboxPath(location.pathname)
+ ? (agentChatShownChannelView?.channelId ?? null)
+ : null,
+ },
+ );
+
+ return {
+ status: getAiChatThreadTriageStatus({
+ hasAiPermission,
+ isInboxEnabled,
+ areParticipantsLoaded: isDefined(agentChatThreadParticipants),
+ scope: inboxStatus?.scope ?? 'NONE',
+ }),
+ isInChannel: inboxStatus?.isChannelCopy ?? false,
+ };
+};
diff --git a/packages/twenty-front/src/modules/ai/utils/getAiChatThreadTriageStatus.ts b/packages/twenty-front/src/modules/ai/utils/getAiChatThreadTriageStatus.ts
new file mode 100644
index 00000000000..0e70a188b79
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/utils/getAiChatThreadTriageStatus.ts
@@ -0,0 +1,30 @@
+import { type AgentChatThreadInboxStatus } from '@/ai/types/AgentChatThreadInboxStatus';
+
+const TRIAGE_STATUS_BY_SCOPE = {
+ INBOX: 'open',
+ SNOOZED: 'snoozed',
+ ARCHIVED: 'done',
+} as const;
+
+export const getAiChatThreadTriageStatus = ({
+ hasAiPermission,
+ isInboxEnabled,
+ areParticipantsLoaded,
+ scope,
+}: {
+ hasAiPermission: boolean;
+ isInboxEnabled: boolean;
+ areParticipantsLoaded: boolean;
+ scope: AgentChatThreadInboxStatus['scope'];
+}) => {
+ if (
+ !hasAiPermission ||
+ !isInboxEnabled ||
+ !areParticipantsLoaded ||
+ scope === 'NONE'
+ ) {
+ return undefined;
+ }
+
+ return TRIAGE_STATUS_BY_SCOPE[scope];
+};
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 0273a12f841..ddf8e61c385 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -614,6 +614,8 @@ export const DOCUMENTED_COMPONENTS = [
'Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it.',
actionsVisibility:
'When trailing actions are visible: on hover and focus, or always.',
+ actionsPlacement:
+ 'Keeps actions beside the content at every width when set to `end`. The default `auto` preserves responsive wrapping. Hidden end actions do not reserve width on devices without touch.',
},
},
{
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 4b82e9828be..6d1db6b4bb0 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -7972,6 +7972,13 @@
"defaultValue": null,
"description": "Trailing content, such as buttons, rendered after the content."
},
+ {
+ "name": "actionsPlacement",
+ "type": "\"auto\" | \"end\"",
+ "required": false,
+ "defaultValue": "auto",
+ "description": "Keeps actions beside the content at every width when set to `end`. The default `auto` preserves responsive wrapping. Hidden end actions do not reserve width on devices without touch."
+ },
{
"name": "actionsVisibility",
"type": "\"always\" | \"hover\"",
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
index 287e5e65b93..99919b85187 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
@@ -144,6 +144,19 @@
.root:focus-within .actions {
opacity: 1;
}
+
+ .root[data-actions-placement='end'][data-actions-visibility='hover'] {
+ > .actions {
+ inset-block-start: 0;
+ inset-inline-end: var(--t-spacing-1);
+ position: absolute;
+ }
+
+ &:hover > .actions,
+ &:focus-within > .actions {
+ position: static;
+ }
+ }
}
.checkIndicator {
@@ -194,8 +207,22 @@
}
}
+.root[data-description-placement='below'][data-actions-placement='end'] {
+ flex-wrap: nowrap;
+
+ .label {
+ gap: var(--t-spacing-0_5);
+ }
+
+ .actions {
+ flex-wrap: nowrap;
+ max-inline-size: none;
+ }
+}
+
@container (max-width: 480px) {
- .root[data-description-placement='below'] > .actions {
+ .root[data-description-placement='below']:not([data-actions-placement='end'])
+ > .actions {
flex-basis: 100%;
max-inline-size: 100%;
}
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
index ba6954f67c6..91c29ae42ca 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
@@ -26,6 +26,7 @@ export const ListItem = ({
descriptionPlacement = 'inline',
actions,
actionsVisibility = 'hover',
+ actionsPlacement = 'auto',
shortcut,
shortcutJoinLabel,
hasSubmenu = false,
@@ -54,6 +55,7 @@ export const ListItem = ({
props: {
...props,
'data-actions-visibility': actionsVisibility,
+ 'data-actions-placement': actionsPlacement,
'data-description-placement': descriptionPlacement,
'data-selection-appearance': selectionAppearance,
className: clsx(styles.root, className),
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiline.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiline.stories.tsx
index ca93a08edd9..ae3bb3cd051 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiline.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiline.stories.tsx
@@ -10,11 +10,14 @@ import {
ComponentDecorator,
type CatalogStory,
} from '@ui/testing';
+import { themeCssVariables } from '@ui/theme';
import { ListItem } from '../ListItem';
import { type ListItemProps } from '../types/ListItemProps';
import { ListItemMultilineExample } from './ListItemMultilineExample';
+const onEndAction = fn();
+
const meta: Meta<typeof ListItem> = {
title: 'UI/Navigation/ListItem/Multiline',
component: ListItem,
@@ -84,6 +87,87 @@ export const NarrowControlInteractions: Story = {
},
};
+export const EndActionInteractions: Story = {
+ tags: ['!autodocs', '!dev'],
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 400 } },
+ args: {
+ render: <div role="group" aria-label="Planning document" />,
+ onClick: fn(),
+ actionsPlacement: 'end',
+ children: (
+ <Text
+ render={<span />}
+ style={{ display: 'block', lineHeight: themeCssVariables.spacing[4] }}
+ truncate
+ >
+ Quarterly planning and the proposed timeline for every team
+ </Text>
+ ),
+ description: (
+ <Text
+ render={<span />}
+ style={{
+ display: 'block',
+ lineHeight: `calc(${themeCssVariables.spacing[4]} - ${themeCssVariables.spacing[0.5]})`,
+ }}
+ truncate
+ >
+ Review the proposed timeline and confirm the next steps with the team.
+ </Text>
+ ),
+ actions: (
+ <Button
+ size="sm"
+ variant="ghost"
+ onClick={(event) => {
+ event.stopPropagation();
+ onEndAction();
+ }}
+ >
+ Archive
+ </Button>
+ ),
+ },
+ play: async ({ canvasElement, args }) => {
+ const { userEvent: trustedUserEvent } = await import('vitest/browser');
+ const canvas = within(canvasElement);
+ const row = canvas.getByRole('group', { name: 'Planning document' });
+ const archive = canvas.getByRole('button', { name: 'Archive' });
+ const title = canvas.getByText(
+ 'Quarterly planning and the proposed timeline for every team',
+ );
+ const description = canvas.getByText(
+ 'Review the proposed timeline and confirm the next steps with the team.',
+ );
+ await trustedUserEvent.unhover(row);
+ const initialHeight = row.getBoundingClientRect().height;
+ const initialTitleWidth = title.clientWidth;
+
+ await trustedUserEvent.hover(row);
+ await waitFor(() => expect(archive).toBeVisible());
+ await expect(row.getBoundingClientRect().height).toBe(initialHeight);
+ await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
+ await trustedUserEvent.unhover(row);
+ await userEvent.tab();
+ await expect(archive).toHaveFocus();
+ await waitFor(() =>
+ expect(archive.parentElement).toHaveStyle({ opacity: '1' }),
+ );
+ await expect(row.getBoundingClientRect().height).toBe(initialHeight);
+ await expect(archive.getBoundingClientRect().top).toBeLessThan(
+ description.getBoundingClientRect().bottom,
+ );
+ await expect(title.clientWidth).toBeLessThan(initialTitleWidth);
+ await expect(title).toHaveStyle({ textOverflow: 'ellipsis' });
+ await expect(description).toHaveStyle({ textOverflow: 'ellipsis' });
+ await expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
+ await userEvent.keyboard('{Enter}');
+ await expect(onEndAction).toHaveBeenCalledTimes(1);
+ await expect(args.onClick).not.toHaveBeenCalled();
+ },
+};
+
export const TruncatedDescription: Story = {
decorators: [ComponentDecorator],
parameters: { container: { width: 240 } },
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts b/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
index 3989856549d..91290586b74 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
@@ -44,6 +44,7 @@ export type ListItemProps = Omit<
/** Trailing content, such as buttons, rendered after the content. */
actions?: ReactNode;
actionsVisibility?: 'hover' | 'always';
+ actionsPlacement?: 'auto' | 'end';
/**
* Keyboard shortcut keys displayed at the end of the row. Registering the
* shortcut is up to the application.