The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix UI builds without Monaco (#26134)
Raphaël Bosi94935e6e3969
diff --git a/.github/workflows/ci-ui.yaml b/.github/workflows/ci-ui.yamlindex 650bd1e0aa8..95b303cd068 100644--- a/.github/workflows/ci-ui.yaml+++ b/.github/workflows/ci-ui.yaml@@ -42,6 +42,9 @@ jobs:- name: Check generated theme artifacts are up to dateif: matrix.task == 'lint'run: npx nx generate:check twenty-ui+ - name: Check optional peer dependencies stay out of the root entry point+ if: matrix.task == 'pack-size'+ run: npx nx test:package twenty-uiui-sb-build:needs: changed-files-checkif: >-diff --git a/packages/twenty-companion/package.json b/packages/twenty-companion/package.jsonindex e3a3de3c78e..3506d5c506d 100644--- a/packages/twenty-companion/package.json+++ b/packages/twenty-companion/package.json@@ -48,7 +48,6 @@"electron": "44.1.0","esbuild": "^0.28.1","jsdom": "^30.0.1",- "monaco-editor": "^0.52.2","sass": "^1.83.0","typescript": "^5.9.3","vite": "^7.3.0",diff --git a/packages/twenty-docs/developers/extend/apps/layout/front-components.mdx b/packages/twenty-docs/developers/extend/apps/layout/front-components.mdxindex d2c4ee64cac..d23cecc69ce 100644--- a/packages/twenty-docs/developers/extend/apps/layout/front-components.mdx+++ b/packages/twenty-docs/developers/extend/apps/layout/front-components.mdx@@ -706,7 +706,7 @@ Twenty ships its component library as the [`twenty-ui`](https://www.npmjs.com/pa`twenty-ui` is published alongside the SDK packages with the same version. Add it to your app, pinned to the version of `twenty-sdk` and `twenty-client-sdk` you use:```bash-yarn add -D [email protected]+yarn add -D [email protected]````twenty-ui` is bundled into your front component at build time, so it only needs to be a dependency of your app — there is nothing to configure at runtime.@@ -715,15 +715,16 @@ yarn add -D [email protected]Import from the matching subpath rather than the package root, so only the components you use end up in your bundle:-All existing UI components are grouped under `twenty-ui/primitives/<family>`.-The `components/` folder is reserved for higher-level app building blocks.+Foundational controls are grouped under `twenty-ui/primitives/<family>`.+Shared design presets and app building blocks are available from `twenty-ui/components`.+These entry points do not require `monaco-editor`.| Subpath | What it exports || --- | --- || `twenty-ui/primitives/accessibility` | Hidden elements and keyboard interaction helpers || `twenty-ui/primitives/data-display` | Avatars, chips, tags, status indicators, and display helpers || `twenty-ui/primitives/feedback` | Toasts, banners, progress bars, and loaders |-| `twenty-ui/primitives/input` | Buttons, form controls, pickers, and code editors |+| `twenty-ui/primitives/input` | Buttons, form controls, and pickers || `twenty-ui/primitives/json-visualizer` | JSON tree viewer || `twenty-ui/primitives/layout` | Layout, animation, resizing, and section components || `twenty-ui/primitives/navigation` | Links, list items, menus, and tabs |diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.jsonindex a569450ca40..a052fd56097 100644--- a/packages/twenty-docs/docs.json+++ b/packages/twenty-docs/docs.json@@ -578,7 +578,8 @@"ui/components/input/main-button","ui/components/input/light-button","ui/components/input/icon-button",- "ui/components/section"+ "ui/components/section",+ "ui/components/code-editor"]}]diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.jsonindex 996f1be7b77..cf576cda238 100644--- a/packages/twenty-docs/navigation/base-structure.json+++ b/packages/twenty-docs/navigation/base-structure.json@@ -592,7 +592,8 @@"ui/components/input/main-button","ui/components/input/light-button","ui/components/input/icon-button",- "ui/components/section"+ "ui/components/section",+ "ui/components/code-editor"]}]diff --git a/packages/twenty-docs/snippets/ui/generated/components/code-editor-header.mdx b/packages/twenty-docs/snippets/ui/generated/components/code-editor-header.mdxnew file mode 100644index 00000000000..76d0e4b8325--- /dev/null+++ b/packages/twenty-docs/snippets/ui/generated/components/code-editor-header.mdx@@ -0,0 +1,24 @@+{/*+ * _____ _+ *|_ _|_ _____ _ __ | |_ _ _+ * | | \ \ /\ / / _ \ '_ \| __| | | | 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="leftNodes" type="ReactNode[]">+ Elements shown at the start of the header, such as tabs.+</ParamField>++<ParamField body="rightNodes" type="ReactNode[]">+ Elements shown at the end of the header, such as actions.+</ParamField>++<ParamField body="title" type="string">+ Text shown at the start of the header, after `leftNodes`.+</ParamField>diff --git a/packages/twenty-docs/snippets/ui/generated/components/code-editor.mdx b/packages/twenty-docs/snippets/ui/generated/components/code-editor.mdxnew file mode 100644index 00000000000..85de266dd0d--- /dev/null+++ b/packages/twenty-docs/snippets/ui/generated/components/code-editor.mdx@@ -0,0 +1,68 @@+{/*+ * _____ _+ *|_ _|_ _____ _ __ | |_ _ _+ * | | \ \ /\ / / _ \ '_ \| __| | | | 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="autoHeight" type="boolean" default="false">+ Grows the editor to fit its content instead of using `height`. Ignored when `resizable` is set.+</ParamField>++<ParamField body="contentPadding" type=""default" | "comfortable"" default="default">+ `default` pads the top and bottom of the content. `comfortable` also widens the gap between line numbers and code.+</ParamField>++<ParamField body="height" type="string | number" default="450">+ Editor height in pixels or as a CSS length. With `resizable`, a numeric height sets the initial height.+</ParamField>++<ParamField body="isLoading" type="boolean" default="false">+ Shows a loader at the editor height instead of the editor. A loader also shows while Monaco loads.+</ParamField>++<ParamField body="language" type="string">+ Monaco language identifier for highlighting and language services, such as `json` or `typescript`.+</ParamField>++<ParamField body="onChange" type="((value: string) => void)">+ Called with the full content whenever it changes.+</ParamField>++<ParamField body="onMount" type="OnMount">+ Called when the editor is ready, with the editor instance and the Monaco namespace. The Twenty theme is already applied.+</ParamField>++<ParamField body="onValidate" type="OnValidate">+ Called with the markers Monaco reports after validating the content, such as JSON syntax errors.+</ParamField>++<ParamField body="options" type="IStandaloneEditorConstructionOptions">+ Monaco editor options merged over the Twenty defaults. `padding` is ignored; use `contentPadding` instead.+</ParamField>++<ParamField body="resizable" type="boolean" default="false">+ Adds a handle below the editor to drag its height.+</ParamField>++<ParamField body="setMarkers" type="((value: string) => IMarkerData[])">+ Returns custom validation markers for the content. Runs when the editor mounts and after every change, replacing the previous custom markers.+</ParamField>++<ParamField body="transparentBackground" type="boolean">+ Removes the editor background so the surrounding surface shows through.+</ParamField>++<ParamField body="value" type="string">+ Content of the editor. Pair it with `onChange` to control the editor.+</ParamField>++<ParamField body="variant" type=""default" | "with-header" | "borderless"" default="default">+ Border treatment: `default` draws a rounded border, `with-header` attaches the editor below a `CodeEditorHeader`, and `borderless` removes the border.+</ParamField>diff --git a/packages/twenty-docs/ui/components/code-editor.mdx b/packages/twenty-docs/ui/components/code-editor.mdxnew file mode 100644index 00000000000..a7616244697--- /dev/null+++ b/packages/twenty-docs/ui/components/code-editor.mdx@@ -0,0 +1,102 @@+---+title: CodeEditor+description: Edit and display code in a Monaco editor styled with the Twenty theme.+---++import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';+import CodeEditorReference from '/snippets/ui/generated/components/code-editor.mdx';+import CodeEditorHeaderReference from '/snippets/ui/generated/components/code-editor-header.mdx';++`CodeEditor` renders a [Monaco](https://microsoft.github.io/monaco-editor/) editor that follows the Twenty theme in light and dark mode. `CodeEditorHeader` adds a bar above it for a title, tabs, or actions. Both come from `twenty-ui/components/code-editor`, a separate entry point, so the rest of Twenty UI works without Monaco.++<StoryEmbed+ storyId="ui-components-codeeditor--documentation"+ title="Code editor example"+ height={280}+/>++## Setup++Install the editor's optional peer dependencies:++```bash+yarn add @monaco-editor/react monaco-editor+```++The editor loads your installed `monaco-editor` package rather than a copy from a CDN. Monaco runs language features such as validation and autocompletion in web workers, and creating those workers depends on your bundler. Before an editor mounts, define `MonacoEnvironment.getWorker` as described in [Monaco's ESM integration guide](https://github.com/microsoft/monaco-editor/blob/main/docs/integrate-esm.md). Without it, the editor still renders, but language features are unavailable.++The code editor does not run inside [front components](/developers/extend/apps/layout/front-components) yet.++## Usage++```tsx+import { useState } from 'react';+import { CodeEditor } from 'twenty-ui/components/code-editor';++export const PayloadEditor = () => {+ const [payload, setPayload] = useState('{\n "name": "Acme"\n}');++ return (+ <CodeEditor+ language="json"+ value={payload}+ onChange={setPayload}+ height={200}+ />+ );+};+```++`onChange` receives the full content on every change. A loader shows until Monaco has loaded. Set `isLoading` to keep showing it while your own data loads.++## Add a header++```tsx+import { CodeEditor, CodeEditorHeader } from 'twenty-ui/components/code-editor';+import { Button } from 'twenty-ui/primitives/input';++type ScriptEditorProps = {+ script: string;+ onRun: () => void;+};++export const ScriptEditor = ({ script, onRun }: ScriptEditorProps) => (+ <div>+ <CodeEditorHeader+ title="index.ts"+ rightNodes={[+ <Button key="run" size="sm" onClick={onRun}>+ Run+ </Button>,+ ]}+ />+ <CodeEditor language="typescript" value={script} variant="with-header" />+ </div>+);+```++`variant="with-header"` removes the editor's top border so it joins the header. Use `borderless` when the editor sits inside a surface that already has a border.++## Size and appearance++The editor is 450px tall by default. Set `height` to a number of pixels or a CSS length. `autoHeight` grows the editor with its content, and `resizable` adds a handle below it to drag the height. When both are set, `resizable` applies.++`contentPadding="comfortable"` widens the gap between line numbers and code. `transparentBackground` lets the surrounding surface show through.++## Validation++Monaco reports its own diagnostics, such as JSON syntax errors, through `onValidate`. To add your own, return marker data from `setMarkers`. It runs when the editor mounts and after every change, and replaces the markers it set before.++## Keyboard++While the editor has focus, it stops keyboard events from propagating. React key handlers on parent components and document-level shortcuts do not receive keystrokes typed in the editor.++## Props++### CodeEditor++<CodeEditorReference />++### CodeEditorHeader++<CodeEditorHeaderReference />diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdxindex 44efa269373..163e6f2faa2 100644--- a/packages/twenty-docs/ui/components/overview.mdx+++ b/packages/twenty-docs/ui/components/overview.mdx@@ -6,7 +6,7 @@ description: Shared design presets and reusable app building blocks composed froComponents combine [primitives](/ui/primitives/overview) into recurring design presets and reusable app building blocks. Like primitives, they receive data and callbacks from your application.-Import shared components from `twenty-ui/components`. See [Getting started](/ui/getting-started) for installation and theme setup.+Import shared components from `twenty-ui/components`. The code editor has its own entry point, `twenty-ui/components/code-editor`, because it requires Monaco. See [Getting started](/ui/getting-started) for installation and theme setup.## Browse components@@ -16,3 +16,4 @@ Import shared components from `twenty-ui/components`. See [Getting started](/ui/| [LightButton](/ui/components/input/light-button) | Lightweight actions with standard or subtle emphasis. || [IconButton](/ui/components/input/icon-button) | Square icon actions built on Button. || [Section](/ui/components/section) | Related content with a heading, description, and optional action. |+| [CodeEditor](/ui/components/code-editor) | Code editing with Monaco, an optional header, and the Twenty theme. |diff --git a/packages/twenty-docs/ui/getting-started.mdx b/packages/twenty-docs/ui/getting-started.mdxindex b42a6bd4ec7..c02d43855c4 100644--- a/packages/twenty-docs/ui/getting-started.mdx+++ b/packages/twenty-docs/ui/getting-started.mdx@@ -16,10 +16,14 @@ Twenty UI is Twenty's React component library. It provides components, icons, anFor a standalone React application, install the library and its peer dependencies:```bash-yarn add twenty-ui monaco-editor react@^19 react-dom@^19+yarn add twenty-ui react@^19 react-dom@^19```-`monaco-editor` powers the code editor components, but install it even if you never render an editor: the `twenty-ui/primitives/input`, `twenty-ui/primitives/feedback`, and `twenty-ui/primitives/navigation` entry points reference it, and bundlers fail to resolve it otherwise.+The [code editor](/ui/components/code-editor) has a separate entry point, `twenty-ui/components/code-editor`. Other components do not require Monaco. To use the code editor, install its optional peer dependencies and configure Monaco workers for your bundler before mounting it:++```bash+yarn add @monaco-editor/react monaco-editor+```If you are building a Twenty app, follow [Using Twenty UI components](/developers/extend/apps/layout/front-components#using-twenty-ui-components). The front component renderer supplies the workspace theme and has a different setup from a standalone browser application.@@ -68,10 +72,11 @@ Each primitive family has a matching public entry point, such as| Import | Contents || -------------------------------------- | ------------------------------------------------------------ || `twenty-ui/components` | Shared design presets and reusable app building blocks |+| `twenty-ui/components/code-editor` | Code editor, editor header, and editor theme helpers || `twenty-ui/primitives/accessibility` | Hidden elements and keyboard interaction helpers || `twenty-ui/primitives/data-display` | Avatars, chips, tags, status indicators, and display helpers || `twenty-ui/primitives/feedback` | Toasts, banners, progress bars, and loaders |-| `twenty-ui/primitives/input` | Buttons, form controls, pickers, and code editors |+| `twenty-ui/primitives/input` | Buttons, form controls, and pickers || `twenty-ui/primitives/json-visualizer` | JSON tree viewer || `twenty-ui/primitives/layout` | Layout, animation, resizing, and section components || `twenty-ui/primitives/navigation` | Links, list items, menus, and tabs |diff --git a/packages/twenty-front-component-renderer/package.json b/packages/twenty-front-component-renderer/package.jsonindex aac97cc6532..dd6a01d4cfd 100644--- a/packages/twenty-front-component-renderer/package.json+++ b/packages/twenty-front-component-renderer/package.json@@ -33,6 +33,7 @@"@chakra-ui/react": "^3.33.0","@emotion/react": "^11.14.0","@emotion/styled": "^11.14.0",+ "@monaco-editor/react": "^4.7.0","@mui/material": "^7.3.8","@storybook/addon-vitest": "^10.4.6","@storybook/react-vite": "^10.4.6",@@ -41,6 +42,7 @@"@types/react-dom": "^19.2.0","@typescript/native-preview": "^7.0.0-dev.20260116.1","@vitest/browser-playwright": "^4.1.0",+ "monaco-editor": "0.52.2","playwright": "^1.60.0","prettier": "^3.1.1","recharts": "^3.9.2",diff --git a/packages/twenty-front-component-renderer/scripts/front-component-stories/build-source-examples.ts b/packages/twenty-front-component-renderer/scripts/front-component-stories/build-source-examples.tsindex 57e0622f694..c4086e035b9 100644--- a/packages/twenty-front-component-renderer/scripts/front-component-stories/build-source-examples.ts+++ b/packages/twenty-front-component-renderer/scripts/front-component-stories/build-source-examples.ts@@ -5,6 +5,8 @@ import { fileURLToPath } from 'node:url';import { getFrontComponentBuildPlugins } from 'twenty-sdk/front-component-renderer/build';+import twentyUiPackageJson from '../../../twenty-ui/package.json';+const dirname = path.dirname(fileURLToPath(import.meta.url));const storiesDir = path.resolve(dirname, '../../src/__stories__');const exampleSourcesBuiltDir = path.resolve(@@ -26,9 +28,14 @@ const SOURCE_SCAN_ROOTS = [const rootNodeModules = path.resolve(dirname, '../../../../node_modules');-const twentyUiIndividualIndex = path.resolve(+const twentyUiIndividualDir = path.resolve(dirname,- '../../../twenty-ui/dist/individual/individual-entry.js',+ '../../../twenty-ui/dist/individual',+);++const twentyUiIndividualIndex = path.join(+ twentyUiIndividualDir,+ 'individual-entry.js',);const sdkDefineIndex = path.resolve(@@ -67,33 +74,17 @@ const twentySharedAliases = Object.fromEntries(]),);-const TWENTY_UI_SUBMODULES = [- 'components',- 'icon',- 'primitives',- 'primitives/accessibility',- 'primitives/data-display',- 'primitives/feedback',- 'primitives/input',- 'primitives/json-visualizer',- 'primitives/layout',- 'primitives/navigation',- 'primitives/surfaces',- 'primitives/typography',- 'theme-constants',- 'utilities',-];+const twentyUiSubmodules = Object.keys(twentyUiPackageJson.exports)+ .filter((subpath) => subpath !== '.' && !subpath.endsWith('.css'))+ .map((subpath) => subpath.slice(2));const twentyUiAliases = {- 'twenty-ui/style.css': path.join(- path.dirname(twentyUiIndividualIndex),- 'twenty-ui.css',- ),+ 'twenty-ui/style.css': path.join(twentyUiIndividualDir, 'twenty-ui.css'),'twenty-ui': twentyUiIndividualIndex,...Object.fromEntries(- TWENTY_UI_SUBMODULES.map((submodule) => [+ twentyUiSubmodules.map((submodule) => [`twenty-ui/${submodule}`,- twentyUiIndividualIndex,+ path.join(twentyUiIndividualDir, submodule, 'index.js'),]),),};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-code-editor-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-code-editor-gallery.front-component.tsxindex 684bcada78e..32b18abbc65 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-code-editor-gallery.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-code-editor-gallery.front-component.tsx@@ -1,6 +1,6 @@import { defineFrontComponent } from 'twenty-sdk/define';import { useState } from 'react';-import { CodeEditor } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';import { ThemeProvider } from 'twenty-ui/theme-constants';// KNOWN ISSUE: CodeEditor wraps @monaco-editor/react, which lazy-loads thediff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsxindex bee3583b0d6..e98dee3ea66 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx@@ -1,6 +1,7 @@import { defineFrontComponent } from 'twenty-sdk/define';import { IconButton, LightButton, MainButton } from 'twenty-ui/components';import { IconPlus, IconSearch, IconStar, IconTrash } from 'twenty-ui/icon';+import { CodeEditorHeader } from 'twenty-ui/components/code-editor';import {AnimatedButton,AnimatedLightIconButton,@@ -9,7 +10,6 @@ import {ColorPickerButton,ColorSchemeCard,ColorSchemePicker,- CoreEditorHeader,FloatingButton,FloatingButtonGroup,FloatingIconButton,@@ -84,8 +84,8 @@ const INPUT_ENTRIES: GalleryEntry[] = [),},{- name: 'CoreEditorHeader',- node: <CoreEditorHeader title="Editor" />,+ name: 'CodeEditorHeader',+ node: <CodeEditorHeader title="Editor" />,},{name: 'ColorPickerButton',diff --git a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsxindex 2e84c4f6eeb..727b5dd8d56 100644--- a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx+++ b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx@@ -11,7 +11,8 @@ import {IconDownload,IconFile,} from 'twenty-ui/icon';-import { CodeEditor, LightIconButton } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';+import { LightIconButton } from 'twenty-ui/primitives/input';import { AnimatedExpandableContainer } from 'twenty-ui/primitives/layout';import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';import { useCopyToClipboard } from '~/hooks/useCopyToClipboard';diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RawJsonFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RawJsonFieldInput.tsxindex 9563b3d502a..a1e5220cfb1 100644--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RawJsonFieldInput.tsx+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RawJsonFieldInput.tsx@@ -10,7 +10,8 @@ import { useLingui } from '@lingui/react/macro';import { useContext, useRef, useState } from 'react';import { Key } from 'ts-key-enum';import { IconPencil } from 'twenty-ui/icon';-import { CodeEditor, FloatingIconButton } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';+import { FloatingIconButton } from 'twenty-ui/primitives/input';import {JsonTree,isTwoFirstDepths,diff --git a/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableDatabaseInput.tsx b/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableDatabaseInput.tsxindex 30dbaeece53..ed6f49dbae6 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableDatabaseInput.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableDatabaseInput.tsx@@ -9,7 +9,7 @@ import { styled } from '@linaria/react';import { t } from '@lingui/core/macro';import { type ConfigVariableValue } from 'twenty-shared/types';import { CustomError } from 'twenty-shared/utils';-import { CodeEditor } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';import { MenuItemMultiSelect } from 'twenty-ui/primitives/navigation';import { themeCssVariables } from 'twenty-ui/theme-constants';import { ConfigVariableType } from '~/generated-admin/graphql';diff --git a/packages/twenty-front/src/modules/settings/logic-functions/components/SettingsLogicFunctionCodeEditor.tsx b/packages/twenty-front/src/modules/settings/logic-functions/components/SettingsLogicFunctionCodeEditor.tsxindex 909555444bf..e76793173e6 100644--- a/packages/twenty-front/src/modules/settings/logic-functions/components/SettingsLogicFunctionCodeEditor.tsx+++ b/packages/twenty-front/src/modules/settings/logic-functions/components/SettingsLogicFunctionCodeEditor.tsx@@ -4,7 +4,7 @@ import { type editor } from 'monaco-editor';import { AutoTypings } from 'monaco-editor-auto-typings';import { useParams } from 'react-router-dom';import { isDefined } from 'twenty-shared/utils';-import { CodeEditor } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';export type File = {language: string;diff --git a/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionCodeEditorTab.tsx b/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionCodeEditorTab.tsxindex 8eb1f53304c..0221d886e2a 100644--- a/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionCodeEditorTab.tsx+++ b/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionCodeEditorTab.tsx@@ -9,8 +9,9 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useimport { styled } from '@linaria/react';import { t } from '@lingui/core/macro';import { Section } from 'twenty-ui/components';+import { CodeEditorHeader } from 'twenty-ui/components/code-editor';import { IconPlayerPlay } from 'twenty-ui/icon';-import { Button, CoreEditorHeader } from 'twenty-ui/primitives/input';+import { Button } from 'twenty-ui/primitives/input';const StyledTabListContainer = styled.div`> * {@@ -63,7 +64,7 @@ export const SettingsLogicFunctionCodeEditorTab = ({title={t`Code your function`}description={t`Write your function (in typescript) below`}/>- <CoreEditorHeader leftNodes={[HeaderTabList]} rightNodes={[TestButton]} />+ <CodeEditorHeader leftNodes={[HeaderTabList]} rightNodes={[TestButton]} />{activeTabId && (<SettingsLogicFunctionCodeEditorfiles={files}diff --git a/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionTestTab.tsx b/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionTestTab.tsxindex 17a54018d4f..d1f2f7a91aa 100644--- a/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionTestTab.tsx+++ b/packages/twenty-front/src/modules/settings/logic-functions/components/tabs/SettingsLogicFunctionTestTab.tsx@@ -12,6 +12,7 @@ import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';import { isDefined } from 'twenty-shared/utils';import { Section } from 'twenty-ui/components';+import { CodeEditor, CodeEditorHeader } from 'twenty-ui/components/code-editor';import {IconClock,IconDatabase,@@ -20,11 +21,7 @@ import {IconWebhook,type IconComponent,} from 'twenty-ui/icon';-import {- Button,- CodeEditor,- CoreEditorHeader,-} from 'twenty-ui/primitives/input';+import { Button } from 'twenty-ui/primitives/input';import { themeCssVariables } from 'twenty-ui/theme-constants';type TriggerButton = {@@ -155,7 +152,7 @@ export const SettingsLogicFunctionTestTab = ({</div>)}<StyledCodeEditorContainer>- <CoreEditorHeader+ <CodeEditorHeadertitle={t`Input`}rightNodes={[<Buttondiff --git a/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerPayloadFormat.tsx b/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerPayloadFormat.tsxindex 91754e52943..c0f84c03279 100644--- a/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerPayloadFormat.tsx+++ b/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerPayloadFormat.tsx@@ -1,6 +1,6 @@import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';-import { CodeEditor } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';import { themeCssVariables } from 'twenty-ui/theme-constants';const StyledContainer = styled.div`diff --git a/packages/twenty-front/src/modules/settings/mcp-and-apis/components/SettingsMcpSetup.tsx b/packages/twenty-front/src/modules/settings/mcp-and-apis/components/SettingsMcpSetup.tsxindex 86f853f9ce6..608ed4aa045 100644--- a/packages/twenty-front/src/modules/settings/mcp-and-apis/components/SettingsMcpSetup.tsx+++ b/packages/twenty-front/src/modules/settings/mcp-and-apis/components/SettingsMcpSetup.tsx@@ -12,7 +12,7 @@ import {isHttpsUrl,} from '@/settings/mcp-and-apis/utils/mcpSetup';import { Section } from 'twenty-ui/components';-import { CodeEditor, CoreEditorHeader } from 'twenty-ui/primitives/input';+import { CodeEditor, CodeEditorHeader } from 'twenty-ui/components/code-editor';import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme-constants';import { REACT_APP_SERVER_BASE_URL } from '~/config';@@ -75,7 +75,7 @@ export const SettingsMcpSetup = () => {title={t`Manual configuration`}description={t`Access your workspace data from your favorite MCP client like Claude, Codex or Cursor.`}/>- <CoreEditorHeader+ <CodeEditorHeaderleftNodes={[<StyledMcpEditorHeaderTitle key="mcp-editor-header-title"><StyledMcpIcon aria-hidden />diff --git a/packages/twenty-front/src/modules/workflow/components/WorkflowStepExecutionResult.tsx b/packages/twenty-front/src/modules/workflow/components/WorkflowStepExecutionResult.tsxindex 8bf02e46073..540e2d93d78 100644--- a/packages/twenty-front/src/modules/workflow/components/WorkflowStepExecutionResult.tsx+++ b/packages/twenty-front/src/modules/workflow/components/WorkflowStepExecutionResult.tsx@@ -6,7 +6,7 @@ import {IconSquareRoundedCheck,IconSquareRoundedX,} from 'twenty-ui/icon';-import { CodeEditor, CoreEditorHeader } from 'twenty-ui/primitives/input';+import { CodeEditor, CodeEditorHeader } from 'twenty-ui/components/code-editor';import { AnimatedCircleLoading } from 'twenty-ui/primitives/layout';import { themeCssVariables, ThemeContext } from 'twenty-ui/theme-constants';import { useContext } from 'react';@@ -127,7 +127,7 @@ export const WorkflowStepExecutionResult = ({return (<StyledContainer>- <CoreEditorHeader+ <CodeEditorHeaderleftNodes={[computeLeftNode()]}rightNodes={[<LightCopyIconButton copyText={result} />]}/>diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowCodeEditor.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowCodeEditor.tsxindex 190941e8d2b..ea62c55b159 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowCodeEditor.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowCodeEditor.tsx@@ -4,7 +4,8 @@ import { useLingui } from '@lingui/react/macro';import { type Monaco } from '@monaco-editor/react';import { type editor } from 'monaco-editor';import { IconMaximize } from 'twenty-ui/icon';-import { CodeEditor, LightIconButton } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';+import { LightIconButton } from 'twenty-ui/primitives/input';import { themeCssVariables } from 'twenty-ui/theme-constants';const CODE_EDITOR_MIN_HEIGHT = 343;diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsxindex aee52bd9b14..1a78209839e 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx@@ -10,7 +10,8 @@ import { setNestedValue } from '@/workflow/workflow-steps/workflow-actions/code-import { LogicFunctionExecutionResult } from '@/logic-functions/components/LogicFunctionExecutionResult';import { LogicFunctionLogs } from '@/logic-functions/components/LogicFunctionLogs';-import { InputLabel, CodeEditor } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';+import { InputLabel } from 'twenty-ui/primitives/input';import { TabList } from '@/ui/layout/tab-list/components/TabList';import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowReadonlyActionCode.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowReadonlyActionCode.tsxindex 5b2758d50b5..438f4ac7f64 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowReadonlyActionCode.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowReadonlyActionCode.tsx@@ -10,7 +10,7 @@ import { styled } from '@linaria/react';import { type Monaco } from '@monaco-editor/react';import { type editor } from 'monaco-editor';import { AutoTypings } from 'monaco-editor-auto-typings';-import { CodeEditor } from 'twenty-ui/primitives/input';+import { CodeEditor } from 'twenty-ui/components/code-editor';const StyledCodeEditorContainer = styled.div`display: flex;diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.tsindex 3063f72c879..527c20108e3 100644--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts@@ -128,6 +128,7 @@ export const DOCUMENTATION_PATHS = {GETTING_STARTED_KEY_FEATURES: '/getting-started/key-features',GETTING_STARTED_QUICKSTART: '/getting-started/quickstart',UI_ACCESSIBILITY: '/ui/accessibility',+ UI_COMPONENTS_CODE_EDITOR: '/ui/components/code-editor',UI_COMPONENTS_INPUT_ICON_BUTTON: '/ui/components/input/icon-button',UI_COMPONENTS_INPUT_LIGHT_BUTTON: '/ui/components/input/light-button',UI_COMPONENTS_INPUT_MAIN_BUTTON: '/ui/components/input/main-button',diff --git a/packages/twenty-ui/.size-limit.json b/packages/twenty-ui/.size-limit.jsonindex d2c6a356a73..7f9216244eb 100644--- a/packages/twenty-ui/.size-limit.json+++ b/packages/twenty-ui/.size-limit.json@@ -15,6 +15,11 @@"path": "dist/components.mjs","limit": "95 kB"},+ {+ "name": "components/code-editor",+ "path": "dist/components/code-editor.mjs",+ "limit": "15 kB"+ },{"name": "primitives","path": "dist/primitives.mjs",diff --git a/packages/twenty-ui/.storybook/preview.tsx b/packages/twenty-ui/.storybook/preview.tsxindex 2b2b632ac11..ecbdb206e8d 100644--- a/packages/twenty-ui/.storybook/preview.tsx+++ b/packages/twenty-ui/.storybook/preview.tsx@@ -1,3 +1,5 @@+import '@fontsource/dm-mono/400.css';+import '@fontsource/dm-mono/500.css';import '@fontsource/inter/400.css';import '@fontsource/inter/500.css';import '@fontsource/inter/600.css';@@ -7,6 +9,8 @@ import '@ui/theme-constants/theme-light.css';import '@ui/theme-constants/theme-dark.css';import { ThemeProvider } from '@ui/theme-constants';+import './setupMonacoEnvironment';+const preview: Preview = {tags: ['autodocs'],parameters: {diff --git a/packages/twenty-ui/.storybook/setupMonacoEnvironment.ts b/packages/twenty-ui/.storybook/setupMonacoEnvironment.tsnew file mode 100644index 00000000000..72e0748342c--- /dev/null+++ b/packages/twenty-ui/.storybook/setupMonacoEnvironment.ts@@ -0,0 +1,32 @@+import { type Environment } from 'monaco-editor';+import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker.js?worker';+import CssWorker from 'monaco-editor/esm/vs/language/css/css.worker.js?worker';+import HtmlWorker from 'monaco-editor/esm/vs/language/html/html.worker.js?worker';+import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker.js?worker';+import TypeScriptWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker.js?worker';++const monacoEnvironment: Environment = {+ getWorker: (_workerId, label) => {+ switch (label) {+ case 'json':+ return new JsonWorker();+ case 'css':+ case 'scss':+ case 'less':+ return new CssWorker();+ case 'html':+ case 'handlebars':+ case 'razor':+ return new HtmlWorker();+ case 'typescript':+ case 'javascript':+ return new TypeScriptWorker();+ default:+ return new EditorWorker();+ }+ },+};++(+ globalThis as unknown as { MonacoEnvironment?: Environment }+).MonacoEnvironment = monacoEnvironment;diff --git a/packages/twenty-ui/README.md b/packages/twenty-ui/README.mdindex 1bc112ef6ee..713cb884f80 100644--- a/packages/twenty-ui/README.md+++ b/packages/twenty-ui/README.md@@ -15,10 +15,14 @@ Read the [twenty-ui documentation](https://docs.twenty.com/ui/getting-started) fFor a standalone React application, install the library and its peer dependencies. React 19 is required.```bash-npm install twenty-ui monaco-editor react@^19 react-dom@^19+npm install twenty-ui react@^19 react-dom@^19```-Install `monaco-editor` even if you never render a code editor: the `twenty-ui/primitives/input`, `twenty-ui/primitives/feedback`, and `twenty-ui/primitives/navigation` entry points reference it, and bundlers fail to resolve it otherwise.+The code editor is available separately from `twenty-ui/components/code-editor`. Only applications using that entry point need to install its optional peers:++```bash+npm install @monaco-editor/react monaco-editor+```For Twenty apps, follow [Using Twenty UI components](https://docs.twenty.com/developers/extend/apps/layout/front-components#using-twenty-ui-components). The front component renderer supplies the workspace theme. Keep `twenty-ui`, `twenty-sdk`, and `twenty-client-sdk` on the same version.@@ -50,15 +54,16 @@ import { Button } from 'twenty-ui/primitives/input';| Subpath | Contents || --- | --- |-| `twenty-ui` | All components, icons, theme tokens, and utilities |+| `twenty-ui` | Components except the code editor, icons, theme tokens, and utilities || `twenty-ui/assets` | Logos and static assets || `twenty-ui/components` | Shared design presets and reusable app building blocks |+| `twenty-ui/components/code-editor` | Code editor, editor header, and editor theme helpers || `twenty-ui/icon` | Icon components and the icon provider || `twenty-ui/primitives` | Foundational UI controls and compound controls || `twenty-ui/primitives/accessibility` | Hidden elements and keyboard interaction helpers || `twenty-ui/primitives/data-display` | Avatars, chips, tags, status indicators, and display helpers || `twenty-ui/primitives/feedback` | Toasts, banners, progress bars, and loaders |-| `twenty-ui/primitives/input` | Buttons, form controls, pickers, and code editors |+| `twenty-ui/primitives/input` | Buttons, form controls, and pickers || `twenty-ui/primitives/json-visualizer` | JSON tree viewer || `twenty-ui/primitives/layout` | Layout, animation, resizing, and section components || `twenty-ui/primitives/navigation` | Links, list items, menus, and tabs |diff --git a/packages/twenty-ui/docs/codeEditorHeaderPropDescriptions.ts b/packages/twenty-ui/docs/codeEditorHeaderPropDescriptions.tsnew file mode 100644index 00000000000..e0279eb2cdc--- /dev/null+++ b/packages/twenty-ui/docs/codeEditorHeaderPropDescriptions.ts@@ -0,0 +1,7 @@+import { type CodeEditorHeaderProps } from '../src/components/code-editor/CodeEditorHeader/types/CodeEditorHeaderProps';++export const CODE_EDITOR_HEADER_PROP_DESCRIPTIONS = {+ title: 'Text shown at the start of the header, after `leftNodes`.',+ leftNodes: 'Elements shown at the start of the header, such as tabs.',+ rightNodes: 'Elements shown at the end of the header, such as actions.',+} satisfies Partial<Record<keyof CodeEditorHeaderProps, string>>;diff --git a/packages/twenty-ui/docs/codeEditorPropDescriptions.ts b/packages/twenty-ui/docs/codeEditorPropDescriptions.tsnew file mode 100644index 00000000000..d0dc3356596--- /dev/null+++ b/packages/twenty-ui/docs/codeEditorPropDescriptions.ts@@ -0,0 +1,30 @@+import { type CodeEditorProps } from '../src/components/code-editor/CodeEditor/types/CodeEditorProps';++export const CODE_EDITOR_PROP_DESCRIPTIONS = {+ value:+ 'Content of the editor. Pair it with `onChange` to control the editor.',+ language:+ 'Monaco language identifier for highlighting and language services, such as `json` or `typescript`.',+ height:+ 'Editor height in pixels or as a CSS length. With `resizable`, a numeric height sets the initial height.',+ options:+ 'Monaco editor options merged over the Twenty defaults. `padding` is ignored; use `contentPadding` instead.',+ onMount:+ 'Called when the editor is ready, with the editor instance and the Monaco namespace. The Twenty theme is already applied.',+ onValidate:+ 'Called with the markers Monaco reports after validating the content, such as JSON syntax errors.',+ onChange: 'Called with the full content whenever it changes.',+ setMarkers:+ 'Returns custom validation markers for the content. Runs when the editor mounts and after every change, replacing the previous custom markers.',+ variant:+ 'Border treatment: `default` draws a rounded border, `with-header` attaches the editor below a `CodeEditorHeader`, and `borderless` removes the border.',+ isLoading:+ 'Shows a loader at the editor height instead of the editor. A loader also shows while Monaco loads.',+ transparentBackground:+ 'Removes the editor background so the surrounding surface shows through.',+ resizable: 'Adds a handle below the editor to drag its height.',+ contentPadding:+ '`default` pads the top and bottom of the content. `comfortable` also widens the gap between line numbers and code.',+ autoHeight:+ 'Grows the editor to fit its content instead of using `height`. Ignored when `resizable` is set.',+} satisfies Partial<Record<keyof CodeEditorProps, string>>;diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 92ad78b14be..c518c973b6b 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -3,6 +3,8 @@ import { BUTTON_GROUP_PROP_DESCRIPTIONS } from './buttonGroupPropDescriptions';import { BUTTON_PROP_DESCRIPTIONS } from './buttonPropDescriptions';import { ICON_BUTTON_PROP_DESCRIPTIONS } from './iconButtonPropDescriptions';import { CHIP_PROP_DESCRIPTIONS } from './chipPropDescriptions';+import { CODE_EDITOR_HEADER_PROP_DESCRIPTIONS } from './codeEditorHeaderPropDescriptions';+import { CODE_EDITOR_PROP_DESCRIPTIONS } from './codeEditorPropDescriptions';import { DIALOG_TITLE_PROP_DESCRIPTIONS } from './dialogTitlePropDescriptions';import { HEADING_PROP_DESCRIPTIONS } from './headingPropDescriptions';import { LIGHT_BUTTON_PROP_DESCRIPTIONS } from './lightButtonPropDescriptions';@@ -206,6 +208,20 @@ export const DOCUMENTED_COMPONENTS = [Header: SECTION_HEADER_PROP_DESCRIPTIONS,},},+ {+ name: 'CodeEditor',+ source: 'components/code-editor/CodeEditor/CodeEditor.tsx',+ entryPoint: 'twenty-ui/components/code-editor',+ slug: 'components/code-editor',+ propDescriptions: CODE_EDITOR_PROP_DESCRIPTIONS,+ },+ {+ name: 'CodeEditorHeader',+ source: 'components/code-editor/CodeEditorHeader/CodeEditorHeader.tsx',+ entryPoint: 'twenty-ui/components/code-editor',+ slug: 'components/code-editor-header',+ propDescriptions: CODE_EDITOR_HEADER_PROP_DESCRIPTIONS,+ },{name: 'Dialog',source: 'primitives/surfaces/Dialog/Dialog.tsx',diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 63e93e2f08e..3d54f9f85b3 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -5379,6 +5379,139 @@}]},+ {+ "name": "CodeEditor",+ "entryPoint": "twenty-ui/components/code-editor",+ "slug": "components/code-editor",+ "props": [+ {+ "name": "autoHeight",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Grows the editor to fit its content instead of using `height`. Ignored when `resizable` is set."+ },+ {+ "name": "contentPadding",+ "type": "\"default\" | \"comfortable\"",+ "required": false,+ "defaultValue": "default",+ "description": "`default` pads the top and bottom of the content. `comfortable` also widens the gap between line numbers and code."+ },+ {+ "name": "height",+ "type": "string | number",+ "required": false,+ "defaultValue": "450",+ "description": "Editor height in pixels or as a CSS length. With `resizable`, a numeric height sets the initial height."+ },+ {+ "name": "isLoading",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Shows a loader at the editor height instead of the editor. A loader also shows while Monaco loads."+ },+ {+ "name": "language",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Monaco language identifier for highlighting and language services, such as `json` or `typescript`."+ },+ {+ "name": "onChange",+ "type": "((value: string) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Called with the full content whenever it changes."+ },+ {+ "name": "onMount",+ "type": "OnMount",+ "required": false,+ "defaultValue": null,+ "description": "Called when the editor is ready, with the editor instance and the Monaco namespace. The Twenty theme is already applied."+ },+ {+ "name": "onValidate",+ "type": "OnValidate",+ "required": false,+ "defaultValue": null,+ "description": "Called with the markers Monaco reports after validating the content, such as JSON syntax errors."+ },+ {+ "name": "options",+ "type": "IStandaloneEditorConstructionOptions",+ "required": false,+ "defaultValue": null,+ "description": "Monaco editor options merged over the Twenty defaults. `padding` is ignored; use `contentPadding` instead."+ },+ {+ "name": "resizable",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Adds a handle below the editor to drag its height."+ },+ {+ "name": "setMarkers",+ "type": "((value: string) => IMarkerData[])",+ "required": false,+ "defaultValue": null,+ "description": "Returns custom validation markers for the content. Runs when the editor mounts and after every change, replacing the previous custom markers."+ },+ {+ "name": "transparentBackground",+ "type": "boolean",+ "required": false,+ "defaultValue": null,+ "description": "Removes the editor background so the surrounding surface shows through."+ },+ {+ "name": "value",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Content of the editor. Pair it with `onChange` to control the editor."+ },+ {+ "name": "variant",+ "type": "\"default\" | \"with-header\" | \"borderless\"",+ "required": false,+ "defaultValue": "default",+ "description": "Border treatment: `default` draws a rounded border, `with-header` attaches the editor below a `CodeEditorHeader`, and `borderless` removes the border."+ }+ ]+ },+ {+ "name": "CodeEditorHeader",+ "entryPoint": "twenty-ui/components/code-editor",+ "slug": "components/code-editor-header",+ "props": [+ {+ "name": "leftNodes",+ "type": "ReactNode[]",+ "required": false,+ "defaultValue": null,+ "description": "Elements shown at the start of the header, such as tabs."+ },+ {+ "name": "rightNodes",+ "type": "ReactNode[]",+ "required": false,+ "defaultValue": null,+ "description": "Elements shown at the end of the header, such as actions."+ },+ {+ "name": "title",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Text shown at the start of the header, after `leftNodes`."+ }+ ]+ },{"name": "Dialog","entryPoint": "twenty-ui/primitives/surfaces",diff --git a/packages/twenty-ui/package.json b/packages/twenty-ui/package.jsonindex 7bbdf439774..d9809e981a1 100644--- a/packages/twenty-ui/package.json+++ b/packages/twenty-ui/package.json@@ -30,7 +30,9 @@],"devDependencies": {"@argos-ci/storybook": "6.2.3",+ "@fontsource/dm-mono": "^5.2.7","@fontsource/inter": "^5.2.8",+ "@monaco-editor/react": "^4.7.0","@prettier/sync": "^0.5.2","@size-limit/preset-small-lib": "^12.1.0","@storybook-community/storybook-addon-cookie": "^5.0.0",@@ -51,6 +53,7 @@"esbuild": "^0.28.1","glob": "^11.1.0","jsdom": "^30.0.1",+ "monaco-editor": "0.52.2","prettier": "^3.1.1","react": "^19.2.0","react-docgen-typescript": "^2.2.2",@@ -71,7 +74,6 @@"dependencies": {"@base-ui/react": "^1.8.0","@base-ui/utils": "0.4.0",- "@monaco-editor/react": "^4.7.0","@sniptt/guards": "^0.2.0","@tabler/icons-react": "^3.31.0","clsx": "^2.1.1",@@ -81,6 +83,7 @@"zod": "^4.1.11"},"peerDependencies": {+ "@monaco-editor/react": "^4.7.0","monaco-editor": ">= 0.25.0 < 1","react": "^19.0.0","react-dom": "^19.0.0"@@ -114,6 +117,11 @@"import": "./dist/components.mjs","require": "./dist/components.cjs"},+ "./components/code-editor": {+ "types": "./dist/components/code-editor/index.d.ts",+ "import": "./dist/components/code-editor.mjs",+ "require": "./dist/components/code-editor.cjs"+ },"./icon": {"types": "./dist/icon/index.d.ts","import": "./dist/icon.mjs",@@ -203,6 +211,9 @@"components": ["dist/components/index.d.ts"],+ "components/code-editor": [+ "dist/components/code-editor/index.d.ts"+ ],"icon": ["dist/icon/index.d.ts"],@@ -252,5 +263,13 @@"dist/utilities/index.d.ts"]}+ },+ "peerDependenciesMeta": {+ "@monaco-editor/react": {+ "optional": true+ },+ "monaco-editor": {+ "optional": true+ }}}diff --git a/packages/twenty-ui/project.json b/packages/twenty-ui/project.jsonindex fbbad6deb8c..dac88e2885c 100644--- a/packages/twenty-ui/project.json+++ b/packages/twenty-ui/project.json@@ -91,6 +91,16 @@"command": "tsx scripts/checkPackSize.ts"}},+ "test:package": {+ "executor": "nx:run-commands",+ "cache": true,+ "dependsOn": ["build"],+ "inputs": ["production"],+ "options": {+ "cwd": "{projectRoot}",+ "command": "tsx scripts/checkOptionalDependencies.ts"+ }+ },"clean": {"executor": "nx:run-commands","options": { "command": "rimraf {projectRoot}/dist" }diff --git a/packages/twenty-ui/scripts/checkOptionalDependencies.ts b/packages/twenty-ui/scripts/checkOptionalDependencies.tsnew file mode 100644index 00000000000..57c046f7283--- /dev/null+++ b/packages/twenty-ui/scripts/checkOptionalDependencies.ts@@ -0,0 +1,120 @@+import { isNonEmptyArray } from '@sniptt/guards';+import { build, type Plugin } from 'esbuild';+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import ts from 'typescript';++import packageJson from '../package.json';+import { isDefined } from '../src/utilities/utils/isDefined';++type DeclarationImport = {+ declarationFilePath: string;+ importPath: string;+};++const PACKAGE_PATH = path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ '..',+);+const ROOT_ENTRY_POINT = packageJson.exports['.'];+const OPTIONAL_PEER_DEPENDENCY_NAMES = Object.entries(+ packageJson.peerDependenciesMeta,+)+ .filter(([, { optional }]) => optional)+ .map(([dependencyName]) => dependencyName);+const BARE_IMPORT_PATH_PATTERN = /^[^./]/;+const DECLARATION_FILE_SUFFIXES = ['.d.ts', '/index.d.ts'];++const isOptionalPeerDependencyImportPath = (importPath: string) =>+ OPTIONAL_PEER_DEPENDENCY_NAMES.some(+ (dependencyName) =>+ importPath === dependencyName ||+ importPath.startsWith(`${dependencyName}/`),+ );++const rejectOptionalPeerDependenciesPlugin: Plugin = {+ name: 'reject-optional-peer-dependencies',+ setup: (build) => {+ build.onResolve({ filter: BARE_IMPORT_PATH_PATTERN }, ({ path }) =>+ isOptionalPeerDependencyImportPath(path)+ ? { errors: [{ text: `Unexpected optional peer dependency: ${path}` }] }+ : undefined,+ );+ },+};++const resolveDeclarationFilePath = (+ importerFilePath: string,+ importPath: string,+) => {+ const declarationFilePath = DECLARATION_FILE_SUFFIXES.map((suffix) =>+ path.resolve(path.dirname(importerFilePath), `${importPath}${suffix}`),+ ).find((candidateFilePath) => fs.existsSync(candidateFilePath));++ if (!isDefined(declarationFilePath)) {+ throw new Error(+ `Cannot resolve ${importPath} from ${path.relative(PACKAGE_PATH, importerFilePath)}`,+ );+ }++ return declarationFilePath;+};++const collectBareDeclarationImports = (+ declarationFilePath: string,+ visitedDeclarationFilePaths: Set<string>,+): DeclarationImport[] => {+ if (visitedDeclarationFilePaths.has(declarationFilePath)) {+ return [];+ }++ visitedDeclarationFilePaths.add(declarationFilePath);++ const { importedFiles, typeReferenceDirectives } = ts.preProcessFile(+ fs.readFileSync(declarationFilePath, 'utf-8'),+ );++ return [...importedFiles, ...typeReferenceDirectives].flatMap(+ ({ fileName: importPath }) =>+ BARE_IMPORT_PATH_PATTERN.test(importPath)+ ? [{ declarationFilePath, importPath }]+ : collectBareDeclarationImports(+ resolveDeclarationFilePath(declarationFilePath, importPath),+ visitedDeclarationFilePaths,+ ),+ );+};++for (const entryPath of [ROOT_ENTRY_POINT.import, ROOT_ENTRY_POINT.require]) {+ await build({+ entryPoints: [path.resolve(PACKAGE_PATH, entryPath)],+ bundle: true,+ packages: 'external',+ write: false,+ logLevel: 'error',+ plugins: [rejectOptionalPeerDependenciesPlugin],+ });+}++const optionalPeerDependencyDeclarationImports = collectBareDeclarationImports(+ path.resolve(PACKAGE_PATH, ROOT_ENTRY_POINT.types),+ new Set(),+).filter(({ importPath }) => isOptionalPeerDependencyImportPath(importPath));++if (isNonEmptyArray(optionalPeerDependencyDeclarationImports)) {+ for (const {+ declarationFilePath,+ importPath,+ } of optionalPeerDependencyDeclarationImports) {+ process.stderr.write(+ `Unexpected optional peer dependency: ${importPath} in ${path.relative(PACKAGE_PATH, declarationFilePath)}\n`,+ );+ }++ process.exit(1);+}++process.stdout.write(+ 'The root entry point builds without optional peer dependencies.\n',+);diff --git a/packages/twenty-ui/scripts/generateBarrels.ts b/packages/twenty-ui/scripts/generateBarrels.tsindex 9ac11d07c8a..42ade769f96 100644--- a/packages/twenty-ui/scripts/generateBarrels.ts+++ b/packages/twenty-ui/scripts/generateBarrels.ts@@ -13,6 +13,12 @@ const PACKAGE_JSON_FILENAME = 'package.json';const NX_PROJECT_CONFIGURATION_FILENAME = 'project.json';const PACKAGE_PATH = path.resolve('packages/twenty-ui');const SRC_PATH = path.resolve(`${PACKAGE_PATH}/src`);+const STANDALONE_MODULES = [+ 'assets',+ 'components/code-editor',+ 'styles',+ 'testing',+];const PACKAGE_JSON_PATH = path.join(PACKAGE_PATH, PACKAGE_JSON_FILENAME);const NX_PROJECT_CONFIGURATION_PATH = path.join(PACKAGE_PATH,@@ -145,9 +151,11 @@ const generateModuleIndexFiles = (exportByBarrel: ExportByBarrel[]) => {.join('\n');}).join('\n');- const childModuleExports = childModuleDirectories.map(- (directory) => `export * from './${path.basename(directory)}';`,- );+ const childModuleExports = childModuleDirectories+ .filter(+ (directory) => !STANDALONE_MODULES.includes(getModuleName(directory)),+ )+ .map((directory) => `export * from './${path.basename(directory)}';`);const content = [fileExports, ...childModuleExports].filter((entry) => entry !== '').join('\n');@@ -507,13 +515,12 @@ const retrieveExportsByBarrel = (barrelDirectories: string[]) => {});};-const ROOT_BARREL_EXCLUDED_MODULES = ['assets', 'styles', 'testing'];const INDIVIDUAL_ENTRY_FILENAME = 'individual-entry';const getRootBarrelModuleNames = (moduleDirectories: string[]) =>moduleDirectories.map(getModuleName)- .filter((moduleName) => !ROOT_BARREL_EXCLUDED_MODULES.includes(moduleName));+ .filter((moduleName) => !STANDALONE_MODULES.includes(moduleName));const generateRootBarrel = (moduleDirectories: string[],@@ -542,8 +549,13 @@ const generateIndividualEntry = (const main = () => {const moduleDirectories = getSubDirectoryPaths(SRC_PATH);const barrelDirectories = [- ...moduleDirectories,- ...getSubDirectoryPaths(path.join(SRC_PATH, 'primitives')),+ ...new Set([+ ...moduleDirectories,+ ...getSubDirectoryPaths(path.join(SRC_PATH, 'primitives')),+ ...STANDALONE_MODULES.map((moduleName) =>+ path.join(SRC_PATH, moduleName),+ ),+ ]),].sort((first, second) => first.localeCompare(second));const exportsByBarrel = retrieveExportsByBarrel(barrelDirectories);const moduleIndexFiles = generateModuleIndexFiles(exportsByBarrel);diff --git a/packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.module.scss b/packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.module.scsssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.module.scssrename to packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.module.scssdiff --git a/packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.module.scss.d.ts b/packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.module.scss.d.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.module.scss.d.tsrename to packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.module.scss.d.tsdiff --git a/packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.tsx b/packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.tsxsimilarity index 90%rename from packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.tsxrename to packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.tsxindex a149aac4ce3..fa7061d53bc 100644--- a/packages/twenty-ui/src/primitives/input/CodeEditor/CodeEditor.tsx+++ b/packages/twenty-ui/src/components/code-editor/CodeEditor/CodeEditor.tsx@@ -1,11 +1,7 @@-import Editor, {- loader,- type EditorProps,- type Monaco,-} from '@monaco-editor/react';+import Editor, { loader, type Monaco } from '@monaco-editor/react';import { Loader } from '@ui/primitives/feedback/Loader/Loader';-import { BASE_CODE_EDITOR_THEME_ID } from '@ui/primitives/input/CodeEditor/constants/BaseCodeEditorThemeId';-import { getBaseCodeEditorTheme } from '@ui/primitives/input/CodeEditor/utils/getBaseCodeEditorTheme';+import { BASE_CODE_EDITOR_THEME_ID } from '@ui/components/code-editor/CodeEditor/constants/BaseCodeEditorThemeId';+import { getBaseCodeEditorTheme } from '@ui/components/code-editor/CodeEditor/utils/getBaseCodeEditorTheme';import { ResizeHandle } from '@ui/primitives/layout/ResizeHandle/ResizeHandle';import { useResizeHandle } from '@ui/primitives/layout/ResizeHandle/hooks/useResizeHandle';import {@@ -18,9 +14,7 @@ import { type KeyboardEvent, useEffect, useState } from 'react';import { isDefined } from '@ui/utilities/utils/isDefined';import styles from './CodeEditor.module.scss';--type CodeEditorVariant = 'default' | 'with-header' | 'borderless';-type CodeEditorContentPadding = 'default' | 'comfortable';+import { type CodeEditorProps } from './types/CodeEditorProps';// Left alone, `@monaco-editor/loader` downloads Monaco from a CDN at runtime,// which puts a second Monaco — pinned to a different version than the one we@@ -62,20 +56,6 @@ const setCodeEditorTheme = (monaco.editor.setTheme(BASE_CODE_EDITOR_THEME_ID);};-type CodeEditorProps = Pick<- EditorProps,- 'value' | 'language' | 'onMount' | 'onValidate' | 'height' | 'options'-> & {- onChange?: (value: string) => void;- setMarkers?: (value: string) => editor.IMarkerData[];- variant?: CodeEditorVariant;- isLoading?: boolean;- transparentBackground?: boolean;- resizable?: boolean;- contentPadding?: CodeEditorContentPadding;- autoHeight?: boolean;-};-export const CodeEditor = ({value,language,diff --git a/packages/twenty-ui/src/components/code-editor/CodeEditor/__stories__/CodeEditor.stories.tsx b/packages/twenty-ui/src/components/code-editor/CodeEditor/__stories__/CodeEditor.stories.tsxnew file mode 100644index 00000000000..96d32c89af2--- /dev/null+++ b/packages/twenty-ui/src/components/code-editor/CodeEditor/__stories__/CodeEditor.stories.tsx@@ -0,0 +1,99 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';++import { CodeEditorHeader } from '@ui/components/code-editor/CodeEditorHeader/CodeEditorHeader';+import { Button } from '@ui/primitives/input/Button/Button';+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';++import { CodeEditor } from '../CodeEditor';+import { waitForCodeEditorContent } from './waitForCodeEditorContent';++const WORKSPACE_SETTINGS_JSON = JSON.stringify(+ { name: 'Acme', plan: 'Pro', seats: 12 },+ null,+ 2,+);++const handleChange = fn();++const meta: Meta<typeof CodeEditor> = {+ title: 'UI/Components/CodeEditor',+ component: CodeEditor,+ args: {+ value: WORKSPACE_SETTINGS_JSON,+ language: 'json',+ height: 160,+ },+ parameters: {+ a11y: A11Y_DEFER_COLOR_CONTRAST,+ container: { width: 480 },+ },+ render: (args) => (+ <div style={{ width: '100%' }}>+ <CodeEditor {...args} />+ </div>+ ),+};++export default meta;++type Story = StoryObj<typeof CodeEditor>;++export const Default: Story = {+ decorators: [ComponentDecorator],+ play: async ({ canvasElement }) => {+ await waitForCodeEditorContent(canvasElement, '"name": "Acme"');+ },+};++export const Documentation: Story = {+ ...Default,+ args: { variant: 'with-header' },+ render: (args) => (+ <div style={{ width: '100%' }}>+ <CodeEditorHeader+ title="workspace.json"+ rightNodes={[+ <Button key="format" size="sm" variant="outline">+ Format+ </Button>,+ ]}+ />+ <CodeEditor {...args} />+ </div>+ ),+};++export const Dark: Story = {+ ...Documentation,+ tags: ['!autodocs'],+ globals: { colorScheme: 'dark' },+};++export const Editing: Story = {+ ...Default,+ args: {+ language: 'plaintext',+ onChange: handleChange,+ options: { occurrencesHighlight: 'off', cursorBlinking: 'solid' },+ },+ play: async ({ canvasElement }) => {+ handleChange.mockClear();++ await waitForCodeEditorContent(canvasElement, '"name": "Acme"');++ within(canvasElement).getByRole('textbox').focus();+ await userEvent.keyboard('x');++ await waitFor(() => {+ expect(handleChange).toHaveBeenLastCalledWith(+ `x${WORKSPACE_SETTINGS_JSON}`,+ );+ });+ },+};++export const Loading: Story = {+ decorators: [ComponentDecorator],+ args: { isLoading: true },+};diff --git a/packages/twenty-ui/src/components/code-editor/CodeEditor/__stories__/waitForCodeEditorContent.ts b/packages/twenty-ui/src/components/code-editor/CodeEditor/__stories__/waitForCodeEditorContent.tsnew file mode 100644index 00000000000..eee8e4a03a5--- /dev/null+++ b/packages/twenty-ui/src/components/code-editor/CodeEditor/__stories__/waitForCodeEditorContent.ts@@ -0,0 +1,20 @@+import { expect, waitFor } from 'storybook/test';++const NON_BREAKING_SPACE = ' ';+const CODE_EDITOR_LOAD_TIMEOUT_IN_MS = 20_000;++export const waitForCodeEditorContent = async (+ canvasElement: HTMLElement,+ expectedContent: string,+) => {+ await waitFor(+ () => {+ const renderedLines = canvasElement.querySelector('.view-lines');++ expect(+ renderedLines?.textContent?.split(NON_BREAKING_SPACE).join(' '),+ ).toContain(expectedContent);+ },+ { timeout: CODE_EDITOR_LOAD_TIMEOUT_IN_MS },+ );+};diff --git a/packages/twenty-ui/src/primitives/input/CodeEditor/constants/BaseCodeEditorThemeId.ts b/packages/twenty-ui/src/components/code-editor/CodeEditor/constants/BaseCodeEditorThemeId.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/CodeEditor/constants/BaseCodeEditorThemeId.tsrename to packages/twenty-ui/src/components/code-editor/CodeEditor/constants/BaseCodeEditorThemeId.tsdiff --git a/packages/twenty-ui/src/components/code-editor/CodeEditor/types/CodeEditorProps.ts b/packages/twenty-ui/src/components/code-editor/CodeEditor/types/CodeEditorProps.tsnew file mode 100644index 00000000000..6d1f33c5d37--- /dev/null+++ b/packages/twenty-ui/src/components/code-editor/CodeEditor/types/CodeEditorProps.ts@@ -0,0 +1,19 @@+import { type EditorProps } from '@monaco-editor/react';+import { type editor } from 'monaco-editor';++type CodeEditorVariant = 'default' | 'with-header' | 'borderless';+type CodeEditorContentPadding = 'default' | 'comfortable';++export type CodeEditorProps = Pick<+ EditorProps,+ 'value' | 'language' | 'onMount' | 'onValidate' | 'height' | 'options'+> & {+ onChange?: (value: string) => void;+ setMarkers?: (value: string) => editor.IMarkerData[];+ variant?: CodeEditorVariant;+ isLoading?: boolean;+ transparentBackground?: boolean;+ resizable?: boolean;+ contentPadding?: CodeEditorContentPadding;+ autoHeight?: boolean;+};diff --git a/packages/twenty-ui/src/primitives/input/CodeEditor/utils/getBaseCodeEditorTheme.ts b/packages/twenty-ui/src/components/code-editor/CodeEditor/utils/getBaseCodeEditorTheme.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/CodeEditor/utils/getBaseCodeEditorTheme.tsrename to packages/twenty-ui/src/components/code-editor/CodeEditor/utils/getBaseCodeEditorTheme.tsdiff --git a/packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.module.scss b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.module.scsssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.module.scssrename to packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.module.scssdiff --git a/packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.module.scss.d.ts b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.module.scss.d.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.module.scss.d.tsrename to packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.module.scss.d.tsdiff --git a/packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.tsx b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.tsxsimilarity index 75%rename from packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.tsxrename to packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.tsxindex 3cd97f84b49..8f4d5612a66 100644--- a/packages/twenty-ui/src/primitives/input/CodeEditorHeader/CodeEditorHeader.tsx+++ b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/CodeEditorHeader.tsx@@ -1,16 +1,11 @@+import { type CodeEditorHeaderProps } from './types/CodeEditorHeaderProps';import styles from './CodeEditorHeader.module.scss';-export type CoreEditorHeaderProps = {- title?: string;- leftNodes?: React.ReactNode[];- rightNodes?: React.ReactNode[];-};--export const CoreEditorHeader = ({+export const CodeEditorHeader = ({title,leftNodes,rightNodes,-}: CoreEditorHeaderProps) => {+}: CodeEditorHeaderProps) => {return (<div className={styles.editorHeader}><div className={styles.elementContainer}>diff --git a/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/__stories__/CodeEditorHeader.stories.tsx b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/__stories__/CodeEditorHeader.stories.tsxnew file mode 100644index 00000000000..790a685e85c--- /dev/null+++ b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/__stories__/CodeEditorHeader.stories.tsx@@ -0,0 +1,60 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, within } from 'storybook/test';++import { IconCopy } from '@ui/icon/components/TablerIcons';+import { Button } from '@ui/primitives/input/Button/Button';+import { LightIconButton } from '@ui/primitives/input/LightIconButton/LightIconButton';+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';++import { CodeEditorHeader } from '../CodeEditorHeader';++const meta: Meta<typeof CodeEditorHeader> = {+ title: 'UI/Components/CodeEditorHeader',+ component: CodeEditorHeader,+ args: { title: 'workspace.json' },+ parameters: {+ a11y: A11Y_DEFER_COLOR_CONTRAST,+ container: { width: 480 },+ },+ render: (args) => (+ <div style={{ width: '100%' }}>+ <CodeEditorHeader {...args} />+ </div>+ ),+};++export default meta;++type Story = StoryObj<typeof CodeEditorHeader>;++export const Default: Story = {+ decorators: [ComponentDecorator],+ play: async ({ canvasElement }) => {+ await expect(+ within(canvasElement).getByText('workspace.json'),+ ).toBeVisible();+ },+};++export const WithActions: Story = {+ ...Default,+ args: {+ leftNodes: [+ <LightIconButton key="copy" Icon={IconCopy} aria-label="Copy code" />,+ ],+ rightNodes: [+ <Button key="run" size="sm" variant="solid" color="accent">+ Run+ </Button>,+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expect(canvas.getByText('workspace.json')).toBeVisible();+ await expect(+ canvas.getByRole('button', { name: 'Copy code' }),+ ).toBeVisible();+ await expect(canvas.getByRole('button', { name: 'Run' })).toBeVisible();+ },+};diff --git a/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/types/CodeEditorHeaderProps.ts b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/types/CodeEditorHeaderProps.tsnew file mode 100644index 00000000000..601e18a1804--- /dev/null+++ b/packages/twenty-ui/src/components/code-editor/CodeEditorHeader/types/CodeEditorHeaderProps.ts@@ -0,0 +1,5 @@+export type CodeEditorHeaderProps = {+ title?: string;+ leftNodes?: React.ReactNode[];+ rightNodes?: React.ReactNode[];+};diff --git a/packages/twenty-ui/src/components/code-editor/index.ts b/packages/twenty-ui/src/components/code-editor/index.tsnew file mode 100644index 00000000000..5508a6d3a78--- /dev/null+++ b/packages/twenty-ui/src/components/code-editor/index.ts@@ -0,0 +1,15 @@+/*+ * _____ _+ *|_ _|_ _____ _ __ | |_ _ _+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file+ * | | \ V V / __/ | | | |_| |_| | Any edits to this will be overridden+ * |_| \_/\_/ \___|_| |_|\__|\__, |+ * |___/+ */++export { CodeEditor } from './CodeEditor/CodeEditor';+export { BASE_CODE_EDITOR_THEME_ID } from './CodeEditor/constants/BaseCodeEditorThemeId';+export type { CodeEditorProps } from './CodeEditor/types/CodeEditorProps';+export { getBaseCodeEditorTheme } from './CodeEditor/utils/getBaseCodeEditorTheme';+export { CodeEditorHeader } from './CodeEditorHeader/CodeEditorHeader';+export type { CodeEditorHeaderProps } from './CodeEditorHeader/types/CodeEditorHeaderProps';diff --git a/packages/twenty-ui/src/primitives/input/index.ts b/packages/twenty-ui/src/primitives/input/index.tsindex ab27ce85ba5..01de9311ccf 100644--- a/packages/twenty-ui/src/primitives/input/index.ts+++ b/packages/twenty-ui/src/primitives/input/index.ts@@ -26,11 +26,6 @@ export type { CheckboxProps } from './Checkbox/types/CheckboxProps';export type { CheckboxShape } from './Checkbox/types/CheckboxShape';export type { CheckboxSize } from './Checkbox/types/CheckboxSize';export type { CheckboxVariant } from './Checkbox/types/CheckboxVariant';-export { CodeEditor } from './CodeEditor/CodeEditor';-export { BASE_CODE_EDITOR_THEME_ID } from './CodeEditor/constants/BaseCodeEditorThemeId';-export { getBaseCodeEditorTheme } from './CodeEditor/utils/getBaseCodeEditorTheme';-export type { CoreEditorHeaderProps } from './CodeEditorHeader/CodeEditorHeader';-export { CoreEditorHeader } from './CodeEditorHeader/CodeEditorHeader';export { ColorPickerButton } from './ColorPickerButton/ColorPickerButton';export type {ColorSchemeSegmentProps,diff --git a/packages/twenty-ui/tsconfig.json b/packages/twenty-ui/tsconfig.jsonindex 2835d49d897..064c7b4d11d 100644--- a/packages/twenty-ui/tsconfig.json+++ b/packages/twenty-ui/tsconfig.json@@ -33,6 +33,7 @@"vite.config.ts","scripts/generateDocsData.ts","docs/**/*.ts",- "scripts/checkDocsExamples.ts"+ "scripts/checkDocsExamples.ts",+ "scripts/checkOptionalDependencies.ts"]}diff --git a/packages/twenty-ui/vite.config.individual.ts b/packages/twenty-ui/vite.config.individual.tsindex 6b80d23fda6..abc5f70d768 100644--- a/packages/twenty-ui/vite.config.individual.ts+++ b/packages/twenty-ui/vite.config.individual.ts@@ -13,6 +13,12 @@ const depNames = Object.keys({const isExternal = (id: string): boolean =>depNames.some((dep) => id === dep || id.startsWith(dep + '/'));+const entries = Object.keys(packageJson.exports)+ .filter((subpath) => !subpath.endsWith('.css'))+ .map((subpath) =>+ subpath === '.' ? 'src/individual-entry.ts' : `src/${subpath}/index.ts`,+ );+export default defineConfig(() => {return {resolve: {@@ -57,7 +63,7 @@ export default defineConfig(() => {requireReturnsDefault: 'auto',},lib: {- entry: 'src/individual-entry.ts',+ entry: entries,formats: ['es'],},rollupOptions: {diff --git a/yarn.lock b/yarn.lockindex 7dd092c406e..dc7fad20e3a 100644--- a/yarn.lock+++ b/yarn.lock@@ -20001,7 +20001,6 @@ __metadata:electron: "npm:44.1.0"esbuild: "npm:^0.28.1"jsdom: "npm:^30.0.1"- monaco-editor: "npm:^0.52.2"react: "npm:^19.2.0"react-dom: "npm:^19.2.0"sass: "npm:^1.83.0"@@ -27980,6 +27979,7 @@ __metadata:lodash.startcase: "npm:^4.4.0"twenty-sdk: "workspace:*"twenty-shared: "workspace:*"+ twenty-ui: "workspace:*"typescript: "npm:^5.9.3"uuid: "npm:^13.0.2"vite: "npm:^8.0.0"@@ -39936,7 +39936,7 @@ __metadata:languageName: nodelinkType: hard-"monaco-editor@npm:0.52.2, monaco-editor@npm:^0.52.2":+"monaco-editor@npm:0.52.2":version: 0.52.2resolution: "monaco-editor@npm:0.52.2"checksum: 10c0/5a92da64f1e2ab375c0ce99364137f794d057c97bed10ecc65a08d6e6846804b8ecbd377eacf01e498f7dfbe1b21e8be64f728256681448f0484df90e767b435@@ -49965,6 +49965,7 @@ __metadata:"@chakra-ui/react": "npm:^3.33.0""@emotion/react": "npm:^11.14.0""@emotion/styled": "npm:^11.14.0"+ "@monaco-editor/react": "npm:^4.7.0""@mui/material": "npm:^7.3.8""@quilted/threads": "npm:^4.0.1""@remote-dom/core": "npm:^1.10.1"@@ -49977,6 +49978,7 @@ __metadata:"@types/react-dom": "npm:^19.2.0""@typescript/native-preview": "npm:^7.0.0-dev.20260116.1""@vitest/browser-playwright": "npm:^4.1.0"+ monaco-editor: "npm:0.52.2"playwright: "npm:^1.60.0"prettier: "npm:^3.1.1"react: "npm:^19.2.0"@@ -50507,6 +50509,7 @@ __metadata:"@argos-ci/storybook": "npm:6.2.3""@base-ui/react": "npm:^1.8.0""@base-ui/utils": "npm:0.4.0"+ "@fontsource/dm-mono": "npm:^5.2.7""@fontsource/inter": "npm:^5.2.8""@monaco-editor/react": "npm:^4.7.0""@prettier/sync": "npm:^0.5.2"@@ -50532,6 +50535,7 @@ __metadata:esbuild: "npm:^0.28.1"glob: "npm:^11.1.0"jsdom: "npm:^30.0.1"+ monaco-editor: "npm:0.52.2"prettier: "npm:^3.1.1"react: "npm:^19.2.0"react-docgen-typescript: "npm:^2.2.2"@@ -50553,9 +50557,15 @@ __metadata:vitest: "npm:^4.1.0"zod: "npm:^4.1.11"peerDependencies:+ "@monaco-editor/react": ^4.7.0monaco-editor: ">= 0.25.0 < 1"react: ^19.0.0react-dom: ^19.0.0+ peerDependenciesMeta:+ "@monaco-editor/react":+ optional: true+ monaco-editor:+ optional: truelanguageName: unknownlinkType: soft