Skip to content

The open alternative to Salesforce, designed for AI.

Pin Ask AI globally and open new chats in full page (#25005)

Félix Malfait2e6ad27b3792
diff --git a/packages/twenty-front/src/modules/ai/hooks/__tests__/useOpenAiChatPage.test.tsx b/packages/twenty-front/src/modules/ai/hooks/__tests__/useOpenAiChatPage.test.tsx
new file mode 100644
index 00000000000..3a547664ea0
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/hooks/__tests__/useOpenAiChatPage.test.tsx
@@ -0,0 +1,104 @@
+import { act, renderHook } from '@testing-library/react';
+import { Provider as JotaiProvider } from 'jotai';
+import { type ReactNode } from 'react';
+
+import { useOpenAiChatPage } from '@/ai/hooks/useOpenAiChatPage';
+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
+
+const navigateMock = jest.fn();
+const closeSidePanelMenuMock = jest.fn();
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useNavigate: () => navigateMock,
+}));
+
+jest.mock('@/side-panel/hooks/useSidePanelMenu', () => ({
+ useSidePanelMenu: () => ({ closeSidePanelMenu: closeSidePanelMenuMock }),
+}));
+
+const Wrapper = ({ children }: { children: ReactNode }) => (
+ <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>
+);
+
+describe('useOpenAiChatPage', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ window.history.pushState({}, '', '/objects/people');
+ });
+
+ it('should open a new chat and remember where to collapse back to', () => {
+ const { result } = renderHook(() => useOpenAiChatPage(), {
+ wrapper: Wrapper,
+ });
+
+ act(() => {
+ result.current.openAiChatPage();
+ });
+
+ expect(closeSidePanelMenuMock).toHaveBeenCalled();
+ expect(navigateMock).toHaveBeenCalledWith('/chat', {
+ state: { returnLocation: '/objects/people' },
+ });
+ });
+
+ it('should keep the current view and query in the return location', () => {
+ window.history.pushState({}, '', '/objects/people?viewId=42');
+
+ const { result } = renderHook(() => useOpenAiChatPage(), {
+ wrapper: Wrapper,
+ });
+
+ act(() => {
+ result.current.openAiChatPage();
+ });
+
+ expect(navigateMock).toHaveBeenCalledWith('/chat', {
+ state: { returnLocation: '/objects/people?viewId=42' },
+ });
+ });
+
+ it('should open an existing thread', () => {
+ const { result } = renderHook(() => useOpenAiChatPage(), {
+ wrapper: Wrapper,
+ });
+
+ act(() => {
+ result.current.openAiChatPage({
+ threadId: '20202020-0000-4000-8000-000000000001',
+ });
+ });
+
+ expect(navigateMock).toHaveBeenCalledWith(
+ '/chat/20202020-0000-4000-8000-000000000001',
+ expect.anything(),
+ );
+ });
+
+ it('should ignore a draft thread that has no thread id yet', () => {
+ const { result } = renderHook(() => useOpenAiChatPage(), {
+ wrapper: Wrapper,
+ });
+
+ act(() => {
+ result.current.openAiChatPage({ threadId: 'new-thread-draft' });
+ });
+
+ expect(navigateMock).toHaveBeenCalledWith('/chat', expect.anything());
+ });
+
+ it('should not navigate while already on the AI chat page', () => {
+ window.history.pushState({}, '', '/chat');
+
+ const { result } = renderHook(() => useOpenAiChatPage(), {
+ wrapper: Wrapper,
+ });
+
+ act(() => {
+ result.current.openAiChatPage();
+ });
+
+ expect(navigateMock).not.toHaveBeenCalled();
+ expect(closeSidePanelMenuMock).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-front/src/modules/ai/hooks/useOpenAiChatPage.ts b/packages/twenty-front/src/modules/ai/hooks/useOpenAiChatPage.ts
new file mode 100644
index 00000000000..124d929b886
--- /dev/null
+++ b/packages/twenty-front/src/modules/ai/hooks/useOpenAiChatPage.ts
@@ -0,0 +1,42 @@
+import { AppPath } from 'twenty-shared/types';
+import { isDefined, isValidUuid } from 'twenty-shared/utils';
+
+import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
+import { useNavigateApp } from '~/hooks/useNavigateApp';
+import { isCurrentPathAiChatPage } from '~/utils/isCurrentPathAiChatPage';
+
+export const useOpenAiChatPage = () => {
+ const navigate = useNavigateApp();
+ const { closeSidePanelMenu } = useSidePanelMenu();
+
+ const openAiChatPage = ({
+ threadId,
+ }: {
+ threadId?: string | null;
+ } = {}) => {
+ if (isCurrentPathAiChatPage()) {
+ return;
+ }
+
+ void closeSidePanelMenu();
+
+ navigate(
+ AppPath.AiChat,
+ {
+ threadId:
+ isDefined(threadId) && isValidUuid(threadId) ? threadId : null,
+ },
+ undefined,
+ {
+ state: {
+ // Read from the window rather than useLocation so that opening a new
+ // chat does not require a router context from every caller of
+ // useSwitchToNewAiChat, front components included.
+ returnLocation: `${window.location.pathname}${window.location.search}${window.location.hash}`,
+ },
+ },
+ );
+ };
+
+ return { openAiChatPage };
+};
diff --git a/packages/twenty-front/src/modules/ai/hooks/useSwitchToNewAiChat.ts b/packages/twenty-front/src/modules/ai/hooks/useSwitchToNewAiChat.ts
index 7b273435bf3..7649d709a8a 100644
--- a/packages/twenty-front/src/modules/ai/hooks/useSwitchToNewAiChat.ts
+++ b/packages/twenty-front/src/modules/ai/hooks/useSwitchToNewAiChat.ts
@@ -1,5 +1,6 @@
import { useStore } from 'jotai';
+import { useOpenAiChatPage } from '@/ai/hooks/useOpenAiChatPage';
import { useSelectAiChatThread } from '@/ai/hooks/useSelectAiChatThread';
import { AGENT_CHAT_NEW_THREAD_DRAFT_KEY } from '@/ai/states/agentChatDraftsByThreadIdState';
import { shouldFocusChatEditorState } from '@/ai/states/shouldFocusChatEditorState';
@@ -8,19 +9,32 @@ import { threadIdCreatedFromDraftState } from '@/ai/states/threadIdCreatedFromDr
import { useOpenAskAiPageInSidePanel } from '@/side-panel/hooks/useOpenAskAiPageInSidePanel';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
-export const useSwitchToNewAiChat = () => {
+type UseSwitchToNewAiChatParams = {
+ shouldOpenInFullPage?: boolean;
+};
+
+export const useSwitchToNewAiChat = ({
+ shouldOpenInFullPage = false,
+}: UseSwitchToNewAiChatParams = {}) => {
const setThreadIdCreatedFromDraft = useSetAtomState(
threadIdCreatedFromDraftState,
);
const { selectAiChatThread } = useSelectAiChatThread();
const store = useStore();
const { openAskAiPage } = useOpenAskAiPageInSidePanel();
+ const { openAiChatPage } = useOpenAiChatPage();
const switchToNewChat = () => {
setThreadIdCreatedFromDraft(null);
store.set(hasTriggeredCreateForDraftState.atom, false);
selectAiChatThread(AGENT_CHAT_NEW_THREAD_DRAFT_KEY);
- openAskAiPage();
+
+ if (shouldOpenInFullPage) {
+ openAiChatPage();
+ } else {
+ openAskAiPage();
+ }
+
store.set(shouldFocusChatEditorState.atom, true);
};
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
index 67bebf506bb..0c69b1fc8f9 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
@@ -149,7 +149,9 @@ export const MainNavigationDrawerTabsRow = ({
const { theme } = useContext(ThemeContext);
const [navigationDrawerActiveTab, setNavigationDrawerActiveTab] =
useAtomState(navigationDrawerActiveTabState);
- const { switchToNewChat } = useSwitchToNewAiChat();
+ const { switchToNewChat } = useSwitchToNewAiChat({
+ shouldOpenInFullPage: true,
+ });
const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
const isExpanded = useIsNavigationDrawerContentExpanded();
@@ -171,6 +173,7 @@ export const MainNavigationDrawerTabsRow = ({
};
const handleNewChatClick = () => {
+ setNavigationDrawerActiveTab(NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY);
switchToNewChat();
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/ask-ai/hooks/useExpandAskAiSidePanelPage.ts b/packages/twenty-front/src/modules/side-panel/pages/ask-ai/hooks/useExpandAskAiSidePanelPage.ts
index 21a2b072a13..8c6e0a7e995 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/ask-ai/hooks/useExpandAskAiSidePanelPage.ts
+++ b/packages/twenty-front/src/modules/side-panel/pages/ask-ai/hooks/useExpandAskAiSidePanelPage.ts
@@ -1,42 +1,20 @@
import { useLingui } from '@lingui/react/macro';
-import { useLocation } from 'react-router-dom';
-import { AppPath } from 'twenty-shared/types';
-import { isDefined, isValidUuid } from 'twenty-shared/utils';
+import { useOpenAiChatPage } from '@/ai/hooks/useOpenAiChatPage';
import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';
-import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
import { type SidePanelExpandTarget } from '@/side-panel/types/SidePanelExpandTarget';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useNavigateApp } from '~/hooks/useNavigateApp';
export const useExpandAskAiSidePanelPage = (): SidePanelExpandTarget => {
const { t } = useLingui();
- const navigate = useNavigateApp();
- const location = useLocation();
const currentAiChatThread = useAtomStateValue(currentAiChatThreadState);
- const { closeSidePanelMenu } = useSidePanelMenu();
+ const { openAiChatPage } = useOpenAiChatPage();
return {
label: t`Expand chat`,
hasExpandShortcut: false,
expand: () => {
- void closeSidePanelMenu();
-
- navigate(
- AppPath.AiChat,
- {
- threadId:
- isDefined(currentAiChatThread) && isValidUuid(currentAiChatThread)
- ? currentAiChatThread
- : null,
- },
- undefined,
- {
- state: {
- returnLocation: `${location.pathname}${location.search}${location.hash}`,
- },
- },
- );
+ openAiChatPage({ threadId: currentAiChatThread });
},
};
};
diff --git a/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts b/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts
index 722c0f365c2..74727162f28 100644
--- a/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts
+++ b/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts
@@ -901,7 +901,7 @@ export const mockedCommandMenuItems: CommandMenuItemFieldsFragment[] =
"frontComponentId": null,
"engineComponentKey": "ASK_AI",
"position": 43,
- "isPinned": false,
+ "isPinned": true,
"payload": null,
"hotKeys": [
"@"
@@ -914,7 +914,7 @@ export const mockedCommandMenuItems: CommandMenuItemFieldsFragment[] =
"frontComponent": null,
"label": "Ask AI",
"icon": "IconSparkles",
- "shortLabel": "Ask AI"
+ "shortLabel": null
},
{
"__typename": "CommandMenuItem",
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-upgrade-version-command.module.ts
index bcc6b8b1e89..59c08f8cfc2 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-upgrade-version-command.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-upgrade-version-command.module.ts
@@ -6,6 +6,7 @@ import { AddBlocklistScopeFieldCommand } from 'src/database/commands/upgrade-ver
import { EnableEditLayoutAcrossAppCommand } from 'src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787906715270-enable-edit-layout-across-app.command';
import { BackfillLinkedTimelineActivityHappensAtCommand } from 'src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787914663665-backfill-linked-timeline-activity-happens-at.command';
import { ConfigureTimelineActivityHappensAtCommand } from 'src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787918663365-configure-timeline-activity-happens-at.command';
+import { PinAskAiCommandMenuItemCommand } from 'src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787938100000-pin-ask-ai-command-menu-item.command';
import { ApplicationModule } from 'src/engine/core-modules/application/application.module';
import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-schema-manager/workspace-schema-manager.module';
import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
@@ -27,6 +28,7 @@ import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace
EnableEditLayoutAcrossAppCommand,
BackfillLinkedTimelineActivityHappensAtCommand,
ConfigureTimelineActivityHappensAtCommand,
+ PinAskAiCommandMenuItemCommand,
],
})
export class V2_38_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787938100000-pin-ask-ai-command-menu-item.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787938100000-pin-ask-ai-command-menu-item.command.ts
new file mode 100644
index 00000000000..b101e764961
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/2-38-workspace-command-1787938100000-pin-ask-ai-command-menu-item.command.ts
@@ -0,0 +1,78 @@
+import { Command } from 'nest-commander';
+import { TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER } from 'twenty-shared/application';
+import { isDefined } from 'twenty-shared/utils';
+
+import { ProvisionedWorkspaceCommandRunner } from 'src/database/commands/command-runners/provisioned-workspace.command-runner';
+import { WorkspaceIteratorService } from 'src/database/commands/command-runners/workspace-iterator.service';
+import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspace.command-runner';
+import { buildPinAskAiCommandMenuItemUpdate } from 'src/database/commands/upgrade-version-command/2-38/utils/build-pin-ask-ai-command-menu-item-update.util';
+import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';
+import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
+import { STANDARD_COMMAND_MENU_ITEMS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant';
+import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager/workspace-migration/exceptions/workspace-migration-builder-exception';
+import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';
+
+@RegisteredWorkspaceCommand('2.38.0', 1787938100000)
+@Command({
+ name: 'upgrade:2-38:pin-ask-ai-command-menu-item',
+ description:
+ 'Pin the Ask AI command to page headers as an icon-only action across the app',
+})
+export class PinAskAiCommandMenuItemCommand extends ProvisionedWorkspaceCommandRunner {
+ constructor(
+ protected readonly workspaceIteratorService: WorkspaceIteratorService,
+ private readonly workspaceCacheService: WorkspaceCacheService,
+ private readonly workspaceMigrationValidateBuildAndRunService: WorkspaceMigrationValidateBuildAndRunService,
+ ) {
+ super(workspaceIteratorService);
+ }
+
+ override async runOnWorkspace({
+ workspaceId,
+ options,
+ }: RunOnWorkspaceArgs): Promise<void> {
+ const { flatCommandMenuItemMaps } =
+ await this.workspaceCacheService.getOrRecompute(workspaceId, [
+ 'flatCommandMenuItemMaps',
+ ]);
+
+ const commandMenuItemToUpdate = buildPinAskAiCommandMenuItemUpdate({
+ existingCommandMenuItem:
+ flatCommandMenuItemMaps.byUniversalIdentifier[
+ STANDARD_COMMAND_MENU_ITEMS.askAi.universalIdentifier
+ ],
+ now: new Date().toISOString(),
+ });
+
+ if (!isDefined(commandMenuItemToUpdate)) {
+ return;
+ }
+
+ if (options.dryRun) {
+ this.logger.log(`Would pin the Ask AI command for workspace ${workspaceId}`);
+
+ return;
+ }
+
+ const validateAndBuildResult =
+ await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunWorkspaceMigration(
+ {
+ allFlatEntityOperationByMetadataName: {
+ commandMenuItem: {
+ flatEntityToCreate: [],
+ flatEntityToDelete: [],
+ flatEntityToUpdate: [commandMenuItemToUpdate],
+ },
+ },
+ workspaceId,
+ isSystemBuild: true,
+ applicationUniversalIdentifier:
+ TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER,
+ },
+ );
+
+ if (validateAndBuildResult.status === 'fail') {
+ throw new WorkspaceMigrationBuilderException(validateAndBuildResult);
+ }
+ }
+}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/utils/__tests__/build-pin-ask-ai-command-menu-item-update.util.spec.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/utils/__tests__/build-pin-ask-ai-command-menu-item-update.util.spec.ts
new file mode 100644
index 00000000000..155d6b35120
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/utils/__tests__/build-pin-ask-ai-command-menu-item-update.util.spec.ts
@@ -0,0 +1,87 @@
+import { buildPinAskAiCommandMenuItemUpdate } from 'src/database/commands/upgrade-version-command/2-38/utils/build-pin-ask-ai-command-menu-item-update.util';
+import { type FlatCommandMenuItem } from 'src/engine/metadata-modules/flat-command-menu-item/types/flat-command-menu-item.type';
+import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';
+import { createStandardCommandMenuItemFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/command-menu-item/create-standard-command-menu-item-flat-metadata.util';
+
+const NOW = '2026-08-28T14:00:00.000Z';
+const LEGACY_COMMAND_MENU_ITEM: FlatCommandMenuItem = Object.freeze({
+ ...createStandardCommandMenuItemFlatMetadata({
+ commandMenuItemName: 'askAi',
+ commandMenuItemId: 'ask-ai-command-id',
+ workspaceId: 'workspace-id',
+ twentyStandardApplicationId: 'application-id',
+ dependencyFlatEntityMaps: {
+ flatObjectMetadataMaps: createEmptyFlatEntityMaps(),
+ },
+ now: '2026-08-01T00:00:00.000Z',
+ }),
+ isPinned: false,
+ shortLabel: 'Ask AI',
+});
+
+describe('buildPinAskAiCommandMenuItemUpdate', () => {
+ it('pins the command and drops its short label without changing other fields', () => {
+ expect(
+ buildPinAskAiCommandMenuItemUpdate({
+ existingCommandMenuItem: LEGACY_COMMAND_MENU_ITEM,
+ now: NOW,
+ }),
+ ).toEqual({
+ ...LEGACY_COMMAND_MENU_ITEM,
+ isPinned: true,
+ shortLabel: null,
+ updatedAt: NOW,
+ });
+ });
+
+ it.each([
+ { name: 'missing command', existingCommandMenuItem: undefined },
+ {
+ name: 'command already pinned',
+ existingCommandMenuItem: {
+ ...LEGACY_COMMAND_MENU_ITEM,
+ isPinned: true,
+ },
+ },
+ {
+ name: 'custom short label',
+ existingCommandMenuItem: {
+ ...LEGACY_COMMAND_MENU_ITEM,
+ shortLabel: 'Ask Twenty',
+ },
+ },
+ {
+ name: 'workspace pinning override',
+ existingCommandMenuItem: {
+ ...LEGACY_COMMAND_MENU_ITEM,
+ overrides: { isPinned: false },
+ },
+ },
+ {
+ name: 'workspace short label override',
+ existingCommandMenuItem: {
+ ...LEGACY_COMMAND_MENU_ITEM,
+ overrides: { shortLabel: 'Ask AI' },
+ },
+ },
+ ])('skips $name', ({ existingCommandMenuItem }) => {
+ expect(
+ buildPinAskAiCommandMenuItemUpdate({ existingCommandMenuItem, now: NOW }),
+ ).toBeUndefined();
+ });
+
+ it('does not update an already migrated command', () => {
+ const updatedCommandMenuItem = buildPinAskAiCommandMenuItemUpdate({
+ existingCommandMenuItem: LEGACY_COMMAND_MENU_ITEM,
+ now: NOW,
+ });
+
+ expect(updatedCommandMenuItem).toBeDefined();
+ expect(
+ buildPinAskAiCommandMenuItemUpdate({
+ existingCommandMenuItem: updatedCommandMenuItem,
+ now: '2026-08-29T14:00:00.000Z',
+ }),
+ ).toBeUndefined();
+ });
+});
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/utils/build-pin-ask-ai-command-menu-item-update.util.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/utils/build-pin-ask-ai-command-menu-item-update.util.ts
new file mode 100644
index 00000000000..040d86bc10b
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-38/utils/build-pin-ask-ai-command-menu-item-update.util.ts
@@ -0,0 +1,39 @@
+import { isDefined } from 'twenty-shared/utils';
+
+import { type FlatCommandMenuItem } from 'src/engine/metadata-modules/flat-command-menu-item/types/flat-command-menu-item.type';
+import { STANDARD_COMMAND_MENU_ITEMS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant';
+
+const LEGACY_ASK_AI_SHORT_LABEL = 'Ask AI';
+
+export const buildPinAskAiCommandMenuItemUpdate = ({
+ existingCommandMenuItem,
+ now,
+}: {
+ existingCommandMenuItem: FlatCommandMenuItem | undefined;
+ now: string;
+}): FlatCommandMenuItem | undefined => {
+ if (!isDefined(existingCommandMenuItem)) {
+ return undefined;
+ }
+
+ // Pinning and short labels are workspace-editable, so an override means the
+ // workspace already made its own choice for this command.
+ const hasWorkspaceOverride =
+ isDefined(existingCommandMenuItem.overrides?.isPinned) ||
+ isDefined(existingCommandMenuItem.overrides?.shortLabel);
+
+ if (
+ hasWorkspaceOverride ||
+ existingCommandMenuItem.isPinned !== false ||
+ existingCommandMenuItem.shortLabel !== LEGACY_ASK_AI_SHORT_LABEL
+ ) {
+ return undefined;
+ }
+
+ return {
+ ...existingCommandMenuItem,
+ isPinned: STANDARD_COMMAND_MENU_ITEMS.askAi.isPinned,
+ shortLabel: STANDARD_COMMAND_MENU_ITEMS.askAi.shortLabel,
+ updatedAt: now,
+ };
+};
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts
index 1ea880ddfb3..8fa0535d258 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts
@@ -873,11 +873,9 @@ export const STANDARD_COMMAND_MENU_ITEMS = {
msg({ message: `Ask AI`, context: 'commandMenuItem.label' }),
),
icon: 'IconSparkles',
- isPinned: false,
+ isPinned: true,
position: 43,
- shortLabel: i18nLabel(
- msg({ message: `Ask AI`, context: 'commandMenuItem.shortLabel' }),
- ),
+ shortLabel: null,
availabilityType: CommandMenuItemAvailabilityType.GLOBAL,
conditionalAvailabilityExpression: 'permissionFlags.AI',
availabilityObjectMetadataUniversalIdentifier: null,