Skip to content

The open alternative to Salesforce, designed for AI.

Remove AI chat inbox filter dropdown (#27172)

Félix Malfaitf8a020f89e7e
diff --git a/packages/twenty-front/src/modules/ai/components/AgentChatThreadInboxClockEffect.tsx b/packages/twenty-front/src/modules/ai/components/AgentChatThreadInboxClockEffect.tsx
index 338991c8798..d10856d8d68 100644
--- a/packages/twenty-front/src/modules/ai/components/AgentChatThreadInboxClockEffect.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AgentChatThreadInboxClockEffect.tsx
@@ -4,8 +4,7 @@ import { useEffect } from 'react';
import { agentChatThreadInboxNowState } from '@/ai/states/agentChatThreadInboxNowState';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
-// Snoozes end, and threads age out of the last activity filter, without any
-// event announcing it
+// Snoozes end without any event announcing it
export const AgentChatThreadInboxClockEffect = () => {
const setAgentChatThreadInboxNow = useSetAtomState(
agentChatThreadInboxNowState,
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdown.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdown.tsx
deleted file mode 100644
index 9ca7777e97b..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdown.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { useLingui } from '@lingui/react/macro';
-import { Dropdown } from 'twenty-ui/components';
-import { IconChevronDown } from 'twenty-ui/icon';
-import { Button } from 'twenty-ui/primitives/input';
-
-import { AiChatThreadFilterDropdownContent } from '@/ai/components/AiChatThreadFilterDropdownContent';
-import { AGENT_CHAT_THREAD_FILTER_STATUS_ICONS } from '@/ai/constants/AgentChatThreadFilterStatusIcons';
-import { AGENT_CHAT_THREAD_FILTER_STATUS_LABELS } from '@/ai/constants/AgentChatThreadFilterStatusLabels';
-import { AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE } from '@/ai/constants/AiChatThreadFilterDropdownPage';
-import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
-import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-
-export const AiChatThreadFilterDropdown = () => {
- const { t } = useLingui();
- const agentChatThreadFilterStatus = useAtomStateValue(
- agentChatThreadFilterStatusState,
- );
- const StatusIcon =
- AGENT_CHAT_THREAD_FILTER_STATUS_ICONS[agentChatThreadFilterStatus];
-
- return (
- <DropdownRoot
- dropdownId="ai-chat-thread-filter"
- type="menu"
- defaultPage={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.ROOT}
- >
- <Dropdown.Trigger
- render={
- <Button
- variant="ghost"
- size="sm"
- startIcon={<StatusIcon />}
- endIcon={<IconChevronDown />}
- >
- {t(
- AGENT_CHAT_THREAD_FILTER_STATUS_LABELS[
- agentChatThreadFilterStatus
- ],
- )}
- </Button>
- }
- />
- <Dropdown.Content align="start" aria-label={t`Filter chats`}>
- <AiChatThreadFilterDropdownContent />
- </Dropdown.Content>
- </DropdownRoot>
- );
-};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownContent.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownContent.tsx
deleted file mode 100644
index 4bd7f297dea..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownContent.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Dropdown } from 'twenty-ui/components';
-
-import { AiChatThreadFilterDropdownGroupByMenu } from '@/ai/components/AiChatThreadFilterDropdownGroupByMenu';
-import { AiChatThreadFilterDropdownLastActivityMenu } from '@/ai/components/AiChatThreadFilterDropdownLastActivityMenu';
-import { AiChatThreadFilterDropdownRootMenu } from '@/ai/components/AiChatThreadFilterDropdownRootMenu';
-import { AiChatThreadFilterDropdownStatusMenu } from '@/ai/components/AiChatThreadFilterDropdownStatusMenu';
-import { AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE } from '@/ai/constants/AiChatThreadFilterDropdownPage';
-
-export const AiChatThreadFilterDropdownContent = () => (
- <>
- <Dropdown.Page id={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.ROOT} type="menu">
- <AiChatThreadFilterDropdownRootMenu />
- </Dropdown.Page>
- <Dropdown.Page
- id={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.STATUS}
- type="picker"
- >
- <AiChatThreadFilterDropdownStatusMenu />
- </Dropdown.Page>
- <Dropdown.Page
- id={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.GROUP_BY}
- type="picker"
- >
- <AiChatThreadFilterDropdownGroupByMenu />
- </Dropdown.Page>
- <Dropdown.Page
- id={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.LAST_ACTIVITY}
- type="picker"
- >
- <AiChatThreadFilterDropdownLastActivityMenu />
- </Dropdown.Page>
- </>
-);
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownGroupByMenu.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownGroupByMenu.tsx
deleted file mode 100644
index 1a0bc156d40..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownGroupByMenu.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { useLingui } from '@lingui/react/macro';
-import { Dropdown } from 'twenty-ui/components';
-
-import { AGENT_CHAT_THREAD_GROUP_BY } from '@/ai/constants/AgentChatThreadGroupBy';
-import { AGENT_CHAT_THREAD_GROUP_BY_LABELS } from '@/ai/constants/AgentChatThreadGroupByLabels';
-import { agentChatThreadGroupByState } from '@/ai/states/agentChatThreadGroupByState';
-import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
-
-const AGENT_CHAT_THREAD_GROUP_BY_OPTIONS = [
- AGENT_CHAT_THREAD_GROUP_BY.DATE,
- AGENT_CHAT_THREAD_GROUP_BY.NONE,
-] as const;
-
-export const AiChatThreadFilterDropdownGroupByMenu = () => {
- const { t } = useLingui();
- const [agentChatThreadGroupBy, setAgentChatThreadGroupBy] = useAtomState(
- agentChatThreadGroupByState,
- );
-
- return (
- <>
- <Dropdown.Back>{t`Group by`}</Dropdown.Back>
- <Dropdown.Section>
- {AGENT_CHAT_THREAD_GROUP_BY_OPTIONS.map((option) => (
- <Dropdown.OptionItem
- key={option}
- onSelect={() => {
- setAgentChatThreadGroupBy(option);
- }}
- selected={agentChatThreadGroupBy === option}
- >
- {t(AGENT_CHAT_THREAD_GROUP_BY_LABELS[option])}
- </Dropdown.OptionItem>
- ))}
- </Dropdown.Section>
- </>
- );
-};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownLastActivityMenu.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownLastActivityMenu.tsx
deleted file mode 100644
index 746ebed87b9..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownLastActivityMenu.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { useLingui } from '@lingui/react/macro';
-import { Dropdown } from 'twenty-ui/components';
-
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER } from '@/ai/constants/AgentChatThreadLastActivityFilter';
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_LABELS } from '@/ai/constants/AgentChatThreadLastActivityFilterLabels';
-import { agentChatThreadLastActivityFilterState } from '@/ai/states/agentChatThreadLastActivityFilterState';
-import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
-
-const AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_OPTIONS = [
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ONE_DAY,
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.THREE_DAYS,
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.SEVEN_DAYS,
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.THIRTY_DAYS,
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ALL,
-] as const;
-
-export const AiChatThreadFilterDropdownLastActivityMenu = () => {
- const { t } = useLingui();
- const [
- agentChatThreadLastActivityFilter,
- setAgentChatThreadLastActivityFilter,
- ] = useAtomState(agentChatThreadLastActivityFilterState);
-
- return (
- <>
- <Dropdown.Back>{t`Last activity`}</Dropdown.Back>
- <Dropdown.Section>
- {AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_OPTIONS.map((option) => (
- <Dropdown.OptionItem
- key={option}
- onSelect={() => {
- setAgentChatThreadLastActivityFilter(option);
- }}
- selected={agentChatThreadLastActivityFilter === option}
- >
- {t(AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_LABELS[option])}
- </Dropdown.OptionItem>
- ))}
- </Dropdown.Section>
- </>
- );
-};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownRootMenu.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownRootMenu.tsx
deleted file mode 100644
index af45c696396..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownRootMenu.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import { Dropdown } from 'twenty-ui/components';
-import { useLingui } from '@lingui/react/macro';
-import {
- IconClock,
- IconLayoutList,
- IconStatusChange,
- IconTrash,
-} from 'twenty-ui/icon';
-
-import { AGENT_CHAT_THREAD_FILTER_STATUS } from '@/ai/constants/AgentChatThreadFilterStatus';
-import { AGENT_CHAT_THREAD_FILTER_STATUS_LABELS } from '@/ai/constants/AgentChatThreadFilterStatusLabels';
-import { AGENT_CHAT_THREAD_GROUP_BY } from '@/ai/constants/AgentChatThreadGroupBy';
-import { AGENT_CHAT_THREAD_GROUP_BY_LABELS } from '@/ai/constants/AgentChatThreadGroupByLabels';
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER } from '@/ai/constants/AgentChatThreadLastActivityFilter';
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_LABELS } from '@/ai/constants/AgentChatThreadLastActivityFilterLabels';
-import { AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE } from '@/ai/constants/AiChatThreadFilterDropdownPage';
-import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
-import { agentChatThreadGroupByState } from '@/ai/states/agentChatThreadGroupByState';
-import { agentChatThreadLastActivityFilterState } from '@/ai/states/agentChatThreadLastActivityFilterState';
-import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
-
-export const AiChatThreadFilterDropdownRootMenu = () => {
- const { t } = useLingui();
-
- const [agentChatThreadFilterStatus, setAgentChatThreadFilterStatus] =
- useAtomState(agentChatThreadFilterStatusState);
- const [agentChatThreadGroupBy, setAgentChatThreadGroupBy] = useAtomState(
- agentChatThreadGroupByState,
- );
- const [
- agentChatThreadLastActivityFilter,
- setAgentChatThreadLastActivityFilter,
- ] = useAtomState(agentChatThreadLastActivityFilterState);
-
- const isAtDefaults =
- agentChatThreadFilterStatus === AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE &&
- agentChatThreadGroupBy === AGENT_CHAT_THREAD_GROUP_BY.DATE &&
- agentChatThreadLastActivityFilter ===
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ALL;
-
- const handleClearFilters = () => {
- setAgentChatThreadFilterStatus(AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE);
- setAgentChatThreadGroupBy(AGENT_CHAT_THREAD_GROUP_BY.DATE);
- setAgentChatThreadLastActivityFilter(
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ALL,
- );
- };
-
- return (
- <>
- <Dropdown.Section>
- <Dropdown.ActionItem
- startIcon={<IconStatusChange />}
- description={t(
- AGENT_CHAT_THREAD_FILTER_STATUS_LABELS[agentChatThreadFilterStatus],
- )}
- descriptionPlacement="end"
- hasSubmenu
- page={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.STATUS}
- >{t`Status`}</Dropdown.ActionItem>
- <Dropdown.ActionItem
- startIcon={<IconLayoutList />}
- description={t(
- AGENT_CHAT_THREAD_GROUP_BY_LABELS[agentChatThreadGroupBy],
- )}
- descriptionPlacement="end"
- hasSubmenu
- page={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.GROUP_BY}
- >{t`Group by`}</Dropdown.ActionItem>
- <Dropdown.ActionItem
- startIcon={<IconClock />}
- description={t(
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_LABELS[
- agentChatThreadLastActivityFilter
- ],
- )}
- descriptionPlacement="end"
- hasSubmenu
- page={AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE.LAST_ACTIVITY}
- >{t`Last activity`}</Dropdown.ActionItem>
- {!isAtDefaults && (
- <>
- <Dropdown.Separator />
- <Dropdown.ActionItem
- color="danger"
- startIcon={<IconTrash />}
- onClick={handleClearFilters}
- >{t`Clear filters`}</Dropdown.ActionItem>
- </>
- )}
- </Dropdown.Section>
- </>
- );
-};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownStatusMenu.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownStatusMenu.tsx
deleted file mode 100644
index a3c3f702487..00000000000
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadFilterDropdownStatusMenu.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { useLingui } from '@lingui/react/macro';
-import { Dropdown } from 'twenty-ui/components';
-
-import { AGENT_CHAT_THREAD_FILTER_STATUS } from '@/ai/constants/AgentChatThreadFilterStatus';
-import { AGENT_CHAT_THREAD_FILTER_STATUS_LABELS } from '@/ai/constants/AgentChatThreadFilterStatusLabels';
-import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
-import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
-
-const AGENT_CHAT_THREAD_FILTER_STATUS_OPTIONS = [
- AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE,
- AGENT_CHAT_THREAD_FILTER_STATUS.UNREAD,
- AGENT_CHAT_THREAD_FILTER_STATUS.SNOOZED,
- AGENT_CHAT_THREAD_FILTER_STATUS.DONE,
- AGENT_CHAT_THREAD_FILTER_STATUS.DELETED,
- AGENT_CHAT_THREAD_FILTER_STATUS.ALL,
-] as const;
-
-export const AiChatThreadFilterDropdownStatusMenu = () => {
- const { t } = useLingui();
- const [agentChatThreadFilterStatus, setAgentChatThreadFilterStatus] =
- useAtomState(agentChatThreadFilterStatusState);
-
- return (
- <>
- <Dropdown.Back>{t`Status`}</Dropdown.Back>
- <Dropdown.Section>
- {AGENT_CHAT_THREAD_FILTER_STATUS_OPTIONS.map((option) => (
- <Dropdown.OptionItem
- key={option}
- onSelect={() => {
- setAgentChatThreadFilterStatus(option);
- }}
- selected={agentChatThreadFilterStatus === option}
- >
- {t(AGENT_CHAT_THREAD_FILTER_STATUS_LABELS[option])}
- </Dropdown.OptionItem>
- ))}
- </Dropdown.Section>
- </>
- );
-};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadList.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadList.tsx
index ee50d6f121f..646a8ab926f 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadList.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatThreadList.tsx
@@ -19,7 +19,6 @@ type AiChatThreadListProps = {
threads: AgentChatThreadRecord[];
surface: AiChatThreadActionsSurface;
selectedThreadId?: string;
- isGroupedByDate?: boolean;
onThreadClick: (thread: AgentChatThreadRecord) => void;
onDetachThread?: (threadId: string) => void;
};
@@ -28,7 +27,6 @@ export const AiChatThreadList = ({
threads,
surface,
selectedThreadId,
- isGroupedByDate = true,
onThreadClick,
onDetachThread,
}: AiChatThreadListProps) => {
@@ -47,14 +45,12 @@ export const AiChatThreadList = ({
return (
<>
- {isGroupedByDate
- ? groupThreadsByDate(threads).map((dateGroup) => (
- <div key={dateGroup.id}>
- <StyledGroupTitle>{dateGroup.title}</StyledGroupTitle>
- {dateGroup.threads.map(renderThread)}
- </div>
- ))
- : threads.map(renderThread)}
+ {groupThreadsByDate(threads).map((dateGroup) => (
+ <div key={dateGroup.id}>
+ <StyledGroupTitle>{dateGroup.title}</StyledGroupTitle>
+ {dateGroup.threads.map(renderThread)}
+ </div>
+ ))}
</>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadFilterDropdown.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadFilterDropdown.test.tsx
deleted file mode 100644
index a6ac68adeeb..00000000000
--- a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatThreadFilterDropdown.test.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import { i18n } from '@lingui/core';
-import { I18nProvider } from '@lingui/react';
-import { render, screen, waitFor } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import { createStore, Provider } from 'jotai';
-
-import { AiChatThreadFilterDropdown } from '@/ai/components/AiChatThreadFilterDropdown';
-import { AGENT_CHAT_THREAD_FILTER_STATUS } from '@/ai/constants/AgentChatThreadFilterStatus';
-import { AGENT_CHAT_THREAD_GROUP_BY } from '@/ai/constants/AgentChatThreadGroupBy';
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER } from '@/ai/constants/AgentChatThreadLastActivityFilter';
-import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
-import { agentChatThreadGroupByState } from '@/ai/states/agentChatThreadGroupByState';
-import { agentChatThreadLastActivityFilterState } from '@/ai/states/agentChatThreadLastActivityFilterState';
-import { focusStackState } from '@/ui/utilities/focus/states/focusStackState';
-
-const renderFilterDropdown = () => {
- const store = createStore();
- store.set(
- agentChatThreadFilterStatusState.atom,
- AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE,
- );
- store.set(agentChatThreadGroupByState.atom, AGENT_CHAT_THREAD_GROUP_BY.DATE);
- store.set(
- agentChatThreadLastActivityFilterState.atom,
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ALL,
- );
-
- render(
- <I18nProvider i18n={i18n}>
- <Provider store={store}>
- <AiChatThreadFilterDropdown />
- </Provider>
- </I18nProvider>,
- );
-
- return { store, user: userEvent.setup() };
-};
-
-describe('AiChatThreadFilterDropdown', () => {
- it('applies a filter, restores the trigger, and reopens at the root page', async () => {
- const { store, user } = renderFilterDropdown();
- const trigger = screen.getByRole('button', { name: 'Open' });
-
- await user.click(trigger);
- await user.click(await screen.findByRole('menuitem', { name: /Status/ }));
- await user.click(await screen.findByRole('button', { name: 'Deleted' }));
-
- expect(store.get(agentChatThreadFilterStatusState.atom)).toBe(
- AGENT_CHAT_THREAD_FILTER_STATUS.DELETED,
- );
- await waitFor(() =>
- expect(screen.queryByRole('dialog')).not.toBeInTheDocument(),
- );
- await waitFor(() => expect(trigger).toHaveFocus());
- await waitFor(() => expect(store.get(focusStackState.atom)).toEqual([]));
-
- await user.click(trigger);
- expect(
- await screen.findByRole('menuitem', { name: /Status Deleted/ }),
- ).toBeVisible();
- await user.click(screen.getByRole('menuitem', { name: 'Clear filters' }));
- expect(store.get(agentChatThreadFilterStatusState.atom)).toBe('active');
- });
-
- it('returns from a picker without changing its value and releases shortcut scope on dismissal', async () => {
- const { store, user } = renderFilterDropdown();
- await user.click(screen.getByRole('button', { name: 'Open' }));
- await user.click(await screen.findByRole('menuitem', { name: /Group by/ }));
- expect(
- await screen.findByRole('button', { name: 'Date', pressed: true }),
- ).toBeVisible();
- expect(store.get(focusStackState.atom).at(-1)?.globalHotkeysConfig).toEqual(
- {
- enableGlobalHotkeysConflictingWithKeyboard: false,
- enableGlobalHotkeysWithModifiers: false,
- },
- );
-
- await user.click(screen.getByRole('button', { name: 'Group by' }));
- expect(
- await screen.findByRole('menuitem', { name: /Group by/ }),
- ).toHaveFocus();
- expect(store.get(agentChatThreadGroupByState.atom)).toBe('date');
- await user.keyboard('{Escape}');
- await waitFor(() => expect(store.get(focusStackState.atom)).toEqual([]));
- });
-});
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatus.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatus.ts
index 409bb8039ae..a8abe2ba486 100644
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatus.ts
+++ b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatus.ts
@@ -1,9 +1,5 @@
export const AGENT_CHAT_THREAD_FILTER_STATUS = {
ACTIVE: 'active',
- UNREAD: 'unread',
SNOOZED: 'snoozed',
DONE: 'done',
- // Deleting a chat used to archive it, so saved filters still hold 'archived'
- DELETED: 'archived',
- ALL: 'all',
} as const;
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusIcons.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusIcons.ts
index a78c3c103d5..bbd234e5ef7 100644
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusIcons.ts
+++ b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusIcons.ts
@@ -2,10 +2,7 @@ import {
type IconComponent,
IconCircleDashed,
IconClock,
- IconEyeOff,
- IconMessage,
IconProgressCheck,
- IconTrash,
} from 'twenty-ui/icon';
import { type AgentChatThreadFilterStatus } from '@/ai/types/AgentChatThreadFilterStatus';
@@ -15,9 +12,6 @@ export const AGENT_CHAT_THREAD_FILTER_STATUS_ICONS: Record<
IconComponent
> = {
active: IconCircleDashed,
- unread: IconEyeOff,
snoozed: IconClock,
done: IconProgressCheck,
- archived: IconTrash,
- all: IconMessage,
};
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusLabels.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusLabels.ts
index 73e452f480f..4d4c09ba3fc 100644
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusLabels.ts
+++ b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadFilterStatusLabels.ts
@@ -8,9 +8,6 @@ export const AGENT_CHAT_THREAD_FILTER_STATUS_LABELS: Record<
MessageDescriptor
> = {
active: msg`Open`,
- unread: msg`Unread`,
snoozed: msg`Snoozed`,
done: msg`Done`,
- archived: msg`Deleted`,
- all: msg`All`,
};
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadGroupBy.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadGroupBy.ts
deleted file mode 100644
index e6cbf6c04dc..00000000000
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadGroupBy.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export const AGENT_CHAT_THREAD_GROUP_BY = {
- DATE: 'date',
- NONE: 'none',
-} as const;
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadGroupByLabels.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadGroupByLabels.ts
deleted file mode 100644
index 105f75608a1..00000000000
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadGroupByLabels.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { msg } from '@lingui/core/macro';
-import { type MessageDescriptor } from '@lingui/core';
-
-import { type AgentChatThreadGroupBy } from '@/ai/types/AgentChatThreadGroupBy';
-
-export const AGENT_CHAT_THREAD_GROUP_BY_LABELS: Record<
- AgentChatThreadGroupBy,
- MessageDescriptor
-> = {
- date: msg`Date`,
- none: msg`None`,
-};
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilter.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilter.ts
deleted file mode 100644
index bdf76890ed0..00000000000
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilter.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export const AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER = {
- ALL: 'all',
- ONE_DAY: '1d',
- THREE_DAYS: '3d',
- SEVEN_DAYS: '7d',
- THIRTY_DAYS: '30d',
-} as const;
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilterDays.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilterDays.ts
deleted file mode 100644
index 0167253b672..00000000000
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilterDays.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { type AgentChatThreadLastActivityFilter } from '@/ai/types/AgentChatThreadLastActivityFilter';
-
-export const AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_DAYS: Record<
- AgentChatThreadLastActivityFilter,
- number | null
-> = {
- all: null,
- '1d': 1,
- '3d': 3,
- '7d': 7,
- '30d': 30,
-};
diff --git a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilterLabels.ts b/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilterLabels.ts
deleted file mode 100644
index de8ea53c62c..00000000000
--- a/packages/twenty-front/src/modules/ai/constants/AgentChatThreadLastActivityFilterLabels.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { msg } from '@lingui/core/macro';
-import { type MessageDescriptor } from '@lingui/core';
-
-import { type AgentChatThreadLastActivityFilter } from '@/ai/types/AgentChatThreadLastActivityFilter';
-
-export const AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_LABELS: Record<
- AgentChatThreadLastActivityFilter,
- MessageDescriptor
-> = {
- all: msg`All`,
- '1d': msg`1d`,
- '3d': msg`3d`,
- '7d': msg`7d`,
- '30d': msg`30d`,
-};
diff --git a/packages/twenty-front/src/modules/ai/constants/AiChatThreadFilterDropdownPage.ts b/packages/twenty-front/src/modules/ai/constants/AiChatThreadFilterDropdownPage.ts
deleted file mode 100644
index c3098a97cad..00000000000
--- a/packages/twenty-front/src/modules/ai/constants/AiChatThreadFilterDropdownPage.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export const AI_CHAT_THREAD_FILTER_DROPDOWN_PAGE = {
- ROOT: 'root',
- STATUS: 'status',
- GROUP_BY: 'groupBy',
- LAST_ACTIVITY: 'lastActivity',
-} as const;
diff --git a/packages/twenty-front/src/modules/ai/states/agentChatThreadFilterStatusState.ts b/packages/twenty-front/src/modules/ai/states/agentChatThreadFilterStatusState.ts
index e3bfddf7c53..57e9ba16235 100644
--- a/packages/twenty-front/src/modules/ai/states/agentChatThreadFilterStatusState.ts
+++ b/packages/twenty-front/src/modules/ai/states/agentChatThreadFilterStatusState.ts
@@ -8,4 +8,6 @@ export const agentChatThreadFilterStatusState =
defaultValue: AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE,
useLocalStorage: true,
localStorageOptions: { getOnInit: true },
+ validateInitFn: (filterStatus) =>
+ Object.values(AGENT_CHAT_THREAD_FILTER_STATUS).includes(filterStatus),
});
diff --git a/packages/twenty-front/src/modules/ai/states/agentChatThreadGroupByState.ts b/packages/twenty-front/src/modules/ai/states/agentChatThreadGroupByState.ts
deleted file mode 100644
index 89def85d881..00000000000
--- a/packages/twenty-front/src/modules/ai/states/agentChatThreadGroupByState.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { AGENT_CHAT_THREAD_GROUP_BY } from '@/ai/constants/AgentChatThreadGroupBy';
-import { type AgentChatThreadGroupBy } from '@/ai/types/AgentChatThreadGroupBy';
-import { createAtomState } from '@/ui/utilities/state/jotai/utils/createAtomState';
-
-export const agentChatThreadGroupByState =
- createAtomState<AgentChatThreadGroupBy>({
- key: 'agentChatThreadGroupByState',
- defaultValue: AGENT_CHAT_THREAD_GROUP_BY.DATE,
- useLocalStorage: true,
- localStorageOptions: { getOnInit: true },
- });
diff --git a/packages/twenty-front/src/modules/ai/states/agentChatThreadLastActivityFilterState.ts b/packages/twenty-front/src/modules/ai/states/agentChatThreadLastActivityFilterState.ts
deleted file mode 100644
index f2912bb6aec..00000000000
--- a/packages/twenty-front/src/modules/ai/states/agentChatThreadLastActivityFilterState.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER } from '@/ai/constants/AgentChatThreadLastActivityFilter';
-import { type AgentChatThreadLastActivityFilter } from '@/ai/types/AgentChatThreadLastActivityFilter';
-import { createAtomState } from '@/ui/utilities/state/jotai/utils/createAtomState';
-
-export const agentChatThreadLastActivityFilterState =
- createAtomState<AgentChatThreadLastActivityFilter>({
- key: 'agentChatThreadLastActivityFilterState',
- defaultValue: AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ALL,
- useLocalStorage: true,
- localStorageOptions: { getOnInit: true },
- });
diff --git a/packages/twenty-front/src/modules/ai/states/selectors/__tests__/agentChatVisibleThreadsSelector.test.ts b/packages/twenty-front/src/modules/ai/states/selectors/__tests__/agentChatVisibleThreadsSelector.test.ts
index 85650cf5841..9e70225b956 100644
--- a/packages/twenty-front/src/modules/ai/states/selectors/__tests__/agentChatVisibleThreadsSelector.test.ts
+++ b/packages/twenty-front/src/modules/ai/states/selectors/__tests__/agentChatVisibleThreadsSelector.test.ts
@@ -1,10 +1,8 @@
import { createStore } from 'jotai';
import { AGENT_CHAT_THREAD_FILTER_STATUS } from '@/ai/constants/AgentChatThreadFilterStatus';
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER } from '@/ai/constants/AgentChatThreadLastActivityFilter';
import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
import { agentChatThreadInboxNowState } from '@/ai/states/agentChatThreadInboxNowState';
-import { agentChatThreadLastActivityFilterState } from '@/ai/states/agentChatThreadLastActivityFilterState';
import { setAgentChatThreadList } from '@/ai/testing/setAgentChatThreadList';
import { agentChatThreadParticipantsState } from '@/ai/states/agentChatThreadParticipantsState';
import { agentChatVisibleThreadsSelector } from '@/ai/states/selectors/agentChatVisibleThreadsSelector';
@@ -95,10 +93,6 @@ const getVisibleThreadIds = (filterStatus: AgentChatThreadFilterStatus) => {
);
store.set(agentChatThreadInboxNowState.atom, NOW);
store.set(agentChatThreadFilterStatusState.atom, filterStatus);
- store.set(
- agentChatThreadLastActivityFilterState.atom,
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER.ALL,
- );
return store.get(agentChatVisibleThreadsSelector.atom).map(({ id }) => id);
};
@@ -109,25 +103,8 @@ describe('agentChatVisibleThreadsSelector', () => {
AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE,
['read', 'archived-then-active', 'snoozed-then-active', 'unread'],
],
- [
- AGENT_CHAT_THREAD_FILTER_STATUS.UNREAD,
- ['archived-then-active', 'snoozed-then-active', 'unread'],
- ],
[AGENT_CHAT_THREAD_FILTER_STATUS.SNOOZED, ['snoozed']],
[AGENT_CHAT_THREAD_FILTER_STATUS.DONE, ['archived']],
- [AGENT_CHAT_THREAD_FILTER_STATUS.DELETED, ['deleted']],
- [
- AGENT_CHAT_THREAD_FILTER_STATUS.ALL,
- [
- 'read',
- 'archived-then-active',
- 'snoozed-then-active',
- 'unread',
- 'snoozed',
- 'archived',
- 'deleted',
- ],
- ],
])('lists the %s threads', (filterStatus, expectedThreadIds) => {
expect(getVisibleThreadIds(filterStatus)).toEqual(expectedThreadIds);
});
diff --git a/packages/twenty-front/src/modules/ai/states/selectors/agentChatVisibleThreadsSelector.ts b/packages/twenty-front/src/modules/ai/states/selectors/agentChatVisibleThreadsSelector.ts
index fa89e362d1e..17ddf093e05 100644
--- a/packages/twenty-front/src/modules/ai/states/selectors/agentChatVisibleThreadsSelector.ts
+++ b/packages/twenty-front/src/modules/ai/states/selectors/agentChatVisibleThreadsSelector.ts
@@ -1,24 +1,19 @@
-import { millisecondsInDay } from 'date-fns/constants';
import { isDefined } from 'twenty-shared/utils';
import { AGENT_CHAT_THREAD_FILTER_STATUS } from '@/ai/constants/AgentChatThreadFilterStatus';
-import { AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_DAYS } from '@/ai/constants/AgentChatThreadLastActivityFilterDays';
import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
-import { agentChatThreadInboxNowState } from '@/ai/states/agentChatThreadInboxNowState';
-import { agentChatThreadLastActivityFilterState } from '@/ai/states/agentChatThreadLastActivityFilterState';
import { agentChatThreadInboxStatusFamilySelector } from '@/ai/states/selectors/agentChatThreadInboxStatusFamilySelector';
import { agentChatThreadsSelector } from '@/ai/states/selectors/agentChatThreadsSelector';
import { type AgentChatThreadFilterStatus } from '@/ai/types/AgentChatThreadFilterStatus';
import { type AgentChatThreadInboxStatus } from '@/ai/types/AgentChatThreadInboxStatus';
import { type AgentChatThreadRecord } from '@/ai/types/AgentChatThreadRecord';
-import { getAgentChatThreadLastActivityAt } from '@/ai/utils/getAgentChatThreadLastActivityAt';
import { createAtomSelector } from '@/ui/utilities/state/jotai/utils/createAtomSelector';
-const INBOX_SCOPE_BY_FILTER_STATUS: Partial<
- Record<AgentChatThreadFilterStatus, AgentChatThreadInboxStatus['scope']>
+const INBOX_SCOPE_BY_FILTER_STATUS: Record<
+ AgentChatThreadFilterStatus,
+ AgentChatThreadInboxStatus['scope']
> = {
[AGENT_CHAT_THREAD_FILTER_STATUS.ACTIVE]: 'INBOX',
- [AGENT_CHAT_THREAD_FILTER_STATUS.UNREAD]: 'INBOX',
[AGENT_CHAT_THREAD_FILTER_STATUS.SNOOZED]: 'SNOOZED',
[AGENT_CHAT_THREAD_FILTER_STATUS.DONE]: 'ARCHIVED',
};
@@ -28,46 +23,14 @@ export const agentChatVisibleThreadsSelector = createAtomSelector<
>({
key: 'agentChatVisibleThreadsSelector',
get: ({ get }) => {
- const filterStatus = get(agentChatThreadFilterStatusState);
- const lastActivityDays =
- AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER_DAYS[
- get(agentChatThreadLastActivityFilterState)
- ];
- const cutoffMs = isDefined(lastActivityDays)
- ? get(agentChatThreadInboxNowState) - lastActivityDays * millisecondsInDay
- : null;
- const requiredScope = INBOX_SCOPE_BY_FILTER_STATUS[filterStatus];
-
- const isInFilterStatus = (thread: AgentChatThreadRecord) => {
- if (filterStatus === AGENT_CHAT_THREAD_FILTER_STATUS.ALL) {
- return true;
- }
-
- if (filterStatus === AGENT_CHAT_THREAD_FILTER_STATUS.DELETED) {
- return isDefined(thread.deletedAt);
- }
-
- if (isDefined(thread.deletedAt)) {
- return false;
- }
-
- const { scope, isUnread } = get(
- agentChatThreadInboxStatusFamilySelector,
- thread.id,
- );
-
- return (
- scope === requiredScope &&
- (filterStatus !== AGENT_CHAT_THREAD_FILTER_STATUS.UNREAD || isUnread)
- );
- };
+ const requiredScope =
+ INBOX_SCOPE_BY_FILTER_STATUS[get(agentChatThreadFilterStatusState)];
return get(agentChatThreadsSelector).filter(
(thread) =>
- isInFilterStatus(thread) &&
- (!isDefined(cutoffMs) ||
- new Date(getAgentChatThreadLastActivityAt(thread)).getTime() >=
- cutoffMs),
+ !isDefined(thread.deletedAt) &&
+ get(agentChatThreadInboxStatusFamilySelector, thread.id).scope ===
+ requiredScope,
);
},
});
diff --git a/packages/twenty-front/src/modules/ai/types/AgentChatThreadGroupBy.ts b/packages/twenty-front/src/modules/ai/types/AgentChatThreadGroupBy.ts
deleted file mode 100644
index 703c318da16..00000000000
--- a/packages/twenty-front/src/modules/ai/types/AgentChatThreadGroupBy.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { type AGENT_CHAT_THREAD_GROUP_BY } from '@/ai/constants/AgentChatThreadGroupBy';
-
-export type AgentChatThreadGroupBy =
- (typeof AGENT_CHAT_THREAD_GROUP_BY)[keyof typeof AGENT_CHAT_THREAD_GROUP_BY];
diff --git a/packages/twenty-front/src/modules/ai/types/AgentChatThreadLastActivityFilter.ts b/packages/twenty-front/src/modules/ai/types/AgentChatThreadLastActivityFilter.ts
deleted file mode 100644
index 25804ef7af6..00000000000
--- a/packages/twenty-front/src/modules/ai/types/AgentChatThreadLastActivityFilter.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { type AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER } from '@/ai/constants/AgentChatThreadLastActivityFilter';
-
-export type AgentChatThreadLastActivityFilter =
- (typeof AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER)[keyof typeof AGENT_CHAT_THREAD_LAST_ACTIVITY_FILTER];
diff --git a/packages/twenty-front/src/pages/ai-chat/AiChatInboxPage.tsx b/packages/twenty-front/src/pages/ai-chat/AiChatInboxPage.tsx
index d7575f1de79..2f0aaad29f7 100644
--- a/packages/twenty-front/src/pages/ai-chat/AiChatInboxPage.tsx
+++ b/packages/twenty-front/src/pages/ai-chat/AiChatInboxPage.tsx
@@ -6,19 +6,19 @@ import { isDefined, isValidUuid } from 'twenty-shared/utils';
import { IconButton } from 'twenty-ui/components';
import { IconChevronLeft, IconPlus } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
import { useIsMobile } from 'twenty-ui/utilities';
import { SkeletonLoader } from '@/activities/components/SkeletonLoader';
import { AgentChatThreadsFetchMoreTrigger } from '@/ai/components/AgentChatThreadsFetchMoreTrigger';
import { AiChatInboxSelectionEffect } from '@/ai/components/AiChatInboxSelectionEffect';
-import { AiChatThreadFilterDropdown } from '@/ai/components/AiChatThreadFilterDropdown';
import { AiChatThreadList } from '@/ai/components/AiChatThreadList';
-import { AGENT_CHAT_THREAD_GROUP_BY } from '@/ai/constants/AgentChatThreadGroupBy';
+import { AGENT_CHAT_THREAD_FILTER_STATUS_ICONS } from '@/ai/constants/AgentChatThreadFilterStatusIcons';
+import { AGENT_CHAT_THREAD_FILTER_STATUS_LABELS } from '@/ai/constants/AgentChatThreadFilterStatusLabels';
import { AI_CHAT_THREAD_ACTIONS_SURFACE } from '@/ai/constants/AiChatThreadActionsSurface';
import { useChatThreads } from '@/ai/hooks/useChatThreads';
import { useSwitchToNewAiChat } from '@/ai/hooks/useSwitchToNewAiChat';
-import { agentChatThreadGroupByState } from '@/ai/states/agentChatThreadGroupByState';
+import { agentChatThreadFilterStatusState } from '@/ai/states/agentChatThreadFilterStatusState';
import { agentChatVisibleThreadsSelector } from '@/ai/states/selectors/agentChatVisibleThreadsSelector';
import { AnimatedPlaceholder } from '@/ui/feedback/empty-state/components/AnimatedPlaceholder/AnimatedPlaceholder';
import { EmptyState } from '@/ui/feedback/empty-state/components/EmptyState';
@@ -59,7 +59,12 @@ export const AiChatInboxPage = () => {
const { threadId } = useParams();
const selectedThreadId =
isDefined(threadId) && isValidUuid(threadId) ? threadId : undefined;
- const agentChatThreadGroupBy = useAtomStateValue(agentChatThreadGroupByState);
+ const theme = useTheme();
+ const agentChatThreadFilterStatus = useAtomStateValue(
+ agentChatThreadFilterStatusState,
+ );
+ const FilterStatusIcon =
+ AGENT_CHAT_THREAD_FILTER_STATUS_ICONS[agentChatThreadFilterStatus];
const { threads, loading } = useChatThreads(agentChatVisibleThreadsSelector);
const { switchToNewChat } = useSwitchToNewAiChat({
shouldOpenInFullPage: true,
@@ -87,7 +92,12 @@ export const AiChatInboxPage = () => {
<PageCardLayout
header={
<PageCardHeader
- title={<AiChatThreadFilterDropdown />}
+ icon={<FilterStatusIcon size={theme.icon.size.md} />}
+ title={t(
+ AGENT_CHAT_THREAD_FILTER_STATUS_LABELS[
+ agentChatThreadFilterStatus
+ ],
+ )}
actionButton={
<Button
size="sm"
@@ -120,9 +130,6 @@ export const AiChatInboxPage = () => {
threads={threads}
surface={AI_CHAT_THREAD_ACTIONS_SURFACE.INBOX_PAGE}
selectedThreadId={selectedThreadId}
- isGroupedByDate={
- agentChatThreadGroupBy === AGENT_CHAT_THREAD_GROUP_BY.DATE
- }
onThreadClick={({ id }) => selectThread(id)}
/>
)}