: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(workflows): remove the list view (#128919)
Michael Reichenbach33323f972942
diff --git a/common/storybook/storybook-timings.json b/common/storybook/storybook-timings.jsonindex c53fa5cfab22..d309409021aa 100644--- a/common/storybook/storybook-timings.json+++ b/common/storybook/storybook-timings.json@@ -3375,10 +3375,6 @@"chromium": 5.528,"webkit": 4.249},- "products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx": {- "chromium": 44.712,- "webkit": 13.455- },"products/workflows/frontend/Workflows/suggestions/WorkflowSuggestionEmailChange.stories.tsx": {"chromium": 1.63,"webkit": 1.851diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e8df8508eccd..162a5df7de3d 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -8522,10 +8522,6 @@ snapshots:hash: v1.k794b7964.82956ad7b49338362f216d5648ee89813a3e18e903bc45b42c07c78f1b2a8867.byfxv4NIxretK2jzWWtxLDC8JOBfVF-tTXUPEO57PJ8products-workflows-editor-configuration-panel--email--light:hash: v1.k794b7964.dd2c15bc5c6a886c41f24f953cd0357978914f002f42d732b842c2349c04317b.6WUo7ta3_veXnom0KzU7BZ1lUzBWNCxugxmfTVPZwlQ- products-workflows-editor-configuration-panel--email-in-side-panel--dark:- hash: v1.k794b7964.b86dd0589d4176cecbfdfec32ed5fd8d9d6b4da89571a78f3d46567b13b095a7.pmXKJhqonqv2m0izV0rqZGqzaKcC7NuPqds4ykm428Y- products-workflows-editor-configuration-panel--email-in-side-panel--light:- hash: v1.k794b7964.5148ef83b4ffa0066217d18ab900c6c7fc93e6c7024dd16c30d3adce5be0ad95.fmtMjqlnEFw4qXHvkmJrJtAAzPGgwrBGTrPYwjoQtQYproducts-workflows-editor-configuration-panel--logs--dark:hash: v1.k794b7964.beabe0c2c69154a7e7b8e5709226f710bbb707c7a2a96ea3b908e7b5348ad177.l8BzDM-8b8Z6jYzADnoiRggNuU02m3lgVa6vtNm2VOwproducts-workflows-editor-configuration-panel--logs--light:@@ -8579,9 +8575,9 @@ snapshots:products-workflows-editor-graph--support-sla-routing--light:hash: v1.k794b7964.87ebdaa62ffea5299872bf5b8595333606db612d3172c77d965c7567f9e2c5f5.H8yPhfb_9AJBqMxoFMubMcFyAmyc0rHSMfLvsz7RWQsproducts-workflows-editor-graph--with-navigation--dark:- hash: v1.k794b7964.dc721e65f438bf7fe2013543ff26dde41b16ce179086b5629e9b182e7e9fe483.T27e_uDxg83LB3eFtxlSWpVURFyifK7b51mVmX0SA2U+ hash: v1.k794b7964.8af849cea368652abf270e3b4fb744efb3ac987d05aac1c5a80ac8102ac2912d.j8jEiJv_egz0M2wd2sSjSeJqHpaP4z0j2O900JKcsY8products-workflows-editor-graph--with-navigation--light:- hash: v1.k794b7964.5767ba8d3b87f362fd36271e24d446f990bbf86aff2024da1e6fe269644805cc.4pktGj-uAP68UGvPlyCThR0LcIIKU6oOPBlxjWH3_ds+ hash: v1.k794b7964.3658b450056f0dd8e9b1d8d419fdc3e7cdd799966bfa567edfb6eb2fa5fb4491.VgnxMZyatRGloOVFqpk78UezVv6Rp9wuZS3Rg591Zwcproducts-workflows-editor-tile-canvas--long-emails--dark:hash: v1.k794b7964.1952a127037bb7742f34a262ba7383326e4f5e04c86ffd58caf988de908d8fe0.lASWXxfI4hHT-xShH9moFcK8Fsd5JbnWjflhV6hu1dIproducts-workflows-editor-tile-canvas--long-emails--light:@@ -8602,38 +8598,6 @@ snapshots:hash: v1.k794b7964.7c7eac0a64e20be352335e9955c4abccf70d7ec2b180217d33e275e59061a7af.RfzdMvzPcl8UMVgMFh5cr00tXX09P7bfm2EC7tBQdVsproducts-workflows-editor-tile-canvas--with-step-counts--light:hash: v1.k794b7964.50beae04f0b949a710da41fdca70c671369ae0ac0499d284b69e1c57e931f1bc.o27SKj0cbEgIAZ6OSgXLX9_lFEaYUAWLmXef1W0TB3w- products-workflows-editor-tree--add-on-promotion-emails--dark:- hash: v1.k794b7964.17e5ae30b6cfa98729709e1bb572aa329eea7d267ee0fd757a8bcbb1d065f805.UCtBAJZoCAO4I9fElU_pbm8QniucCrnrfH8XHXnsEZA- products-workflows-editor-tree--add-on-promotion-emails--light:- hash: v1.k794b7964.f830380f7e4815a04d0194868c15ca52f1833cf78b57a69594fbd57402a0c561.5SP1lTTSGd3IzpqmDjcDcv1zuKatqfbNe1j7GkxPC9U- products-workflows-editor-tree--customer-onboarding-and-retention--dark:- hash: v1.k794b7964.808a132ead05351093977b04223be9dedd9e0623a2ed4de7defd9a8a5ba5a5cc.UzaUo0418u_lhAD2HCPee68-9wGdgRdWaekPfYR5mQA- products-workflows-editor-tree--customer-onboarding-and-retention--light:- hash: v1.k794b7964.67d1a2b0ef94f015512b92f398eaea2368b095f73a50aefd6f80a560081cf7bf.bNeVhwn053pmSIaXqid9kbk2prGjITRcrOeTls9PIqw- products-workflows-editor-tree--narrow-customer-onboarding-and-retention--dark:- hash: v1.k794b7964.673b09f7bfb1a2fb5f76a9d4e9fd654487b2dfb9e281556a4670cacf43dad021.CL7Ne89Gxo5uEAOHiOZ57sxijGimFQFEltj9marnNcs- products-workflows-editor-tree--narrow-customer-onboarding-and-retention--light:- hash: v1.k794b7964.314a6ca95c60c27d347ca282243c3302f888af0a6e7baa46c5b0e4199786f6cb.Zw8SsNDqanIMfgBrWRyc_VRFK5VDlTqkT6YAUpUGnKo- products-workflows-editor-tree--narrow-workflow--dark:- hash: v1.k794b7964.c5d5f2a2866b78902551f9e9380136d9be5a0011279f2e54f95377f013545b20.I-T3nqERLPDU8txzIe16BUhe78gHADq0jM4W39rAjYY- products-workflows-editor-tree--narrow-workflow--light:- hash: v1.k794b7964.7d8dac9b3eb931220260bb75055a56e7adcb05342e22d58003fa11574542dc24.Fj7P8W9ZEhkxhLJEd43nRkEoRGLmq0sstG1vv2rRa8I- products-workflows-editor-tree--new-workflow--dark:- hash: v1.k794b7964.a7f6a336ea69706fbf9c906d3548f0b772d465d9d867dabaa64af73088580d19.dPuzPuRnzJGd1m5ZyaPlBHt5OvuYmyDjwqxRyDiCzDE- products-workflows-editor-tree--new-workflow--light:- hash: v1.k794b7964.b26c001de2fec999dbf8cc7a5cb5e90a125221918565462383596e5954544120.1m0sV-zURViZ0FtU4NAcxq_lqR59MX6e0u93mf4TWhc- products-workflows-editor-tree--pending-ticket-cleanup--dark:- hash: v1.k794b7964.2de8be67590d2f1066894e8d3485b6037a3ff773f9290e67719a760106f3e642.vIxviv3sMgP2V_uh31dcntx-1MKtUwtS8GcEGP5OEMM- products-workflows-editor-tree--pending-ticket-cleanup--light:- hash: v1.k794b7964.58cf54c92e805d3467a646c65999e24754329185c78874fa445e04a6a7eebcf2.CXoA9tIjwJO99F8aFSybnxRmvJMzB2ip3Z-RowWBKNg- products-workflows-editor-tree--renewal-window-alerts--dark:- hash: v1.k794b7964.9a5bb43c5b9d124cca88f4e2c696103d1ab9d61305c8a8e17b62c227a15b6d70.-CPdH4DReMqjWF2eGilglDR00bid3OvfnKp8g2qfQVc- products-workflows-editor-tree--renewal-window-alerts--light:- hash: v1.k794b7964.c719df6871c48d89de7ad2f3c5965a56804dceda27b9a452bc27919932a14a10.jQgVO9iXW7sZnojFvL-Rh2Onb1exWc-0EfcCAF7keY4- products-workflows-editor-tree--support-sla-routing--dark:- hash: v1.k794b7964.411dd0f28eda261f093e7736ce3f58456e8aa70b09d8914116ea14698b24be24.xsESYYjDOqBeoYAUerv0N8ZaXq9q1W_9TX-oHH1Rwac- products-workflows-editor-tree--support-sla-routing--light:- hash: v1.k794b7964.57dcc01b1a8941186c56d4313765c1bc324d4d7773052ff59c33e32a76847677.CJpJ9x1W6gNaVt-_vLknTrAf0T8kp_ylQmeJp-aqhSYproducts-workflows-reputation--domain-withheld-from-caller--dark:hash: v1.k794b7964.4c8ae4bd60867d552c0b0499308c93dbb6a9e6da74929a97ddbedd39f992599b.bwSgpaQEan0zikdVKGPrgdoZQY5PMjSXnsfOVCyrrVcproducts-workflows-reputation--domain-withheld-from-caller--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex e0fa72ec61b1..7655ff0eaa79 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -627,7 +627,6 @@ export const FEATURE_FLAGS = {WORKFLOWS_GOAL_EVENT_ENTRIES: 'workflows-goal-event-entries', // owner: @silthus #team-workflows, shows and keeps every stored event entry in goal and wait step editorsWORKFLOWS_INTERNAL_EVENT_FILTERS: 'workflows-internal-event-filters', // owner: @haven #team-workflowsWORKFLOWS_KEEP_LOCAL_EDITS: 'workflows-keep-local-edits', // owner: @silthus #team-workflows, keeps unsaved edits when the workflow changes elsewhere- WORKFLOWS_LINEAR_VIEW: 'workflows-linear-view', // owner: #team-workflowsWORKFLOWS_PUSH_NOTIFICATIONS: 'workflows-push-notifications', // owner: #team-workflowsWORKFLOWS_SENDING_TIER_REQUESTS: 'workflows-sending-tier-requests', // owner: @luke-belton #team-workflows, lets customers request a higher email sending tierWORKFLOWS_SUPABASE_AUTH_EMAILS: 'workflows-supabase-auth-emails', // owner: @luke-belton #team-workflows, send Supabase auth emails through transactional templatesdiff --git a/products/workflows/frontend/Workflows/Workflow.tsx b/products/workflows/frontend/Workflows/Workflow.tsxindex eb121046f554..3efe9d477eb0 100644--- a/products/workflows/frontend/Workflows/Workflow.tsx+++ b/products/workflows/frontend/Workflows/Workflow.tsx@@ -2,8 +2,6 @@ import { useActions, useValues } from 'kea'import { LemonBanner, LemonButton, SpinnerOverlay } from '@posthog/lemon-ui'-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'-import { CanvasCommandGroup } from './hogflows/editor/tile-canvas/CanvasCommandGroup'import { HogFlowEditor } from './hogflows/HogFlowEditor'import { hogFlowEditorLogic } from './hogflows/hogFlowEditorLogic'@@ -15,17 +13,12 @@ export function Workflow(props: WorkflowLogicProps): JSX.Element {workflowLogic(props))const { loadWorkflow, keepMyWorkflowVersion } = useActions(workflowLogic(props))- const { editorLayout, isTreeView, isTileCanvas } = useValues(hogFlowEditorLogic(logicProps))- const { setEditorLayout } = useActions(hogFlowEditorLogic(logicProps))- const treeViewEnabled = useFeatureFlag('WORKFLOWS_LINEAR_VIEW')+ const { isTileCanvas } = useValues(hogFlowEditorLogic(logicProps))return (<div className="relative flex min-h-[25rem] flex-1 flex-col overflow-hidden rounded-md border"><WorkflowStatusBar{...props}- editorLayout={editorLayout}- showEditorLayoutToggle={treeViewEnabled && !isTileCanvas}- onEditorLayoutChange={setEditorLayout}commands={isTileCanvas ? <CanvasCommandGroup {...logicProps} /> : undefined}/>{/* Brief working/disabled overlay while we reconcile to an edit made elsewhere (clean state). */}@@ -49,11 +42,7 @@ export function Workflow(props: WorkflowLogicProps): JSX.Element {</div></LemonBanner>)}- {!originalWorkflow && workflowLoading ? (- <SpinnerOverlay />- ) : (- <HogFlowEditor isTreeView={isTreeView} isTileCanvas={isTileCanvas} />- )}+ {!originalWorkflow && workflowLoading ? <SpinnerOverlay /> : <HogFlowEditor isTileCanvas={isTileCanvas} />}</div>)}diff --git a/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx b/products/workflows/frontend/Workflows/WorkflowStatusBar.tsxindex f1b367f99a98..b74c11717a4b 100644--- a/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx+++ b/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx@@ -1,30 +1,20 @@import { useValues, useActions } from 'kea'-import { IconClock, IconDecisionTree, IconInfo, IconList } from '@posthog/icons'-import { LemonButton, LemonSegmentedButton, LemonSwitch, LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'+import { IconClock, IconInfo } from '@posthog/icons'+import { LemonButton, LemonSwitch, LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'import { LastSavedIndicator } from 'lib/components/LastSavedIndicator'import { useDebouncedValue } from 'lib/hooks/useDebouncedValue'import { urls } from 'scenes/urls'-import type { HogFlowEditorLayout } from './hogflows/hogFlowEditorLogic'import { WorkflowLogicProps, workflowLogic } from './workflowLogic'type WorkflowStatusBarProps = WorkflowLogicProps & {- editorLayout: HogFlowEditorLayout- showEditorLayoutToggle: boolean- onEditorLayoutChange: (layout: HogFlowEditorLayout) => void/** Editor commands that sit in the bar, such as the tile canvas panels. They bring their own History. */commands?: JSX.Element}-export function WorkflowStatusBar({- editorLayout,- showEditorLayoutToggle,- onEditorLayoutChange,- commands,- ...props-}: WorkflowStatusBarProps): JSX.Element | null {+export function WorkflowStatusBar({ commands, ...props }: WorkflowStatusBarProps): JSX.Element | null {const logic = workflowLogic(props)const {originalWorkflow,@@ -50,27 +40,6 @@ export function WorkflowStatusBar({return (<div className="@container/workflow-status flex items-center justify-between gap-2 px-2 py-1.5 border-b bg-surface-secondary rounded-t-md flex-wrap"><div className="flex items-center gap-3 min-w-0">- {showEditorLayoutToggle && (- <LemonSegmentedButton- value={editorLayout}- onChange={onEditorLayoutChange}- size="small"- options={[- {- value: 'simple',- icon: <IconList />,- tooltip: 'List view',- 'data-attr': 'workflow-switch-to-simple-view',- },- {- value: 'advanced',- icon: <IconDecisionTree />,- tooltip: 'Graph view',- 'data-attr': 'workflow-switch-to-advanced-view',- },- ]}- />- )}{showWorkflowStatus &&(isEditingDraftOfLive ? (<LemonTag type="warning">Editing draft</LemonTag>diff --git a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsxindex 993165f08880..31f9296be14d 100644--- a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx+++ b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx@@ -27,7 +27,6 @@ import { HogFlowEditorPanel } from './panel/HogFlowEditorPanel'import { LOW_DETAIL_ZOOM, MAX_ZOOM, MIN_ZOOM } from './react_flow_utils/constants'import { REACT_FLOW_EDGE_TYPES } from './react_flow_utils/SmartEdge'import { REACT_FLOW_NODE_TYPES } from './steps/Nodes'-import { HogFlowTreeEditor } from './tree/HogFlowTreeEditor'import { HogFlowActionEdge, HogFlowActionNode } from './types'function HogFlowGraphEditor(): JSX.Element {@@ -135,35 +134,13 @@ function HogFlowGraphEditor(): JSX.Element {)}-function HogFlowTreeEditorContent(): JSX.Element {- return (- <div- className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden @max-[48rem]/workflow-editor:flex-col @max-[48rem]/workflow-editor:overflow-y-auto"- data-attr="workflow-editor"- >- <HogFlowTreeEditor />- <HogFlowEditorPanel layout="panel" />- </div>- )-}--export function HogFlowEditor({- isTreeView,- isTileCanvas = false,-}: {- isTreeView: boolean- isTileCanvas?: boolean-}): JSX.Element {+export function HogFlowEditor({ isTileCanvas = false }: { isTileCanvas?: boolean }): JSX.Element {const { logicProps } = useValues(workflowLogic)return (<BindLogic logic={hogFlowEditorLogic} props={logicProps}><HogFlowBranchSelectionProvider><div className="@container/workflow-editor flex min-h-0 min-w-0 flex-1">- {isTreeView ? (- <ReactFlowProvider>- <HogFlowTreeEditorContent />- </ReactFlowProvider>- ) : isTileCanvas ? (+ {isTileCanvas ? (<ReactFlowProvider><TileCanvas /></ReactFlowProvider>diff --git a/products/workflows/frontend/Workflows/hogflows/tree/exampleWorkflows.ts b/products/workflows/frontend/Workflows/hogflows/editor/exampleWorkflows.tssimilarity index 100%rename from products/workflows/frontend/Workflows/hogflows/tree/exampleWorkflows.tsrename to products/workflows/frontend/Workflows/hogflows/editor/exampleWorkflows.tsdiff --git a/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx b/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsxindex c0cb95c31579..c4ae7e88af08 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx@@ -3,7 +3,6 @@ import { BindLogic, useValues } from 'kea'import { SpinnerOverlay } from '@posthog/lemon-ui'-import { FEATURE_FLAGS } from 'lib/constants'import { App } from 'scenes/App'import { urls } from 'scenes/urls'@@ -42,7 +41,7 @@ function StorybookWorkflow(): JSX.Element {return (<div className="flex h-full flex-col">- {originalWorkflow ? <HogFlowEditor key={originalWorkflow.id} isTreeView={false} /> : <SpinnerOverlay />}+ {originalWorkflow ? <HogFlowEditor key={originalWorkflow.id} /> : <SpinnerOverlay />}</div>)}@@ -64,8 +63,7 @@ export const NarrowWorkflow: StoryFn = () => (NarrowWorkflow.parameters = { testOptions: { waitForSelector: '.react-flow__node' } }export const WithNavigation: StoryFn = () => <App />WithNavigation.parameters = {- pageUrl: `${urls.workflow(CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID, 'workflow')}?view=graph`,- featureFlags: [FEATURE_FLAGS.WORKFLOWS_LINEAR_VIEW],+ pageUrl: urls.workflow(CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID, 'workflow'),mockDate: '2026-09-04 12:00:00',testOptions: {waitForSelector: '.react-flow__node',diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvas.stories.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvas.stories.tsxindex dc4d9322d749..5f62df8c8d4c 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvas.stories.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvas.stories.tsx@@ -70,7 +70,7 @@ function StoryEditor({<div className="flex h-full flex-col">{originalWorkflow ? (<>- <HogFlowEditor key={originalWorkflow.id} isTreeView={false} isTileCanvas={!!tileCanvasEnabled} />+ <HogFlowEditor key={originalWorkflow.id} isTileCanvas={!!tileCanvasEnabled} /><StoryState metrics={metrics} openAllPaths={openAllPaths} /></>) : (diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.tsindex e2b5c718d000..7234828b088c 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts@@ -1,5 +1,5 @@-import { isBranchingAction } from '../../tree/workflowTree'import type { HogFlow, HogFlowAction } from '../../types'+import { isBranchingAction } from '../../workflowBranches'import { StepPresentation, stepPresentation, TimeWindowPresentation, WaitPresentation } from './stepPresentation'import {ActionOf,diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.tsindex 407ae5c60f2b..380b7c243a1b 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts@@ -2,8 +2,8 @@ import type { AppMetricsTotalsRequest } from 'lib/components/AppMetrics/appMetriimport { getEdgeId } from '../../edgeId'import type { CreateActionType, HogFlowEditorActionMetrics } from '../../hogFlowEditorLogic'-import { getWorkflowBranchLabel, isBranchingAction } from '../../tree/workflowTree'import type { HogFlow, HogFlowAction, HogFlowEdge } from '../../types'+import { getWorkflowBranchLabel, isBranchingAction } from '../../workflowBranches'export type FlowGraph = Pick<HogFlow, 'actions' | 'edges'>diff --git a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.tsindex 8b1dd2797a5c..c5aa3b7d839e 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts+++ b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts@@ -1,8 +1,8 @@import { mswDecorator } from '~/mocks/browser'import { NEW_WORKFLOW } from '../../workflowLogic'-import { EXAMPLE_WORKFLOWS } from '../tree/exampleWorkflows'import type { HogFlow, HogFlowAction } from '../types'+import { EXAMPLE_WORKFLOWS } from './exampleWorkflows'export const CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID = 'storybook-complex-workflow'export const CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW: HogFlow = {diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.tsindex e49233ece589..9111ff335dc2 100644--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts@@ -191,34 +191,6 @@ describe('hogFlowEditorLogic', () => {expect(logic.values.selectedNode).toMatchObject({ id: action.id, data: action })})- it('duplicates a linear step below itself', () => {- const delay: HogFlowAction = {- id: 'delay',- name: 'Delay',- description: '',- type: 'delay',- created_at: 0,- updated_at: 0,- config: { delay_duration: '1d' },- }- workflowLogic().actions.setWorkflowInfo({- actions: [NEW_WORKFLOW.actions[0], delay, NEW_WORKFLOW.actions[1]],- edges: [edge(TRIGGER_NODE_ID, delay.id, 'continue'), edge(delay.id, EXIT_NODE_ID, 'continue')],- })-- logic.actions.duplicateNodeBelow(delay.id)-- const duplicatedAction = logic.values.workflow.actions.find(- (action) => action.id !== delay.id && action.type === delay.type- )- expect(duplicatedAction).toMatchObject({ name: delay.name, config: delay.config })- expect(logic.values.workflow.edges).toEqual([- edge(TRIGGER_NODE_ID, delay.id, 'continue'),- edge(delay.id, duplicatedAction!.id, 'continue'),- edge(duplicatedAction!.id, EXIT_NODE_ID, 'continue'),- ])- })-it('keeps edits made while "Save as team default" was saving', () => {const email = {id: 'email',@@ -289,7 +261,7 @@ describe('hogFlowEditorLogic', () => {},} as HogFlowAction,},- ])('duplicates $case below itself', ({ step }) => {+ ])('copies $case onto the edge below it', ({ step }) => {teamLogic.actions.loadCurrentTeamSuccess({...MOCK_DEFAULT_TEAM,workflows_config: {@@ -303,7 +275,13 @@ describe('hogFlowEditorLogic', () => {edges: [edge(TRIGGER_NODE_ID, step.id, 'continue'), edge(step.id, EXIT_NODE_ID, 'continue')],})- logic.actions.duplicateNodeBelow(step.id)+ logic.actions.startCopyingNode({+ id: step.id,+ type: step.type,+ data: step,+ position: { x: 0, y: 0 },+ } as HogFlowActionNode)+ logic.actions.onDrop(undefined, edge(step.id, EXIT_NODE_ID, 'continue'))const duplicatedAction = logic.values.workflow.actions.find((action) => action.id !== step.id && action.type === step.type@@ -709,7 +687,6 @@ describe('hogFlowEditorLogic', () => {featureFlagLogic.actions.setFeatureFlags(flags, Object.fromEntries(flags.map((flag) => [flag, true])))const editorLogic = hogFlowEditorLogic()editorLogic.mount()- editorLogic.actions.setEditorLayout('advanced')await expectLogic(editorLogic).toFinishAllListeners()const layout = jest.spyOn(autolayout, 'getFormattedNodes')diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsxindex 23b2dde3dd91..6df2004cb414 100644--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx@@ -61,7 +61,6 @@ import type { UtmTagValues } from './steps/components/UtmTagFields'import type { UtmTagKey } from './steps/components/UtmTagFields'import { getHogFlowStep } from './steps/HogFlowSteps'import { CyclotronInputType, StepViewNodeHandle } from './steps/types'-import { isWorkflowTreeComplete } from './tree/workflowTree'import type { DropzoneNode, HogFlow, HogFlowAction, HogFlowActionEdge, HogFlowActionNode } from './types'import type { HogFlowEdge } from './types'@@ -211,7 +210,6 @@ export function canMoveStep(workflow: HogFlow, actionId: string): boolean {export const HOG_FLOW_EDITOR_MODES = ['build', 'variables', 'test', 'metrics', 'logs'] as constexport type HogFlowEditorMode = (typeof HOG_FLOW_EDITOR_MODES)[number]export const HOG_FLOW_EDITOR_DEFAULT_PANEL_WIDTH = 592-export type HogFlowEditorLayout = 'simple' | 'advanced'export type HogFlowEditorActionMetrics = {actionId: stringsucceeded: number@@ -289,12 +287,10 @@ export interface hogFlowEditorLogicValues {animatingEdgePair: string | nulldropzoneNodes: DropzoneNode[]edges: HogFlowActionEdge[]- editorLayout: HogFlowEditorLayouthighlightedDropzoneNodeId: string | nullisCopyingNode: booleanisMovingNode: booleanisTileCanvas: boolean- isTreeView: booleanisZoomedOutFar: booleanmode: HogFlowEditorModemovingNodeId: string | null@@ -308,7 +304,6 @@ export interface hogFlowEditorLogicValues {selectedNodeCanBeCopiedOrMoved: booleanselectedNodeCanBeDeleted: booleanselectedNodeId: string | null- treePathsCollapsedByDefault: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -2131,9 +2126,6 @@ export interface hogFlowEditorLogicActions {copyNodeToHighlightedDropzone: () => {value: true}- duplicateNodeBelow: (actionId: string) => {- actionId: string- }fitView: (options?: { duration?: number; noZoom?: boolean }) => {duration?: number | undefinednoZoom?: boolean | undefined@@ -2229,9 +2221,6 @@ export interface hogFlowEditorLogicActions {setEdges: (edges: HogFlowActionEdge[]) => {edges: HogFlowActionEdge[]}- setEditorLayout: (editorLayout: HogFlowEditorLayout) => {- editorLayout: HogFlowEditorLayout- }setHighlightedDropzoneNodeId: (highlightedDropzoneNodeId: string | null) => {highlightedDropzoneNodeId: string | null}@@ -2262,9 +2251,6 @@ export interface hogFlowEditorLogicActions {setSelectedNodeId: (selectedNodeId: string | null) => {selectedNodeId: string | null}- setTreePathsCollapsedByDefault: (collapsed: boolean) => {- collapsed: boolean- }showDropzones: () => {value: true}@@ -2287,7 +2273,6 @@ export interface hogFlowEditorLogicMeta {key: string__keaTypeGenInternalSelectorTypes: {isTileCanvas: (featureFlags: FeatureFlagsSet) => boolean- isTreeView: (featureFlags: FeatureFlagsSet, editorLayout: HogFlowEditorLayout, isTileCanvas: boolean) => booleannodesById: (nodes: HogFlowActionNode[]) => Record<string, HogFlowActionNode>selectedNode: (nodes: HogFlowActionNode[],@@ -2363,10 +2348,8 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([}),setNodeToBeAdded: (nodeToBeAdded: CreateActionType | HogFlowActionNode | null) => ({ nodeToBeAdded }),setHighlightedDropzoneNodeId: (highlightedDropzoneNodeId: string | null) => ({ highlightedDropzoneNodeId }),- setEditorLayout: (editorLayout: HogFlowEditorLayout) => ({ editorLayout }),setMode: (mode: HogFlowEditorMode) => ({ mode }),setPanelWidth: (panelWidth: number) => ({ panelWidth }),- setTreePathsCollapsedByDefault: (collapsed: boolean) => ({ collapsed }),clearPanelWidth: true,setAnimatingEdgePair: (from: string, to: string) => ({ from, to }),clearAnimatingEdgePair: true,@@ -2387,7 +2370,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([isBranchJoinDropzone,joinEdges,}),- duplicateNodeBelow: (actionId: string) => ({ actionId }),markUtmSavedAsTeamDefault: (actionId: string, saved: UtmTagValues) => ({ actionId, saved }),loadActionMetricsById: (params: Pick<AppMetricsTotalsRequest, 'appSource' | 'appSourceId' | 'dateFrom' | 'dateTo'>,@@ -2398,12 +2380,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([setIsZoomedOutFar: (isZoomedOutFar: boolean) => ({ isZoomedOutFar }),}),reducers(() => ({- editorLayout: [- 'simple' as HogFlowEditorLayout,- {- setEditorLayout: (_, { editorLayout }) => editorLayout,- },- ],mode: ['build' as HogFlowEditorMode,{@@ -2418,15 +2394,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([clearPanelWidth: () => null,},],- // A fixed storage key, so the choice carries to the next workflow rather than being- // remembered per workflow the way this logic's own key would store it.- treePathsCollapsedByDefault: [- false,- { persist: true, storageKey: 'hogFlowTreePathsCollapsedByDefault' },- {- setTreePathsCollapsedByDefault: (_, { collapsed }) => collapsed,- },- ],nodes: [[] as HogFlowActionNode[],{@@ -2515,16 +2482,11 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([})),selectors({- /** The tile canvas replaces both the graph and the list view. */+ /** The tile canvas replaces the graph view. */isTileCanvas: [(s) => [s.featureFlags],(featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.WORKFLOWS_TILE_CANVAS],],- isTreeView: [- (s) => [s.featureFlags, s.editorLayout, s.isTileCanvas],- (featureFlags: FeatureFlagsSet, editorLayout: HogFlowEditorLayout, isTileCanvas: boolean): boolean =>- !isTileCanvas && !!featureFlags[FEATURE_FLAGS.WORKFLOWS_LINEAR_VIEW] && editorLayout === 'simple',- ],nodesById: [(s) => [s.nodes],(nodes: HogFlowActionNode[]): Record<string, HogFlowActionNode> => {@@ -3217,17 +3179,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([},})},- duplicateNodeBelow: ({ actionId }) => {- const action = values.workflow.actions.find((action) => action.id === actionId)- const targetEdge = values.workflow.edges.find((edge) => edge.from === actionId)-- if (!action || action.type === 'trigger' || action.type === 'exit' || !targetEdge) {- return- }-- actions.setNodeToBeAdded(action)- actions.onDrop(undefined, targetEdge)- },handlePaneClick: () => {actions.setSelectedNodeId(null)if (values.isCopyingNode) {@@ -3251,9 +3202,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([// Auto-save round-trips can emit a deep-equal workflow; skipping the rebuild avoids// re-deriving every node and edge (including the async layout pass) for no change.if (hogFlow && !objectsEqual(hogFlow, oldHogFlow)) {- if (values.editorLayout === 'simple' && !isWorkflowTreeComplete(hogFlow)) {- actions.setEditorLayout('advanced')- }actions.resetFlowFromHogFlow(hogFlow)}},@@ -3277,26 +3225,17 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([return {setSelectedNodeId: () => syncProperty('node', values.selectedNodeId ?? null),setMode: () => syncProperty('mode', values.mode),- setEditorLayout: () => syncProperty('view', values.editorLayout === 'simple' ? 'linear' : 'graph'),}}),urlToAction(({ actions, values }) => {const reactToTabChange = (_: any, search: Record<string, string>): void => {- const { node = null, mode, view } = search+ const { node = null, mode } = searchif (node !== values.selectedNodeId) {actions.setSelectedNodeId(node ?? null)}if (mode && HOG_FLOW_EDITOR_MODES.includes(mode as HogFlowEditorMode) && mode !== values.mode) {actions.setMode(mode as HogFlowEditorMode)}- const requestedEditorLayout = view === 'graph' ? 'advanced' : 'simple'- const editorLayout =- requestedEditorLayout === 'simple' && !isWorkflowTreeComplete(values.workflow)- ? 'advanced'- : requestedEditorLayout- if (editorLayout !== values.editorLayout) {- actions.setEditorLayout(editorLayout)- }}return {@@ -3305,9 +3244,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([}),events(({ actions, values }) => ({afterMount: () => {- if (values.editorLayout === 'simple' && !isWorkflowTreeComplete(values.workflow)) {- actions.setEditorLayout('advanced')- }actions.resetFlowFromHogFlow(values.workflow)const handleKeyDown = (e: KeyboardEvent): void => {diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsxindex 2a4315fe03f2..f22390d93722 100644--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx@@ -164,7 +164,6 @@ const PANEL_WORKFLOW: HogFlow = {type PanelStoryProps = {mode: HogFlowEditorModeselectedNodeId: string | null- layout?: 'floating' | 'panel'}const meta: Meta<typeof HogFlowEditorPanel> = {@@ -212,7 +211,7 @@ const meta: Meta<typeof HogFlowEditorPanel> = {}export default meta-function PanelStory({ mode, selectedNodeId, layout = 'floating' }: PanelStoryProps): JSX.Element {+function PanelStory({ mode, selectedNodeId }: PanelStoryProps): JSX.Element {const { originalWorkflow } = useValues(workflowLogic(LOGIC_PROPS))const { nodes } = useValues(hogFlowEditorLogic(LOGIC_PROPS))const { setWorkflowValues } = useActions(workflowLogic(LOGIC_PROPS))@@ -235,18 +234,9 @@ function PanelStory({ mode, selectedNodeId, layout = 'floating' }: PanelStoryPro<ReactFlowProvider><BindLogic logic={workflowLogic} props={LOGIC_PROPS}><BindLogic logic={hogFlowEditorLogic} props={LOGIC_PROPS}>- {layout === 'panel' ? (- // Mirrors the tree view's host: a full-height row where the panel sits- // beside the tree, so the panel is as tall as the editor- <div className="@container/workflow-editor relative flex h-screen overflow-hidden @max-[48rem]/workflow-editor:flex-col @max-[48rem]/workflow-editor:overflow-y-auto">- <div className="min-w-0 flex-1 bg-background" />- <HogFlowEditorPanel layout="panel" />- </div>- ) : (- <div className="relative h-screen w-[37rem] overflow-hidden bg-surface-primary">- <HogFlowEditorPanel />- </div>- )}+ <div className="relative h-screen w-[37rem] overflow-hidden bg-surface-primary">+ <HogFlowEditorPanel />+ </div></BindLogic></BindLogic></ReactFlowProvider>@@ -270,9 +260,6 @@ Webhook.args = { mode: 'build', selectedNodeId: 'webhook' }export const Email: StoryFn<PanelStoryProps> = Template.bind({})Email.args = { mode: 'build', selectedNodeId: 'email' }-export const EmailInSidePanel: StoryFn<PanelStoryProps> = Template.bind({})-EmailInSidePanel.args = { mode: 'build', selectedNodeId: 'email', layout: 'panel' }-export const ConditionalBranch: StoryFn<PanelStoryProps> = Template.bind({})ConditionalBranch.args = { mode: 'build', selectedNodeId: 'conditional' }diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsxindex d925ba89ed9b..0f92d846bccf 100644--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx@@ -1,12 +1,9 @@import clsx from 'clsx'import { useActions, useValues } from 'kea'-import { useRef } from 'react'import { IconArrowLeft, IconX } from '@posthog/icons'import { LemonBadge, LemonButton, LemonTab, LemonTabs } from '@posthog/lemon-ui'-import { Resizer } from 'lib/lemon-ui/Resizer/Resizer'-import { ResizerLogicProps, resizerLogic } from 'lib/lemon-ui/Resizer/resizerLogic'import { capitalizeFirstLetter } from 'lib/utils/strings'import {@@ -26,7 +23,7 @@ import { EmailActionTestContent } from './testing/HogFlowEditorNotificationPanelimport { HogFlowEditorPanelTest } from './testing/HogFlowEditorPanelTest'export interface HogFlowEditorPanelProps {- layout?: 'floating' | 'panel' | 'docked'+ layout?: 'floating' | 'docked'onClose?: () => voidview?: { title: string; content: JSX.Element }}@@ -38,14 +35,6 @@ export function HogFlowEditorPanel({}: HogFlowEditorPanelProps = {}): JSX.Element | null {const { panelWidth, selectedNode, mode, workflow } = useValues(hogFlowEditorLogic)const { clearPanelWidth, setMode, setPanelWidth, setSelectedNodeId } = useActions(hogFlowEditorLogic)- const panelRef = useRef<HTMLDivElement>(null)- const resizerProps: ResizerLogicProps = {- logicKey: 'hog-flow-simple-panel',- containerRef: panelRef,- placement: 'left',- persistent: true,- }- const { desiredSize: panelLayoutWidth } = useValues(resizerLogic(resizerProps))const variablesCount = workflow?.variables?.length || 0const width = panelWidth ?? HOG_FLOW_EDITOR_DEFAULT_PANEL_WIDTH@@ -73,29 +62,16 @@ export function HogFlowEditorPanel({return (<div- ref={panelRef}data-attr="workflow-editor-panel"className={clsx('flex min-h-0 max-h-full flex-col justify-end overflow-hidden @max-[48rem]/workflow-editor:!relative @max-[48rem]/workflow-editor:!min-w-0 @max-[48rem]/workflow-editor:!w-full @max-[48rem]/workflow-editor:!max-w-full @max-[48rem]/workflow-editor:shrink-0',layout === 'floating' && 'absolute right-0 max-w-full p-2 @max-[48rem]/workflow-editor:!h-96',- layout === 'panel' &&- 'relative h-full shrink-0 bg-surface-primary @max-[48rem]/workflow-editor:!h-96 @max-[48rem]/workflow-editor:border-t',layout === 'docked' &&'relative h-full min-w-80 max-w-[calc(100%-30rem)] shrink-0 border-l bg-surface-primary @max-[48rem]/workflow-editor:!h-1/2 @max-[48rem]/workflow-editor:border-t @max-[48rem]/workflow-editor:border-l-0')}- style={- layout === 'panel'- ? { width: panelLayoutWidth ?? '50%', minWidth: '20rem', maxWidth: '70%' }- : { width }- }+ style={{ width }}>- {layout !== 'panel' ? (- <HogFlowEditorPanelResizeHandle width={width} onResize={setPanelWidth} onReset={clearPanelWidth} />- ) : (- <div className="@max-[48rem]/workflow-editor:hidden">- <Resizer {...resizerProps} />- </div>- )}+ <HogFlowEditorPanelResizeHandle width={width} onResize={setPanelWidth} onReset={clearPanelWidth} /><divclassName={clsx('relative z-10 flex min-h-0 flex-col overflow-hidden bg-surface-primary',diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeBranch.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeBranch.tsxdeleted file mode 100644index 0fc84535b4e3..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeBranch.tsx+++ /dev/null@@ -1,200 +0,0 @@-import { useActions } from 'kea'-import type { CSSProperties, ReactNode } from 'react'--import { IconArrowRight, IconChevronDown, IconEllipsis } from '@posthog/icons'--import PropertyFiltersDisplay from 'lib/components/PropertyFilters/components/PropertyFiltersDisplay'-import { LemonButton } from 'lib/lemon-ui/LemonButton'-import { LemonMenu } from 'lib/lemon-ui/LemonMenu'-import { LemonTag } from 'lib/lemon-ui/LemonTag'-import { cn } from 'lib/utils/css-classes'--import { getHogFlowBranchColor, useHogFlowBranchSelection } from '../HogFlowBranchSelection'-import { hogFlowEditorLogic } from '../hogFlowEditorLogic'-import type { HogFlowEdge } from '../types'-import { HogFlowTreeBranchConnector } from './HogFlowTreeBranchConnector'-import { getWaitTimeoutLabel, type WorkflowTreeBranch, type WorkflowTreeNode } from './workflowTree'-import { getWorkflowTreeBranchSummary, getWorkflowTreeOccurrenceKey } from './workflowTreePresentation'--export function HogFlowTreeBranch({- node,- branch,- index,- isLast,- branchCollapsed,- onToggleCollapsed,- onFocusBranch,- onSelectContinuation,- path,- children,-}: {- node: WorkflowTreeNode- branch: WorkflowTreeBranch- index: number- isLast: boolean- branchCollapsed: boolean- onToggleCollapsed: () => void- onFocusBranch?: (path: HogFlowEdge[]) => void- onSelectContinuation: (actionId: string) => void- path: HogFlowEdge[]- children: ReactNode-}): JSX.Element {- const { setSelectedNodeId } = useActions(hogFlowEditorLogic)- const { selectedBranch, setSelectedBranch } = useHogFlowBranchSelection()- const continuation = branch.sequence.continueTo ?? node.joinAction- const branchIndex = branch.edge.type === 'branch' ? (branch.edge.index ?? index) : null- const pathColor = getHogFlowBranchColor(branchIndex)- const isBranchSelected = selectedBranch?.actionId === node.action.id && selectedBranch.index === branchIndex- const branchFilters =- branchIndex !== null && node.action.type === 'conditional_branch'- ? (node.action.config.conditions[branchIndex]?.filters?.properties ?? [])- : []- const percentage =- branchIndex !== null && node.action.type === 'random_cohort_branch'- ? node.action.config.cohorts[branchIndex]?.percentage- : undefined- const badge =- node.action.type === 'conditional_branch'- ? branchIndex === null- ? 'Else'- : `If #${branchIndex + 1}`- : node.action.type === 'wait_until_condition'- ? branchIndex === null- ? getWaitTimeoutLabel(node.action.config.max_wait_duration)- ? 'Timeout'- : 'No match'- : 'Match'- : branchIndex === null- ? 'Fallback'- : percentage !== undefined- ? `${percentage}%`- : `${branchIndex + 1}`-- const selectContinuation = (): void => {- if (continuation) {- setSelectedBranch(null)- setSelectedNodeId(continuation.id)- onSelectContinuation(continuation.id)- }- }-- return (- <div- className="relative min-w-0 ps-6 [--workflow-branch-line-color:var(--border-bold-3000)] has-[>[data-workflow-branch-highlight]>[data-workflow-branch-header]:is(:hover,:focus-within)]:[--workflow-branch-line-color:var(--workflow-branch-color)]"- style={{ '--workflow-branch-color': pathColor } as CSSProperties}- data-workflow-branch-index={branchIndex ?? 'continue'}- >- <HogFlowTreeBranchConnector isLast={isLast} />- <div className="min-w-0" data-workflow-branch-highlight>- <div- data-workflow-branch-header- className={cn(- 'flex min-w-0 items-start gap-2 rounded p-2',- isBranchSelected && 'bg-surface-secondary ring-1 ring-primary'- )}- >- <LemonButton- type="tertiary"- size="xsmall"- className="!bg-transparent"- aria-label={`${branchCollapsed ? 'Show' : 'Hide'} branch steps`}- aria-expanded={!branchCollapsed}- icon={<IconChevronDown className={cn(branchCollapsed && '-rotate-90')} />}- onClick={() => onToggleCollapsed()}- />- <div className="min-w-0 flex-1">- <div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1">- <LemonButton- type="tertiary"- size="xsmall"- className="!px-0 max-w-full"- aria-label={`Edit ${branch.label} path from ${node.action.name}`}- aria-pressed={isBranchSelected}- // A focused path returns focus here. Every branch header renders this- // button, but the actions menu below it is conditional.- id={`workflow-tree-path-${getWorkflowTreeOccurrenceKey(node.action.id, [...path, branch.edge])}`}- onClick={() => {- setSelectedNodeId(node.action.id)- setSelectedBranch({- actionId: node.action.id,- index: branchIndex,- })- }}- data-attr="workflow-tree-select-branch"- >- <span className="flex min-w-0 flex-wrap items-center gap-2">- <LemonTag- size={node.action.type === 'conditional_branch' ? 'medium' : 'small'}- className={cn(- 'shrink-0',- node.action.type === 'conditional_branch' && 'uppercase'- )}- style={{- color:- node.action.type === 'conditional_branch'- ? `color-mix(in srgb, ${pathColor} 60%, var(--text-3000))`- : pathColor,- borderColor: pathColor,- }}- >- {badge}- </LemonTag>- <span className="break-words whitespace-normal">{branch.label}</span>- </span>- </LemonButton>- {branchFilters.length > 0 && (- <div className="pointer-events-none ms-auto min-w-0 max-w-full text-xs">- <PropertyFiltersDisplay filters={branchFilters} compact />- </div>- )}- </div>- {branchCollapsed && (- <p className="mb-0 mt-1 break-words text-xs text-secondary">- {getWorkflowTreeBranchSummary(node, branch)}- </p>- )}- </div>- {onFocusBranch &&- (branch.sequence.nodes.length > 1 ||- branch.sequence.nodes.some((child) => child.branches.length > 0)) && (- <LemonMenu- items={[- {- label: 'Focus on this path',- onClick: () => onFocusBranch([...path, branch.edge]),- },- ]}- >- <LemonButton- type="tertiary"- size="xsmall"- className="!bg-transparent shrink-0"- icon={<IconEllipsis />}- aria-label={`Actions for ${branch.label}`}- tooltip="Path actions"- data-attr="workflow-tree-focus-branch"- />- </LemonMenu>- )}- </div>- <div className={cn('min-w-0 ps-3 ms-2 mt-2', branchCollapsed && 'hidden')}>- {children}- {continuation && (- <div className="relative py-1">- <LemonButton- type="tertiary"- size="xsmall"- className="!px-0"- icon={<IconArrowRight />}- onClick={selectContinuation}- data-attr="workflow-tree-select-continuation"- >- <span className="break-words whitespace-normal">{`Continue to: ${continuation.name}`}</span>- </LemonButton>- </div>- )}- </div>- </div>- </div>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeBranchConnector.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeBranchConnector.tsxdeleted file mode 100644index 0b2c87bd22ed..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeBranchConnector.tsx+++ /dev/null@@ -1,24 +0,0 @@-export function HogFlowTreeBranchConnector({ isLast }: { isLast: boolean }): JSX.Element {- return (- <>- <svg- aria-hidden="true"- className="pointer-events-none absolute start-2 -top-3 h-9 w-4 text-[var(--workflow-branch-line-color)] rtl:-scale-x-100"- viewBox="0 0 16 36"- fill="none"- >- <path- d={`M 1 0 V 23 A 12 12 0 0 0 13 35 H 16${!isLast ? ' M 1 23 V 36' : ''}`}- stroke="currentColor"- strokeWidth={2}- />- </svg>- {!isLast && (- <span- aria-hidden="true"- className="pointer-events-none absolute start-2 top-6 -bottom-3 border-s-2 border-[var(--workflow-branch-line-color)]"- />- )}- </>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeCollapseAllButton.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeCollapseAllButton.tsxdeleted file mode 100644index 1a33d328bbee..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeCollapseAllButton.tsx+++ /dev/null@@ -1,53 +0,0 @@-import { IconCollapse, IconExpand } from '@posthog/icons'--import { LemonButton } from 'lib/lemon-ui/LemonButton'--import type { WorkflowTreeSequence } from './workflowTree'-import {- areAllWorkflowTreeBranchesCollapsed,- getWorkflowTreeBranchGroups,- type WorkflowTreeNodeViewState,-} from './workflowTreePresentation'--export function HogFlowTreeCollapseAllButton({- tree,- viewStates,- onViewStateChange,- onCollapsedChange,-}: {- tree: WorkflowTreeSequence- viewStates: Record<string, WorkflowTreeNodeViewState>- onViewStateChange: (key: string, state: WorkflowTreeNodeViewState) => void- onCollapsedChange: (collapsed: boolean) => void-}): JSX.Element | null {- const groups = getWorkflowTreeBranchGroups(tree)- if (!groups.length) {- return null- }-- // Reading the state back from the branches keeps the label right after someone expands one by hand.- const allCollapsed = areAllWorkflowTreeBranchesCollapsed(groups, viewStates)-- return (- <div className="mb-2 flex justify-end">- <LemonButton- type="tertiary"- size="xsmall"- icon={allCollapsed ? <IconExpand /> : <IconCollapse />}- onClick={() => {- const nextCollapsed = !allCollapsed- for (const group of groups) {- onViewStateChange(group.occurrenceKey, {- branchesOpen: true,- collapsedBranches: nextCollapsed ? new Set(group.branchKeys) : new Set(),- })- }- onCollapsedChange(nextCollapsed)- }}- data-attr="workflow-tree-collapse-all-paths"- >- {allCollapsed ? 'Expand all paths' : 'Collapse all paths'}- </LemonButton>- </div>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeDropzone.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeDropzone.tsxdeleted file mode 100644index e2535300671b..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeDropzone.tsx+++ /dev/null@@ -1,191 +0,0 @@-import { useActions, useValues } from 'kea'-import { useState } from 'react'-import type { DragEvent } from 'react'--import { IconPlus } from '@posthog/icons'--import { LemonButton } from 'lib/lemon-ui/LemonButton'-import { cn, Popover, PopoverContent, PopoverTrigger } from 'lib/ui/quill'--import { type CreateActionType, hogFlowEditorLogic } from '../hogFlowEditorLogic'-import { HogFlowEditorPanelBuild } from '../panel/HogFlowEditorPanelBuild'-import type { HogFlowEdge } from '../types'-import { computeMoveTreeBranchEdges, isBranchingAction } from './workflowTree'--export function HogFlowTreeDropzone({- active,- draggedActionId,- draggedActionIdRef,- onDragEnd,- edge,- isBranchJoin = false,- joinEdges,- showConnector = true,- compact = false,- insertionLabel,- alwaysVisible = false,-}: {- active: boolean- draggedActionId: string | null- draggedActionIdRef: { current: string | null }- onDragEnd: () => void- edge: HogFlowEdge- isBranchJoin?: boolean- joinEdges?: HogFlowEdge[]- showConnector?: boolean- compact?: boolean- insertionLabel?: string- alwaysVisible?: boolean-}): JSX.Element {- const { workflow } = useValues(hogFlowEditorLogic)- const {- moveNodeToEdge,- onDragOver,- onDrop,- setHighlightedDropzoneNodeId,- setNodeToBeAdded,- setSelectedNodeId,- setWorkflowInfo,- } = useActions(hogFlowEditorLogic)- const [highlighted, setHighlighted] = useState(false)- const [pickerOpen, setPickerOpen] = useState(false)- const isAdjacentToDraggedAction = draggedActionId === edge.to || (!isBranchJoin && draggedActionId === edge.from)- const handleDragOver = (event: DragEvent<HTMLElement>): void => {- setHighlighted(true)- onDragOver(event)- }- const handleDrop = (event: DragEvent<HTMLElement>): void => {- setHighlighted(false)- const draggedActionId = draggedActionIdRef.current- if (draggedActionId) {- if (edge.to === draggedActionId || (!isBranchJoin && edge.from === draggedActionId)) {- onDragEnd()- return- }- const action = workflow.actions.find((action) => action.id === draggedActionId)- if (!action || !isBranchingAction(action)) {- moveNodeToEdge(draggedActionId, edge, isBranchJoin, joinEdges)- } else {- const newEdges = computeMoveTreeBranchEdges(workflow, draggedActionId, edge, isBranchJoin, joinEdges)- if (newEdges) {- setWorkflowInfo({ actions: workflow.actions, edges: newEdges })- setSelectedNodeId(draggedActionId)- }- }- onDragEnd()- } else if (isBranchJoin) {- if (joinEdges) {- onDrop(event, edge, joinEdges)- } else {- setHighlightedDropzoneNodeId(`dropzone_target_${edge.to}_branch_join`)- onDrop(event)- }- } else {- onDrop(event, edge)- }- }- const handleInsertAction = (action: CreateActionType): void => {- setPickerOpen(false)- setNodeToBeAdded(action)-- if (isBranchJoin && !joinEdges) {- setHighlightedDropzoneNodeId(`dropzone_target_${edge.to}_branch_join`)- onDrop()- } else {- onDrop(undefined, edge, joinEdges)- }- }- return (- <div- className={cn(- 'group relative flex w-full items-center justify-center',- alwaysVisible ? 'min-h-8' : compact ? 'h-2' : 'h-4'- )}- data-workflow-tree-dropzone-candidate- data-workflow-tree-dropzone-disabled={isAdjacentToDraggedAction || undefined}- >- <div- className={cn(- 'absolute inset-0 flex items-center justify-center',- active ? 'hidden' : 'group-data-[workflow-tree-dragging=true]/tree:hidden'- )}- >- <div- aria-hidden="true"- className={cn(- 'absolute inset-x-0 top-1/2 h-px -translate-y-1/2 bg-muted-foreground/50 opacity-0 transition-opacity',- pickerOpen && 'opacity-100',- (showConnector || insertionLabel) && 'group-hover:opacity-100 group-focus-within:opacity-100'- )}- />- <Popover open={pickerOpen} onOpenChange={setPickerOpen}>- <PopoverTrigger- render={- <LemonButton- htmlType="button"- type="tertiary"- size="xsmall"- tooltip={insertionLabel ?? 'Insert step here'}- className={cn(- alwaysVisible- ? 'relative z-10 me-auto min-w-0 max-w-full bg-transparent text-muted-foreground'- : 'absolute -right-2 top-1/2 z-10 !size-4 -translate-y-1/2 border-0 !bg-transparent !p-0'- )}- aria-label={insertionLabel ?? 'Insert step here'}- data-attr="workflow-tree-insert-action"- />- }- >- {alwaysVisible ? (- <>- <IconPlus className="size-3 shrink-0" />- <span className="truncate">{insertionLabel}</span>- </>- ) : (- <span- className={cn(- 'flex size-4 items-center justify-center rounded-full border border-primary bg-primary text-primary-foreground opacity-0 transition-[opacity,box-shadow] group-hover:opacity-100 group-focus-within:opacity-100 group-hover:shadow-sm',- pickerOpen && 'opacity-100 shadow-sm'- )}- >- <IconPlus className="size-3" />- </span>- )}- </PopoverTrigger>- <PopoverContent side="bottom" align="end" className="w-72 max-h-96 overflow-hidden p-0">- <HogFlowEditorPanelBuild className="max-h-96 p-2" onActionSelect={handleInsertAction} />- </PopoverContent>- </Popover>- </div>- <div- className={cn(- 'absolute -inset-y-3 inset-x-0 z-20 items-center',- isAdjacentToDraggedAction- ? 'hidden'- : 'hidden group-data-[workflow-tree-dropzone-closest=true]:flex'- )}- onDragOver={handleDragOver}- onDragLeave={() => setHighlighted(false)}- onDrop={handleDrop}- data-attr="workflow-tree-dropzone"- >- <div- aria-hidden="true"- className={cn(- 'absolute inset-x-0 top-1/2 h-0.5 -translate-y-1/2 bg-primary opacity-30 transition-opacity duration-150 group-data-[workflow-tree-dropzone-closest=true]:opacity-100',- highlighted && 'opacity-100'- )}- />- <span- aria-hidden="true"- className={cn(- 'absolute -right-2 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center rounded-full border border-primary bg-primary text-primary-foreground opacity-30 transition-[opacity,transform,box-shadow] duration-150 group-data-[workflow-tree-dropzone-closest=true]:scale-110 group-data-[workflow-tree-dropzone-closest=true]:opacity-100 group-data-[workflow-tree-dropzone-closest=true]:shadow-sm',- highlighted && 'scale-110 opacity-100 shadow-sm'- )}- >- <IconPlus className="size-3" />- </span>- </div>- </div>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsxdeleted file mode 100644index 3a506077fbca..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx+++ /dev/null@@ -1,370 +0,0 @@-import type { Meta, StoryFn } from '@storybook/react'-import { BindLogic, useActions } from 'kea'-import { useEffect, type ReactNode } from 'react'--import { FEATURE_FLAGS } from 'lib/constants'-import { lemonBannerLogic } from 'lib/lemon-ui/LemonBanner/lemonBannerLogic'--import { mswDecorator } from '~/mocks/browser'--import { Workflow } from '../../Workflow'-import { NEW_WORKFLOW, workflowLogic } from '../../workflowLogic'-import type { HogFlow, HogFlowAction } from '../types'-import { EXAMPLE_WORKFLOWS } from './exampleWorkflows'-import { HogFlowTreeEditor } from './HogFlowTreeEditor'--const COMPLEX_WORKFLOW_ID = 'storybook-complex-workflow'-const FEATURE_PREVIEW_DISMISS_KEY = 'workflow-tree-feature-preview'--function ResetFeaturePreviewDismissal({ children, storyId }: { children: ReactNode; storyId: string }): JSX.Element {- const { resetDismissKey } = useActions(lemonBannerLogic({ dismissKey: FEATURE_PREVIEW_DISMISS_KEY }))-- useEffect(() => {- resetDismissKey()- }, [resetDismissKey, storyId])-- return <>{children}</>-}--const COMPLEX_WORKFLOW: HogFlow = {- id: COMPLEX_WORKFLOW_ID,- team_id: 1,- version: 7,- name: 'Customer onboarding and retention',- description: 'Routes new accounts by stage and follows up when activation stalls.',- status: 'draft',- trigger: {- type: 'event',- filters: {- events: [{ id: 'account_created', name: 'Account created', type: 'events' }],- properties: [],- actions: [],- },- },- conversion: { window: '7d', filters: [] },- exit_condition: 'exit_only_at_end',- variables: [- { key: 'account_stage', type: 'string', label: 'Account stage', default: 'new' },- { key: 'follow_up_count', type: 'number', label: 'Follow-up count', default: 0 },- ],- actions: [- {- id: 'trigger',- type: 'trigger',- name: 'Account created',- description: 'Starts when a new account is created.',- config: {- type: 'event',- filters: {- events: [{ id: 'account_created', name: 'Account created', type: 'events' }],- properties: [],- actions: [],- },- },- },- {- id: 'route-by-stage',- type: 'conditional_branch',- name: 'Route by customer stage',- description: 'Choose a path based on the current account stage.',- config: {- conditions: [- {- name: 'Paid account',- filters: {- properties: [{ key: 'account_stage', value: ['paid'], operator: 'exact', type: 'person' }],- },- },- {- name: 'Trial account',- filters: {- properties: [{ key: 'account_stage', value: ['trial'], operator: 'exact', type: 'person' }],- },- },- {- name: 'At-risk account',- filters: {- properties: [- { key: 'account_stage', value: ['at_risk'], operator: 'exact', type: 'person' },- ],- },- },- ],- },- },- {- id: 'notify-account-team',- type: 'function',- name: 'Notify account team',- description: 'Send the paid account to the account team.',- config: {- template_id: 'template-slack',- inputs: {- slack_workspace: { value: 1 },- channel: { value: '#account-updates' },- text: { value: 'A paid account was created for {person.properties.email}.', templating: 'hog' },- },- },- },- {- id: 'wait-for-business-hours',- type: 'wait_until_time_window',- name: 'Wait for business hours',- description: 'Continue on a weekday between 09:00 and 17:00 UTC.',- config: { timezone: 'UTC', day: 'weekday', time: ['09:00', '17:00'] },- },- {- id: 'choose-onboarding-path',- type: 'random_cohort_branch',- name: 'Choose onboarding path',- description: 'Split trial accounts between two onboarding paths.',- config: {- cohorts: [- { name: 'Guided onboarding', percentage: 60 },- { name: 'Self-serve onboarding', percentage: 30 },- ],- },- },- {- id: 'create-onboarding-task',- type: 'function',- name: 'Create onboarding task',- description: 'Create a task for the guided onboarding path.',- config: {- template_id: 'template-webhook',- inputs: {- url: { value: 'https://example.com/hooks/onboarding' },- method: { value: 'POST' },- body: { value: { account_id: '{person.id}', path: 'guided' }, templating: 'hog' },- },- },- },- {- id: 'wait-one-day',- type: 'delay',- name: 'Wait one day',- description: 'Give the self-serve path time to activate.',- config: { delay_duration: '1d' },- },- {- id: 'send-self-serve-reminder',- type: 'function',- name: 'Send self-serve reminder',- description: 'Request a reminder from the messaging service.',- config: {- template_id: 'template-webhook',- inputs: {- url: { value: 'https://example.com/hooks/reminders' },- method: { value: 'POST' },- body: { value: { account_id: '{person.id}', reminder: 'activation' }, templating: 'hog' },- },- },- },- {- id: 'hold-control-group',- type: 'delay',- name: 'Hold control group',- description: 'Wait before measuring the control group.',- config: { delay_duration: '3d' },- },- {- id: 'wait-for-activation',- type: 'wait_until_condition',- name: 'Wait for activation',- description: 'Continue when the account activates or after seven days.',- config: {- condition: {- name: 'Product activated',- filters: { events: [{ id: 'product_activated', name: 'Product activated', type: 'events' }] },- },- max_wait_duration: '7d',- },- },- {- id: 'share-activation',- type: 'function',- name: 'Share activation',- description: 'Notify the retention team that activation completed.',- config: {- template_id: 'template-slack',- inputs: {- slack_workspace: { value: 1 },- channel: { value: '#retention-updates' },- text: { value: 'Account {person.id} activated.', templating: 'hog' },- },- },- },- {- id: 'create-follow-up-task',- type: 'function',- name: 'Create follow-up task',- description: 'Create a task when activation does not complete.',- config: {- template_id: 'template-webhook',- inputs: {- url: { value: 'https://example.com/hooks/follow-up' },- method: { value: 'POST' },- body: { value: { account_id: '{person.id}', reason: 'activation_timeout' }, templating: 'hog' },- },- },- },- {- id: 'send-activation-outcome',- type: 'function',- name: 'Send activation outcome',- description: 'Record whether the account activated or needs a follow-up.',- config: {- template_id: 'template-webhook',- inputs: {- url: { value: 'https://example.com/hooks/activation-outcomes' },- method: { value: 'POST' },- body: { value: { account_id: '{person.id}' }, templating: 'hog' },- },- },- },- {- id: 'record-self-serve-account',- type: 'function',- name: 'Record self-serve account',- description: 'Record accounts that do not match a managed stage.',- config: {- template_id: 'template-webhook',- inputs: {- url: { value: 'https://example.com/hooks/self-serve' },- method: { value: 'POST' },- body: { value: { account_id: '{person.id}', path: 'self_serve' }, templating: 'hog' },- },- },- },- {- id: 'pause-before-summary',- type: 'delay',- name: 'Pause before summary',- description: 'Wait 30 seconds before recording the final outcome.',- config: { delay_duration: '30s' },- },- {- id: 'record-workflow-outcome',- type: 'function',- name: 'Record workflow outcome',- description: 'Send the completed route to the example endpoint.',- config: {- template_id: 'template-webhook',- inputs: {- url: { value: 'https://example.com/hooks/outcomes' },- method: { value: 'POST' },- body: { value: { account_id: '{person.id}', status: 'complete' }, templating: 'hog' },- },- },- },- {- id: 'exit',- type: 'exit',- name: 'End workflow',- description: 'The account has completed its onboarding route.',- config: { reason: 'Onboarding route completed' },- },- ] as HogFlowAction[],- edges: [- { from: 'trigger', to: 'route-by-stage', type: 'continue' },- { from: 'route-by-stage', to: 'notify-account-team', type: 'branch', index: 0 },- { from: 'notify-account-team', to: 'wait-for-business-hours', type: 'continue' },- { from: 'wait-for-business-hours', to: 'pause-before-summary', type: 'continue' },- { from: 'route-by-stage', to: 'choose-onboarding-path', type: 'branch', index: 1 },- { from: 'choose-onboarding-path', to: 'create-onboarding-task', type: 'branch', index: 0 },- { from: 'create-onboarding-task', to: 'pause-before-summary', type: 'continue' },- { from: 'choose-onboarding-path', to: 'wait-one-day', type: 'branch', index: 1 },- { from: 'wait-one-day', to: 'send-self-serve-reminder', type: 'continue' },- { from: 'send-self-serve-reminder', to: 'pause-before-summary', type: 'continue' },- { from: 'choose-onboarding-path', to: 'hold-control-group', type: 'continue' },- { from: 'hold-control-group', to: 'pause-before-summary', type: 'continue' },- { from: 'route-by-stage', to: 'wait-for-activation', type: 'branch', index: 2 },- { from: 'wait-for-activation', to: 'share-activation', type: 'branch', index: 0 },- { from: 'share-activation', to: 'send-activation-outcome', type: 'continue' },- { from: 'wait-for-activation', to: 'create-follow-up-task', type: 'continue' },- { from: 'create-follow-up-task', to: 'send-activation-outcome', type: 'continue' },- { from: 'send-activation-outcome', to: 'pause-before-summary', type: 'continue' },- { from: 'route-by-stage', to: 'record-self-serve-account', type: 'continue' },- { from: 'record-self-serve-account', to: 'pause-before-summary', type: 'continue' },- { from: 'pause-before-summary', to: 'record-workflow-outcome', type: 'continue' },- { from: 'record-workflow-outcome', to: 'exit', type: 'continue' },- ],- created_at: '2026-09-04T12:00:00.000Z',- updated_at: '2026-09-04T12:00:00.000Z',-}--const meta: Meta<typeof HogFlowTreeEditor> = {- title: 'Products/Workflows/Editor/Tree',- component: HogFlowTreeEditor,- parameters: {- featureFlags: [FEATURE_FLAGS.WORKFLOWS_LINEAR_VIEW],- layout: 'fullscreen',- mockDate: '2026-09-04 12:00:00',- testOptions: {- waitForLoadersToDisappear: true,- waitForSelector: '[data-attr=workflow-tree-editor]',- viewport: { width: 1600, height: 1000 },- },- },- decorators: [- (Story, context) => (- <ResetFeaturePreviewDismissal storyId={context.id}>- <Story />- </ResetFeaturePreviewDismissal>- ),- mswDecorator({- get: {- '/api/environments/:team_id/hog_flows/:id/': ({ params }) => [- 200,- PICKABLE_WORKFLOWS[String(params.id)] ?? COMPLEX_WORKFLOW,- ],- '/api/environments/:team_id/messaging_categories': { count: 0, results: [] },- },- patch: {- '/api/environments/:team_id/hog_flows/:id/': async ({ request, params }) => [- 200,- {- ...(PICKABLE_WORKFLOWS[String(params.id)] ?? COMPLEX_WORKFLOW),- ...((await request.json()) as Partial<HogFlow>),- updated_at: '2026-09-04T12:01:00.000Z',- },- ],- },- post: {- '/api/environments/:team_id/hog_flows/user_blast_radius/': {- affected: 240,- total: 1200,- limit: 100000,- dedupe_key: null,- confirm_token: 'storybook-confirm-token',- },- },- }),- ],-}-export default meta--const PICKABLE_WORKFLOWS: Record<string, HogFlow> = {- new: NEW_WORKFLOW,- [COMPLEX_WORKFLOW_ID]: COMPLEX_WORKFLOW,- ...EXAMPLE_WORKFLOWS,-}--const InteractiveWorkflow = ({ id, className }: { id: string; className?: string }): JSX.Element => (- <BindLogic logic={workflowLogic} props={{ id }}>- <div className={`h-screen ${className ?? ''} [&>div]:!h-full [&>div]:!max-h-none`}>- <Workflow id={id} />- </div>- </BindLogic>-)--export const CustomerOnboardingAndRetention: StoryFn = () => <InteractiveWorkflow id={COMPLEX_WORKFLOW_ID} />-export const NarrowCustomerOnboardingAndRetention: StoryFn = () => (- <InteractiveWorkflow id={COMPLEX_WORKFLOW_ID} className="w-5xl max-w-full" />-)-export const NewWorkflow: StoryFn = () => <InteractiveWorkflow id="new" />-export const NarrowWorkflow: StoryFn = () => <InteractiveWorkflow id="new" className="w-[40rem] max-w-full" />-export const SupportSlaRouting: StoryFn = () => <InteractiveWorkflow id="example-support-sla-routing" />-export const RenewalWindowAlerts: StoryFn = () => <InteractiveWorkflow id="example-renewal-window-alerts" />-export const PendingTicketCleanup: StoryFn = () => <InteractiveWorkflow id="example-pending-ticket-cleanup" />-export const AddOnPromotionEmails: StoryFn = () => <InteractiveWorkflow id="example-add-on-promotion-emails" />diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.tsxdeleted file mode 100644index 2cb4d2c48f4d..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.tsx+++ /dev/null@@ -1,315 +0,0 @@-import { useActions, useValues } from 'kea'-import { useEffect, useMemo, useRef, useState } from 'react'-import type { DragEvent } from 'react'--import { LemonButton } from 'lib/lemon-ui/LemonButton'-import { ScrollArea, ScrollBar } from 'lib/ui/quill'--import { setHogFlowDragImage } from '../dragPreview'-import { useHogFlowBranchSelection } from '../HogFlowBranchSelection'-import { hogFlowEditorLogic } from '../hogFlowEditorLogic'-import type { HogFlowEdge } from '../types'-import { HogFlowTreeCollapseAllButton } from './HogFlowTreeCollapseAllButton'-import { HogFlowTreeDropzone } from './HogFlowTreeDropzone'-import { HogFlowTreeFeaturePreview } from './HogFlowTreeFeaturePreview'-import { HogFlowTreeFocusHeader } from './HogFlowTreeFocusHeader'-import { HogFlowTreeNode } from './HogFlowTreeNode'-import { buildWorkflowTree } from './workflowTree'-import {- findWorkflowTreePath,- getWorkflowTreeBranchGroups,- getWorkflowTreeContinuationPath,- getWorkflowTreeOccurrenceKey,- getWorkflowTreeStepId,- WORKFLOW_TREE_BRANCH_LIMIT,- type WorkflowTreeNodeViewState,-} from './workflowTreePresentation'--export function HogFlowTreeEditor(): JSX.Element {- const { nodeToBeAdded, workflow, treePathsCollapsedByDefault } = useValues(hogFlowEditorLogic)- const { setSelectedNodeId, setTreePathsCollapsedByDefault } = useActions(hogFlowEditorLogic)- const { setSelectedBranch } = useHogFlowBranchSelection()- const [focusedEdges, setFocusedEdges] = useState<HogFlowEdge[]>([])- const [focusTarget, setFocusTarget] = useState<string | null>(null)- const [viewStates, setViewStates] = useState<Record<string, WorkflowTreeNodeViewState>>({})- const treeRef = useRef<HTMLDivElement>(null)- const draggedActionIdRef = useRef<string | null>(null)- const [draggedActionId, setDraggedActionId] = useState<string | null>(null)- const draggedStepRef = useRef<HTMLElement | null>(null)- const closestDropzoneRef = useRef<HTMLElement | null>(null)- const dragStartYRef = useRef<number | null>(null)- const tree = useMemo(() => buildWorkflowTree(workflow), [workflow])- const focusedPath = useMemo(() => findWorkflowTreePath(tree, focusedEdges), [tree, focusedEdges])- const focused = focusedPath.at(-1)- const focusedContinuation = focused ? (focused.branch.sequence.continueTo ?? focused.node.joinAction) : null- const activeDropzones = !!nodeToBeAdded-- const updateViewState = (key: string, state: WorkflowTreeNodeViewState): void => {- setViewStates((current) => ({ ...current, [key]: { ...current[key], ...state } }))- }-- // The remembered choice applies once per workflow, so editing a step does not re-collapse- // paths the person opened since.- const defaultAppliedToRef = useRef<string | null>(null)- useEffect(() => {- if (!treePathsCollapsedByDefault || defaultAppliedToRef.current === workflow.id) {- return- }- const groups = getWorkflowTreeBranchGroups(tree)- if (!groups.length) {- return- }- defaultAppliedToRef.current = workflow.id- setViewStates((current) => {- const next = { ...current }- for (const group of groups) {- next[group.occurrenceKey] = {- ...next[group.occurrenceKey],- branchesOpen: true,- collapsedBranches: new Set(group.branchKeys),- }- }- return next- })- }, [tree, workflow.id, treePathsCollapsedByDefault])-- const focusBranch = (edges: HogFlowEdge[]): void => {- setSelectedBranch(null)- setSelectedNodeId(null)- setFocusedEdges(edges)- setFocusTarget('workflow-tree-exit-focus')- }-- const revealPath = (path: HogFlowEdge[]): void => {- for (const [index, { node, branch }] of findWorkflowTreePath(tree, path).entries()) {- const key = getWorkflowTreeOccurrenceKey(node.action.id, path.slice(0, index))- const collapsedBranches = new Set(viewStates[key]?.collapsedBranches)- collapsedBranches.delete(`${branch.edge.from}-${branch.edge.type}-${branch.edge.index ?? 'continue'}`)- updateViewState(key, {- branchesOpen: true,- showAllBranches:- viewStates[key]?.showAllBranches ||- node.branches.filter((item) => item.edge.type === 'branch').indexOf(branch) >=- WORKFLOW_TREE_BRANCH_LIMIT,- collapsedBranches,- })- }- }-- const returnToWorkflow = (): void => {- if (focused) {- revealPath(focusedEdges.slice(0, -1))- setFocusedEdges([])- setFocusTarget(`workflow-tree-path-${getWorkflowTreeOccurrenceKey(focused.node.action.id, focusedEdges)}`)- }- }-- const selectContinuation = (actionId: string): void => {- setSelectedBranch(null)- setSelectedNodeId(actionId)- const destinationPath = getWorkflowTreeContinuationPath(tree, actionId)- revealPath(destinationPath)- // A path inside the focused view can join at a step that the focused view also shows, so leave- // focus only for a join that the user cannot already see.- if (- focused &&- getWorkflowTreeOccurrenceKey(actionId, destinationPath.slice(0, focusedEdges.length)) !==- getWorkflowTreeOccurrenceKey(actionId, focusedEdges)- ) {- setFocusedEdges([])- }- setFocusTarget(getWorkflowTreeStepId(actionId, destinationPath))- }-- useEffect(() => {- if (!focusTarget) {- return- }- const frame = requestAnimationFrame(() => {- const target = document.getElementById(focusTarget)- const control = target instanceof HTMLButtonElement ? target : target?.querySelector('button')- control?.focus({ preventScroll: true })- target?.scrollIntoView({ block: 'nearest' })- setFocusTarget(null)- })- return () => cancelAnimationFrame(frame)- }, [focusTarget])-- const clearClosestDropzone = (): void => {- closestDropzoneRef.current?.removeAttribute('data-workflow-tree-dropzone-closest')- closestDropzoneRef.current = null- }-- useEffect(() => {- if (!activeDropzones) {- clearClosestDropzone()- }- }, [activeDropzones])-- const onDragStart = (- event: DragEvent<HTMLDivElement>,- actionId: string,- dragPreviewElement: HTMLDivElement | null- ): void => {- event.dataTransfer.effectAllowed = 'move'- event.dataTransfer.setData('text/plain', actionId)- dragStartYRef.current = event.clientY- const step = event.currentTarget.closest('[data-attr="workflow-tree-step"]')- if (step instanceof HTMLElement && typeof event.dataTransfer.setDragImage === 'function') {- setHogFlowDragImage(event.dataTransfer, dragPreviewElement)- step.dataset.workflowTreeDragging = 'true'- draggedStepRef.current = step- }- draggedActionIdRef.current = actionId- setDraggedActionId(actionId)- treeRef.current?.setAttribute('data-workflow-tree-dragging', 'true')- }-- const onTreeDragOver = (event: DragEvent<HTMLDivElement>): void => {- if (!draggedActionIdRef.current && !activeDropzones) {- return- }-- event.preventDefault()- if (dragStartYRef.current !== null && Math.abs(event.clientY - dragStartYRef.current) < 16) {- clearClosestDropzone()- return- }-- const candidates = Array.from(- treeRef.current?.querySelectorAll<HTMLElement>('[data-workflow-tree-dropzone-candidate]') ?? []- ).filter((candidate) => {- if (candidate.dataset.workflowTreeDropzoneDisabled === 'true') {- return false- }-- let ancestor: HTMLElement | null = candidate- while (ancestor) {- if (ancestor.dataset.workflowTreeBranchContent === draggedActionIdRef.current) {- return false- }- ancestor = ancestor.parentElement- }- return true- })- const closestDropzone = candidates.reduce<HTMLElement | null>((closest, candidate) => {- if (!closest) {- return candidate- }- const closestCenter = closest.getBoundingClientRect().top + closest.getBoundingClientRect().height / 2- const candidateCenter = candidate.getBoundingClientRect().top + candidate.getBoundingClientRect().height / 2- return Math.abs(event.clientY - candidateCenter) < Math.abs(event.clientY - closestCenter)- ? candidate- : closest- }, null)-- if (closestDropzone !== closestDropzoneRef.current) {- clearClosestDropzone()- closestDropzone?.setAttribute('data-workflow-tree-dropzone-closest', 'true')- closestDropzoneRef.current = closestDropzone- }- }-- const onTreeDropCapture = (event: DragEvent<HTMLDivElement>): void => {- const nativeEvent = event.nativeEvent as globalThis.DragEvent & { workflowTreeNearestDrop?: boolean }- if (nativeEvent.workflowTreeNearestDrop) {- return- }-- event.preventDefault()- event.stopPropagation()- const closestDropzone = closestDropzoneRef.current- if (!closestDropzone) {- onDragEnd()- return- }-- const dropEvent = new window.DragEvent('drop', {- bubbles: true,- cancelable: true,- clientX: event.clientX,- clientY: event.clientY,- dataTransfer: event.dataTransfer,- }) as globalThis.DragEvent & { workflowTreeNearestDrop?: boolean }- dropEvent.workflowTreeNearestDrop = true- closestDropzone.querySelector<HTMLElement>('[data-attr="workflow-tree-dropzone"]')?.dispatchEvent(dropEvent)- }-- const onDragEnd = (): void => {- clearClosestDropzone()- dragStartYRef.current = null- treeRef.current?.removeAttribute('data-workflow-tree-dragging')- draggedStepRef.current?.removeAttribute('data-workflow-tree-dragging')- draggedStepRef.current = null- draggedActionIdRef.current = null- setDraggedActionId(null)- }-- return (- <div className="flex min-h-0 min-w-0 flex-1 flex-col">- <HogFlowTreeFeaturePreview />- <ScrollArea- className="min-h-0 min-w-0 flex-1 bg-background @max-[48rem]/workflow-editor:min-h-80 @max-[48rem]/workflow-editor:shrink-0"- data-quill- data-attr="workflow-tree-editor"- >- <div- ref={treeRef}- className="group/tree mx-auto flex w-full max-w-3xl flex-col p-4"- onDragOver={onTreeDragOver}- onDropCapture={onTreeDropCapture}- >- {focused ? (- <HogFlowTreeFocusHeader focusedPath={focusedPath} onReturnToWorkflow={returnToWorkflow} />- ) : (- <HogFlowTreeCollapseAllButton- tree={tree}- viewStates={viewStates}- onViewStateChange={updateViewState}- onCollapsedChange={setTreePathsCollapsedByDefault}- />- )}- {(focused?.branch.sequence ?? tree).nodes.map((node) => (- <HogFlowTreeNode- key={node.action.id}- node={node}- activeDropzones={activeDropzones}- draggedActionId={draggedActionId}- draggedActionIdRef={draggedActionIdRef}- onDragStart={onDragStart}- onDragEnd={onDragEnd}- onFocusBranch={focusBranch}- onSelectContinuation={selectContinuation}- path={focused ? focusedEdges : []}- viewStates={viewStates}- onViewStateChange={updateViewState}- />- ))}- {focused?.branch.sequence.trailingEdge && (- <HogFlowTreeDropzone- active={activeDropzones}- draggedActionId={draggedActionId}- draggedActionIdRef={draggedActionIdRef}- onDragEnd={onDragEnd}- edge={focused.branch.sequence.trailingEdge}- alwaysVisible={focused.branch.sequence.nodes.length === 0}- insertionLabel={`Add step to ${focused.branch.label}`}- />- )}- {focusedContinuation && (- <LemonButton- type="secondary"- size="small"- className="self-start max-w-full mt-3"- onClick={() => selectContinuation(focusedContinuation.id)}- data-attr="workflow-tree-focus-continuation"- >- <span className="break-words whitespace-normal">{`Continue to: ${focusedContinuation.name}`}</span>- </LemonButton>- )}- </div>- <ScrollBar orientation="vertical" />- </ScrollArea>- </div>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeFeaturePreview.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeFeaturePreview.tsxdeleted file mode 100644index df31177b291b..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeFeaturePreview.tsx+++ /dev/null@@ -1,21 +0,0 @@-import { FeaturePreviewFeedbackBanner } from '../../../FeaturePreviewFeedbackBanner'--const SURVEY_ID = '01a0856f-7ae3-0000-eef6-fec0a2e1b78f'-const RATING_QUESTION_ID = 'a899da8d-092a-41ce-ab9b-8e18b2c7cfd8'-const FEEDBACK_QUESTION_ID = 'acbad4b5-52c2-4a56-a280-5d2ddd064612'--export function HogFlowTreeFeaturePreview(): JSX.Element {- return (- <FeaturePreviewFeedbackBanner- surveyId={SURVEY_ID}- ratingQuestionId={RATING_QUESTION_ID}- feedbackQuestionId={FEEDBACK_QUESTION_ID}- surface="workflow_tree_editor"- dismissKey="workflow-tree-feature-preview"- prompt="We’re trialling a new list based workflow view. What do you think?"- feedbackTitle="Help shape the new workflow view"- feedbackPlaceholder="Tell us what works, what doesn’t, or what you’d change"- data-attr="workflow-tree-feature-preview"- />- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeFocusHeader.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeFocusHeader.tsxdeleted file mode 100644index 13a2d6bf9b64..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeFocusHeader.tsx+++ /dev/null@@ -1,37 +0,0 @@-import { LemonButton } from 'lib/lemon-ui/LemonButton'-import { LemonCard } from 'lib/lemon-ui/LemonCard'--import { getWorkflowTreeBranchSummary, type WorkflowTreePath } from './workflowTreePresentation'--export function HogFlowTreeFocusHeader({- focusedPath,- onReturnToWorkflow,-}: {- focusedPath: WorkflowTreePath[]- onReturnToWorkflow: () => void-}): JSX.Element | null {- const focused = focusedPath.at(-1)- if (!focused) {- return null- }- return (- <LemonCard hoverEffect={false} className="mb-3 p-3">- <LemonButton- type="tertiary"- size="small"- onClick={onReturnToWorkflow}- id="workflow-tree-exit-focus"- data-attr="workflow-tree-exit-focus"- >- Back to workflow- </LemonButton>- <p className="my-2 break-words text-xs text-secondary">- {focusedPath.map(({ node, branch }) => `${node.action.name} › ${branch.label}`).join(' › ')}- </p>- <h3 className="mb-1 break-words">{focused.branch.label}</h3>- <p className="mb-0 break-words text-xs text-secondary">- {getWorkflowTreeBranchSummary(focused.node, focused.branch)}- </p>- </LemonCard>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeNode.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeNode.tsxdeleted file mode 100644index 5f44269b528c..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeNode.tsx+++ /dev/null@@ -1,249 +0,0 @@-import { Fragment, useEffect, useRef } from 'react'-import type { DragEvent } from 'react'--import { IconChevronDown } from '@posthog/icons'--import { LemonButton } from 'lib/lemon-ui/LemonButton'-import { cn } from 'lib/utils/css-classes'--import { useHogFlowBranchSelection } from '../HogFlowBranchSelection'-import type { HogFlowEdge } from '../types'-import { HogFlowTreeBranch } from './HogFlowTreeBranch'-import { HogFlowTreeDropzone } from './HogFlowTreeDropzone'-import { HogFlowTreeStep } from './HogFlowTreeStep'-import type { WorkflowTreeNode } from './workflowTree'-import {- getWorkflowTreeOccurrenceKey,- getWorkflowTreeStepId,- WORKFLOW_TREE_BRANCH_LIMIT,- type WorkflowTreeNodeViewState,-} from './workflowTreePresentation'--export function HogFlowTreeNode({- activeDropzones,- draggedActionId,- draggedActionIdRef,- node,- onDragEnd,- onDragStart,- showIncomingConnector = true,- onFocusBranch,- onSelectContinuation,- path,- viewStates,- onViewStateChange,-}: {- activeDropzones: boolean- draggedActionId: string | null- draggedActionIdRef: { current: string | null }- node: WorkflowTreeNode- onDragEnd: () => void- onDragStart: (event: DragEvent<HTMLDivElement>, actionId: string, dragPreviewElement: HTMLDivElement | null) => void- showIncomingConnector?: boolean- onFocusBranch?: (path: HogFlowEdge[]) => void- onSelectContinuation: (actionId: string) => void- path: HogFlowEdge[]- viewStates: Record<string, WorkflowTreeNodeViewState>- onViewStateChange: (key: string, state: WorkflowTreeNodeViewState) => void-}): JSX.Element {- const { selectedBranch } = useHogFlowBranchSelection()- const occurrenceKey = getWorkflowTreeOccurrenceKey(node.action.id, path)- const {- branchesOpen = true,- collapsedBranches = new Set<string>(),- showAllBranches = false,- } = viewStates[occurrenceKey] ?? {}- const nodeRef = useRef<HTMLDivElement>(null)- const branchContentRef = useRef<HTMLDivElement>(null)- const branchToggleRef = useRef<HTMLButtonElement>(null)- const pendingBranchToggle = useRef(false)- const conditionBranches = node.branches.filter((branch) => branch.edge.type === 'branch')- const visibleBranches = showAllBranches- ? node.branches- : [- ...conditionBranches.slice(0, WORKFLOW_TREE_BRANCH_LIMIT),- ...node.branches.filter((branch) => branch.edge.type === 'continue'),- ]- const hiddenBranchCount = node.branches.length - visibleBranches.length- const visibleConditionCount = showAllBranches ? conditionBranches.length : WORKFLOW_TREE_BRANCH_LIMIT- const firstHiddenBranchIndex = conditionBranches[WORKFLOW_TREE_BRANCH_LIMIT]?.edge.index- const joinEdge = node.joinEdges[0]- const branchNoun = node.action.type === 'conditional_branch' ? 'conditions' : 'paths'-- const toggleBranchCollapsed = (branchKey: string): void => {- const next = new Set(collapsedBranches)- next.has(branchKey) ? next.delete(branchKey) : next.add(branchKey)- onViewStateChange(occurrenceKey, { collapsedBranches: next })- }-- useEffect(() => {- if (!pendingBranchToggle.current) {- return- }- pendingBranchToggle.current = false- const target = showAllBranches- ? branchContentRef.current?.querySelector<HTMLButtonElement>(- `:scope > [data-workflow-branch-index="${firstHiddenBranchIndex}"] [data-attr="workflow-tree-select-branch"]`- )- : branchToggleRef.current- target?.focus({ preventScroll: true })- target?.scrollIntoView({ block: showAllBranches ? 'start' : 'nearest' })- }, [showAllBranches, firstHiddenBranchIndex])-- useEffect(() => {- if (selectedBranch?.actionId === node.action.id) {- nodeRef.current- ?.querySelector(`[data-workflow-branch-index="${selectedBranch.index ?? 'continue'}"]`)- ?.scrollIntoView({ block: 'nearest' })- }- }, [node.action.id, selectedBranch])-- const step = (- <HogFlowTreeStep- action={node.action}- stepId={getWorkflowTreeStepId(node.action.id, path)}- collapseControl={- node.branches.length > 0 ? (- <LemonButton- type="tertiary"- size="small"- className="!bg-transparent"- aria-label={`${branchesOpen ? 'Hide' : 'Show'} ${branchNoun}`}- aria-expanded={branchesOpen}- tooltip={`${branchesOpen ? 'Hide' : 'Show'} ${branchNoun}`}- icon={<IconChevronDown className={cn(!branchesOpen && '-rotate-90')} />}- onClick={() => onViewStateChange(occurrenceKey, { branchesOpen: !branchesOpen })}- />- ) : undefined- }- onDragStart={onDragStart}- onDragEnd={onDragEnd}- canDrag={- node.action.type !== 'trigger' &&- node.action.type !== 'exit' &&- (!node.branches.length || !!node.joinActionId)- }- />- )-- return (- <div ref={nodeRef} className="flex w-full min-w-0 flex-col">- {node.incomingEdge && (- <HogFlowTreeDropzone- active={activeDropzones}- draggedActionId={draggedActionId}- draggedActionIdRef={draggedActionIdRef}- onDragEnd={onDragEnd}- edge={node.incomingEdge}- showConnector={showIncomingConnector}- compact={!showIncomingConnector}- />- )}- {node.branches.length === 0 ? (- step- ) : (- <>- <div className="min-w-0">- {step}- {branchesOpen && (- <div- ref={branchContentRef}- className="flex min-w-0 flex-col gap-3 pt-3"- data-workflow-tree-branch-content={node.action.id}- >- {visibleBranches.map((branch, index) => {- const branchKey = `${branch.edge.from}-${branch.edge.type}-${branch.edge.index ?? 'continue'}`- return (- <Fragment key={branchKey}>- <HogFlowTreeBranch- node={node}- branch={branch}- index={index}- isLast={index === visibleBranches.length - 1}- branchCollapsed={collapsedBranches.has(branchKey)}- onToggleCollapsed={() => toggleBranchCollapsed(branchKey)}- onFocusBranch={onFocusBranch}- onSelectContinuation={onSelectContinuation}- path={path}- >- {branch.sequence.nodes.map((childNode, childIndex) => (- <HogFlowTreeNode- key={childNode.action.id}- node={childNode}- activeDropzones={activeDropzones}- draggedActionId={draggedActionId}- draggedActionIdRef={draggedActionIdRef}- onDragStart={onDragStart}- onDragEnd={onDragEnd}- showIncomingConnector={childIndex > 0}- onFocusBranch={onFocusBranch}- onSelectContinuation={onSelectContinuation}- path={[...path, branch.edge]}- viewStates={viewStates}- onViewStateChange={onViewStateChange}- />- ))}- {branch.sequence.trailingEdge && (- <HogFlowTreeDropzone- active={activeDropzones}- draggedActionId={draggedActionId}- draggedActionIdRef={draggedActionIdRef}- onDragEnd={onDragEnd}- edge={branch.sequence.trailingEdge}- showConnector={false}- alwaysVisible={branch.sequence.nodes.length === 0}- insertionLabel={`Add step to ${branch.label}`}- />- )}- </HogFlowTreeBranch>- {conditionBranches.length > WORKFLOW_TREE_BRANCH_LIMIT &&- index === visibleConditionCount - 1 && (- <div className="relative ps-8">- {index < visibleBranches.length - 1 && (- <span- aria-hidden="true"- className="pointer-events-none absolute start-2 -top-3 -bottom-3 border-s-2 border-[var(--border-bold-3000)]"- />- )}- <LemonButton- ref={branchToggleRef}- type="secondary"- size="xsmall"- aria-expanded={showAllBranches}- onClick={() => {- pendingBranchToggle.current = true- onViewStateChange(occurrenceKey, {- showAllBranches: !showAllBranches,- })- }}- data-attr="workflow-tree-toggle-more-branches"- >- {showAllBranches- ? 'Show fewer branches'- : `Show ${hiddenBranchCount} more branches`}- </LemonButton>- </div>- )}- </Fragment>- )- })}- </div>- )}- </div>- {joinEdge && (- <HogFlowTreeDropzone- active={activeDropzones}- draggedActionId={draggedActionId}- draggedActionIdRef={draggedActionIdRef}- onDragEnd={onDragEnd}- edge={joinEdge}- isBranchJoin- joinEdges={node.joinEdges}- insertionLabel={`Add step after ${node.action.name} paths`}- />- )}- </>- )}- </div>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeStep.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeStep.tsxdeleted file mode 100644index 93164e39e8e7..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeStep.tsx+++ /dev/null@@ -1,203 +0,0 @@-import { useActions, useValues } from 'kea'-import { useRef } from 'react'-import type { DragEvent, ReactNode } from 'react'--import { IconCopy, IconDrag, IconTrash } from '@posthog/icons'--import { Badge, Button, Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle, cn } from 'lib/ui/quill'--import { workflowLogic } from '../../workflowLogic'-import { useHogFlowBranchSelection } from '../HogFlowBranchSelection'-import { hogFlowEditorLogic } from '../hogFlowEditorLogic'-import { StepView } from '../steps/components/StepView'-import { useHogFlowStep } from '../steps/HogFlowSteps'-import type { HogFlowAction, HogFlowActionNode } from '../types'-import { isBranchingAction } from './workflowTree'--export function HogFlowTreeStep({- action,- onDragEnd,- onDragStart,- collapseControl,- stepId,- canDrag = !['trigger', 'exit'].includes(action.type) && !isBranchingAction(action),-}: {- action: HogFlowAction- onDragEnd: () => void- onDragStart: (event: DragEvent<HTMLDivElement>, actionId: string, dragPreviewElement: HTMLDivElement | null) => void- collapseControl?: ReactNode- stepId: string- canDrag?: boolean-}): JSX.Element {- const { animatingEdgePair, nodesById, selectedNode } = useValues(hogFlowEditorLogic)- const { duplicateNodeBelow, onNodesDelete, setSelectedNodeId } = useActions(hogFlowEditorLogic)- const { setSelectedBranch } = useHogFlowBranchSelection()- const { actionValidationErrorsById, workflow } = useValues(workflowLogic)- const step = useHogFlowStep(action)- const dragPreviewRef = useRef<HTMLDivElement>(null)-- const isSelected = selectedNode?.id === action.id- const canHaveActions = !['trigger', 'exit'].includes(action.type)- const outgoingActionIds = workflow.edges.filter((edge) => edge.from === action.id).map((edge) => edge.to)- const canDelete = canHaveActions && (outgoingActionIds.length === 1 || new Set(outgoingActionIds).size === 1)- const canDuplicate = canDelete && !isBranchingAction(action)- const node =- nodesById[action.id] ??- ({- id: action.id,- type: 'action',- data: action,- position: { x: 0, y: 0 },- deletable: canHaveActions,- selectable: true,- draggable: false,- connectable: false,- } satisfies HogFlowActionNode)- const validationResult = actionValidationErrorsById[action.id]- const hasValidationIssue =- validationResult?.valid === false || Object.keys(validationResult?.warnings ?? {}).length > 0- const isAnimationTarget = animatingEdgePair?.endsWith(`->${action.id}`) ?? false- const previews = step?.previews ?? []- const hasFooterContent = !!action.description || previews.length > 0-- return (- <Item- variant="outline"- size="xs"- className={cn(- 'relative flex-nowrap !gap-2 bg-card !px-2 !py-1.5',- isSelected && 'border-ring ring-2 ring-ring/30',- isAnimationTarget && 'border-success',- 'data-[workflow-tree-dragging]:opacity-50'- )}- data-attr="workflow-tree-step"- id={stepId}- >- <Button- type="button"- variant="link"- className="absolute inset-0 z-0 h-full w-full"- aria-label={`Edit ${action.name}`}- aria-pressed={isSelected}- onClick={() => {- setSelectedBranch(null)- setSelectedNodeId(action.id)- }}- />- {canDrag && (- <div- draggable- className="relative z-10 -ms-0.5 -me-1 flex size-5 shrink-0 cursor-grab items-center justify-center text-muted-foreground active:cursor-grabbing"- onDragStart={(event) => onDragStart(event, action.id, dragPreviewRef.current)}- onDragEnd={onDragEnd}- data-attr="workflow-tree-step-drag"- >- <IconDrag className="size-4" />- </div>- )}- <ItemMedia- variant="image"- className="pointer-events-none relative z-10 !size-8 shrink-0 [&>img]:!size-6 [&>img]:!object-contain [&>svg]:!size-6 [&>svg]:shrink-0"- style={- step?.color- ? {- alignSelf: 'center',- translate: 'none',- backgroundColor: `${step.color}20`,- color: step.color,- }- : { alignSelf: 'center', translate: 'none' }- }- >- {step?.icon}- </ItemMedia>- <ItemContent className="pointer-events-none relative z-10 min-w-0 gap-0.5">- <div className="flex min-w-0 items-center gap-1">- <ItemTitle className="pointer-events-none min-w-0 flex-1 max-w-full break-words whitespace-normal leading-tight">- {action.name}- </ItemTitle>- {canHaveActions && (- <ItemActions- className={cn(- 'pointer-events-auto',- '!gap-px ms-auto shrink-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100',- isSelected ? 'opacity-100' : 'opacity-20'- )}- >- {canDuplicate && (- <Button- type="button"- variant="default"- size="icon-sm"- aria-label="Duplicate step"- title="Duplicate step"- onClick={() => duplicateNodeBelow(action.id)}- data-attr="workflow-tree-duplicate-step"- >- <IconCopy />- </Button>- )}- <Button- type="button"- variant="default"- size="icon-sm"- aria-label="Delete step"- title={canDelete ? 'Delete step' : 'Clean up branching steps first'}- disabled={!canDelete}- onClick={() => {- onNodesDelete([node])- setSelectedNodeId(null)- }}- data-attr="workflow-tree-delete-step"- >- <IconTrash />- </Button>- </ItemActions>- )}- </div>- {hasFooterContent && (- <div className="flex min-w-0 flex-wrap items-center gap-2">- {action.description && (- <ItemDescription className="pointer-events-none min-w-0 flex-1 whitespace-normal break-words leading-tight">- {action.description}- </ItemDescription>- )}- {previews.length > 0 && (- <div className="pointer-events-none ms-auto flex min-w-0 max-w-full flex-wrap items-center justify-end gap-1">- {previews.slice(0, 3).map((preview, index) => (- <Badge- key={`${preview.label}-${index}`}- variant="default"- className="max-w-full whitespace-normal break-words h-auto min-h-4 py-0 leading-tight"- >- {preview.icon}- {preview.label}- </Badge>- ))}- </div>- )}- </div>- )}- </ItemContent>- {collapseControl && (- <div className="pointer-events-auto relative z-10 -my-1.5 -me-2 flex w-10 shrink-0 items-center justify-center border-s">- {collapseControl}- </div>- )}- {hasValidationIssue && (- <Badge- variant="warning"- className="pointer-events-none absolute -end-1 -top-1 z-20 !size-5 !min-w-5 shrink-0 !rounded-full border-2 border-card !p-0 !leading-none shadow-sm"- aria-label="Some fields need attention"- >- !- </Badge>- )}- <div ref={dragPreviewRef} className="pointer-events-none absolute invisible" aria-hidden="true">- <div className="origin-top-left scale-150">- <StepView action={{ ...action, id: `drag-preview-${action.id}` }} />- </div>- </div>- </Item>- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/workflowTree.test.ts b/products/workflows/frontend/Workflows/hogflows/tree/workflowTree.test.tsdeleted file mode 100644index 67134edfba6c..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/workflowTree.test.ts+++ /dev/null@@ -1,506 +0,0 @@-import type { HogFlow, HogFlowAction, HogFlowEdge } from '../types'-import {- buildWorkflowTree,- computeMoveTreeBranchEdges,- getWorkflowBranchLabel,- isWorkflowTreeComplete,-} from './workflowTree'-import {- areAllWorkflowTreeBranchesCollapsed,- findWorkflowTreePath,- getWorkflowTreeBranchGroups,- getWorkflowTreeBranchSummary,- getWorkflowTreeContinuationPath,- getWorkflowTreeOccurrenceKey,- getWorkflowTreeStepIds,-} from './workflowTreePresentation'--const action = (id: string, type: HogFlowAction['type'] = 'function'): HogFlowAction =>- ({ id, type, name: id, description: '', config: {} }) as HogFlowAction--const edge = (from: string, to: string, type: HogFlowEdge['type'] = 'continue', index?: number): HogFlowEdge => ({- from,- to,- type,- index,-})--const workflow = (actions: HogFlowAction[], edges: HogFlowEdge[]): Pick<HogFlow, 'actions' | 'edges'> => ({- actions,- edges,-})--describe('buildWorkflowTree', () => {- it('falls back when an action is unreachable from the trigger', () => {- expect(- isWorkflowTreeComplete(- workflow(- [action('trigger', 'trigger'), action('exit', 'exit'), action('orphan')],- [edge('trigger', 'exit')]- )- )- ).toBe(false)- })-- it('renders converging routes before one shared continuation', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('condition', 'conditional_branch'),- action('yes'),- action('no'),- action('shared'),- action('exit', 'exit'),- ],- [- edge('trigger', 'condition'),- edge('condition', 'yes', 'branch', 0),- edge('condition', 'no'),- edge('yes', 'shared'),- edge('no', 'shared'),- edge('shared', 'exit'),- ]- )- )-- expect(tree.nodes.map((node) => node.action.id)).toEqual(['trigger', 'condition', 'shared', 'exit'])- expect(tree.nodes[1].branches.map((branch) => branch.sequence.nodes.map((node) => node.action.id))).toEqual([- ['yes'],- ['no'],- ])- expect(tree.nodes[1].joinActionId).toBe('shared')- expect(tree.nodes[1].joinAction?.id).toBe('shared')- expect(getWorkflowTreeBranchSummary(tree.nodes[1], tree.nodes[1].branches[0])).toBe(- '1 step · Continue to: shared'- )- })-- it('keeps immediate routes empty and exposes their insertion edges', () => {- const tree = buildWorkflowTree(- workflow(- [action('trigger', 'trigger'), action('condition', 'conditional_branch'), action('exit', 'exit')],- [edge('trigger', 'condition'), edge('condition', 'exit', 'branch', 0), edge('condition', 'exit')]- )- )-- expect(tree.nodes.map((node) => node.action.id)).toEqual(['trigger', 'condition', 'exit'])- expect(tree.nodes[1].branches.map((branch) => branch.sequence.nodes)).toEqual([[], []])- expect(tree.nodes[1].branches.map((branch) => branch.sequence.trailingEdge)).toEqual([- edge('condition', 'exit', 'branch', 0),- edge('condition', 'exit'),- ])- expect(getWorkflowTreeBranchSummary(tree.nodes[1], tree.nodes[1].branches[0])).toBe(- '0 steps · Continue to: exit'- )- })-- it('leaves routes terminal when they have no shared continuation', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('condition', 'conditional_branch'),- action('left-exit', 'exit'),- action('right-exit', 'exit'),- ],- [- edge('trigger', 'condition'),- edge('condition', 'left-exit', 'branch', 0),- edge('condition', 'right-exit'),- ]- )- )-- expect(tree.nodes.map((node) => node.action.id)).toEqual(['trigger', 'condition'])- expect(tree.nodes[1].joinActionId).toBeNull()- expect(tree.nodes[1].branches.map((branch) => branch.sequence.nodes.map((node) => node.action.id))).toEqual([- ['left-exit'],- ['right-exit'],- ])- expect(getWorkflowTreeBranchSummary(tree.nodes[1], tree.nodes[1].branches[0])).toBe('1 step · End workflow')- })-- it('scopes a nested branch join to its own routes', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('outer', 'conditional_branch'),- action('paid'),- action('trial'),- action('at-risk'),- action('onboarding', 'conditional_branch'),- action('guided'),- action('self-serve'),- action('shared'),- action('exit', 'exit'),- ],- [- edge('trigger', 'outer'),- edge('outer', 'paid', 'branch', 0),- edge('outer', 'trial', 'branch', 1),- edge('outer', 'at-risk'),- edge('paid', 'shared'),- edge('trial', 'onboarding'),- edge('at-risk', 'shared'),- edge('onboarding', 'guided', 'branch', 0),- edge('onboarding', 'self-serve', 'branch', 1),- edge('onboarding', 'shared'),- edge('guided', 'shared'),- edge('self-serve', 'shared'),- edge('shared', 'exit'),- ]- )- )-- const onboarding = tree.nodes[1].branches[1].sequence.nodes.find((node) => node.action.id === 'onboarding')- expect(onboarding?.joinEdges).toEqual([- edge('guided', 'shared'),- edge('self-serve', 'shared'),- edge('onboarding', 'shared'),- ])- expect(getWorkflowTreeBranchSummary(tree.nodes[1], tree.nodes[1].branches[1])).toBe(- '4 steps · Continue to: shared'- )- expect(- findWorkflowTreePath(tree, [- edge('outer', 'trial', 'branch', 1),- edge('onboarding', 'guided', 'branch', 0),- ]).map(({ node, branch }) => [node.action.id, branch.edge.index])- ).toEqual([- ['outer', 1],- ['onboarding', 0],- ])- expect(- findWorkflowTreePath(tree, [- edge('outer', 'trial', 'branch', 1),- edge('deleted-branch', 'guided', 'branch', 0),- ])- ).toEqual([])- })-- it('joins a nested path that links to a step another route shows', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('outer', 'conditional_branch'),- action('inner', 'conditional_branch'),- action('shared'),- action('other'),- action('join'),- action('exit', 'exit'),- ],- [- edge('trigger', 'outer'),- edge('outer', 'shared', 'branch', 0),- edge('outer', 'inner'),- edge('inner', 'shared', 'branch', 0),- edge('inner', 'other'),- edge('shared', 'join'),- edge('other', 'join'),- edge('join', 'exit'),- ]- )- )-- const inner = tree.nodes[1].branches[1].sequence.nodes[0]- expect(inner.branches[0].sequence.continueTo?.id).toBe('shared')- expect(inner.joinEdges).toEqual([edge('shared', 'join'), edge('other', 'join')])- })-- it('collects branching steps nested inside a path so collapsing covers them', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('outer', 'conditional_branch'),- action('paid'),- action('trial'),- action('onboarding', 'conditional_branch'),- action('guided'),- action('self-serve'),- action('shared'),- action('exit', 'exit'),- ],- [- edge('trigger', 'outer'),- edge('outer', 'paid', 'branch', 0),- edge('outer', 'trial', 'branch', 1),- edge('paid', 'shared'),- edge('trial', 'onboarding'),- edge('onboarding', 'guided', 'branch', 0),- edge('onboarding', 'self-serve', 'branch', 1),- edge('guided', 'shared'),- edge('self-serve', 'shared'),- edge('shared', 'exit'),- ]- )- )-- const groups = getWorkflowTreeBranchGroups(tree)- expect(groups.map((group) => group.branchKeys.length)).toEqual([2, 2])- expect(groups[1].occurrenceKey).toBe(- getWorkflowTreeOccurrenceKey('onboarding', [edge('outer', 'trial', 'branch', 1)])- )-- const collapseOnly = (index: number): Record<string, { collapsedBranches: Set<string> }> => ({- [groups[index].occurrenceKey]: { collapsedBranches: new Set(groups[index].branchKeys) },- })- expect(areAllWorkflowTreeBranchesCollapsed(groups, collapseOnly(0))).toBe(false)- expect(areAllWorkflowTreeBranchesCollapsed(groups, { ...collapseOnly(0), ...collapseOnly(1) })).toBe(true)- })-- it('keeps a nested join inside the focused path and the outer join outside it', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('outer', 'conditional_branch'),- action('trial'),- action('paid'),- action('inner', 'conditional_branch'),- action('guided'),- action('self-serve'),- action('followup'),- action('shared'),- action('exit', 'exit'),- ],- [- edge('trigger', 'outer'),- edge('outer', 'trial', 'branch', 0),- edge('outer', 'paid'),- edge('trial', 'inner'),- edge('inner', 'guided', 'branch', 0),- edge('inner', 'self-serve'),- edge('guided', 'followup'),- edge('self-serve', 'followup'),- edge('followup', 'shared'),- edge('paid', 'shared'),- edge('shared', 'exit'),- ]- )- )-- const [focused] = findWorkflowTreePath(tree, [edge('outer', 'trial', 'branch', 0)])-- expect(focused.branch.sequence.nodes.find((node) => node.action.id === 'inner')?.joinActionId).toBe('followup')- expect(focused.node.joinActionId).toBe('shared')- expect([...getWorkflowTreeStepIds(focused.branch.sequence)]).toEqual([- 'trial',- 'inner',- 'guided',- 'self-serve',- 'followup',- ])- const innerPath = [edge('outer', 'trial', 'branch', 0), edge('inner', 'guided', 'branch', 0)]- expect(getWorkflowTreeContinuationPath(tree, 'followup')).toEqual(innerPath.slice(0, 1))- expect(getWorkflowTreeContinuationPath(tree, 'shared')).toEqual([])- })-- it('shows a step that several paths share once and links to it from the other paths', () => {- const tree = buildWorkflowTree(- workflow(- [- action('trigger', 'trigger'),- action('outer', 'conditional_branch'),- action('wait', 'wait_until_condition'),- action('matched'),- action('timeout'),- action('exit', 'exit'),- ],- [- edge('trigger', 'outer'),- edge('outer', 'wait', 'branch', 0),- edge('outer', 'wait', 'branch', 1),- edge('outer', 'exit'),- edge('wait', 'matched', 'branch', 0),- edge('wait', 'timeout'),- edge('matched', 'exit'),- edge('timeout', 'exit'),- ]- )- )- const firstPath = [edge('outer', 'wait', 'branch', 0), edge('wait', 'matched', 'branch', 0)]- const [, secondRoute] = tree.nodes[1].branches-- expect(findWorkflowTreePath(tree, firstPath).map(({ branch }) => branch.edge)).toEqual(firstPath)- expect(getWorkflowTreeContinuationPath(tree, 'matched')).toEqual(firstPath)- expect(secondRoute.sequence.nodes).toEqual([])- expect(secondRoute.sequence.continueTo?.id).toBe('wait')- expect(secondRoute.sequence.trailingEdge).toEqual(edge('outer', 'wait', 'branch', 1))- expect(getWorkflowTreeBranchSummary(tree.nodes[1], secondRoute)).toBe('0 steps · Continue to: wait')- expect(- findWorkflowTreePath(tree, [edge('outer', 'wait', 'branch', 1), edge('wait', 'matched', 'branch', 0)])- ).toEqual([])- })-- it('shows each step once when nested branches merge only some of their paths', () => {- const levels = 12- const actions = [action('trigger', 'trigger'), action('exit', 'exit')]- const edges = [edge('trigger', 'split-0')]- for (let level = 0; level < levels; level++) {- const next = level + 1 < levels ? `split-${level + 1}` : 'exit'- actions.push(- action(`split-${level}`, 'conditional_branch'),- action(`a-${level}`),- action(`b-${level}`),- action(`merge-${level}`)- )- edges.push(- edge(`split-${level}`, `a-${level}`, 'branch', 0),- edge(`split-${level}`, `b-${level}`, 'branch', 1),- edge(`split-${level}`, 'exit'),- edge(`a-${level}`, `merge-${level}`),- edge(`b-${level}`, `merge-${level}`),- edge(`merge-${level}`, next)- )- }- const tree = buildWorkflowTree(workflow(actions, edges))-- const placements: string[] = []- const collect = (sequence: typeof tree): void => {- for (const node of sequence.nodes) {- placements.push(node.action.id)- node.branches.forEach((branch) => collect(branch.sequence))- }- }- collect(tree)-- expect(placements).toHaveLength(actions.length)- expect(new Set(placements).size).toBe(actions.length)- const lastSplit = findWorkflowTreePath(- tree,- Array.from({ length: levels }, (_, level) => edge(`split-${level}`, `a-${level}`, 'branch', 0))- ).at(-1)- expect(lastSplit?.node.branches[1].sequence.continueTo?.id).toBe(`merge-${levels - 1}`)- expect(isWorkflowTreeComplete(workflow(actions, edges))).toBe(true)- })-- it.each([- [false, 'none', 'branch', 'Condition matched'],- [false, 'targetless', 'branch', 'Condition matched'],- [false, 'targeted', 'branch', 'Event received'],- [true, 'none', 'branch', 'Condition matched'],- [true, 'targetless', 'branch', 'Condition matched'],- [true, 'targeted', 'branch', 'Condition or event matched'],- [false, 'none', 'continue', 'No match within 2d'],- [false, 'targeted', 'continue', 'No match within 2d'],- ] as const)(- 'labels wait outcomes for condition=%s events=%s and edge=%s',- (hasCondition, events, edgeType, label) => {- const eventConfigs = {- none: [],- targetless: [{ filters: { events: [], actions: [] } }],- targeted: [{ filters: { events: [{ id: 'activated' }] } }],- }- const waitAction: HogFlowAction = {- id: 'wait',- type: 'wait_until_condition',- name: 'Wait for activation',- description: '',- config: {- condition: hasCondition ? { filters: { properties: [{ key: 'plan', value: 'pro' }] } } : {},- max_wait_duration: '2d',- events: eventConfigs[events],- },- }- expect(getWorkflowBranchLabel(waitAction, edge('wait', 'next', edgeType, 0))).toBe(label)- }- )-- it.each([- ['2d', 'No match within 2d'],- ['31d', 'No match within 30d'],- ['25h', 'No match within 24h'],- ['90m', 'No match within 60m'],- ['m', 'No match'],- ['', 'No match'],- [undefined, 'No match'],- ] as const)('labels a wait timeout of %s on the continue edge', (maxWaitDuration, label) => {- const waitAction = {- id: 'wait',- type: 'wait_until_condition',- name: 'Wait for activation',- description: '',- config: { condition: {}, events: [], max_wait_duration: maxWaitDuration },- } as HogFlowAction- expect(getWorkflowBranchLabel(waitAction, edge('wait', 'next', 'continue'))).toBe(label)- })-- it.each([- ['branch', 'Loyal users'],- ['continue', 'Fallback if no cohort has traffic'],- ] as const)('labels random cohort outcomes for edge=%s', (edgeType, label) => {- const cohortAction: HogFlowAction = {- id: 'split',- type: 'random_cohort_branch',- name: 'Split traffic',- description: '',- config: { cohorts: [{ name: 'Loyal users', percentage: 30 }] },- }- expect(getWorkflowBranchLabel(cohortAction, edge('split', 'next', edgeType, 0))).toBe(label)- })-- it('moves a branching action with all of its paths', () => {- const workflowWithJoin = workflow(- [- action('trigger', 'trigger'),- action('condition', 'conditional_branch'),- action('yes'),- action('no'),- action('shared'),- action('after'),- action('exit', 'exit'),- ],- [- edge('trigger', 'condition'),- edge('condition', 'yes', 'branch', 0),- edge('condition', 'no'),- edge('yes', 'shared'),- edge('no', 'shared'),- edge('shared', 'after'),- edge('after', 'exit'),- ]- )-- expect(computeMoveTreeBranchEdges(workflowWithJoin, 'condition', edge('shared', 'after'), false)).toEqual([- edge('trigger', 'shared'),- edge('condition', 'yes', 'branch', 0),- edge('condition', 'no'),- edge('yes', 'after'),- edge('no', 'after'),- edge('after', 'exit'),- edge('shared', 'condition'),- ])- })-- it('refuses to move a branching action whose path links to a step that another route enters', () => {- const workflowWithSharedStep = workflow(- [- action('trigger', 'trigger'),- action('outer', 'conditional_branch'),- action('inner', 'conditional_branch'),- action('shared'),- action('other'),- action('join'),- action('after'),- action('exit', 'exit'),- ],- [- edge('trigger', 'outer'),- edge('outer', 'shared', 'branch', 0),- edge('outer', 'inner'),- edge('inner', 'shared', 'branch', 0),- edge('inner', 'other'),- edge('shared', 'join'),- edge('other', 'join'),- edge('join', 'after'),- edge('after', 'exit'),- ]- )-- expect(computeMoveTreeBranchEdges(workflowWithSharedStep, 'inner', edge('join', 'after'), false)).toBeNull()- })-})diff --git a/products/workflows/frontend/Workflows/hogflows/tree/workflowTree.ts b/products/workflows/frontend/Workflows/hogflows/tree/workflowTree.tsdeleted file mode 100644index 1c160355e2d1..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/workflowTree.ts+++ /dev/null@@ -1,487 +0,0 @@-import type { HogFlow, HogFlowAction, HogFlowEdge } from '../types'--export const BRANCHING_ACTION_TYPES = ['conditional_branch', 'random_cohort_branch', 'wait_until_condition'] as const--export interface WorkflowTreeSequence {- nodes: WorkflowTreeNode[]- trailingEdge: HogFlowEdge | null- continueTo: HogFlowAction | null-}--export interface WorkflowTreeNode {- action: HogFlowAction- incomingEdge: HogFlowEdge | null- branches: WorkflowTreeBranch[]- joinActionId: string | null- joinAction: HogFlowAction | null- joinEdges: HogFlowEdge[]-}--export interface WorkflowTreeBranch {- edge: HogFlowEdge- label: string- sequence: WorkflowTreeSequence-}--// A wait can run without a timeout, and the duration field keeps a unit-only value such as "m"-// while its number input is empty. Neither names a window, so accept only the complete duration-// that the step schema accepts. The alternation is the grammar the API and the worker already-// share: it keeps each digit run owned by one quantifier, where `\d*\.?\d+` lets both claim the-// same digits and backtracks quadratically on a long stored value that never matches.-const COMPLETE_DURATION_PATTERN = /^([0-9]+(?:\.[0-9]+)?|\.[0-9]+)([dhms])$/--// The executor holds a wait to the ceiling of its unit, and the API stores a larger amount-// unchanged. Use the same ceilings here so the label names the window the wait really honors.-const MAX_WAIT_AMOUNT_FOR_UNIT: Record<string, number> = {- d: 30,- h: 24,- m: 60,- s: 60,-}--export function isBranchingAction(action: Pick<HogFlowAction, 'type'>): boolean {- return BRANCHING_ACTION_TYPES.includes(action.type as (typeof BRANCHING_ACTION_TYPES)[number])-}--export function getWaitTimeoutLabel(maxWaitDuration: string | undefined): string | null {- const parts = COMPLETE_DURATION_PATTERN.exec(maxWaitDuration ?? '')- if (!parts) {- return null- }- const [, amount, unit] = parts- return `${Math.min(parseFloat(amount), MAX_WAIT_AMOUNT_FOR_UNIT[unit])}${unit}`-}--export function getWorkflowBranchLabel(action: HogFlowAction | undefined, edge: HogFlowEdge): string {- if (action?.type === 'wait_until_condition') {- if (edge.type === 'continue') {- const timeout = getWaitTimeoutLabel(action.config.max_wait_duration)- return timeout ? `No match within ${timeout}` : 'No match'- }- const { condition, events } = action.config- if (condition?.name) {- return condition.name- }- // The editor leaves an entry behind when the last event is removed, and the runtime skips- // an entry that targets no event and no action. Such an entry cannot resolve the wait, so- // it must not name an event here.- const waitsForEvent = events?.some(- (eventConfig) =>- (eventConfig.filters?.events?.length ?? 0) > 0 || (eventConfig.filters?.actions?.length ?? 0) > 0- )- if (!waitsForEvent) {- return 'Condition matched'- }- // The property condition and the events resolve the wait through this same edge, so a wait- // that sets both must not name only one of them.- const filters = condition?.filters- const hasConditionFilters =- (filters?.properties?.length ?? 0) > 0 ||- (filters?.events?.length ?? 0) > 0 ||- (filters?.actions?.length ?? 0) > 0- return hasConditionFilters ? 'Condition or event matched' : 'Event received'- }- if (edge.type === 'continue') {- // A random cohort split scales its weights to their total and always picks a cohort, so this- // edge carries the leftover of an unusable split rather than a share of the traffic.- return action?.type === 'random_cohort_branch' ? 'Fallback if no cohort has traffic' : 'No match'- }-- if (!action) {- return `If condition #${(edge.index ?? 0) + 1} matches`- }-- switch (action.type) {- case 'random_cohort_branch':- return action.config.cohorts?.[edge.index ?? 0]?.name || `If cohort #${(edge.index ?? 0) + 1} matches`- case 'conditional_branch':- return action.config.conditions?.[edge.index ?? 0]?.name || `If condition #${(edge.index ?? 0) + 1} matches`- default:- return `If condition #${(edge.index ?? 0) + 1} matches`- }-}--function intersectSets(sets: Set<string>[]): Set<string> {- if (sets.length === 0) {- return new Set()- }-- return new Set([...sets[0]].filter((value) => sets.slice(1).every((set) => set.has(value))))-}--function setsEqual(left: Set<string>, right: Set<string>): boolean {- return left.size === right.size && [...left].every((value) => right.has(value))-}--function postOrder(actionIds: string[], outgoingEdgesByActionId: Map<string, HogFlowEdge[]>): string[] {- const order: string[] = []- const visited = new Set<string>()-- for (const rootId of actionIds) {- if (visited.has(rootId)) {- continue- }- visited.add(rootId)- const stack: { actionId: string; nextEdge: number }[] = [{ actionId: rootId, nextEdge: 0 }]-- while (stack.length) {- const frame = stack[stack.length - 1]- const edge = (outgoingEdgesByActionId.get(frame.actionId) ?? [])[frame.nextEdge++]- if (!edge) {- order.push(frame.actionId)- stack.pop()- } else if (!visited.has(edge.to)) {- visited.add(edge.to)- stack.push({ actionId: edge.to, nextEdge: 0 })- }- }- }-- return order-}--function buildPostDominators(- actionIds: string[],- outgoingEdgesByActionId: Map<string, HogFlowEdge[]>-): Map<string, Set<string>> {- const allActionIds = new Set(actionIds)- const postDominators = new Map(- actionIds.map((actionId) => [- actionId,- outgoingEdgesByActionId.get(actionId)?.length ? new Set(allActionIds) : new Set([actionId]),- ])- )-- // Visiting successors first lets each pass see final successor sets, so the loop ends after one or two- // passes. In array order, a long chain needs one pass per step, and each pass costs O(n²).- const visitOrder = postOrder(actionIds, outgoingEdgesByActionId)-- for (let pass = 0; pass < actionIds.length * actionIds.length; pass++) {- let changed = false-- for (const actionId of visitOrder) {- const successors = (outgoingEdgesByActionId.get(actionId) ?? [])- .map((edge) => postDominators.get(edge.to))- .filter((set): set is Set<string> => !!set)- const next = new Set([actionId, ...intersectSets(successors)])-- if (!setsEqual(next, postDominators.get(actionId) ?? new Set())) {- postDominators.set(actionId, next)- changed = true- }- }-- if (!changed) {- break- }- }-- return postDominators-}--function distancesFrom(- startActionId: string,- outgoingEdgesByActionId: Map<string, HogFlowEdge[]>-): Map<string, number> {- const distances = new Map([[startActionId, 0]])- const queue = [startActionId]-- for (let index = 0; index < queue.length; index++) {- const actionId = queue[index]- const distance = distances.get(actionId) ?? 0-- for (const edge of outgoingEdgesByActionId.get(actionId) ?? []) {- if (!distances.has(edge.to)) {- distances.set(edge.to, distance + 1)- queue.push(edge.to)- }- }- }-- return distances-}--function findBranchJoinActionId(- actionId: string,- edges: HogFlowEdge[],- outgoingEdgesByActionId: Map<string, HogFlowEdge[]>,- postDominatorsByActionId: Map<string, Set<string>>,- actionOrder: Map<string, number>-): string | null {- const targetIds = [...new Set(edges.map((edge) => edge.to))]- const candidates = intersectSets(- targetIds.map((targetId) => postDominatorsByActionId.get(targetId) ?? new Set<string>())- )- candidates.delete(actionId)-- const distances = targetIds.map((targetId) => distancesFrom(targetId, outgoingEdgesByActionId))-- return (- [...candidates].sort((left, right) => {- const leftDistances = distances.map((map) => map.get(left) ?? Number.POSITIVE_INFINITY)- const rightDistances = distances.map((map) => map.get(right) ?? Number.POSITIVE_INFINITY)- const maxDifference = Math.max(...leftDistances) - Math.max(...rightDistances)- const totalDifference =- leftDistances.reduce((total, distance) => total + distance, 0) -- rightDistances.reduce((total, distance) => total + distance, 0)-- return maxDifference || totalDifference || (actionOrder.get(left) ?? 0) - (actionOrder.get(right) ?? 0)- })[0] ?? null- )-}--// Walk the edges and not the tree, because a path can end with a link to a step that renders under another-// path but still reaches the join.-function collectBranchJoinEdges(- branchingActionId: string,- joinActionId: string,- outgoingEdgesByActionId: Map<string, HogFlowEdge[]>-): HogFlowEdge[] {- const joinEdges: HogFlowEdge[] = []- const visited = new Set([branchingActionId])- const stack: { actionId: string; nextEdge: number }[] = [{ actionId: branchingActionId, nextEdge: 0 }]-- while (stack.length) {- const frame = stack[stack.length - 1]- const edge = (outgoingEdgesByActionId.get(frame.actionId) ?? [])[frame.nextEdge++]- if (!edge) {- stack.pop()- } else if (edge.to === joinActionId) {- joinEdges.push(edge)- } else if (!visited.has(edge.to)) {- visited.add(edge.to)- stack.push({ actionId: edge.to, nextEdge: 0 })- }- }-- return joinEdges-}--export function buildWorkflowTree(workflow: Pick<HogFlow, 'actions' | 'edges'>): WorkflowTreeSequence {- const actionsById = new Map(workflow.actions.map((action) => [action.id, action]))- const actionOrder = new Map(workflow.actions.map((action, index) => [action.id, index]))- const outgoingEdgesByActionId = new Map<string, HogFlowEdge[]>()-- for (const edge of workflow.edges) {- if (!actionsById.has(edge.from) || !actionsById.has(edge.to)) {- continue- }- outgoingEdgesByActionId.set(edge.from, [...(outgoingEdgesByActionId.get(edge.from) ?? []), edge])- }-- for (const edges of outgoingEdgesByActionId.values()) {- edges.sort((left, right) => {- if (left.type !== right.type) {- return left.type === 'branch' ? -1 : 1- }- return (left.index ?? Number.POSITIVE_INFINITY) - (right.index ?? Number.POSITIVE_INFINITY)- })- }-- const postDominatorsByActionId = buildPostDominators([...actionsById.keys()], outgoingEdgesByActionId)-- // Each action renders once. A path that reaches an action that is already placed ends with a link to- // it. Copying the shared steps under every path instead grows with the number of routes through the- // graph, which is exponential when branches nest and only some of their paths merge.- const placedActionIds = new Set<string>()-- const buildSequence = (- startActionId: string | undefined,- stopActionId: string | null,- incomingEdge: HogFlowEdge | null- ): WorkflowTreeSequence => {- const nodes: WorkflowTreeNode[] = []- let actionId = startActionId- let edgeIntoAction = incomingEdge-- while (actionId && actionId !== stopActionId && !placedActionIds.has(actionId)) {- const action = actionsById.get(actionId)- if (!action) {- break- }-- placedActionIds.add(actionId)- const outgoingEdges = outgoingEdgesByActionId.get(actionId) ?? []- const node: WorkflowTreeNode = {- action,- incomingEdge: edgeIntoAction,- branches: [],- joinActionId: null,- joinAction: null,- joinEdges: [],- }-- if (outgoingEdges.length <= 1) {- nodes.push(node)- edgeIntoAction = outgoingEdges[0] ?? null- actionId = outgoingEdges[0]?.to- continue- }-- const joinActionId = findBranchJoinActionId(- actionId,- outgoingEdges,- outgoingEdgesByActionId,- postDominatorsByActionId,- actionOrder- )- node.joinActionId = joinActionId- node.joinAction = joinActionId ? (actionsById.get(joinActionId) ?? null) : null- node.branches = outgoingEdges.map((edge) => ({- edge,- label: getWorkflowBranchLabel(action, edge),- sequence: buildSequence(edge.to, joinActionId, edge),- }))- if (joinActionId) {- node.joinEdges = collectBranchJoinEdges(actionId, joinActionId, outgoingEdgesByActionId)- }- nodes.push(node)-- if (!joinActionId) {- return { nodes, trailingEdge: null, continueTo: null }- }-- actionId = joinActionId- edgeIntoAction = null- }-- const continueTo = actionId && actionId !== stopActionId ? (actionsById.get(actionId) ?? null) : null- return {- nodes,- trailingEdge: actionId === stopActionId || continueTo ? edgeIntoAction : null,- continueTo: edgeIntoAction ? continueTo : null,- }- }-- const trigger = workflow.actions.find((action) => action.type === 'trigger') ?? workflow.actions[0]- return buildSequence(trigger?.id, null, null)-}--export function isWorkflowTreeComplete(workflow: Pick<HogFlow, 'actions' | 'edges'>): boolean {- const actionIds = new Set<string>()- collectWorkflowTreeActionIds(buildWorkflowTree(workflow), actionIds)- return workflow.actions.every((action) => actionIds.has(action.id))-}--function findWorkflowTreeNode(sequence: WorkflowTreeSequence, actionId: string): WorkflowTreeNode | null {- for (const node of sequence.nodes) {- if (node.action.id === actionId) {- return node- }-- for (const branch of node.branches) {- const branchNode = findWorkflowTreeNode(branch.sequence, actionId)- if (branchNode) {- return branchNode- }- }- }-- return null-}--function collectWorkflowTreeActionIds(sequence: WorkflowTreeSequence, actionIds: Set<string>): void {- for (const node of sequence.nodes) {- actionIds.add(node.action.id)- for (const branch of node.branches) {- collectWorkflowTreeActionIds(branch.sequence, actionIds)- }- }-}--function collectActionIdsBefore(startActionId: string, stopActionId: string, edges: HogFlowEdge[]): Set<string> {- const actionIds = new Set([startActionId])- const queue = [startActionId]-- for (let index = 0; index < queue.length; index++) {- for (const edge of edges) {- if (edge.from === queue[index] && edge.to !== stopActionId && !actionIds.has(edge.to)) {- actionIds.add(edge.to)- queue.push(edge.to)- }- }- }-- return actionIds-}--export function computeMoveTreeBranchEdges(- workflow: Pick<HogFlow, 'actions' | 'edges'>,- movingActionId: string,- targetEdge: HogFlowEdge,- isBranchJoinDropzone: boolean,- joinEdges?: HogFlowEdge[]-): HogFlow['edges'] | null {- const branchNode = findWorkflowTreeNode(buildWorkflowTree(workflow), movingActionId)- const joinActionId = branchNode?.joinActionId-- if (!branchNode || !joinActionId) {- return null- }-- // Collect the block from the edges and not from the tree, because a path can end with a link to a step- // that renders under another path but still runs before the join.- const movedActionIds = collectActionIdsBefore(movingActionId, joinActionId, workflow.edges)-- // A route from outside the block that enters one of its steps would follow that step to the new place and- // skip the join, so refuse the move.- const enteredFromOutside = workflow.edges.some(- (edge) => edge.to !== movingActionId && movedActionIds.has(edge.to) && !movedActionIds.has(edge.from)- )- if (enteredFromOutside) {- return null- }-- if (movedActionIds.has(targetEdge.from) || movedActionIds.has(targetEdge.to)) {- return null- }-- const terminalEdges = workflow.edges.filter((edge) => movedActionIds.has(edge.from) && edge.to === joinActionId)- if (terminalEdges.length === 0 || !workflow.edges.some((edge) => edge.to === movingActionId)) {- return null- }-- let newEdges = workflow.edges.map((edge) => (edge.to === movingActionId ? { ...edge, to: joinActionId } : edge))-- const targetEdgeIndexes = isBranchJoinDropzone- ? newEdges- .map((edge, index) => ({ edge, index }))- .filter(({ edge }) => {- if (movedActionIds.has(edge.from)) {- return false- }-- if (joinEdges) {- return joinEdges.some(- (joinEdge) =>- edge.from === joinEdge.from &&- edge.to === joinEdge.to &&- edge.type === joinEdge.type &&- edge.index === joinEdge.index- )- }-- return edge.to === targetEdge.to- })- .map(({ index }) => index)- : [- newEdges.findIndex(- (edge) =>- edge.from === targetEdge.from && edge.type === targetEdge.type && edge.index === targetEdge.index- ),- ]-- if (targetEdgeIndexes.length === 0 || targetEdgeIndexes.includes(-1)) {- return null- }-- const edgesToSplit = targetEdgeIndexes.map((index) => newEdges[index])- const insertionTarget = edgesToSplit[0].to- targetEdgeIndexes.sort((left, right) => right - left).forEach((index) => newEdges.splice(index, 1))-- const terminalEdgeSet = new Set(terminalEdges)- newEdges = newEdges.map((edge) => (terminalEdgeSet.has(edge) ? { ...edge, to: insertionTarget } : edge))- newEdges.push(...edgesToSplit.map((edge) => ({ ...edge, to: movingActionId })))-- return newEdges-}diff --git a/products/workflows/frontend/Workflows/hogflows/tree/workflowTreePresentation.ts b/products/workflows/frontend/Workflows/hogflows/tree/workflowTreePresentation.tsdeleted file mode 100644index 5b242e536b62..000000000000--- a/products/workflows/frontend/Workflows/hogflows/tree/workflowTreePresentation.ts+++ /dev/null@@ -1,144 +0,0 @@-import type { HogFlowEdge } from '../types'-import type { WorkflowTreeBranch, WorkflowTreeNode, WorkflowTreeSequence } from './workflowTree'--export const WORKFLOW_TREE_BRANCH_LIMIT = 6--export interface WorkflowTreePath {- node: WorkflowTreeNode- branch: WorkflowTreeBranch-}--export interface WorkflowTreeNodeViewState {- branchesOpen?: boolean- collapsedBranches?: Set<string>- showAllBranches?: boolean-}--export function getWorkflowTreeOccurrenceKey(actionId: string, path: HogFlowEdge[]): string {- return encodeURIComponent(JSON.stringify([path.map((edge) => [edge.from, edge.type, edge.index]), actionId]))-}--export function getWorkflowTreeStepId(actionId: string, path: HogFlowEdge[]): string {- return `workflow-tree-step-${actionId}${path.length ? `-${getWorkflowTreeOccurrenceKey(actionId, path)}` : ''}`-}--export function findWorkflowTreePath(sequence: WorkflowTreeSequence, edges: HogFlowEdge[]): WorkflowTreePath[] {- const [edge, ...remainingEdges] = edges- if (!edge) {- return []- }- for (const node of sequence.nodes) {- for (const branch of node.branches) {- const path = { node, branch }- if (branch.edge.from === edge.from && branch.edge.type === edge.type && branch.edge.index === edge.index) {- if (remainingEdges.length === 0) {- return [path]- }- const nestedPath = findWorkflowTreePath(branch.sequence, remainingEdges)- return nestedPath.length ? [path, ...nestedPath] : []- }- }- }- return []-}--export function getWorkflowTreeContinuationPath(tree: WorkflowTreeSequence, actionId: string): HogFlowEdge[] {- const search = (sequence: WorkflowTreeSequence, path: HogFlowEdge[]): HogFlowEdge[] | null => {- for (const node of sequence.nodes) {- if (node.action.id === actionId) {- return path- }- for (const branch of node.branches) {- const found = search(branch.sequence, [...path, branch.edge])- if (found) {- return found- }- }- }- return null- }- return search(tree, []) ?? []-}--function collectStepIds(sequence: WorkflowTreeSequence, stepIds: Set<string>): void {- for (const node of sequence.nodes) {- stepIds.add(node.action.id)- for (const branch of node.branches) {- collectStepIds(branch.sequence, stepIds)- }- }-}--export function getWorkflowTreeStepIds(sequence: WorkflowTreeSequence): Set<string> {- const stepIds = new Set<string>()- collectStepIds(sequence, stepIds)- return stepIds-}--function getPathDestination(sequence: WorkflowTreeSequence): string {- if (sequence.continueTo) {- return `Continue to: ${sequence.continueTo.name}`- }- const lastNode = sequence.nodes.at(-1)- if (lastNode?.action.type === 'exit') {- return 'End workflow'- }- if (lastNode?.branches.length) {- const destinations = new Set(lastNode.branches.map((branch) => getPathDestination(branch.sequence)))- return destinations.size === 1 ? [...destinations][0] : 'Paths have different destinations'- }- return 'No next step'-}--export function getWorkflowTreeBranchSummary(node: WorkflowTreeNode, branch: WorkflowTreeBranch): string {- const count = getWorkflowTreeStepIds(branch.sequence).size- const continuation = branch.sequence.continueTo ?? node.joinAction- const destination = continuation ? `Continue to: ${continuation.name}` : getPathDestination(branch.sequence)- return `${count} ${count === 1 ? 'step' : 'steps'} · ${destination}`-}--export function getWorkflowTreeBranchKey(edge: HogFlowEdge): string {- return `${edge.from}-${edge.type}-${edge.index ?? 'continue'}`-}--export interface WorkflowTreeBranchGroup {- occurrenceKey: string- branchKeys: string[]-}--function collectBranchGroups(- sequence: WorkflowTreeSequence,- path: HogFlowEdge[],- groups: WorkflowTreeBranchGroup[]-): void {- for (const node of sequence.nodes) {- if (node.branches.length) {- groups.push({- occurrenceKey: getWorkflowTreeOccurrenceKey(node.action.id, path),- branchKeys: node.branches.map((branch) => getWorkflowTreeBranchKey(branch.edge)),- })- }- for (const branch of node.branches) {- collectBranchGroups(branch.sequence, [...path, branch.edge], groups)- }- }-}--/** Every branching step in the tree, including the ones nested inside a path. */-export function getWorkflowTreeBranchGroups(sequence: WorkflowTreeSequence): WorkflowTreeBranchGroup[] {- const groups: WorkflowTreeBranchGroup[] = []- collectBranchGroups(sequence, [], groups)- return groups-}--export function areAllWorkflowTreeBranchesCollapsed(- groups: WorkflowTreeBranchGroup[],- viewStates: Record<string, WorkflowTreeNodeViewState>-): boolean {- return (- groups.length > 0 &&- groups.every((group) =>- group.branchKeys.every((branchKey) => viewStates[group.occurrenceKey]?.collapsedBranches?.has(branchKey))- )- )-}diff --git a/products/workflows/frontend/Workflows/hogflows/workflowBranches.test.ts b/products/workflows/frontend/Workflows/hogflows/workflowBranches.test.tsnew file mode 100644index 000000000000..1d037fdb534e--- /dev/null+++ b/products/workflows/frontend/Workflows/hogflows/workflowBranches.test.ts@@ -0,0 +1,76 @@+import type { HogFlowAction, HogFlowEdge } from './types'+import { getWorkflowBranchLabel } from './workflowBranches'++const edge = (from: string, to: string, type: HogFlowEdge['type'] = 'continue', index?: number): HogFlowEdge => ({+ from,+ to,+ type,+ index,+})++describe('getWorkflowBranchLabel', () => {+ it.each([+ [false, 'none', 'branch', 'Condition matched'],+ [false, 'targetless', 'branch', 'Condition matched'],+ [false, 'targeted', 'branch', 'Event received'],+ [true, 'none', 'branch', 'Condition matched'],+ [true, 'targetless', 'branch', 'Condition matched'],+ [true, 'targeted', 'branch', 'Condition or event matched'],+ [false, 'none', 'continue', 'No match within 2d'],+ [false, 'targeted', 'continue', 'No match within 2d'],+ ] as const)(+ 'labels wait outcomes for condition=%s events=%s and edge=%s',+ (hasCondition, events, edgeType, label) => {+ const eventConfigs = {+ none: [],+ targetless: [{ filters: { events: [], actions: [] } }],+ targeted: [{ filters: { events: [{ id: 'activated' }] } }],+ }+ const waitAction: HogFlowAction = {+ id: 'wait',+ type: 'wait_until_condition',+ name: 'Wait for activation',+ description: '',+ config: {+ condition: hasCondition ? { filters: { properties: [{ key: 'plan', value: 'pro' }] } } : {},+ max_wait_duration: '2d',+ events: eventConfigs[events],+ },+ }+ expect(getWorkflowBranchLabel(waitAction, edge('wait', 'next', edgeType, 0))).toBe(label)+ }+ )++ it.each([+ ['2d', 'No match within 2d'],+ ['31d', 'No match within 30d'],+ ['25h', 'No match within 24h'],+ ['90m', 'No match within 60m'],+ ['m', 'No match'],+ ['', 'No match'],+ [undefined, 'No match'],+ ] as const)('labels a wait timeout of %s on the continue edge', (maxWaitDuration, label) => {+ const waitAction = {+ id: 'wait',+ type: 'wait_until_condition',+ name: 'Wait for activation',+ description: '',+ config: { condition: {}, events: [], max_wait_duration: maxWaitDuration },+ } as HogFlowAction+ expect(getWorkflowBranchLabel(waitAction, edge('wait', 'next', 'continue'))).toBe(label)+ })++ it.each([+ ['branch', 'Loyal users'],+ ['continue', 'Fallback if no cohort has traffic'],+ ] as const)('labels random cohort outcomes for edge=%s', (edgeType, label) => {+ const cohortAction: HogFlowAction = {+ id: 'split',+ type: 'random_cohort_branch',+ name: 'Split traffic',+ description: '',+ config: { cohorts: [{ name: 'Loyal users', percentage: 30 }] },+ }+ expect(getWorkflowBranchLabel(cohortAction, edge('split', 'next', edgeType, 0))).toBe(label)+ })+})diff --git a/products/workflows/frontend/Workflows/hogflows/workflowBranches.ts b/products/workflows/frontend/Workflows/hogflows/workflowBranches.tsnew file mode 100644index 000000000000..45f75b8af63c--- /dev/null+++ b/products/workflows/frontend/Workflows/hogflows/workflowBranches.ts@@ -0,0 +1,81 @@+import type { HogFlowAction, HogFlowEdge } from './types'++const BRANCHING_ACTION_TYPES = ['conditional_branch', 'random_cohort_branch', 'wait_until_condition'] as const++// A wait can run without a timeout, and the duration field keeps a unit-only value such as "m"+// while its number input is empty. Neither names a window, so accept only the complete duration+// that the step schema accepts. The alternation is the grammar the API and the worker already+// share: it keeps each digit run owned by one quantifier, where `\d*\.?\d+` lets both claim the+// same digits and backtracks quadratically on a long stored value that never matches.+const COMPLETE_DURATION_PATTERN = /^([0-9]+(?:\.[0-9]+)?|\.[0-9]+)([dhms])$/++// The executor holds a wait to the ceiling of its unit, and the API stores a larger amount+// unchanged. Use the same ceilings here so the label names the window the wait really honors.+const MAX_WAIT_AMOUNT_FOR_UNIT: Record<string, number> = {+ d: 30,+ h: 24,+ m: 60,+ s: 60,+}++export function isBranchingAction(action: Pick<HogFlowAction, 'type'>): boolean {+ return BRANCHING_ACTION_TYPES.includes(action.type as (typeof BRANCHING_ACTION_TYPES)[number])+}++function getWaitTimeoutLabel(maxWaitDuration: string | undefined): string | null {+ const parts = COMPLETE_DURATION_PATTERN.exec(maxWaitDuration ?? '')+ if (!parts) {+ return null+ }+ const [, amount, unit] = parts+ return `${Math.min(parseFloat(amount), MAX_WAIT_AMOUNT_FOR_UNIT[unit])}${unit}`+}++export function getWorkflowBranchLabel(action: HogFlowAction | undefined, edge: HogFlowEdge): string {+ if (action?.type === 'wait_until_condition') {+ if (edge.type === 'continue') {+ const timeout = getWaitTimeoutLabel(action.config.max_wait_duration)+ return timeout ? `No match within ${timeout}` : 'No match'+ }+ const { condition, events } = action.config+ if (condition?.name) {+ return condition.name+ }+ // The editor leaves an entry behind when the last event is removed, and the runtime skips+ // an entry that targets no event and no action. Such an entry cannot resolve the wait, so+ // it must not name an event here.+ const waitsForEvent = events?.some(+ (eventConfig) =>+ (eventConfig.filters?.events?.length ?? 0) > 0 || (eventConfig.filters?.actions?.length ?? 0) > 0+ )+ if (!waitsForEvent) {+ return 'Condition matched'+ }+ // The property condition and the events resolve the wait through this same edge, so a wait+ // that sets both must not name only one of them.+ const filters = condition?.filters+ const hasConditionFilters =+ (filters?.properties?.length ?? 0) > 0 ||+ (filters?.events?.length ?? 0) > 0 ||+ (filters?.actions?.length ?? 0) > 0+ return hasConditionFilters ? 'Condition or event matched' : 'Event received'+ }+ if (edge.type === 'continue') {+ // A random cohort split scales its weights to their total and always picks a cohort, so this+ // edge carries the leftover of an unusable split rather than a share of the traffic.+ return action?.type === 'random_cohort_branch' ? 'Fallback if no cohort has traffic' : 'No match'+ }++ if (!action) {+ return `If condition #${(edge.index ?? 0) + 1} matches`+ }++ switch (action.type) {+ case 'random_cohort_branch':+ return action.config.cohorts?.[edge.index ?? 0]?.name || `If cohort #${(edge.index ?? 0) + 1} matches`+ case 'conditional_branch':+ return action.config.conditions?.[edge.index ?? 0]?.name || `If condition #${(edge.index ?? 0) + 1} matches`+ default:+ return `If condition #${(edge.index ?? 0) + 1} matches`+ }+}