Skip to content

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

feat(workflows): make the tile canvas the only workflow editor (#129380)

Daniel Marchuk749138a54ec1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index be73422de5a7..e7ae753ce15f 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8507,81 +8507,49 @@ snapshots:
products-workflows-destinationworkflowsuggestionmodal--only-default-events--light:
hash: v1.k794b7964.21895ceb9ab912423f10d159496b58f0b96cbc893cf1144aa19ad43f52bc3607.fo4F07GH5X5Qkg3Ql-A1ZPXkkPp2WWyMSDVgLF9Eaow
products-workflows-editor-configuration-panel--build--dark:
- hash: v1.k794b7964.ba77097ed29985565b93fbc6783a05e1d057fe5a12779705eaa6d744aa77cfb7.dXBhkcHPwydmzF6HM-fUZqF060li4rZDdMxjFRtqwjQ
+ hash: v1.k794b7964.65c25d5ed821066b684a166db4a4aa03a6d180a45c85e87a66d9dfcb57f123c8.KsDQsNcKIElCi3MspCTWDnIfqOrBOfEY4DQIeyjRkWk
products-workflows-editor-configuration-panel--build--light:
- hash: v1.k794b7964.68f9e8d6025533cc2b82375fa065822c639c4174d0112a13de8b8fcdf0a673f0.VgfO6Zb4jIczGth1k5UuTFh_X65d8wT8wYkuM886TqE
+ hash: v1.k794b7964.cc2ae52e60a0a629d4b06d3b71caa41a9681c0a1b4d224017f9571c4d49b5050.3rt4HFA-aGee2bJ_hJJudSmhum_WganRVRy9CDrbdXQ
products-workflows-editor-configuration-panel--build-palette--dark:
- hash: v1.k794b7964.8c4db943f81e773cea8c5a200d6f3c18ccf839dd416167cb5952828943356223.pzLDyV2mYfv18mUMVxFcZtOUH9wyLc6-VbJovO4xKI8
+ hash: v1.k794b7964.f628d273476c169568489b4b996d8f8f125f641fe3e3ca820aa447a8dff525e5.7XbHxlEWUhymuE6Z25vBAntDBAmV-lc_fhSJmTmBHS8
products-workflows-editor-configuration-panel--build-palette--light:
- hash: v1.k794b7964.bb0ec76fa80bf963c7dc2fc60d34e3e5ac217983c2a5af4f290d136cea1cda34.XdqbwvU8p-Rfe2N0_NMJP6axztA6cdIzFFHWVW94ZGQ
+ hash: v1.k794b7964.33d2b18317dd552e73dcecad413258a6327e9ba9b4e9789fb63ec5cb76260e2e.KyNG852y4EnsI2C1xDC9vGO1AospW0bZbdXhSoE_6-Y
products-workflows-editor-configuration-panel--cohort-branch--dark:
- hash: v1.k794b7964.89705899ccfa2ee8b18d86d538e800a3a25e91fd25261d88738dd97809388c45.waPXpQ-N2vcu8Ta_GIKzoX0InqMySnxWOXWn6BsfA4g
+ hash: v1.k794b7964.a7ef0056f6841d6053df6be96315506c4af5db944bd2ab2e4745753539777cf3.oGJs6FNfcKS8YG-RqAqCrtWlt8LQK5yuQzpzl62Lous
products-workflows-editor-configuration-panel--cohort-branch--light:
- hash: v1.k794b7964.4fd0f6ff9c17a685913afb00d14a5804d28eac0f4dbe5b89ab2b60c9258d757f.dGeUSO7-kt1SuNSTiOTtQ0yWrCXD3wWCrJ0JkzXqPHQ
+ hash: v1.k794b7964.1c5a649f3e283ff111511a7c92733f54a549a5b94475c33fa37108df8b17c17c.vzsfLADCEfxVKsCSVE_bPc4rUFoyK2CEQvGA8FhWZbo
products-workflows-editor-configuration-panel--conditional-branch--dark:
- hash: v1.k794b7964.1eb79775e70860dc633e482b88508c068b4d58c7215e66c934843917ffb77a35.E5WSfkL1VqIXna_-48aVNC5ob6HVZdbK8cOe31xs5RA
+ hash: v1.k794b7964.08c4bf8c389d5628269b8b7bad44186ef356810ba6c93f2b6840794f9eca747f.YpLSJuUFY4lIV3z_vXe1yb6LvYybQmWHQHYeFypct6A
products-workflows-editor-configuration-panel--conditional-branch--light:
- hash: v1.k794b7964.3691f905593cd2084ec01847e80b3eeda4c834bd1c34a9d0f37e2d36db9c5f0c.2xvXivEkevaUXKSag8wYob1Hi2ZyfxUcr7VE46qW50w
+ hash: v1.k794b7964.36f3c96044e1b65be02bff6230321d856f7dc38e87ff8016e5c39bc53d1b69b9.G-pCmYKoQMcQtHc17mula64XNTxgAYgFA6pPBqGfGkY
products-workflows-editor-configuration-panel--email--dark:
- hash: v1.k794b7964.82956ad7b49338362f216d5648ee89813a3e18e903bc45b42c07c78f1b2a8867.byfxv4NIxretK2jzWWtxLDC8JOBfVF-tTXUPEO57PJ8
+ hash: v1.k794b7964.f12cd46c85e3ceafc7d4487fcf95712ceed7e93788b9c34c7321ce1e3d02bef5.H_L0r3Gtfa67-ZBhWpzNzF2sMDC77GXyuq9JpQKFT9U
products-workflows-editor-configuration-panel--email--light:
- hash: v1.k794b7964.dd2c15bc5c6a886c41f24f953cd0357978914f002f42d732b842c2349c04317b.6WUo7ta3_veXnom0KzU7BZ1lUzBWNCxugxmfTVPZwlQ
+ hash: v1.k794b7964.53300220941ee649ea973d333d1c6ef0873a3894cee3e41f0c15f645fda89cd6.qPWj7emtIqrYOObPinblkcltl6p_JHFLan4LIz3GPZM
products-workflows-editor-configuration-panel--logs--dark:
- hash: v1.k794b7964.beabe0c2c69154a7e7b8e5709226f710bbb707c7a2a96ea3b908e7b5348ad177.l8BzDM-8b8Z6jYzADnoiRggNuU02m3lgVa6vtNm2VOw
+ hash: v1.k794b7964.cd6b6ceb0814a2765ab52e649033d0dfa173baad5b57ee1b7a845a449ae32b8c.g0SpetcKafX_5tzXwwxcbL9oN9ik13xiVJg45AuM2Us
products-workflows-editor-configuration-panel--logs--light:
- hash: v1.k794b7964.e2ae4d6a508b7cfdbc09c3843e1e7c7caedcbe5902ce7f7f81631eefd48b821b.1eE_3Zo-nzcr7dE2fP4A2qr7ajX485FGAN-2208Z-Sg
+ hash: v1.k794b7964.3ae9f9ccb9f7d63b9c34cb17078b202c715b703f3464400faf56da606f2c1237.04rCy1L141VllZoNA7V1q7frb7CVZ13ePXMbvUWGZyI
products-workflows-editor-configuration-panel--metrics--dark:
- hash: v1.k794b7964.4eb61af73d79487b1b0d1c10b0f082d8093843922622ff24ae2b8f2b6eb2306d.kHaOuT84uzvGJnQ69XZxOeCDw_A0SN2elIYBF0JTPCc
+ hash: v1.k794b7964.9144c9b4421ed87f3dd61c987a30876440332e726b8415f90b775e0bb339b17e.v2UPDCcwm3_Lug0gbBirXYPxwa1l1qSi-VmnwK_0b1w
products-workflows-editor-configuration-panel--metrics--light:
- hash: v1.k794b7964.14d86b6a5e0a15aee914a5a197771183c5c5cba603a3b34e424c66baca6ebb4f.sn-OpXsJa-NQYj203M9cwkFVSK_JtTZx81Yo4LMJChs
+ hash: v1.k794b7964.22eedd3104fa3bbb30e59a1124dbb36627837a49db3190517899c50003ecc038.U8Bj7kWo2WvYGuJbxElHRru0GNqlDSvjBw339s_LcnI
products-workflows-editor-configuration-panel--test--dark:
- hash: v1.k794b7964.9dc8563bad3c610afe3a9a11e3dd565c61baf592e508c40ee7ed2cb518aa7bc5.8CXuUKcSDMO1JOR_T1aMnzbL9-iJFiT6A8JY3p06_d4
+ hash: v1.k794b7964.301d330270772f8f7537b5a8f776436fd5abdfb4187b9b8dd98bd643c5c62c5e.KhkBZA4ONKYmaXASmeoNMps18sCYUESnVH8uHc-zR8c
products-workflows-editor-configuration-panel--test--light:
- hash: v1.k794b7964.77e439c596febbef403bb59ac7479c423a034cca8657970821ac4ec0918584cb.VyTiPbd6I_VSVPXWvG_w1csrciseUEIxMYL7WX2EdP8
+ hash: v1.k794b7964.63ed575bfdab478aec71e70e8364965e32037f4c94e9e7ca53e87305020a82fd.1Tf8HlFXp8GWQWagDfj-QumsIPPfZxJBLNLcqayfSN0
products-workflows-editor-configuration-panel--trigger--dark:
- hash: v1.k794b7964.24086e087c3259ab0632a32e834c80d15ddc7d5349ce2a8a58ad30c6a6ac3a3a.uGTkRrvb873NTEKX0jum4ltekgUmsIbbDvZclDSdlOM
+ hash: v1.k794b7964.fb651c84fb5c1be49bb7cf50b8a6934f61904c9db0b39eef9650da27deb609a8.xK1N2tms2TWdVxl3gAj-BTc_KE6dVRziEkgDVW01GLk
products-workflows-editor-configuration-panel--trigger--light:
- hash: v1.k794b7964.2e2669fec49872d5656b14d5ddcea2b4c95d17161b5f30b052e57281cc0c8956.Y6RgOCfSDzZ_j_3N-HLCpG70wNfx3WqlmBBGspAbqrQ
+ hash: v1.k794b7964.c85331f9d391049835e83a083c62e2874baefbfe9702dc3c39ab91cd2eacbba4.qhdW9pScqryKbYe_p5Tb5RTsassuGXKlD9mUGQgf8gI
products-workflows-editor-configuration-panel--variables--dark:
- hash: v1.k794b7964.c936a553b0ecd3a1a7cd478e4848cb6ad5d3c7c566e7c47aca7c164b663ce106.PFeB3oTy3Wr4fmTcYgVv56Ur35h7UpA9BOFeO-8Y63s
+ hash: v1.k794b7964.370f650c10e2fa532e15001de8d8d7c4d357ee854c9e526880eca358ddd24b90.8zNZkFAt0OSLjgnJ5cgO-G-kOnIWrhtrsECcrPeursw
products-workflows-editor-configuration-panel--variables--light:
- hash: v1.k794b7964.e755c7e47cc53fab702c298414df2ab452bbe7f0182475888e8d6a6614174142.NrDxyc4ZMWe9aaXccP1uyLnJoFvt5gp5UDi4IObWHJ4
+ hash: v1.k794b7964.213342dc86b3f7bfe22e99477cda7be5a9257d736c30fbb5eeca0f9fe2243e7a.JJCaR5ZB4A49d-BaatrNqY9RtQB5ewgqMB3DVY-YKqI
products-workflows-editor-configuration-panel--webhook--dark:
- hash: v1.k794b7964.ae40e661ff40af560a8514c23ee903b5ed2612a89d003e30ff8c8538be817241.LZP1-ccPa8UF-2g3VkEU7FCQc74H5K4qd8y7Jvfw3fc
+ hash: v1.k794b7964.5ab0d015fa9f4b1e588b4c5576c19cba1d7147337ea9440072b79b2e4c1a749e.buuQ6s2J9oN1-6u7OoQlxViMus3WlUZoeh8WeAAA_dc
products-workflows-editor-configuration-panel--webhook--light:
- hash: v1.k794b7964.50f31a08c94115097306a76810343499b35294055b5f6a96d8466a77ff6dd72c.KgUwEqV9D2ROlg3pazBZGDM3-z7W6595ojBL0uvLGRc
- products-workflows-editor-graph--add-on-promotion-emails--dark:
- hash: v1.k794b7964.7db3a946182f054df76c6ee7f9583ecd903f0b840002bd395ef8ba5fc6843b68.5T_XKw_YTklY2LHnIY-qcqlrP4DUOMsRDtvNOQHWdjE
- products-workflows-editor-graph--add-on-promotion-emails--light:
- hash: v1.k794b7964.a1e759ee9fffca4fa21457f342108bfab3246a506843853e16c35d40b66fa1e4.Gcgbh5o59BXZMvrJaQw3sNwR6-w3657v_WlbSgkJ2Qc
- products-workflows-editor-graph--customer-onboarding-and-retention--dark:
- hash: v1.k794b7964.7f1240ea2e401403097ede1060b7e25f0b2df5f1d9743ef08bb6941dd692e23b.RCZdGruSNFGnbW3rT57dl1RzvF_Bgziy3BnA6fYcpFs
- products-workflows-editor-graph--customer-onboarding-and-retention--light:
- hash: v1.k794b7964.1d255032a76f53b3772d691492c9df5b6d2cc8f433102cf77056d2ded7f0ec52.JBR3WodHJMTjtET7451p-ii3WxT3Pa9m0GCPW0Vg0Ho
- products-workflows-editor-graph--narrow-workflow--dark:
- hash: v1.k794b7964.5ff30ad312f22fa5efb2d69d33c8b646b37f1eaa1c20273624abea8da2695385.SzcyAFbI-V2e7lVn43pBB09H3ljKxR7h42KHbnsU_J8
- products-workflows-editor-graph--narrow-workflow--light:
- hash: v1.k794b7964.4bc3ee5b43a357b995a1d0c811cfec4d25beac7cdab5f5fbde0e7440cb0d290c.pJsODEUTl7LDCmAz9PoMXm3e9uFlxyagkTxXiwX0Qio
- products-workflows-editor-graph--new-workflow--dark:
- hash: v1.k794b7964.f679d013a77cb96c53d5663ae2f66b0ad0230eb68ea5c98a4b579ab144ae1a70.EBukMpAzfN9dx4fJ_Vonsm3YoNL1G8ulVu0wfGt8MVA
- products-workflows-editor-graph--new-workflow--light:
- hash: v1.k794b7964.5ab94515bc86029887eb363444ab3acc988b2693b9289e714413890b8c189c54.IAalFCsHJCkj8Q0NBbpan57faqK9q0XLQ8OPsHFdrqs
- products-workflows-editor-graph--pending-ticket-cleanup--dark:
- hash: v1.k794b7964.22405d49b71d11a6356fd0d7b866472ae6597cc33e7c01a4a762cb913407b729.6JlfZBvRiJ3zINRLxuV_oy-MOHRBFASpvIuxZ6xaFN4
- products-workflows-editor-graph--pending-ticket-cleanup--light:
- hash: v1.k794b7964.6cb87844c46f6838bb75c24a1ecdf2f35dceef208fc1ecf08d2770debed3173b.hFUueQGNfRBRjUt8LEpN3kpVd-LZpy1zirfjpR0F9hg
- products-workflows-editor-graph--renewal-window-alerts--dark:
- hash: v1.k794b7964.0268f83b607849e9f60dc4c158c7b819bf16005f5a3a77b2223331e622d6eb50.Seq0j6y5K7FTu2zsefetLtFuYgXZVm_0Pa1FWijbckk
- products-workflows-editor-graph--renewal-window-alerts--light:
- hash: v1.k794b7964.19b0719a16b301cf66f73f434ab4db447c6bc0f9baca1dc4d211612c6b02c0a4.QGlrBZazFF9lt8eYqanWw4Ku6zncuc23tMq5QxftX0w
- products-workflows-editor-graph--support-sla-routing--dark:
- hash: v1.k794b7964.ec785571118345d28b0024f9b7dbd752c0ca29b014de70f514e29d4d1e254774.CLbb0vxCoY_MAeoxx4nZ8idnAhS94Zv3u96mGm65huM
- products-workflows-editor-graph--support-sla-routing--light:
- hash: v1.k794b7964.87ebdaa62ffea5299872bf5b8595333606db612d3172c77d965c7567f9e2c5f5.H8yPhfb_9AJBqMxoFMubMcFyAmyc0rHSMfLvsz7RWQs
- products-workflows-editor-graph--with-navigation--dark:
- hash: v1.k794b7964.8af849cea368652abf270e3b4fb744efb3ac987d05aac1c5a80ac8102ac2912d.j8jEiJv_egz0M2wd2sSjSeJqHpaP4z0j2O900JKcsY8
- products-workflows-editor-graph--with-navigation--light:
- hash: v1.k794b7964.3658b450056f0dd8e9b1d8d419fdc3e7cdd799966bfa567edfb6eb2fa5fb4491.VgnxMZyatRGloOVFqpk78UezVv6Rp9wuZS3Rg591Zwc
+ hash: v1.k794b7964.580fcd7c7973765ac2621ff06f59af46aeaf3869e54fd951dbcab69ec77c7e1b.S_vxkKiZhfNIeigTUCkV3V1vz7q-b8mAg8boalMWfQQ
products-workflows-editor-tile-canvas--long-emails--dark:
hash: v1.k794b7964.1952a127037bb7742f34a262ba7383326e4f5e04c86ffd58caf988de908d8fe0.lASWXxfI4hHT-xShH9moFcK8Fsd5JbnWjflhV6hu1dI
products-workflows-editor-tile-canvas--long-emails--light:
@@ -14667,9 +14635,9 @@ snapshots:
scenes-app-notebooks-widget-views--survey-views--light:
hash: v1.k794b7964.cf80404856645fd4b39cabb876b1b80f7ab50960cda1ae4df8780de0206d2619.xkeEhbVBdpoOxW1276sZhbGY6ZFHbZyf5w7Ij4iExzo
scenes-app-notebooks-widget-views--workflow-views--dark:
- hash: v1.k794b7964.1010624ac986e0cb262358f044e35a019243041f6e3ebbc7d885ca4742ece97b.9DC01-1aciZlk6THhuBWfJdwlAXHbxvoeRLSWu3TR0I
+ hash: v1.k794b7964.287ec07885268e18ba3b0ed6b0393a0a0fc7f70fb05d58d032f2e84e6d896fb6.22VEvJ6uCkb1HoIQKp_QE5LtxOOkje8_Fp-uQt287ME
scenes-app-notebooks-widget-views--workflow-views--light:
- hash: v1.k794b7964.72cda06b7242af9b6a4d9177d40c31af68f9a3162e373b0acb6c3ad5154cabfb.IjwXYk9nakhyYyWZUt3sWnLNm_Hvwp4DFNpMjD-C-WM
+ hash: v1.k794b7964.96208f0ac0ffb8bfc6f9cbfe5a1065262d45469c3af0738cc7531ffb753694c7.cLKvdFoSF1YYvLPtW1CbGXDHrmha-aM6_bNxHA1jggw
scenes-app-oauth-authorize--access-controls-apply--dark:
hash: v1.k794b7964.4f421d7fb891d0a77a0211d80ec9efc6899b84fb14cf331833cd175bdc738b10.doktEISQ1Rqmw7byfMxsgoY3VnXeI5pvbAXUr8yfsT0
scenes-app-oauth-authorize--access-controls-apply--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 62b3e932ec19..912247928585 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -628,7 +628,6 @@ export const FEATURE_FLAGS = {
WORKFLOWS_SENDING_TIER_REQUESTS: 'workflows-sending-tier-requests', // owner: @luke-belton #team-workflows, lets customers request a higher email sending tier
WORKFLOWS_SUPABASE_AUTH_EMAILS: 'workflows-supabase-auth-emails', // owner: @luke-belton #team-workflows, send Supabase auth emails through transactional templates
WORKFLOWS_SURVEY_STEP: 'workflows-survey-step', // owner: @dmarchuk #team-workflows
- WORKFLOWS_TILE_CANVAS: 'workflows-tile-canvas', // owner: #team-workflows
WORKFLOWS_TRANSACTIONAL_EMAIL_API: 'workflows-transactional-email-api', // owner: @mayteio #team-workflows
XAA_AUTHENTICATION: 'xaa-authentication', // owner: @reecejones #team-platform-features
} as const
diff --git a/products/workflows/frontend/Workflows/Workflow.tsx b/products/workflows/frontend/Workflows/Workflow.tsx
index 3efe9d477eb0..1d09919841fb 100644
--- a/products/workflows/frontend/Workflows/Workflow.tsx
+++ b/products/workflows/frontend/Workflows/Workflow.tsx
@@ -4,7 +4,6 @@ import { LemonBanner, LemonButton, SpinnerOverlay } from '@posthog/lemon-ui'
import { CanvasCommandGroup } from './hogflows/editor/tile-canvas/CanvasCommandGroup'
import { HogFlowEditor } from './hogflows/HogFlowEditor'
-import { hogFlowEditorLogic } from './hogflows/hogFlowEditorLogic'
import { WorkflowLogicProps, workflowLogic } from './workflowLogic'
import { WorkflowStatusBar } from './WorkflowStatusBar'
@@ -13,14 +12,10 @@ export function Workflow(props: WorkflowLogicProps): JSX.Element {
workflowLogic(props)
)
const { loadWorkflow, keepMyWorkflowVersion } = useActions(workflowLogic(props))
- const { isTileCanvas } = useValues(hogFlowEditorLogic(logicProps))
return (
<div className="relative flex min-h-[25rem] flex-1 flex-col overflow-hidden rounded-md border">
- <WorkflowStatusBar
- {...props}
- commands={isTileCanvas ? <CanvasCommandGroup {...logicProps} /> : undefined}
- />
+ <WorkflowStatusBar {...props} commands={<CanvasCommandGroup {...logicProps} />} />
{/* Brief working/disabled overlay while we reconcile to an edit made elsewhere (clean state). */}
{isSyncingExternalEdit && <SpinnerOverlay />}
{externallyEdited && (
@@ -42,7 +37,7 @@ export function Workflow(props: WorkflowLogicProps): JSX.Element {
</div>
</LemonBanner>
)}
- {!originalWorkflow && workflowLoading ? <SpinnerOverlay /> : <HogFlowEditor isTileCanvas={isTileCanvas} />}
+ {!originalWorkflow && workflowLoading ? <SpinnerOverlay /> : <HogFlowEditor />}
</div>
)
}
diff --git a/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx b/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx
index b74c11717a4b..3b8b22a90467 100644
--- a/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx
@@ -1,17 +1,15 @@
import { useValues, useActions } from 'kea'
-import { IconClock, IconInfo } from '@posthog/icons'
-import { LemonButton, LemonSwitch, LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'
+import { IconInfo } from '@posthog/icons'
+import { 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 { WorkflowLogicProps, workflowLogic } from './workflowLogic'
type WorkflowStatusBarProps = WorkflowLogicProps & {
- /** Editor commands that sit in the bar, such as the tile canvas panels. They bring their own History. */
- commands?: JSX.Element
+ commands: JSX.Element
}
export function WorkflowStatusBar({ commands, ...props }: WorkflowStatusBarProps): JSX.Element | null {
@@ -58,7 +56,7 @@ export function WorkflowStatusBar({ commands, ...props }: WorkflowStatusBarProps
{commands}
</div>
{/* Interactive controls sit right-anchored with variable-width text leftmost, so the
- toggle and History never shift as the narration or the timestamp changes. */}
+ toggle never shifts as the narration or the timestamp changes. */}
{showWorkflowStatus && historyWorkflowId && (
<div className="flex items-center gap-3 shrink-0">
{autoSaveEnabled && showSaving ? (
@@ -86,17 +84,6 @@ export function WorkflowStatusBar({ commands, ...props }: WorkflowStatusBarProps
<IconInfo className="text-tertiary size-4" />
</Tooltip>
</span>
- {!commands && (
- <LemonButton
- type="tertiary"
- size="small"
- icon={<IconClock />}
- to={urls.workflow(historyWorkflowId, 'history')}
- tooltip="See and restore previous versions"
- >
- History
- </LemonButton>
- )}
</div>
)}
</div>
diff --git a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
index 31f9296be14d..26f877932ccd 100644
--- a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
@@ -1,154 +1,22 @@
import '@xyflow/react/dist/style.css'
-import {
- Background,
- BackgroundVariant,
- Controls,
- EdgeTypes,
- NodeTypes,
- Panel,
- ReactFlow,
- ReactFlowProvider,
- useNodesInitialized,
- useReactFlow,
-} from '@xyflow/react'
-import { BindLogic, useActions, useValues } from 'kea'
-import { useEffect, useMemo, useRef } from 'react'
-
-import { IconInfo } from '@posthog/icons'
-
-import { themeLogic } from '~/layout/navigation-3000/themeLogic'
+import { ReactFlowProvider } from '@xyflow/react'
+import { BindLogic, useValues } from 'kea'
import { workflowLogic } from '../workflowLogic'
import { TileCanvas } from './editor/tile-canvas/TileCanvas'
import { HogFlowBranchSelectionProvider } from './HogFlowBranchSelection'
import { hogFlowEditorLogic } from './hogFlowEditorLogic'
-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 { HogFlowActionEdge, HogFlowActionNode } from './types'
-
-function HogFlowGraphEditor(): JSX.Element {
- const { isDarkModeOn } = useValues(themeLogic)
-
- const { nodes, edges, dropzoneNodes, isMovingNode, isCopyingNode, isZoomedOutFar } = useValues(hogFlowEditorLogic)
- const {
- onEdgesChange,
- onNodesChange,
- setSelectedNodeId,
- setReactFlowInstance,
- onNodesDelete,
- onDragOver,
- onDrop,
- setReactFlowWrapper,
- handlePaneClick,
- setIsZoomedOutFar,
- fitView,
- } = useActions(hogFlowEditorLogic)
-
- const reactFlowWrapper = useRef<HTMLDivElement>(null)
- const reactFlowInstance = useReactFlow()
- const nodesInitialized = useNodesInitialized()
-
- useEffect(() => {
- setReactFlowInstance(reactFlowInstance)
- }, [reactFlowInstance, setReactFlowInstance])
-
- useEffect(() => {
- setReactFlowWrapper(reactFlowWrapper)
- }, [setReactFlowWrapper])
-
- useEffect(() => {
- if (!nodesInitialized || !reactFlowWrapper.current) {
- return
- }
-
- const observer = new ResizeObserver(() => fitView({ duration: 0 }))
- observer.observe(reactFlowWrapper.current)
- return () => observer.disconnect()
- }, [fitView, nodesInitialized])
-
- // ReactFlow diffs its nodes prop by reference: an inline spread would hand it a fresh array
- // every render, making every render look like a graph change.
- const nodesWithDropzones = useMemo(
- () => [...nodes, ...(dropzoneNodes as unknown as HogFlowActionNode[])],
- [nodes, dropzoneNodes]
- )
-
- 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"
- >
- <div
- ref={reactFlowWrapper}
- className="flex min-h-0 min-w-0 grow @max-[48rem]/workflow-editor:min-h-80 @max-[48rem]/workflow-editor:shrink-0"
- >
- <ReactFlow<HogFlowActionNode, HogFlowActionEdge>
- className="grow"
- fitView
- minZoom={MIN_ZOOM}
- maxZoom={MAX_ZOOM}
- // Only dispatched when the detail tier flips, so panning and zooming don't put a
- // Redux action on every animation frame.
- onMove={(_, viewport) => {
- const zoomedOutFar = viewport.zoom < LOW_DETAIL_ZOOM
- if (zoomedOutFar !== isZoomedOutFar) {
- setIsZoomedOutFar(zoomedOutFar)
- }
- }}
- nodes={nodesWithDropzones}
- edges={edges}
- onNodesChange={onNodesChange}
- onEdgesChange={onEdgesChange}
- onNodesDelete={onNodesDelete}
- onDragOver={onDragOver}
- onDrop={onDrop}
- onNodeClick={(_, node) => node.selectable && setSelectedNodeId(node.id)}
- nodeTypes={REACT_FLOW_NODE_TYPES as NodeTypes}
- edgeTypes={REACT_FLOW_EDGE_TYPES as EdgeTypes}
- nodesDraggable={false}
- colorMode={isDarkModeOn ? 'dark' : 'light'}
- onPaneClick={handlePaneClick}
- >
- <Background gap={36} variant={BackgroundVariant.Dots} />
-
- {(isMovingNode || isCopyingNode) && (
- <Panel position="bottom-left">
- {/* Offset right of the zoom controls so the hint sits beside them */}
- <div className="flex flex-wrap items-center gap-1.5 ml-12 px-3 py-1.5 rounded border shadow-sm bg-surface-primary text-sm">
- <IconInfo className="text-base text-muted shrink-0" />
- <span>Click a highlighted spot to {isMovingNode ? 'move' : 'copy'} this step</span>
- <span className="text-muted">· press Esc to cancel</span>
- </div>
- </Panel>
- )}
-
- <Controls showInteractive={false} />
- </ReactFlow>
- </div>
-
- <HogFlowEditorPanel />
- </div>
- )
-}
-export function HogFlowEditor({ isTileCanvas = false }: { isTileCanvas?: boolean }): JSX.Element {
+export function HogFlowEditor(): 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">
- {isTileCanvas ? (
- <ReactFlowProvider>
- <TileCanvas />
- </ReactFlowProvider>
- ) : (
- <ReactFlowProvider>
- <HogFlowGraphEditor />
- </ReactFlowProvider>
- )}
+ <ReactFlowProvider>
+ <TileCanvas />
+ </ReactFlowProvider>
</div>
</HogFlowBranchSelectionProvider>
</BindLogic>
diff --git a/products/workflows/frontend/Workflows/hogflows/dragPreview.ts b/products/workflows/frontend/Workflows/hogflows/dragPreview.ts
index 6008256d6f9f..350a51be8c6a 100644
--- a/products/workflows/frontend/Workflows/hogflows/dragPreview.ts
+++ b/products/workflows/frontend/Workflows/hogflows/dragPreview.ts
@@ -1,4 +1,5 @@
-import { NODE_HEIGHT, NODE_WIDTH } from './react_flow_utils/constants'
+export const NODE_WIDTH = 120
+export const NODE_HEIGHT = 34
export function setHogFlowDragImage(dataTransfer: DataTransfer, element: HTMLElement | null): void {
if (!element || typeof dataTransfer.setDragImage !== 'function') {
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/exampleWorkflows.ts b/products/workflows/frontend/Workflows/hogflows/editor/exampleWorkflows.ts
deleted file mode 100644
index 7e866fb44de7..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/editor/exampleWorkflows.ts
+++ /dev/null
@@ -1,736 +0,0 @@
-import type { HogFlow, HogFlowAction } from '../types'
-
-type Edge = HogFlow['edges'][number]
-
-const BASE: Omit<HogFlow, 'id' | 'name' | 'description' | 'trigger' | 'actions' | 'edges' | 'variables'> = {
- team_id: 1,
- version: 4,
- status: 'active',
- exit_condition: 'exit_only_at_end',
- created_at: '2026-09-01T09:00:00.000Z',
- updated_at: '2026-09-04T12:00:00.000Z',
-}
-
-const eventTrigger = (id: string, name: string): HogFlow['trigger'] => ({
- type: 'event',
- filters: { events: [{ id, name, type: 'events' }], properties: [], actions: [] },
-})
-
-const input = (value: unknown, order: number): { order: number; value: unknown; templating: 'hog' } => ({
- order,
- value,
- templating: 'hog',
-})
-
-const variableCondition = (
- name: string,
- key: string,
- value: string | string[]
-): { name: string; filters: { properties: any[] } } => ({
- name,
- filters: { properties: [{ key, type: 'workflow_variable', value, operator: 'exact' }] },
-})
-
-const groupCondition = (
- name: string,
- key: string,
- value: string
-): { name: string; filters: { properties: any[] } } => ({
- name,
- filters: { properties: [{ key, type: 'group', value, operator: 'exact', group_type_index: 0 }] },
-})
-
-const exitAction = (reason: string): HogFlowAction =>
- ({ id: 'exit_node', type: 'exit', name: 'Exit', description: '', config: { reason } }) as HogFlowAction
-
-const getTicket = (id: string, name: string, description: string): HogFlowAction =>
- ({
- id,
- type: 'function',
- name,
- description,
- config: {
- template_id: 'template-posthog-get-ticket',
- inputs: { ticket_id: input('{event.properties.ticket_id}', 0) },
- },
- }) as HogFlowAction
-
-const emailAction = (id: string, name: string, subject: string, preheader: string, body: string): HogFlowAction =>
- ({
- id,
- type: 'function_email',
- name,
- description: '',
- config: {
- template_id: 'template-email',
- message_category_id: '019a0000-0000-0000-0000-000000000001',
- message_category_type: 'marketing',
- inputs: {
- email: {
- order: 0,
- templating: 'liquid',
- value: {
- to: { name: '', email: '{{ person.properties.email }}' },
- from: { integrationId: 1 },
- subject,
- preheader,
- html: `<html><body><h1>${subject}</h1><p>${body}</p></body></html>`,
- text: body,
- },
- },
- },
- },
- }) as HogFlowAction
-
-const setPersonProperty = (id: string, name: string, sentLabel: string): HogFlowAction =>
- ({
- id,
- type: 'function',
- name,
- description: 'Set properties of a person in PostHog.',
- config: {
- template_id: 'template-posthog-capture',
- inputs: {
- distinct_id: input('{event.distinct_id}', 0),
- set_properties: input(
- {
- workflow_emails_sent: `{arrayPushBack(person.properties.workflow_emails_sent ?? [], '${sentLabel}')}`,
- },
- 1
- ),
- set_once_properties: input({}, 2),
- },
- },
- }) as HogFlowAction
-
-const slackAction = (id: string, name: string, text: string): HogFlowAction =>
- ({
- id,
- type: 'function',
- name,
- description: '',
- config: {
- template_id: 'template-slack',
- inputs: {
- slack_workspace: input(1, 0),
- channel: input('#alerts-example', 1),
- icon_emoji: input(':hedgehog:', 2),
- username: input('PostHog', 3),
- text: input(text, 4),
- },
- },
- }) as HogFlowAction
-
-/**
- * Support SLA routing — walks a customer through segment checks and then a nine-way plan branch,
- * with a "is a tighter SLA already set?" guard in front of every write. 43 nodes, 79 edges.
- */
-const supportSlaRouting = (): HogFlow => {
- const actions: HogFlowAction[] = []
- const edges: Edge[] = []
-
- const updateTicket = (id: string, name: string, tag: string, amount: number): HogFlowAction =>
- ({
- id,
- type: 'function',
- name,
- description: `Add the ${tag} tag and set a ${amount} hour SLA`,
- config: {
- template_id: 'template-posthog-update-ticket',
- inputs: {
- ticket_id: input('{event.properties.ticket_id}', 0),
- sla_amount: input(String(amount), 1),
- sla_unit: input('hour', 2),
- sla_business_hours: input(
- {
- days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
- time: ['09:00', '17:00'],
- timezone: 'UTC',
- },
- 3
- ),
- tags: input([tag], 4),
- tags_mode: input('add', 5),
- },
- },
- }) as HogFlowAction
-
- // Every SLA write sits behind a guard that exits when the ticket already has a tighter deadline.
- const guardedWrite = (key: string, label: string, tag: string, hours: number): string => {
- const guardId = `guard_${key}`
- const writeId = `set_sla_${key}`
- actions.push({
- id: guardId,
- type: 'conditional_branch',
- name: `${label} SLA guard`,
- description: 'Skip the write when the existing SLA is already tighter.',
- config: { conditions: [variableCondition('Existing SLA is tighter', 'ticket_sla_is_tighter', ['true'])] },
- } as HogFlowAction)
- actions.push(updateTicket(writeId, `${label} ticket`, tag, hours))
- edges.push({ from: guardId, to: 'exit_node', type: 'branch', index: 0 })
- edges.push({ from: guardId, to: writeId, type: 'continue' })
- edges.push({ from: writeId, to: 'exit_node', type: 'continue' })
- return guardId
- }
-
- actions.push({
- id: 'trigger_node',
- type: 'trigger',
- name: 'Response from the customer',
- description: 'New response received',
- config: eventTrigger('$conversation_message_received', 'Ticket message received'),
- } as HogFlowAction)
- actions.push(getTicket('get_ticket', 'Get ticket', 'Load the ticket so its tags and SLA are available.'))
- actions.push({
- id: 'check_exclusions',
- type: 'conditional_branch',
- name: 'Check for exclusions',
- description: 'Skip tickets from the excluded channel, the excluded inboxes, or a new ticket.',
- config: {
- conditions: [
- variableCondition('From the excluded channel', 'ticket_slack_channel_id', 'C00EXAMPLE1'),
- variableCondition('Sent to shop@', 'ticket_email_to', ['[email protected]']),
- variableCondition('Sent to abuse@', 'ticket_email_to', ['[email protected]']),
- variableCondition('Ticket status is new', 'ticket_status', ['new']),
- ],
- },
- } as HogFlowAction)
- edges.push({ from: 'trigger_node', to: 'get_ticket', type: 'continue' })
- edges.push({ from: 'get_ticket', to: 'check_exclusions', type: 'continue' })
- for (const index of [0, 1, 2, 3]) {
- edges.push({ from: 'check_exclusions', to: 'exit_node', type: 'branch', index })
- }
-
- // Segments are checked one after another, each falling through to the next.
- const segments = [
- {
- key: 'top-accounts',
- label: 'Top accounts',
- tag: 'segment_top_accounts',
- hours: 2,
- property: 'is_top_account',
- },
- { key: 'churn-risk', label: 'Churn risk', tag: 'segment_churn_risk', hours: 2, property: 'is_churn_risk' },
- { key: 'onboarding', label: 'Onboarding', tag: 'segment_onboarding', hours: 8, property: 'is_onboarding' },
- ]
- let fallthroughFrom = 'check_exclusions'
- for (const segment of segments) {
- const checkId = `check_${segment.key}`
- actions.push({
- id: checkId,
- type: 'conditional_branch',
- name: `Check if ${segment.label.toLowerCase()}`,
- description: '',
- config: { conditions: [groupCondition(segment.label, segment.property, 'true')] },
- } as HogFlowAction)
- edges.push({ from: fallthroughFrom, to: checkId, type: 'continue' })
- const guardId = guardedWrite(segment.key, segment.label, segment.tag, segment.hours)
- edges.push({ from: checkId, to: guardId, type: 'branch', index: 0 })
- fallthroughFrom = checkId
- }
-
- const plans = [
- { key: 'enterprise', label: 'Enterprise', tag: 'plan_enterprise', hours: 4 },
- { key: 'enterprise-managed', label: 'Enterprise (managed)', tag: 'plan_enterprise_managed', hours: 4 },
- { key: 'scale', label: 'Scale', tag: 'plan_scale', hours: 16 },
- { key: 'growth', label: 'Growth', tag: 'plan_growth', hours: 32 },
- { key: 'teams', label: 'Teams', tag: 'plan_teams', hours: 16 },
- { key: 'paid', label: 'Paid', tag: 'plan_paid', hours: 32 },
- { key: 'free', label: 'Free', tag: 'plan_free', hours: 48 },
- { key: 'startup', label: 'Startup', tag: 'plan_startup', hours: 32 },
- { key: 'accelerator', label: 'Accelerator', tag: 'plan_accelerator', hours: 16 },
- ]
- actions.push({
- id: 'check_plan',
- type: 'conditional_branch',
- name: 'Check billing plan',
- description: 'Check the billing plan for every customer that matched no segment.',
- config: { conditions: plans.map((plan) => groupCondition(plan.label, 'billing_plan', plan.key)) },
- } as HogFlowAction)
- edges.push({ from: fallthroughFrom, to: 'check_plan', type: 'continue' })
- plans.forEach((plan, index) => {
- const guardId = guardedWrite(plan.key, plan.label, plan.tag, plan.hours)
- edges.push({ from: 'check_plan', to: guardId, type: 'branch', index })
- })
-
- actions.push({
- id: 'check_shared_channel',
- type: 'conditional_branch',
- name: 'Check shared channel',
- description: 'Customers with a shared channel get a default SLA instead of an alert.',
- config: {
- conditions: [
- variableCondition('Has a shared Slack channel', 'ticket_channel_kind', ['slack']),
- variableCondition('Has a shared Teams channel', 'ticket_channel_kind', ['teams']),
- ],
- },
- } as HogFlowAction)
- edges.push({ from: 'check_plan', to: 'check_shared_channel', type: 'continue' })
- edges.push({
- from: 'check_shared_channel',
- to: guardedWrite('slack-default', 'Shared Slack channel default', 'channel_slack_default', 16),
- type: 'branch',
- index: 0,
- })
- edges.push({
- from: 'check_shared_channel',
- to: guardedWrite('teams-default', 'Shared Teams channel default', 'channel_teams_default', 16),
- type: 'branch',
- index: 1,
- })
-
- actions.push({
- id: 'check_contact_route',
- type: 'conditional_branch',
- name: 'Check the page or inbox the reply came from',
- description: '',
- config: {
- conditions: [
- variableCondition('Replied from /login', 'ticket_page', ['/login']),
- variableCondition('Replied from /signup', 'ticket_page', ['/signup']),
- variableCondition('Emailed billing@', 'ticket_email_to', ['[email protected]']),
- ],
- },
- } as HogFlowAction)
- edges.push({ from: 'check_shared_channel', to: 'check_contact_route', type: 'continue' })
- const loginGuard = guardedWrite('login-default', 'Login default', 'unknown_login_default', 8)
- const billingGuard = guardedWrite('billing-default', 'Billing default', 'unknown_billing_default', 32)
- edges.push({ from: 'check_contact_route', to: loginGuard, type: 'branch', index: 0 })
- edges.push({ from: 'check_contact_route', to: loginGuard, type: 'branch', index: 1 })
- edges.push({ from: 'check_contact_route', to: billingGuard, type: 'branch', index: 2 })
-
- actions.push(
- slackAction(
- 'alert_unmatched',
- 'Alert the support channel',
- 'A ticket matched no segment, plan, or channel and needs triage by hand.'
- )
- )
- edges.push({ from: 'check_contact_route', to: 'alert_unmatched', type: 'continue' })
- edges.push({ from: 'alert_unmatched', to: 'exit_node', type: 'continue' })
- actions.push(exitAction('Default exit'))
-
- return {
- ...BASE,
- id: 'example-support-sla-routing',
- name: 'Support SLA routing by segment and plan',
- description:
- 'Runs when a customer replies to a ticket. Checks segments in priority order, then the billing plan, and sets a response-time SLA plus a matching tag. Every write is guarded so a tighter existing SLA is never overwritten.',
- trigger: eventTrigger('$conversation_message_received', 'Ticket message received'),
- variables: [
- { key: 'ticket_status', type: 'string', label: 'Status', default: '' },
- { key: 'ticket_priority', type: 'string', label: 'Priority', default: '' },
- { key: 'ticket_number', type: 'string', label: 'Number', default: '' },
- { key: 'ticket_subject', type: 'string', label: 'Subject', default: '' },
- { key: 'ticket_email_to', type: 'string', label: 'Sent to', default: '' },
- { key: 'ticket_page', type: 'string', label: 'Page', default: '' },
- { key: 'ticket_slack_channel_id', type: 'string', label: 'Slack channel', default: '' },
- { key: 'ticket_channel_kind', type: 'string', label: 'Channel kind', default: '' },
- { key: 'ticket_sla_due_at', type: 'string', label: 'SLA due at', default: '' },
- { key: 'ticket_sla_is_tighter', type: 'string', label: 'Existing SLA is tighter', default: '' },
- ],
- actions,
- edges,
- }
-}
-
-/**
- * Renewal alerting — a short gate chain that fans out into seven mutually exclusive Slack pings.
- * 15 nodes, 25 edges.
- */
-const renewalWindowAlerts = (): HogFlow => {
- const pings = [
- {
- id: 'ping_renewal_over',
- name: 'Ping: credit runs out early',
- text: 'Credit runs out before the renewal date.',
- },
- {
- id: 'ping_renewal_under',
- name: 'Ping: credit left at renewal',
- text: 'Credit is left over at the renewal date.',
- },
- { id: 'ping_renewal_on12', name: 'Ping: on track, 12 month', text: 'On track on a 12 month contract.' },
- {
- id: 'ping_renewal_multi',
- name: 'Ping: on track, multi-year',
- text: 'On track on a multi-year contract that is ending.',
- },
- {
- id: 'ping_instalment_over',
- name: 'Ping: gap before the instalment',
- text: 'Credit runs out before the next instalment.',
- },
- {
- id: 'ping_instalment_under',
- name: 'Ping: credit left at the instalment',
- text: 'Credit is left over at the next instalment.',
- },
- {
- id: 'ping_instalment_on',
- name: 'Ping: instalment on track',
- text: 'Usage is on track for the next instalment.',
- },
- ]
-
- const actions: HogFlowAction[] = [
- {
- id: 'trigger_node',
- type: 'trigger',
- name: 'Contract phase becomes renewal window',
- description: '',
- config: eventTrigger('$account_custom_property_changed', 'Account custom property changed'),
- } as HogFlowAction,
- {
- id: 'get_account',
- type: 'function',
- name: 'Fetch the account',
- description: 'Loads the account so the message can name the managing team.',
- on_error: 'continue',
- output_variable: { key: 'account' },
- config: {
- template_id: 'template-posthog-get-account',
- inputs: { external_id: input('{event.properties.account_external_id}', 0) },
- },
- } as HogFlowAction,
- {
- id: 'gate_managed',
- type: 'conditional_branch',
- name: 'Account has a managing team?',
- description: '',
- config: { conditions: [groupCondition('Has a managing team', 'account_team', 'set')] },
- } as HogFlowAction,
- {
- id: 'gate_signed',
- type: 'conditional_branch',
- name: 'Renewal already signed?',
- description: '',
- config: { conditions: [groupCondition('Already signed', 'renewal_signed', 'true')] },
- } as HogFlowAction,
- {
- id: 'branch_next_event',
- type: 'conditional_branch',
- name: 'Next event: instalment or contract end?',
- description: '',
- config: {
- conditions: [
- groupCondition('Next instalment', 'next_contract_event', 'instalment'),
- groupCondition('Contract end', 'next_contract_event', 'contract_end'),
- ],
- },
- } as HogFlowAction,
- {
- id: 'band_renewal',
- type: 'conditional_branch',
- name: 'Renewal: usage band and term',
- description: '',
- config: {
- conditions: [
- groupCondition('Runs out early', 'usage_band', 'over'),
- groupCondition('Credit left over', 'usage_band', 'under'),
- groupCondition('On track, 12 month', 'usage_band', 'on_track_12'),
- groupCondition('On track, multi-year', 'usage_band', 'on_track_multi'),
- ],
- },
- } as HogFlowAction,
- {
- id: 'band_instalment',
- type: 'conditional_branch',
- name: 'Instalment: usage band',
- description: '',
- config: {
- conditions: [
- groupCondition('Runs out early', 'usage_band', 'over'),
- groupCondition('Credit left over', 'usage_band', 'under'),
- groupCondition('On track', 'usage_band', 'on_track'),
- ],
- },
- } as HogFlowAction,
- ...pings.map((ping) => slackAction(ping.id, ping.name, ping.text)),
- exitAction('Done'),
- ]
-
- const edges: Edge[] = [
- { from: 'trigger_node', to: 'get_account', type: 'continue' },
- { from: 'get_account', to: 'gate_managed', type: 'continue' },
- { from: 'gate_managed', to: 'gate_signed', type: 'branch', index: 0 },
- { from: 'gate_managed', to: 'exit_node', type: 'continue' },
- { from: 'gate_signed', to: 'exit_node', type: 'branch', index: 0 },
- { from: 'gate_signed', to: 'branch_next_event', type: 'continue' },
- { from: 'branch_next_event', to: 'band_instalment', type: 'branch', index: 0 },
- { from: 'branch_next_event', to: 'band_renewal', type: 'branch', index: 1 },
- { from: 'branch_next_event', to: 'exit_node', type: 'continue' },
- { from: 'band_renewal', to: 'ping_renewal_over', type: 'branch', index: 0 },
- { from: 'band_renewal', to: 'ping_renewal_under', type: 'branch', index: 1 },
- { from: 'band_renewal', to: 'ping_renewal_on12', type: 'branch', index: 2 },
- { from: 'band_renewal', to: 'ping_renewal_multi', type: 'branch', index: 3 },
- { from: 'band_renewal', to: 'exit_node', type: 'continue' },
- { from: 'band_instalment', to: 'ping_instalment_over', type: 'branch', index: 0 },
- { from: 'band_instalment', to: 'ping_instalment_under', type: 'branch', index: 1 },
- { from: 'band_instalment', to: 'ping_instalment_on', type: 'branch', index: 2 },
- { from: 'band_instalment', to: 'exit_node', type: 'continue' },
- ...pings.map((ping): Edge => ({ from: ping.id, to: 'exit_node', type: 'continue' })),
- ]
-
- return {
- ...BASE,
- id: 'example-renewal-window-alerts',
- name: 'Renewal window alerts',
- description:
- 'Pings the account owner when a contract enters its renewal window. Skips signed renewals, then routes by the next contract event and the usage band to one of seven messages.',
- trigger: eventTrigger('$account_custom_property_changed', 'Account custom property changed'),
- variables: [],
- actions,
- edges,
- }
-}
-
-/**
- * Pending ticket cleanup — long, mostly linear, with three delays and a re-check before each send.
- * 15 nodes, 21 edges.
- */
-const pendingTicketCleanup = (): HogFlow => {
- const actions: HogFlowAction[] = [
- {
- id: 'trigger_node',
- type: 'trigger',
- name: 'Ticket becomes pending',
- description: '',
- config: eventTrigger('$conversation_ticket_status_changed', 'Ticket status changed'),
- } as HogFlowAction,
- {
- id: 'delay_five_days',
- type: 'delay',
- name: 'Wait five days',
- description: '',
- config: { delay_duration: '5d' },
- } as HogFlowAction,
- getTicket('get_ticket', 'Get ticket', 'Load the ticket before deciding whether to warn.'),
- {
- id: 'check_exclusions',
- type: 'conditional_branch',
- name: 'Check for exclusions',
- description: '',
- config: {
- conditions: [
- variableCondition('From the excluded channel', 'ticket_slack_channel_id', 'C00EXAMPLE1'),
- variableCondition('Sent to shop@', 'ticket_email_to', ['[email protected]']),
- variableCondition('Sent to abuse@', 'ticket_email_to', ['[email protected]']),
- variableCondition('Excluded from reporting', 'ticket_tags', ['exclude_from_reporting']),
- ],
- },
- } as HogFlowAction,
- {
- id: 'check_pending',
- type: 'conditional_branch',
- name: 'Still pending?',
- description: '',
- config: { conditions: [variableCondition('Still pending', 'ticket_status', ['pending'])] },
- } as HogFlowAction,
- emailAction(
- 'email_warning',
- 'Warning email',
- 'We will close this ticket soon',
- 'Reply to keep it open',
- 'We have not heard back for five days. Reply and we will pick this up again.'
- ),
- {
- id: 'delay_two_days',
- type: 'delay',
- name: 'Wait two days',
- description: '',
- config: { delay_duration: '2d' },
- } as HogFlowAction,
- getTicket('get_ticket_again', 'Get ticket again', 'Re-read the ticket after the warning.'),
- {
- id: 'check_pending_again',
- type: 'conditional_branch',
- name: 'Still pending after the warning?',
- description: '',
- config: { conditions: [variableCondition('Still pending', 'ticket_status', ['pending'])] },
- } as HogFlowAction,
- {
- id: 'resolve_ticket',
- type: 'function',
- name: 'Resolve the ticket',
- description: '',
- config: {
- template_id: 'template-posthog-update-ticket',
- inputs: {
- ticket_id: input('{event.properties.ticket_id}', 0),
- status: input('resolved', 1),
- tags_mode: input('add', 2),
- },
- },
- } as HogFlowAction,
- {
- id: 'delay_one_day',
- type: 'delay',
- name: 'Wait 24 hours',
- description: '',
- config: { delay_duration: '1d' },
- } as HogFlowAction,
- getTicket('recheck_ticket', 'Re-check the ticket', 'Only survey tickets that are still resolved.'),
- {
- id: 'check_resolved',
- type: 'conditional_branch',
- name: 'Still resolved?',
- description: '',
- config: { conditions: [variableCondition('Still resolved', 'ticket_status', ['resolved'])] },
- } as HogFlowAction,
- emailAction(
- 'email_survey',
- 'Satisfaction survey',
- 'How did we do?',
- 'One question, one click',
- 'Your ticket is closed. Tell us how the support went.'
- ),
- exitAction('Default exit'),
- ]
-
- const edges: Edge[] = [
- { from: 'trigger_node', to: 'delay_five_days', type: 'continue' },
- { from: 'delay_five_days', to: 'get_ticket', type: 'continue' },
- { from: 'get_ticket', to: 'check_exclusions', type: 'continue' },
- { from: 'check_exclusions', to: 'exit_node', type: 'branch', index: 0 },
- { from: 'check_exclusions', to: 'exit_node', type: 'branch', index: 1 },
- { from: 'check_exclusions', to: 'exit_node', type: 'branch', index: 2 },
- { from: 'check_exclusions', to: 'exit_node', type: 'branch', index: 3 },
- { from: 'check_exclusions', to: 'check_pending', type: 'continue' },
- { from: 'check_pending', to: 'email_warning', type: 'branch', index: 0 },
- { from: 'check_pending', to: 'exit_node', type: 'continue' },
- { from: 'email_warning', to: 'delay_two_days', type: 'continue' },
- { from: 'delay_two_days', to: 'get_ticket_again', type: 'continue' },
- { from: 'get_ticket_again', to: 'check_pending_again', type: 'continue' },
- { from: 'check_pending_again', to: 'resolve_ticket', type: 'branch', index: 0 },
- { from: 'check_pending_again', to: 'exit_node', type: 'continue' },
- { from: 'resolve_ticket', to: 'delay_one_day', type: 'continue' },
- { from: 'delay_one_day', to: 'recheck_ticket', type: 'continue' },
- { from: 'recheck_ticket', to: 'check_resolved', type: 'continue' },
- { from: 'check_resolved', to: 'email_survey', type: 'branch', index: 0 },
- { from: 'check_resolved', to: 'exit_node', type: 'continue' },
- { from: 'email_survey', to: 'exit_node', type: 'continue' },
- ]
-
- return {
- ...BASE,
- id: 'example-pending-ticket-cleanup',
- name: 'Close tickets that stay pending',
- description:
- 'Warns on day five, closes the ticket on day seven if nobody replied, then sends a satisfaction survey a day later when the ticket is still closed.',
- trigger: eventTrigger('$conversation_ticket_status_changed', 'Ticket status changed'),
- variables: [
- { key: 'ticket_status', type: 'string', label: 'Status', default: '' },
- { key: 'ticket_email_to', type: 'string', label: 'Sent to', default: '' },
- { key: 'ticket_tags', type: 'string', label: 'Tags', default: '' },
- { key: 'ticket_slack_channel_id', type: 'string', label: 'Slack channel', default: '' },
- ],
- actions,
- edges,
- }
-}
-
-/**
- * Add-on promotion — a wide email split where each send is followed by its own person-property write.
- * 14 nodes, 19 edges.
- */
-const addOnPromotionEmails = (): HogFlow => {
- const paths = [
- { key: 'seat_growth', subject: 'Your team is growing', label: 'Seat growth' },
- { key: 'flag_usage', subject: 'You are running a lot of flags', label: 'Flag usage' },
- { key: 'project_count', subject: 'Time for another project?', label: 'Project count' },
- { key: 'follow_up_a', subject: 'One more thing about add-ons', label: 'Follow-up A' },
- { key: 'follow_up_b', subject: 'A different angle on add-ons', label: 'Follow-up B' },
- ]
-
- const emailId = (key: string): string => `email_${key}`
- const writeId = (key: string): string => `record_${key}`
-
- const actions: HogFlowAction[] = [
- {
- id: 'trigger_node',
- type: 'trigger',
- name: 'No add-on and revenue above the threshold',
- description: '',
- config: eventTrigger('organization usage report', 'Organization usage report'),
- } as HogFlowAction,
- {
- id: 'branch_signal',
- type: 'conditional_branch',
- name: 'Which growth signal fired?',
- description: '',
- config: {
- conditions: [
- groupCondition('Seat growth', 'growth_signal', 'seats'),
- groupCondition('Flag usage', 'growth_signal', 'flags'),
- groupCondition('Project count', 'growth_signal', 'projects'),
- groupCondition('Nothing specific', 'growth_signal', 'generic'),
- ],
- },
- } as HogFlowAction,
- {
- id: 'branch_second_email',
- type: 'conditional_branch',
- name: 'Send a second email?',
- description: '',
- config: {
- conditions: [
- groupCondition('First follow-up', 'follow_up_stage', 'first'),
- groupCondition('Second follow-up', 'follow_up_stage', 'second'),
- ],
- },
- } as HogFlowAction,
- ...paths.flatMap((path) => [
- emailAction(
- emailId(path.key),
- path.label,
- path.subject,
- 'A quick look at what the add-ons do',
- 'Here is what the Growth and Scale add-ons change for a workspace your size.'
- ),
- setPersonProperty(writeId(path.key), 'Update person property', path.subject),
- ]),
- exitAction('Default exit'),
- ]
-
- const edges: Edge[] = [
- { from: 'trigger_node', to: 'branch_signal', type: 'continue' },
- { from: 'branch_signal', to: emailId('seat_growth'), type: 'branch', index: 0 },
- { from: 'branch_signal', to: emailId('flag_usage'), type: 'branch', index: 1 },
- { from: 'branch_signal', to: emailId('project_count'), type: 'branch', index: 2 },
- { from: 'branch_signal', to: 'branch_second_email', type: 'branch', index: 3 },
- { from: 'branch_signal', to: 'exit_node', type: 'continue' },
- { from: 'branch_second_email', to: emailId('follow_up_a'), type: 'branch', index: 0 },
- { from: 'branch_second_email', to: emailId('follow_up_b'), type: 'branch', index: 1 },
- { from: 'branch_second_email', to: 'exit_node', type: 'continue' },
- ...paths.flatMap((path): Edge[] => [
- { from: emailId(path.key), to: writeId(path.key), type: 'continue' },
- { from: writeId(path.key), to: 'exit_node', type: 'continue' },
- ]),
- ]
-
- return {
- ...BASE,
- id: 'example-add-on-promotion-emails',
- name: 'Promote add-ons from a growth signal',
- description:
- 'Splits on which growth signal fired, sends the matching email, and records the send on the person so the same email never goes out twice.',
- trigger: eventTrigger('organization usage report', 'Organization usage report'),
- variables: [{ key: 'growth_signal', type: 'string', label: 'Growth signal', default: '' }],
- actions,
- edges,
- }
-}
-
-/**
- * Redacted stand-ins for the busiest workflows running in production, matched node for node and
- * edge for edge. Names, filters, channels, addresses, and email bodies are invented.
- */
-export const EXAMPLE_WORKFLOWS: Record<string, HogFlow> = Object.fromEntries(
- [supportSlaRouting(), renewalWindowAlerts(), pendingTicketCleanup(), addOnPromotionEmails()].map((flow) => [
- flow.id,
- flow,
- ])
-)
-
-export const EXAMPLE_WORKFLOW_IDS = Object.keys(EXAMPLE_WORKFLOWS)
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx b/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx
deleted file mode 100644
index c4ae7e88af08..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import type { Meta, StoryFn } from '@storybook/react'
-import { BindLogic, useValues } from 'kea'
-
-import { SpinnerOverlay } from '@posthog/lemon-ui'
-
-import { App } from 'scenes/App'
-import { urls } from 'scenes/urls'
-
-import { workflowLogic } from '../../../workflowLogic'
-import { HogFlowEditor } from '../../HogFlowEditor'
-import {
- CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID,
- workflowEditorStoryDecorator,
-} from '../workflowEditorStoryFixtures'
-
-const meta: Meta<typeof HogFlowEditor> = {
- title: 'Products/Workflows/Editor/Graph',
- component: HogFlowEditor,
- parameters: {
- layout: 'fullscreen',
- testOptions: {
- waitForLoadersToDisappear: true,
- waitForSelector: '[data-attr=workflow-editor]',
- viewport: { width: 1600, height: 1000 },
- },
- },
- decorators: [workflowEditorStoryDecorator],
-}
-export default meta
-
-const WorkflowStory = ({ id, className = '' }: { id: string; className?: string }): JSX.Element => (
- <BindLogic logic={workflowLogic} props={{ id }}>
- <div className={`h-screen [&>div]:!h-full [&>div]:!max-h-none ${className}`}>
- <StorybookWorkflow />
- </div>
- </BindLogic>
-)
-
-function StorybookWorkflow(): JSX.Element {
- const { originalWorkflow } = useValues(workflowLogic)
-
- return (
- <div className="flex h-full flex-col">
- {originalWorkflow ? <HogFlowEditor key={originalWorkflow.id} /> : <SpinnerOverlay />}
- </div>
- )
-}
-
-export const NewWorkflow: StoryFn = () => <WorkflowStory id="new" />
-export const CustomerOnboardingAndRetention: StoryFn = () => (
- <WorkflowStory id={CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID} />
-)
-export const SupportSlaRouting: StoryFn = () => <WorkflowStory id="example-support-sla-routing" />
-export const RenewalWindowAlerts: StoryFn = () => <WorkflowStory id="example-renewal-window-alerts" />
-export const PendingTicketCleanup: StoryFn = () => <WorkflowStory id="example-pending-ticket-cleanup" />
-export const AddOnPromotionEmails: StoryFn = () => <WorkflowStory id="example-add-on-promotion-emails" />
-
-// 32rem sits below the 48rem container-query breakpoint the editor uses to stack the settings
-// panel under the graph, so this story exercises the narrow layout.
-export const NarrowWorkflow: StoryFn = () => (
- <WorkflowStory id={CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID} className="w-[32rem] max-w-full" />
-)
-NarrowWorkflow.parameters = { testOptions: { waitForSelector: '.react-flow__node' } }
-export const WithNavigation: StoryFn = () => <App />
-WithNavigation.parameters = {
- pageUrl: urls.workflow(CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID, 'workflow'),
- mockDate: '2026-09-04 12:00:00',
- testOptions: {
- waitForSelector: '.react-flow__node',
- viewport: { width: 1280, height: 900 },
- includeNavigationInSnapshot: true,
- },
-}
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.tsx
index 5f62df8c8d4c..8130b32ad6a7 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
@@ -4,9 +4,6 @@ import { useEffect } from 'react'
import { SpinnerOverlay } from '@posthog/lemon-ui'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
-
import { workflowLogic } from '../../../workflowLogic'
import { HogFlowEditor } from '../../HogFlowEditor'
import type { HogFlowEditorActionMetrics } from '../../hogFlowEditorLogic'
@@ -25,7 +22,6 @@ const meta: Meta = {
title: 'Products/Workflows/Editor/Tile canvas',
parameters: {
layout: 'fullscreen',
- featureFlags: [FEATURE_FLAGS.WORKFLOWS_TILE_CANVAS],
mockDate: '2026-10-10 12:00:00',
testOptions: {
waitForLoadersToDisappear: true,
@@ -65,12 +61,11 @@ function StoryEditor({
openAllPaths?: boolean
}): JSX.Element {
const { originalWorkflow } = useValues(workflowLogic)
- const tileCanvasEnabled = useFeatureFlag('WORKFLOWS_TILE_CANVAS')
return (
<div className="flex h-full flex-col">
{originalWorkflow ? (
<>
- <HogFlowEditor key={originalWorkflow.id} isTileCanvas={!!tileCanvasEnabled} />
+ <HogFlowEditor key={originalWorkflow.id} />
<StoryState metrics={metrics} openAllPaths={openAllPaths} />
</>
) : (
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasPanel.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasPanel.tsx
index 1730f88d74e7..8ff1d6649e9c 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasPanel.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasPanel.tsx
@@ -20,5 +20,5 @@ export function TileCanvasPanel(): JSX.Element {
),
}
: undefined
- return <HogFlowEditorPanel layout="docked" onClose={closePanel} view={historyView} />
+ return <HogFlowEditorPanel onClose={closePanel} view={historyView} />
}
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts
index d9816dc74969..a9bd500e9849 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts
@@ -606,17 +606,5 @@ describe('tileCanvasLogic', () => {
it('counts the people a step filtered out', () => {
expect(stepCount(logic.values.stepMetrics, 'pause')).toBe(48)
})
-
- it('keeps the canvas counts when the Metrics panel loads another date range', async () => {
- const editorLogic = hogFlowEditorLogic({ id: WORKFLOW_ID })
-
- await expectLogic(logic, () =>
- editorLogic.actions.loadActionMetricsByIdSuccess({
- pause: { actionId: 'pause', succeeded: 3, failed: 0, filtered: 0 },
- })
- )
-
- expect(stepCount(logic.values.stepMetrics, 'pause')).toBe(48)
- })
})
})
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts
index 6e7743cec8ea..50342727e89a 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts
@@ -1085,7 +1085,7 @@ export const tileCanvasLogic = kea<tileCanvasLogicType>([
},
})),
afterMount(({ actions, values, cache }) => {
- // The step can be picked before the canvas mounts, from the tree view or a link to the step.
+ // The step can be picked before the canvas mounts, from a link to the step.
if (values.selectedNodeId) {
actions.revealStep(values.selectedNodeId)
}
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts
index c855df5c0f8d..d2c028f5cdb8 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts
@@ -40,6 +40,11 @@ function useViewportFollowsResize(wrapperRef: RefObject<HTMLDivElement>): void {
let previous = sizeOf(wrapper)
const observer = new ResizeObserver(() => {
const next = sizeOf(wrapper)
+ // A canvas that briefly collapses to no width shows nothing, so measuring from it would move the steps out
+ // of view for good. The next real size compares against the last real size instead.
+ if (next.width === 0 || next.height === 0) {
+ return
+ }
if (next.width === previous.width && next.height === previous.height) {
return
}
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
index c5aa3b7d839e..deb61f716b2d 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
@@ -1,295 +1,16 @@
import { mswDecorator } from '~/mocks/browser'
import { NEW_WORKFLOW } from '../../workflowLogic'
-import type { HogFlow, HogFlowAction } from '../types'
-import { EXAMPLE_WORKFLOWS } from './exampleWorkflows'
+import type { HogFlow } from '../types'
-export const CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID = 'storybook-complex-workflow'
-export const CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW: HogFlow = {
- id: CUSTOMER_ONBOARDING_AND_RETENTION_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 PICKABLE_WORKFLOWS: Record<string, HogFlow> = {
- [CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID]: CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW,
- ...EXAMPLE_WORKFLOWS,
-}
-
-/** Pass more workflows to make them loadable by id in a story. */
export function createWorkflowEditorStoryDecorator(
- extraWorkflows: Record<string, HogFlow> = {}
+ workflowsById: Record<string, HogFlow>
): ReturnType<typeof mswDecorator> {
- const workflowsById: Record<string, HogFlow> = { ...PICKABLE_WORKFLOWS, ...extraWorkflows }
return mswDecorator({
get: {
'/api/projects/:team_id/hog_flow_templates/': { count: 0, results: [] },
// nosemgrep: no-environments-api-urls-frontend -- api.hogFlows has not migrated to generated project routes.
- '/api/environments/:team_id/hog_flows/:id/': ({ params }) => [
- 200,
- workflowsById[String(params.id)] ?? CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW,
- ],
+ '/api/environments/:team_id/hog_flows/:id/': ({ params }) => [200, workflowsById[String(params.id)]],
// nosemgrep: no-environments-api-urls-frontend -- api.messaging has not migrated to generated project routes.
'/api/environments/:team_id/messaging_categories': { count: 0, results: [] },
'/api/projects/:team_id/workflow_imports/for_workflow/': [204],
@@ -299,7 +20,7 @@ export function createWorkflowEditorStoryDecorator(
'/api/environments/:team_id/hog_flows/:id/': async ({ request, params }) => [
200,
{
- ...(workflowsById[String(params.id)] ?? CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW),
+ ...workflowsById[String(params.id)],
...((await request.json()) as Partial<HogFlow>),
updated_at: '2026-09-04T12:01:00.000Z',
},
@@ -329,5 +50,3 @@ export function createWorkflowEditorStoryDecorator(
},
})
}
-
-export const workflowEditorStoryDecorator = createWorkflowEditorStoryDecorator()
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts
index 9111ff335dc2..7a42b25a84fc 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts
@@ -2,15 +2,12 @@ import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
import { expectLogic } from 'kea-test-utils'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { teamLogic } from 'scenes/teamLogic'
import { initKeaTests } from '~/test/init'
import { EXIT_NODE_ID, NEW_WORKFLOW, TRIGGER_NODE_ID, workflowLogic } from '../workflowLogic'
import { computeInsertEdges, computeMoveEdges, hogFlowEditorLogic } from './hogFlowEditorLogic'
-import * as autolayout from './react_flow_utils/autolayout'
import { HogFlow, HogFlowAction, HogFlowActionEdge, HogFlowActionNode } from './types'
type Edge = HogFlow['edges'][0]
@@ -294,415 +291,6 @@ describe('hogFlowEditorLogic', () => {
])
})
- describe('conditional branch naming', () => {
- const createMockHogFlow = (conditionNames?: (string | undefined)[]): HogFlow => ({
- id: 'test-flow',
- team_id: 1,
- version: 1,
- name: 'Test Flow',
- status: 'draft',
- exit_condition: 'exit_only_at_end',
- actions: [
- {
- id: 'trigger',
- name: 'Trigger',
- description: '',
- type: 'trigger',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- type: 'event',
- filters: {},
- },
- },
- {
- id: 'branch',
- name: 'Conditional Branch',
- description: '',
- type: 'conditional_branch',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- conditions: conditionNames
- ? conditionNames.map((name) => ({ filters: {}, name }))
- : [{ filters: {} }, { filters: {} }],
- },
- },
- {
- id: 'exit',
- name: 'Exit',
- description: '',
- type: 'exit',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: { reason: '' },
- },
- ],
- edges: [
- { from: 'trigger', to: 'branch', type: 'continue' },
- { from: 'branch', to: 'exit', type: 'branch', index: 0 },
- { from: 'branch', to: 'exit', type: 'branch', index: 1 },
- { from: 'branch', to: 'exit', type: 'continue' },
- ],
- updated_at: new Date().toISOString(),
- created_at: new Date().toISOString(),
- })
-
- it('should use default labels when condition names are not provided', () => {
- const mockFlow = createMockHogFlow()
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
-
- // Find the branch edges
- const branchEdge0 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_0'))
- const branchEdge1 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_1'))
- const continueEdge = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('continue_branch'))
-
- expect(branchEdge0?.data?.label).toBe('If condition #1 matches')
- expect(branchEdge1?.data?.label).toBe('If condition #2 matches')
- expect(continueEdge?.data?.label).toBe('No match')
- })
-
- it('should use custom names when provided for conditional branches', () => {
- const mockFlow = createMockHogFlow(['User is premium', 'User is in trial'])
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
-
- // Find the branch edges
- const branchEdge0 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_0'))
- const branchEdge1 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_1'))
- const continueEdge = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('continue_branch'))
-
- expect(branchEdge0?.data?.label).toBe('User is premium')
- expect(branchEdge1?.data?.label).toBe('User is in trial')
- expect(continueEdge?.data?.label).toBe('No match')
- })
-
- it('should fall back to default labels for conditions without names', () => {
- const mockFlow = createMockHogFlow(['User is premium', undefined])
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
-
- // Find the branch edges
- const branchEdge0 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_0'))
- const branchEdge1 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_1'))
-
- expect(branchEdge0?.data?.label).toBe('User is premium')
- expect(branchEdge1?.data?.label).toBe('If condition #2 matches')
- })
-
- it('should not show labels for single-edge nodes', () => {
- const mockFlow = createMockHogFlow()
- // Remove all but one edge from the branch node
- mockFlow.edges = [
- { from: 'trigger', to: 'branch', type: 'continue' },
- { from: 'branch', to: 'exit', type: 'continue' },
- ]
-
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
- const branchEdge = edges.find((e) => e.source === 'branch')
-
- expect(branchEdge?.data?.label).toBeUndefined()
- })
-
- it('should update edge labels when conditions are modified', () => {
- const mockFlow = createMockHogFlow()
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- // Update the action with new condition names
- const updatedAction: HogFlowAction = {
- id: 'branch',
- name: 'Conditional Branch',
- description: '',
- type: 'conditional_branch',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- conditions: [
- { filters: {}, name: 'New condition 1' },
- { filters: {}, name: 'New condition 2' },
- ],
- },
- }
-
- logic.actions.setWorkflowAction('branch', updatedAction)
-
- // Re-trigger the flow reset to update edges
- const updatedFlow = {
- ...mockFlow,
- actions: mockFlow.actions.map((a) => (a.id === 'branch' ? updatedAction : a)),
- }
- logic.actions.resetFlowFromHogFlow(updatedFlow)
-
- const edges = logic.values.edges
- const branchEdge0 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_0'))
- const branchEdge1 = edges.find((e) => e.source === 'branch' && e.sourceHandle?.includes('branch_branch_1'))
-
- expect(branchEdge0?.data?.label).toBe('New condition 1')
- expect(branchEdge1?.data?.label).toBe('New condition 2')
- })
-
- it('should use custom names for wait_until_condition when provided', () => {
- const mockFlow: HogFlow = {
- ...createMockHogFlow(),
- actions: [
- {
- id: 'trigger',
- name: 'Trigger',
- description: '',
- type: 'trigger',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- type: 'event',
- filters: {},
- },
- },
- {
- id: 'wait',
- name: 'Wait Until',
- description: '',
- type: 'wait_until_condition',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- condition: { filters: {}, name: 'User completes onboarding' },
- max_wait_duration: '1h',
- },
- },
- {
- id: 'exit',
- name: 'Exit',
- description: '',
- type: 'exit',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: { reason: '' },
- },
- ],
- edges: [
- { from: 'trigger', to: 'wait', type: 'continue' },
- { from: 'wait', to: 'exit', type: 'branch', index: 0 },
- { from: 'wait', to: 'exit', type: 'continue' },
- ],
- }
-
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
- const branchEdge = edges.find((e) => e.source === 'wait' && e.sourceHandle?.includes('branch_wait_0'))
-
- expect(branchEdge?.data?.label).toBe('User completes onboarding')
- })
-
- it('should handle wait_until_condition edge labels without custom names', () => {
- const mockFlow: HogFlow = {
- ...createMockHogFlow(),
- actions: [
- {
- id: 'trigger',
- name: 'Trigger',
- description: '',
- type: 'trigger',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- type: 'event',
- filters: {},
- },
- },
- {
- id: 'wait',
- name: 'Wait Until',
- description: '',
- type: 'wait_until_condition',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- condition: { filters: {} },
- max_wait_duration: '1h',
- },
- },
- {
- id: 'exit',
- name: 'Exit',
- description: '',
- type: 'exit',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: { reason: '' },
- },
- ],
- edges: [
- { from: 'trigger', to: 'wait', type: 'continue' },
- { from: 'wait', to: 'exit', type: 'branch', index: 0 },
- { from: 'wait', to: 'exit', type: 'continue' },
- ],
- }
-
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
- const branchEdge = edges.find((e) => e.source === 'wait' && e.sourceHandle?.includes('branch_wait_0'))
-
- expect(branchEdge?.data?.label).toBe('If condition matches')
- })
-
- it('should use custom names for random_cohort_branch when provided', () => {
- const mockFlow: HogFlow = {
- ...createMockHogFlow(),
- actions: [
- {
- id: 'trigger',
- name: 'Trigger',
- description: '',
- type: 'trigger',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- type: 'event',
- filters: {},
- },
- },
- {
- id: 'cohort',
- name: 'Random Cohort',
- description: '',
- type: 'random_cohort_branch',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- cohorts: [
- { percentage: 50, name: 'Control group' },
- { percentage: 50, name: 'Test group' },
- ],
- },
- },
- {
- id: 'exit',
- name: 'Exit',
- description: '',
- type: 'exit',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: { reason: '' },
- },
- ],
- edges: [
- { from: 'trigger', to: 'cohort', type: 'continue' },
- { from: 'cohort', to: 'exit', type: 'branch', index: 0 },
- { from: 'cohort', to: 'exit', type: 'branch', index: 1 },
- ],
- }
-
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
- const branchEdge0 = edges.find((e) => e.source === 'cohort' && e.sourceHandle?.includes('branch_cohort_0'))
- const branchEdge1 = edges.find((e) => e.source === 'cohort' && e.sourceHandle?.includes('branch_cohort_1'))
-
- expect(branchEdge0?.data?.label).toBe('Control group')
- expect(branchEdge1?.data?.label).toBe('Test group')
- })
-
- it('should handle random_cohort_branch edge labels without custom names', () => {
- const mockFlow: HogFlow = {
- ...createMockHogFlow(),
- actions: [
- {
- id: 'trigger',
- name: 'Trigger',
- description: '',
- type: 'trigger',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- type: 'event',
- filters: {},
- },
- },
- {
- id: 'cohort',
- name: 'Random Cohort',
- description: '',
- type: 'random_cohort_branch',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: {
- cohorts: [{ percentage: 50 }, { percentage: 50 }],
- },
- },
- {
- id: 'exit',
- name: 'Exit',
- description: '',
- type: 'exit',
- created_at: Date.now(),
- updated_at: Date.now(),
- config: { reason: '' },
- },
- ],
- edges: [
- { from: 'trigger', to: 'cohort', type: 'continue' },
- { from: 'cohort', to: 'exit', type: 'branch', index: 0 },
- { from: 'cohort', to: 'exit', type: 'branch', index: 1 },
- ],
- }
-
- logic.actions.resetFlowFromHogFlow(mockFlow)
-
- const edges = logic.values.edges
- const branchEdge0 = edges.find((e) => e.source === 'cohort' && e.sourceHandle?.includes('branch_cohort_0'))
- const branchEdge1 = edges.find((e) => e.source === 'cohort' && e.sourceHandle?.includes('branch_cohort_1'))
-
- expect(branchEdge0?.data?.label).toBe('If cohort #1 matches')
- expect(branchEdge1?.data?.label).toBe('If cohort #2 matches')
- })
- })
-
- describe('legacy graph layout under the tile canvas', () => {
- const delay: HogFlowAction = {
- id: 'delay',
- name: 'Delay',
- description: '',
- type: 'delay',
- created_at: 0,
- updated_at: 0,
- config: { delay_duration: '1d' },
- }
-
- it.each([
- {
- name: 'skips the layout while the tile canvas shows',
- flags: [FEATURE_FLAGS.WORKFLOWS_TILE_CANVAS],
- laysOut: false,
- },
- { name: 'lays out the graph editor', flags: [], laysOut: true },
- ])('$name, and keeps the steps the canvas reads', async ({ flags, laysOut }) => {
- featureFlagLogic.actions.setFeatureFlags(flags, Object.fromEntries(flags.map((flag) => [flag, true])))
- const editorLogic = hogFlowEditorLogic()
- editorLogic.mount()
- await expectLogic(editorLogic).toFinishAllListeners()
- const layout = jest.spyOn(autolayout, 'getFormattedNodes')
-
- await expectLogic(editorLogic, () =>
- 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')],
- })
- ).toFinishAllListeners()
-
- expect(layout.mock.calls.length > 0).toBe(laysOut)
- expect(editorLogic.values.nodes.map((node) => node.id)).toEqual([TRIGGER_NODE_ID, delay.id, EXIT_NODE_ID])
- layout.mockRestore()
- })
- })
-
describe('graph identity across rebuilds', () => {
// Auto-save round-trips rebuild the graph from the workflow; without id-based
// reconciliation every node and edge object is recreated each time and every ReactFlow
@@ -803,7 +391,6 @@ describe('hogFlowEditorLogic', () => {
type: 'action',
data: { id, type: 'exit', name: id, description: '', config: {} } as unknown as HogFlowAction,
position: { x: 0, y: 0 },
- handles: [],
}) as HogFlowActionNode
const makeEdge = (
@@ -815,9 +402,6 @@ describe('hogFlowEditorLogic', () => {
id: `${from}->${to} ${type} ${index ?? ''}`.trim(),
source: from,
target: to,
- type: 'smart',
- sourceHandle: type === 'continue' ? `continue_${from}` : `branch_${from}_${index}`,
- targetHandle: `target_${to}`,
data: { edge: { from, to, type, index } },
})
@@ -864,75 +448,4 @@ describe('hogFlowEditorLogic', () => {
expect(branchJoinDropzones()).toEqual(expected)
})
})
-
- describe('graph layout', () => {
- const step = (id: string, type: HogFlowAction['type'], conditions = 0): HogFlowAction =>
- ({
- id,
- type,
- name: id,
- description: '',
- created_at: 1,
- updated_at: 1,
- config:
- type === 'conditional_branch'
- ? { conditions: Array.from({ length: conditions }, () => ({ filters: {} })) }
- : type === 'delay'
- ? { delay_duration: '1d' }
- : {},
- }) as HogFlowAction
-
- const xOf = (id: string): number => {
- const node = logic.values.nodes.find((candidate) => candidate.id === id)
- if (!node) {
- throw new Error(`node ${id} was not laid out`)
- }
- return node.position.x
- }
-
- beforeEach(async () => {
- await expectLogic(logic).toDispatchActions(['setNodesRaw'])
- })
-
- it('keeps each branch on its own side after a step is added above a nested condition', async () => {
- const flow: HogFlow = {
- ...NEW_WORKFLOW,
- actions: [
- step('trigger', 'trigger'),
- step('route', 'conditional_branch', 1),
- step('added', 'delay'),
- step('choose', 'conditional_branch', 2),
- step('first', 'delay'),
- step('second', 'delay'),
- step('second_followup', 'delay'),
- step('wait', 'conditional_branch', 1),
- step('follow_up', 'delay'),
- step('outcome', 'delay'),
- step('exit', 'exit'),
- ],
- edges: [
- edge('trigger', 'route', 'continue'),
- edge('route', 'added', 'branch', 0),
- edge('added', 'choose', 'continue'),
- edge('choose', 'first', 'branch', 0),
- edge('first', 'exit', 'continue'),
- edge('choose', 'second', 'branch', 1),
- edge('second', 'second_followup', 'continue'),
- edge('second_followup', 'exit', 'continue'),
- edge('choose', 'exit', 'continue'),
- edge('route', 'wait', 'branch', 1),
- edge('wait', 'outcome', 'branch', 0),
- edge('wait', 'follow_up', 'continue'),
- edge('follow_up', 'outcome', 'continue'),
- edge('outcome', 'exit', 'continue'),
- edge('route', 'exit', 'continue'),
- ],
- }
-
- await expectLogic(logic, () => logic.actions.resetFlowFromHogFlow(flow)).toDispatchActions(['setNodesRaw'])
-
- expect(xOf('added')).toBeLessThan(xOf('wait'))
- expect(xOf('first')).toBeLessThan(xOf('second'))
- })
- })
})
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
index 6df2004cb414..e0c60927506a 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
@@ -1,32 +1,14 @@
-import {
- Edge,
- EdgeChange,
- MarkerType,
- Node,
- NodeChange,
- Position,
- ReactFlowInstance,
- applyEdgeChanges,
- applyNodeChanges,
- getOutgoers,
-} from '@xyflow/react'
+import { getOutgoers } from '@xyflow/react'
import { MakeLogicType, actions, connect, events, kea, key, listeners, path, props, reducers, selectors } from 'kea'
-import { loaders } from 'kea-loaders'
import { router, urlToAction } from 'kea-router'
import { subscriptions } from 'kea-subscriptions'
import posthog from 'posthog-js'
-import type { DragEvent, RefObject } from 'react'
+import type { DragEvent } from 'react'
import { lemonToast } from '@posthog/lemon-ui'
-import {
- AppMetricsTotalsRequest,
- AppMetricsTotalsResponse,
- loadAppMetricsTotals,
-} from 'lib/components/AppMetrics/appMetricsLogic'
-import { FEATURE_FLAGS } from 'lib/constants'
+import { AppMetricsTotalsResponse } from 'lib/components/AppMetrics/appMetricsLogic'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
-import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
import { uuid } from 'lib/utils/dom'
import { objectsEqual, reconcileById } from 'lib/utils/objects'
@@ -46,21 +28,11 @@ import { optOutCategoriesLogic } from '../../OptOuts/optOutCategoriesLogic'
import type { MessageCategory } from '../../OptOuts/optOutCategoriesLogic'
import { EXIT_NODE_ID, TRIGGER_NODE_ID, WorkflowLogicProps, workflowLogic } from '../workflowLogic'
import { getEdgeId } from './edgeId'
-import { getFormattedNodes } from './react_flow_utils/autolayout'
-import {
- BOTTOM_HANDLE_POSITION,
- MAX_ZOOM,
- MIN_ZOOM,
- NODE_HEIGHT,
- NODE_WIDTH,
- TOP_HANDLE_POSITION,
-} from './react_flow_utils/constants'
-import { getSmartStepPath } from './react_flow_utils/SmartEdge'
import { getTeamUtmDefaults, newEmailUtmConfig, utmKeysFollowingSavedDefault } from './steps/components/utmDefaults'
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 { CyclotronInputType } from './steps/types'
import type { DropzoneNode, HogFlow, HogFlowAction, HogFlowActionEdge, HogFlowActionNode } from './types'
import type { HogFlowEdge } from './types'
@@ -98,32 +70,6 @@ export function computeInsertEdges(
/**
* Helper to get branch label with custom name fallback
*/
-const getBranchLabel = (action: HogFlowAction | undefined, edge: HogFlow['edges'][0]): string => {
- if (!action) {
- return `If condition #${(edge.index || 0) + 1} matches`
- }
-
- switch (action.type) {
- case 'wait_until_condition': {
- const waitAction = action as Extract<HogFlowAction, { type: 'wait_until_condition' }>
- const customName = waitAction.config.condition?.name
- return customName || 'If condition matches'
- }
- case 'random_cohort_branch': {
- const cohortAction = action as Extract<HogFlowAction, { type: 'random_cohort_branch' }>
- const cohort = cohortAction.config.cohorts?.[edge.index || 0]
- return cohort?.name || `If cohort #${(edge.index || 0) + 1} matches`
- }
- case 'conditional_branch': {
- const branchAction = action as Extract<HogFlowAction, { type: 'conditional_branch' }>
- const condition = branchAction.config.conditions?.[edge.index || 0]
- return condition?.name || `If condition #${(edge.index || 0) + 1} matches`
- }
- default:
- return `If condition #${(edge.index || 0) + 1} matches`
- }
-}
-
/**
* Computes the new edges after moving a node to a new position in the graph.
* Extracted into pure function to be easier to test.
@@ -274,7 +220,6 @@ export type CreateActionType = Pick<HogFlowAction, 'type' | 'config' | 'name' |
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface hogFlowEditorLogicValues {
- featureFlags: FeatureFlagsSet // featureFlagLogic
integrations: IntegrationType[] | null // integrationsLogic
categories: MessageCategory[] // optOutCategoriesLogic
categoriesLoading: boolean // optOutCategoriesLogic
@@ -282,24 +227,17 @@ export interface hogFlowEditorLogicValues {
edgesByActionId: Record<string, HogFlowEdge[]> // workflowLogic
hogFunctionTemplatesById: Record<string, HogFunctionTemplateType> // workflowLogic
workflow: HogFlow // workflowLogic
- actionMetricsById: Record<string, HogFlowEditorActionMetrics> | null
- actionMetricsByIdLoading: boolean
- animatingEdgePair: string | null
dropzoneNodes: DropzoneNode[]
edges: HogFlowActionEdge[]
highlightedDropzoneNodeId: string | null
isCopyingNode: boolean
isMovingNode: boolean
- isTileCanvas: boolean
- isZoomedOutFar: boolean
mode: HogFlowEditorMode
movingNodeId: string | null
nodeToBeAdded: CreateActionType | HogFlowActionNode | null
nodes: HogFlowActionNode[]
nodesById: Record<string, HogFlowActionNode>
panelWidth: number | null
- reactFlowInstance: ReactFlowInstance<Node, Edge> | null
- reactFlowWrapper: RefObject<HTMLDivElement> | null
selectedNode: HogFlowActionNode | null
selectedNodeCanBeCopiedOrMoved: boolean
selectedNodeCanBeDeleted: boolean
@@ -2117,52 +2055,18 @@ export interface hogFlowEditorLogicActions {
setWorkflowInfo: (workflow: Partial<HogFlow>) => {
workflow: Partial<HogFlow>
} // workflowLogic
- clearAnimatingEdgePair: () => {
- value: true
- }
clearPanelWidth: () => {
value: true
}
copyNodeToHighlightedDropzone: () => {
value: true
}
- fitView: (options?: { duration?: number; noZoom?: boolean }) => {
- duration?: number | undefined
- noZoom?: boolean | undefined
- }
handlePaneClick: () => {
value: true
}
hideDropzones: () => {
value: true
}
- loadActionMetricsById: (
- params: Pick<AppMetricsTotalsRequest, 'appSource' | 'appSourceId' | 'dateFrom' | 'dateTo'>,
- timezone: string
- ) => {
- params: Pick<AppMetricsTotalsRequest, 'appSource' | 'appSourceId' | 'dateFrom' | 'dateTo'>
- timezone: string
- }
- loadActionMetricsByIdFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadActionMetricsByIdSuccess: (
- actionMetricsById: Record<string, HogFlowEditorActionMetrics>,
- payload?: {
- params: Pick<AppMetricsTotalsRequest, 'appSource' | 'appSourceId' | 'dateFrom' | 'dateTo'>
- timezone: string
- }
- ) => {
- actionMetricsById: Record<string, HogFlowEditorActionMetrics>
- payload?: {
- params: Pick<AppMetricsTotalsRequest, 'appSource' | 'appSourceId' | 'dateFrom' | 'dateTo'>
- timezone: string
- }
- }
markUtmSavedAsTeamDefault: (
actionId: string,
saved: UtmTagValues
@@ -2196,25 +2100,12 @@ export interface hogFlowEditorLogicActions {
joinEdges: HogFlowEdge[] | undefined
targetEdge: HogFlowEdge | undefined
}
- onEdgesChange: (edges: EdgeChange<HogFlowActionEdge>[]) => {
- edges: EdgeChange<HogFlowActionEdge>[]
- }
- onNodesChange: (nodes: NodeChange<HogFlowActionNode>[]) => {
- nodes: NodeChange<HogFlowActionNode>[]
- }
onNodesDelete: (deleted: HogFlowActionNode[]) => {
deleted: HogFlowActionNode[]
}
resetFlowFromHogFlow: (hogFlow: HogFlow) => {
hogFlow: HogFlow
}
- setAnimatingEdgePair: (
- from: string,
- to: string
- ) => {
- from: string
- to: string
- }
setDropzoneNodes: (dropzoneNodes: DropzoneNode[]) => {
dropzoneNodes: DropzoneNode[]
}
@@ -2224,30 +2115,18 @@ export interface hogFlowEditorLogicActions {
setHighlightedDropzoneNodeId: (highlightedDropzoneNodeId: string | null) => {
highlightedDropzoneNodeId: string | null
}
- setIsZoomedOutFar: (isZoomedOutFar: boolean) => {
- isZoomedOutFar: boolean
- }
setMode: (mode: HogFlowEditorMode) => {
mode: 'build' | 'logs' | 'metrics' | 'test' | 'variables'
}
setNodeToBeAdded: (nodeToBeAdded: CreateActionType | HogFlowActionNode | null) => {
nodeToBeAdded: CreateActionType | HogFlowActionNode | null
}
- setNodes: (nodes: HogFlowActionNode[]) => {
- nodes: HogFlowActionNode[]
- }
setNodesRaw: (nodes: HogFlowActionNode[]) => {
nodes: HogFlowActionNode[]
}
setPanelWidth: (panelWidth: number) => {
panelWidth: number
}
- setReactFlowInstance: (reactFlowInstance: ReactFlowInstance<Node, Edge>) => {
- reactFlowInstance: ReactFlowInstance<Node, Edge>
- }
- setReactFlowWrapper: (reactFlowWrapper: RefObject<HTMLDivElement>) => {
- reactFlowWrapper: RefObject<HTMLDivElement>
- }
setSelectedNodeId: (selectedNodeId: string | null) => {
selectedNodeId: string | null
}
@@ -2272,7 +2151,6 @@ export interface hogFlowEditorLogicActions {
export interface hogFlowEditorLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- isTileCanvas: (featureFlags: FeatureFlagsSet) => boolean
nodesById: (nodes: HogFlowActionNode[]) => Record<string, HogFlowActionNode>
selectedNode: (
nodes: HogFlowActionNode[],
@@ -2312,8 +2190,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
['integrations'],
teamLogic,
['currentTeam'],
- featureFlagLogic,
- ['featureFlags'],
],
actions: [
workflowLogic,
@@ -2323,10 +2199,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
],
})),
actions({
- onEdgesChange: (edges: EdgeChange<HogFlowActionEdge>[]) => ({ edges }),
- onNodesChange: (nodes: NodeChange<HogFlowActionNode>[]) => ({ nodes }),
onNodesDelete: (deleted: HogFlowActionNode[]) => ({ deleted }),
- setNodes: (nodes: HogFlowActionNode[]) => ({ nodes }),
setDropzoneNodes: (dropzoneNodes: DropzoneNode[]) => ({
dropzoneNodes,
}),
@@ -2336,10 +2209,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
setEdges: (edges: HogFlowActionEdge[]) => ({ edges }),
setSelectedNodeId: (selectedNodeId: string | null) => ({ selectedNodeId }),
resetFlowFromHogFlow: (hogFlow: HogFlow) => ({ hogFlow }),
- setReactFlowInstance: (reactFlowInstance: ReactFlowInstance<Node, Edge>) => ({
- reactFlowInstance,
- }),
- setReactFlowWrapper: (reactFlowWrapper: RefObject<HTMLDivElement>) => ({ reactFlowWrapper }),
onDragOver: (event: DragEvent) => ({ event }),
onDrop: (event?: DragEvent, targetEdge?: HogFlowEdge, joinEdges?: HogFlowEdge[]) => ({
event,
@@ -2351,8 +2220,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
setMode: (mode: HogFlowEditorMode) => ({ mode }),
setPanelWidth: (panelWidth: number) => ({ panelWidth }),
clearPanelWidth: true,
- setAnimatingEdgePair: (from: string, to: string) => ({ from, to }),
- clearAnimatingEdgePair: true,
startCopyingNode: (node: HogFlowActionNode) => ({ node }),
stopCopyingNode: true,
copyNodeToHighlightedDropzone: true,
@@ -2371,13 +2238,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
joinEdges,
}),
markUtmSavedAsTeamDefault: (actionId: string, saved: UtmTagValues) => ({ actionId, saved }),
- loadActionMetricsById: (
- params: Pick<AppMetricsTotalsRequest, 'appSource' | 'appSourceId' | 'dateFrom' | 'dateTo'>,
- timezone: string
- ) => ({ params, timezone }),
- fitView: (options: { duration?: number; noZoom?: boolean } = {}) => options,
handlePaneClick: true,
- setIsZoomedOutFar: (isZoomedOutFar: boolean) => ({ isZoomedOutFar }),
}),
reducers(() => ({
mode: [
@@ -2438,12 +2299,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
stopMovingNode: () => false,
},
],
- isZoomedOutFar: [
- false,
- {
- setIsZoomedOutFar: (_, { isZoomedOutFar }) => isZoomedOutFar,
- },
- ],
movingNodeId: [
null as string | null,
{
@@ -2458,35 +2313,9 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
startCopyingNode: (_, { node }) => node.data,
},
],
- reactFlowInstance: [
- null as ReactFlowInstance<Node, Edge> | null,
- {
- setReactFlowInstance: (_, { reactFlowInstance }) => reactFlowInstance,
- },
- ],
- reactFlowWrapper: [
- null as RefObject<HTMLDivElement> | null,
- {
- setReactFlowWrapper: (_, { reactFlowWrapper }) => reactFlowWrapper,
- },
- ],
- animatingEdgePair: [
- null as string | null,
- {
- setAnimatingEdgePair: (_: string | null, { from, to }: { from: string; to: string }) =>
- `${from}->${to}`,
- clearAnimatingEdgePair: () => null,
- setMode: () => null,
- },
- ],
})),
selectors({
- /** The tile canvas replaces the graph view. */
- isTileCanvas: [
- (s) => [s.featureFlags],
- (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.WORKFLOWS_TILE_CANVAS],
- ],
nodesById: [
(s) => [s.nodes],
(nodes: HogFlowActionNode[]): Record<string, HogFlowActionNode> => {
@@ -2552,111 +2381,16 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
},
],
}),
- loaders(() => ({
- actionMetricsById: [
- null as Record<string, HogFlowEditorActionMetrics> | null,
- {
- loadActionMetricsById: async ({ params, timezone }, breakpoint) => {
- await breakpoint(10)
- const _params: AppMetricsTotalsRequest = {
- ...params,
- breakdownBy: ['instance_id', 'metric_name'],
- metricName: ['succeeded', 'failed', 'rate_limited', 'triggered'],
- }
- const response = await loadAppMetricsTotals(_params, timezone)
- await breakpoint(10)
-
- return actionMetricsFromTotals(response)
- },
- },
- ],
- })),
listeners(({ values, actions }) => {
- let animationTimeout: ReturnType<typeof setTimeout> | null = null
return {
- onEdgesChange: ({ edges }) => {
- actions.setEdges(applyEdgeChanges(edges, values.edges))
- },
- onNodesChange: ({ nodes }) => {
- actions.setNodes(applyNodeChanges(nodes, values.nodes))
- },
- setAnimatingEdgePair: () => {
- if (animationTimeout) {
- clearTimeout(animationTimeout)
- }
- animationTimeout = setTimeout(() => {
- animationTimeout = null
- actions.clearAnimatingEdgePair()
- }, 1500)
- },
-
resetFlowFromHogFlow: ({ hogFlow }) => {
try {
- const edgeCountBySource = new Map<string, number>()
- hogFlow.edges.forEach((edge) =>
- edgeCountBySource.set(edge.from, (edgeCountBySource.get(edge.from) ?? 0) + 1)
- )
- const actionsById = new Map(hogFlow.actions.map((action) => [action.id, action]))
- const edges: HogFlowActionEdge[] = hogFlow.edges.map((edge) => {
- const isOnlyEdgeForNode = edgeCountBySource.get(edge.from) === 1
- const edgeSourceAction = actionsById.get(edge.from)
-
- return {
- // Only these values are set by the user
- source: edge.from,
- target: edge.to,
-
- // All other values are derived
- id: getEdgeId(edge),
- type: 'smart',
- deletable: false,
- reconnectable: false,
- selectable: false,
- focusable: false,
- markerEnd: {
- type: MarkerType.ArrowClosed,
- },
- data: {
- edge,
- label: isOnlyEdgeForNode
- ? undefined
- : edge.type === 'continue'
- ? `No match`
- : getBranchLabel(edgeSourceAction, edge),
- },
- labelShowBg: false,
- targetHandle: `target_${edge.to}`,
- sourceHandle:
- edge.type === 'continue'
- ? `continue_${edge.from}`
- : `branch_${edge.from}_${edge.index}`,
- }
- })
-
- const handlesByIdByNodeId: Record<string, Record<string, StepViewNodeHandle>> = {}
-
- edges.forEach((edge) => {
- if (!handlesByIdByNodeId[edge.source]) {
- handlesByIdByNodeId[edge.source] = {}
- }
- if (!handlesByIdByNodeId[edge.target]) {
- handlesByIdByNodeId[edge.target] = {}
- }
-
- handlesByIdByNodeId[edge.source][edge.sourceHandle ?? ''] = {
- id: edge.sourceHandle,
- type: 'source',
- position: Position.Bottom,
- ...BOTTOM_HANDLE_POSITION,
- }
-
- handlesByIdByNodeId[edge.target][edge.targetHandle ?? ''] = {
- id: edge.targetHandle,
- type: 'target',
- position: Position.Top,
- ...TOP_HANDLE_POSITION,
- }
- })
+ const edges: HogFlowActionEdge[] = hogFlow.edges.map((edge) => ({
+ id: getEdgeId(edge),
+ source: edge.from,
+ target: edge.to,
+ data: { edge },
+ }))
const nodes: HogFlowActionNode[] = hogFlow.actions.map((action: HogFlowAction) => {
const step = getHogFlowStep(action, values.hogFunctionTemplatesById)
@@ -2675,7 +2409,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
type: 'action',
data: migratedAction,
position: { x: 0, y: 0 },
- handles: Object.values(handlesByIdByNodeId[migratedAction.id] ?? {}),
deletable: !['trigger', 'exit'].includes(migratedAction.type),
selectable: true,
draggable: false,
@@ -2683,29 +2416,15 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
}
})
- // Reuse unchanged edge references so ReactFlow only reprocesses edges that
- // actually changed (matching its own applyEdgeChanges contract).
+ // Keep unchanged references so a save round trip doesn't re-render every step.
actions.setEdges(reconcileById(values.edges, edges, (edge) => edge.id))
- actions.setNodes(nodes)
+ actions.setNodesRaw(reconcileById(values.nodes, nodes, (node) => node.id))
} catch (error) {
console.error('Error resetting flow from hog flow', error)
lemonToast.error('Error updating workflow')
}
},
- setNodes: async ({ nodes }, breakpoint) => {
- // The tile canvas lays out its own tiles and reads only the steps and edges, so skip ELK under it.
- const formattedNodes = values.isTileCanvas ? nodes : await getFormattedNodes(nodes, values.edges)
- // Drop this layout run if a newer setNodes was dispatched while elk was working,
- // so overlapping rebuilds can't finish out of order and let a stale layout win.
- breakpoint()
-
- // Reconcile after layout so positions participate in the equality check: a node
- // that moved gets a fresh reference, an untouched one keeps its identity and its
- // ReactFlow subtree doesn't re-render.
- actions.setNodesRaw(reconcileById(values.nodes, formattedNodes, (node) => node.id))
- },
-
onNodesDelete: ({ deleted }) => {
if (deleted.some((node) => node.id === values.selectedNodeId)) {
actions.setSelectedNodeId(null)
@@ -2720,7 +2439,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
// Find the deleted node
const deletedNode = deleted.find((node) => node.id === hogFlowEdge.to)
if (deletedNode) {
- // The React Flow layout may still be pending, so rewire from the canonical workflow.
const outgoer = values.workflow.edges.find((edge) => edge.from === deletedNode.id)
if (outgoer) {
// Change target to the first outgoer
@@ -2771,25 +2489,10 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
const targetNode = nodesById[edge.target]
if (sourceNode && targetNode) {
- const sourceHandle = sourceNode.handles?.find((h) => h.id === edge.sourceHandle)
- const targetHandle = targetNode.handles?.find((h) => h.id === edge.targetHandle)
-
- // The tile canvas finds a dropzone by its edge and draws its own +, so it needs no position.
- const [, labelX, labelY] = values.isTileCanvas
- ? [undefined, 0, 0]
- : getSmartStepPath({
- sourceX: sourceNode.position.x + (sourceHandle?.x || 0),
- sourceY: sourceNode.position.y + (sourceHandle?.y || 0),
- targetX: targetNode.position.x + (targetHandle?.x || 0),
- targetY: targetNode.position.y + (targetHandle?.y || 0),
- edges,
- currentEdgeId: edge.id,
- })
-
dropzoneNodes.push({
id: `dropzone_edge_${edge.id}`,
type: 'dropzone',
- position: { x: labelX - NODE_WIDTH / 2, y: labelY - NODE_HEIGHT / 2 },
+ position: { x: 0, y: 0 },
data: {
edge,
},
@@ -2813,10 +2516,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
dropzoneNodes.push({
id: branchJoinDropzoneTargetId,
type: 'dropzone',
- position: {
- x: targetNode.position.x,
- y: targetNode.position.y - NODE_HEIGHT,
- },
+ position: { x: 0, y: 0 },
data: {
edge,
isBranchJoinDropzone: true,
@@ -3047,57 +2747,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
// We can clear the dropzones now
actions.hideDropzones()
},
- setReactFlowInstance: () => {
- // TRICKY: Slight race condition here where the react flow instance is not set yet
- setTimeout(() => {
- actions.fitView({ duration: 0 })
- }, 100)
- },
- setSelectedNodeId: ({ selectedNodeId }) => {
- if (selectedNodeId) {
- actions.fitView({ noZoom: true })
- }
- },
- fitView: ({ duration, noZoom }) => {
- const { reactFlowWrapper, reactFlowInstance } = values
- if (!reactFlowWrapper?.current || !reactFlowInstance) {
- return
- }
- const wrapperRect = reactFlowWrapper.current.getBoundingClientRect()
- const wrapperWidth = wrapperRect?.width ?? 0
- const wrapperHeight = wrapperRect?.height ?? 0
- const panel = reactFlowWrapper.current.parentElement?.querySelector<HTMLElement>(
- '[data-attr="workflow-editor-panel"]'
- )
- const panelWidth =
- panel && getComputedStyle(panel).position === 'absolute'
- ? Math.min(panel.getBoundingClientRect().width, wrapperWidth)
- : 0
- const nodesToFit = values.selectedNode ? [values.selectedNode] : values.nodes
- const nodesBounds = reactFlowInstance.getNodesBounds(nodesToFit)
- const visibleWidth = wrapperWidth - panelWidth
- // Size the padding for the zoom this fit lands on. With the current zoom each fit depends
- // on the previous one, so the resize observer and the mount timeout leave a different
- // viewport depending on how often they fire. fitView clamps its zoom to the instance limits,
- // so clamp here too, or a small workflow gets padding for a zoom it never reaches.
- const unclampedFitZoom = Math.min(visibleWidth / nodesBounds.width, wrapperHeight / nodesBounds.height)
- const fitZoom =
- noZoom || !nodesBounds.width || !nodesBounds.height
- ? reactFlowInstance.getZoom()
- : Math.min(Math.max(unclampedFitZoom, MIN_ZOOM), MAX_ZOOM)
- const nodesWidthAdjusted = nodesBounds.width * fitZoom
- // Calculate the padding right to fit the panel width to the wrapper width
- // Looks complicated but its basically the difference between the wrapper width and the nodes width adjusted for the zoom factor
- const paddingRight = wrapperWidth - nodesWidthAdjusted / 2 - (wrapperWidth - panelWidth) / 2
-
- reactFlowInstance.fitView({
- padding: panelWidth > 0 ? { right: `${paddingRight}px` } : 0.2,
- maxZoom: noZoom ? reactFlowInstance.getZoom() : undefined,
- minZoom: noZoom ? reactFlowInstance.getZoom() : undefined,
- nodes: nodesToFit,
- duration: duration ?? 100,
- })
- },
startCopyingNode: () => {
actions.showDropzones()
},
@@ -3122,10 +2771,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
actions.hideDropzones()
},
moveNodeToHighlightedDropzone: () => {
- // Uses computeMoveEdges (pure function) to manipulate edges in a single
- // setWorkflowInfo call rather than onNodesDelete + onDrop (like copy does).
- // This preserves node identity and avoids a race condition where two async
- // layout computations from separate setWorkflowInfo calls complete out of order.
+ // Changes the edges in one setWorkflowInfo call, unlike copy, so the step keeps its identity.
const movingNodeId = values.movingNodeId!
const dropzoneNode = values.dropzoneNodes.find((x) => x.id === values.highlightedDropzoneNodeId)
if (!dropzoneNode) {
@@ -3191,16 +2837,10 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
}
}),
- subscriptions(({ actions, values }) => ({
- isTileCanvas: (isTileCanvas: boolean, wasTileCanvas: boolean | undefined) => {
- // Leaving the tile canvas needs the positions it skipped.
- if (wasTileCanvas && !isTileCanvas) {
- actions.resetFlowFromHogFlow(values.workflow)
- }
- },
+ subscriptions(({ actions }) => ({
workflow: (hogFlow?: HogFlow, oldHogFlow?: HogFlow) => {
// 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.
+ // re-deriving every node and edge for no change.
if (hogFlow && !objectsEqual(hogFlow, oldHogFlow)) {
actions.resetFlowFromHogFlow(hogFlow)
}
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx
index f22390d93722..e2af321031d1 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx
@@ -234,7 +234,8 @@ function PanelStory({ mode, selectedNodeId }: PanelStoryProps): JSX.Element {
<ReactFlowProvider>
<BindLogic logic={workflowLogic} props={LOGIC_PROPS}>
<BindLogic logic={hogFlowEditorLogic} props={LOGIC_PROPS}>
- <div className="relative h-screen w-[37rem] overflow-hidden bg-surface-primary">
+ <div className="@container/workflow-editor relative flex h-screen overflow-hidden">
+ <div className="min-w-0 flex-1 bg-background" />
<HogFlowEditorPanel />
</div>
</BindLogic>
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
index 0f92d846bccf..aa20f89edf44 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
@@ -1,4 +1,3 @@
-import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { IconArrowLeft, IconX } from '@posthog/icons'
@@ -23,16 +22,11 @@ import { EmailActionTestContent } from './testing/HogFlowEditorNotificationPanel
import { HogFlowEditorPanelTest } from './testing/HogFlowEditorPanelTest'
export interface HogFlowEditorPanelProps {
- layout?: 'floating' | 'docked'
onClose?: () => void
view?: { title: string; content: JSX.Element }
}
-export function HogFlowEditorPanel({
- layout = 'floating',
- onClose,
- view,
-}: HogFlowEditorPanelProps = {}): JSX.Element | null {
+export function HogFlowEditorPanel({ onClose, view }: HogFlowEditorPanelProps = {}): JSX.Element | null {
const { panelWidth, selectedNode, mode, workflow } = useValues(hogFlowEditorLogic)
const { clearPanelWidth, setMode, setPanelWidth, setSelectedNodeId } = useActions(hogFlowEditorLogic)
@@ -56,36 +50,23 @@ export function HogFlowEditorPanel({
),
key: mode,
}))
- // A docked panel is too narrow for every tab, and Variables has its own button beside the canvas.
- const shownTabs = layout === 'docked' ? tabs.filter((tab) => tab.key !== 'variables') : tabs
+ // The panel is too narrow for every tab, and Variables has its own button beside the canvas.
+ const shownTabs = tabs.filter((tab) => tab.key !== 'variables')
const title = view?.title ?? (shownTabs.some((tab) => tab.key === mode) ? null : capitalizeFirstLetter(mode))
return (
<div
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 === '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'
- )}
+ className="relative flex h-full min-h-0 max-h-full min-w-80 max-w-[calc(100%-30rem)] shrink-0 flex-col justify-end overflow-hidden border-l bg-surface-primary @max-[48rem]/workflow-editor:!relative @max-[48rem]/workflow-editor:!h-1/2 @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 @max-[48rem]/workflow-editor:border-t @max-[48rem]/workflow-editor:border-l-0"
style={{ width }}
>
<HogFlowEditorPanelResizeHandle width={width} onResize={setPanelWidth} onReset={clearPanelWidth} />
- <div
- className={clsx(
- 'relative z-10 flex min-h-0 flex-col overflow-hidden bg-surface-primary',
- layout === 'floating'
- ? 'max-h-full rounded-md border shadow-[0_3px_0_var(--border)] @max-[48rem]/workflow-editor:h-full'
- : 'h-full !rounded-none'
- )}
- >
+ <div className="relative z-10 flex h-full min-h-0 flex-col overflow-hidden !rounded-none bg-surface-primary">
<div className="flex shrink-0 items-center gap-2 border-b">
<div
- className={clsx(
- 'transition-all overflow-hidden flex p-1',
+ className={`transition-all overflow-hidden flex p-1 ${
!selectedNode ? 'w-2 opacity-0' : 'w-10 opacity-100'
- )}
+ }`}
>
<LemonButton
aria-label="Back to steps"
@@ -104,7 +85,7 @@ export function HogFlowEditorPanel({
activeKey={mode}
onChange={(key) => setMode(key)}
tabs={shownTabs}
- size={layout === 'docked' ? 'small' : undefined}
+ size="small"
barClassName="-mb-px "
/>
)}
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
index 6d02f59f0fe5..83822d200b8f 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
@@ -12,9 +12,8 @@ import { teamLogic } from 'scenes/teamLogic'
import { HogFunctionTemplateType } from '~/types'
import { workflowLogic } from '../../workflowLogic'
-import { setHogFlowDragImage } from '../dragPreview'
+import { NODE_HEIGHT, NODE_WIDTH, setHogFlowDragImage } from '../dragPreview'
import { CreateActionType, hogFlowEditorLogic } from '../hogFlowEditorLogic'
-import { StepView } from '../steps/components/StepView'
import { useHogFlowStep } from '../steps/HogFlowSteps'
import { HogFlowAction } from '../types'
import { destinationStep, isBetaStep, isPickableDestination, workflowStepSections } from '../workflowStepCatalog'
@@ -69,9 +68,15 @@ function HogFlowEditorToolbarNode({
{!onActionSelect && (
<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.type}-${action.name}` } as HogFlowAction}
- />
+ <div
+ className="flex items-center gap-1 rounded border bg-surface-primary p-1 text-xxs font-medium"
+ style={{ width: NODE_WIDTH, height: NODE_HEIGHT }}
+ >
+ <span className="shrink-0" style={{ color: step.color }}>
+ {step.icon}
+ </span>
+ <span className="truncate">{action.name}</span>
+ </div>
</div>
</div>
)}
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelMetrics.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelMetrics.tsx
index 08cbf10f2e9a..0dc3769f8e01 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelMetrics.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelMetrics.tsx
@@ -1,5 +1,5 @@
-import { useActions, useValues } from 'kea'
-import { useEffect, useMemo } from 'react'
+import { useValues } from 'kea'
+import { useMemo } from 'react'
import { LemonButton, SpinnerOverlay } from '@posthog/lemon-ui'
@@ -19,7 +19,6 @@ import { hogFlowEditorLogic } from '../hogFlowEditorLogic'
export function HogFlowEditorPanelMetrics(): JSX.Element | null {
const { selectedNode, workflow } = useValues(hogFlowEditorLogic)
- const { loadActionMetricsById } = useActions(hogFlowEditorLogic)
const actionId = selectedNode?.data.id
const id = useMemo(() => {
return actionId ? ([TRIGGER_NODE_ID, EXIT_NODE_ID].includes(actionId) ? '' : actionId) : undefined
@@ -58,7 +57,7 @@ export function HogFlowEditorPanelMetrics(): JSX.Element | null {
},
})
- const { appMetricsTrendsLoading, appMetricsTrends, params, currentTeam, getDateRangeAbsolute } = useValues(logic)
+ const { appMetricsTrendsLoading, appMetricsTrends } = useValues(logic)
const seriesOverrides = useMemo(() => {
if (!appMetricsTrends) {
@@ -75,31 +74,6 @@ export function HogFlowEditorPanelMetrics(): JSX.Element | null {
)
}, [appMetricsTrends, isEmailAction, isPushAction])
- useEffect(() => {
- if (!shouldShowActionLevelMetrics) {
- return
- }
- // Bit hacky - we load the values here from the logic as connecting the logics together was weirdly tricky
- loadActionMetricsById(
- {
- appSource: params.appSource,
- appSourceId: params.appSourceId,
- dateFrom: getDateRangeAbsolute().dateFrom.toISOString(),
- dateTo: getDateRangeAbsolute().dateTo.toISOString(),
- },
- currentTeam?.timezone ?? 'UTC'
- )
- }, [
- shouldShowActionLevelMetrics,
- params.appSource,
- params.appSourceId,
- params.dateFrom,
- params.dateTo,
- currentTeam?.timezone,
- loadActionMetricsById,
- getDateRangeAbsolute,
- ])
-
return (
<>
<div className="border-b">
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/hogFlowOutputMappingLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/panel/hogFlowOutputMappingLogic.test.ts
index 2220f5d77c11..b480ef3441d7 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/hogFlowOutputMappingLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/hogFlowOutputMappingLogic.test.ts
@@ -490,10 +490,9 @@ describe('hogFlowOutputMappingLogic', () => {
describe('setMappingVariable', () => {
it('creates the workflow variable when the name is new, then maps and persists it', async () => {
const node = makeActionNode('action-new-var')
- await expectLogic(editorLogic, () => {
- editorLogic.actions.setNodesRaw([node])
- editorLogic.actions.setSelectedNodeId('action-new-var')
- }).toMatchValues({ selectedNode: node })
+ // Saving the new variable rebuilds the nodes from the workflow, so the step must be in it.
+ wfLogic.actions.setWorkflowInfo({ actions: [node.data] })
+ editorLogic.actions.setSelectedNodeId('action-new-var')
logic.actions.initMappings([{ key: '', result_path: 'output.verdict' }])
await expectLogic(logic, () => {
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
index 9aa3b6b28c5a..755d3dbe7e82 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
@@ -201,13 +201,6 @@ export interface hogFlowEditorTestLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface hogFlowEditorTestLogicActions {
- setAnimatingEdgePair: (
- from: string,
- to: string
- ) => {
- from: string
- to: string
- } // hogFlowEditorLogic
setSelectedNodeId: (selectedNodeId: string | null) => {
selectedNodeId: string | null
} // hogFlowEditorLogic
@@ -1063,7 +1056,7 @@ export const hogFlowEditorTestLogic = kea<hogFlowEditorTestLogicType>([
teamLogic,
['currentTeam'],
],
- actions: [hogFlowEditorLogic, ['setSelectedNodeId', 'setAnimatingEdgePair']],
+ actions: [hogFlowEditorLogic, ['setSelectedNodeId']],
})),
actions({
setTestResult: (testResult: HogflowTestResult | null) => ({ testResult }),
@@ -1565,11 +1558,6 @@ export const hogFlowEditorTestLogic = kea<hogFlowEditorTestLogicType>([
}
actions.markSampleGlobalsStale()
},
- setTestResult: ({ testResult }) => {
- if (testResult?.nextActionId && values.selectedNodeId) {
- actions.setAnimatingEdgePair(values.selectedNodeId, testResult.nextActionId)
- }
- },
loadSampleGlobalsSuccess: () => {
actions.setTestInvocationValue('globals', JSON.stringify(values.sampleGlobals, null, 2))
},
diff --git a/products/workflows/frontend/Workflows/hogflows/react_flow_utils/SmartEdge.tsx b/products/workflows/frontend/Workflows/hogflows/react_flow_utils/SmartEdge.tsx
deleted file mode 100644
index 1bd87d636818..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/react_flow_utils/SmartEdge.tsx
+++ /dev/null
@@ -1,299 +0,0 @@
-import { BaseEdge, Edge, EdgeLabelRenderer, EdgeProps, useEdges } from '@xyflow/react'
-import { useValues } from 'kea'
-import { useEffect, useRef } from 'react'
-
-import { LemonTag } from '@posthog/lemon-ui'
-
-import { hogFlowEditorLogic } from '../hogFlowEditorLogic'
-import { HogFlowEdge } from '../types'
-import { MINIMUM_EDGE_SPACING } from './constants'
-
-// Programmatic function to get smart step path with horizontal branching
-// Handles both edge-to-edge spacing and edge-to-node collision avoidance
-export function getSmartStepPath({
- sourceX,
- sourceY,
- targetX,
- targetY,
- edges,
- currentEdgeId,
- borderRadius = 5,
-}: {
- sourceX: number
- sourceY: number
- targetX: number
- targetY: number
- edges: Edge[]
- currentEdgeId: string
- borderRadius?: number
-}): [string, number, number, number, number] {
- // Calculate smart horizontal offset for this edge
- const calculateHorizontalOffset = (): number => {
- if (!currentEdgeId || edges.length === 0) {
- return 0
- }
-
- // Find the current edge if it exists
- const currentEdge = edges.find((edge) => edge.id === currentEdgeId)
- if (!currentEdge) {
- return 0
- }
-
- // Find edges that share the same source, including the current edge
- const conflictingEdges = edges.filter((edge) => edge.source === currentEdge.source)
-
- // Initialize offset based on edge conflicts
- let horizontalOffset = 0
-
- if (conflictingEdges.length > 0) {
- // Sort edges by source handle position to ensure consistent ordering
- const sortedEdges = conflictingEdges.sort((a, b) => {
- const aEdgeData = a.data!.edge as HogFlowEdge
- const bEdgeData = b.data!.edge as HogFlowEdge
-
- if (aEdgeData.type === 'branch' && bEdgeData.type === 'branch') {
- return (aEdgeData.index || 0) - (bEdgeData.index || 0)
- }
-
- return aEdgeData.type === 'continue' ? 1 : -1
- })
- const edgeIndex = sortedEdges.findIndex((edge) => edge.id === currentEdgeId)
- const totalEdges = sortedEdges.length
-
- // Calculate horizontal offset to distribute edges evenly
- // Center the group around zero offset
- const centerIndex = (totalEdges - 1) / 2
- const offsetMultiplier = edgeIndex - centerIndex
- horizontalOffset = offsetMultiplier * MINIMUM_EDGE_SPACING
- }
-
- return horizontalOffset
- }
-
- const horizontalOffset = calculateHorizontalOffset()
-
- // Define key points for the 5-segment path
- // Ensure adequate spacing between segments, especially for vertically close nodes
- const verticalDistance = targetY - sourceY
-
- // Handle both normal (sourceY < targetY) and inverted (sourceY > targetY) cases
- let segment1EndY, segment3EndY
-
- if (verticalDistance >= 0) {
- // Normal case: source above target
- segment1EndY = sourceY + 10
- segment3EndY = targetY - 10
- } else {
- // Inverted case: source below target - we need to go up then down
- segment1EndY = sourceY - 10
- segment3EndY = targetY + 10
- }
-
- // The x value that the main "usable" (i.e. vertical, droppable, label-able) segment of the path will travel along
- const branchX = sourceX + horizontalOffset
-
- let pathCommands: string[]
-
- const NEGLIGIBLE_DRIFT = 10
-
- // There are 4 types of line segments that can be drawn:
-
- // Case 1: Straight vertical line
- if (Math.abs(sourceX - targetX) < NEGLIGIBLE_DRIFT && horizontalOffset === 0) {
- pathCommands = [`M ${sourceX} ${sourceY}`, `L ${targetX} ${targetY}`]
- }
- // Case 2: L-shaped path that branches outwards and then straight down to target
- else if (Math.abs(targetX - branchX) < NEGLIGIBLE_DRIFT) {
- pathCommands = [
- `M ${sourceX} ${sourceY}`,
- `L ${sourceX} ${segment1EndY - borderRadius}`,
- `Q ${sourceX} ${segment1EndY} ${sourceX + (branchX > sourceX ? borderRadius : -borderRadius)} ${segment1EndY}`,
- `L ${branchX - (branchX > sourceX ? borderRadius : -borderRadius)} ${segment1EndY}`,
- `Q ${branchX} ${segment1EndY} ${branchX} ${segment1EndY + borderRadius}`,
- `L ${targetX} ${targetY}`,
- ]
- }
- // Case 3: Reverse L-shaped path that goes straight down and then branches back inwards to target
- else if (Math.abs(targetX - sourceX) > NEGLIGIBLE_DRIFT && horizontalOffset === 0) {
- pathCommands = [
- `M ${sourceX} ${sourceY}`,
- `L ${sourceX} ${segment3EndY - borderRadius}`,
- `Q ${sourceX} ${segment3EndY} ${sourceX + (targetX > sourceX ? borderRadius : -borderRadius)} ${segment3EndY}`,
- `L ${targetX - (targetX > sourceX ? borderRadius : -borderRadius)} ${segment3EndY}`,
- `Q ${targetX} ${segment3EndY} ${targetX} ${segment3EndY + borderRadius}`,
- `L ${targetX} ${targetY}`,
- ]
- }
- // Case 4: 5-segment path that branches outwards, travels down, then branches back inwards to target
- else {
- pathCommands = [
- `M ${sourceX} ${sourceY}`,
- `L ${sourceX} ${segment1EndY - borderRadius}`,
- `Q ${sourceX} ${segment1EndY} ${sourceX + (branchX > sourceX ? borderRadius : -borderRadius)} ${segment1EndY}`,
- `L ${branchX - (branchX > sourceX ? borderRadius : -borderRadius)} ${segment1EndY}`,
- `Q ${branchX} ${segment1EndY} ${branchX} ${segment1EndY + borderRadius}`,
- `L ${branchX} ${segment3EndY - borderRadius}`,
- `Q ${branchX} ${segment3EndY} ${branchX - (branchX > targetX ? borderRadius : -borderRadius)} ${segment3EndY}`,
- `L ${targetX + (branchX > targetX ? borderRadius : -borderRadius)} ${segment3EndY}`,
- `Q ${targetX} ${segment3EndY} ${targetX} ${segment3EndY + borderRadius}`,
- `L ${targetX} ${targetY}`,
- ]
- }
- const svgPath = pathCommands.join(' ')
-
- // Calculate label position (middle of the branched section)
- const labelX = branchX
- const labelY = segment1EndY + (segment3EndY - segment1EndY) / 2
-
- // Calculate offsets
- const offsetX = Math.abs(labelX - sourceX)
- const offsetY = Math.abs(labelY - sourceY)
-
- return [svgPath, labelX, labelY, offsetX, offsetY]
-}
-
-function EdgeLabel({ transform, label }: { transform: string; label: string }): JSX.Element {
- return (
- <LemonTag
- style={{
- transform,
- }}
- size="small"
- className="nodrag nopan absolute text-[0.45rem] font-sans font-medium"
- type="muted"
- >
- {label}
- </LemonTag>
- )
-}
-
-function findXAtY(path: SVGPathElement, targetY: number, totalLength: number): number | null {
- const tolerance = 1 // Y tolerance for finding intersection
- const step = totalLength / 1000 // Sample the path at 1000 points
-
- for (let distance = 0; distance <= totalLength; distance += step) {
- const point = path.getPointAtLength(distance)
- if (Math.abs(point.y - targetY) <= tolerance) {
- return point.x
- }
- }
-
- return null
-}
-
-function getPointAtYValue(pathString: string, distance: number, targetY?: number): { x: number; y: number } {
- // Create a temporary SVG path element to calculate the point
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
- const path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
- path.setAttribute('d', pathString)
- svg.appendChild(path)
- document.body.appendChild(svg)
-
- try {
- const totalLength = path.getTotalLength()
-
- // Calculate the Y value to use
- let yValue: number
- if (targetY !== undefined) {
- yValue = targetY
- } else {
- // Calculate Y based on distance along path (25% minimum)
- const percentageDistance = totalLength * 0.25
- const effectiveDistance = Math.max(distance, percentageDistance)
- const clampedDistance = Math.min(effectiveDistance, totalLength)
- const point = path.getPointAtLength(clampedDistance)
- yValue = point.y
- }
-
- // Find the X coordinate at the Y value
- const xAtY = findXAtY(path, yValue, totalLength)
-
- return {
- x: xAtY !== null ? xAtY : 0, // Fallback to 0 if no intersection found
- y: yValue,
- }
- } finally {
- document.body.removeChild(svg)
- }
-}
-
-const ANIMATION_DURATION_S = 1.5
-
-export function SmartEdge({
- id,
- source,
- target,
- sourceX,
- sourceY,
- targetX,
- targetY,
- sourcePosition,
- targetPosition,
- markerEnd,
- markerStart,
- data,
- ...props
-}: EdgeProps): JSX.Element {
- const edges = useEdges()
- const { animatingEdgePair, mode } = useValues(hogFlowEditorLogic)
-
- const isAnimating = mode === 'test' && animatingEdgePair === `${source}->${target}`
- const animPathRef = useRef<SVGPathElement>(null)
-
- // Use the programmatic function to get the smart step path
- const [edgePath] = getSmartStepPath({
- sourceX,
- sourceY,
- targetX,
- targetY,
- edges,
- currentEdgeId: id,
- })
-
- useEffect(() => {
- let animation: Animation | null = null
- if (isAnimating && animPathRef.current) {
- animation = animPathRef.current.animate(
- [
- { strokeDashoffset: '1', opacity: 0.8 },
- { strokeDashoffset: '0', opacity: 0.8, offset: 0.7 },
- { strokeDashoffset: '0', opacity: 0 },
- ],
- { duration: ANIMATION_DURATION_S * 1000, easing: 'ease-out', fill: 'forwards' }
- )
- }
- return () => animation?.cancel()
- }, [isAnimating, edgePath])
-
- const labelPoint = getPointAtYValue(edgePath, 20, sourceY + 20)
-
- return (
- <>
- <BaseEdge {...props} path={edgePath} markerEnd={markerEnd} markerStart={markerStart} />
- {isAnimating && (
- <path
- ref={animPathRef}
- d={edgePath}
- pathLength={1}
- stroke="var(--success)"
- strokeWidth={1.5}
- fill="none"
- strokeDasharray={1}
- strokeDashoffset={1}
- />
- )}
- <EdgeLabelRenderer>
- {data?.label ? (
- <EdgeLabel
- transform={`translate(-50%, -50%) translate(${labelPoint.x}px,${labelPoint.y}px)`}
- label={(data?.label as string) || ''}
- />
- ) : null}
- </EdgeLabelRenderer>
- </>
- )
-}
-
-export const REACT_FLOW_EDGE_TYPES = {
- smart: SmartEdge,
-}
diff --git a/products/workflows/frontend/Workflows/hogflows/react_flow_utils/autolayout.ts b/products/workflows/frontend/Workflows/hogflows/react_flow_utils/autolayout.ts
deleted file mode 100644
index e764055d91d1..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/react_flow_utils/autolayout.ts
+++ /dev/null
@@ -1,120 +0,0 @@
-import { Edge, Position } from '@xyflow/react'
-import type { ElkExtendedEdge, ElkNode } from 'elkjs/lib/elk.bundled.js'
-
-import { getElk } from 'lib/elk'
-
-import { TRIGGER_NODE_ID } from '../../workflowLogic'
-import type { HogFlowActionNode } from '../types'
-import { NODE_EDGE_GAP, NODE_HEIGHT, NODE_LAYER_GAP, NODE_NODE_GAP, NODE_WIDTH } from './constants'
-
-/**
- * By default, React Flow does not do any layouting of nodes or edges. This file uses the ELK Layered algorithm
- * to format node positions and (tries to) prevent edges from crossing over each other.
- *
- * https://eclipse.dev/elk/reference/algorithms/org-eclipse-elk-layered.html
- */
-
-const getElkPortSide = (position: Position): string => {
- switch (position) {
- case Position.Top:
- return 'NORTH'
- case Position.Bottom:
- return 'SOUTH'
- case Position.Left:
- return 'WEST'
- case Position.Right:
- return 'EAST'
- }
-}
-
-export const getFormattedNodes = async (nodes: HogFlowActionNode[], edges: Edge[]): Promise<HogFlowActionNode[]> => {
- const elkOptions = {
- 'elk.algorithm': 'layered',
- 'elk.layered.spacing.nodeNodeBetweenLayers': `${NODE_LAYER_GAP}`,
- 'elk.spacing.nodeNode': `${NODE_NODE_GAP}`,
- 'elk.spacing.edgeEdge': `${NODE_EDGE_GAP}`,
- 'elk.spacing.edgeNode': `${NODE_EDGE_GAP}`,
- 'elk.direction': 'DOWN',
- // Keep each branch's first step in one layer with its siblings, so the fixed port order keeps the
- // branches left to right. The default layering can move that step down a layer and to the other side.
- 'elk.layered.layering.strategy': 'LONGEST_PATH_SOURCE',
- 'elk.layered.nodePlacement.strategy': 'SIMPLE',
- 'elk.alignment': 'CENTER',
- 'elk.layered.nodePlacement.bk.fixedAlignment': 'BALANCED',
- 'elk.padding': '[left=0, top=0, right=0, bottom=0]',
- }
-
- const graph: ElkNode = {
- id: 'root',
- layoutOptions: elkOptions,
- children: nodes.map((node) => {
- const handles =
- node.handles
- ?.sort((a, b) => (a.id || '').localeCompare(b.id || ''))
- .map((h) => ({
- id: h.id || `${node.id}_${h.type}`,
- properties: {
- side: getElkPortSide(h.position),
- },
- })) || []
-
- return {
- ...node,
- width: NODE_WIDTH,
- height: NODE_HEIGHT,
- targetPosition: 'top',
- sourcePosition: 'bottom',
- properties: {
- 'org.eclipse.elk.portConstraints': 'FIXED_ORDER',
- },
- ports: [...handles],
- }
- }),
- edges: edges.map((edge) => ({
- ...edge,
- id: edge.id,
- sources: [edge.sourceHandle || edge.source],
- targets: [edge.targetHandle || edge.target],
- })) as ElkExtendedEdge[],
- }
-
- const elk = await getElk()
- const layoutedGraph = await elk.layout(graph)
-
- /**
- * NB: ELK adjusts the positions of the nodes without taking into account the trigger node.
- * needing a consistent position. This causes jerky movement each time the graph is updated.
- * To combat that, we always give the trigger node a fixed 0,0 position and adjust the other nodes
- * relative to it.
- */
-
- // Find the trigger node and use its position as the offset
- const triggerNode = layoutedGraph.children?.find((node) => node.id === TRIGGER_NODE_ID)
- const offsetX = triggerNode?.x || 0
- const offsetY = triggerNode?.y || 0
-
- // Adjust all node positions relative to the trigger node
- layoutedGraph.children?.forEach((node) => {
- node.x = (node.x || 0) - offsetX
- node.y = (node.y || 0) - offsetY
- })
-
- // Rebuild from the input nodes rather than spreading elk's children: elk annotates every
- // graph element it lays out with internal bookkeeping (e.g. a `$H` hash that differs per
- // run), which would leak into ReactFlow and make deep-equal layouts look changed. Handle
- // positions come from each node's `handles`, not node-level source/targetPosition, so
- // dropping elk's copies of those fields is safe.
- const layoutedById = new Map(layoutedGraph.children?.map((child) => [child.id, child]))
- return nodes.map((node) => {
- const layouted = layoutedById.get(node.id)
- if (!layouted) {
- console.warn(`[autolayout] elk did not return a position for node "${node.id}"; defaulting to (0, 0)`)
- }
- return {
- ...node,
- width: NODE_WIDTH,
- height: NODE_HEIGHT,
- position: { x: layouted?.x ?? 0, y: layouted?.y ?? 0 },
- }
- })
-}
diff --git a/products/workflows/frontend/Workflows/hogflows/react_flow_utils/constants.ts b/products/workflows/frontend/Workflows/hogflows/react_flow_utils/constants.ts
deleted file mode 100644
index 1ba04f9a896e..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/react_flow_utils/constants.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-export const NODE_WIDTH = 120
-export const NODE_HEIGHT = 34
-
-export const NODE_NODE_GAP = 100
-
-// Minimum horizontal distance between parallel edges
-export const MINIMUM_EDGE_SPACING = 170
-
-// NODE_EDGE_GAP is MINIMUM_EDGE_SPACING - 1 to account for the 1px stroke width of edges
-export const NODE_EDGE_GAP = MINIMUM_EDGE_SPACING - 1
-export const NODE_LAYER_GAP = 75
-
-// React Flow defaults to a 0.5 floor, which isn't enough to fit a wide branching workflow on screen.
-// This also raises the ceiling on the initial fitView, which is bounded by the instance's minZoom.
-export const MIN_ZOOM = 0.1
-
-// React Flow's default ceiling, named so the fit zoom math can clamp to the same bound.
-export const MAX_ZOOM = 2
-
-// Below this, a node's description renders as an illegible smudge (it's 0.3rem at zoom 1), so we drop
-// it and leave the node as a labelled block for reading the overall shape of the workflow.
-export const LOW_DETAIL_ZOOM = 0.4
-
-export const TOP_HANDLE_POSITION = {
- x: NODE_WIDTH / 2,
- y: 0,
-}
-
-export const BOTTOM_HANDLE_POSITION = {
- x: NODE_WIDTH / 2,
- y: NODE_HEIGHT,
-}
-
-export const LEFT_HANDLE_POSITION = {
- x: 0,
- y: NODE_HEIGHT / 2,
-}
-
-export const RIGHT_HANDLE_POSITION = {
- x: NODE_WIDTH,
- y: NODE_HEIGHT / 2,
-}
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx b/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx
deleted file mode 100644
index ed621470e4c6..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import { Handle, useUpdateNodeInternals } from '@xyflow/react'
-import clsx from 'clsx'
-import { useActions, useValues } from 'kea'
-import { useEffect, useState } from 'react'
-
-import { IconCopy, IconDrag, IconPlus } from '@posthog/icons'
-
-import { hogFlowEditorLogic } from '../hogFlowEditorLogic'
-import { NODE_HEIGHT, NODE_WIDTH } from '../react_flow_utils/constants'
-import { StepView } from './components/StepView'
-import { HogFlowStepNodeProps } from './types'
-
-export type ReactFlowNodeType = 'action' | 'dropzone'
-
-export const REACT_FLOW_NODE_TYPES: Record<ReactFlowNodeType, React.ComponentType<HogFlowStepNodeProps>> = {
- dropzone: DropzoneNode,
- action: HogFlowActionNode,
-}
-
-function DropzoneNode({ id }: HogFlowStepNodeProps): JSX.Element {
- const [isHighlighted, setIsHighlighted] = useState(false)
- const { isCopyingNode, isMovingNode } = useValues(hogFlowEditorLogic)
- const { setHighlightedDropzoneNodeId, copyNodeToHighlightedDropzone, moveNodeToHighlightedDropzone } =
- useActions(hogFlowEditorLogic)
-
- useEffect(() => {
- setHighlightedDropzoneNodeId(isHighlighted ? id : null)
- }, [id, isHighlighted, setHighlightedDropzoneNodeId])
-
- const handleClick = (): void => {
- if (isCopyingNode) {
- copyNodeToHighlightedDropzone()
- } else if (isMovingNode) {
- moveNodeToHighlightedDropzone()
- }
- }
-
- return (
- <div
- onDragOver={() => setIsHighlighted(true)}
- onDragLeave={() => setIsHighlighted(false)}
- onMouseOver={() => setIsHighlighted(true)}
- onMouseOut={() => setIsHighlighted(false)}
- onClick={isCopyingNode || isMovingNode ? handleClick : undefined}
- className={clsx(
- 'flex justify-center items-center p-2 rounded border border-dashed transition-all cursor-pointer hover:border-primary hover:bg-surface-primary',
- isHighlighted ? 'border-primary bg-surface-primary' : 'border-transparent'
- )}
- // eslint-disable-next-line react/forbid-dom-props
- style={{
- width: NODE_WIDTH,
- height: NODE_HEIGHT,
- }}
- >
- <div className="flex flex-col justify-center items-center w-4 h-4 rounded-full border bg-surface-primary">
- {isCopyingNode ? (
- <IconCopy className="text-sm text-primary" />
- ) : isMovingNode ? (
- <IconDrag className="text-sm text-primary" />
- ) : (
- <IconPlus className="text-sm text-primary" />
- )}
- </div>
- </div>
- )
-}
-
-function HogFlowActionNode(props: HogFlowStepNodeProps): JSX.Element | null {
- const updateNodeInternals = useUpdateNodeInternals()
-
- const { nodesById } = useValues(hogFlowEditorLogic)
-
- useEffect(() => {
- updateNodeInternals(props.id)
- }, [props.id, updateNodeInternals])
-
- const node = nodesById[props.id]
-
- return (
- <div className="transition-all hover:translate-y-[-2px]">
- {node?.handles?.map((handle) => (
- // isConnectable={false} prevents edges from being manually added
- <Handle key={handle.id} className="opacity-0" {...handle} isConnectable={false} />
- ))}
- <StepView action={props.data} />
- </div>
- )
-}
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx b/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx
deleted file mode 100644
index 77ddd23e5a87..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx
+++ /dev/null
@@ -1,267 +0,0 @@
-import { useReactFlow } from '@xyflow/react'
-import { useActions, useValues } from 'kea'
-import { useMemo } from 'react'
-
-import { IconCopy, IconDrag, IconEllipsis, IconTrash } from '@posthog/icons'
-import { LemonInput, LemonTextArea, Tooltip } from '@posthog/lemon-ui'
-
-import { LemonBadge } from 'lib/lemon-ui/LemonBadge'
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
-
-import { StepImportNotesTooltipBadge } from '../../../import/StepImportNotesTooltipBadge'
-import { workflowLogic } from '../../../workflowLogic'
-import { hogFlowEditorLogic } from '../../hogFlowEditorLogic'
-import { NODE_HEIGHT, NODE_WIDTH } from '../../react_flow_utils/constants'
-import { HogFlowAction } from '../../types'
-import { useHogFlowStep } from '../HogFlowSteps'
-import { isScheduleTrigger } from '../types'
-import { buildSummary } from './rrule-helpers'
-import { StepViewLogicProps, stepViewLogic } from './stepViewLogic'
-import { StepViewMetrics } from './StepViewMetrics'
-
-export function StepView({ action }: { action: HogFlowAction }): JSX.Element {
- const {
- selectedNode,
- mode,
- nodesById,
- selectedNodeCanBeDeleted,
- selectedNodeCanBeCopiedOrMoved,
- animatingEdgePair,
- workflow,
- isZoomedOutFar,
- } = useValues(hogFlowEditorLogic)
- const { setSelectedNodeId, startCopyingNode, startMovingNode } = useActions(hogFlowEditorLogic)
- const { actionValidationErrorsById, logicProps, scheduleState, scheduleStartsAt, isScheduleRepeating } =
- useValues(workflowLogic)
- const { deleteElements } = useReactFlow()
-
- const scheduleDescription = useMemo(() => {
- if (!isScheduleTrigger(action)) {
- return null
- }
- if (!scheduleStartsAt) {
- return 'No schedule configured'
- }
- if (!isScheduleRepeating) {
- return 'One-time run'
- }
- return buildSummary(scheduleState, scheduleStartsAt)
- }, [action, scheduleState, scheduleStartsAt, isScheduleRepeating])
-
- const isSelected = selectedNode?.id === action.id
- const node = nodesById[action.id]
-
- const stepViewLogicProps: StepViewLogicProps = { action, workflowLogicProps: logicProps }
- const { isEditingName, isEditingDescription, editNameValue, editDescriptionValue } = useValues(
- stepViewLogic(stepViewLogicProps)
- )
- const {
- startEditingName,
- startEditingDescription,
- setEditNameValue,
- setEditDescriptionValue,
- saveName,
- saveDescription,
- cancelEditingName,
- cancelEditingDescription,
- } = useActions(stepViewLogic(stepViewLogicProps))
-
- const shouldShowMetricsSummary = mode === 'metrics' && workflow.trigger?.type !== 'batch'
- const height = shouldShowMetricsSummary ? NODE_HEIGHT + 10 : NODE_HEIGHT
-
- const Step = useHogFlowStep(action)
- const { selectedColor, colorLight, color, icon } = useMemo(() => {
- return {
- selectedColor: Step?.color
- ? isSelected
- ? `${Step?.color}`
- : `${Step?.color}20`
- : isSelected
- ? 'var(--border-primary)'
- : 'var(--border)',
- colorLight: Step?.color ? `${Step?.color}20` : 'var(--border)',
- color: Step?.color || 'var(--text-secondary)',
- icon: Step?.icon,
- }
- }, [isSelected, Step])
-
- const hasValidationError = actionValidationErrorsById[action.id]?.valid === false
- const hasValidationWarning = Object.keys(actionValidationErrorsById[action.id]?.warnings ?? {}).length > 0
- const isAnimationTarget = mode === 'test' && animatingEdgePair?.endsWith(`->${action.id}`)
-
- return (
- <div
- className="relative flex flex-col cursor-pointer rounded user-select-none bg-surface-primary transition-[border-color] duration-300"
- style={{
- width: NODE_WIDTH,
- height,
- borderWidth: 1,
- borderColor: isAnimationTarget ? 'var(--success)' : selectedColor,
- boxShadow: `0px 2px 0px 0px ${colorLight}`,
- zIndex: 0,
- }}
- >
- {/* Content layer */}
- <div className="relative z-10 flex gap-1 p-1 items-start w-full">
- <div
- className="flex justify-center h-6 items-center aspect-square rounded"
- style={{
- backgroundColor: colorLight,
- color,
- }}
- >
- {icon}
- </div>
- <div className="flex flex-col flex-1 min-w-0 pr-4">
- <div className="flex justify-between items-center gap-1">
- {isEditingName ? (
- <div onClick={(e) => e.stopPropagation()} className="flex-1 min-w-0">
- <LemonInput
- autoFocus
- value={editNameValue}
- onChange={setEditNameValue}
- onBlur={(e: React.FocusEvent) => {
- e.stopPropagation()
- saveName()
- }}
- onKeyDown={(e: React.KeyboardEvent) => {
- e.stopPropagation()
- if (e.key === 'Enter') {
- e.preventDefault()
- saveName()
- ;(e.target as HTMLInputElement).blur()
- } else if (e.key === 'Escape') {
- e.preventDefault()
- cancelEditingName()
- ;(e.target as HTMLInputElement).blur()
- }
- }}
- className="text-[0.45rem] font-sans font-medium !bg-transparent !border-0 !shadow-none !p-0 !pl-1 !m-0 !min-h-0 !h-[0.55rem] !leading-tight focus-within:!ring-1 focus-within:!ring-primary !rounded"
- />
- </div>
- ) : (
- <Tooltip title={action.name}>
- <div
- className={`text-[0.45rem] font-sans font-medium rounded-sm px-0.5 -mx-0.5 transition-colors pl-1 truncate min-w-0 flex-1 ${isSelected ? 'cursor-text hover:bg-fill-button-tertiary-hover' : ''}`}
- onClick={(e) => {
- if (isSelected) {
- e.stopPropagation()
- startEditingName()
- }
- }}
- >
- {action.name}
- </div>
- </Tooltip>
- )}
- </div>
-
- {isEditingDescription ? (
- <div onClick={(e) => e.stopPropagation()} className="min-w-0">
- <LemonTextArea
- autoFocus
- value={editDescriptionValue}
- onChange={setEditDescriptionValue}
- onFocus={(e: React.FocusEvent<HTMLTextAreaElement>) => {
- const el = e.target
- el.setSelectionRange(el.value.length, el.value.length)
- }}
- onBlur={(e: React.FocusEvent) => {
- e.stopPropagation()
- saveDescription()
- }}
- onKeyDown={(e: React.KeyboardEvent) => {
- e.stopPropagation()
- if (e.key === 'Enter' && !e.shiftKey) {
- e.preventDefault()
- saveDescription()
- ;(e.target as HTMLTextAreaElement).blur()
- } else if (e.key === 'Escape') {
- e.preventDefault()
- cancelEditingDescription()
- ;(e.target as HTMLTextAreaElement).blur()
- }
- }}
- className="text-[0.3rem] text-muted !bg-transparent !border-0 !shadow-none !p-0 !px-1 !m-0 !min-h-0 !max-h-[0.9rem] !leading-[0.45rem] !resize-none !overflow-hidden !rounded-sm"
- />
- </div>
- ) : isZoomedOutFar ? null : (
- <Tooltip title={scheduleDescription ?? action.description ?? ''}>
- <div
- className={`text-[0.3rem]/1.5 text-muted line-clamp-2 !rounded-sm px-0.5 -mx-0.5 transition-colors pl-1 min-w-0 min-h-[0.45rem] overflow-hidden ${isSelected && !isScheduleTrigger(action) ? 'cursor-text hover:bg-fill-button-tertiary-hover' : ''}`}
- onClick={(e) => {
- if (isSelected && !isScheduleTrigger(action)) {
- e.stopPropagation()
- startEditingDescription()
- }
- }}
- >
- {scheduleDescription ?? action.description ?? ''}
- </div>
- </Tooltip>
- )}
- </div>
- {isSelected && node?.deletable && (
- <div className="absolute top-0.5 right-0.5" onClick={(e) => e.stopPropagation()}>
- <LemonMenu
- items={[
- selectedNodeCanBeCopiedOrMoved
- ? {
- label: 'Copy',
- icon: <IconCopy />,
- status: 'default',
- onClick: () => startCopyingNode(node),
- }
- : null,
- selectedNodeCanBeCopiedOrMoved
- ? {
- label: 'Move',
- icon: <IconDrag />,
- status: 'default',
- onClick: () => startMovingNode(node),
- }
- : null,
- {
- label: 'Delete',
- status: 'danger',
- icon: <IconTrash />,
- onClick: () => {
- void deleteElements({ nodes: [node] })
- setSelectedNodeId(null)
- },
- disabledReason: !selectedNodeCanBeDeleted
- ? 'Clean up branching steps first'
- : undefined,
- },
- ]}
- >
- <LemonButton
- icon={<IconEllipsis className="text-[0.65rem]" />}
- size="xsmall"
- tooltip="Step actions"
- noPadding
- />
- </LemonMenu>
- </div>
- )}
- </div>
- {logicProps.id ? <StepImportNotesTooltipBadge workflowId={logicProps.id} stepId={action.id} /> : null}
- {hasValidationError || hasValidationWarning ? (
- <div className="absolute top-0 right-0 scale-75">
- <LemonBadge status="warning" size="small" content="!" position="top-right" />
- </div>
- ) : null}
- {shouldShowMetricsSummary && (
- <div
- style={{
- borderTopColor: colorLight,
- borderTopWidth: 1,
- }}
- >
- <StepViewMetrics action={action} />
- </div>
- )}
- </div>
- )
-}
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/components/StepViewMetrics.tsx b/products/workflows/frontend/Workflows/hogflows/steps/components/StepViewMetrics.tsx
deleted file mode 100644
index 2dcb6887d02b..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/steps/components/StepViewMetrics.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { useValues } from 'kea'
-
-import { IconCheck, IconFilter, IconX } from '@posthog/icons'
-import { LemonSkeleton, Tooltip } from '@posthog/lemon-ui'
-
-import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
-
-import { HogFlowEditorActionMetrics, hogFlowEditorLogic } from '../../hogFlowEditorLogic'
-import { HogFlowAction } from '../../types'
-
-export function StepViewMetrics({ action }: { action: HogFlowAction }): JSX.Element {
- const { actionMetricsById, actionMetricsByIdLoading } = useValues(hogFlowEditorLogic)
-
- const metrics: HogFlowEditorActionMetrics = actionMetricsById?.[action.id] ?? {
- actionId: action.id,
- succeeded: 0,
- failed: 0,
- filtered: 0,
- }
-
- if (actionMetricsByIdLoading) {
- return (
- <div className="flex h-2 items-center gap-1 px-1">
- <LemonSkeleton className="w-full h-[6px]" />
- <LemonSkeleton className="w-full h-[6px]" />
- <LemonSkeleton className="w-full h-[6px]" />
- </div>
- )
- }
-
- return (
- <div className="flex flex-row items-center text-[6px] font-mono">
- <Tooltip title="Successful runs of this action">
- <div className="flex-1 px-1 text-success">
- <IconCheck /> {humanFriendlyLargeNumber(metrics.succeeded)}
- </div>
- </Tooltip>
-
- <Tooltip title="Failed runs of this action">
- <div className="flex-1 px-1 text-error">
- <IconX /> {humanFriendlyLargeNumber(metrics.failed)}
- </div>
- </Tooltip>
- <Tooltip title="Filtered runs of this action">
- <div className="flex-1 px-1 text-muted">
- <IconFilter /> {humanFriendlyLargeNumber(metrics.filtered)}
- </div>
- </Tooltip>
- </div>
- )
-}
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/components/stepViewLogic.ts b/products/workflows/frontend/Workflows/hogflows/steps/components/stepViewLogic.ts
deleted file mode 100644
index 3656b0d6f0a0..000000000000
--- a/products/workflows/frontend/Workflows/hogflows/steps/components/stepViewLogic.ts
+++ /dev/null
@@ -1,155 +0,0 @@
-import { MakeLogicType, actions, connect, kea, key, listeners, path, props, propsChanged, reducers } from 'kea'
-
-import { WorkflowLogicProps, workflowLogic } from '../../../workflowLogic'
-import { HogFlowAction } from '../../types'
-
-export type StepViewLogicProps = {
- action: HogFlowAction
- workflowLogicProps: WorkflowLogicProps
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface stepViewLogicValues {
- editDescriptionValue: string
- editNameValue: string
- isEditingDescription: boolean
- isEditingName: boolean
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface stepViewLogicActions {
- setWorkflowAction: (
- actionId: string,
- action: HogFlowAction
- ) => {
- action: HogFlowAction
- actionId: string
- } // workflowLogic
- cancelEditingDescription: () => {
- value: true
- }
- cancelEditingName: () => {
- value: true
- }
- saveDescription: () => {
- value: true
- }
- saveName: () => {
- value: true
- }
- setEditDescriptionValue: (value: string) => {
- value: string
- }
- setEditNameValue: (value: string) => {
- value: string
- }
- startEditingDescription: () => {
- value: true
- }
- startEditingName: () => {
- value: true
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface stepViewLogicMeta {
- key: string
-}
-
-export type stepViewLogicType = MakeLogicType<
- stepViewLogicValues,
- stepViewLogicActions,
- StepViewLogicProps,
- stepViewLogicMeta
->
-
-export const stepViewLogic = kea<stepViewLogicType>([
- path((key) => [
- 'products',
- 'workflows',
- 'frontend',
- 'Workflows',
- 'hogflows',
- 'steps',
- 'components',
- 'stepViewLogic',
- key,
- ]),
- props({} as StepViewLogicProps),
- key(({ action }: StepViewLogicProps) => action.id),
- connect(({ workflowLogicProps }: StepViewLogicProps) => ({
- actions: [workflowLogic(workflowLogicProps), ['setWorkflowAction']],
- })),
- actions({
- startEditingName: true,
- startEditingDescription: true,
- setEditNameValue: (value: string) => ({ value }),
- setEditDescriptionValue: (value: string) => ({ value }),
- saveName: true,
- saveDescription: true,
- cancelEditingName: true,
- cancelEditingDescription: true,
- }),
- reducers(({ props }) => ({
- isEditingName: [
- false,
- {
- startEditingName: () => true,
- saveName: () => false,
- cancelEditingName: () => false,
- },
- ],
- isEditingDescription: [
- false,
- {
- startEditingDescription: () => true,
- saveDescription: () => false,
- cancelEditingDescription: () => false,
- },
- ],
- editNameValue: [
- props.action.name,
- {
- setEditNameValue: (_, { value }) => value,
- saveName: (state) => state,
- cancelEditingName: () => props.action.name,
- },
- ],
- editDescriptionValue: [
- props.action.description || '',
- {
- setEditDescriptionValue: (_, { value }) => value,
- saveDescription: (state) => state,
- cancelEditingDescription: () => props.action.description || '',
- },
- ],
- })),
- listeners(({ actions, props, values }) => ({
- saveName: () => {
- const trimmedName = values.editNameValue.trim()
- if (trimmedName && trimmedName !== props.action.name) {
- actions.setWorkflowAction(props.action.id, {
- ...props.action,
- name: trimmedName,
- })
- }
- },
- saveDescription: () => {
- const trimmedDescription = values.editDescriptionValue.trim()
- if (trimmedDescription !== (props.action.description || '')) {
- actions.setWorkflowAction(props.action.id, {
- ...props.action,
- description: trimmedDescription,
- })
- }
- },
- })),
- propsChanged(({ actions, props, values }) => {
- if (!values.isEditingName && values.editNameValue !== props.action.name) {
- actions.setEditNameValue(props.action.name)
- }
- if (!values.isEditingDescription && values.editDescriptionValue !== (props.action.description || '')) {
- actions.setEditDescriptionValue(props.action.description || '')
- }
- }),
-])
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/types.ts b/products/workflows/frontend/Workflows/hogflows/steps/types.ts
index 44f17e8494a6..faed98a2d73c 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/types.ts
+++ b/products/workflows/frontend/Workflows/hogflows/steps/types.ts
@@ -1,19 +1,10 @@
-import { Handle, NodeProps } from '@xyflow/react'
import { z } from 'zod'
-import { Optional } from 'lib/utils/types'
import { LogEntry } from 'scenes/hog-functions/logs/logsViewerLogic'
import { HogFlowAction } from '../types'
import { isDuration, isSignedDuration } from './durations'
-export type HogFlowStepNodeProps = NodeProps & {
- data: HogFlowAction
- type: HogFlowAction['type']
-}
-
-export type StepViewNodeHandle = Omit<Optional<Handle, 'width' | 'height'>, 'nodeId'> & { label?: string }
-
const ActionFiltersSchema = z.object({
events: z.array(z.any()).optional(),
properties: z.array(z.any()).optional(),
diff --git a/products/workflows/frontend/Workflows/hogflows/types.ts b/products/workflows/frontend/Workflows/hogflows/types.ts
index 131640a88e56..ffb81acf2673 100644
--- a/products/workflows/frontend/Workflows/hogflows/types.ts
+++ b/products/workflows/frontend/Workflows/hogflows/types.ts
@@ -116,7 +116,7 @@ export interface HogFlow extends z.infer<typeof HogFlowSchema> {
}
export interface HogFlowEdge extends z.infer<typeof HogFlowEdgeSchema> {}
-export interface HogFlowActionEdge extends Edge<{ edge: HogFlowEdge; label?: string }> {}
+export interface HogFlowActionEdge extends Edge<{ edge: HogFlowEdge }> {}
export type HogFlowAction = z.infer<typeof HogFlowActionSchema> & Record<string, unknown>
export interface HogFlowActionNode extends Node<HogFlowAction> {}
diff --git a/products/workflows/frontend/Workflows/import/StepImportNotesTooltipBadge.tsx b/products/workflows/frontend/Workflows/import/StepImportNotesTooltipBadge.tsx
deleted file mode 100644
index fa8c63540398..000000000000
--- a/products/workflows/frontend/Workflows/import/StepImportNotesTooltipBadge.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useValues } from 'kea'
-
-import { Tooltip } from '@posthog/lemon-ui'
-
-import { StepImportNotesBadge } from './StepImportNotesBadge'
-import { StepImportNotesList } from './StepImportNotesList'
-import { workflowImportNotesLogic } from './workflowImportNotesLogic'
-
-/** The import badge with its notes on hover, for steps that have no hover card of their own. */
-export function StepImportNotesTooltipBadge({
- workflowId,
- stepId,
-}: {
- workflowId: string
- stepId: string
-}): JSX.Element | null {
- const { notesByStepId } = useValues(workflowImportNotesLogic({ id: workflowId }))
- if (!notesByStepId[stepId]?.length) {
- return null
- }
- return (
- <Tooltip title={<StepImportNotesList workflowId={workflowId} stepId={stepId} />}>
- <span>
- <StepImportNotesBadge workflowId={workflowId} stepId={stepId} />
- </span>
- </Tooltip>
- )
-}
diff --git a/products/workflows/frontend/Workflows/overview/WorkflowOverview.tsx b/products/workflows/frontend/Workflows/overview/WorkflowOverview.tsx
index 24cb70a47328..02a2fde05c55 100644
--- a/products/workflows/frontend/Workflows/overview/WorkflowOverview.tsx
+++ b/products/workflows/frontend/Workflows/overview/WorkflowOverview.tsx
@@ -16,7 +16,6 @@ import { WorkflowMetricCard } from '../WorkflowMetricCard'
import { METRIC_COLORS, withDisplayName, workflowMetricsSummaryLogic } from '../workflowMetricsSummaryLogic'
import { WorkflowMessageLeaderboard } from './WorkflowMessageLeaderboard'
import { WorkflowOverviewDetails } from './WorkflowOverviewDetails'
-import { WorkflowOverviewFeedback } from './WorkflowOverviewFeedback'
import { WorkflowOverviewHealth } from './WorkflowOverviewHealth'
import { WorkflowOverviewInFlight } from './WorkflowOverviewInFlight'
import { workflowOverviewLogic } from './workflowOverviewLogic'
@@ -161,7 +160,6 @@ export function WorkflowOverview({ id, run, previousRun, controls }: WorkflowOve
return (
<div className="@container flex flex-col gap-4" data-attr="workflow-overview">
- <WorkflowOverviewFeedback />
<div className="flex flex-wrap items-center justify-end gap-2">
{controls ?? <AppMetricsFilters logicKey={logicKey} />}
</div>
diff --git a/products/workflows/frontend/Workflows/overview/WorkflowOverviewFeedback.tsx b/products/workflows/frontend/Workflows/overview/WorkflowOverviewFeedback.tsx
deleted file mode 100644
index cae8d8f0a057..000000000000
--- a/products/workflows/frontend/Workflows/overview/WorkflowOverviewFeedback.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import { FeaturePreviewFeedbackBanner } from '../../FeaturePreviewFeedbackBanner'
-
-const SURVEY_ID = '01a135a4-2f3c-0000-4732-df04655842ff'
-const RATING_QUESTION_ID = '521dcdd1-4a8b-40c4-a8b3-41ac5b9a751f'
-const FEEDBACK_QUESTION_ID = '227c1646-eafa-46ad-823c-d2a8892a806b'
-
-export function WorkflowOverviewFeedback(): JSX.Element {
- return (
- <FeaturePreviewFeedbackBanner
- surveyId={SURVEY_ID}
- ratingQuestionId={RATING_QUESTION_ID}
- feedbackQuestionId={FEEDBACK_QUESTION_ID}
- surface="workflow_overview_tab"
- dismissKey="workflow-overview-feature-preview"
- prompt="We're trying out an overview for workflows. Is it useful?"
- feedbackTitle="Help shape the workflow overview"
- feedbackPlaceholder="Tell us what's useful, what's missing, or what you'd change"
- className=""
- data-attr="workflow-overview-feature-preview"
- />
- )
-}