The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Harden unified workspace surfaces (#25164)
Félix Malfait14d196c1e21e
diff --git a/packages/twenty-docs/developers/extend/apps/layout/front-components.mdx b/packages/twenty-docs/developers/extend/apps/layout/front-components.mdxindex 308ced1f09f..81b499a9863 100644--- a/packages/twenty-docs/developers/extend/apps/layout/front-components.mdx+++ b/packages/twenty-docs/developers/extend/apps/layout/front-components.mdx@@ -154,7 +154,7 @@ Import them from `twenty-sdk/front-component`:- **`Command`** — Runs an async callback via the `execute` prop.- **`CommandLink`** — Navigates to an app path. Props: `to`, `params`, `queryParams`, `options`.- **`CommandModal`** — Opens a confirmation modal. If the user confirms, executes the `execute` callback. Props: `title`, `subtitle`, `execute`, `confirmButtonText`, `confirmButtonAccent`.-- **`CommandOpenSidePanelPage`** — Opens content in the side panel. Workspace routes use the same typed `to`, `params`, and `queryParams` props as `CommandLink`, plus optional `hash`, `pageTitle`, and `resetNavigationStack` props. `pageTitle` overrides the panel header title, while `resetNavigationStack` clears earlier panel pages before opening the route. Purpose-built panel tools use their own page-specific props.+- **`CommandOpenSidePanelPage`** — Opens content in the side panel. Routed pages use the same typed `to`, `params`, and `queryParams` props as `CommandLink`, plus optional `hash`, `pageTitle`, and `resetNavigationStack` props. The workspace route registry decides whether the requested `AppPath` supports the side panel. `pageTitle` overrides the panel header title, while `resetNavigationStack` clears earlier panel pages before opening the route. Purpose-built panel tools use their own page-specific props.Here is a full example of a headless front component using `Command` to run an action from the command menu:diff --git a/packages/twenty-front/src/hooks/__tests__/useNavigateSettings.test.tsx b/packages/twenty-front/src/hooks/__tests__/useNavigateSettings.test.tsxindex ecd3c8cf756..4109a734ac5 100644--- a/packages/twenty-front/src/hooks/__tests__/useNavigateSettings.test.tsx+++ b/packages/twenty-front/src/hooks/__tests__/useNavigateSettings.test.tsx@@ -27,8 +27,6 @@ const SidePanelWrapper = ({ children }: { children: React.ReactNode }) => (type: 'side-panel',instanceId: 'side-panel-page',ownsRouteLocation: false,- headerTitlePortal: null,- headerActionsPortal: null,}}>{children}diff --git a/packages/twenty-front/src/modules/ai/hooks/useChatReferenceTarget.ts b/packages/twenty-front/src/modules/ai/hooks/useChatReferenceTarget.tsindex ebf560d29a5..d37a9f65b08 100644--- a/packages/twenty-front/src/modules/ai/hooks/useChatReferenceTarget.ts+++ b/packages/twenty-front/src/modules/ai/hooks/useChatReferenceTarget.ts@@ -1,5 +1,5 @@import { useLocation } from 'react-router-dom';-import { isDefined } from 'twenty-shared/utils';+import { isNonEmptyString } from '@sniptt/guards';import { shouldOpenAiChatAfterOnboardingState } from '@/onboarding/states/shouldOpenAiChatAfterOnboardingState';import { useOpenRoutedPageInSidePanel } from '@/side-panel/routing/hooks/useOpenRoutedPageInSidePanel';@@ -21,7 +21,7 @@ export const useChatReferenceTarget = (return {to: path,onClick:- isDefined(path) && isArtifactSurface+ isNonEmptyString(path) && isArtifactSurface? (onOpenArtifact ?? (() => openRoutedPageInSidePanel({ path }))): undefined,};diff --git a/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsx b/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsxindex d66c89b82cf..9556249a4f2 100644--- a/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsx+++ b/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsx@@ -690,7 +690,7 @@ const MAIN_AND_SIDE_PANEL_SETTINGS_ROUTE_HANDLE: SettingsRouteHandle = {const EXPANDABLE_SETTINGS_ROUTE_HANDLE: SettingsRouteHandle = {...MAIN_AND_SIDE_PANEL_SETTINGS_ROUTE_HANDLE,- isLocationExpandableFromSidePanel: () => true,+ isLocationExpandableFromSidePanel: true,};const MEMBERS_LIST_SETTINGS_ROUTE_HANDLE: SettingsRouteHandle = {diff --git a/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx b/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsxindex 9ee7f2025fc..8a281f06432 100644--- a/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx+++ b/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx@@ -5,7 +5,7 @@ import { useReturnToPath } from '@/auth/hooks/useReturnToPath';import { useIsOnAuthOrOnboardingPage } from '@/auth/hooks/useIsOnAuthOrOnboardingPage';import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';import { SIDE_PANEL_PATH_SEARCH_PARAM } from '@/side-panel/routing/constants/SidePanelPathSearchParam';-import { isSidePanelRoutedLocation } from '@/side-panel/routing/utils/isSidePanelRoutedLocation';+import { isWorkspaceLocationAvailableOnSurface } from '@/app/routing/utils/isWorkspaceLocationAvailableOnSurface';import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState';import { sidePanelPageInfoSelector } from '@/side-panel/states/sidePanelPageInfoSelector';import { MAIN_CONTEXT_STORE_INSTANCE_ID } from '@/context-store/constants/MainContextStoreInstanceId';@@ -29,6 +29,7 @@ import { useResetFocusStackToFocusItem } from '@/ui/utilities/focus/hooks/useResimport { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import { isSafeInternalPath } from '@/ui/navigation/utils/isSafeInternalPath';import { currentPageLayoutIdState } from '@/page-layout/states/currentPageLayoutIdState';import { useStore } from 'jotai';import { useEffect, useState } from 'react';@@ -57,8 +58,12 @@ export const PageChangeEffect = () => {const hasRoutedSidePanelTarget =isDefined(sidePanelPathFromUrl) &&- sidePanelPathFromUrl.startsWith('/') &&- isSidePanelRoutedLocation(workspaceRouteObjects, sidePanelPathFromUrl);+ isSafeInternalPath(sidePanelPathFromUrl) &&+ isWorkspaceLocationAvailableOnSurface(+ workspaceRouteObjects,+ 'side-panel',+ sidePanelPathFromUrl,+ );const pageChangeEffectNavigateLocation =usePageChangeEffectNavigateLocation();@@ -119,7 +124,8 @@ export const PageChangeEffect = () => {const currentPage = store.get(sidePanelPageInfoSelector.atom).page;const shouldKeepSidePanelOpen =currentPage === SidePanelPages.NavigationMenuItemEdit ||- currentPage === SidePanelPages.AskAI;+ currentPage === SidePanelPages.AskAI ||+ currentPage === SidePanelPages.RoutedPage;if (!shouldKeepSidePanelOpen) {closeSidePanelMenu();diff --git a/packages/twenty-front/src/modules/app/routing/components/WorkspaceRoutes.tsx b/packages/twenty-front/src/modules/app/routing/components/WorkspaceRoutes.tsxindex fcc6ac76dc5..0db7bbc6c05 100644--- a/packages/twenty-front/src/modules/app/routing/components/WorkspaceRoutes.tsx+++ b/packages/twenty-front/src/modules/app/routing/components/WorkspaceRoutes.tsx@@ -1,33 +1,35 @@import { useWorkspaceRouteObjects } from '@/app/routing/components/WorkspaceRouteObjectsProvider';-import { type WorkspaceSurfaceType } from '@/app/routing/types/WorkspaceRouteObject';import { getWorkspaceRouteObjectsForSurface } from '@/app/routing/utils/getWorkspaceRouteObjectsForSurface';import { isWorkspaceLocationAvailableOnSurface } from '@/app/routing/utils/isWorkspaceLocationAvailableOnSurface';import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';import { RoutedFlowStateScopeContext } from '@/ui/utilities/state/contexts/RoutedFlowStateScopeContext';-import { type ReactNode } from 'react';+import { type ReactNode, useMemo } from 'react';import { type Location, useRoutes } from 'react-router-dom';export const WorkspaceRoutes = ({- surface,location,fallback = null,}: {- surface: WorkspaceSurfaceType;location?: Partial<Location> | string;fallback?: ReactNode;}) => {const routeObjects = useWorkspaceRouteObjects();const workspaceSurface = useWorkspaceSurface();- const surfaceRouteObjects = getWorkspaceRouteObjectsForSurface(- routeObjects,- surface,+ const surfaceRouteObjects = useMemo(+ () =>+ getWorkspaceRouteObjectsForSurface(routeObjects, workspaceSurface.type),+ [routeObjects, workspaceSurface.type],);const routedElement = useRoutes(surfaceRouteObjects, location);const isLocationAvailable =location === undefined ||- isWorkspaceLocationAvailableOnSurface(routeObjects, surface, location);+ isWorkspaceLocationAvailableOnSurface(+ routeObjects,+ workspaceSurface.type,+ location,+ );return (<RoutedFlowStateScopeContext.Providerdiff --git a/packages/twenty-front/src/modules/app/routing/types/WorkspaceRouteObject.ts b/packages/twenty-front/src/modules/app/routing/types/WorkspaceRouteObject.tsindex 644ae6a4a7c..c0f5e7fdcaa 100644--- a/packages/twenty-front/src/modules/app/routing/types/WorkspaceRouteObject.ts+++ b/packages/twenty-front/src/modules/app/routing/types/WorkspaceRouteObject.ts@@ -4,13 +4,9 @@ export type WorkspaceSurfaceType = 'main' | 'side-panel';export type WorkspaceRouteHandle = {workspaceSurfaces: readonly WorkspaceSurfaceType[];- isLocationAvailableOnSurface?: (args: {- surface: WorkspaceSurfaceType;- location: Partial<Location> | string;- }) => boolean;- isLocationExpandableFromSidePanel?: (args: {- location: Partial<Location> | string;- }) => boolean;+ isLocationExpandableFromSidePanel?:+ | boolean+ | ((args: { location: Partial<Location> | string }) => boolean);};export type WorkspaceRouteObject = Omit<diff --git a/packages/twenty-front/src/modules/app/routing/utils/__tests__/createWorkspaceRouteObjects.test.tsx b/packages/twenty-front/src/modules/app/routing/utils/__tests__/createWorkspaceRouteObjects.test.tsxindex 9d76bce3d79..cc060220829 100644--- a/packages/twenty-front/src/modules/app/routing/utils/__tests__/createWorkspaceRouteObjects.test.tsx+++ b/packages/twenty-front/src/modules/app/routing/utils/__tests__/createWorkspaceRouteObjects.test.tsx@@ -13,6 +13,18 @@ import { SettingsProtectedRouteWrapper } from '@/settings/components/SettingsProconst SETTINGS_ROOT_PATH = AppPath.SettingsCatchAll.replace('/*', '');describe('workspace route objects', () => {+ it('does not leak generated route IDs into the shared registry', () => {+ const collectRouteIds = (+ routes: ReturnType<typeof createWorkspaceRouteObjects>,+ ): string[] =>+ routes.flatMap((route) => [+ ...(route.id === undefined ? [] : [route.id]),+ ...collectRouteIds(route.children ?? []),+ ]);++ expect(collectRouteIds(createWorkspaceRouteObjects({}))).toEqual([]);+ });+it('can be embedded in a data router without route id collisions', () => {const router = createMemoryRouter([{ children: createWorkspaceRouteObjects({}) },diff --git a/packages/twenty-front/src/modules/app/routing/utils/createWorkspaceRouteObjects.tsx b/packages/twenty-front/src/modules/app/routing/utils/createWorkspaceRouteObjects.tsxindex 47d3cfdea60..1d847d721d1 100644--- a/packages/twenty-front/src/modules/app/routing/utils/createWorkspaceRouteObjects.tsx+++ b/packages/twenty-front/src/modules/app/routing/utils/createWorkspaceRouteObjects.tsx@@ -1,5 +1,5 @@import { lazy } from 'react';-import { type Location, Navigate, parsePath } from 'react-router-dom';+import { Navigate } from 'react-router-dom';import { AppPath, SettingsPath } from 'twenty-shared/types';import { getSettingsPath } from 'twenty-shared/utils';@@ -62,15 +62,6 @@ type CreateWorkspaceRouteObjectsArgs = {const MAIN_AND_SIDE_PANEL = ['main', 'side-panel'] as const;const SETTINGS_ROOT_PATH = AppPath.SettingsCatchAll.replace('/*', '');-const isSettingsRootLocation = (location: Partial<Location> | string) => {- const pathname =- typeof location === 'string'- ? parsePath(location).pathname- : location.pathname;-- return pathname?.replace(/\/$/, '') === SETTINGS_ROOT_PATH;-};-export const createWorkspaceRouteObjects = ({isAdminPageEnabled,isWorkflowCoreIndexPageEnabled,@@ -91,7 +82,7 @@ export const createWorkspaceRouteObjects = ({),handle: {workspaceSurfaces: MAIN_AND_SIDE_PANEL,- isLocationExpandableFromSidePanel: () => true,+ isLocationExpandableFromSidePanel: true,},} satisfies WorkspaceRouteObject,]@@ -109,7 +100,7 @@ export const createWorkspaceRouteObjects = ({),handle: {workspaceSurfaces: MAIN_AND_SIDE_PANEL,- isLocationExpandableFromSidePanel: () => true,+ isLocationExpandableFromSidePanel: true,},},{@@ -149,11 +140,6 @@ export const createWorkspaceRouteObjects = ({path: SETTINGS_ROOT_PATH,element: <SettingsRouteOutlet />,children: settingsRouteObjects,- handle: {- workspaceSurfaces: MAIN_AND_SIDE_PANEL,- isLocationAvailableOnSurface: ({ location }) =>- !isSettingsRootLocation(location),- },},{path: AppPath.Dpa,diff --git a/packages/twenty-front/src/modules/app/routing/utils/isWorkspaceLocationAvailableOnSurface.ts b/packages/twenty-front/src/modules/app/routing/utils/isWorkspaceLocationAvailableOnSurface.tsindex bc1db952944..9261cb5482d 100644--- a/packages/twenty-front/src/modules/app/routing/utils/isWorkspaceLocationAvailableOnSurface.ts+++ b/packages/twenty-front/src/modules/app/routing/utils/isWorkspaceLocationAvailableOnSurface.ts@@ -14,8 +14,7 @@ export const isWorkspaceLocationAvailableOnSurface = (return (canonicalMatch !== undefined &&- (routeHandle?.workspaceSurfaces.includes(surface) ?? surface === 'main') &&- (routeHandle?.isLocationAvailableOnSurface?.({ surface, location }) ?? true)+ (routeHandle?.workspaceSurfaces.includes(surface) ?? surface === 'main'));};@@ -23,16 +22,17 @@ export const isWorkspaceLocationExpandableFromSidePanel = (routeObjects: WorkspaceRouteObject[],location: Partial<Location> | string,) => {+ if (+ !isWorkspaceLocationAvailableOnSurface(routeObjects, 'side-panel', location)+ ) {+ return false;+ }+const canonicalMatch = matchRoutes(routeObjects, location)?.at(-1);- const routeHandle = canonicalMatch?.route.handle;+ const expandable =+ canonicalMatch?.route.handle?.isLocationExpandableFromSidePanel;- return (- !!routeHandle?.workspaceSurfaces.includes('side-panel') &&- (routeHandle.isLocationAvailableOnSurface?.({- surface: 'side-panel',- location,- }) ??- true) &&- (routeHandle.isLocationExpandableFromSidePanel?.({ location }) ?? false)- );+ return typeof expandable === 'function'+ ? expandable({ location })+ : (expandable ?? false);};diff --git a/packages/twenty-front/src/modules/auth/utils/__tests__/isValidReturnToPath.test.ts b/packages/twenty-front/src/modules/auth/utils/__tests__/isValidReturnToPath.test.tsindex 0b5a7679d71..e479949aff6 100644--- a/packages/twenty-front/src/modules/auth/utils/__tests__/isValidReturnToPath.test.ts+++ b/packages/twenty-front/src/modules/auth/utils/__tests__/isValidReturnToPath.test.ts@@ -23,6 +23,13 @@ describe('isValidReturnToPath', () => {expect(isValidReturnToPath('/objects\\..\\evil')).toBe(false);});+ it('should return false for paths containing control characters', () => {+ expect(isValidReturnToPath('/\n/evil.com')).toBe(false);+ expect(isValidReturnToPath('/\r/evil.com')).toBe(false);+ expect(isValidReturnToPath('/\t/evil.com')).toBe(false);+ expect(isValidReturnToPath('/objects/pe\u0000ople')).toBe(false);+ });+it('should return false for onboarding paths', () => {expect(isValidReturnToPath('/workspace-activation')).toBe(false);expect(isValidReturnToPath('/create/profile')).toBe(false);diff --git a/packages/twenty-front/src/modules/auth/utils/clearSessionLocalStorageKeys.ts b/packages/twenty-front/src/modules/auth/utils/clearSessionLocalStorageKeys.tsindex b5f1d8c75c4..5bcf4be0948 100644--- a/packages/twenty-front/src/modules/auth/utils/clearSessionLocalStorageKeys.ts+++ b/packages/twenty-front/src/modules/auth/utils/clearSessionLocalStorageKeys.ts@@ -1,6 +1,8 @@import { safeRemoveLocalStorageItems } from '@/auth/utils/safeRemoveLocalStorageItems';const SESSION_KEYS_TO_CLEAR = [+ // Clear values persisted before this now-unused state was removed.+ 'lastVisitedObjectMetadataItemIdState','lastVisitedViewPerObjectMetadataItemState','ai/agentChatDraftsByThreadIdState','companyEnrichmentState',diff --git a/packages/twenty-front/src/modules/auth/utils/isValidReturnToPath.ts b/packages/twenty-front/src/modules/auth/utils/isValidReturnToPath.tsindex e3fadb322b1..9f7f908e11a 100644--- a/packages/twenty-front/src/modules/auth/utils/isValidReturnToPath.ts+++ b/packages/twenty-front/src/modules/auth/utils/isValidReturnToPath.ts@@ -1,6 +1,6 @@import { ONBOARDING_PATHS } from '@/auth/constants/OnboardingPaths';import { ONGOING_USER_CREATION_PATHS } from '@/auth/constants/OngoingUserCreationPaths';-import { isNonEmptyString } from '@sniptt/guards';+import { isSafeInternalPath } from '@/ui/navigation/utils/isSafeInternalPath';import { AppPath } from 'twenty-shared/types';const extractPathPrefix = (appPath: string): string => appPath.split('/:')[0];@@ -12,11 +12,7 @@ const EXCLUDED_PATH_PREFIXES = [].map(extractPathPrefix);export const isValidReturnToPath = (path: string): boolean => {- if (!isNonEmptyString(path) || path === '/') {- return false;- }-- if (!path.startsWith('/') || path.startsWith('//') || path.includes('\\')) {+ if (!isSafeInternalPath(path) || path === '/') {return false;}diff --git a/packages/twenty-front/src/modules/front-components/hooks/__tests__/useFrontComponentExecutionContext.test.tsx b/packages/twenty-front/src/modules/front-components/hooks/__tests__/useFrontComponentExecutionContext.test.tsxindex 69353028987..bd3dfb7bd55 100644--- a/packages/twenty-front/src/modules/front-components/hooks/__tests__/useFrontComponentExecutionContext.test.tsx+++ b/packages/twenty-front/src/modules/front-components/hooks/__tests__/useFrontComponentExecutionContext.test.tsx@@ -472,10 +472,31 @@ describe('useFrontComponentExecutionContext', () => {await expect(result.current.frontComponentHostCommunicationApi.openSidePanelPage({to: AppPath.Home,- }),+ } as never),).rejects.toThrow('Unsupported side-panel route: /home');});+ it('lets the workspace route registry decide whether a settings route can render', async () => {+ const { result } = renderUseFrontComponentExecutionContext({+ frontComponentId: FRONT_COMPONENT_ID,+ });++ await act(async () => {+ await result.current.frontComponentHostCommunicationApi.openSidePanelPage(+ {+ to: AppPath.SettingsCatchAll,+ params: { '*': 'objects/companies/name' },+ },+ );+ });++ expect(mockOpenRoutedPageInSidePanel).toHaveBeenCalledWith({+ path: '/settings/objects/companies/name',+ pageTitle: undefined,+ resetNavigationStack: undefined,+ });+ });+it('rejects legacy ViewRecords because it has no canonical route params', async () => {const { result } = renderUseFrontComponentExecutionContext({frontComponentId: FRONT_COMPONENT_ID,diff --git a/packages/twenty-front/src/modules/front-components/hooks/useFrontComponentExecutionContext.ts b/packages/twenty-front/src/modules/front-components/hooks/useFrontComponentExecutionContext.tsindex 8d68da68d32..6230653b7b2 100644--- a/packages/twenty-front/src/modules/front-components/hooks/useFrontComponentExecutionContext.ts+++ b/packages/twenty-front/src/modules/front-components/hooks/useFrontComponentExecutionContext.ts@@ -222,6 +222,7 @@ export const useFrontComponentExecutionContext = ({const pathWithHash = isNonEmptyString(params.hash)? `${path}#${encodeURIComponent(params.hash)}`: path;+const pageId = openRoutedPageInSidePanel({path: pathWithHash,pageTitle: params.pageTitle,diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsxindex 54565f257fb..7b50b5c55f9 100644--- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx+++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexPageHeader.tsx@@ -6,6 +6,7 @@ import { useNumberFormat } from '@/localization/hooks/useNumberFormat';import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';import { RecordIndexPageHeaderIcon } from '@/object-record/record-index/components/RecordIndexPageHeaderIcon';import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext';+import { SidePanelPageTitleSyncEffect } from '@/side-panel/components/SidePanelPageTitleSyncEffect';import { SidePanelToggleButton } from '@/side-panel/components/SidePanelToggleButton';import { PageCardHeader } from '@/ui/layout/page/components/PageCardHeader';import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';@@ -72,20 +73,23 @@ export const RecordIndexPageHeader = () => {);return (- <PageCardHeader- icon={- <RecordIndexPageHeaderIcon objectMetadataItem={objectMetadataItem} />- }- title={pageHeaderTitle}- actionButton={- isDefined(contextStoreCurrentViewId) ? (- <>- <RecordIndexCommandMenu />- {!isLayoutCustomizationModeEnabled &&- workspaceSurface.type === 'main' && <SidePanelToggleButton />}- </>- ) : undefined- }- />+ <>+ <SidePanelPageTitleSyncEffect pageTitle={label} />+ <PageCardHeader+ icon={+ <RecordIndexPageHeaderIcon objectMetadataItem={objectMetadataItem} />+ }+ title={pageHeaderTitle}+ actionButton={+ isDefined(contextStoreCurrentViewId) ? (+ <>+ <RecordIndexCommandMenu />+ {!isLayoutCustomizationModeEnabled &&+ workspaceSurface.type === 'main' && <SidePanelToggleButton />}+ </>+ ) : undefined+ }+ />+ </>);};diff --git a/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useRecordIndexIdFromCurrentContextStore.test.tsx b/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useRecordIndexIdFromCurrentContextStore.test.tsxindex 9af7db10281..2fd6c42e44c 100644--- a/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useRecordIndexIdFromCurrentContextStore.test.tsx+++ b/packages/twenty-front/src/modules/object-record/record-index/hooks/__tests__/useRecordIndexIdFromCurrentContextStore.test.tsx@@ -57,8 +57,6 @@ describe('useRecordIndexIdFromCurrentContextStore', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><Wrapper>diff --git a/packages/twenty-front/src/modules/object-record/record-show/components/__stories__/PageLayoutRecordPageRendererEmailThread.stories.tsx b/packages/twenty-front/src/modules/object-record/record-show/components/__stories__/PageLayoutRecordPageRendererEmailThread.stories.tsxindex 65014c8c90a..ee89b557372 100644--- a/packages/twenty-front/src/modules/object-record/record-show/components/__stories__/PageLayoutRecordPageRendererEmailThread.stories.tsx+++ b/packages/twenty-front/src/modules/object-record/record-show/components/__stories__/PageLayoutRecordPageRendererEmailThread.stories.tsx@@ -174,8 +174,6 @@ const meta: Meta<EmailThreadStoryArgs> = {type: 'side-panel',instanceId: 'story-side-panel',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><CommandMenuComponentInstanceContext.Providerdiff --git a/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPagePagination.ts b/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPagePagination.tsindex 36b04df0779..76f6ba366eb 100644--- a/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPagePagination.ts+++ b/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPagePagination.ts@@ -234,7 +234,9 @@ export const useRecordShowPagePagination = ((navigationItem) =>navigationItem.page === SidePanelPages.RoutedPage &&navigationItem.routedLocation.pathname === indexLocation.pathname &&- navigationItem.routedLocation.search === (indexLocation.search ?? ''),+ (new URLSearchParams(navigationItem.routedLocation.search).get(+ 'viewId',+ ) ?? '') === (viewIdQueryParam ?? ''),);if (previousIndexPageIndex >= 0) {diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsxindex 721fff7dda6..cad4543a530 100644--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabList.test.tsx@@ -180,8 +180,6 @@ const renderTabList = ({type: isInSidePanel ? 'side-panel' : 'main',instanceId: isInSidePanel ? 'side-panel' : 'main',ownsRouteLocation: !isInSidePanel,- headerTitlePortal: null,- headerActionsPortal: null,}}><PageLayoutComponentInstanceContext.Providerdiff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsxindex acef43d9f0a..f3c953e8f4a 100644--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsx+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsx@@ -2,6 +2,7 @@ import { PageLayoutTabListEffect } from '@/page-layout/components/PageLayoutTabLimport { makeTab } from '@/page-layout/testing/pageLayoutDraftFixtures';import { LayoutRenderingProvider } from '@/ui/layout/contexts/LayoutRenderingContext';import { WorkspaceSurfaceContext } from '@/ui/layout/contexts/WorkspaceSurfaceContext';+import { getWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { TabListFromUrlOptionalEffect } from '@/ui/layout/tab-list/components/TabListFromUrlOptionalEffect';import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext';@@ -118,8 +119,13 @@ describe('PageLayoutTabListEffect', () => {expectedNavigationType,}) => {const store = createStore();+ const surfaceInstanceId = isInSidePanel ? 'side-panel-page-1' : 'main';const activeTabAtom = activeTabIdComponentState.atomFamily({- instanceId: TAB_LIST_INSTANCE_ID,+ instanceId: getWorkspaceSurfaceScopedComponentInstanceId({+ componentInstanceId: TAB_LIST_INSTANCE_ID,+ surfaceType: isInSidePanel ? 'side-panel' : 'main',+ surfaceInstanceId,+ }),});store.set(activeTabAtom, activeTabId);@@ -133,10 +139,8 @@ describe('PageLayoutTabListEffect', () => {<WorkspaceSurfaceContext.Providervalue={{type: isInSidePanel ? 'side-panel' : 'main',- instanceId: isInSidePanel ? 'side-panel-page-1' : 'main',+ instanceId: surfaceInstanceId,ownsRouteLocation,- headerTitlePortal: null,- headerActionsPortal: null,}}><LayoutRenderingProviderdiff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsxindex ae5969ffd3c..ac2e55796cf 100644--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx@@ -155,8 +155,6 @@ const TestWrapper = ({ children }: { children: ReactNode }) => (type: mockIsInSidePanel ? 'side-panel' : 'main',instanceId: mockIsInSidePanel ? 'side-panel' : 'main',ownsRouteLocation: !mockIsInSidePanel,- headerTitlePortal: null,- headerActionsPortal: null,}}>{children}diff --git a/packages/twenty-front/src/modules/page-layout/widgets/components/__stories__/WidgetRenderer.stories.tsx b/packages/twenty-front/src/modules/page-layout/widgets/components/__stories__/WidgetRenderer.stories.tsxindex 9635f2c53cf..5e3b23555c9 100644--- a/packages/twenty-front/src/modules/page-layout/widgets/components/__stories__/WidgetRenderer.stories.tsx+++ b/packages/twenty-front/src/modules/page-layout/widgets/components/__stories__/WidgetRenderer.stories.tsx@@ -34,6 +34,7 @@ import { WidgetComponentInstanceContext } from '@/page-layout/widgets/states/conimport { widgetCardHoveredComponentFamilyState } from '@/page-layout/widgets/states/widgetCardHoveredComponentFamilyState';import { LayoutRenderingProvider } from '@/ui/layout/contexts/LayoutRenderingContext';import { WorkspaceSurfaceContext } from '@/ui/layout/contexts/WorkspaceSurfaceContext';+import { getWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import {AggregateOperations,AxisNameDisplay,@@ -85,6 +86,13 @@ const WIDGET_ID_MANY_TO_ONE_RELATION = 'widget-relation-field';const WIDGET_ID_ONE_TO_MANY_RELATION = 'widget-one-to-many-relation-field';const WIDGET_ID_CATALOG = 'catalog-widget';const TAB_ID_OVERVIEW = 'tab-overview';+const SIDE_PANEL_INSTANCE_ID = 'widget-side-panel';+const SIDE_PANEL_PAGE_LAYOUT_INSTANCE_ID =+ getWorkspaceSurfaceScopedComponentInstanceId({+ componentInstanceId: PAGE_LAYOUT_TEST_INSTANCE_ID,+ surfaceType: 'side-panel',+ surfaceInstanceId: SIDE_PANEL_INSTANCE_ID,+ });const mockPersonRecord: ObjectRecord = {__typename: 'Person',@@ -1478,37 +1486,35 @@ export const InSidePanel: Story = {getTestEnrichedObjectMetadataItemsMock(),);jotaiStore.set(isMinimalMetadataReadyState.atom, true);- const pageLayoutData = createPageLayoutWithWidget(+ const sidePanelPageLayoutData = createPageLayoutWithWidget(widget,PageLayoutType.RECORD_PAGE,);jotaiStore.set(pageLayoutPersistedComponentState.atomFamily({- instanceId: PAGE_LAYOUT_TEST_INSTANCE_ID,+ instanceId: SIDE_PANEL_PAGE_LAYOUT_INSTANCE_ID,}),- pageLayoutData,+ sidePanelPageLayoutData,);jotaiStore.set(pageLayoutDraftComponentState.atomFamily({- instanceId: PAGE_LAYOUT_TEST_INSTANCE_ID,+ instanceId: SIDE_PANEL_PAGE_LAYOUT_INSTANCE_ID,}),- pageLayoutData,+ sidePanelPageLayoutData,);return (<div style={{ width: '400px', padding: '20px' }}><JestMetadataAndApolloMocksWrapper><CoreClientProviderWrapper>- <PageLayoutTestWrapper store={jotaiStore}>- <WorkspaceSurfaceContext.Provider- value={{- type: 'side-panel',- instanceId: 'widget-side-panel',- ownsRouteLocation: false,- headerTitlePortal: null,- headerActionsPortal: null,- }}- >+ <WorkspaceSurfaceContext.Provider+ value={{+ type: 'side-panel',+ instanceId: SIDE_PANEL_INSTANCE_ID,+ ownsRouteLocation: false,+ }}+ >+ <PageLayoutTestWrapper store={jotaiStore}><LayoutRenderingProvidervalue={{layoutType: PageLayoutType.RECORD_PAGE,@@ -1528,15 +1534,15 @@ export const InSidePanel: Story = {><WidgetComponentInstanceContext.Providervalue={{- instanceId: 'widget-side-panel',+ instanceId: SIDE_PANEL_INSTANCE_ID,}}><WidgetRenderer widget={widget} /></WidgetComponentInstanceContext.Provider></PageLayoutContentProvider></LayoutRenderingProvider>- </WorkspaceSurfaceContext.Provider>- </PageLayoutTestWrapper>+ </PageLayoutTestWrapper>+ </WorkspaceSurfaceContext.Provider></CoreClientProviderWrapper></JestMetadataAndApolloMocksWrapper></div>diff --git a/packages/twenty-front/src/modules/settings/components/__tests__/SettingsProtectedRouteWrapper.test.tsx b/packages/twenty-front/src/modules/settings/components/__tests__/SettingsProtectedRouteWrapper.test.tsxindex fba6fa0adba..d72e67446fa 100644--- a/packages/twenty-front/src/modules/settings/components/__tests__/SettingsProtectedRouteWrapper.test.tsx+++ b/packages/twenty-front/src/modules/settings/components/__tests__/SettingsProtectedRouteWrapper.test.tsx@@ -43,8 +43,6 @@ const renderProtectedRoute = (surface: 'main' | 'side-panel') =>type: surface,instanceId: surface === 'main' ? 'main' : 'panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><I18nProvider i18n={i18n}>diff --git a/packages/twenty-front/src/modules/settings/components/__tests__/SettingsRoutedFlowStateScope.test.tsx b/packages/twenty-front/src/modules/settings/components/__tests__/SettingsRoutedFlowStateScope.test.tsxindex dbd1d1d393e..7ce07bf45c6 100644--- a/packages/twenty-front/src/modules/settings/components/__tests__/SettingsRoutedFlowStateScope.test.tsx+++ b/packages/twenty-front/src/modules/settings/components/__tests__/SettingsRoutedFlowStateScope.test.tsx@@ -41,8 +41,6 @@ const ScopedStateProbe = ({}: {name: 'main' | 'panel' | 'panel-second';}) => {- const modalId = useWorkspaceSurfaceScopedComponentInstanceId(MODAL_ID);- const dropdownId = useWorkspaceSurfaceScopedComponentInstanceId(DROPDOWN_ID);const tableId = useWorkspaceSurfaceScopedComponentInstanceId('role-table');const settingsDraftRole = useAtomFamilyStateValue(settingsDraftRoleFamilyState,@@ -62,12 +60,12 @@ const ScopedStateProbe = ({);const isModalOpened = useAtomComponentStateValue(isModalOpenedComponentState,- modalId,+ MODAL_ID,);const { openModal, toggleModal } = useModal();const isDropdownOpen = useAtomComponentStateValue(isDropdownOpenComponentState,- dropdownId,+ DROPDOWN_ID,);const { openDropdown } = useOpenDropdown();const sortedFieldByTable = useAtomFamilyStateValue(@@ -163,8 +161,6 @@ describe('settings routed-flow state scope', () => {type: 'main',instanceId: 'main',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RoutedFlowStateScopeContext.Provider value={null}>@@ -177,8 +173,6 @@ describe('settings routed-flow state scope', () => {instanceId: 'panel-page-1',routedFlowStateScopeId: 'panel-flow-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RoutedFlowStateScopeContext.Provider value="panel-flow-1">@@ -191,8 +185,6 @@ describe('settings routed-flow state scope', () => {instanceId: 'panel-page-2',routedFlowStateScopeId: 'panel-flow-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RoutedFlowStateScopeContext.Provider value="panel-flow-1">@@ -261,8 +253,6 @@ describe('settings routed-flow state scope', () => {instanceId: 'panel-page-42',routedFlowStateScopeId: 'panel-flow-7',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><MemoryRouter initialEntries={['/settings/roles']}>@@ -275,7 +265,7 @@ describe('settings routed-flow state scope', () => {},]}>- <WorkspaceRoutes surface="side-panel" />+ <WorkspaceRoutes /></WorkspaceRouteObjectsContext.Provider></MemoryRouter></WorkspaceSurfaceContext.Provider>diff --git a/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx b/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsxindex f5564b9926f..cf93ab21de3 100644--- a/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx+++ b/packages/twenty-front/src/modules/settings/components/layout/SettingsPageLayout.tsx@@ -1,5 +1,6 @@import { SettingsEditableTitle } from '@/settings/components/SettingsEditableTitle';import { SettingsSecondaryBar } from '@/settings/components/layout/SettingsSecondaryBar';+import { SidePanelPageTitleSyncEffect } from '@/side-panel/components/SidePanelPageTitleSyncEffect';import { PageCardHeader } from '@/ui/layout/page/components/PageCardHeader';import { PageCardLayout } from '@/ui/layout/page/components/PageCardLayout';import { type BreadcrumbProps } from '@/ui/navigation/bread-crumb/components/Breadcrumb';@@ -9,6 +10,7 @@ import { isDefined } from 'twenty-shared/utils';type SettingsPageLayoutProps = {links: BreadcrumbProps['links'];title?: ReactNode;+ pageTitle?: string;icon?: ReactNode;actionButton?: ReactNode;secondaryBar?: ReactNode;@@ -20,6 +22,7 @@ type SettingsPageLayoutProps = {export const SettingsPageLayout = ({links,title,+ pageTitle,icon,actionButton,secondaryBar,@@ -29,6 +32,13 @@ export const SettingsPageLayout = ({}: SettingsPageLayoutProps) => {const titleInstanceId = useId();+ const sidePanelPageTitle =+ pageTitle ??+ (typeof title === 'string'+ ? title+ : links.findLast(({ children }) => typeof children === 'string')+ ?.children);+const formattedTitle =typeof title === 'string' ? (<SettingsEditableTitle@@ -42,25 +52,34 @@ export const SettingsPageLayout = ({);return (- <PageCardLayout- header={- <PageCardHeader- links={links}- title={formattedTitle}- icon={icon}- tag={tag}- actionButton={actionButton}- centerTitle- titleColor={titleColor}- />- }- secondaryBar={- isDefined(secondaryBar) ? (- <SettingsSecondaryBar>{secondaryBar}</SettingsSecondaryBar>- ) : undefined- }- >- {children}- </PageCardLayout>+ <>+ <SidePanelPageTitleSyncEffect+ pageTitle={+ typeof sidePanelPageTitle === 'string'+ ? sidePanelPageTitle+ : undefined+ }+ />+ <PageCardLayout+ header={+ <PageCardHeader+ links={links}+ title={formattedTitle}+ icon={icon}+ tag={tag}+ actionButton={actionButton}+ centerTitle+ titleColor={titleColor}+ />+ }+ secondaryBar={+ isDefined(secondaryBar) ? (+ <SettingsSecondaryBar>{secondaryBar}</SettingsSecondaryBar>+ ) : undefined+ }+ >+ {children}+ </PageCardLayout>+ </>);};diff --git a/packages/twenty-front/src/modules/settings/components/layout/useSettingsActiveTabId.ts b/packages/twenty-front/src/modules/settings/components/layout/useSettingsActiveTabId.tsindex af0943148ad..9649ec71ef4 100644--- a/packages/twenty-front/src/modules/settings/components/layout/useSettingsActiveTabId.ts+++ b/packages/twenty-front/src/modules/settings/components/layout/useSettingsActiveTabId.ts@@ -1,5 +1,4 @@import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';-import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { useLocation } from 'react-router-dom';import { isDefined } from 'twenty-shared/utils';@@ -11,11 +10,9 @@ export const useSettingsActiveTabId = (componentInstanceId: string,tabIds: string[],): string | null => {- const scopedComponentInstanceId =- useWorkspaceSurfaceScopedComponentInstanceId(componentInstanceId);const activeTabId = useAtomComponentStateValue(activeTabIdComponentState,- scopedComponentInstanceId,+ componentInstanceId,);const { hash } = useLocation();diff --git a/packages/twenty-front/src/modules/settings/roles/components/__tests__/SettingsRoleRouteGuard.test.tsx b/packages/twenty-front/src/modules/settings/roles/components/__tests__/SettingsRoleRouteGuard.test.tsxindex 0f8e28158e8..7c1a5c52a4c 100644--- a/packages/twenty-front/src/modules/settings/roles/components/__tests__/SettingsRoleRouteGuard.test.tsx+++ b/packages/twenty-front/src/modules/settings/roles/components/__tests__/SettingsRoleRouteGuard.test.tsx@@ -36,8 +36,6 @@ const renderGuard = ({type: surface,instanceId: `${surface}-surface`,ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><SettingsRoleRouteGuard roleId="role-1">diff --git a/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRole.tsx b/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRole.tsxindex 1d707ef6bb3..23d4580110e 100644--- a/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRole.tsx+++ b/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRole.tsx@@ -141,6 +141,7 @@ export const SettingsRole = ({ roleId, isCreateMode }: SettingsRoleProps) => {return (<SettingsPageLayouttitle={<SettingsRoleLabelContainer roleId={roleId} />}+ pageTitle={settingsDraftRole.label}secondaryBar={<SettingsTabBartabs={tabs}diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelDefaultSelectionEffect.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelDefaultSelectionEffect.tsxindex ad4ffaaa468..eb111882a7c 100644--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelDefaultSelectionEffect.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelDefaultSelectionEffect.tsx@@ -2,7 +2,6 @@ import { SIDE_PANEL_SELECTABLE_LIST_ID } from '@/side-panel/constants/SidePanelSimport { hasUserSelectedSidePanelListItemState } from '@/side-panel/states/hasUserSelectedSidePanelListItemState';import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';-import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';import { useEffect } from 'react';@@ -16,13 +15,9 @@ export const SidePanelDefaultSelectionEffect = ({const { setSelectedItemId } = useSelectableList(SIDE_PANEL_SELECTABLE_LIST_ID,);- const scopedSelectableListId = useWorkspaceSurfaceScopedComponentInstanceId(- SIDE_PANEL_SELECTABLE_LIST_ID,- );-const selectedItemId = useAtomComponentStateValue(selectedItemIdComponentState,- scopedSelectableListId,+ SIDE_PANEL_SELECTABLE_LIST_ID,);const hasUserSelectedSidePanelListItem = useAtomStateValue(diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelPageTitleSyncEffect.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelPageTitleSyncEffect.tsxnew file mode 100644index 00000000000..cd1ab0f9e5a--- /dev/null+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelPageTitleSyncEffect.tsx@@ -0,0 +1,21 @@+import { useUpdateSidePanelPageInfo } from '@/side-panel/hooks/useUpdateSidePanelPageInfo';+import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';+import { useEffect } from 'react';+import { isDefined } from 'twenty-shared/utils';++export const SidePanelPageTitleSyncEffect = ({+ pageTitle,+}: {+ pageTitle?: string;+}) => {+ const workspaceSurface = useWorkspaceSurface();+ const { updateSidePanelPageInfo } = useUpdateSidePanelPageInfo();++ useEffect(() => {+ if (workspaceSurface.type === 'side-panel' && isDefined(pageTitle)) {+ updateSidePanelPageInfo({ pageTitle });+ }+ }, [pageTitle, updateSidePanelPageInfo, workspaceSurface.type]);++ return null;+};diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelRouter.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelRouter.tsxindex dec0175bafb..e068fe85d88 100644--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelRouter.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelRouter.tsx@@ -11,6 +11,7 @@ import { isPageLayoutSidePanelPage } from '@/side-panel/pages/page-layout/utils/import { SidePanelPageComponentInstanceContext } from '@/side-panel/states/contexts/SidePanelPageComponentInstanceContext';import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';import { WorkspaceSurfaceContext } from '@/ui/layout/contexts/WorkspaceSurfaceContext';+import { WorkspaceSurfaceHeaderPortalContext } from '@/ui/layout/contexts/WorkspaceSurfaceHeaderPortalContext';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';import { styled } from '@linaria/react';@@ -84,48 +85,51 @@ export const SidePanelRouter = () => {sidePanelPageInstanceId): undefined,ownsRouteLocation: false,- headerTitlePortal,- headerActionsPortal,}),[currentNavigationItem?.routedFlowStateScopeId,- headerActionsPortal,- headerTitlePortal,sidePanelPage,sidePanelPageInstanceId,],);+ const headerPortal = useMemo(+ () => ({ title: headerTitlePortal, actions: headerActionsPortal }),+ [headerActionsPortal, headerTitlePortal],+ );+return (<SidePanelContainer><SidePanelPageComponentInstanceContext.Providervalue={{ instanceId: sidePanelPageInstanceId }}><WorkspaceSurfaceContext.Provider value={workspaceSurface}>- <motion.div- initial={{ opacity: 0 }}- animate={{ opacity: 1 }}- exit={{ opacity: 0 }}- transition={{- duration: theme.animation.duration.instant,- delay: 0.1,- }}- >- <SidePanelTopBar- setHeaderTitlePortal={setHeaderTitlePortal}- setHeaderActionsPortal={setHeaderActionsPortal}- />- </motion.div>- <StyledSidePanelContent>- <CommandMenuContextProvider- displayType="listItem"- containerType={CommandMenuItemContainerType.CommandMenuList}+ <WorkspaceSurfaceHeaderPortalContext.Provider value={headerPortal}>+ <motion.div+ initial={{ opacity: 0 }}+ animate={{ opacity: 1 }}+ exit={{ opacity: 0 }}+ transition={{+ duration: theme.animation.duration.instant,+ delay: 0.1,+ }}>- <SidePanelSubPageRouter>- {sidePanelPageComponent}- </SidePanelSubPageRouter>- </CommandMenuContextProvider>- </StyledSidePanelContent>+ <SidePanelTopBar+ setHeaderTitlePortal={setHeaderTitlePortal}+ setHeaderActionsPortal={setHeaderActionsPortal}+ />+ </motion.div>+ <StyledSidePanelContent>+ <CommandMenuContextProvider+ displayType="listItem"+ containerType={CommandMenuItemContainerType.CommandMenuList}+ >+ <SidePanelSubPageRouter>+ {sidePanelPageComponent}+ </SidePanelSubPageRouter>+ </CommandMenuContextProvider>+ </StyledSidePanelContent>+ </WorkspaceSurfaceHeaderPortalContext.Provider></WorkspaceSurfaceContext.Provider></SidePanelPageComponentInstanceContext.Provider></SidePanelContainer>diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelTopBar.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelTopBar.tsxindex 95ebabb2a73..e7754ba445f 100644--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelTopBar.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelTopBar.tsx@@ -83,18 +83,21 @@ const StyledHeaderTitleContainer = styled.div`display: flex;flex: 1;min-width: 0;-- &:has([data-workspace-header-title-portal]:not(:empty))- > [data-routed-page-fallback-info] {- display: none;- }`;const StyledHeaderTitlePortal = styled.div`align-items: center;- display: flex;- flex: 1;+ display: none;min-width: 0;++ &:not(:empty) {+ display: flex;+ flex: 1;+ }++ &:not(:empty) + [data-side-panel-page-info] {+ display: none;+ }`;const StyledHeaderActionsPortal = styled.div`@@ -230,15 +233,12 @@ export const SidePanelTopBar = ({</AnimatePresence>{!COMMAND_MENU_SIDE_PANEL_PAGES.includes(sidePanelPage) && (<StyledHeaderTitleContainer>+ <StyledHeaderTitlePortal ref={setHeaderTitlePortal} />{lastChip && (- <div data-routed-page-fallback-info="">+ <div data-side-panel-page-info=""><SidePanelPageInfo pageChip={lastChip} /></div>)}- <StyledHeaderTitlePortal- ref={setHeaderTitlePortal}- data-workspace-header-title-portal=""- /></StyledHeaderTitleContainer>)}{COMMAND_MENU_SIDE_PANEL_PAGES.includes(sidePanelPage) && (diff --git a/packages/twenty-front/src/modules/side-panel/components/__tests__/PurposeBuiltSidePanelPageState.test.tsx b/packages/twenty-front/src/modules/side-panel/components/__tests__/PurposeBuiltSidePanelPageState.test.tsxnew file mode 100644index 00000000000..b7b9aadc470--- /dev/null+++ b/packages/twenty-front/src/modules/side-panel/components/__tests__/PurposeBuiltSidePanelPageState.test.tsx@@ -0,0 +1,68 @@+import { composeEmailConnectedAccountIdComponentState } from '@/side-panel/pages/compose-email/states/composeEmailConnectedAccountIdComponentState';+import { createRelatedRecordTargetComponentState } from '@/side-panel/pages/create-related-record/states/createRelatedRecordTargetComponentState';+import { SidePanelPageComponentInstanceContext } from '@/side-panel/states/contexts/SidePanelPageComponentInstanceContext';+import { WorkspaceSurfaceContext } from '@/ui/layout/contexts/WorkspaceSurfaceContext';+import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';+import { renderHook } from '@testing-library/react';+import { createStore, Provider } from 'jotai';+import { type PropsWithChildren } from 'react';++const PAGE_ID = 'purpose-built-page-id';++describe('purpose-built side-panel page state', () => {+ it('reads state seeded with the side-panel page instance ID', () => {+ const store = createStore();+ const targetRecord = {+ id: 'record-id',+ targetObjectNameSingular: 'company',+ };++ store.set(+ composeEmailConnectedAccountIdComponentState.atomFamily({+ instanceId: PAGE_ID,+ }),+ 'connected-account-id',+ );+ store.set(+ createRelatedRecordTargetComponentState.atomFamily({+ instanceId: PAGE_ID,+ }),+ targetRecord,+ );++ const wrapper = ({ children }: PropsWithChildren) => (+ <Provider store={store}>+ <SidePanelPageComponentInstanceContext.Provider+ value={{ instanceId: PAGE_ID }}+ >+ <WorkspaceSurfaceContext.Provider+ value={{+ type: 'side-panel',+ instanceId: PAGE_ID,+ ownsRouteLocation: false,+ }}+ >+ {children}+ </WorkspaceSurfaceContext.Provider>+ </SidePanelPageComponentInstanceContext.Provider>+ </Provider>+ );++ const { result } = renderHook(+ () => ({+ connectedAccountId: useAtomComponentStateValue(+ composeEmailConnectedAccountIdComponentState,+ ),+ targetRecord: useAtomComponentStateValue(+ createRelatedRecordTargetComponentState,+ ),+ }),+ { wrapper },+ );++ expect(result.current).toEqual({+ connectedAccountId: 'connected-account-id',+ targetRecord,+ });+ });+});diff --git a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelTopBar.test.tsx b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelTopBar.test.tsxindex 9e0f3106771..9f7754f7174 100644--- a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelTopBar.test.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelTopBar.test.tsx@@ -6,6 +6,7 @@ import { createStore, Provider as JotaiProvider } from 'jotai';import { SIDE_PANEL_FOCUS_ID } from '@/side-panel/constants/SidePanelFocusId';import { SIDE_PANEL_SELECTABLE_LIST_ID } from '@/side-panel/constants/SidePanelSelectableListId';import { SidePanelList } from '@/side-panel/components/SidePanelList';+import { type SidePanelContextChipProps } from '@/side-panel/components/SidePanelContextChip';import { SidePanelTopBar } from '@/side-panel/components/SidePanelTopBar';import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState';import {@@ -35,8 +36,10 @@ jest.mock('@/side-panel/components/SidePanelExpandButton', () => ({const mockCloseSidePanelMenu = jest.fn();+let mockContextChips: SidePanelContextChipProps[] = [];+jest.mock('@/side-panel/hooks/useSidePanelContextChips', () => ({- useSidePanelContextChips: () => ({ contextChips: [] }),+ useSidePanelContextChips: () => ({ contextChips: mockContextChips }),}));jest.mock('@/side-panel/hooks/useSidePanelMenu', () => ({@@ -108,6 +111,7 @@ describe('SidePanelTopBar', () => {beforeEach(() => {mockCloseSidePanelMenu.mockClear();mockIsMobile = false;+ mockContextChips = [];});it('keeps the command menu search input focused while arrowing through items', async () => {@@ -332,6 +336,37 @@ describe('SidePanelTopBar', () => {).toBe(true);});+ it('shows routed page info when the header title portal is empty', () => {+ const store = createSidePanelTopBarStore({+ sidePanelNavigationStack: [+ {+ page: SidePanelPages.RoutedPage,+ pageTitle: 'Companies',+ pageIcon: IconDotsVertical,+ pageId: 'companies',+ routedLocation: {+ pathname: '/objects/companies',+ search: '',+ hash: '',+ state: null,+ key: 'companies',+ },+ },+ ],+ });+ mockContextChips = [{ Icons: [], text: 'Companies' }];++ render(+ <I18nProvider i18n={i18n}>+ <JotaiProvider store={store}>+ <SidePanelTopBar />+ </JotaiProvider>+ </I18nProvider>,+ );++ expect(screen.getByText('Companies')).toBeInTheDocument();+ });+it('shows the close button on mobile when there is no back button to dismiss the panel', () => {mockIsMobile = true;diff --git a/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenCalendarEventInSidePanel.test.tsx b/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenCalendarEventInSidePanel.test.tsxindex 7f386b63c7a..350a10d752a 100644--- a/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenCalendarEventInSidePanel.test.tsx+++ b/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenCalendarEventInSidePanel.test.tsx@@ -25,8 +25,8 @@ jest.mock('@/side-panel/hooks/useNavigateSidePanel', () => ({}),}));-jest.mock('@/side-panel/routing/utils/isSidePanelRoutedLocation', () => ({- isSidePanelRoutedLocation: () => true,+jest.mock('@/app/routing/utils/isWorkspaceLocationAvailableOnSurface', () => ({+ isWorkspaceLocationAvailableOnSurface: () => true,}));const mockOpenNewRecordTitleCell = jest.fn();diff --git a/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenRecordInSidePanel.test.tsx b/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenRecordInSidePanel.test.tsxindex 607611971c8..2648931eb31 100644--- a/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenRecordInSidePanel.test.tsx+++ b/packages/twenty-front/src/modules/side-panel/hooks/__tests__/useOpenRecordInSidePanel.test.tsx@@ -34,8 +34,8 @@ jest.mock('@/side-panel/hooks/useNavigateSidePanel', () => ({}),}));-jest.mock('@/side-panel/routing/utils/isSidePanelRoutedLocation', () => ({- isSidePanelRoutedLocation: () => true,+jest.mock('@/app/routing/utils/isWorkspaceLocationAvailableOnSurface', () => ({+ isWorkspaceLocationAvailableOnSurface: () => true,}));const mockOpenNewRecordTitleCell = jest.fn();diff --git a/packages/twenty-front/src/modules/side-panel/pages/record-page/hooks/__tests__/useNavigateToRecordPageFromSidePanel.test.tsx b/packages/twenty-front/src/modules/side-panel/pages/record-page/hooks/__tests__/useNavigateToRecordPageFromSidePanel.test.tsxindex a6cf0b5dec4..df29adfffc9 100644--- a/packages/twenty-front/src/modules/side-panel/pages/record-page/hooks/__tests__/useNavigateToRecordPageFromSidePanel.test.tsx+++ b/packages/twenty-front/src/modules/side-panel/pages/record-page/hooks/__tests__/useNavigateToRecordPageFromSidePanel.test.tsx@@ -101,8 +101,6 @@ const renderNavigateToRecordPage = ({type: 'side-panel',instanceId: PAGE_INSTANCE_ID,ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}>{children}diff --git a/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelPathUrlSyncEffect.tsx b/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelPathUrlSyncEffect.tsxindex 286deeb6882..60ab17c45f9 100644--- a/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelPathUrlSyncEffect.tsx+++ b/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelPathUrlSyncEffect.tsx@@ -7,7 +7,8 @@ import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';import { SIDE_PANEL_PATH_SEARCH_PARAM } from '@/side-panel/routing/constants/SidePanelPathSearchParam';import { useCurrentSidePanelRoutedPath } from '@/side-panel/routing/hooks/useCurrentSidePanelRoutedPath';import { useOpenRoutedPageInSidePanel } from '@/side-panel/routing/hooks/useOpenRoutedPageInSidePanel';-import { isSidePanelRoutedLocation } from '@/side-panel/routing/utils/isSidePanelRoutedLocation';+import { isWorkspaceLocationAvailableOnSurface } from '@/app/routing/utils/isWorkspaceLocationAvailableOnSurface';+import { isSafeInternalPath } from '@/ui/navigation/utils/isSafeInternalPath';export const SidePanelPathUrlSyncEffect = () => {const location = useLocation();@@ -68,9 +69,12 @@ export const SidePanelPathUrlSyncEffect = () => {if (pathInUrlChanged) {const isValidPathInUrl =isDefined(pathInUrl) &&- pathInUrl.startsWith('/') &&- !pathInUrl.startsWith('//') &&- isSidePanelRoutedLocation(routeObjects, pathInUrl);+ isSafeInternalPath(pathInUrl) &&+ isWorkspaceLocationAvailableOnSurface(+ routeObjects,+ 'side-panel',+ pathInUrl,+ );if (isValidPathInUrl) {if (pathInUrl !== currentRoutedPath) {diff --git a/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRouteNavigatorProvider.tsx b/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRouteNavigatorProvider.tsxindex 1cfab58ca09..2b5f28e7f88 100644--- a/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRouteNavigatorProvider.tsx+++ b/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRouteNavigatorProvider.tsx@@ -3,8 +3,7 @@ import { useSidePanelHistory } from '@/side-panel/hooks/useSidePanelHistory';import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';import { useOpenSettingsMenu } from '@/navigation/hooks/useOpenSettings';import { useOpenRoutedPageInSidePanel } from '@/side-panel/routing/hooks/useOpenRoutedPageInSidePanel';-import { isSidePanelRoutedLocation } from '@/side-panel/routing/utils/isSidePanelRoutedLocation';-import { toSidePanelLocation } from '@/side-panel/routing/utils/toSidePanelLocation';+import { isWorkspaceLocationAvailableOnSurface } from '@/app/routing/utils/isWorkspaceLocationAvailableOnSurface';import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';import { useStore } from 'jotai';import { type ReactNode, useContext, useMemo } from 'react';@@ -43,11 +42,10 @@ export const SidePanelRouteNavigatorProvider = ({) => {const shouldNavigateMain = options?.surface === 'main';const path = getPathFromTo(to);- const location = toSidePanelLocation(path, state);if (!shouldNavigateMain &&- isSidePanelRoutedLocation(routeObjects, location)+ isWorkspaceLocationAvailableOnSurface(routeObjects, 'side-panel', path)) {const currentNavigationItem = store.get(sidePanelNavigationStackState.atom)@@ -65,17 +63,14 @@ export const SidePanelRouteNavigatorProvider = ({}void closeSidePanelMenu();- if (location.pathname.startsWith('/settings')) {+ if (path.startsWith('/settings')) {openSettingsMenu();}parentNavigator[method](to, state, options);};return {- createHref: (to) => parentNavigator.createHref(to),- encodeLocation: parentNavigator.encodeLocation- ? (to) => parentNavigator.encodeLocation!(to)- : undefined,+ ...parentNavigator,push: (to, state, options) => navigate('push', to, state, options),replace: (to, state, options) => navigate('replace', to, state, options),go: (delta) => {diff --git a/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRoutedPage.tsx b/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRoutedPage.tsxindex 68799587ad8..8865ec0b45a 100644--- a/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRoutedPage.tsx+++ b/packages/twenty-front/src/modules/side-panel/routing/components/SidePanelRoutedPage.tsx@@ -1,11 +1,11 @@-import { Suspense, useMemo } from 'react';+import { useMemo } from 'react';import { isDefined } from 'twenty-shared/utils';+import { Trans } from '@lingui/react/macro';import { WorkspaceRoutes } from '@/app/routing/components/WorkspaceRoutes';import { WorkspaceRouteUnavailable } from '@/app/routing/components/WorkspaceRouteUnavailable';import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';import { AppErrorBoundary } from '@/error-handler/components/AppErrorBoundary';-import { SettingsSkeletonLoader } from '@/settings/components/SettingsSkeletonLoader';import { SidePanelRouteNavigatorProvider } from '@/side-panel/routing/components/SidePanelRouteNavigatorProvider';import { useCurrentSidePanelRoutedLocation } from '@/side-panel/routing/hooks/useCurrentSidePanelRoutedPath';import { SidePanelPageComponentInstanceContext } from '@/side-panel/states/contexts/SidePanelPageComponentInstanceContext';@@ -13,7 +13,11 @@ import { WorkspaceSurfaceContext } from '@/ui/layout/contexts/WorkspaceSurfaceCoimport { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';import { useComponentInstanceStateContext } from '@/ui/utilities/state/component-state/hooks/useComponentInstanceStateContext';-const SidePanelRouteErrorFallback = () => <WorkspaceRouteUnavailable />;+const SidePanelRouteErrorFallback = () => (+ <WorkspaceRouteUnavailable>+ <Trans>Something went wrong while loading this page.</Trans>+ </WorkspaceRouteUnavailable>+);export const SidePanelRoutedPage = () => {const location = useCurrentSidePanelRoutedLocation();@@ -44,13 +48,10 @@ export const SidePanelRoutedPage = () => {resetOnLocationChange={false}><SidePanelRouteNavigatorProvider>- <Suspense fallback={<SettingsSkeletonLoader />}>- <WorkspaceRoutes- surface="side-panel"- location={location}- fallback={<WorkspaceRouteUnavailable />}- />- </Suspense>+ <WorkspaceRoutes+ location={location}+ fallback={<WorkspaceRouteUnavailable />}+ /></SidePanelRouteNavigatorProvider></AppErrorBoundary></ContextStoreComponentInstanceContext.Provider>diff --git a/packages/twenty-front/src/modules/side-panel/routing/components/__tests__/SidePanelRouteNavigatorProvider.test.tsx b/packages/twenty-front/src/modules/side-panel/routing/components/__tests__/SidePanelRouteNavigatorProvider.test.tsxindex 4062a268726..5b129189aac 100644--- a/packages/twenty-front/src/modules/side-panel/routing/components/__tests__/SidePanelRouteNavigatorProvider.test.tsx+++ b/packages/twenty-front/src/modules/side-panel/routing/components/__tests__/SidePanelRouteNavigatorProvider.test.tsx@@ -171,8 +171,6 @@ const renderNavigationProbe = () => {type: 'side-panel',instanceId: 'panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><SidePanelRouteNavigatorProvider>diff --git a/packages/twenty-front/src/modules/side-panel/routing/hooks/useOpenRoutedPageInSidePanel.ts b/packages/twenty-front/src/modules/side-panel/routing/hooks/useOpenRoutedPageInSidePanel.tsindex bdcc5d5709a..121ee3378be 100644--- a/packages/twenty-front/src/modules/side-panel/routing/hooks/useOpenRoutedPageInSidePanel.ts+++ b/packages/twenty-front/src/modules/side-panel/routing/hooks/useOpenRoutedPageInSidePanel.ts@@ -7,10 +7,11 @@ import { v4 } from 'uuid';import { useWorkspaceRouteObjects } from '@/app/routing/components/WorkspaceRouteObjectsProvider';import { useNavigateSidePanel } from '@/side-panel/hooks/useNavigateSidePanel';-import { isSidePanelRoutedLocation } from '@/side-panel/routing/utils/isSidePanelRoutedLocation';+import { isWorkspaceLocationAvailableOnSurface } from '@/app/routing/utils/isWorkspaceLocationAvailableOnSurface';import { toSidePanelLocation } from '@/side-panel/routing/utils/toSidePanelLocation';import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';import { releaseRemovedRoutedFlowStateScopes } from '@/side-panel/routing/utils/releaseRemovedRoutedFlowStateScopes';+import { isSafeInternalPath } from '@/ui/navigation/utils/isSafeInternalPath';export const useOpenRoutedPageInSidePanel = () => {const store = useStore();@@ -33,13 +34,19 @@ export const useOpenRoutedPageInSidePanel = () => {replaceCurrent?: boolean;routedFlowStateScopeId?: string;}) => {- if (!path.startsWith('/') || path.startsWith('//')) {+ if (!isSafeInternalPath(path)) {return null;}let routedLocation = toSidePanelLocation(path, state);- if (!isSidePanelRoutedLocation(routeObjects, routedLocation)) {+ if (+ !isWorkspaceLocationAvailableOnSurface(+ routeObjects,+ 'side-panel',+ routedLocation,+ )+ ) {return null;}diff --git a/packages/twenty-front/src/modules/side-panel/routing/utils/isSidePanelRoutedLocation.ts b/packages/twenty-front/src/modules/side-panel/routing/utils/isSidePanelRoutedLocation.tsdeleted file mode 100644index 7511e0e7a29..00000000000--- a/packages/twenty-front/src/modules/side-panel/routing/utils/isSidePanelRoutedLocation.ts+++ /dev/null@@ -1,9 +0,0 @@-import { type WorkspaceRouteObject } from '@/app/routing/types/WorkspaceRouteObject';-import { isWorkspaceLocationAvailableOnSurface } from '@/app/routing/utils/isWorkspaceLocationAvailableOnSurface';-import { type Location } from 'react-router-dom';--export const isSidePanelRoutedLocation = (- routeObjects: WorkspaceRouteObject[],- location: Partial<Location> | string,-) =>- isWorkspaceLocationAvailableOnSurface(routeObjects, 'side-panel', location);diff --git a/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceContext.ts b/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceContext.tsindex 203446f3e47..f47a6ff4e4f 100644--- a/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceContext.ts+++ b/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceContext.ts@@ -7,8 +7,6 @@ export type WorkspaceSurfaceContextValue = {// Present only when a routed surface owns flow-local editor and UI state.routedFlowStateScopeId?: string;ownsRouteLocation: boolean;- headerTitlePortal: HTMLElement | null;- headerActionsPortal: HTMLElement | null;};export const WorkspaceSurfaceContext =@@ -16,6 +14,4 @@ export const WorkspaceSurfaceContext =type: 'main',instanceId: MAIN_CONTEXT_STORE_INSTANCE_ID,ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,});diff --git a/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceHeaderPortalContext.ts b/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceHeaderPortalContext.tsnew file mode 100644index 00000000000..13394fce30e--- /dev/null+++ b/packages/twenty-front/src/modules/ui/layout/contexts/WorkspaceSurfaceHeaderPortalContext.ts@@ -0,0 +1,12 @@+import { createContext } from 'react';++export type WorkspaceSurfaceHeaderPortalContextValue = {+ title: HTMLElement | null;+ actions: HTMLElement | null;+};++export const WorkspaceSurfaceHeaderPortalContext =+ createContext<WorkspaceSurfaceHeaderPortalContextValue>({+ title: null,+ actions: null,+ });diff --git a/packages/twenty-front/src/modules/ui/layout/hooks/useWorkspaceSurfaceHeaderPortal.ts b/packages/twenty-front/src/modules/ui/layout/hooks/useWorkspaceSurfaceHeaderPortal.tsnew file mode 100644index 00000000000..a23bb7196e7--- /dev/null+++ b/packages/twenty-front/src/modules/ui/layout/hooks/useWorkspaceSurfaceHeaderPortal.ts@@ -0,0 +1,5 @@+import { WorkspaceSurfaceHeaderPortalContext } from '@/ui/layout/contexts/WorkspaceSurfaceHeaderPortalContext';+import { useContext } from 'react';++export const useWorkspaceSurfaceHeaderPortal = () =>+ useContext(WorkspaceSurfaceHeaderPortalContext);diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsxindex 37ec69a0b26..a7b85219b08 100644--- a/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx+++ b/packages/twenty-front/src/modules/ui/layout/page/components/PageCardHeader.tsx@@ -1,6 +1,7 @@import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';import { SIDE_PANEL_TOP_BAR_HEIGHT } from '@/side-panel/constants/SidePanelTopBarHeight';import { useWorkspaceSurface } from '@/ui/layout/hooks/useWorkspaceSurface';+import { useWorkspaceSurfaceHeaderPortal } from '@/ui/layout/hooks/useWorkspaceSurfaceHeaderPortal';import {Breadcrumb,type BreadcrumbProps,@@ -106,6 +107,7 @@ export const PageCardHeader = ({const isMobile = useIsMobile();const isNavigationDrawerExpanded = useNavigationDrawerExpanded();const workspaceSurface = useWorkspaceSurface();+ const workspaceSurfaceHeaderPortal = useWorkspaceSurfaceHeaderPortal();const hasTitleContent = isDefined(icon) || isDefined(title) || isDefined(tag);const shouldCenterTitle = centerTitle && hasTitleContent;@@ -129,15 +131,15 @@ export const PageCardHeader = ({if (workspaceSurface.type === 'side-panel') {return (<>- {isDefined(workspaceSurface.headerTitlePortal) &&+ {isDefined(workspaceSurfaceHeaderPortal.title) &&isDefined(surfaceTitleContent) &&createPortal(<StyledSurfaceTitle titleColor={titleColor}>{surfaceTitleContent}</StyledSurfaceTitle>,- workspaceSurface.headerTitlePortal,+ workspaceSurfaceHeaderPortal.title,)}- {isDefined(workspaceSurface.headerActionsPortal) &&+ {isDefined(workspaceSurfaceHeaderPortal.actions) &&isDefined(actionButton) &&createPortal(<StyledSurfaceActions@@ -145,7 +147,7 @@ export const PageCardHeader = ({>{actionButton}</StyledSurfaceActions>,- workspaceSurface.headerActionsPortal,+ workspaceSurfaceHeaderPortal.actions,)}</>);diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.tsindex 92a9c064c74..84e4920613d 100644--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts@@ -4,18 +4,13 @@ import { useStore } from 'jotai';import { SelectableListComponentInstanceContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListComponentInstanceContext';import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';-import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';import { isDefined } from 'twenty-shared/utils';export const useSelectableList = (instanceId?: string) => {- const unscopedSelectableListInstanceId =- useAvailableComponentInstanceIdOrThrow(- SelectableListComponentInstanceContext,- instanceId,- );- const selectableListInstanceId = useWorkspaceSurfaceScopedComponentInstanceId(- unscopedSelectableListInstanceId,+ const selectableListInstanceId = useAvailableComponentInstanceIdOrThrow(+ SelectableListComponentInstanceContext,+ instanceId,);const store = useStore();diff --git a/packages/twenty-front/src/modules/ui/navigation/utils/isSafeInternalPath.ts b/packages/twenty-front/src/modules/ui/navigation/utils/isSafeInternalPath.tsnew file mode 100644index 00000000000..055decf3b5c--- /dev/null+++ b/packages/twenty-front/src/modules/ui/navigation/utils/isSafeInternalPath.ts@@ -0,0 +1,8 @@+import { isNonEmptyString } from '@sniptt/guards';++export const isSafeInternalPath = (path: string): boolean =>+ isNonEmptyString(path) &&+ path.startsWith('/') &&+ !path.startsWith('//') &&+ !path.includes('\\') &&+ !/[\u0000-\u001f\u007f]/u.test(path);diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceId.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceId.tsindex aead2e9d9b3..9fa24e9d406 100644--- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceId.ts+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceId.ts@@ -1,5 +1,6 @@import { useComponentInstanceStateContext } from '@/ui/utilities/state/component-state/hooks/useComponentInstanceStateContext';import { type ComponentInstanceStateContext } from '@/ui/utilities/state/component-state/types/ComponentInstanceStateContext';+import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { isNonEmptyString } from '@sniptt/guards';export const useAvailableComponentInstanceId = <@@ -10,10 +11,9 @@ export const useAvailableComponentInstanceId = <const instanceStateContext = useComponentInstanceStateContext(Context);const instanceIdFromContext = instanceStateContext?.instanceId;+ const scopedInstanceId = useWorkspaceSurfaceScopedComponentInstanceId(+ instanceIdFromContext ?? '',+ );- if (isNonEmptyString(instanceIdFromContext)) {- return instanceIdFromContext;- } else {- return null;- }+ return isNonEmptyString(scopedInstanceId) ? scopedInstanceId : null;};diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow.tsindex b40ad08b62d..4119eec559b 100644--- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow.ts+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow.ts@@ -1,5 +1,6 @@import { useComponentInstanceStateContext } from '@/ui/utilities/state/component-state/hooks/useComponentInstanceStateContext';import { type ComponentInstanceStateContext } from '@/ui/utilities/state/component-state/types/ComponentInstanceStateContext';+import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { isNonEmptyString } from '@sniptt/guards';export const useAvailableComponentInstanceIdOrThrow = <@@ -11,14 +12,17 @@ export const useAvailableComponentInstanceIdOrThrow = <const instanceStateContext = useComponentInstanceStateContext(Context);const instanceIdFromContext = instanceStateContext?.instanceId;+ const availableInstanceId = isNonEmptyString(instanceIdFromProps)+ ? instanceIdFromProps+ : (instanceIdFromContext ?? '');+ const scopedInstanceId =+ useWorkspaceSurfaceScopedComponentInstanceId(availableInstanceId);- if (isNonEmptyString(instanceIdFromProps)) {- return instanceIdFromProps;- } else if (isNonEmptyString(instanceIdFromContext)) {- return instanceIdFromContext;- } else {- throw new Error(- 'Instance id is not provided and cannot be found in context.',- );+ if (isNonEmptyString(scopedInstanceId)) {+ return scopedInstanceId;}++ throw new Error(+ 'Instance id is not provided and cannot be found in context.',+ );};diff --git a/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsx b/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsxindex 1557ffff6e9..e9208a895b2 100644--- a/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsx+++ b/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsx@@ -117,8 +117,6 @@ describe('RecordIndexPage workspace surface composition', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RecordIndexPage />@@ -141,8 +139,6 @@ describe('RecordIndexPage workspace surface composition', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RecordIndexPage />diff --git a/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPage.surface.test.tsx b/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPage.surface.test.tsxindex af2436d91ae..8528aabf764 100644--- a/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPage.surface.test.tsx+++ b/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPage.surface.test.tsx@@ -147,8 +147,6 @@ describe('RecordShowPage workspace surface composition', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RecordShowPage />@@ -177,8 +175,6 @@ describe('RecordShowPage workspace surface composition', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RecordShowPage />@@ -211,8 +207,6 @@ describe('RecordShowPage workspace surface composition', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}><RecordShowPage />diff --git a/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPageHeader.surface.test.tsx b/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPageHeader.surface.test.tsxindex 240216c4133..6a3f27e45f1 100644--- a/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPageHeader.surface.test.tsx+++ b/packages/twenty-front/src/pages/object-record/__tests__/RecordShowPageHeader.surface.test.tsx@@ -91,8 +91,6 @@ describe('RecordShowPageHeader workspace surface composition', () => {type: 'side-panel',instanceId: 'side-panel-page-1',ownsRouteLocation: true,- headerTitlePortal: null,- headerActionsPortal: null,}}>{header}diff --git a/packages/twenty-front/src/pages/settings/communications/SettingsWorkspaceCommunicationGroupChannelDetail.tsx b/packages/twenty-front/src/pages/settings/communications/SettingsWorkspaceCommunicationGroupChannelDetail.tsxindex 94f19ccfabf..0885cdd6430 100644--- a/packages/twenty-front/src/pages/settings/communications/SettingsWorkspaceCommunicationGroupChannelDetail.tsx+++ b/packages/twenty-front/src/pages/settings/communications/SettingsWorkspaceCommunicationGroupChannelDetail.tsx@@ -154,6 +154,7 @@ export const SettingsWorkspaceCommunicationGroupChannelDetail = () => {return (<SettingsPageLayout+ pageTitle={displayNameDraft ?? displayName}title={<SettingsEditableTitleinstanceId="email-group-display-name"diff --git a/packages/twenty-front/src/pages/settings/logic-functions/SettingsLogicFunctionDetail.tsx b/packages/twenty-front/src/pages/settings/logic-functions/SettingsLogicFunctionDetail.tsxindex d9969b78b3f..c5315222616 100644--- a/packages/twenty-front/src/pages/settings/logic-functions/SettingsLogicFunctionDetail.tsx+++ b/packages/twenty-front/src/pages/settings/logic-functions/SettingsLogicFunctionDetail.tsx@@ -144,6 +144,7 @@ export const SettingsLogicFunctionDetail = () => {!loading &&!applicationLoading && (<SettingsPageLayout+ pageTitle={formValues.name}title={<SettingsLogicFunctionLabelContainervalue={formValues.name}diff --git a/packages/twenty-sdk/src/sdk/front-component/command/CommandOpenSidePanelPage.tsx b/packages/twenty-sdk/src/sdk/front-component/command/CommandOpenSidePanelPage.tsxindex 36d08d6e6c0..0f3fbedcfb6 100644--- a/packages/twenty-sdk/src/sdk/front-component/command/CommandOpenSidePanelPage.tsx+++ b/packages/twenty-sdk/src/sdk/front-component/command/CommandOpenSidePanelPage.tsx@@ -1,11 +1,11 @@import {+ type AppPath,openSidePanelPage,type OpenSidePanelPageParams,unmountFrontComponent,useFrontComponentId,} from '@/sdk/front-component';import { useEffect, useState } from 'react';-import { type AppPath } from 'twenty-shared/types';export type CommandOpenSidePanelPageProps<T extends AppPath = AppPath> =OpenSidePanelPageParams<T>;