The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add AI overview presentation (#29303)
Raphaël Bosifd1701702d1e
diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiOverview.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiOverview.tsxnew file mode 100644index 00000000000..e5568359bd4--- /dev/null+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiOverview.tsx@@ -0,0 +1,39 @@+import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';+import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';+import { t } from '@lingui/core/macro';+import { SettingsPath } from 'twenty-shared/types';+import { getSettingsPath } from 'twenty-shared/utils';+import { type SettingsAiOverviewProps } from '~/pages/settings/ai/types/SettingsAiOverviewProps';++export const SettingsAiOverview = ({+ avatarSection,+ behaviorSection,+ summarySection,+ secondaryBar,+ mcpSection,+ workspaceInstructionsSection,+ systemPromptSection,+}: SettingsAiOverviewProps) => {+ return (+ <SettingsPageLayout+ title={t`AI`}+ links={[+ {+ children: t`Workspace`,+ href: getSettingsPath(SettingsPath.General),+ },+ { children: t`AI` },+ ]}+ secondaryBar={secondaryBar}+ >+ <SettingsPageContainer>+ {avatarSection}+ {behaviorSection}+ {summarySection}+ {mcpSection}+ {workspaceInstructionsSection}+ {systemPromptSection}+ </SettingsPageContainer>+ </SettingsPageLayout>+ );+};diff --git a/packages/twenty-front/src/pages/settings/ai/components/__stories__/SettingsAiOverview.stories.tsx b/packages/twenty-front/src/pages/settings/ai/components/__stories__/SettingsAiOverview.stories.tsxnew file mode 100644index 00000000000..3ce1a60d9ea--- /dev/null+++ b/packages/twenty-front/src/pages/settings/ai/components/__stories__/SettingsAiOverview.stories.tsx@@ -0,0 +1,108 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, userEvent, within } from 'storybook/test';+import { SettingsPath } from 'twenty-shared/types';+import { getSettingsPath } from 'twenty-shared/utils';+import { Section } from 'twenty-ui/components/layout';+import { Text } from 'twenty-ui/primitives/typography';+import { SettingsAiOverview } from '~/pages/settings/ai/components/SettingsAiOverview';+import { settingsAiOverviewStoryParameters } from '~/pages/settings/ai/components/__stories__/settingsAiOverviewStoryParameters';+import { settingsAiOverviewStorySections } from '~/pages/settings/ai/components/__stories__/settingsAiOverviewStorySections';+import { type SettingsAiOverviewProps } from '~/pages/settings/ai/types/SettingsAiOverviewProps';+import {+ PageDecorator,+ type PageDecoratorArgs,+} from '~/testing/decorators/PageDecorator';++const meta = {+ title: 'Pages/Settings/AI/Overview',+ component: SettingsAiOverview,+ decorators: [PageDecorator],+ args: {+ routePath: '/settings/ai',+ routeParams: {},+ additionalRoutes: [getSettingsPath(SettingsPath.AiPrompts)],+ mcpSection: settingsAiOverviewStorySections.mcpSection,+ workspaceInstructionsSection:+ settingsAiOverviewStorySections.workspaceInstructionsSection,+ systemPromptSection: settingsAiOverviewStorySections.systemPromptSection,+ },+ render: (args) => (+ <SettingsAiOverview+ avatarSection={args.avatarSection}+ behaviorSection={args.behaviorSection}+ summarySection={args.summarySection}+ secondaryBar={args.secondaryBar}+ mcpSection={args.mcpSection}+ workspaceInstructionsSection={args.workspaceInstructionsSection}+ systemPromptSection={args.systemPromptSection}+ />+ ),+ parameters: settingsAiOverviewStoryParameters,+} satisfies Meta<SettingsAiOverviewProps & PageDecoratorArgs>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const headings = await canvas.findAllByRole('heading', { level: 2 });++ expect(headings.map(({ textContent }) => textContent)).toEqual([+ 'MCP Server',+ 'Workspace Instructions',+ 'System Prompt',+ ]);+ },+};++export const WithSections: Story = {+ args: {+ avatarSection: (+ <Section.Root>+ <Section.Header title="Avatar" />+ </Section.Root>+ ),+ behaviorSection: (+ <Section.Root>+ <Section.Header title="Behavior" />+ </Section.Root>+ ),+ summarySection: (+ <Section.Root>+ <Section.Header title="At a glance" />+ </Section.Root>+ ),+ secondaryBar: <Text>Overview navigation</Text>,+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const headings = await canvas.findAllByRole('heading', { level: 2 });++ expect(headings.map(({ textContent }) => textContent)).toEqual([+ 'Avatar',+ 'Behavior',+ 'At a glance',+ 'MCP Server',+ 'Workspace Instructions',+ 'System Prompt',+ ]);+ expect(canvas.getByText('Overview navigation')).toBeInTheDocument();+ },+};++export const SystemPromptsNavigation: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await userEvent.click(+ await canvas.findByRole('link', { name: 'Read system prompts' }),+ );++ expect(+ await canvas.findByText(+ `Navigated to ${getSettingsPath(SettingsPath.AiPrompts)}`,+ ),+ ).toBeVisible();+ },+};diff --git a/packages/twenty-front/src/pages/settings/ai/components/__stories__/settingsAiOverviewStoryParameters.ts b/packages/twenty-front/src/pages/settings/ai/components/__stories__/settingsAiOverviewStoryParameters.tsnew file mode 100644index 00000000000..12ad3e3babe--- /dev/null+++ b/packages/twenty-front/src/pages/settings/ai/components/__stories__/settingsAiOverviewStoryParameters.ts@@ -0,0 +1,21 @@+import { graphql, HttpResponse } from 'msw';+import { graphqlMocks } from '~/testing/graphqlMocks';++export const settingsAiOverviewStoryParameters = {+ msw: {+ handlers: [+ graphql.query('GetAiSystemPromptPreview', () =>+ HttpResponse.json({+ data: {+ getAiSystemPromptPreview: {+ __typename: 'AiSystemPromptPreview',+ estimatedTokenCount: 12400,+ sections: [],+ },+ },+ }),+ ),+ ...graphqlMocks.handlers,+ ],+ },+};diff --git a/packages/twenty-front/src/pages/settings/ai/components/__stories__/settingsAiOverviewStorySections.tsx b/packages/twenty-front/src/pages/settings/ai/components/__stories__/settingsAiOverviewStorySections.tsxnew file mode 100644index 00000000000..fa55d23dbef--- /dev/null+++ b/packages/twenty-front/src/pages/settings/ai/components/__stories__/settingsAiOverviewStorySections.tsx@@ -0,0 +1,25 @@+import { SettingsCard } from '@/settings/components/SettingsCard';+import { SettingsPath } from 'twenty-shared/types';+import { getSettingsPath } from 'twenty-shared/utils';+import { Section } from 'twenty-ui/components/layout';+import { IconSparkles } from 'twenty-ui/icon';+import { SettingsAiSystemPromptsSection } from '~/pages/settings/ai/components/SettingsAiSystemPromptsSection';+import { SettingsAiWorkspaceInstructionsSection } from '~/pages/settings/ai/components/SettingsAiWorkspaceInstructionsSection';++export const settingsAiOverviewStorySections = {+ mcpSection: (+ <Section.Root>+ <Section.Header+ title="MCP Server"+ description="Connect AI assistants like Claude or Cursor to your workspace via the Model Context Protocol"+ />+ <SettingsCard+ Icon={<IconSparkles />}+ title="Set up MCP"+ to={getSettingsPath(SettingsPath.AI)}+ />+ </Section.Root>+ ),+ workspaceInstructionsSection: <SettingsAiWorkspaceInstructionsSection />,+ systemPromptSection: <SettingsAiSystemPromptsSection />,+};diff --git a/packages/twenty-front/src/pages/settings/ai/types/SettingsAiOverviewProps.ts b/packages/twenty-front/src/pages/settings/ai/types/SettingsAiOverviewProps.tsnew file mode 100644index 00000000000..a812e18329c--- /dev/null+++ b/packages/twenty-front/src/pages/settings/ai/types/SettingsAiOverviewProps.ts@@ -0,0 +1,11 @@+import { type ReactNode } from 'react';++export type SettingsAiOverviewProps = {+ avatarSection?: ReactNode;+ behaviorSection?: ReactNode;+ summarySection?: ReactNode;+ secondaryBar?: ReactNode;+ mcpSection: ReactNode;+ workspaceInstructionsSection: ReactNode;+ systemPromptSection: ReactNode;+};