Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(workflows): share the step catalog, workflow actions and edge id (#119736)

Daniel Marchukcee03d437096
diff --git a/products/workflows/frontend/Workflows/WorkflowActions.tsx b/products/workflows/frontend/Workflows/WorkflowActions.tsx
new file mode 100644
index 000000000000..0ddd37ee01bc
--- /dev/null
+++ b/products/workflows/frontend/Workflows/WorkflowActions.tsx
@@ -0,0 +1,265 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+import { useEffect, useRef, useState } from 'react'
+
+import { IconTrash } from '@posthog/icons'
+import { LemonButton, LemonDivider } from '@posthog/lemon-ui'
+import { Button, Separator } from '@posthog/quill'
+
+import { AccessControlAction } from 'lib/components/AccessControlAction'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
+
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { HogFlowManualTriggerButton } from './hogflows/HogFlowManualTriggerButton'
+import { QuillWorkflowSaveActions } from './QuillWorkflowSaveActions'
+import { workflowTemplateLogic } from './templates/workflowTemplateLogic'
+import { workflowLogic } from './workflowLogic'
+import { WorkflowSceneLogicProps } from './workflowSceneLogic'
+import { parseWorkflowTriggerPrefill, TRIGGER_PREFILL_PARAM } from './workflowTriggerPrefill'
+
+export function WorkflowActions(props: WorkflowSceneLogicProps): JSX.Element {
+ const {
+ workflow,
+ hasUnsavedChanges,
+ hasStagedDraft,
+ draftActionPending,
+ isWorkflowSubmitting,
+ workflowHasErrors,
+ workflowUserAccessLevel,
+ publishDisabledReason,
+ discardDisabledReason,
+ showDraftActions,
+ } = useValues(workflowLogic)
+ const { saveWorkflowPartial, submitWorkflow, discardChanges, publishDraft, discardDraft } =
+ useActions(workflowLogic)
+ const { searchParams } = useValues(router)
+ const editTemplateId = searchParams.editTemplateId as string | undefined
+ const templateId = searchParams.templateId as string | undefined
+ const { showSaveAsTemplateModal } = useActions(workflowTemplateLogic({ ...props, editTemplateId }))
+
+ const isSavedWorkflow = props.id && props.id !== 'new'
+ const isCreatedFromTemplate = props.id === 'new' && !!templateId
+ const isCreatedFromLink = props.id === 'new' && !!parseWorkflowTriggerPrefill(searchParams[TRIGGER_PREFILL_PARAM])
+ const isManualWorkflow = ['manual', 'batch'].includes(workflow?.trigger?.type || '')
+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')
+ const [displayStatus, setDisplayStatus] = useState(workflow?.status)
+ const [isTransitioning, setIsTransitioning] = useState(false)
+ const prevStatusRef = useRef(workflow?.status)
+ useEffect(() => {
+ // Only transition if status actually changed (not on initial mount)
+ if (workflow?.status !== displayStatus && prevStatusRef.current !== undefined) {
+ setIsTransitioning(true)
+ const timer = setTimeout(() => {
+ setDisplayStatus(workflow?.status)
+ setIsTransitioning(false)
+ }, 150)
+ prevStatusRef.current = workflow?.status
+ return () => clearTimeout(timer)
+ } else if (workflow?.status !== displayStatus) {
+ // On initial mount, just set it without transition
+ setDisplayStatus(workflow?.status)
+ prevStatusRef.current = workflow?.status
+ }
+ }, [workflow?.status, displayStatus])
+
+ return (
+ <>
+ {isManualWorkflow && <HogFlowManualTriggerButton {...props} />}
+ {isSavedWorkflow && (
+ <>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Workflow}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={workflowUserAccessLevel ?? undefined}
+ >
+ {todayRailNav ? (
+ <Button
+ variant={displayStatus === 'active' ? 'primary' : 'outline'}
+ // Stays clickable when steps have errors: the attempt is what
+ // reveals the per-field messages, and saveWorkflowPartial
+ // guards the actual enable with a toast.
+ onClick={() =>
+ saveWorkflowPartial({
+ status: workflow?.status === 'draft' ? 'active' : 'draft',
+ })
+ }
+ disabledReason={hasUnsavedChanges ? 'Save changes first' : undefined}
+ className="transition-colors duration-300 ease-in-out"
+ data-attr="workflow-launch"
+ >
+ <span
+ className={`inline-block transition-opacity duration-300 ease-in-out ${
+ isTransitioning ? 'opacity-0' : 'opacity-100'
+ }`}
+ >
+ {displayStatus === 'draft' ? 'Enable' : 'Disable'}
+ </span>
+ </Button>
+ ) : (
+ <LemonButton
+ type={displayStatus === 'active' ? 'primary' : 'secondary'}
+ // Stays clickable when steps have errors: the attempt is what
+ // reveals the per-field messages, and saveWorkflowPartial
+ // guards the actual enable with a toast.
+ onClick={() =>
+ saveWorkflowPartial({
+ status: workflow?.status === 'draft' ? 'active' : 'draft',
+ })
+ }
+ size="small"
+ disabledReason={hasUnsavedChanges ? 'Save changes first' : undefined}
+ className="transition-colors duration-300 ease-in-out"
+ data-attr="workflow-launch"
+ >
+ <span
+ className={`inline-block transition-opacity duration-300 ease-in-out ${
+ isTransitioning ? 'opacity-0' : 'opacity-100'
+ }`}
+ >
+ {displayStatus === 'draft' ? 'Enable' : 'Disable'}
+ </span>
+ </LemonButton>
+ )}
+ </AccessControlAction>
+ {todayRailNav ? <Separator orientation="vertical" /> : <LemonDivider vertical />}
+ </>
+ )}
+ {todayRailNav ? (
+ <QuillWorkflowSaveActions
+ hasUnsavedChanges={hasUnsavedChanges}
+ hasStagedDraft={hasStagedDraft}
+ showDraftActions={showDraftActions}
+ editTemplateId={editTemplateId}
+ isWorkflowSubmitting={isWorkflowSubmitting}
+ draftActionPending={draftActionPending}
+ saveDisabledReason={
+ workflowHasErrors
+ ? 'Some fields still need work'
+ : isCreatedFromTemplate || isCreatedFromLink
+ ? undefined
+ : hasUnsavedChanges
+ ? undefined
+ : 'No changes to save'
+ }
+ publishDisabledReason={publishDisabledReason}
+ discardDisabledReason={discardDisabledReason}
+ saveLabel={
+ props.id === 'new' ? 'Create as draft' : workflow?.status === 'active' ? 'Save draft' : 'Save'
+ }
+ saveUserAccessLevel={props.id === 'new' ? undefined : (workflowUserAccessLevel ?? undefined)}
+ workflowUserAccessLevel={workflowUserAccessLevel ?? undefined}
+ onDiscardChanges={() => discardChanges()}
+ onUpdateTemplate={showSaveAsTemplateModal}
+ onSave={submitWorkflow}
+ onPublish={() => publishDraft()}
+ onDiscardDraft={() => discardDraft()}
+ />
+ ) : (
+ <>
+ {hasUnsavedChanges && (
+ <LemonButton
+ data-attr="discard-workflow-changes"
+ type="secondary"
+ onClick={() => discardChanges()}
+ size="small"
+ >
+ Clear changes
+ </LemonButton>
+ )}
+ {editTemplateId ? (
+ <LemonButton
+ type="primary"
+ size="small"
+ onClick={showSaveAsTemplateModal}
+ loading={isWorkflowSubmitting}
+ >
+ Update template
+ </LemonButton>
+ ) : (
+ // Both buttons hold a fixed slot for the whole edit. Auto-save used to
+ // swap this group between "Save draft" and "Publish" every few seconds,
+ // which moved a different action under a pointer that had not left the
+ // button.
+ <>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Workflow}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={
+ props.id === 'new' ? undefined : (workflowUserAccessLevel ?? undefined)
+ }
+ >
+ <LemonButton
+ data-attr="workflow-save"
+ type={hasStagedDraft && !hasUnsavedChanges ? 'secondary' : 'primary'}
+ size="small"
+ htmlType="submit"
+ form="workflow"
+ onClick={submitWorkflow}
+ loading={isWorkflowSubmitting}
+ disabledReason={
+ workflowHasErrors
+ ? 'Some fields still need work'
+ : isCreatedFromTemplate || isCreatedFromLink
+ ? undefined
+ : hasUnsavedChanges
+ ? undefined
+ : 'No changes to save'
+ }
+ >
+ {props.id === 'new'
+ ? 'Create as draft'
+ : workflow?.status === 'active'
+ ? 'Save draft'
+ : 'Save'}
+ </LemonButton>
+ </AccessControlAction>
+ {showDraftActions && (
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Workflow}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={workflowUserAccessLevel ?? undefined}
+ >
+ <LemonButton
+ data-attr="workflow-publish"
+ type={hasStagedDraft && !hasUnsavedChanges ? 'primary' : 'secondary'}
+ size="small"
+ onClick={() => publishDraft()}
+ loading={draftActionPending === 'publish'}
+ disabledReason={publishDisabledReason}
+ // Discarding is rare and destructive, so it sits in the
+ // menu rather than next to the button a person aims for.
+ sideAction={{
+ 'data-attr': 'workflow-draft-actions',
+ 'aria-label': 'More draft actions',
+ dropdown: {
+ placement: 'bottom-end',
+ overlay: (
+ <LemonMenuOverlay
+ items={[
+ {
+ label: 'Discard draft',
+ icon: <IconTrash />,
+ status: 'danger',
+ onClick: () => discardDraft(),
+ disabledReason: discardDisabledReason,
+ 'data-attr': 'workflow-discard-draft',
+ },
+ ]}
+ />
+ ),
+ },
+ }}
+ >
+ Publish
+ </LemonButton>
+ </AccessControlAction>
+ )}
+ </>
+ )}
+ </>
+ )}
+ </>
+ )
+}
diff --git a/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx b/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx
index 0dac99050343..a58064066610 100644
--- a/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx
@@ -1,18 +1,12 @@
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
-import { useEffect, useRef, useState } from 'react'
import { IconArchive, IconClock, IconCopy, IconScreen, IconTrash, IconUpload } from '@posthog/icons'
-import { LemonButton, LemonDivider } from '@posthog/lemon-ui'
-import { Button, Separator } from '@posthog/quill'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'
import { FEATURE_FLAGS } from 'lib/constants'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
-import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { urls } from 'scenes/urls'
import {
@@ -22,77 +16,29 @@ import {
SceneMenuBarSeparator,
} from '~/layout/scenes/components/SceneMenuBar'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
-import { ScenePanel, ScenePanelActionsSection, ScenePanelDivider } from '~/layout/scenes/SceneLayout'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
-import { HogFlowManualTriggerButton } from './hogflows/HogFlowManualTriggerButton'
-import { QuillWorkflowSaveActions } from './QuillWorkflowSaveActions'
import { workflowSuggestionsAvailabilityLogic } from './suggestions/workflowSuggestionsAvailabilityLogic'
import { WorkflowSuggestionsMenuItem } from './suggestions/WorkflowSuggestionsMenuItem'
-import { WorkflowSuggestionsPanelToggle } from './suggestions/WorkflowSuggestionsPanelToggle'
import { SaveAsTemplateModal } from './templates/SaveAsTemplateModal'
import { workflowTemplateLogic } from './templates/workflowTemplateLogic'
+import { WorkflowActions } from './WorkflowActions'
import { workflowLogic } from './workflowLogic'
import { WorkflowSceneLogicProps } from './workflowSceneLogic'
-import { parseWorkflowTriggerPrefill, TRIGGER_PREFILL_PARAM } from './workflowTriggerPrefill'
+import { WorkflowScenePanel } from './WorkflowScenePanel'
export const WorkflowSceneHeader = (props: WorkflowSceneLogicProps = {}): JSX.Element => {
- const {
- workflow,
- hasUnsavedChanges,
- hasStagedDraft,
- draftActionPending,
- isWorkflowSubmitting,
- workflowLoading,
- workflowHasErrors,
- workflowUserAccessLevel,
- publishDisabledReason,
- discardDisabledReason,
- showDraftActions,
- } = useValues(workflowLogic)
- const {
- saveWorkflowPartial,
- submitWorkflow,
- setWorkflowValue,
- duplicate,
- archiveWorkflow,
- discardChanges,
- publishDraft,
- discardDraft,
- } = useActions(workflowLogic)
+ const { workflow, hasUnsavedChanges, hasStagedDraft, workflowLoading, workflowUserAccessLevel } =
+ useValues(workflowLogic)
+ const { setWorkflowValue, duplicate, archiveWorkflow, publishDraft, discardDraft } = useActions(workflowLogic)
const { searchParams } = useValues(router)
const editTemplateId = searchParams.editTemplateId as string | undefined
- const templateId = searchParams.templateId as string | undefined
- const templateLogic = workflowTemplateLogic({ ...props, editTemplateId })
- const { showSaveAsTemplateModal } = useActions(templateLogic)
+ const { showSaveAsTemplateModal } = useActions(workflowTemplateLogic({ ...props, editTemplateId }))
const isSavedWorkflow = props.id && props.id !== 'new'
- const isCreatedFromTemplate = props.id === 'new' && !!templateId
- const isCreatedFromLink = props.id === 'new' && !!parseWorkflowTriggerPrefill(searchParams[TRIGGER_PREFILL_PARAM])
- const isManualWorkflow = ['manual', 'batch'].includes(workflow?.trigger?.type || '')
const { featureFlags } = useValues(featureFlagLogic)
const sceneMenuBarEnabled = !!featureFlags[FEATURE_FLAGS.SCENE_MENU_BAR]
- const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')
const { suggestionsAvailable } = useValues(workflowSuggestionsAvailabilityLogic)
- const [displayStatus, setDisplayStatus] = useState(workflow?.status)
- const [isTransitioning, setIsTransitioning] = useState(false)
- const prevStatusRef = useRef(workflow?.status)
- useEffect(() => {
- // Only transition if status actually changed (not on initial mount)
- if (workflow?.status !== displayStatus && prevStatusRef.current !== undefined) {
- setIsTransitioning(true)
- const timer = setTimeout(() => {
- setDisplayStatus(workflow?.status)
- setIsTransitioning(false)
- }, 150)
- prevStatusRef.current = workflow?.status
- return () => clearTimeout(timer)
- } else if (workflow?.status !== displayStatus) {
- // On initial mount, just set it without transition
- setDisplayStatus(workflow?.status)
- prevStatusRef.current = workflow?.status
- }
- }, [workflow?.status, displayStatus])
return (
<>
@@ -220,258 +166,8 @@ export const WorkflowSceneHeader = (props: WorkflowSceneLogicProps = {}): JSX.El
}
actions={
<>
- {isManualWorkflow && <HogFlowManualTriggerButton {...props} />}
- {isSavedWorkflow && (
- <>
- <AccessControlAction
- resourceType={AccessControlResourceType.Workflow}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={workflowUserAccessLevel ?? undefined}
- >
- {todayRailNav ? (
- <Button
- variant={displayStatus === 'active' ? 'primary' : 'outline'}
- // Stays clickable when steps have errors: the attempt is what
- // reveals the per-field messages, and saveWorkflowPartial
- // guards the actual enable with a toast.
- onClick={() =>
- saveWorkflowPartial({
- status: workflow?.status === 'draft' ? 'active' : 'draft',
- })
- }
- disabledReason={hasUnsavedChanges ? 'Save changes first' : undefined}
- className="transition-colors duration-300 ease-in-out"
- data-attr="workflow-launch"
- >
- <span
- className={`inline-block transition-opacity duration-300 ease-in-out ${
- isTransitioning ? 'opacity-0' : 'opacity-100'
- }`}
- >
- {displayStatus === 'draft' ? 'Enable' : 'Disable'}
- </span>
- </Button>
- ) : (
- <LemonButton
- type={displayStatus === 'active' ? 'primary' : 'secondary'}
- // Stays clickable when steps have errors: the attempt is what
- // reveals the per-field messages, and saveWorkflowPartial
- // guards the actual enable with a toast.
- onClick={() =>
- saveWorkflowPartial({
- status: workflow?.status === 'draft' ? 'active' : 'draft',
- })
- }
- size="small"
- disabledReason={hasUnsavedChanges ? 'Save changes first' : undefined}
- className="transition-colors duration-300 ease-in-out"
- data-attr="workflow-launch"
- >
- <span
- className={`inline-block transition-opacity duration-300 ease-in-out ${
- isTransitioning ? 'opacity-0' : 'opacity-100'
- }`}
- >
- {displayStatus === 'draft' ? 'Enable' : 'Disable'}
- </span>
- </LemonButton>
- )}
- </AccessControlAction>
- {todayRailNav ? <Separator orientation="vertical" /> : <LemonDivider vertical />}
- <ScenePanel>
- {suggestionsAvailable && (
- <>
- <ScenePanelActionsSection>
- <WorkflowSuggestionsPanelToggle id={props.id!} />
- </ScenePanelActionsSection>
- <ScenePanelDivider />
- </>
- )}
- <ScenePanelActionsSection>
- <ButtonPrimitive
- menuItem
- onClick={() => duplicate()}
- data-attr="workflow-duplicate-btn"
- >
- <IconCopy />
- Duplicate
- </ButtonPrimitive>
- <ButtonPrimitive
- menuItem
- onClick={showSaveAsTemplateModal}
- data-attr="workflow-save-as-template-btn"
- >
- <IconScreen />
- Save as template
- </ButtonPrimitive>
- </ScenePanelActionsSection>
- <ScenePanelDivider />
- <ScenePanelActionsSection>
- <AccessControlAction
- resourceType={AccessControlResourceType.Workflow}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={workflowUserAccessLevel ?? undefined}
- >
- {({ disabledReason }) => (
- <ButtonPrimitive
- menuItem
- onClick={() => archiveWorkflow(workflow)}
- variant="danger"
- data-attr="workflow-archive-btn"
- disabled={!!disabledReason}
- tooltip={disabledReason ?? undefined}
- >
- <IconArchive />
- Archive
- </ButtonPrimitive>
- )}
- </AccessControlAction>
- </ScenePanelActionsSection>
- </ScenePanel>
- </>
- )}
- {todayRailNav ? (
- <QuillWorkflowSaveActions
- hasUnsavedChanges={hasUnsavedChanges}
- hasStagedDraft={hasStagedDraft}
- showDraftActions={showDraftActions}
- editTemplateId={editTemplateId}
- isWorkflowSubmitting={isWorkflowSubmitting}
- draftActionPending={draftActionPending}
- saveDisabledReason={
- workflowHasErrors
- ? 'Some fields still need work'
- : isCreatedFromTemplate || isCreatedFromLink
- ? undefined
- : hasUnsavedChanges
- ? undefined
- : 'No changes to save'
- }
- publishDisabledReason={publishDisabledReason}
- discardDisabledReason={discardDisabledReason}
- saveLabel={
- props.id === 'new'
- ? 'Create as draft'
- : workflow?.status === 'active'
- ? 'Save draft'
- : 'Save'
- }
- saveUserAccessLevel={
- props.id === 'new' ? undefined : (workflowUserAccessLevel ?? undefined)
- }
- workflowUserAccessLevel={workflowUserAccessLevel ?? undefined}
- onDiscardChanges={() => discardChanges()}
- onUpdateTemplate={showSaveAsTemplateModal}
- onSave={submitWorkflow}
- onPublish={() => publishDraft()}
- onDiscardDraft={() => discardDraft()}
- />
- ) : (
- <>
- {hasUnsavedChanges && (
- <LemonButton
- data-attr="discard-workflow-changes"
- type="secondary"
- onClick={() => discardChanges()}
- size="small"
- >
- Clear changes
- </LemonButton>
- )}
- {editTemplateId ? (
- <LemonButton
- type="primary"
- size="small"
- onClick={showSaveAsTemplateModal}
- loading={isWorkflowSubmitting}
- >
- Update template
- </LemonButton>
- ) : (
- // Both buttons hold a fixed slot for the whole edit. Auto-save used to
- // swap this group between "Save draft" and "Publish" every few seconds,
- // which moved a different action under a pointer that had not left the
- // button.
- <>
- <AccessControlAction
- resourceType={AccessControlResourceType.Workflow}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={
- props.id === 'new' ? undefined : (workflowUserAccessLevel ?? undefined)
- }
- >
- <LemonButton
- data-attr="workflow-save"
- type={hasStagedDraft && !hasUnsavedChanges ? 'secondary' : 'primary'}
- size="small"
- htmlType="submit"
- form="workflow"
- onClick={submitWorkflow}
- loading={isWorkflowSubmitting}
- disabledReason={
- workflowHasErrors
- ? 'Some fields still need work'
- : isCreatedFromTemplate || isCreatedFromLink
- ? undefined
- : hasUnsavedChanges
- ? undefined
- : 'No changes to save'
- }
- >
- {props.id === 'new'
- ? 'Create as draft'
- : workflow?.status === 'active'
- ? 'Save draft'
- : 'Save'}
- </LemonButton>
- </AccessControlAction>
- {showDraftActions && (
- <AccessControlAction
- resourceType={AccessControlResourceType.Workflow}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={workflowUserAccessLevel ?? undefined}
- >
- <LemonButton
- data-attr="workflow-publish"
- type={
- hasStagedDraft && !hasUnsavedChanges ? 'primary' : 'secondary'
- }
- size="small"
- onClick={() => publishDraft()}
- loading={draftActionPending === 'publish'}
- disabledReason={publishDisabledReason}
- // Discarding is rare and destructive, so it sits in the
- // menu rather than next to the button a person aims for.
- sideAction={{
- 'data-attr': 'workflow-draft-actions',
- 'aria-label': 'More draft actions',
- dropdown: {
- placement: 'bottom-end',
- overlay: (
- <LemonMenuOverlay
- items={[
- {
- label: 'Discard draft',
- icon: <IconTrash />,
- status: 'danger',
- onClick: () => discardDraft(),
- disabledReason: discardDisabledReason,
- 'data-attr': 'workflow-discard-draft',
- },
- ]}
- />
- ),
- },
- }}
- >
- Publish
- </LemonButton>
- </AccessControlAction>
- )}
- </>
- )}
- </>
- )}
+ <WorkflowActions {...props} />
+ {isSavedWorkflow && <WorkflowScenePanel {...props} />}
</>
}
/>
diff --git a/products/workflows/frontend/Workflows/WorkflowScenePanel.tsx b/products/workflows/frontend/Workflows/WorkflowScenePanel.tsx
new file mode 100644
index 000000000000..5dd5eaace0f5
--- /dev/null
+++ b/products/workflows/frontend/Workflows/WorkflowScenePanel.tsx
@@ -0,0 +1,70 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+
+import { IconArchive, IconCopy, IconScreen } from '@posthog/icons'
+
+import { AccessControlAction } from 'lib/components/AccessControlAction'
+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
+
+import { ScenePanel, ScenePanelActionsSection, ScenePanelDivider } from '~/layout/scenes/SceneLayout'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { workflowSuggestionsAvailabilityLogic } from './suggestions/workflowSuggestionsAvailabilityLogic'
+import { WorkflowSuggestionsPanelToggle } from './suggestions/WorkflowSuggestionsPanelToggle'
+import { workflowTemplateLogic } from './templates/workflowTemplateLogic'
+import { workflowLogic } from './workflowLogic'
+import { WorkflowSceneLogicProps } from './workflowSceneLogic'
+
+export function WorkflowScenePanel(props: WorkflowSceneLogicProps): JSX.Element {
+ const { workflow, workflowUserAccessLevel } = useValues(workflowLogic)
+ const { duplicate, archiveWorkflow } = useActions(workflowLogic)
+ const { searchParams } = useValues(router)
+ const editTemplateId = searchParams.editTemplateId as string | undefined
+ const { showSaveAsTemplateModal } = useActions(workflowTemplateLogic({ ...props, editTemplateId }))
+ const { suggestionsAvailable } = useValues(workflowSuggestionsAvailabilityLogic)
+
+ return (
+ <ScenePanel>
+ {suggestionsAvailable && (
+ <>
+ <ScenePanelActionsSection>
+ <WorkflowSuggestionsPanelToggle id={props.id!} />
+ </ScenePanelActionsSection>
+ <ScenePanelDivider />
+ </>
+ )}
+ <ScenePanelActionsSection>
+ <ButtonPrimitive menuItem onClick={() => duplicate()} data-attr="workflow-duplicate-btn">
+ <IconCopy />
+ Duplicate
+ </ButtonPrimitive>
+ <ButtonPrimitive menuItem onClick={showSaveAsTemplateModal} data-attr="workflow-save-as-template-btn">
+ <IconScreen />
+ Save as template
+ </ButtonPrimitive>
+ </ScenePanelActionsSection>
+ <ScenePanelDivider />
+ <ScenePanelActionsSection>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Workflow}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={workflowUserAccessLevel ?? undefined}
+ >
+ {({ disabledReason }) => (
+ <ButtonPrimitive
+ menuItem
+ onClick={() => archiveWorkflow(workflow)}
+ variant="danger"
+ data-attr="workflow-archive-btn"
+ disabled={!!disabledReason}
+ tooltip={disabledReason ?? undefined}
+ >
+ <IconArchive />
+ Archive
+ </ButtonPrimitive>
+ )}
+ </AccessControlAction>
+ </ScenePanelActionsSection>
+ </ScenePanel>
+ )
+}
diff --git a/products/workflows/frontend/Workflows/hogflows/edgeId.ts b/products/workflows/frontend/Workflows/hogflows/edgeId.ts
new file mode 100644
index 000000000000..44b4bb6b8064
--- /dev/null
+++ b/products/workflows/frontend/Workflows/hogflows/edgeId.ts
@@ -0,0 +1,6 @@
+import type { HogFlowEdge } from './types'
+
+/** One id per workflow edge, so every editor surface that draws an edge names it the same way. */
+export function getEdgeId(edge: HogFlowEdge): string {
+ return `${edge.from}->${edge.to} ${edge.type} ${edge.index ?? ''}`.trim()
+}
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
index 8eb7cf6ef8c9..ad15efbc1793 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
@@ -34,6 +34,7 @@ import { resolveDefaultEmailSender } from '../../Channels/defaultEmailSender'
import { optOutCategoriesLogic } from '../../OptOuts/optOutCategoriesLogic'
import type { MessageCategory } from '../../OptOuts/optOutCategoriesLogic'
import { EXIT_NODE_ID, TRIGGER_NODE_ID, WorkflowLogicProps, workflowLogic } from '../workflowLogic'
+import { getEdgeId } from './edgeId'
import { getFormattedNodes } from './react_flow_utils/autolayout'
import {
BOTTOM_HANDLE_POSITION,
@@ -50,9 +51,6 @@ import { isWorkflowTreeComplete } from './tree/workflowTree'
import type { DropzoneNode, HogFlow, HogFlowAction, HogFlowActionEdge, HogFlowActionNode } from './types'
import type { HogFlowEdge } from './types'
-const getEdgeId = (edge: HogFlow['edges'][number]): string =>
- `${edge.from}->${edge.to} ${edge.type} ${edge.index ?? ''}`.trim()
-
export function computeInsertEdges(
edges: HogFlow['edges'],
newActionId: string,
@@ -2559,9 +2557,14 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
resetFlowFromHogFlow: ({ hogFlow }) => {
try {
+ const edgeCountBySource = new Map<string, number>()
+ hogFlow.edges.forEach((edge) =>
+ edgeCountBySource.set(edge.from, (edgeCountBySource.get(edge.from) ?? 0) + 1)
+ )
+ const actionsById = new Map(hogFlow.actions.map((action) => [action.id, action]))
const edges: HogFlowActionEdge[] = hogFlow.edges.map((edge) => {
- const isOnlyEdgeForNode = hogFlow.edges.filter((e) => e.from === edge.from).length === 1
- const edgeSourceAction = hogFlow.actions.find((action) => action.id === edge.from)
+ const isOnlyEdgeForNode = edgeCountBySource.get(edge.from) === 1
+ const edgeSourceAction = actionsById.get(edge.from)
return {
// Only these values are set by the user
@@ -2706,7 +2709,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
},
showDropzones: () => {
- const { nodes, edges, isMovingNode, movingNodeId } = values
+ const { nodesById, edges, isMovingNode, movingNodeId } = values
const dropzoneNodes: DropzoneNode[] = []
@@ -2726,8 +2729,8 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
if (skipEdgeIds.has(edge.id)) {
return
}
- const sourceNode = nodes.find((n) => n.id === edge.source)
- const targetNode = nodes.find((n) => n.id === edge.target)
+ const sourceNode = nodesById[edge.source]
+ const targetNode = nodesById[edge.target]
if (sourceNode && targetNode) {
const sourceHandle = sourceNode.handles?.find((h) => h.id === edge.sourceHandle)
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
index c3a67033e47e..6d02f59f0fe5 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
@@ -11,201 +11,13 @@ import { teamLogic } from 'scenes/teamLogic'
import { HogFunctionTemplateType } from '~/types'
-import { CreateActionType, hogFlowEditorLogic } from '../hogFlowEditorLogic'
-import { destinationPickerFilter } from './destinationPickerFilter'
-// Side-effect imports: register product-specific trigger and action nodes
-import '../registry'
-
-import { FEATURE_FLAGS } from 'lib/constants'
-
-import { PERSON_DEPENDENT_ACTION_TYPES, workflowLogic } from '../../workflowLogic'
+import { workflowLogic } from '../../workflowLogic'
import { setHogFlowDragImage } from '../dragPreview'
-import { getRegisteredActionNodeCategories } from '../registry/actions/actionNodeRegistry'
+import { CreateActionType, hogFlowEditorLogic } from '../hogFlowEditorLogic'
import { StepView } from '../steps/components/StepView'
import { useHogFlowStep } from '../steps/HogFlowSteps'
-import { DEFAULT_DELAY_DURATION, getDelayDescription } from '../steps/stepDelayLogic'
import { HogFlowAction } from '../types'
-
-export const ACTION_NODES_TO_SHOW: CreateActionType[] = [
- {
- type: 'function_email',
- name: 'Email',
- description: 'Send an email to the user.',
- config: {
- template_id: 'template-email',
- inputs: {},
- },
- },
- {
- type: 'function_sms',
- name: 'SMS',
- description: 'Send an SMS to the user.',
- config: {
- template_id: 'template-twilio',
- inputs: {},
- },
- },
- {
- type: 'function',
- name: 'Slack',
- description: 'Send a Slack message to the user.',
- config: { template_id: 'template-slack', inputs: {} },
- },
- {
- type: 'function',
- name: 'Webhook',
- description: 'Send a Webhook to the user.',
- config: { template_id: 'template-webhook', inputs: {} },
- },
-]
-
-const PUSH_NOTIFICATION_ACTION_NODE: CreateActionType = {
- type: 'function_push',
- name: 'Push',
- description: 'Send a push notification to the user.',
- config: { template_id: 'template-native-push', inputs: {} },
-}
-
-const AI_TASK_ACTION_NODE: CreateActionType = {
- type: 'function',
- name: 'Create AI task',
- description: 'Start an AI agent task with instructions from this workflow.',
- config: {
- template_id: 'template-posthog-create-task',
- // Pinned rather than relying on the template default: the engine only reads
- // action.config.inputs at execution time, and this value is what turns a 409
- // "task limit reached" reply into a graceful skip instead of a failed step.
- inputs: { non_failure_status_codes: { value: [409] } },
- },
- output_variable: { key: 'task', result_path: null, label: 'Task' },
-}
-
-const RUN_SCOUT_ACTION_NODE: CreateActionType = {
- type: 'function',
- name: 'Run scout',
- description: 'Start a Signals scout run. The scout explores as it does on its schedule.',
- config: {
- template_id: 'template-posthog-run-scout',
- // Same reason as the AI-task node above: 409 (run in flight, scout paused, cooldown,
- // budget, or quota) is backpressure the step should skip on, not fail.
- inputs: { non_failure_status_codes: { value: [409] } },
- },
- output_variable: { key: 'scout_run', result_path: null, label: 'Scout run' },
-}
-
-const CLASSIFY_ACTION_NODE: CreateActionType = {
- type: 'function',
- name: 'Classify with AI',
- description: 'Ask an AI model to pick one category for the context. Branch on the result with a condition step.',
- config: { template_id: 'template-posthog-classify', inputs: {} },
- output_variable: [
- { key: 'category', result_path: 'category', label: 'Category' },
- { key: 'confidence', result_path: 'confidence', label: 'Confidence' },
- ],
-}
-
-const REPLAY_VISION_ACTION_NODE: CreateActionType = {
- type: 'function',
- name: 'Replay Vision',
- description: "Ask about, categorize, score or summarize the triggering event's session recording.",
- config: { template_id: 'template-posthog-replay-vision', inputs: {} },
- output_variable: { key: 'replay_vision', result_path: null, label: 'Replay Vision' },
-}
-
-export const DELAY_NODES_TO_SHOW: CreateActionType[] = [
- {
- type: 'delay',
- name: 'Delay',
- description: getDelayDescription({ delay_duration: DEFAULT_DELAY_DURATION }),
- config: { delay_duration: DEFAULT_DELAY_DURATION },
- },
- {
- type: 'wait_until_time_window',
- name: 'Time window',
- description: 'Wait for the next allowed time window before continuing.',
- config: {
- timezone: null,
- day: 'any',
- time: 'any',
- },
- },
- {
- type: 'wait_until_condition',
- name: 'Wait until',
- description: 'Wait until a matching event fires or a condition is met, up to a maximum duration.',
- branchEdges: 1,
- config: {
- condition: { filters: null },
- max_wait_duration: '5m',
- },
- },
-]
-
-export const LOGIC_NODES_TO_SHOW: CreateActionType[] = [
- {
- type: 'conditional_branch',
- name: 'Conditional branch',
- description: 'Branch using conditions on event or person properties.',
- branchEdges: 1,
- config: {
- conditions: [
- {
- filters: {},
- },
- ],
- },
- },
- {
- type: 'random_cohort_branch',
- name: 'Cohort branch',
- description: 'Randomly branch off based on cohort percentages.',
- branchEdges: 1,
- config: {
- cohorts: [
- {
- percentage: 50,
- },
- ],
- },
- },
-]
-
-export const POSTHOG_NODES_TO_SHOW: CreateActionType[] = [
- {
- type: 'function',
- name: 'Set variable',
- description: 'Set a workflow variable.',
- config: { template_id: 'template-posthog-set-variable', inputs: {} },
- },
- {
- type: 'function',
- name: 'Capture event',
- description: 'Capture an event to PostHog.',
- config: { template_id: 'template-posthog-capture', inputs: {} },
- },
- {
- type: 'function',
- name: 'Update person property',
- description: 'Set properties of a person in PostHog.',
- config: { template_id: 'template-posthog-update-person-properties', inputs: {} },
- },
- {
- type: 'function',
- name: 'Set group property',
- description: 'Set properties of a group in PostHog.',
- config: { template_id: 'template-posthog-group-identify', inputs: {} },
- },
-]
-
-const TEMPLATE_IDS_AT_TOP_LEVEL: string[] = [
- ...ACTION_NODES_TO_SHOW.map((action) => (action.config as any).template_id),
- ...DELAY_NODES_TO_SHOW.map((action) => (action.config as any).template_id),
- ...LOGIC_NODES_TO_SHOW.map((action) => (action.config as any).template_id),
- ...POSTHOG_NODES_TO_SHOW.map((action) => (action.config as any).template_id),
- ...getRegisteredActionNodeCategories().flatMap((cat) =>
- cat.nodes.map((action) => (action.config as any).template_id)
- ),
-].filter((t) => !!t)
+import { destinationStep, isBetaStep, isPickableDestination, workflowStepSections } from '../workflowStepCatalog'
function HogFlowEditorToolbarNode({
action,
@@ -284,8 +96,6 @@ function HogFlowEditorToolbarSection({
)
}
-const customFilterFunction = destinationPickerFilter(TEMPLATE_IDS_AT_TOP_LEVEL)
-
function HogFunctionTemplatesChooser({
onActionSelect,
}: {
@@ -293,7 +103,7 @@ function HogFunctionTemplatesChooser({
}): JSX.Element {
const logic = hogFunctionTemplateListLogic({
type: 'destination',
- customFilterFunction,
+ customFilterFunction: isPickableDestination,
})
const { loading, filteredTemplates, filters } = useValues(logic)
@@ -328,15 +138,7 @@ function HogFunctionTemplatesChooser({
{filteredTemplates.map((template: HogFunctionTemplateType) => (
<li key={template.type}>
<HogFlowEditorToolbarNode
- action={{
- type: 'function',
- name: template.name,
- description:
- typeof template.description === 'string'
- ? template.description
- : '',
- config: { template_id: template.id, inputs: {} },
- }}
+ action={destinationStep(template)}
onActionSelect={onActionSelect}
>
<div className="py-1 flex items-center gap-1 flex-1">
@@ -373,129 +175,41 @@ export function HogFlowEditorPanelBuild({
const { currentTeam } = useValues(teamLogic)
const { isRowScopedTrigger } = useValues(workflowLogic)
- const registeredCategories = getRegisteredActionNodeCategories(featureFlags)
-
- // Warehouse-triggered workflows have no person, so don't offer person-dependent steps at all.
- const hideIfRowScoped = (nodes: CreateActionType[]): CreateActionType[] =>
- isRowScopedTrigger ? nodes.filter((node) => !PERSON_DEPENDENT_ACTION_TYPES.has(node.type)) : nodes
-
- // Scouts and Replay Vision belong to the project's main environment, and the server refuses their steps
- // elsewhere. currentTeam is required: while it loads, both sides of the comparison are undefined.
- const isMainEnvironment = !!currentTeam && currentTeam.id === currentTeam.project_id
-
- const delayNodes = hideIfRowScoped(DELAY_NODES_TO_SHOW)
- const logicNodes = hideIfRowScoped(LOGIC_NODES_TO_SHOW)
+ const sections = workflowStepSections({ featureFlags, currentTeam, isRowScopedTrigger })
return (
<div
className={`flex flex-col overflow-y-auto${className ? ` ${className}` : ''}`}
data-attr="workflow-add-action"
>
- <HogFlowEditorToolbarSection title="Dispatch">
- {ACTION_NODES_TO_SHOW.map((node, index) => (
- <HogFlowEditorToolbarNode
- key={`${node.type}-${index}`}
- action={node}
- onActionSelect={onActionSelect}
- />
- ))}
- {featureFlags[FEATURE_FLAGS.WORKFLOWS_PUSH_NOTIFICATIONS] && (
- <HogFlowEditorToolbarNode
- key="push-notifications"
- action={PUSH_NOTIFICATION_ACTION_NODE}
- onActionSelect={onActionSelect}
- />
- )}
- <HogFunctionTemplatesChooser onActionSelect={onActionSelect} />
- </HogFlowEditorToolbarSection>
-
- {(featureFlags[FEATURE_FLAGS.WORKFLOW_AI_TASK_ACTION] ||
- featureFlags[FEATURE_FLAGS.WORKFLOW_CLASSIFY_ACTION] ||
- isMainEnvironment) && (
+ {sections.map((section) => (
<HogFlowEditorToolbarSection
+ key={section.key}
title={
- <span className="inline-flex items-center gap-1">
- AI <IconSparkles />
- </span>
+ section.key === 'ai' ? (
+ <span className="inline-flex items-center gap-1">
+ {section.title} <IconSparkles />
+ </span>
+ ) : (
+ section.title
+ )
}
>
- {featureFlags[FEATURE_FLAGS.WORKFLOW_AI_TASK_ACTION] && (
- <HogFlowEditorToolbarNode
- key="ai-task"
- action={AI_TASK_ACTION_NODE}
- onActionSelect={onActionSelect}
- >
- <span className="inline-flex items-center gap-1.5">
- {AI_TASK_ACTION_NODE.name}
- <LemonTag type="completion">Beta</LemonTag>
- </span>
- </HogFlowEditorToolbarNode>
- )}
- {isMainEnvironment && (
- <HogFlowEditorToolbarNode
- key="run-scout"
- action={RUN_SCOUT_ACTION_NODE}
- onActionSelect={onActionSelect}
- />
- )}
- {featureFlags[FEATURE_FLAGS.WORKFLOW_CLASSIFY_ACTION] && (
- <HogFlowEditorToolbarNode
- key="classify"
- action={CLASSIFY_ACTION_NODE}
- onActionSelect={onActionSelect}
- />
- )}
- {isMainEnvironment && (
- <HogFlowEditorToolbarNode
- key="replay-vision"
- action={REPLAY_VISION_ACTION_NODE}
- onActionSelect={onActionSelect}
- />
- )}
- </HogFlowEditorToolbarSection>
- )}
-
- <HogFlowEditorToolbarSection title="Delays">
- {delayNodes.map((action, index) => (
- <HogFlowEditorToolbarNode
- key={`${action.type}-${index}`}
- action={action}
- onActionSelect={onActionSelect}
- />
- ))}
- </HogFlowEditorToolbarSection>
-
- {logicNodes.length > 0 && (
- <HogFlowEditorToolbarSection title="Audience split">
- {logicNodes.map((action, index) => (
- <HogFlowEditorToolbarNode
- key={`${action.type}-${index}`}
- action={action}
- onActionSelect={onActionSelect}
- />
- ))}
- </HogFlowEditorToolbarSection>
- )}
-
- <HogFlowEditorToolbarSection title="PostHog actions">
- {POSTHOG_NODES_TO_SHOW.map((action, index) => (
- <HogFlowEditorToolbarNode
- key={`${action.type}-${index}`}
- action={action}
- onActionSelect={onActionSelect}
- />
- ))}
- </HogFlowEditorToolbarSection>
-
- {registeredCategories.map((cat) => (
- <HogFlowEditorToolbarSection key={cat.label} title={cat.label}>
- {cat.nodes.map((action, index) => (
+ {section.steps.map((action, index) => (
<HogFlowEditorToolbarNode
key={`${action.type}-${index}`}
action={action}
onActionSelect={onActionSelect}
- />
+ >
+ {isBetaStep(action) ? (
+ <span className="inline-flex items-center gap-1.5">
+ {action.name}
+ <LemonTag type="completion">Beta</LemonTag>
+ </span>
+ ) : undefined}
+ </HogFlowEditorToolbarNode>
))}
+ {section.key === 'dispatch' && <HogFunctionTemplatesChooser onActionSelect={onActionSelect} />}
</HogFlowEditorToolbarSection>
))}
</div>
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelSelectedStep.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelSelectedStep.tsx
index cce16d616410..07918c876602 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelSelectedStep.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelSelectedStep.tsx
@@ -3,17 +3,15 @@ import { useActions, useValues } from 'kea'
import { IconTrash } from '@posthog/icons'
import { LemonBadge, LemonButton, Tooltip } from '@posthog/lemon-ui'
-import { EditableField } from 'lib/components/EditableField/EditableField'
-
import { workflowLogic } from '../../workflowLogic'
import { hogFlowEditorLogic } from '../hogFlowEditorLogic'
import { useHogFlowStep } from '../steps/HogFlowSteps'
-import { isScheduleTrigger } from '../steps/types'
+import { HogFlowStepNameFields } from './HogFlowStepNameFields'
export function HogFlowEditorPanelSelectedStep(): JSX.Element | null {
const { selectedNode, selectedNodeCanBeDeleted } = useValues(hogFlowEditorLogic)
const { actionValidationErrorsById } = useValues(workflowLogic)
- const { onNodesDelete, setWorkflowAction, setSelectedNodeId } = useActions(hogFlowEditorLogic)
+ const { onNodesDelete, setSelectedNodeId } = useActions(hogFlowEditorLogic)
const Step = useHogFlowStep(selectedNode?.data)
if (!selectedNode) {
@@ -37,39 +35,7 @@ export function HogFlowEditorPanelSelectedStep(): JSX.Element | null {
{Step?.icon}
</span>
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
- <EditableField
- name="step-name"
- value={action.name}
- onSave={(value) => {
- const trimmed = value.trim()
- if (trimmed) {
- setWorkflowAction(action.id, { ...action, name: trimmed })
- }
- }}
- placeholder="Step name"
- minLength={1}
- saveOnBlur
- clickToEdit
- compactButtons
- compactIcon
- className="text-sm font-semibold"
- data-attr="workflow-step-name"
- />
- {!isScheduleTrigger(action) && (
- <EditableField
- name="step-description"
- value={action.description || ''}
- onSave={(value) => setWorkflowAction(action.id, { ...action, description: value.trim() })}
- placeholder="Add a description (optional)"
- multiline
- saveOnBlur
- clickToEdit
- compactButtons
- compactIcon
- className="text-xs text-secondary"
- data-attr="workflow-step-description"
- />
- )}
+ <HogFlowStepNameFields action={action} />
</div>
{selectedNode.deletable && (
<LemonButton
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowStepNameFields.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowStepNameFields.tsx
new file mode 100644
index 000000000000..ef4d939794d9
--- /dev/null
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowStepNameFields.tsx
@@ -0,0 +1,48 @@
+import { useActions } from 'kea'
+
+import { EditableField } from 'lib/components/EditableField/EditableField'
+
+import { hogFlowEditorLogic } from '../hogFlowEditorLogic'
+import { isScheduleTrigger } from '../steps/types'
+import type { HogFlowAction } from '../types'
+
+export function HogFlowStepNameFields({ action }: { action: HogFlowAction }): JSX.Element {
+ const { setWorkflowAction } = useActions(hogFlowEditorLogic)
+ return (
+ <>
+ <EditableField
+ name="step-name"
+ value={action.name}
+ onSave={(value) => {
+ const trimmed = value.trim()
+ if (trimmed) {
+ setWorkflowAction(action.id, { ...action, name: trimmed })
+ }
+ }}
+ placeholder="Step name"
+ minLength={1}
+ saveOnBlur
+ clickToEdit
+ compactButtons
+ compactIcon
+ className="text-sm font-semibold"
+ data-attr="workflow-step-name"
+ />
+ {!isScheduleTrigger(action) && (
+ <EditableField
+ name="step-description"
+ value={action.description || ''}
+ onSave={(value) => setWorkflowAction(action.id, { ...action, description: value.trim() })}
+ placeholder="Add a description (optional)"
+ multiline
+ saveOnBlur
+ clickToEdit
+ compactButtons
+ compactIcon
+ className="text-xs text-secondary"
+ data-attr="workflow-step-description"
+ />
+ )}
+ </>
+ )
+}
diff --git a/products/workflows/frontend/Workflows/hogflows/workflowStepCatalog.test.ts b/products/workflows/frontend/Workflows/hogflows/workflowStepCatalog.test.ts
new file mode 100644
index 000000000000..8c17918294fc
--- /dev/null
+++ b/products/workflows/frontend/Workflows/hogflows/workflowStepCatalog.test.ts
@@ -0,0 +1,76 @@
+import { FEATURE_FLAGS } from 'lib/constants'
+
+import type { HogFunctionTemplateType } from '~/types'
+
+import { isPickableDestination, StepCatalogContext, workflowStepSections } from './workflowStepCatalog'
+
+const mainEnvironment = { id: 1, project_id: 1 }
+
+const listed = (context: Partial<StepCatalogContext>): Record<string, string[]> =>
+ Object.fromEntries(
+ workflowStepSections({
+ featureFlags: {},
+ currentTeam: mainEnvironment,
+ isRowScopedTrigger: false,
+ ...context,
+ }).map((section) => [section.title, section.steps.map((step) => step.name)])
+ )
+
+describe('workflowStepCatalog', () => {
+ it('lists every step a workflow can always add, in the order the step picker shows them', () => {
+ expect(listed({})).toEqual({
+ Dispatch: ['Email', 'SMS', 'Slack', 'Webhook'],
+ AI: ['Run scout', 'Replay Vision'],
+ Delays: ['Delay', 'Time window', 'Wait until'],
+ 'Audience split': ['Conditional branch', 'Cohort branch'],
+ 'PostHog actions': ['Set variable', 'Capture event', 'Update person property', 'Set group property'],
+ Support: ['Get ticket', 'Update ticket', 'Send message'],
+ })
+ })
+
+ it.each([
+ {
+ name: 'adds the AI task and classify steps behind their flags',
+ context: {
+ featureFlags: {
+ [FEATURE_FLAGS.WORKFLOW_AI_TASK_ACTION]: true,
+ [FEATURE_FLAGS.WORKFLOW_CLASSIFY_ACTION]: true,
+ },
+ },
+ ai: ['Create AI task', 'Run scout', 'Classify with AI', 'Replay Vision'],
+ },
+ {
+ name: 'leaves the main-environment steps out of another environment',
+ context: {
+ featureFlags: { [FEATURE_FLAGS.WORKFLOW_AI_TASK_ACTION]: true },
+ currentTeam: { id: 2, project_id: 1 },
+ },
+ ai: ['Create AI task'],
+ },
+ {
+ name: 'leaves the main-environment steps out while the team loads',
+ context: { currentTeam: null },
+ ai: undefined,
+ },
+ ])('$name', ({ context, ai }) => {
+ expect(listed(context).AI).toEqual(ai)
+ })
+
+ it('offers no step that needs a person to a workflow that runs on warehouse rows', () => {
+ const sections = listed({ isRowScopedTrigger: true })
+
+ expect([sections.Delays, sections['Audience split']]).toEqual([
+ ['Delay', 'Time window'],
+ ['Conditional branch'],
+ ])
+ })
+
+ it('keeps destinations that are already a step of their own out of the destination list', () => {
+ const template = (id: string, name: string): HogFunctionTemplateType =>
+ ({ id, name, type: 'destination', status: 'stable', description: '' }) as HogFunctionTemplateType
+
+ const templates = [template('template-slack', 'Slack'), template('template-hubspot', 'HubSpot')]
+
+ expect(templates.filter(isPickableDestination).map((template) => template.name)).toEqual(['HubSpot'])
+ })
+})
diff --git a/products/workflows/frontend/Workflows/hogflows/workflowStepCatalog.ts b/products/workflows/frontend/Workflows/hogflows/workflowStepCatalog.ts
new file mode 100644
index 000000000000..3a7fa47055a8
--- /dev/null
+++ b/products/workflows/frontend/Workflows/hogflows/workflowStepCatalog.ts
@@ -0,0 +1,273 @@
+// Registers the product-specific action nodes before any catalog reads them.
+import './registry'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
+
+import type { HogFunctionTemplateType, TeamPublicType, TeamType } from '~/types'
+
+import { PERSON_DEPENDENT_ACTION_TYPES } from '../workflowLogic'
+import type { CreateActionType } from './hogFlowEditorLogic'
+import { destinationPickerFilter } from './panel/destinationPickerFilter'
+import { getRegisteredActionNodeCategories } from './registry/actions/actionNodeRegistry'
+import { DEFAULT_DELAY_DURATION, getDelayDescription } from './steps/stepDelayLogic'
+
+const ACTION_NODES_TO_SHOW: CreateActionType[] = [
+ {
+ type: 'function_email',
+ name: 'Email',
+ description: 'Send an email to the user.',
+ config: {
+ template_id: 'template-email',
+ inputs: {},
+ },
+ },
+ {
+ type: 'function_sms',
+ name: 'SMS',
+ description: 'Send an SMS to the user.',
+ config: {
+ template_id: 'template-twilio',
+ inputs: {},
+ },
+ },
+ {
+ type: 'function',
+ name: 'Slack',
+ description: 'Send a Slack message to the user.',
+ config: { template_id: 'template-slack', inputs: {} },
+ },
+ {
+ type: 'function',
+ name: 'Webhook',
+ description: 'Send a Webhook to the user.',
+ config: { template_id: 'template-webhook', inputs: {} },
+ },
+]
+
+const PUSH_NOTIFICATION_ACTION_NODE: CreateActionType = {
+ type: 'function_push',
+ name: 'Push',
+ description: 'Send a push notification to the user.',
+ config: { template_id: 'template-native-push', inputs: {} },
+}
+
+const AI_TASK_ACTION_NODE: CreateActionType = {
+ type: 'function',
+ name: 'Create AI task',
+ description: 'Start an AI agent task with instructions from this workflow.',
+ config: {
+ template_id: 'template-posthog-create-task',
+ // Pinned rather than relying on the template default: the engine only reads
+ // action.config.inputs at execution time, and this value is what turns a 409
+ // "task limit reached" reply into a graceful skip instead of a failed step.
+ inputs: { non_failure_status_codes: { value: [409] } },
+ },
+ output_variable: { key: 'task', result_path: null, label: 'Task' },
+}
+
+const RUN_SCOUT_ACTION_NODE: CreateActionType = {
+ type: 'function',
+ name: 'Run scout',
+ description: 'Start a Signals scout run. The scout explores as it does on its schedule.',
+ config: {
+ template_id: 'template-posthog-run-scout',
+ // Same reason as the AI-task node above: 409 (run in flight, scout paused, cooldown,
+ // budget, or quota) is backpressure the step should skip on, not fail.
+ inputs: { non_failure_status_codes: { value: [409] } },
+ },
+ output_variable: { key: 'scout_run', result_path: null, label: 'Scout run' },
+}
+
+const CLASSIFY_ACTION_NODE: CreateActionType = {
+ type: 'function',
+ name: 'Classify with AI',
+ description: 'Ask an AI model to pick one category for the context. Branch on the result with a condition step.',
+ config: { template_id: 'template-posthog-classify', inputs: {} },
+ output_variable: [
+ { key: 'category', result_path: 'category', label: 'Category' },
+ { key: 'confidence', result_path: 'confidence', label: 'Confidence' },
+ ],
+}
+
+const REPLAY_VISION_ACTION_NODE: CreateActionType = {
+ type: 'function',
+ name: 'Replay Vision',
+ description: "Ask about, categorize, score or summarize the triggering event's session recording.",
+ config: { template_id: 'template-posthog-replay-vision', inputs: {} },
+ output_variable: { key: 'replay_vision', result_path: null, label: 'Replay Vision' },
+}
+
+const DELAY_NODES_TO_SHOW: CreateActionType[] = [
+ {
+ type: 'delay',
+ name: 'Delay',
+ description: getDelayDescription({ delay_duration: DEFAULT_DELAY_DURATION }),
+ config: { delay_duration: DEFAULT_DELAY_DURATION },
+ },
+ {
+ type: 'wait_until_time_window',
+ name: 'Time window',
+ description: 'Wait for the next allowed time window before continuing.',
+ config: {
+ timezone: null,
+ day: 'any',
+ time: 'any',
+ },
+ },
+ {
+ type: 'wait_until_condition',
+ name: 'Wait until',
+ description: 'Wait until a matching event fires or a condition is met, up to a maximum duration.',
+ branchEdges: 1,
+ config: {
+ condition: { filters: null },
+ max_wait_duration: '5m',
+ },
+ },
+]
+
+const LOGIC_NODES_TO_SHOW: CreateActionType[] = [
+ {
+ type: 'conditional_branch',
+ name: 'Conditional branch',
+ description: 'Branch using conditions on event or person properties.',
+ branchEdges: 1,
+ config: {
+ conditions: [
+ {
+ filters: {},
+ },
+ ],
+ },
+ },
+ {
+ type: 'random_cohort_branch',
+ name: 'Cohort branch',
+ description: 'Randomly branch off based on cohort percentages.',
+ branchEdges: 1,
+ config: {
+ cohorts: [
+ {
+ percentage: 50,
+ },
+ ],
+ },
+ },
+]
+
+const POSTHOG_NODES_TO_SHOW: CreateActionType[] = [
+ {
+ type: 'function',
+ name: 'Set variable',
+ description: 'Set a workflow variable.',
+ config: { template_id: 'template-posthog-set-variable', inputs: {} },
+ },
+ {
+ type: 'function',
+ name: 'Capture event',
+ description: 'Capture an event to PostHog.',
+ config: { template_id: 'template-posthog-capture', inputs: {} },
+ },
+ {
+ type: 'function',
+ name: 'Update person property',
+ description: 'Set properties of a person in PostHog.',
+ config: { template_id: 'template-posthog-update-person-properties', inputs: {} },
+ },
+ {
+ type: 'function',
+ name: 'Set group property',
+ description: 'Set properties of a group in PostHog.',
+ config: { template_id: 'template-posthog-group-identify', inputs: {} },
+ },
+]
+
+export interface StepCatalogContext {
+ featureFlags: FeatureFlagsSet
+ currentTeam: Pick<TeamPublicType | TeamType, 'id' | 'project_id'> | null
+ isRowScopedTrigger: boolean
+}
+
+export interface StepCatalogSection {
+ key: string
+ title: string
+ steps: CreateActionType[]
+}
+
+/** Scouts and Replay Vision belong to the project's main environment, and the server refuses their steps
+ * elsewhere. While the team is still loading, both sides of the id comparison are undefined, so the team must be
+ * there first. */
+function isMainEnvironment(currentTeam: StepCatalogContext['currentTeam']): boolean {
+ return !!currentTeam && currentTeam.id === currentTeam.project_id
+}
+
+function dispatchSteps({ featureFlags }: StepCatalogContext): CreateActionType[] {
+ return [
+ ...ACTION_NODES_TO_SHOW,
+ ...(featureFlags[FEATURE_FLAGS.WORKFLOWS_PUSH_NOTIFICATIONS] ? [PUSH_NOTIFICATION_ACTION_NODE] : []),
+ ]
+}
+
+function aiSteps({ featureFlags, currentTeam }: StepCatalogContext): CreateActionType[] {
+ const mainEnvironment = isMainEnvironment(currentTeam)
+ return [
+ ...(featureFlags[FEATURE_FLAGS.WORKFLOW_AI_TASK_ACTION] ? [AI_TASK_ACTION_NODE] : []),
+ ...(mainEnvironment ? [RUN_SCOUT_ACTION_NODE] : []),
+ ...(featureFlags[FEATURE_FLAGS.WORKFLOW_CLASSIFY_ACTION] ? [CLASSIFY_ACTION_NODE] : []),
+ ...(mainEnvironment ? [REPLAY_VISION_ACTION_NODE] : []),
+ ]
+}
+
+const BETA_TEMPLATE_IDS = new Set(['template-posthog-create-task'])
+
+export function isBetaStep(step: CreateActionType): boolean {
+ const templateId = templateIdOf(step)
+ return !!templateId && BETA_TEMPLATE_IDS.has(templateId)
+}
+
+/** A warehouse-triggered workflow has no person, so it offers no step that needs one. */
+function forTrigger(steps: CreateActionType[], isRowScopedTrigger: boolean): CreateActionType[] {
+ return isRowScopedTrigger ? steps.filter((step) => !PERSON_DEPENDENT_ACTION_TYPES.has(step.type)) : steps
+}
+
+export function workflowStepSections(context: StepCatalogContext): StepCatalogSection[] {
+ return [
+ { key: 'dispatch', title: 'Dispatch', steps: dispatchSteps(context) },
+ { key: 'ai', title: 'AI', steps: aiSteps(context) },
+ { key: 'delays', title: 'Delays', steps: forTrigger(DELAY_NODES_TO_SHOW, context.isRowScopedTrigger) },
+ { key: 'split', title: 'Audience split', steps: forTrigger(LOGIC_NODES_TO_SHOW, context.isRowScopedTrigger) },
+ { key: 'posthog', title: 'PostHog actions', steps: POSTHOG_NODES_TO_SHOW },
+ ...getRegisteredActionNodeCategories(context.featureFlags).map((category) => ({
+ key: category.label,
+ title: category.label,
+ steps: category.nodes,
+ })),
+ ].filter((section) => section.steps.length > 0)
+}
+
+function templateIdOf(step: CreateActionType): string | undefined {
+ return 'template_id' in step.config ? step.config.template_id : undefined
+}
+
+const ALWAYS_LISTED_STEPS: CreateActionType[] = [
+ ...ACTION_NODES_TO_SHOW,
+ ...DELAY_NODES_TO_SHOW,
+ ...LOGIC_NODES_TO_SHOW,
+ ...POSTHOG_NODES_TO_SHOW,
+ ...getRegisteredActionNodeCategories().flatMap((category) => category.nodes),
+]
+
+/** Destinations already offered as their own step stay out of the destination list. */
+const TEMPLATE_IDS_AT_TOP_LEVEL = ALWAYS_LISTED_STEPS.flatMap((step) => templateIdOf(step) ?? [])
+
+export const isPickableDestination = destinationPickerFilter(TEMPLATE_IDS_AT_TOP_LEVEL)
+
+export function destinationStep(template: HogFunctionTemplateType): CreateActionType {
+ return {
+ type: 'function',
+ name: template.name,
+ description: typeof template.description === 'string' ? template.description : '',
+ config: { template_id: template.id, inputs: {} },
+ }
+}