The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(workflow): blank step-editor tabs in the side panel (#25318)
Thomas Trompettea8a1c06236b7
diff --git a/packages/twenty-front/src/modules/command-menu/hooks/__tests__/useWorkflowCommandMenu.test.tsx b/packages/twenty-front/src/modules/command-menu/hooks/__tests__/useWorkflowCommandMenu.test.tsxindex a78d6020a38..6a6eeb421b7 100644--- a/packages/twenty-front/src/modules/command-menu/hooks/__tests__/useWorkflowCommandMenu.test.tsx+++ b/packages/twenty-front/src/modules/command-menu/hooks/__tests__/useWorkflowCommandMenu.test.tsx@@ -174,11 +174,11 @@ describe('useSidePanelWorkflowNavigation', () => {const { result } = renderHooks();act(() => {- result.current.openWorkflowEditStepInSidePanel(- 'test-workflow-id',- 'Edit Step',- IconSettingsAutomation,- );+ result.current.openWorkflowEditStepInSidePanel({+ workflowId: 'test-workflow-id',+ title: 'Edit Step',+ icon: IconSettingsAutomation,+ });});expect(result.current.sidePanelWorkflowId).toBe('test-workflow-id');diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation.ts b/packages/twenty-front/src/modules/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation.tsindex 4af1ebf9d6f..989e1f43f87 100644--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation.ts+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation.ts@@ -1,4 +1,6 @@import { useNavigateSidePanel } from '@/side-panel/hooks/useNavigateSidePanel';+import { getWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';+import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';import { sidePanelWorkflowIdComponentState } from '@/side-panel/pages/workflow/states/sidePanelWorkflowIdComponentState';import { sidePanelWorkflowRunIdComponentState } from '@/side-panel/pages/workflow/states/sidePanelWorkflowRunIdComponentState';import { sidePanelWorkflowStepIdComponentState } from '@/side-panel/pages/workflow/states/sidePanelWorkflowStepIdComponentState';@@ -67,14 +69,34 @@ export const useSidePanelWorkflowNavigation = () => {);const openWorkflowEditStepInSidePanel = useCallback(- (- workflowId: string,- title: string,- icon: IconComponent,- stepId?: string,- ) => {+ ({+ workflowId,+ title,+ icon,+ stepId,+ initialStepTab,+ }: {+ workflowId: string;+ title: string;+ icon: IconComponent;+ stepId?: string;+ initialStepTab?: { tabListComponentId: string; tabId: string };+ }) => {const pageId = v4();+ if (isDefined(initialStepTab)) {+ store.set(+ activeTabIdComponentState.atomFamily({+ instanceId: getWorkspaceSurfaceScopedComponentInstanceId({+ componentInstanceId: initialStepTab.tabListComponentId,+ surfaceType: 'side-panel',+ surfaceInstanceId: pageId,+ }),+ }),+ initialStepTab.tabId,+ );+ }+store.set(sidePanelWorkflowIdComponentState.atomFamily({instanceId: pageId,diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/SidePanelWorkflowCreateStepContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/SidePanelWorkflowCreateStepContent.tsxindex 86485b996df..2e30ad08819 100644--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/SidePanelWorkflowCreateStepContent.tsx+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/SidePanelWorkflowCreateStepContent.tsx@@ -105,12 +105,12 @@ export const SidePanelWorkflowCreateStepContent = () => {setSidePanelNavigationStack([]);- openWorkflowEditStepInSidePanel(- workflowVisualizerWorkflowId,- createdStep.name,- getIcon(getActionIcon(createdStep.type as WorkflowActionType)),- createdStep.id,- );+ openWorkflowEditStepInSidePanel({+ workflowId: workflowVisualizerWorkflowId,+ title: createdStep.name,+ icon: getIcon(getActionIcon(createdStep.type as WorkflowActionType)),+ stepId: createdStep.id,+ });};return <SidePanelWorkflowSelectAction onActionSelected={handleCreateStep} />;diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/step/edit/components/SidePanelWorkflowEditStepTypeContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/step/edit/components/SidePanelWorkflowEditStepTypeContent.tsxindex 25e484a5b59..cea3a9a62eb 100644--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/step/edit/components/SidePanelWorkflowEditStepTypeContent.tsx+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/step/edit/components/SidePanelWorkflowEditStepTypeContent.tsx@@ -68,12 +68,12 @@ export const SidePanelWorkflowEditStepTypeContent = () => {setSidePanelNavigationStack([]);- openWorkflowEditStepInSidePanel(- workflowVisualizerWorkflowId,- updatedStep.name,- getIcon(getActionIcon(updatedStep.type as WorkflowActionType)),- updatedStep.id,- );+ openWorkflowEditStepInSidePanel({+ workflowId: workflowVisualizerWorkflowId,+ title: updatedStep.name,+ icon: getIcon(getActionIcon(updatedStep.type as WorkflowActionType)),+ stepId: updatedStep.id,+ });};return (diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsxindex 4b7e18bb905..e2c9293a648 100644--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx@@ -65,12 +65,12 @@ export const SidePanelWorkflowSelectTriggerTypeContent = () => {setWorkflowSelectedNode(TRIGGER_STEP_ID);- openWorkflowEditStepInSidePanel(+ openWorkflowEditStepInSidePanel({workflowId,- defaultLabel,- getIcon(icon),- TRIGGER_STEP_ID,- );+ title: defaultLabel,+ icon: getIcon(icon),+ stepId: TRIGGER_STEP_ID,+ });};};diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowDiagramStepNodeEditable.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowDiagramStepNodeEditable.tsxindex 49350d52759..ca2dec1650e 100644--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowDiagramStepNodeEditable.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowDiagramStepNodeEditable.tsx@@ -62,12 +62,12 @@ export const WorkflowDiagramStepNodeEditable = ({setWorkflowSelectedNode(id);if (isDefined(workflowVisualizerWorkflowId)) {- openWorkflowEditStepInSidePanel(- workflowVisualizerWorkflowId,- data.name,- getIcon(getWorkflowNodeIconKey(data)),- id,- );+ openWorkflowEditStepInSidePanel({+ workflowId: workflowVisualizerWorkflowId,+ title: data.name,+ icon: getIcon(getWorkflowNodeIconKey(data)),+ stepId: id,+ });}};diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowEditActionAiAgent.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowEditActionAiAgent.tsxindex aa9bf6b358b..14e8cd23e0d 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowEditActionAiAgent.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowEditActionAiAgent.tsx@@ -1,5 +1,6 @@import { TabList } from '@/ui/layout/tab-list/components/TabList';import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';+import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { type SingleTabProps } from '@/ui/layout/tab-list/types/SingleTabProps';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';@@ -113,7 +114,7 @@ export const WorkflowEditActionAiAgent = ({const activeTabId = useAtomComponentStateValue(activeTabIdComponentState,- componentInstanceId,+ useWorkspaceSurfaceScopedComponentInstanceId(componentInstanceId),);const currentTabId =(activeTabId as WorkflowAiAgentTabId) ?? WORKFLOW_AI_AGENT_TABS.PROMPT;diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsxindex 59e6d7e9bb1..d3a77b8945c 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx@@ -13,6 +13,7 @@ import { LogicFunctionLogs } from '@/logic-functions/components/LogicFunctionLogimport { InputLabel, CodeEditor } from 'twenty-ui/input';import { TabList } from '@/ui/layout/tab-list/components/TabList';import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';+import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';@@ -93,7 +94,9 @@ export const WorkflowEditActionCode = ({const fullScreenFocusId = `code-editor-fullscreen-${logicFunctionId}`;const activeTabId = useAtomComponentStateValue(activeTabIdComponentState,- WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID,+ useWorkspaceSurfaceScopedComponentInstanceId(+ WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID,+ ),);const { getUpdatableWorkflowVersion } =useGetUpdatableWorkflowVersionOrThrow();diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/WorkflowEditActionHttpRequest.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/WorkflowEditActionHttpRequest.tsxindex 06706ec7414..12fda795c4d 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/WorkflowEditActionHttpRequest.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/WorkflowEditActionHttpRequest.tsx@@ -8,6 +8,7 @@ import { WorkflowStepCmdEnterButton } from '@/workflow/workflow-steps/componentsimport { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';import { TabList } from '@/ui/layout/tab-list/components/TabList';import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';+import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { WorkflowStepFooter } from '@/workflow/workflow-steps/components/WorkflowStepFooter';import { getBodyTypeFromHeaders } from '@/workflow/workflow-steps/workflow-actions/http-request-action/utils/getBodyTypeFromHeaders';@@ -91,7 +92,9 @@ export const WorkflowEditActionHttpRequest = ({const { theme } = useContext(ThemeContext);const activeTabId = useAtomComponentStateValue(activeTabIdComponentState,- WORKFLOW_HTTP_REQUEST_TAB_LIST_COMPONENT_ID,+ useWorkspaceSurfaceScopedComponentInstanceId(+ WORKFLOW_HTTP_REQUEST_TAB_LIST_COMPONENT_ID,+ ),);const { formData, handleFieldChange, saveAction } = useHttpRequestForm({diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsxindex f345aa6ebbe..ef4207ef003 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx@@ -7,6 +7,7 @@ import { useGetOneLogicFunction } from '@/logic-functions/hooks/useGetOneLogicFuimport { InputLabel } from 'twenty-ui/input';import { TabList } from '@/ui/layout/tab-list/components/TabList';import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';+import { useWorkspaceSurfaceScopedComponentInstanceId } from '@/ui/layout/hooks/useWorkspaceSurfaceScopedComponentInstanceId';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { type WorkflowLogicFunctionAction } from '@/workflow/types/Workflow';import { WorkflowExpectedOutputBodyInput } from '@/workflow/workflow-steps/components/WorkflowExpectedOutputBodyInput';@@ -80,7 +81,9 @@ export const WorkflowEditActionLogicFunction = ({const activeTabId = useAtomComponentStateValue(activeTabIdComponentState,- WORKFLOW_LOGIC_FUNCTION_ACTION_TAB_LIST_COMPONENT_ID,+ useWorkspaceSurfaceScopedComponentInstanceId(+ WORKFLOW_LOGIC_FUNCTION_ACTION_TAB_LIST_COMPONENT_ID,+ ),);const functionInput = useMemo(() => {diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.tsindex 7265ace94a9..2eb8f120454 100644--- a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts@@ -1,7 +1,7 @@import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';import { useSidePanelWorkflowNavigation } from '@/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation';import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';-import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';+import { WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID } from '@/workflow/workflow-steps/workflow-actions/code-action/constants/WorkflowLogicFunctionTabListComponentId';import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';import { workflowVisualizerWorkflowIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowIdComponentState';@@ -82,10 +82,6 @@ export const useVariableDropdown = ({const setWorkflowSelectedNode = useSetAtomComponentState(workflowSelectedNodeComponentState,);- const setActiveTabId = useSetAtomComponentState(- activeTabIdComponentState,- 'workflow-logic-function-tab-list-component-id',- );const setWorkflowDiagram = useSetAtomComponentState(workflowDiagramComponentState,);@@ -153,16 +149,18 @@ export const useVariableDropdown = ({setSidePanelNavigationStack([]);- openWorkflowEditStepInSidePanel(- workflowVisualizerWorkflowId,- step.name,- getIcon(step.icon),- step.id,- );-- if (isDefined(linkOutputSchema.link.tab)) {- setActiveTabId(linkOutputSchema.link.tab);- }+ openWorkflowEditStepInSidePanel({+ workflowId: workflowVisualizerWorkflowId,+ title: step.name,+ icon: getIcon(step.icon),+ stepId: step.id,+ initialStepTab: isDefined(linkOutputSchema.link.tab)+ ? {+ tabListComponentId: WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID,+ tabId: linkOutputSchema.link.tab,+ }+ : undefined,+ });};if (isLinkOutputSchema(currentSubStep)) {