The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Remove model-directed AI chat navigation (#27246)
Félix Malfait62d0030905bd
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsxindex 8fa11f1ba4a..5f71ee13c60 100644--- a/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx+++ b/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx@@ -275,13 +275,16 @@ describe('ChatReferenceChip', () => {},);- it('should open a record in the record side panel from the chat page', () => {+ it('should open a record only when its reference is clicked', async () => {renderWithReferences(<ChatReferenceChip reference={findCase('record').reference} />,{ initialPath: '/chat' },);- clickChip('Acme');+ expect(openRecordInSidePanelMock).not.toHaveBeenCalled();+ expect(openRoutedPageInSidePanelMock).not.toHaveBeenCalled();++ await userEvent.click(screen.getByRole('link', { name: 'Acme' }));expect(openRecordInSidePanelMock).toHaveBeenCalledWith({recordId: RECORD_ID,diff --git a/packages/twenty-front/src/modules/ai/constants/ActionToolStatusLabels.ts b/packages/twenty-front/src/modules/ai/constants/ActionToolStatusLabels.tsindex 739b1aec432..485c2773e96 100644--- a/packages/twenty-front/src/modules/ai/constants/ActionToolStatusLabels.ts+++ b/packages/twenty-front/src/modules/ai/constants/ActionToolStatusLabels.ts@@ -19,10 +19,6 @@ export const ACTION_TOOL_STATUS_LABELS: Record<string, ToolStatusLabels> = {loading: msg`Searching the help center`,completed: msg`Searched the help center`,},- navigate_app: {- loading: msg`Navigating in the app`,- completed: msg`Navigated in the app`,- },share_record: {loading: msg`Sharing record`,completed: msg`Shared record`,diff --git a/packages/twenty-front/src/modules/ai/hooks/__tests__/useProcessWorkspaceSetupCompletion.test.tsx b/packages/twenty-front/src/modules/ai/hooks/__tests__/useProcessWorkspaceSetupCompletion.test.tsxindex ced8c7f5974..1130f3664d8 100644--- a/packages/twenty-front/src/modules/ai/hooks/__tests__/useProcessWorkspaceSetupCompletion.test.tsx+++ b/packages/twenty-front/src/modules/ai/hooks/__tests__/useProcessWorkspaceSetupCompletion.test.tsx@@ -8,7 +8,7 @@ import { type ExtendedUIMessage } from 'twenty-shared/ai';import { AgentChatComponentInstanceContext } from '@/ai/contexts/AgentChatComponentInstanceContext';import { useProcessWorkspaceSetupCompletion } from '@/ai/hooks/useProcessWorkspaceSetupCompletion';-import { processedToolExecutionPartIdsComponentState } from '@/ai/states/processedToolExecutionPartIdsComponentState';+import { processedWorkspaceSetupCompletionIdsComponentState } from '@/ai/states/processedWorkspaceSetupCompletionIdsComponentState';import { shouldContinueAiChatInSidePanelState } from '@/ai/states/shouldContinueAiChatInSidePanelState';import {jotaiStore,@@ -71,7 +71,7 @@ const buildCompletionMessage = (toolCallId: string) =>const getProcessedToolCallIds = () =>jotaiStore.get(- processedToolExecutionPartIdsComponentState.atomFamily({+ processedWorkspaceSetupCompletionIdsComponentState.atomFamily({instanceId: INSTANCE_ID,}),);diff --git a/packages/twenty-front/src/modules/ai/hooks/__tests__/useUpdateStreamingPartsWithDiff.test.tsx b/packages/twenty-front/src/modules/ai/hooks/__tests__/useUpdateStreamingPartsWithDiff.test.tsxindex 70a3b5d5fd1..6ce0aafa97b 100644--- a/packages/twenty-front/src/modules/ai/hooks/__tests__/useUpdateStreamingPartsWithDiff.test.tsx+++ b/packages/twenty-front/src/modules/ai/hooks/__tests__/useUpdateStreamingPartsWithDiff.test.tsx@@ -4,6 +4,9 @@ import { type ReactNode } from 'react';import { Temporal } from 'temporal-polyfill';import { type ExtendedUIMessage } from 'twenty-shared/ai';+import { AgentChatComponentInstanceContext } from '@/ai/contexts/AgentChatComponentInstanceContext';+import { sleep } from '~/utils/sleep';+import { useUpdateStreamingPartsWithDiff } from '@/ai/hooks/useUpdateStreamingPartsWithDiff';import { agentChatUISessionStartTimeState } from '@/ai/states/agentChatUISessionStartTimeState';import {@@ -11,13 +14,16 @@ import {resetJotaiStore,} from '@/ui/utilities/state/jotai/jotaiStore';-const processUIToolCallMessage = jest.fn();+const openRecordTarget = jest.fn();+const openViewTarget = jest.fn();const processWorkspaceSetupCompletion = jest.fn();-jest.mock('@/ai/hooks/useProcessUIToolCallMessage', () => ({- useProcessUIToolCallMessage: () => ({ processUIToolCallMessage }),+jest.mock('@/ai/hooks/useChatTargetNavigation', () => ({+ useChatTargetNavigation: () => ({ openRecordTarget, openViewTarget }),}));+jest.mock('~/utils/sleep', () => ({ sleep: jest.fn() }));+jest.mock('@/ai/hooks/useProcessWorkspaceSetupCompletion', () => ({useProcessWorkspaceSetupCompletion: () => ({processWorkspaceSetupCompletion,@@ -39,7 +45,13 @@ const buildMessage = (const renderUpdateStreamingPartsWithDiff = () => {const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>+ <JotaiProvider store={jotaiStore}>+ <AgentChatComponentInstanceContext.Provider+ value={{ instanceId: 'streaming-navigation-test' }}+ >+ {children}+ </AgentChatComponentInstanceContext.Provider>+ </JotaiProvider>);return renderHook(() => useUpdateStreamingPartsWithDiff(), {@@ -63,17 +75,16 @@ describe('useUpdateStreamingPartsWithDiff', () => {const streamingMessage = buildMessage('streaming', 'Hel');updateStreamingPartsWithDiff([settledMessage, streamingMessage]);- expect(processUIToolCallMessage).toHaveBeenCalledTimes(2);+ expect(processWorkspaceSetupCompletion).toHaveBeenCalledTimes(2);const nextStreamingMessage = buildMessage('streaming', 'Hello');updateStreamingPartsWithDiff([settledMessage, nextStreamingMessage]);- expect(processUIToolCallMessage).toHaveBeenCalledTimes(3);- expect(processUIToolCallMessage).toHaveBeenLastCalledWith(+ expect(processWorkspaceSetupCompletion).toHaveBeenCalledTimes(3);+ expect(processWorkspaceSetupCompletion).toHaveBeenLastCalledWith(nextStreamingMessage,);- expect(processWorkspaceSetupCompletion).toHaveBeenCalledTimes(3);});it('does not process again a refetched message whose content did not change', () => {@@ -82,7 +93,7 @@ describe('useUpdateStreamingPartsWithDiff', () => {updateStreamingPartsWithDiff([buildMessage('answer', 'Done')]);updateStreamingPartsWithDiff([buildMessage('answer', 'Done')]);- expect(processUIToolCallMessage).toHaveBeenCalledTimes(1);+ expect(processWorkspaceSetupCompletion).toHaveBeenCalledTimes(1);});it('leaves messages written before this session alone', () => {@@ -92,7 +103,52 @@ describe('useUpdateStreamingPartsWithDiff', () => {buildMessage('earlier', 'Done', '2026-01-01T09:59:59.000Z'),]);- expect(processUIToolCallMessage).not.toHaveBeenCalled();expect(processWorkspaceSetupCompletion).not.toHaveBeenCalled();});++ it.each(['direct', 'execute_tool'] as const)(+ 'does not navigate or wait when streaming or replaying a legacy %s navigation result',+ (format) => {+ const updateStreamingPartsWithDiff = renderUpdateStreamingPartsWithDiff();+ const message: ExtendedUIMessage = {+ ...buildMessage('legacy-navigation', 'Open this record'),+ parts: [+ {+ type:+ format === 'direct' ? 'tool-navigate_app' : 'tool-execute_tool',+ toolCallId: 'navigate-record',+ state: 'output-available',+ input: { toolName: 'navigate_app' },+ output: {+ success: true,+ result: {+ action: 'navigateToRecord',+ objectNameSingular: 'company',+ recordId: '11111111-1111-4111-8111-111111111111',+ },+ },+ },+ {+ type:+ format === 'direct' ? 'tool-navigate_app' : 'tool-execute_tool',+ toolCallId: 'wait',+ state: 'output-available',+ input: { toolName: 'navigate_app' },+ output: {+ success: true,+ result: { action: 'wait', durationMs: 3000 },+ },+ },+ ],+ };++ updateStreamingPartsWithDiff([message]);+ updateStreamingPartsWithDiff([]);+ updateStreamingPartsWithDiff([{ ...message, parts: [...message.parts] }]);++ expect(openRecordTarget).not.toHaveBeenCalled();+ expect(openViewTarget).not.toHaveBeenCalled();+ expect(sleep).not.toHaveBeenCalled();+ },+ );});diff --git a/packages/twenty-front/src/modules/ai/hooks/useChatTargetNavigation.ts b/packages/twenty-front/src/modules/ai/hooks/useChatTargetNavigation.tsindex 667a89175e7..8b48e4a7a89 100644--- a/packages/twenty-front/src/modules/ai/hooks/useChatTargetNavigation.ts+++ b/packages/twenty-front/src/modules/ai/hooks/useChatTargetNavigation.ts@@ -1,18 +1,12 @@-import { useStore } from 'jotai';import { AppPath } from 'twenty-shared/types';-import { getAppPath, isDefined } from 'twenty-shared/utils';import { useIsAiChatArtifactSurface } from '@/ai/hooks/useIsAiChatArtifactSurface';-import { objectMetadataItemFamilySelector } from '@/object-metadata/states/objectMetadataItemFamilySelector';import { useOpenRecordInSidePanel } from '@/side-panel/hooks/useOpenRecordInSidePanel';-import { useOpenRoutedPageInSidePanel } from '@/side-panel/routing/hooks/useOpenRoutedPageInSidePanel';import { useNavigateApp } from '~/hooks/useNavigateApp';export const useChatTargetNavigation = () => {- const store = useStore();const navigateApp = useNavigateApp();const { openRecordInSidePanel } = useOpenRecordInSidePanel();- const { openRoutedPageInSidePanel } = useOpenRoutedPageInSidePanel();const isAiChatArtifactSurface = useIsAiChatArtifactSurface();const openRecordTarget = ({@@ -37,49 +31,5 @@ export const useChatTargetNavigation = () => {});};- const openViewTarget = ({- objectNameSingular,- viewId,- }: {- objectNameSingular: string;- viewId?: string;- }) => {- const objectMetadataItem = store.get(- objectMetadataItemFamilySelector.selectorFamily({- objectName: objectNameSingular,- objectNameType: 'singular',- }),- );-- if (!isDefined(objectMetadataItem)) {- throw new Error(- `Object with singular name ${objectNameSingular} not found.`,- );- }-- const recordIndexParams = {- objectNamePlural: objectMetadataItem.namePlural,- };- const recordIndexQueryParams = isDefined(viewId) ? { viewId } : undefined;-- if (isAiChatArtifactSurface) {- openRoutedPageInSidePanel({- path: getAppPath(- AppPath.RecordIndexPage,- recordIndexParams,- recordIndexQueryParams,- ),- });-- return;- }-- navigateApp(- AppPath.RecordIndexPage,- recordIndexParams,- recordIndexQueryParams,- );- };-- return { openRecordTarget, openViewTarget };+ return { openRecordTarget };};diff --git a/packages/twenty-front/src/modules/ai/hooks/useClaimUnprocessedToolCallParts.ts b/packages/twenty-front/src/modules/ai/hooks/useClaimUnprocessedToolCallParts.tsdeleted file mode 100644index b4edf880f89..00000000000--- a/packages/twenty-front/src/modules/ai/hooks/useClaimUnprocessedToolCallParts.ts+++ /dev/null@@ -1,44 +0,0 @@-import { processedToolExecutionPartIdsComponentState } from '@/ai/states/processedToolExecutionPartIdsComponentState';-import { useAtomComponentStateCallbackState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateCallbackState';-import { useStore } from 'jotai';--export const useClaimUnprocessedToolCallParts = () => {- const processedToolExecutionPartIdsCallbackState =- useAtomComponentStateCallbackState(- processedToolExecutionPartIdsComponentState,- );-- const store = useStore();-- const claimUnprocessedToolCallParts = <- TToolCallPart extends { toolCallId: string },- >(- toolCallParts: TToolCallPart[],- ): TToolCallPart[] => {- const processedToolExecutionPartIds = store.get(- processedToolExecutionPartIdsCallbackState,- );-- const claimedToolCallIds = new Set(processedToolExecutionPartIds);- const unprocessedToolCallParts = toolCallParts.filter((part) => {- if (claimedToolCallIds.has(part.toolCallId)) {- return false;- }-- claimedToolCallIds.add(part.toolCallId);-- return true;- });-- if (unprocessedToolCallParts.length > 0) {- store.set(processedToolExecutionPartIdsCallbackState, [- ...processedToolExecutionPartIds,- ...unprocessedToolCallParts.map((part) => part.toolCallId),- ]);- }-- return unprocessedToolCallParts;- };-- return { claimUnprocessedToolCallParts };-};diff --git a/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.ts b/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.tsdeleted file mode 100644index 4acf2a0805d..00000000000--- a/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.ts+++ /dev/null@@ -1,68 +0,0 @@-import { useChatTargetNavigation } from '@/ai/hooks/useChatTargetNavigation';-import { useClaimUnprocessedToolCallParts } from '@/ai/hooks/useClaimUnprocessedToolCallParts';-import { extractUIToolCallParts } from '@/ai/utils/extractUIToolCallParts';--import { type ExtendedUIMessage } from 'twenty-shared/ai';-import { isDefined } from 'twenty-shared/utils';-import { sleep } from '~/utils/sleep';--export const useProcessUIToolCallMessage = () => {- const { openRecordTarget, openViewTarget } = useChatTargetNavigation();- const { claimUnprocessedToolCallParts } = useClaimUnprocessedToolCallParts();-- const processUIToolCallMessage = async (- uiToolCallMessage: ExtendedUIMessage,- ) => {- const succeededToolExecutionParts = extractUIToolCallParts(- uiToolCallMessage.parts,- ).filter((part) => part.output?.success === true);-- for (const toolExecutionPart of succeededToolExecutionParts) {- if (claimUnprocessedToolCallParts([toolExecutionPart]).length === 0) {- continue;- }-- const navigateAppOutput = toolExecutionPart.output?.result;-- if (!isDefined(navigateAppOutput)) {- continue;- }-- switch (navigateAppOutput.action) {- case 'navigateToObject': {- openViewTarget({- objectNameSingular: navigateAppOutput.objectNameSingular,- });-- break;- }- case 'navigateToRecord': {- openRecordTarget({- recordId: navigateAppOutput.recordId,- objectNameSingular: navigateAppOutput.objectNameSingular,- });-- break;- }- case 'navigateToView': {- openViewTarget({- objectNameSingular: navigateAppOutput.objectNameSingular,- viewId: navigateAppOutput.viewId,- });-- break;- }- case 'wait': {- await sleep(navigateAppOutput.durationMs);- break;- }- default:- break;- }- }- };-- return {- processUIToolCallMessage,- };-};diff --git a/packages/twenty-front/src/modules/ai/hooks/useProcessWorkspaceSetupCompletion.ts b/packages/twenty-front/src/modules/ai/hooks/useProcessWorkspaceSetupCompletion.tsindex 23f67669a64..4df798e216a 100644--- a/packages/twenty-front/src/modules/ai/hooks/useProcessWorkspaceSetupCompletion.ts+++ b/packages/twenty-front/src/modules/ai/hooks/useProcessWorkspaceSetupCompletion.ts@@ -4,11 +4,11 @@ import { AI_CHAT_SURFACE } from '@/ai/constants/AiChatSurface';import { shouldOpenAiChatAfterOnboardingState } from '@/onboarding/states/shouldOpenAiChatAfterOnboardingState';import { useIsWorkspaceSetupChat } from '@/ai/hooks/useIsWorkspaceSetupChat';import { useReturnFromExpandedAiChat } from '@/ai/hooks/useReturnFromExpandedAiChat';-import { useClaimUnprocessedToolCallParts } from '@/ai/hooks/useClaimUnprocessedToolCallParts';+import { processedWorkspaceSetupCompletionIdsComponentState } from '@/ai/states/processedWorkspaceSetupCompletionIdsComponentState';+import { useAtomComponentStateCallbackState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateCallbackState';import { extractCompletedWorkspaceSetupToolParts } from '@/ai/utils/extractCompletedWorkspaceSetupToolParts';import { useDefaultHomePagePath } from '@/navigation/hooks/useDefaultHomePagePath';import { isSettingsPath } from '~/utils/isSettingsPath';-import { isNonEmptyArray } from '@sniptt/guards';import { useStore } from 'jotai';import { type ExtendedUIMessage } from 'twenty-shared/ai';@@ -22,18 +22,30 @@ export const useProcessWorkspaceSetupCompletion = () => {destinationPath: defaultHomePagePath,});- const { claimUnprocessedToolCallParts } = useClaimUnprocessedToolCallParts();+ const processedCompletionIdsState = useAtomComponentStateCallbackState(+ processedWorkspaceSetupCompletionIdsComponentState,+ );const store = useStore();const processWorkspaceSetupCompletion = (message: Pick<ExtendedUIMessage, 'parts'>,) => {- const claimedParts = claimUnprocessedToolCallParts(- extractCompletedWorkspaceSetupToolParts(message.parts),- );+ const processedCompletionIds = store.get(processedCompletionIdsState);+ const completionIds = new Set([+ ...processedCompletionIds,+ ...extractCompletedWorkspaceSetupToolParts(message.parts).map(+ (part) => part.toolCallId,+ ),+ ]);++ if (completionIds.size === processedCompletionIds.length) {+ return;+ }++ store.set(processedCompletionIdsState, [...completionIds]);- if (!isNonEmptyArray(claimedParts) || !isWorkspaceSetupChat) {+ if (!isWorkspaceSetupChat) {return;}diff --git a/packages/twenty-front/src/modules/ai/hooks/useUpdateStreamingPartsWithDiff.ts b/packages/twenty-front/src/modules/ai/hooks/useUpdateStreamingPartsWithDiff.tsindex 63228402870..f8ec46c23e7 100644--- a/packages/twenty-front/src/modules/ai/hooks/useUpdateStreamingPartsWithDiff.ts+++ b/packages/twenty-front/src/modules/ai/hooks/useUpdateStreamingPartsWithDiff.ts@@ -1,4 +1,3 @@-import { useProcessUIToolCallMessage } from '@/ai/hooks/useProcessUIToolCallMessage';import { useProcessWorkspaceSetupCompletion } from '@/ai/hooks/useProcessWorkspaceSetupCompletion';import { agentChatUISessionStartTimeState } from '@/ai/states/agentChatUISessionStartTimeState';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';@@ -13,7 +12,6 @@ export const useUpdateStreamingPartsWithDiff = () => {agentChatUISessionStartTimeState,);- const { processUIToolCallMessage } = useProcessUIToolCallMessage();const { processWorkspaceSetupCompletion } =useProcessWorkspaceSetupCompletion();@@ -65,7 +63,6 @@ export const useUpdateStreamingPartsWithDiff = () => {continue;}- processUIToolCallMessage(incomingMessage);processWorkspaceSetupCompletion(incomingMessage);}};diff --git a/packages/twenty-front/src/modules/ai/states/processedToolExecutionPartIdsComponentState.ts b/packages/twenty-front/src/modules/ai/states/processedWorkspaceSetupCompletionIdsComponentState.tssimilarity index 72%rename from packages/twenty-front/src/modules/ai/states/processedToolExecutionPartIdsComponentState.tsrename to packages/twenty-front/src/modules/ai/states/processedWorkspaceSetupCompletionIdsComponentState.tsindex c59713041b2..198aad47723 100644--- a/packages/twenty-front/src/modules/ai/states/processedToolExecutionPartIdsComponentState.ts+++ b/packages/twenty-front/src/modules/ai/states/processedWorkspaceSetupCompletionIdsComponentState.ts@@ -1,9 +1,9 @@import { AgentChatComponentInstanceContext } from '@/ai/contexts/AgentChatComponentInstanceContext';import { createAtomComponentState } from '@/ui/utilities/state/jotai/utils/createAtomComponentState';-export const processedToolExecutionPartIdsComponentState =+export const processedWorkspaceSetupCompletionIdsComponentState =createAtomComponentState<string[]>({- key: 'processedToolExecutionPartIdsComponentState',+ key: 'processedWorkspaceSetupCompletionIdsComponentState',defaultValue: [],componentInstanceContext: AgentChatComponentInstanceContext,});diff --git a/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.ts b/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.tsdeleted file mode 100644index 406e1389541..00000000000--- a/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.ts+++ /dev/null@@ -1,11 +0,0 @@-import { type NavigateAppToolOutput } from 'twenty-shared/ai';--export type AgentChatMessageUIToolCallPart = {- toolCallId: string;- output?: {- success: boolean;- message: string;- error?: string;- result?: NavigateAppToolOutput;- };-};diff --git a/packages/twenty-front/src/modules/ai/utils/extractUIToolCallParts.ts b/packages/twenty-front/src/modules/ai/utils/extractUIToolCallParts.tsdeleted file mode 100644index 733f7c1bce8..00000000000--- a/packages/twenty-front/src/modules/ai/utils/extractUIToolCallParts.ts+++ /dev/null@@ -1,12 +0,0 @@-import { type AgentChatMessageUIToolCallPart } from '@/ai/types/AgentChatMessageUIToolCallPart';-import { getEffectiveToolName } from '@/ai/utils/getEffectiveToolName';-import { type DynamicToolUIPart, isToolUIPart, type ToolUIPart } from 'ai';-import { type ExtendedUIMessagePart } from 'twenty-shared/ai';--export const extractUIToolCallParts = (- messageParts: ExtendedUIMessagePart[],-): AgentChatMessageUIToolCallPart[] =>- messageParts.filter(- (part): part is ToolUIPart | DynamicToolUIPart =>- isToolUIPart(part) && getEffectiveToolName(part) === 'navigate_app',- ) as AgentChatMessageUIToolCallPart[];diff --git a/packages/twenty-server/src/engine/core-modules/tool-provider/constants/action-tool-label.constant.ts b/packages/twenty-server/src/engine/core-modules/tool-provider/constants/action-tool-label.constant.tsindex 645f89c5280..a31e462863f 100644--- a/packages/twenty-server/src/engine/core-modules/tool-provider/constants/action-tool-label.constant.ts+++ b/packages/twenty-server/src/engine/core-modules/tool-provider/constants/action-tool-label.constant.ts@@ -11,7 +11,6 @@ export const ACTION_TOOL_IDS = ['create_calendar_event','search_help_center','code_interpreter',- 'navigate_app','save_campaign','create_file_upload','complete_file_upload',@@ -42,9 +41,6 @@ export const ACTION_TOOL_LABELS: Record<ActionToolId, ActionToolLabel> = {code_interpreter: {label: i18nLabel(msg`Code Interpreter`),},- navigate_app: {- label: i18nLabel(msg`Navigate App`),- },save_campaign: {label: i18nLabel(msg`Save Campaign`),},diff --git a/packages/twenty-server/src/engine/core-modules/tool-provider/providers/__tests__/action-tool.provider.spec.ts b/packages/twenty-server/src/engine/core-modules/tool-provider/providers/__tests__/action-tool.provider.spec.tsindex a8ffdc1690f..be0e0a5d6f1 100644--- a/packages/twenty-server/src/engine/core-modules/tool-provider/providers/__tests__/action-tool.provider.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/tool-provider/providers/__tests__/action-tool.provider.spec.ts@@ -11,7 +11,6 @@ import { type SendEmailTool } from 'src/engine/core-modules/tool/tools/email-tooimport { type CompleteFileUploadTool } from 'src/engine/core-modules/tool/tools/file-upload-tool/complete-file-upload-tool';import { type CreateFileUploadTool } from 'src/engine/core-modules/tool/tools/file-upload-tool/create-file-upload-tool';import { type HttpTool } from 'src/engine/core-modules/tool/tools/http-tool/http-tool';-import { type NavigateAppTool } from 'src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool';import { type ExtractJsonPathsTool } from 'src/engine/core-modules/tool/tools/output-navigation-tool/extract-json-paths-tool';import { type SearchOutputTool } from 'src/engine/core-modules/tool/tools/output-navigation-tool/search-output-tool';import { type SearchHelpCenterTool } from 'src/engine/core-modules/tool/tools/search-help-center-tool/search-help-center-tool';@@ -62,7 +61,6 @@ const buildProvider = ({buildTool<CreateFileUploadTool>(),buildTool<CompleteFileUploadTool>(),buildTool<CodeInterpreterTool>(),- buildTool<NavigateAppTool>(),buildTool<ExtractJsonPathsTool>(),buildTool<SearchOutputTool>(),buildTool<SaveCampaignTool>(),@@ -85,6 +83,15 @@ const getToolNames = async (provider: ActionToolProvider) =>);describe('ActionToolProvider', () => {+ it('does not offer or execute the retired navigation tool', async () => {+ const { provider } = buildProvider({ isRecordSharingEnabled: true });++ expect(await getToolNames(provider)).not.toContain('navigate_app');+ await expect(+ provider.executeStaticTool('navigate_app', {}, CONTEXT),+ ).rejects.toThrow('Unknown action tool "navigate_app"');+ });+it('lists share_record when record sharing is enabled', async () => {const { provider, shareRecordTool } = buildProvider({isRecordSharingEnabled: true,diff --git a/packages/twenty-server/src/engine/core-modules/tool-provider/providers/action-tool.provider.ts b/packages/twenty-server/src/engine/core-modules/tool-provider/providers/action-tool.provider.tsindex 820662af3f9..ad7fa3ba946 100644--- a/packages/twenty-server/src/engine/core-modules/tool-provider/providers/action-tool.provider.ts+++ b/packages/twenty-server/src/engine/core-modules/tool-provider/providers/action-tool.provider.ts@@ -30,7 +30,6 @@ import { SendEmailTool } from 'src/engine/core-modules/tool/tools/email-tool/senimport { CompleteFileUploadTool } from 'src/engine/core-modules/tool/tools/file-upload-tool/complete-file-upload-tool';import { CreateFileUploadTool } from 'src/engine/core-modules/tool/tools/file-upload-tool/create-file-upload-tool';import { HttpTool } from 'src/engine/core-modules/tool/tools/http-tool/http-tool';-import { NavigateAppTool } from 'src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool';import { ExtractJsonPathsTool } from 'src/engine/core-modules/tool/tools/output-navigation-tool/extract-json-paths-tool';import { SearchOutputTool } from 'src/engine/core-modules/tool/tools/output-navigation-tool/search-output-tool';import { SearchHelpCenterTool } from 'src/engine/core-modules/tool/tools/search-help-center-tool/search-help-center-tool';@@ -56,7 +55,6 @@ export class ActionToolProvider implements ToolProvider {private readonly createFileUploadTool: CreateFileUploadTool,private readonly completeFileUploadTool: CompleteFileUploadTool,private readonly codeInterpreterTool: CodeInterpreterTool,- private readonly navigateAppTool: NavigateAppTool,private readonly extractJsonPathsTool: ExtractJsonPathsTool,private readonly searchOutputTool: SearchOutputTool,private readonly saveCampaignTool: SaveCampaignTool,@@ -75,7 +73,6 @@ export class ActionToolProvider implements ToolProvider {['create_file_upload', this.createFileUploadTool],['complete_file_upload', this.completeFileUploadTool],['code_interpreter', this.codeInterpreterTool],- ['navigate_app', this.navigateAppTool],['extract_json_paths', this.extractJsonPathsTool],['search_output', this.searchOutputTool],['save_campaign', this.saveCampaignTool],@@ -201,15 +198,6 @@ export class ActionToolProvider implements ToolProvider {),);- descriptors.push(- this.buildDescriptor(- 'navigate_app',- this.navigateAppTool,- includeSchemas,- context.locale,- ),- );-descriptors.push(this.buildDescriptor('extract_json_paths',diff --git a/packages/twenty-server/src/engine/core-modules/tool/tool.module.ts b/packages/twenty-server/src/engine/core-modules/tool/tool.module.tsindex 2d83f1f0c35..ef2c7532c34 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tool.module.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tool.module.ts@@ -17,17 +17,13 @@ import { SendEmailTool } from 'src/engine/core-modules/tool/tools/email-tool/senimport { CompleteFileUploadTool } from 'src/engine/core-modules/tool/tools/file-upload-tool/complete-file-upload-tool';import { CreateFileUploadTool } from 'src/engine/core-modules/tool/tools/file-upload-tool/create-file-upload-tool';import { HttpTool } from 'src/engine/core-modules/tool/tools/http-tool/http-tool';-import { NavigateAppTool } from 'src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool';import { ExtractJsonPathsTool } from 'src/engine/core-modules/tool/tools/output-navigation-tool/extract-json-paths-tool';import { SearchOutputTool } from 'src/engine/core-modules/tool/tools/output-navigation-tool/search-output-tool';import { SearchHelpCenterTool } from 'src/engine/core-modules/tool/tools/search-help-center-tool/search-help-center-tool';import { ShareRecordTool } from 'src/engine/core-modules/tool/tools/share-record-tool/share-record-tool';import { ToolOutputSpillService } from 'src/engine/core-modules/tool/services/tool-output-spill.service';-import { WorkspaceManyOrAllFlatEntityMapsCacheModule } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module';import { ConnectedAccountMetadataModule } from 'src/engine/metadata-modules/connected-account/connected-account-metadata.module';import { ConnectedAccountEntity } from 'src/engine/metadata-modules/connected-account/entities/connected-account.entity';-import { NavigationMenuItemModule } from 'src/engine/metadata-modules/navigation-menu-item/navigation-menu-item.module';-import { ObjectMetadataModule } from 'src/engine/metadata-modules/object-metadata/object-metadata.module';import { CalendarEventCreationManagerModule } from 'src/modules/calendar/calendar-event-creation-manager/calendar-event-creation-manager.module';import { MessagingImportManagerModule } from 'src/modules/messaging/message-import-manager/messaging-import-manager.module';import { MessagingSendManagerModule } from 'src/modules/messaging/message-outbound-manager/messaging-send-manager.module';@@ -46,9 +42,6 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cacheJwtModule,RecordShareModule,SecureHttpClientModule,- ObjectMetadataModule,- NavigationMenuItemModule,- WorkspaceManyOrAllFlatEntityMapsCacheModule,WorkspaceCacheModule,],providers: [@@ -62,7 +55,6 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cacheCreateFileUploadTool,CompleteFileUploadTool,CodeInterpreterTool,- NavigateAppTool,ExtractJsonPathsTool,SearchOutputTool,ShareRecordTool,@@ -80,7 +72,6 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cacheCreateFileUploadTool,CompleteFileUploadTool,CodeInterpreterTool,- NavigateAppTool,ExtractJsonPathsTool,SearchOutputTool,ShareRecordTool,diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/__tests__/navigate-app-tool.schema.spec.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/__tests__/navigate-app-tool.schema.spec.tsdeleted file mode 100644index 0c278b07717..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/__tests__/navigate-app-tool.schema.spec.ts+++ /dev/null@@ -1,54 +0,0 @@-import { NavigateAppInputZodSchema } from 'src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.schema';--const RECORD_ID = '20202020-0000-4000-8000-000000000001';--describe('NavigateAppInputZodSchema', () => {- it('should accept a record navigation by id', () => {- const parseResult = NavigateAppInputZodSchema.safeParse({- navigation: {- type: 'navigateToRecord',- objectNameSingular: 'company',- recordId: RECORD_ID,- },- });-- expect(parseResult.success).toBe(true);- });-- it('should reject a record navigation by name', () => {- const parseResult = NavigateAppInputZodSchema.safeParse({- navigation: {- type: 'navigateToRecord',- objectNameSingular: 'company',- recordName: 'Acme',- },- });-- expect(parseResult.success).toBe(false);- });-- it('should reject a record id that is not a uuid', () => {- const parseResult = NavigateAppInputZodSchema.safeParse({- navigation: {- type: 'navigateToRecord',- objectNameSingular: 'company',- recordId: 'Acme',- },- });-- expect(parseResult.success).toBe(false);- });-- it('should accept a view navigation by id and reject one by name', () => {- expect(- NavigateAppInputZodSchema.safeParse({- navigation: { type: 'navigateToView', viewId: RECORD_ID },- }).success,- ).toBe(true);- expect(- NavigateAppInputZodSchema.safeParse({- navigation: { type: 'navigateToView', viewName: 'All Companies' },- }).success,- ).toBe(false);- });-});diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.schema.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.schema.tsdeleted file mode 100644index 1bf156e9ba7..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.schema.ts+++ /dev/null@@ -1,66 +0,0 @@-import { z } from 'zod';--export const NavigateAppActionZodSchema = z.discriminatedUnion('type', [- z.object({- type: z- .literal('navigateToView')- .describe(- 'Navigate to a specific view by id. ONLY use this type when the user explicitly mentions the word "view" (e.g. "go to the My Companies view") or right after you created or updated a view. Do NOT use this for general navigation requests.',- ),- viewId: z- .string()- .uuid()- .describe(- 'The id of the view to navigate to. Take it from get_views, or from the result of the tool that created or updated the view (e.g. upsert_complete_view, create_view).',- ),- }),- z.object({- type: z- .literal('navigateToObject')- .describe(- 'Navigate to the default view for an object. This is the PREFERRED and DEFAULT type for all navigation requests unless the user explicitly mentions the word "view".',- ),- objectNameSingular: z- .string()- .describe(- 'The singular name of the object to navigate to (e.g. "company", "person", "opportunity")',- ),- }),- z.object({- type: z- .literal('navigateToRecord')- .describe(- 'Navigate to a specific record page by id. Find the record id first with the find_* tools (e.g. find_many_companies filtered by name), or take it from the result of the tool that created the record. If several records match what the user asked for, ask which one they mean before navigating.',- ),- objectNameSingular: z- .string()- .describe(- 'The singular name of the object type (e.g. "company", "person", "opportunity")',- ),- recordId: z.string().uuid().describe('The id of the record to navigate to'),- }),- z.object({- type: z- .literal('wait')- .describe(- 'Wait for a specified duration in milliseconds before continuing. Useful when you need the page to fully load after a navigation before taking further actions (e.g. 2000 for 2 seconds).',- ),- durationMs: z- .number()- .int()- .min(0)- .max(30000)- .describe(- 'The duration in milliseconds to wait (e.g. 2000 for 2 seconds). Maximum 30000 (30 seconds).',- ),- }),-]);--export const NavigateAppInputZodSchema = z.object({- navigation: NavigateAppActionZodSchema.describe(- 'The navigation action to perform.',- ),-});--export type NavigateAppAction = z.infer<typeof NavigateAppActionZodSchema>;-export type NavigateAppInput = z.infer<typeof NavigateAppInputZodSchema>;diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.tsdeleted file mode 100644index 4f0780b26a9..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.ts+++ /dev/null@@ -1,289 +0,0 @@-import { Injectable } from '@nestjs/common';--import { sleep } from 'cloudflare/core';-import Fuse from 'fuse.js';-import { NavigateAppToolOutput } from 'twenty-shared/ai';-import { FeatureFlagKey, type ObjectsPermissions } from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';--import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';-import {- type NavigateAppInput,- NavigateAppInputZodSchema,-} from 'src/engine/core-modules/tool/tools/navigate-tool/navigate-app-tool.schema';-import { buildNavigateToRecordOutput } from 'src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-record-output.util';-import { buildNavigateToViewOutput } from 'src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-view-output.util';-import { type ToolInput } from 'src/engine/core-modules/tool/types/tool-input.type';-import { ToolOutput } from 'src/engine/core-modules/tool/types/tool-output.type';-import { type ToolExecutionContext } from 'src/engine/core-modules/tool/types/tool-execution-context.type';-import { type Tool } from 'src/engine/core-modules/tool/types/tool.type';-import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';-import { findFlatEntityByIdInFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-id-in-flat-entity-maps.util';-import { NavigationMenuItemType } from 'src/engine/metadata-modules/navigation-menu-item/enums/navigation-menu-item-type.enum';-import { NavigationMenuItemService } from 'src/engine/metadata-modules/navigation-menu-item/navigation-menu-item.service';-import { type RolePermissionConfig } from 'src/engine/twenty-orm/types/role-permission-config.type';-import { getObjectsPermissionsFromRolePermissionConfig } from 'src/engine/twenty-orm/utils/get-objects-permissions-from-role-permission-config.util';-import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';--@Injectable()-export class NavigateAppTool implements Tool {- description = `Navigate the application.- Use navigateToRecord to open a specific record. It needs the record id: find it first with the find_* tools, or take it from the result of the tool that created the record.- Default to navigateToObject for all other navigation requests.- Only use navigateToView when the user explicitly mentions the word "view" in their request, or right after creating a view. It needs the view id from get_views or from the tool that created the view.- If the user asks to wait, use the wait tool with the specified duration.`;-- inputSchema = NavigateAppInputZodSchema;-- constructor(- private readonly navigationMenuItemService: NavigationMenuItemService,- private readonly featureFlagService: FeatureFlagService,- private readonly workspaceManyOrAllFlatEntityMapsCacheService: WorkspaceManyOrAllFlatEntityMapsCacheService,- private readonly workspaceCacheService: WorkspaceCacheService,- ) {}-- async execute(- parameters: ToolInput,- context: ToolExecutionContext,- ): Promise<ToolOutput> {- const parseResult = NavigateAppInputZodSchema.safeParse(parameters);-- if (!parseResult.success) {- return {- success: false,- message: 'Invalid navigation input',- error: parseResult.error.message,- };- }-- const input: NavigateAppInput['navigation'] = parseResult.data.navigation;-- switch (input.type) {- case 'navigateToView':- return this.navigateToView({- viewId: input.viewId,- workspaceId: context.workspaceId,- userWorkspaceId: context.userWorkspaceId,- });- case 'navigateToObject':- return this.navigateToObject(- input.objectNameSingular,- context.workspaceId,- );- case 'navigateToRecord':- return this.navigateToRecord({- objectNameSingular: input.objectNameSingular,- recordId: input.recordId,- workspaceId: context.workspaceId,- rolePermissionConfig: context.rolePermissionConfig,- });- case 'wait':- return this.wait(input.durationMs);- }- }-- private async wait(- durationMs: number,- ): Promise<ToolOutput<NavigateAppToolOutput>> {- await sleep(durationMs);-- return {- success: true,- message: `Waited for ${durationMs}ms`,- result: {- action: 'wait',- durationMs,- },- };- }-- private async navigateToView({- viewId,- workspaceId,- userWorkspaceId,- }: {- viewId: string;- workspaceId: string;- userWorkspaceId?: string;- }): Promise<ToolOutput<NavigateAppToolOutput>> {- const { flatObjectMetadataMaps, flatViewMaps } =- await this.workspaceManyOrAllFlatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(- {- workspaceId,- flatMapsKeys: ['flatObjectMetadataMaps', 'flatViewMaps'],- },- );-- const isInitialObjectViewEnabled =- await this.featureFlagService.isFeatureEnabled(- FeatureFlagKey.IS_INITIAL_OBJECT_VIEW_ENABLED,- workspaceId,- );-- return buildNavigateToViewOutput({- viewId,- flatView: findFlatEntityByIdInFlatEntityMaps({- flatEntityId: viewId,- flatEntityMaps: flatViewMaps,- }),- userWorkspaceId,- isInitialObjectViewEnabled,- flatObjectMetadataMaps,- });- }-- private async navigateToObject(- objectNameSingular: string,- workspaceId: string,- ): Promise<ToolOutput<NavigateAppToolOutput>> {- const navigationMenuItems = await this.navigationMenuItemService.findAll({- workspaceId,- });-- const { flatObjectMetadataMaps, flatViewMaps } =- await this.workspaceManyOrAllFlatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(- {- workspaceId,- flatMapsKeys: [- 'flatObjectMetadataMaps',- 'flatViewMaps',- 'flatNavigationMenuItemMaps',- ],- },- );-- type NavigatableObject = {- nameSingular: string;- labelSingular: string;- labelPlural: string;- };-- const navigatableObjects = navigationMenuItems- .map<NavigatableObject | null>((navigationMenuItem) => {- const objectMetadataId =- navigationMenuItem.type === NavigationMenuItemType.OBJECT- ? navigationMenuItem.targetObjectMetadataId- : navigationMenuItem.type === NavigationMenuItemType.VIEW &&- isDefined(navigationMenuItem.viewId)- ? flatViewMaps.byUniversalIdentifier[- flatViewMaps.universalIdentifierById[- navigationMenuItem.viewId- ] ?? ''- ]?.objectMetadataId- : undefined;-- if (!isDefined(objectMetadataId)) {- return null;- }-- const objectMetadataUniversalIdentifier =- flatObjectMetadataMaps.universalIdentifierById[objectMetadataId];-- if (!isDefined(objectMetadataUniversalIdentifier)) {- return null;- }-- const objectMetadata =- flatObjectMetadataMaps.byUniversalIdentifier[- objectMetadataUniversalIdentifier- ];-- if (!isDefined(objectMetadata)) {- return null;- }-- return {- nameSingular: objectMetadata.nameSingular,- labelSingular: objectMetadata.labelSingular,- labelPlural: objectMetadata.labelPlural,- };- })- .filter(isDefined);-- const fuse = new Fuse(navigatableObjects, {- keys: ['nameSingular', 'labelSingular', 'labelPlural'],- threshold: 0.4,- });-- const results = fuse.search(objectNameSingular);- const matchingObject = results[0]?.item;-- if (!isDefined(matchingObject)) {- const availableLabels = navigatableObjects- .map((object) => object.labelPlural)- .join(', ');-- return {- success: false,- message: `Object "${objectNameSingular}" not found`,- error: `No object matching "${objectNameSingular}" was found in this workspace. Available objects: ${availableLabels}`,- };- }-- return {- success: true,- message: `Navigating to ${matchingObject.labelPlural} default view`,- result: {- action: 'navigateToObject',- objectNameSingular: matchingObject.nameSingular,- },- };- }-- private async navigateToRecord({- objectNameSingular,- recordId,- workspaceId,- rolePermissionConfig,- }: {- objectNameSingular: string;- recordId: string;- workspaceId: string;- rolePermissionConfig?: RolePermissionConfig;- }): Promise<ToolOutput<NavigateAppToolOutput>> {- const { flatObjectMetadataMaps } =- await this.workspaceManyOrAllFlatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(- {- workspaceId,- flatMapsKeys: ['flatObjectMetadataMaps'],- },- );-- return buildNavigateToRecordOutput({- objectNameSingular,- recordId,- flatObjectMetadataMaps,- objectsPermissions: await this.getObjectsPermissions({- workspaceId,- rolePermissionConfig,- }),- });- }-- // Missing or unloadable permissions fail closed into the not found result- private async getObjectsPermissions({- workspaceId,- rolePermissionConfig,- }: {- workspaceId: string;- rolePermissionConfig?: RolePermissionConfig;- }): Promise<ObjectsPermissions> {- if (!isDefined(rolePermissionConfig)) {- return {};- }-- try {- const { rolesPermissions } =- await this.workspaceCacheService.getOrRecompute(workspaceId, [- 'rolesPermissions',- ]);-- return getObjectsPermissionsFromRolePermissionConfig({- rolesPermissions,- rolePermissionConfig,- });- } catch {- return {};- }- }-}diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/__tests__/build-navigate-to-record-output.util.spec.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/__tests__/build-navigate-to-record-output.util.spec.tsdeleted file mode 100644index b5a0620a300..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/__tests__/build-navigate-to-record-output.util.spec.ts+++ /dev/null@@ -1,112 +0,0 @@-import { type ObjectPermissions } from 'twenty-shared/types';--import { buildNavigateToRecordOutput } from 'src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-record-output.util';-import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';-import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';-import { addFlatEntityToFlatEntityMapsOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/add-flat-entity-to-flat-entity-maps-or-throw.util';-import { getFlatObjectMetadataMock } from 'src/engine/metadata-modules/flat-object-metadata/__mocks__/get-flat-object-metadata.mock';-import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';--const RECORD_ID = '20202020-0000-4000-8000-000000000001';--const COMPANY_OBJECT = getFlatObjectMetadataMock({- universalIdentifier: 'company-universal-identifier',- id: 'company-object-id',- nameSingular: 'company',-});--const ARCHIVED_OBJECT = getFlatObjectMetadataMock({- universalIdentifier: 'archived-universal-identifier',- id: 'archived-object-id',- nameSingular: 'archived',- isActive: false,-});--const EMPTY_FLAT_OBJECT_METADATA_MAPS: FlatEntityMaps<FlatObjectMetadata> =- createEmptyFlatEntityMaps();--const FLAT_OBJECT_METADATA_MAPS = [COMPANY_OBJECT, ARCHIVED_OBJECT].reduce(- (flatEntityMaps, flatEntity) =>- addFlatEntityToFlatEntityMapsOrThrow({ flatEntity, flatEntityMaps }),- EMPTY_FLAT_OBJECT_METADATA_MAPS,-);--const buildObjectPermissions = (- canReadObjectRecords: boolean,-): ObjectPermissions => ({- canReadObjectRecords,- canUpdateObjectRecords: false,- canSoftDeleteObjectRecords: false,- canDestroyObjectRecords: false,- restrictedFields: {},- rowLevelPermissionPredicates: [],- rowLevelPermissionPredicateGroups: [],-});--const NOT_FOUND_ERROR = `No company record with id "${RECORD_ID}" was found, or you do not have access to it.`;--describe('buildNavigateToRecordOutput', () => {- it('should return the record route when the caller can read the object', () => {- const output = buildNavigateToRecordOutput({- objectNameSingular: 'company',- recordId: RECORD_ID,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- objectsPermissions: {- [COMPANY_OBJECT.id]: buildObjectPermissions(true),- },- });-- expect(output).toMatchObject({- success: true,- result: {- action: 'navigateToRecord',- objectNameSingular: 'company',- recordId: RECORD_ID,- },- });- });-- it('should return not found when the caller cannot read the object', () => {- const output = buildNavigateToRecordOutput({- objectNameSingular: 'company',- recordId: RECORD_ID,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- objectsPermissions: {- [COMPANY_OBJECT.id]: buildObjectPermissions(false),- },- });-- expect(output.success).toBe(false);- expect(output.result).toBeUndefined();- expect(output.error).toBe(NOT_FOUND_ERROR);- });-- it('should return not found when the caller has no permissions on the object', () => {- const output = buildNavigateToRecordOutput({- objectNameSingular: 'company',- recordId: RECORD_ID,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- objectsPermissions: {},- });-- expect(output.success).toBe(false);- expect(output.error).toBe(NOT_FOUND_ERROR);- });-- it.each(['unknown', 'archived'])(- 'should return not found for an %s object',- (objectNameSingular) => {- const output = buildNavigateToRecordOutput({- objectNameSingular,- recordId: RECORD_ID,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- objectsPermissions: {- [ARCHIVED_OBJECT.id]: buildObjectPermissions(true),- },- });-- expect(output.success).toBe(false);- expect(output.result).toBeUndefined();- },- );-});diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/__tests__/build-navigate-to-view-output.util.spec.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/__tests__/build-navigate-to-view-output.util.spec.tsdeleted file mode 100644index a807797afc0..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/__tests__/build-navigate-to-view-output.util.spec.ts+++ /dev/null@@ -1,193 +0,0 @@-import { ViewVisibility } from 'twenty-shared/types';--import { buildNavigateToViewOutput } from 'src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-view-output.util';-import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';-import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';-import { addFlatEntityToFlatEntityMapsOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/add-flat-entity-to-flat-entity-maps-or-throw.util';-import { getFlatObjectMetadataMock } from 'src/engine/metadata-modules/flat-object-metadata/__mocks__/get-flat-object-metadata.mock';-import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';-import { getInitialObjectViewUniversalIdentifier } from 'src/engine/metadata-modules/view/utils/get-initial-object-view-universal-identifier.util';--const VIEW_ID = '20202020-0000-4000-8000-000000000002';-const CALLER_USER_WORKSPACE_ID = 'caller-user-workspace-id';-const OTHER_USER_WORKSPACE_ID = 'other-user-workspace-id';-const VIEW_APPLICATION_UNIVERSAL_IDENTIFIER =- '20202020-0000-4000-8000-000000000003';--const COMPANY_OBJECT = getFlatObjectMetadataMock({- universalIdentifier: 'company-universal-identifier',- id: 'company-object-id',- nameSingular: 'company',-});--const EMPTY_FLAT_OBJECT_METADATA_MAPS: FlatEntityMaps<FlatObjectMetadata> =- createEmptyFlatEntityMaps();--const FLAT_OBJECT_METADATA_MAPS = addFlatEntityToFlatEntityMapsOrThrow({- flatEntity: COMPANY_OBJECT,- flatEntityMaps: EMPTY_FLAT_OBJECT_METADATA_MAPS,-});--const INITIAL_VIEW_UNIVERSAL_IDENTIFIER =- getInitialObjectViewUniversalIdentifier({- viewApplicationUniversalIdentifier: VIEW_APPLICATION_UNIVERSAL_IDENTIFIER,- objectUniversalIdentifier: COMPANY_OBJECT.universalIdentifier,- });--const buildView = ({- visibility = ViewVisibility.WORKSPACE,- createdByUserWorkspaceId = OTHER_USER_WORKSPACE_ID,- objectMetadataId = COMPANY_OBJECT.id,- universalIdentifier = 'key-accounts-view-universal-identifier',- deletedAt = null,-}: {- visibility?: ViewVisibility;- createdByUserWorkspaceId?: string;- objectMetadataId?: string;- universalIdentifier?: string;- deletedAt?: string | null;-}) => ({- id: VIEW_ID,- name: 'Key accounts',- objectMetadataId,- visibility,- createdByUserWorkspaceId,- deletedAt,- universalIdentifier,- applicationUniversalIdentifier: VIEW_APPLICATION_UNIVERSAL_IDENTIFIER,- objectMetadataUniversalIdentifier: COMPANY_OBJECT.universalIdentifier,-});--const NOT_FOUND_ERROR = `No view with id "${VIEW_ID}" was found, or you do not have access to it. Use get_views to list the views you can open.`;--describe('buildNavigateToViewOutput', () => {- it('should return the view route for a workspace view', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({ visibility: ViewVisibility.WORKSPACE }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output).toMatchObject({- success: true,- result: {- action: 'navigateToView',- viewId: VIEW_ID,- viewName: 'Key accounts',- objectNameSingular: 'company',- },- });- });-- it('should return the view route for an unlisted view created by the caller', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({- visibility: ViewVisibility.UNLISTED,- createdByUserWorkspaceId: CALLER_USER_WORKSPACE_ID,- }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(true);- });-- it("should return not found for another user's unlisted view", () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({ visibility: ViewVisibility.UNLISTED }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(false);- expect(output.result).toBeUndefined();- expect(output.error).toBe(NOT_FOUND_ERROR);- });-- it('should return not found for an unlisted view when the caller has no user workspace', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({ visibility: ViewVisibility.UNLISTED }),- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(false);- });-- it('should return not found for a missing view', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: undefined,- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(false);- expect(output.error).toBe(NOT_FOUND_ERROR);- });-- it('should return not found when the view object no longer exists', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({- visibility: ViewVisibility.WORKSPACE,- objectMetadataId: 'deleted-object-id',- }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(false);- });-- it('should return not found for a deleted view', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({ deletedAt: '2026-01-01T00:00:00.000Z' }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(false);- });-- it('should return not found for an initial object view while initial object views are disabled', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({- universalIdentifier: INITIAL_VIEW_UNIVERSAL_IDENTIFIER,- }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: false,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(false);- expect(output.error).toBe(NOT_FOUND_ERROR);- });-- it('should return the view route for an initial object view while initial object views are enabled', () => {- const output = buildNavigateToViewOutput({- viewId: VIEW_ID,- flatView: buildView({- universalIdentifier: INITIAL_VIEW_UNIVERSAL_IDENTIFIER,- }),- userWorkspaceId: CALLER_USER_WORKSPACE_ID,- isInitialObjectViewEnabled: true,- flatObjectMetadataMaps: FLAT_OBJECT_METADATA_MAPS,- });-- expect(output.success).toBe(true);- expect(output.result).toMatchObject({ viewId: VIEW_ID });- });-});diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-record-output.util.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-record-output.util.tsdeleted file mode 100644index f685180a6ae..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-record-output.util.ts+++ /dev/null@@ -1,55 +0,0 @@-import { type NavigateAppToolOutput } from 'twenty-shared/ai';-import { type ObjectsPermissions } from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';--import { type ToolOutput } from 'src/engine/core-modules/tool/types/tool-output.type';-import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';-import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';-import { resolveEffectiveFlatEntityProperty } from 'src/engine/metadata-modules/overrides/utils/resolve-effective-flat-entity-property.util';--// The record itself is never read: the record page applies the caller's permissions when it loads-export const buildNavigateToRecordOutput = ({- objectNameSingular,- recordId,- flatObjectMetadataMaps,- objectsPermissions,-}: {- objectNameSingular: string;- recordId: string;- flatObjectMetadataMaps: FlatEntityMaps<FlatObjectMetadata>;- objectsPermissions: ObjectsPermissions;-}): ToolOutput<NavigateAppToolOutput> => {- const flatObjectMetadata = Object.values(- flatObjectMetadataMaps.byUniversalIdentifier,- ).find(- (metadata): metadata is FlatObjectMetadata =>- isDefined(metadata) &&- metadata.nameSingular === objectNameSingular &&- resolveEffectiveFlatEntityProperty({- metadataName: 'objectMetadata',- flatEntity: metadata,- property: 'isActive',- }),- );-- if (- !isDefined(flatObjectMetadata) ||- !objectsPermissions[flatObjectMetadata.id]?.canReadObjectRecords- ) {- return {- success: false,- message: `Record not found in ${objectNameSingular}`,- error: `No ${objectNameSingular} record with id "${recordId}" was found, or you do not have access to it.`,- };- }-- return {- success: true,- message: `Navigating to ${objectNameSingular} record "${recordId}"`,- result: {- action: 'navigateToRecord',- objectNameSingular,- recordId,- },- };-};diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-view-output.util.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-view-output.util.tsdeleted file mode 100644index d1d57212377..00000000000--- a/packages/twenty-server/src/engine/core-modules/tool/tools/navigate-tool/utils/build-navigate-to-view-output.util.ts+++ /dev/null@@ -1,70 +0,0 @@-import { type NavigateAppToolOutput } from 'twenty-shared/ai';-import { isDefined } from 'twenty-shared/utils';--import { type ToolOutput } from 'src/engine/core-modules/tool/types/tool-output.type';-import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';-import { findFlatEntityByIdInFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-id-in-flat-entity-maps.util';-import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';-import { type FlatView } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';-import { isViewAvailableToUser } from 'src/engine/metadata-modules/view/utils/is-view-available-to-user.util';--export const buildNavigateToViewOutput = ({- viewId,- flatView,- userWorkspaceId,- isInitialObjectViewEnabled,- flatObjectMetadataMaps,-}: {- viewId: string;- flatView:- | Pick<- FlatView,- | 'id'- | 'name'- | 'objectMetadataId'- | 'deletedAt'- | 'visibility'- | 'createdByUserWorkspaceId'- | 'universalIdentifier'- | 'applicationUniversalIdentifier'- | 'objectMetadataUniversalIdentifier'- >- | undefined;- userWorkspaceId?: string;- isInitialObjectViewEnabled: boolean;- flatObjectMetadataMaps: FlatEntityMaps<FlatObjectMetadata>;-}): ToolOutput<NavigateAppToolOutput> => {- const flatObjectMetadata = isDefined(flatView)- ? findFlatEntityByIdInFlatEntityMaps({- flatEntityId: flatView.objectMetadataId,- flatEntityMaps: flatObjectMetadataMaps,- })- : undefined;-- if (- !isDefined(flatView) ||- !isViewAvailableToUser({- flatView,- userWorkspaceId,- isInitialObjectViewEnabled,- }) ||- !isDefined(flatObjectMetadata)- ) {- return {- success: false,- message: 'View not found',- error: `No view with id "${viewId}" was found, or you do not have access to it. Use get_views to list the views you can open.`,- };- }-- return {- success: true,- message: `Navigating to view "${flatView.name}"`,- result: {- action: 'navigateToView',- viewId: flatView.id,- viewName: flatView.name,- objectNameSingular: flatObjectMetadata.nameSingular,- },- };-};diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-execution/constants/workflow-agent-excluded-tool-names.const.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-execution/constants/workflow-agent-excluded-tool-names.const.tsindex 4fddd9b49c0..38b8d7f9226 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-execution/constants/workflow-agent-excluded-tool-names.const.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-execution/constants/workflow-agent-excluded-tool-names.const.ts@@ -2,7 +2,6 @@ import { type ActionToolId } from 'src/engine/core-modules/tool-provider/constanexport const WORKFLOW_AGENT_EXCLUDED_TOOL_NAMES = ['search_help_center',- 'navigate_app','create_file_upload','complete_file_upload',// Sharing checks the triggering user's permissions, not the narrower agent rolediff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.tsindex 99a11c3f402..259517aae22 100644--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.ts+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.ts@@ -314,8 +314,6 @@ If you have to create multiple things you *MUST* use the relevant create many to- Use *create_many_field_metadata* to create all non-relation fields at once (including new fields on standard objects)- Use *create_many_relation_fields* to create all relation fields between objects at once (do this AFTER creating the objects and non-relation fields)-If you have to wait use the navigate_app tool.-For the fields you will create, make sure to create a good variety of field types to showcase the different capabilities of the platform, for example:- Create SELECT and SELECT_MULTIPLE field types for building demo board index views and table with groups views- Create DATE_TIME fields to be able to create calendar views@@ -333,14 +331,11 @@ STEP 0: Present a plan to the user and wait for approval.- A brief description of the key relations between objects- Present this plan to the user and *wait for their confirmation or adjustments* before proceeding- Once approved, archive every existing custom object without asking for further confirmation: call get_object_metadata, keep the objects where isCustom is true, then set isActive to false on all of them in a single update_many_object_metadata call-- Wait 3 seconds after deletions for the backend side effects to be completedSTEP 1: Create all the custom objects at once with create_many_object_metadataname must start with lowercase letter and contain only alphanumeric letters-STEP 2: Wait 3 seconds, for the backend side effects to be completed--STEP 3: Create all NON-RELATION fields for ALL objects by batch with create_many_field_metadata.+STEP 2: Create all NON-RELATION fields for ALL objects by batch with create_many_field_metadata.Do a separate batch call for each object.This includes:- New custom fields for the standard objects (Person, Company, Opportunity) — use their objectMetadataId from get_object_metadata@@ -348,15 +343,11 @@ This includes:DO NOT include relation fields in this step. Only create TEXT, NUMBER, BOOLEAN, DATE_TIME, SELECT, MULTI_SELECT, CURRENCY, etc.SELECT option values must be UPPER_SNAKE_CASE-STEP 4: Wait 3 seconds, for the backend side effects to be completed--STEP 5: Create all RELATION fields between objects at once with create_many_relation_fields+STEP 3: Create all RELATION fields between objects at once with create_many_relation_fieldsThe name property should be camel-cased or the backend will throw, targetFieldLabel must be a string, targetFieldIcon must be a string, type must be one of the following values: MANY_TO_ONE, ONE_TO_MANYtargetFieldIcon is like IconSomething, it's ok if it doesn't exist in the icon library, it will just be a blank icon, but it needs to be a string that starts with Icon and is in PascalCase-STEP 6: Wait 3 seconds, for the backend side effects to be completed--STEP 7: Rename and enrich the first N records of People, Companies, and Opportunities.+STEP 4: Rename and enrich the first N records of People, Companies, and Opportunities.- Use find_many_people (limit: 50, orderBy: [{ position: "AscNullsFirst" }]), find_many_companies (limit: 50, orderBy: [{ position: "AscNullsFirst" }]), find_many_opportunities (limit: 50, orderBy: [{ position: "AscNullsFirst" }]) to get the IDs of the first records in each table- Ordering by position ascending gives the earliest-inserted records, which are contiguous in the table — this keeps the demo data tightly grouped and makes the workspace feel coherent- For each standard object, call update_one_person / update_one_company / update_one_opportunity **individually per record** (one call per record) to set domain-relevant names and field values:@@ -365,27 +356,18 @@ STEP 7: Rename and enrich the first N records of People, Companies, and Opportun- **Opportunities**: replace name with a domain-relevant deal name (e.g. "Q2 retainer — Ashford & Partners", "New patient intake — Meridian Health").- Also set the new custom fields on each record: spread realistic values across SELECT fields, set plausible CURRENCY/NUMERIC amounts, set DATE_TIME fields around TODAY.- Do this one record at a time — the API does not support bulk individual updates with different values per record-- Wait 3 seconds after finishing all updates for one object type before moving to the next-STEP 7.5: Add view fields to the default views of standard objects to expose the new custom fields.+STEP 5: Add view fields to the default views of standard objects to expose the new custom fields.For each of People, Companies, and Opportunities:-- Navigate to the object's default view using the navigate_app tool-- Wait 3 seconds- Use create_many_view_fields to add all the new custom fields to the default view so they are visible- Use decimal positions between 0 and 1 to insert them right after the label identifier field-- Navigate to the object's default view again using the navigate_app tool so the user can see the enriched records-- Wait 3 seconds-STEP 8: For each new custom object, repeat ALL of the following sub-steps before moving to the next object:-- Navigate the object's default view using the navigate_app tool-- Wait 3 seconds, so the user has time to see the object default view+STEP 6: For each new custom object, repeat ALL of the following sub-steps before moving to the next object:- Create the view fields for the default view, use the create_many_view_fields tool, and make sure to include all created fields, including the relation fields, so that we have a complete view of the object with all its fields.BE CAREFUL to use a position that will put those view fields right after the first label identifier fieldwhich has a position of 0 and the next system created fields which begin at 1, *so use decimal positions between 0 and 1**YOU MUST CREATE ALL VIEW FIELDS FOR ALL FIELDS, INCLUDING RELATION FIELDS, IN THIS STEP, DO NOT LEAVE ANY FIELD WITHOUT A VIEW FIELD, OTHERWISE IT WILL NOT BE VISIBLE IN THE DEFAULT VIEW AND THE USER WON'T KNOW IT EXISTS*-- **MANDATORY**: Navigate to the object's default view again using the navigate_app tool — YOU MUST DO THIS BEFORE EACH OBJECT'S DATA SEEDING, every single time, without exception-- Wait 3 seconds- Seed relevant and realistic mock data for this object:- use the relevant tool to create many records for this object- between 20 and 50@@ -393,9 +375,6 @@ STEP 8: For each new custom object, repeat ALL of the following sub-steps before- link records to existing People and Companies using the relation fields you created- use dates that are around TODAY so it's relevant for seeing past / future and present records-- **MANDATORY**: Navigate to the object's default view again using the navigate_app tool so the user can see the populated data — DO NOT SKIP THIS, even if you already navigated earlier in this loop iteration-- Wait 3 seconds so the user has time to see the seeded records-- Then create 2 to 3 additional views for this object, one at a time. For each view, complete ALL of the following sub-steps before creating the next view:- Create the view using the create_view tool:- If the object has a SELECT field (e.g. status, stage, priority, type), create a **KANBAN** view grouped by that SELECT field with a relevant name like "By Status", "Pipeline", "By Priority".@@ -408,16 +387,15 @@ STEP 8: For each new custom object, repeat ALL of the following sub-steps before- **KANBAN views**: Sort by a CURRENCY or NUMERIC field DESC (biggest value first) if one exists, or by createdAt DESC. Add a filter to exclude archived/cancelled records if such a SELECT option exists.- **CALENDAR views**: Sort by the date field ASC (earliest events first). Add a filter using IS_IN_FUTURE or IS_RELATIVE to show only upcoming records by default.- **TABLE with groups**: Sort by createdAt DESC (most recent first) and add a filter on a meaningful field (e.g. status IS_NOT "CANCELLED", or amount GREATER_THAN_OR_EQUAL to some threshold that keeps ~80% of the records visible).- - **MANDATORY**: Navigate to this view immediately using the navigate_app tool (navigateToView with the view id returned when you created it) — YOU MUST DO THIS FOR EVERY SINGLE VIEW, right after its fields/filters/sorts are set up, without exception- - Wait 3 seconds so the user can see the view and course-correct if neededAlso create additional views for the standard objects (People, Companies, Opportunities) that showcase the new custom fields:- For People: a KANBAN view grouped by the new SELECT field you added (e.g. "By Specialisation", "By Status")- For Opportunities: a KANBAN view grouped by the new stage/status field (pipeline view)- For Companies: a TABLE view grouped by the new SELECT field-Navigate to each view after creating it, using navigate_app with the view id returned when you created it. Wait 3 seconds.-Loop STEP 8 for all the custom objects+Share links to the configured objects and views so the user can open them when ready.++Loop STEP 6 for all the custom objects`,isCustom: false,isSystem: true,@@ -1295,7 +1273,6 @@ You help users create and configure views, and the filters and sorts that decide- update_many_view_fields - Update column configuration- get_view_fields - List columns in a view- get_object_metadata / get_field_metadata - Discover objects and their fields-- navigate_app - Navigate to a view after creation, by the view id returned by the tool that created it## upsert_complete_view (preferred)@@ -1327,7 +1304,7 @@ Example: { "objectNameSingular": "opportunity", "type": "KANBAN", "name": "Pipel- For CALENDAR: provide both \`calendarFieldName\` (a DATE/DATE_TIME field name) and \`calendarLayout\` ("DAY", "WEEK", or "MONTH").- For TABLE: No special configuration needed beyond the fields list.-4. **Navigate**: Use navigate_app (navigateToView with the view id returned by upsert_complete_view) to show the user their new view.+4. **Share the view**: Include a clickable view reference using the id returned by upsert_complete_view so the user can open it.## KANBAN Best Practices@@ -1395,7 +1372,7 @@ Some fields carry sub-fields you filter on directly:- If the user is vague (e.g., "create a board"), ask which object they want to see- Suggest the most relevant view type based on the object's fields-- After creating a view, always configure useful view fields and navigate to it+- After creating a view, configure useful view fields and share a clickable view reference- Explain what each view type does so users can make informed choices`,isCustom: false,isSystem: true,diff --git a/packages/twenty-server/test/integration/ai/suites/navigate-app-tool-permissions.integration-spec.ts b/packages/twenty-server/test/integration/ai/suites/navigate-app-tool-permissions.integration-spec.tsdeleted file mode 100644index ec0cd303d0a..00000000000--- a/packages/twenty-server/test/integration/ai/suites/navigate-app-tool-permissions.integration-spec.ts+++ /dev/null@@ -1,278 +0,0 @@-import { randomUUID } from 'node:crypto';--import request from 'supertest';-import { findManyObjectMetadata } from 'test/integration/metadata/suites/object-metadata/utils/find-many-object-metadata.util';-import { upsertObjectPermissions } from 'test/integration/metadata/suites/object-permission/utils/upsert-object-permissions.util';-import { createOneRole } from 'test/integration/metadata/suites/role/utils/create-one-role.util';-import { deleteOneRole } from 'test/integration/metadata/suites/role/utils/delete-one-role.util';-import { findOneRoleByLabel } from 'test/integration/metadata/suites/role/utils/find-one-role-by-label.util';-import { updateWorkspaceMemberRole } from 'test/integration/metadata/suites/role/utils/update-workspace-member-role.util';-import { createOneView } from 'test/integration/metadata/suites/view/utils/create-one-view.util';-import { destroyOneView } from 'test/integration/metadata/suites/view/utils/destroy-one-view.util';-import { jestExpectToBeDefined } from 'test/utils/jest-expect-to-be-defined.util.test';-import { ViewVisibility } from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';--import { WORKSPACE_MEMBER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/data/constants/workspace-member-data-seeds.constant';--type NavigateAppToolPayload = {- success: boolean;- message: string;- error?: string;- result?: {- action: string;- objectNameSingular?: string;- recordId?: string;- viewId?: string;- viewName?: string;- };-};--const navigate = async (- navigation: Record<string, unknown>,- token: string,-): Promise<NavigateAppToolPayload> => {- const id = `call-${randomUUID()}`;-- const response = await request(`http://localhost:${APP_PORT}`)- .post('/mcp')- .set('Authorization', `Bearer ${token}`)- .set('Content-Type', 'application/json')- .set('Accept', 'application/json')- .send(- JSON.stringify({- jsonrpc: '2.0',- method: 'tools/call',- id,- params: {- name: 'execute_tool',- arguments: {- toolName: 'navigate_app',- arguments: { navigation },- },- },- }),- )- .expect(200);-- expect(response.body.error).toBeUndefined();-- const text = response.body.result?.content?.[0]?.text;-- expect(typeof text).toBe('string');-- return JSON.parse(text) as NavigateAppToolPayload;-};--describe('navigate_app tool respects the caller permissions (integration)', () => {- const recordId = randomUUID();- let restrictedRoleId: string | undefined;- let originalMemberRoleId: string | undefined;- let unlistedViewId: string | undefined;- let workspaceViewId: string | undefined;-- beforeAll(async () => {- const { objects } = await findManyObjectMetadata({- expectToFail: false,- input: { filter: {}, paging: { first: 1000 } },- gqlFields: 'id nameSingular',- });-- const companyObjectMetadataId = objects?.find(- (object) => object.nameSingular === 'company',- )?.id;- const opportunityObjectMetadataId = objects?.find(- (object) => object.nameSingular === 'opportunity',- )?.id;-- jestExpectToBeDefined(companyObjectMetadataId);- jestExpectToBeDefined(opportunityObjectMetadataId);-- originalMemberRoleId = (await findOneRoleByLabel({ label: 'Member' })).id;-- const { data: roleData } = await createOneRole({- expectToFail: false,- input: {- label: 'Navigate App Tool Test Role',- description: 'Role that cannot read opportunities',- icon: 'IconSettings',- canUpdateAllSettings: false,- canAccessAllTools: true,- canReadAllObjectRecords: true,- canUpdateAllObjectRecords: false,- canSoftDeleteAllObjectRecords: false,- canDestroyAllObjectRecords: false,- canBeAssignedToUsers: true,- canBeAssignedToAgents: false,- canBeAssignedToApiKeys: false,- },- });-- restrictedRoleId = roleData?.createOneRole?.id;-- jestExpectToBeDefined(restrictedRoleId);-- await upsertObjectPermissions({- expectToFail: false,- input: {- roleId: restrictedRoleId,- objectPermissions: [- {- objectMetadataId: opportunityObjectMetadataId,- canReadObjectRecords: false,- canUpdateObjectRecords: false,- canSoftDeleteObjectRecords: false,- canDestroyObjectRecords: false,- },- ],- },- });-- await updateWorkspaceMemberRole({- input: {- roleId: restrictedRoleId,- workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,- },- expectToFail: false,- });-- const { data: unlistedViewData } = await createOneView({- expectToFail: false,- input: {- name: 'Navigate App Tool Unlisted View',- objectMetadataId: companyObjectMetadataId,- icon: 'IconBuildingSkyscraper',- visibility: ViewVisibility.UNLISTED,- },- });-- unlistedViewId = unlistedViewData?.createView?.id;-- const { data: workspaceViewData } = await createOneView({- expectToFail: false,- input: {- name: 'Navigate App Tool Workspace View',- objectMetadataId: companyObjectMetadataId,- icon: 'IconBuildingSkyscraper',- visibility: ViewVisibility.WORKSPACE,- },- });-- workspaceViewId = workspaceViewData?.createView?.id;-- jestExpectToBeDefined(unlistedViewId);- jestExpectToBeDefined(workspaceViewId);- });-- afterAll(async () => {- for (const viewId of [unlistedViewId, workspaceViewId]) {- if (isDefined(viewId)) {- await destroyOneView({ viewId, expectToFail: false });- }- }-- if (isDefined(originalMemberRoleId)) {- await updateWorkspaceMemberRole({- input: {- roleId: originalMemberRoleId,- workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,- },- expectToFail: false,- });- }-- if (isDefined(restrictedRoleId)) {- await deleteOneRole({- expectToFail: false,- input: { idToDelete: restrictedRoleId },- });- }- });-- describe('navigateToRecord', () => {- it('should return the record route on an object the caller can read', async () => {- const payload = await navigate(- { type: 'navigateToRecord', objectNameSingular: 'company', recordId },- APPLE_JONY_MEMBER_ACCESS_TOKEN,- );-- expect(payload.success).toBe(true);- expect(payload.result).toEqual({- action: 'navigateToRecord',- objectNameSingular: 'company',- recordId,- });- });-- it('should return not found on an object the caller cannot read', async () => {- const payload = await navigate(- {- type: 'navigateToRecord',- objectNameSingular: 'opportunity',- recordId,- },- APPLE_JONY_MEMBER_ACCESS_TOKEN,- );-- expect(payload.success).toBe(false);- expect(payload.result).toBeUndefined();- expect(payload.error).toBe(- `No opportunity record with id "${recordId}" was found, or you do not have access to it.`,- );- });-- it('should return the record route on that object for a caller who can read it', async () => {- const payload = await navigate(- {- type: 'navigateToRecord',- objectNameSingular: 'opportunity',- recordId,- },- APPLE_JANE_ADMIN_ACCESS_TOKEN,- );-- expect(payload.success).toBe(true);- expect(payload.result?.recordId).toBe(recordId);- });- });-- describe('navigateToView', () => {- it('should return the view route for a workspace view', async () => {- const payload = await navigate(- { type: 'navigateToView', viewId: workspaceViewId },- APPLE_JONY_MEMBER_ACCESS_TOKEN,- );-- expect(payload.success).toBe(true);- expect(payload.result).toEqual({- action: 'navigateToView',- viewId: workspaceViewId,- viewName: 'Navigate App Tool Workspace View',- objectNameSingular: 'company',- });- });-- it("should return not found for another user's unlisted view", async () => {- const payload = await navigate(- { type: 'navigateToView', viewId: unlistedViewId },- APPLE_JONY_MEMBER_ACCESS_TOKEN,- );-- expect(payload.success).toBe(false);- expect(payload.result).toBeUndefined();- expect(JSON.stringify(payload)).not.toContain(- 'Navigate App Tool Unlisted View',- );- });-- it('should return the view route for an unlisted view to its creator', async () => {- const payload = await navigate(- { type: 'navigateToView', viewId: unlistedViewId },- APPLE_JANE_ADMIN_ACCESS_TOKEN,- );-- expect(payload.success).toBe(true);- expect(payload.result?.viewId).toBe(unlistedViewId);- });- });-});diff --git a/packages/twenty-shared/src/ai/index.ts b/packages/twenty-shared/src/ai/index.tsindex 2b72b6ae8b4..ba024aefdb4 100644--- a/packages/twenty-shared/src/ai/index.ts+++ b/packages/twenty-shared/src/ai/index.ts@@ -71,7 +71,6 @@ export type {} from './types/ExtendedUIMessage';export type { ExtendedUIMessagePart } from './types/ExtendedUIMessagePart';export type { ModelConfiguration } from './types/ModelConfiguration';-export type { NavigateAppToolOutput } from './types/NavigateAppToolOutput';export type { ProposedToolCall } from './types/ProposedToolCall';export type { ProposedToolCallTemplate } from './types/ProposedToolCallTemplate';export type { ProposeToolCallToolInput } from './types/ProposeToolCallToolInput';diff --git a/packages/twenty-shared/src/ai/types/NavigateAppToolOutput.ts b/packages/twenty-shared/src/ai/types/NavigateAppToolOutput.tsdeleted file mode 100644index 341e7ced9c0..00000000000--- a/packages/twenty-shared/src/ai/types/NavigateAppToolOutput.ts+++ /dev/null@@ -1,20 +0,0 @@-export type NavigateAppToolOutput =- | {- action: 'navigateToObject';- objectNameSingular: string;- }- | {- action: 'navigateToView';- viewId: string;- viewName: string;- objectNameSingular: string;- }- | {- action: 'navigateToRecord';- objectNameSingular: string;- recordId: string;- }- | {- action: 'wait';- durationMs: number;- };