:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(experiments): Adding action header (#80951)
ruby childsc61ee4c348ac
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex ca0a65e18903..dd6fd8ad0d9e 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5299,7 +5299,7 @@ snapshots:replay-scenes-activity-modal--event-explorer-with-modal-not-found--dark:hash: v1.k794b7964.501fe9bfcbdf282d03b6e84473bc502b8039a3885993a7a581642d53c6723c59.wbNI8ZzAgSPgBs4xMZ3CQMf3f9vqSb2FmF_QsN7r-K4replay-scenes-activity-modal--event-explorer-with-modal-not-found--light:- hash: v1.k794b7964.56fdba2366efbb9c09bb3b1c24ef3288c42cb74b7a695ed51a29ea35fbcd24fa.wFMQwl8fDQGG8qaGWuSQ_fU1aRecYd1_QjLOcD0tX9I+ hash: v1.k794b7964.81e20aa66083b87a258198e6ea569f3ddba800c881cf9e290ecf26a91854ea85.dSrHo6fI1JEXYFPhx_CffBlbooKEihfsJgDjDE__yIwreplay-scenes-group--group-events-tab-with-modal-not-found--dark:hash: v1.k794b7964.138cafc1552c1dda770e935bcd85d18ea9311f46e924f50402d3bff212be6973.3ArSEPt5vM96hea6kAfkUt6oQ7aaExJ1dTM8wiKLpaUreplay-scenes-group--group-events-tab-with-modal-not-found--light:@@ -6049,57 +6049,61 @@ snapshots:scenes-app-events-mcp-tool-calls--mcp-tool-calls--light:hash: v1.k794b7964.423e2228f2e2d55107e73c53678f5076d5e7003ac6e9e2c3b420ba1d5bdc9f5d.6MHkzMWpkO6Q8IRSf3BDISXo3179ssSFM_Th3qBJ0Xsscenes-app-experiments--draft-experiment--dark:- hash: v1.k794b7964.18ba3b37c04c8a6d202c3abce2b268b00a0d043b782ede993bb68cae138db832.f5bfIh0sCko802ak3IOBPTlnaYWOM1JGMVJL6AAJrWU+ hash: v1.k794b7964.862ae6da1335a0cec5825234d2a6baf1d5e4eb5c1dec6650924d62d0e117e56b.9_kP5gSMifRjF9JZKyTMqKI2rD78F8UYSBa8ENH_GXUscenes-app-experiments--draft-experiment--light:- hash: v1.k794b7964.74192966b20280489fdc67329370f7c5b675e67a8e18512b61ac71e6c982c0f7.NrgEIHQRT87ytfEBzJVtAVuW3Wn06aWA8erEOgDlmpE+ hash: v1.k794b7964.7355787f803ecf45b38311ba4494e1744c4e4cba40629fdb625adf5187dbe1a2.jJTifUL_cmDr_Evsxg-lPWmRkjh2zZuQJTXkBmHgu_8scenes-app-experiments--experiment-asymmetric-intervals--dark:- hash: v1.k794b7964.49105844a48e3c23386a1bea3720b6a2e4722f6d49afb4125c38351e132a53eb.ljI08w6HZnct_K7roF_S_nuqQ-MA6ChK2Tca7dh9hsI+ hash: v1.k794b7964.56e811cd06c3c3ca6befea4ab0253cf5d5aa96a437287197b3c4fbce5927a62f.k1ahzW6QbDem7TAyNNpg-hHvXOWUp16u-WEEJqyv_Q8scenes-app-experiments--experiment-asymmetric-intervals--light:- hash: v1.k794b7964.b2bc93939d938d962fbd42530c5c06ea637feef8192291232d4726aed5805cb4.Hl0K2n_pRnLrochHVl4MEGZG6PcHg72tGPuBxwQc9J8+ hash: v1.k794b7964.0dea51d851f4824c698bc269922ee4b2d12e01e379b1f9a3574ac574f1728903.oUP3RdTGW0pormIa33Ls3GZNKELUhpHBnnCi4hIebZsscenes-app-experiments--experiment-exposures-expanded--dark:- hash: v1.k794b7964.0c2dbc3f48e7318d8977fbc764e5b4a351896d86fd556451b496ac34d6e1aa14.UpjAeSCvamOAlqu_g_LWgLHB_HiG1zVJ3C1CONT6C5Y+ hash: v1.k794b7964.5609b7dcffea75f30c025e50bc92b3803a04dba1e94c3cbe531d5f667777f71b._2cuxIZjvFOvCQGl1L-OP37Fh0VE8Kd1Ar2PjYIKYDcscenes-app-experiments--experiment-exposures-expanded--light:- hash: v1.k794b7964.ba7d43c183d3d97f0f4056b4293ef15d323c56be131957881cae031d5c654fa9.QfVezRYgy-vWVpeyh5JBZ4B7diInR6UsdbNEMfaB3Ik+ hash: v1.k794b7964.ac4ebb8bf851fc0905419b3bd17cd1036072b2ecc72e5726967b0d0b31b94e39.1E_kGE0J-DG9hRh2XllV5Mu8S8AbRg0UzeAHWvszmlkscenes-app-experiments--experiment-frequentist-five-variants--dark:- hash: v1.k794b7964.64907f2bf773632ae842870dd967079496c161171ca264af1d4e00e4e5c1195f.7yK2Tx9IC-ddtEvHbF__sgBr9ivvBShPMx7VUiyT2H8+ hash: v1.k794b7964.ac4a624a81a3e27d7d161027963c64865f76975e126502cdafe19b787ae5fa5f.PLLLQPUKZhqvgGnObf0EA4H0ftn4V9hOknzMOBIn4zsscenes-app-experiments--experiment-frequentist-five-variants--light:- hash: v1.k794b7964.f478981f562a501e410ad9dcdcbdd71d073a180997aab12894e41512932b1d2f.h8YEuihISGANeWkHFNbbJMm1TtmMLzXRPRLq3twoCD8+ hash: v1.k794b7964.fc8013ce6e850a8415631e141e89b4855d6be07c7162e2bdd294fda88e4d4ba9.bL1P6ZD2UEJTzEaszgA8M0QNgBEFOqdUl1JTvd5TVD4scenes-app-experiments--experiment-frequentist-two-variants--dark:- hash: v1.k794b7964.bb18212dddff7df860cbea51f78d888106dcd91d28a43c72942f4377582b2f9e.m9EZYBw6L48FQNPBH9ilA5oAyaXj1uCwARaznfavowk+ hash: v1.k794b7964.d138ad11d0ce55e9f4efcd49d3c900a5c191f8d523af19344954a1b5f53bbc8b.UgSNRtiE6Zxs5ViVcfjHAil50DT1_7tucGNa5K8XIOMscenes-app-experiments--experiment-frequentist-two-variants--light:- hash: v1.k794b7964.f92ae3b1acfa8fc4f98babb18e7c944e30b5749400dd382d43fa702b1bc0727b.v7qRnZU8furIdj048Ap7rBb0QbVoNS88_de-FqorlF8+ hash: v1.k794b7964.ea348c8a8f4a76b3bb315c0df4b6f3d4d35b9c83f68152cad44e9c9ff3cef095.Da0oLYgJn5q9VzJ6a2CZqQG1Rc7awAnT9WOFy4NP2ag+ scenes-app-experiments--experiment-stopped-with-conclusion--dark:+ hash: v1.k794b7964.0ed912970ce0a55c45fd54799febd21547cedb04534a56e8e789f7ee787c3b39.L7iFT9xjm0sWN6iCtvk9K_z2PKUSEOYkHI_b1oizB2M+ scenes-app-experiments--experiment-stopped-with-conclusion--light:+ hash: v1.k794b7964.793a4b6109b2c0ab65b07d9eaefd1c8862f12bfc7f33b2f452ad20044396b2a7.6B0Meq7yO75vBEoBmuP2dNl2oKTugzzr_IKTcJHhEi0scenes-app-experiments--experiment-with-funnel-metric--dark:- hash: v1.k794b7964.f33abe58d4dc3c42ee0aa09fb9cec2a8d0b4e17a0642164ed913c6b4b87691a4.iDS3IMV59UC7uXmUOJUd8j-NXLUiLeN8j4D6YndOszg+ hash: v1.k794b7964.fd0d0ad7569f50079a322a8901513f854823ce694796a2a24a1e6714ac9c5902.fBtAQkm1LZ7xYp6DTXoQSDqDFjsUkxMCP-aNAZJ1Fmcscenes-app-experiments--experiment-with-funnel-metric--light:- hash: v1.k794b7964.189e0d10904e34237d13c3d281a93fc8280f80ab959bc4c52b9a302e0c312169.-ol38I5Gu8C4051FEwNLLMTCDy_xwChL9TTL9W2hRdU+ hash: v1.k794b7964.a608f24a82fc56569fb7029e98bab3121baa3fd6c5c63492fe9952aa6a43afc5.ZgTLiUZPjDNcaChht0ijSp2F7HoqRkdn__-6JKI7p4Ascenes-app-experiments--experiment-with-legacy-funnels-query--dark:hash: v1.k794b7964.6503cdfd33ae5f9d525d14dc8d43b047e8469beca7e5e489534347904efe1dec.2CtGz-wQvIwr_SQDthwlGJI5bVcJ7bFpetJricY-Lpsscenes-app-experiments--experiment-with-legacy-funnels-query--light:- hash: v1.k794b7964.5c4ca67479d0c5b961ed3e5c43834bdc2746964e1328e9c0be8ba7d86c9f76c8.7vwTqOFXTWxcughOK2rSV6s0pGFzID3BDvMgKwkPXYM+ hash: v1.k794b7964.90eb6e86ccabbca83076708acceb7370c5d2981927097a498d952e7c4de46d08.ll4GkGnimLwqqcMyiISsfWian6bSONcAuvzyfXyufggscenes-app-experiments--experiment-with-legacy-trends-query--dark:hash: v1.k794b7964.03d4ee126b173c15e89b9c392d324782a429004c648a8bc39b1c38a6d574e108.BdtD3YlFV6RZsqF6JJgwkp0J6TN3JJGL35l47EOwtOUscenes-app-experiments--experiment-with-legacy-trends-query--light:hash: v1.k794b7964.42c2f3656a5c989d4b1ee34296ca4bb59e186241920a5f8ca21f319069cc6825.6R2u2nPGBnbJYFX2aAn-ZEDtNpa4m1bQA-1aYg8Y7sMscenes-app-experiments--experiment-with-mean-metric--dark:- hash: v1.k794b7964.3e78a41658e9e1b76cb2428cbb32582077b1b43f820744966285c0862ff7f556.0t5TdyC6dx2nKUFHy-DqEyw4L-07MqrloiHmOD5bo4Y+ hash: v1.k794b7964.68dc40978276b76d39da611d562f3c9265466b73f3e8fb15000c638bfdfb157a.aDami22xbJW3cmnF_5pAvzWjZt9JHuBGAldnztPQdtwscenes-app-experiments--experiment-with-mean-metric--light:- hash: v1.k794b7964.2bd044c1fb951cc5280c8befc03b7534774e703e92aa268f228ab20bd2522411.AFij815dd9946fOpsJgW7T2G_FjYM3Njr7LJ87amVrQ+ hash: v1.k794b7964.653360b3d5a6ccefeddbac9bf7743def00cc3d15ff2676d6f54b0999453ebad1.3Hczx7-pcdwGchm84XBbwOf3d5eDSGXXriZRkKvek9Qscenes-app-experiments--experiment-with-multi-step-funnel-metric--dark:- hash: v1.k794b7964.feb19120fcb35db2a44666c4e20b7728f8b9bb5d0c1bc38d41b7698f5722c181.Hw40iUldn70Z33rYE-zitkjrvytX-vhUGY03V3ycXNk+ hash: v1.k794b7964.6c73e20e6bcfbd467e8e9dea7f6cbcd9d05ba8f99b99879a366d5fc14ae1d296.6QHCgNYcXclmThjruFfmFpJsfM5oode4JC1elbpZ-rEscenes-app-experiments--experiment-with-multi-step-funnel-metric--light:- hash: v1.k794b7964.9d7dfffb7317f37caea4ad6a4492ab88a74944025164c8985ae09d4598998dce.LTVbWdIGOWozyPbgjbbSanV3cqEaLuHls5Da2LEvzRw+ hash: v1.k794b7964.97d7402f9b51d0c2d446c61c0022bb257b60230ee9ef045fb98f9a6f6881021a.u-DOTSJ-2l7aMIVwI4CBomzduA0B_q6-6kfVwbLKl5Mscenes-app-experiments--experiment-with-multiple-metrics--dark:- hash: v1.k794b7964.c2b2dfac0dcf77fefa7bfcd55ad0022ee6a8f461f3c03d74448bab270ba7dd7b.DgmRBGi8wUsgVlPWENMllouOKXKtCawcdVWsU6Srd5U+ hash: v1.k794b7964.935a9474cbc0ab0c65ece0051d8ebc3a88c8f40de3bb8a7a7621dbe1766a4105.2TXN7Cqx8Qd7XzXBjoaslAsm-r4qbXmG0Vlch8j6ph0scenes-app-experiments--experiment-with-multiple-metrics--light:- hash: v1.k794b7964.bd0c9df6ac5649eb99e8fe4b2c4a3ecd5967e86390934fbcaa90d6a98298e62a.CaaUkkkx-ak0cHKyZjYvANiqHcEeRLVUfiYWbGBEGa0+ hash: v1.k794b7964.448c290538a260ff05193bab32d795204e54a5cd96abcb9a7b732b4c42363fed.3t46h15bDQSIO4NUiZmifVgFCXfMt-jTpqOq9r6uobAscenes-app-experiments--experiment-with-multiple-metrics-reordered--dark:- hash: v1.k794b7964.bf78a31867b98f4d38802a891ff6806070a45a51f2cab47681dd0dbfd2c520bd.wua8m3TWJX-zNOg4_kEde_UoBl7SZ3qdtnPkIM_yTxk+ hash: v1.k794b7964.cb832411fa4bb013fe8cf3c5cebae7dab81ec6790bf28b7e19d8ffa6354371c7.Li1GU7QxtL4i4YePx2ss3H5l8uBXbXpU1GaJDWp98Qoscenes-app-experiments--experiment-with-multiple-metrics-reordered--light:- hash: v1.k794b7964.8a4ba7f6b3940090235189423acb5815d3950a5e7e6c04020d1eef1f90ac74f6.F5ZLNpXgvKczk05Mkzg_cN_KZgfsEZ-fs0Gnv9pYo0M+ hash: v1.k794b7964.d93c2bfac6413b2bc65c8aefdcf6c541a9e54c7ecd6f4c1ba72e0b5c2c0972ae.Prz3-ZGrDwYopNhjhvbxFn5YdDlQcqzm0ZcEW9adhlYscenes-app-experiments--experiment-with-ratio-metric--dark:- hash: v1.k794b7964.f7d50e2c065ff1b918c01fae91091f1e6e7ac248a375529d04316a6e5a6ec521.0EZJzXkY1jfkXaoPiKnv3j5o8CNzqI0VBR8Wxs9JC0Y+ hash: v1.k794b7964.996cb1e2faed957b2e9d5125ce6b889579fa2c3821a97d533f16a9177441d39e.JK-y5MPcxs8shOXpHRlmrG0SlfesUgzT-ZcJM_fkN_Escenes-app-experiments--experiment-with-ratio-metric--light:- hash: v1.k794b7964.cc2a5bbb71b901b5db0d97f8ace2666cef4f13301086dd388c6c72d3a3759049.rVJk1AMixaOqQ3KPxmL2IrJZ_3JFQVpVm-XchLm6Bpw+ hash: v1.k794b7964.91c6e783430aee352949d4114d9569d79ab235721c972946f1c040ea919abbf2.dHbCWm1FRc5TK-czma65fdJHYwXE4LPGIz4U5xiYZPkscenes-app-experiments--experiments--dark:hash: v1.k794b7964.bb7a67466cb94c2155158d13444e7f6f473d8176c5823908c467b2d19c0f3ac9.uPI1H-JnVAqnEUTczdLstoglvGWvSOBV5k4w-FXpLWcscenes-app-experiments--experiments--light:@@ -6555,7 +6559,7 @@ snapshots:scenes-app-insights-error-empty-states--server-error--dark:hash: v1.k794b7964.d4fc60a8e2dcacd414609ab296220b7d67381644f361e874c89790ad0166ac72.AvZwp_QBR6TzTD2jw9dj4M96gEsNdZ05GpMMfFp9RjQscenes-app-insights-error-empty-states--server-error--light:- hash: v1.k794b7964.35ed59d2bdcc52c93c986a480bcc36b51913b32c3833fb5b5a16ca1ac3bb3e79.mJrsY5F5nRZ_wO8D937ymEISXRwiSmZpf0ImwObTMy8+ hash: v1.k794b7964.79b5b63d2b650cc4f924ddf5a268fa8ef317b61002f878ba729b43114ff2458c.TeYRm6KIzF4y5I9oHWuR5KmccQgDWrUc9JHk9Hq0p4oscenes-app-insights-error-empty-states--validation-error--dark:hash: v1.k794b7964.855cdd3fac12fc2645b90ff17a8e0150f3cd4e4b646e92b9266e5261459d0d07.yF2PxdOOktpjWsHaPmDXsmLxgz5S3nhheVXgr1Xt1V0scenes-app-insights-error-empty-states--validation-error--light:diff --git a/frontend/src/lib/lemon-ui/LemonMenu/index.ts b/frontend/src/lib/lemon-ui/LemonMenu/index.tsindex 23b285af6ff4..430a856dc98e 100644--- a/frontend/src/lib/lemon-ui/LemonMenu/index.ts+++ b/frontend/src/lib/lemon-ui/LemonMenu/index.ts@@ -1,2 +1,9 @@-export type { LemonMenuItem, LemonMenuItems, LemonMenuOverlayProps, LemonMenuSection } from './LemonMenu'+export type {+ LemonMenuItem,+ LemonMenuItemLeaf,+ LemonMenuItemLeafCallback,+ LemonMenuItems,+ LemonMenuOverlayProps,+ LemonMenuSection,+} from './LemonMenu'export { LemonMenu, LemonMenuOverlay } from './LemonMenu'diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentActionsMenu.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentActionsMenu.tsxnew file mode 100644index 000000000000..6fe3e49b144e--- /dev/null+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentActionsMenu.tsx@@ -0,0 +1,39 @@+import { IconChevronDown } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { LemonMenu } from 'lib/lemon-ui/LemonMenu'++import { useExperimentActions } from './useExperimentActions'++export function ExperimentActionsMenu(): JSX.Element | null {+ const sceneMenuBarEnabled = useFeatureFlag('SCENE_MENU_BAR')++ // The scene menu bar already surfaces every action in its File/Edit menus.+ if (sceneMenuBarEnabled) {+ return null+ }++ return <ExperimentActionsMenuInner />+}++function ExperimentActionsMenuInner(): JSX.Element | null {+ const sections = useExperimentActions('actions-dropdown-')++ if (sections.length === 0) {+ return null+ }++ return (+ <LemonMenu items={sections} placement="bottom-end">+ <LemonButton+ type="secondary"+ size="small"+ sideIcon={<IconChevronDown />}+ data-attr="experiment-actions-menu"+ >+ Actions+ </LemonButton>+ </LemonMenu>+ )+}diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentSceneMenuBar.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentSceneMenuBar.tsxindex 5bc7938408e8..08c86fb35d57 100644--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentSceneMenuBar.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentSceneMenuBar.tsx@@ -1,20 +1,20 @@import { useActions, useAsyncActions, useValues } from 'kea'import { router } from 'kea-router'-import { useState } from 'react'import {IconArchive,IconCopy,- IconEye,+ IconDashboard,+ IconExternal,IconLock,+ IconMessage,IconPause,+ IconPeople,IconPlay,- IconPlusSmall,IconRefresh,IconTrash,IconUnlock,} from '@posthog/icons'-import { LemonDialog } from '@posthog/lemon-ui'import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'import { superpowersLogic } from 'lib/components/Superpowers/superpowersLogic'@@ -25,8 +25,6 @@ import { newInternalTab } from 'lib/utils/newInternalTab'import { addProductIntentForCrossSell } from 'lib/utils/product-intents'import { organizationLogic } from 'scenes/organizationLogic'import { projectLogic } from 'scenes/projectLogic'-import { QuickSurveyType } from 'scenes/surveys/quick-create/types'-import { QuickSurveyModal } from 'scenes/surveys/QuickSurveyModal'import { urls } from 'scenes/urls'import {@@ -40,16 +38,14 @@ import {import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType } from '~/types'-import { CopyExperimentToProjectModal } from '../CopyExperimentToProjectModal'-import { DuplicateExperimentModal } from '../DuplicateExperimentModal'import {canArchiveExperiment,canFreezeExposure,confirmArchiveExperiment,confirmDeleteExperiment,confirmFreezeExposure,+ confirmResetExperiment,confirmUnfreezeExposure,- hasFrozenExposureStamps,} from '../experimentActions'import { experimentLogic } from '../experimentLogic'import { isExperimentExposureFrozen, isExperimentPaused } from '../experimentsLogic'@@ -89,13 +85,15 @@ function ExperimentSceneMenuBarInner(): JSX.Element | null {const { freezeExposure, unfreezeExposure } = useAsyncActions(experimentLogic)const { currentProjectId } = useValues(projectLogic)const { currentOrganization } = useValues(organizationLogic)- const { openPauseExperimentModal, openResumeExperimentModal } = useActions(modalsLogic)+ const {+ openPauseExperimentModal,+ openResumeExperimentModal,+ openDuplicateExperimentModal,+ openCopyToProjectModal,+ openQuickSurveyModal,+ } = useActions(modalsLogic)const { superpowersEnabled } = useValues(superpowersLogic)- const [duplicateModalOpen, setDuplicateModalOpen] = useState(false)- const [copyToProjectModalOpen, setCopyToProjectModalOpen] = useState(false)- const [surveyModalOpen, setSurveyModalOpen] = useState(false)-if (!experiment) {return null}@@ -122,249 +120,191 @@ function ExperimentSceneMenuBarInner(): JSX.Element | null {onDelete: () => router.actions.push(urls.experiments()),})- const handleReset = (): void => {- LemonDialog.open({- title: 'Reset analysis?',- content: (- <>- <div className="text-sm text-secondary max-w-md">- <p>- The experiment start and end dates will be reset and the experiment will go back to draft- mode.- </p>- <p>- All events collected thus far will still exist, but won't be applied to the experiment- unless you manually change the start date after launching the experiment again.- </p>- {hasFrozenExposureStamps(experiment) ? (- <p>- The <b>exposure freeze is removed</b>: the flag serves its original release conditions- again and the snapshot cohort is deleted. Everything else on the flag stays untouched.- </p>- ) : (- <p>- The <b>feature flag remains untouched</b>, so variants stay visible to users.- </p>- )}- </div>- {experiment.archived && (- <div className="text-sm text-secondary">Resetting will also unarchive the experiment.</div>- )}- </>- ),- primaryButton: {- children: 'Confirm',- type: 'primary',- onClick: resetRunningExperiment,- size: 'small',- },- secondaryButton: {- children: 'Cancel',- type: 'tertiary',- size: 'small',- },- })- }+ const handleReset = (): void => confirmResetExperiment(experiment, resetRunningExperiment)const showCreateMenu = isExperimentLaunchedconst showStateMenu = showRunningStateconst showStaffMenu = superpowersEnabledreturn (- <>- <SceneMenuBar>- <SceneMenuBarMenu label="File" dataAttr={`${RESOURCE_TYPE}-menubar-file`}>- {showCreateMenu && (- <>- <SceneMenuBarSubMenu label="Create">- {exposureCohortId ? (- <SceneMenuBarItem- onClick={() => newInternalTab(urls.cohort(exposureCohortId))}- data-attr={`${RESOURCE_TYPE}-menubar-view-exposure-cohort`}- >- <IconEye />- View exposure cohort as new tab- </SceneMenuBarItem>- ) : (- <SceneMenuBarItem- onClick={() => createExposureCohort()}- data-attr={`${RESOURCE_TYPE}-menubar-create-exposure-cohort`}- >- <IconPlusSmall />- Exposure cohort- </SceneMenuBarItem>- )}+ <SceneMenuBar>+ <SceneMenuBarMenu label="File" dataAttr={`${RESOURCE_TYPE}-menubar-file`}>+ {showCreateMenu && (+ <>+ <SceneMenuBarSubMenu label="Create">+ {exposureCohortId ? (<SceneMenuBarItem- onClick={() => createExperimentDashboard()}- disabled={isCreatingExperimentDashboard}- data-attr={`${RESOURCE_TYPE}-menubar-create-dashboard`}+ onClick={() => newInternalTab(urls.cohort(exposureCohortId))}+ data-attr={`${RESOURCE_TYPE}-menubar-view-exposure-cohort`}>- <IconPlusSmall />- Dashboard+ <IconPeople />+ View exposure cohort+ <IconExternal /></SceneMenuBarItem>- {experiment.feature_flag && (- <SceneMenuBarItem- opensFloatingUi- onClick={() => {- setSurveyModalOpen(true)- void addProductIntentForCrossSell({- from: ProductKey.EXPERIMENTS,- to: ProductKey.SURVEYS,- intent_context: ProductIntentContext.QUICK_SURVEY_STARTED,- })- }}- data-attr={`${RESOURCE_TYPE}-menubar-create-survey`}- >- <IconPlusSmall />- Survey- </SceneMenuBarItem>- )}- </SceneMenuBarSubMenu>- <SceneMenuBarSeparator />- </>- )}- <SceneMenuBarFileItems dataAttrKey={RESOURCE_TYPE} />- {hasMultipleProjects && (- <SceneMenuBarItem- opensFloatingUi- onClick={() => setCopyToProjectModalOpen(true)}- disabled={isLegacyExperiment(experiment)}- tooltip={- isLegacyExperiment(experiment)- ? 'Copying is not supported for experiments using legacy metrics.'- : undefined- }- data-attr={`${RESOURCE_TYPE}-menubar-copy-to-project`}- >- <IconCopy />- Copy to another project- </SceneMenuBarItem>- )}- {(canArchive || (canEdit && experiment.archived) || canDelete) && <SceneMenuBarSeparator />}- {canArchive && (- <SceneMenuBarItem- variant="destructive"- onClick={handleArchive}- data-attr={`${RESOURCE_TYPE}-menubar-archive`}- >- <IconArchive />- Archive experiment- </SceneMenuBarItem>- )}- {canEdit && experiment.archived && (- <SceneMenuBarItem- onClick={() => unarchiveExperiment()}- data-attr={`${RESOURCE_TYPE}-menubar-unarchive`}- >- <IconArchive />- Unarchive experiment- </SceneMenuBarItem>- )}- {canDelete && (- <SceneMenuBarItem- variant="destructive"- onClick={handleDelete}- data-attr={`${RESOURCE_TYPE}-menubar-delete`}- >- <IconTrash />- Delete experiment- </SceneMenuBarItem>- )}- </SceneMenuBarMenu>- <SceneMenuBarMenu label="Edit" dataAttr={`${RESOURCE_TYPE}-menubar-edit`}>+ ) : (+ <SceneMenuBarItem+ onClick={() => createExposureCohort()}+ data-attr={`${RESOURCE_TYPE}-menubar-create-exposure-cohort`}+ >+ <IconPeople />+ Exposure cohort+ </SceneMenuBarItem>+ )}+ <SceneMenuBarItem+ onClick={() => createExperimentDashboard()}+ disabled={isCreatingExperimentDashboard}+ data-attr={`${RESOURCE_TYPE}-menubar-create-dashboard`}+ >+ <IconDashboard />+ Dashboard+ </SceneMenuBarItem>+ {experiment.feature_flag && (+ <SceneMenuBarItem+ opensFloatingUi+ onClick={() => {+ openQuickSurveyModal()+ void addProductIntentForCrossSell({+ from: ProductKey.EXPERIMENTS,+ to: ProductKey.SURVEYS,+ intent_context: ProductIntentContext.QUICK_SURVEY_STARTED,+ })+ }}+ data-attr={`${RESOURCE_TYPE}-menubar-create-survey`}+ >+ <IconMessage />+ Survey+ </SceneMenuBarItem>+ )}+ </SceneMenuBarSubMenu>+ <SceneMenuBarSeparator />+ </>+ )}+ <SceneMenuBarFileItems dataAttrKey={RESOURCE_TYPE} />+ {hasMultipleProjects && (<SceneMenuBarItemopensFloatingUi- onClick={() => setDuplicateModalOpen(true)}- data-attr={`${RESOURCE_TYPE}-menubar-duplicate`}+ onClick={() => openCopyToProjectModal()}+ disabled={isLegacyExperiment(experiment)}+ tooltip={+ isLegacyExperiment(experiment)+ ? 'Copying is not supported for experiments using legacy metrics.'+ : undefined+ }+ data-attr={`${RESOURCE_TYPE}-menubar-copy-to-project`}><IconCopy />- Duplicate+ Copy to another project+ </SceneMenuBarItem>+ )}+ {(canArchive || (canEdit && experiment.archived) || canDelete) && <SceneMenuBarSeparator />}+ {canArchive && (+ <SceneMenuBarItem+ variant="destructive"+ onClick={handleArchive}+ data-attr={`${RESOURCE_TYPE}-menubar-archive`}+ >+ <IconArchive />+ Archive experiment</SceneMenuBarItem>- {isExperimentLaunched && (+ )}+ {canEdit && experiment.archived && (+ <SceneMenuBarItem+ onClick={() => unarchiveExperiment()}+ data-attr={`${RESOURCE_TYPE}-menubar-unarchive`}+ >+ <IconArchive />+ Unarchive experiment+ </SceneMenuBarItem>+ )}+ {canDelete && (+ <SceneMenuBarItem+ variant="destructive"+ onClick={handleDelete}+ data-attr={`${RESOURCE_TYPE}-menubar-delete`}+ >+ <IconTrash />+ Delete experiment+ </SceneMenuBarItem>+ )}+ </SceneMenuBarMenu>+ <SceneMenuBarMenu label="Edit" dataAttr={`${RESOURCE_TYPE}-menubar-edit`}>+ <SceneMenuBarItem+ opensFloatingUi+ onClick={() => openDuplicateExperimentModal()}+ data-attr={`${RESOURCE_TYPE}-menubar-duplicate`}+ >+ <IconCopy />+ Duplicate+ </SceneMenuBarItem>+ {isExperimentLaunched && (+ <SceneMenuBarItem+ opensFloatingUi+ onClick={handleReset}+ data-attr={`${RESOURCE_TYPE}-menubar-reset`}+ >+ <IconRefresh />+ Reset analysis+ </SceneMenuBarItem>+ )}+ {showStateMenu &&+ (paused ? (<SceneMenuBarItemopensFloatingUi- onClick={handleReset}- data-attr={`${RESOURCE_TYPE}-menubar-reset`}+ onClick={() => openResumeExperimentModal()}+ data-attr={`${RESOURCE_TYPE}-menubar-resume`}>- <IconRefresh />- Reset analysis+ <IconPlay />+ Resume experiment</SceneMenuBarItem>- )}- {showStateMenu &&- (paused ? (- <SceneMenuBarItem- opensFloatingUi- onClick={() => openResumeExperimentModal()}- data-attr={`${RESOURCE_TYPE}-menubar-resume`}- >- <IconPlay />- Resume experiment- </SceneMenuBarItem>- ) : (- <>- {showFreezeExposure && (- <SceneMenuBarItem- opensFloatingUi- onClick={() => confirmFreezeExposure(() => freezeExposure())}- disabled={freezeExposureLoading}- tooltip={freezeExposureLoading ? 'Freezing exposure…' : undefined}- data-attr={`${RESOURCE_TYPE}-menubar-freeze-exposure`}- >- <IconLock />- Freeze exposure- </SceneMenuBarItem>- )}- {isExperimentExposureFrozen(experiment) && (- <SceneMenuBarItem- opensFloatingUi- onClick={() => confirmUnfreezeExposure(() => unfreezeExposure())}- disabled={unfreezeExposureLoading}- tooltip={unfreezeExposureLoading ? 'Unfreezing exposure…' : undefined}- data-attr={`${RESOURCE_TYPE}-menubar-unfreeze-exposure`}- >- <IconUnlock />- Unfreeze exposure- </SceneMenuBarItem>- )}+ ) : (+ <>+ {showFreezeExposure && (+ <SceneMenuBarItem+ opensFloatingUi+ onClick={() => confirmFreezeExposure(() => freezeExposure())}+ disabled={freezeExposureLoading}+ tooltip={freezeExposureLoading ? 'Freezing exposure…' : undefined}+ data-attr={`${RESOURCE_TYPE}-menubar-freeze-exposure`}+ >+ <IconLock />+ Freeze exposure+ </SceneMenuBarItem>+ )}+ {isExperimentExposureFrozen(experiment) && (<SceneMenuBarItemopensFloatingUi- variant="destructive"- onClick={() => openPauseExperimentModal()}- data-attr={`${RESOURCE_TYPE}-menubar-pause`}+ onClick={() => confirmUnfreezeExposure(() => unfreezeExposure())}+ disabled={unfreezeExposureLoading}+ tooltip={unfreezeExposureLoading ? 'Unfreezing exposure…' : undefined}+ data-attr={`${RESOURCE_TYPE}-menubar-unfreeze-exposure`}>- <IconPause />- Pause experiment+ <IconUnlock />+ Unfreeze exposure</SceneMenuBarItem>- </>- ))}+ )}+ <SceneMenuBarItem+ opensFloatingUi+ variant="destructive"+ onClick={() => openPauseExperimentModal()}+ data-attr={`${RESOURCE_TYPE}-menubar-pause`}+ >+ <IconPause />+ Pause experiment+ </SceneMenuBarItem>+ </>+ ))}+ </SceneMenuBarMenu>+ {showStaffMenu && (+ <SceneMenuBarMenu label="Staff only" dataAttr={`${RESOURCE_TYPE}-menubar-staff`}>+ <SceneMenuBarCheckboxItem+ checked={showDebugPanel}+ onCheckedChange={toggleDebugPanel}+ data-attr={`${RESOURCE_TYPE}-menubar-debug-panel`}+ >+ Show debug panel+ </SceneMenuBarCheckboxItem></SceneMenuBarMenu>- {showStaffMenu && (- <SceneMenuBarMenu label="Staff only" dataAttr={`${RESOURCE_TYPE}-menubar-staff`}>- <SceneMenuBarCheckboxItem- checked={showDebugPanel}- onCheckedChange={toggleDebugPanel}- data-attr={`${RESOURCE_TYPE}-menubar-debug-panel`}- >- Show debug panel- </SceneMenuBarCheckboxItem>- </SceneMenuBarMenu>- )}- </SceneMenuBar>- <DuplicateExperimentModal- isOpen={duplicateModalOpen}- onClose={() => setDuplicateModalOpen(false)}- experiment={experiment}- />- <CopyExperimentToProjectModal- isOpen={copyToProjectModalOpen}- onClose={() => setCopyToProjectModalOpen(false)}- experiment={experiment}- />- <QuickSurveyModal- context={{ type: QuickSurveyType.EXPERIMENT, experiment }}- isOpen={surveyModalOpen}- onCancel={() => setSurveyModalOpen(false)}- />- </>+ )}+ </SceneMenuBar>)}diff --git a/frontend/src/scenes/experiments/ExperimentView/Info.tsx b/frontend/src/scenes/experiments/ExperimentView/Info.tsxindex 2893c5b48eb2..5c1f7936c4b1 100644--- a/frontend/src/scenes/experiments/ExperimentView/Info.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/Info.tsx@@ -21,7 +21,7 @@ import { flagCleanupTaskLogic } from './flagCleanupTaskLogic'import { RunningTime } from './RunningTime'import { StatusTag } from './StatusTag'-function FlagCleanupLine({ experimentId, taskId }: { experimentId: number; taskId: string }): JSX.Element | null {+function FlagCleanupField({ experimentId, taskId }: { experimentId: number; taskId: string }): JSX.Element | null {const { cleanupTask } = useValues(flagCleanupTaskLogic({ experimentId }))if (!cleanupTask) {@@ -48,26 +48,29 @@ function FlagCleanupLine({ experimentId, taskId }: { experimentId: number; taskIconst showLink = isExternalLink || cleanupTask.can_view_taskreturn (- <div className="text-xs text-muted mt-1 mb-3 flex items-center gap-1">- {text}- {showLink && (- <>- ·- <Link- target={isExternalLink ? '_blank' : undefined}- className="flex items-center gap-0.5"- to={prUrl ?? urls.taskDetail(taskId)}- >- {isExternalLink ? (- <>- View on GitHub <IconOpenInNew fontSize="12" />- </>- ) : (- 'View task'- )}- </Link>- </>- )}+ <div className="flex flex-col" data-attr="experiment-flag-cleanup">+ <Label intent="menu">Flag cleanup</Label>+ <div className="flex items-center gap-1">+ {text}+ {showLink && (+ <>+ ·+ <Link+ target={isExternalLink ? '_blank' : undefined}+ className="flex items-center gap-0.5"+ to={prUrl ?? urls.taskDetail(taskId)}+ >+ {isExternalLink ? (+ <>+ View on GitHub <IconOpenInNew fontSize="14" />+ </>+ ) : (+ 'View task'+ )}+ </Link>+ </>+ )}+ </div></div>)}@@ -99,7 +102,7 @@ export function Info(): JSX.Element {return (<>- <div className="grid gap-2 overflow-hidden grid-cols-1 min-[1100px]:grid-cols-[1fr_1fr]">+ <div className="grid gap-2 overflow-hidden grid-cols-1 min-[1100px]:grid-cols-[3fr_2fr]">{/* Column 1 */}<div className="flex flex-col gap-0 overflow-hidden min-w-0">{/* Row 1: Status, Feature flag, Stats engine */}@@ -175,6 +178,33 @@ export function Info(): JSX.Element {: `${((1 - (experiment.stats_config?.frequentist?.alpha ?? 0.05)) * 100).toFixed(0)}%`}</span></div>+ {experiment.conclusion && experiment.end_date && (+ <div className="flex flex-col" data-attr="experiment-conclusion">+ <Label intent="menu">Conclusion</Label>+ <div className="flex items-center gap-2">+ <div+ className={clsx(+ 'w-2 h-2 rounded-full shrink-0',+ CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.color || ''+ )}+ />+ <span className="font-semibold">+ {CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.title ||+ experiment.conclusion}+ </span>+ <LemonButton+ type="secondary"+ size="xsmall"+ icon={<IconPencil />}+ onClick={openEditConclusionModal}+ tooltip="Edit conclusion"+ />+ </div>+ </div>+ )}+ {experiment.flag_cleanup_task_id && typeof experiment.id === 'number' && (+ <FlagCleanupField experimentId={experiment.id} taskId={experiment.flag_cleanup_task_id} />+ )}</div></div>@@ -202,41 +232,9 @@ export function Info(): JSX.Element {</div></div></div>- <div className="flex gap-6">- {experiment.conclusion && experiment.end_date && (- <div className="max-w-[500px]">- <div className="flex items-center gap-2">- <Label intent="menu">Conclusion</Label>- <LemonButton- type="secondary"- size="xsmall"- icon={<IconPencil />}- onClick={openEditConclusionModal}- />- </div>- <div>- <div className="font-semibold flex items-center gap-2">- <div- className={clsx(- 'w-2 h-2 rounded-full',- CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.color || ''- )}- />- <span>- {CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.title || experiment.conclusion}- </span>- </div>- <div>{experiment.conclusion_comment}</div>- {experiment.flag_cleanup_task_id && typeof experiment.id === 'number' && (- <FlagCleanupLine- experimentId={experiment.id}- taskId={experiment.flag_cleanup_task_id}- />- )}- </div>- </div>- )}- </div>+ {experiment.conclusion && experiment.end_date && experiment.conclusion_comment && (+ <div className="mt-2 max-w-[600px] text-secondary">{experiment.conclusion_comment}</div>+ )}</>)}diff --git a/frontend/src/scenes/experiments/ExperimentView/PageHeader.tsx b/frontend/src/scenes/experiments/ExperimentView/PageHeader.tsxindex b3de10126bb1..790751d584d5 100644--- a/frontend/src/scenes/experiments/ExperimentView/PageHeader.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/PageHeader.tsx@@ -1,113 +1,55 @@-import { useActions, useAsyncActions, useValues } from 'kea'-import { router } from 'kea-router'-import { useState } from 'react'+import { useActions, useValues } from 'kea'+import { Fragment } from 'react'-import {- IconArchive,- IconCopy,- IconEye,- IconFlask,- IconLock,- IconPause,- IconPlay,- IconPlusSmall,- IconRefresh,- IconTrash,- IconUnlock,-} from '@posthog/icons'-import { LemonButton, LemonDialog, LemonDivider, LemonSwitch, Link, Tooltip } from '@posthog/lemon-ui'+import { IconFlask } from '@posthog/icons'+import { LemonButton, LemonDivider, LemonSwitch, Tooltip } from '@posthog/lemon-ui'import { useHogfetti } from 'lib/components/Hogfetti/Hogfetti'import { superpowersLogic } from 'lib/components/Superpowers/superpowersLogic'import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'import { userHasAccess } from 'lib/utils/accessControlUtils'-import { newInternalTab } from 'lib/utils/newInternalTab'-import { addProductIntentForCrossSell } from 'lib/utils/product-intents'-import { organizationLogic } from 'scenes/organizationLogic'-import { projectLogic } from 'scenes/projectLogic'import { QuickSurveyType } from 'scenes/surveys/quick-create/types'import { QuickSurveyModal } from 'scenes/surveys/QuickSurveyModal'-import { urls } from 'scenes/urls'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { ScenePanel, ScenePanelActionsSection } from '~/layout/scenes/SceneLayout'-import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType } from '~/types'import { CopyExperimentToProjectModal } from '../CopyExperimentToProjectModal'import { DuplicateExperimentModal } from '../DuplicateExperimentModal'-import {- canArchiveExperiment,- canFreezeExposure,- confirmArchiveExperiment,- confirmDeleteExperiment,- confirmFreezeExposure,- confirmUnfreezeExposure,- hasFrozenExposureStamps,-} from '../experimentActions'import { experimentLogic } from '../experimentLogic'-import { isExperimentExposureFrozen, isExperimentPaused } from '../experimentsLogic'import { modalsLogic } from '../modalsLogic'-import { isLegacyExperiment } from '../utils'+import { ExperimentActionsMenu } from './ExperimentActionsMenu'import { FinishExperimentModal, PauseExperimentModal, ResumeExperimentModal } from './ExperimentModals'import { ExperimentSceneMenuBar } from './ExperimentSceneMenuBar'+import { useExperimentActions } from './useExperimentActions'export function PageHeaderCustom(): JSX.Element {const {experiment,isExperimentDraft,isExperimentRunning,- isExperimentLaunched,isExperimentStopped,- isCreatingExperimentDashboard,experimentLoading,launchExperimentLoading,- freezeExposureLoading,- unfreezeExposureLoading,} = useValues(experimentLogic)- const {- launchExperiment,- archiveExperiment,- unarchiveExperiment,- createExposureCohort,- createExperimentDashboard,- updateExperiment,- setHogfettiTrigger,- } = useActions(experimentLogic)- // Promise-returning dispatch so the confirm dialogs can await completion (shouldAwaitSubmit).- const { freezeExposure, unfreezeExposure } = useAsyncActions(experimentLogic)- const { currentProjectId } = useValues(projectLogic)- const { currentOrganization } = useValues(organizationLogic)- const hasMultipleProjects = (currentOrganization?.projects?.length ?? 0) > 1- const { openFinishExperimentModal, openPauseExperimentModal, openResumeExperimentModal } = useActions(modalsLogic)- const [duplicateModalOpen, setDuplicateModalOpen] = useState(false)- const [copyToProjectModalOpen, setCopyToProjectModalOpen] = useState(false)- const [surveyModalOpen, setSurveyModalOpen] = useState(false)+ const { launchExperiment, updateExperiment, setHogfettiTrigger } = useActions(experimentLogic)+ const { isDuplicateExperimentModalOpen, isCopyToProjectModalOpen, isQuickSurveyModalOpen } = useValues(modalsLogic)+ const { openFinishExperimentModal, closeDuplicateExperimentModal, closeCopyToProjectModal, closeQuickSurveyModal } =+ useActions(modalsLogic)+ const actionSections = useExperimentActions()const { trigger, HogfettiComponent } = useHogfetti()useOnMountEffect(() => {setHogfettiTrigger(trigger)})- const exposureCohortId = experiment?.exposure_cohort-const canEdit = userHasAccess(AccessControlResourceType.Experiment,AccessControlLevel.Editor,experiment.user_access_level)- const canArchive = canEdit && canArchiveExperiment(experiment)- const canDelete = canEdit-- const handleArchive = (): void =>- confirmArchiveExperiment(experiment, (disableFlag) => archiveExperiment(disableFlag))- const handleDelete = (): void =>- confirmDeleteExperiment({- projectId: currentProjectId,- experiment,- onDelete: () => router.actions.push(urls.experiments()),- })return (<>@@ -139,11 +81,6 @@ export function PageHeaderCustom(): JSX.Element {</LemonButton></div>)}- {canArchive && (- <LemonButton type="secondary" status="danger" onClick={handleArchive} size="small">- <b>Archive</b>- </LemonButton>- )}{experiment && isExperimentRunning && !isExperimentStopped && (<><Tooltip title="Conclude this experiment and decide which variant to keep">@@ -159,20 +96,7 @@ export function PageHeaderCustom(): JSX.Element {<FinishExperimentModal /></>)}- {experiment && (- <DuplicateExperimentModal- isOpen={duplicateModalOpen}- onClose={() => setDuplicateModalOpen(false)}- experiment={experiment}- />- )}- {experiment && (- <CopyExperimentToProjectModal- isOpen={copyToProjectModalOpen}- onClose={() => setCopyToProjectModalOpen(false)}- experiment={experiment}- />- )}+ <ExperimentActionsMenu /></>}/>@@ -181,165 +105,53 @@ export function PageHeaderCustom(): JSX.Element {{experiment && (<ScenePanel><ScenePanelActionsSection>- <ButtonPrimitive menuItem onClick={() => setDuplicateModalOpen(true)}>- <IconCopy />- Duplicate- </ButtonPrimitive>-- {hasMultipleProjects && (- <ButtonPrimitive- menuItem- onClick={() => setCopyToProjectModalOpen(true)}- disabledReasons={{- 'Copying is not supported for experiments using legacy metrics.':- isLegacyExperiment(experiment),- }}- >- <IconCopy />- Copy to project- </ButtonPrimitive>- )}-- {isExperimentLaunched && (- <>- {exposureCohortId ? (- // TODO: add custom back button to the destination page- <Link- to={urls.cohort(exposureCohortId)}- buttonProps={{- menuItem: true,- }}- data-attr="view-exposure-cohort"- onClick={() => newInternalTab(urls.cohort(exposureCohortId))}- >- <IconEye /> View exposure cohort as new tab- </Link>- ) : (+ {actionSections.map((section, index) => (+ <Fragment key={section.key}>+ {index > 0 && <LemonDivider />}+ {section.items.map((item) => (<ButtonPrimitive+ key={item['data-attr'] ?? String(item.label)}menuItem- onClick={() => createExposureCohort()}- data-attr="create-exposure-cohort"+ variant={item.status === 'danger' ? 'danger' : 'default'}+ onClick={item.onClick}+ disabledReasons={+ item.disabledReason ? { [item.disabledReason]: true } : undefined+ }+ data-attr={item['data-attr']}>- <IconPlusSmall /> Create exposure cohort+ {item.icon}+ {item.label}+ {item.sideIcon && <span className="ml-auto">{item.sideIcon}</span>}</ButtonPrimitive>- )}- <ButtonPrimitive- menuItem- onClick={() => createExperimentDashboard()}- disabledReasons={{- 'Creating dashboard...': isCreatingExperimentDashboard,- }}- >- <IconPlusSmall /> Create dashboard- </ButtonPrimitive>-- {experiment.feature_flag && (- <ButtonPrimitive- menuItem- onClick={() => {- setSurveyModalOpen(true)- void addProductIntentForCrossSell({- from: ProductKey.EXPERIMENTS,- to: ProductKey.SURVEYS,- intent_context: ProductIntentContext.QUICK_SURVEY_STARTED,- })- }}- >- <IconPlusSmall /> Create survey- </ButtonPrimitive>- )}-- <LemonDivider />-- {isExperimentRunning &&- experiment.feature_flag &&- (isExperimentPaused(experiment) ? (- <ButtonPrimitive- menuItem- data-attr="resume-experiment"- onClick={() => openResumeExperimentModal()}- >- <IconPlay /> Resume experiment- </ButtonPrimitive>- ) : (- <>- {canFreezeExposure(experiment) && (- <ButtonPrimitive- menuItem- data-attr="freeze-exposure"- onClick={() => confirmFreezeExposure(() => freezeExposure())}- disabledReasons={{- 'Freezing exposure...': freezeExposureLoading,- }}- >- <IconLock /> Freeze exposure- </ButtonPrimitive>- )}- {isExperimentExposureFrozen(experiment) && (- <ButtonPrimitive- menuItem- data-attr="unfreeze-exposure"- onClick={() => confirmUnfreezeExposure(() => unfreezeExposure())}- disabledReasons={{- 'Unfreezing exposure...': unfreezeExposureLoading,- }}- >- <IconUnlock /> Unfreeze exposure- </ButtonPrimitive>- )}- <ButtonPrimitive- variant="danger"- menuItem- data-attr="pause-experiment"- onClick={() => openPauseExperimentModal()}- >- <IconPause /> Pause experiment- </ButtonPrimitive>- </>- ))}-- <ResetButton />- </>- )}-- <LemonDivider />-- {canArchive && (- <ButtonPrimitive menuItem data-attr="archive-experiment" onClick={handleArchive}>- <IconArchive /> Archive experiment- </ButtonPrimitive>- )}- {canEdit && experiment.archived && (- <ButtonPrimitive- menuItem- data-attr="unarchive-experiment"- onClick={() => unarchiveExperiment()}- >- <IconArchive /> Unarchive experiment- </ButtonPrimitive>- )}-- {canDelete && (- <ButtonPrimitive- variant="danger"- menuItem- data-attr="delete-experiment"- onClick={handleDelete}- >- <IconTrash /> Delete experiment- </ButtonPrimitive>- )}-- <PauseExperimentModal />- <ResumeExperimentModal />+ ))}+ </Fragment>+ ))}</ScenePanelActionsSection><ExperimentDebugToggle /></ScenePanel>)}+ {experiment && (+ <>+ {/* Outside ScenePanel: the panel unmounts its children whenever no panel+ element is registered, which would leave these modals' open state dangling. */}+ <PauseExperimentModal />+ <ResumeExperimentModal />+ <DuplicateExperimentModal+ isOpen={isDuplicateExperimentModalOpen}+ onClose={() => closeDuplicateExperimentModal()}+ experiment={experiment}+ />+ <CopyExperimentToProjectModal+ isOpen={isCopyToProjectModalOpen}+ onClose={() => closeCopyToProjectModal()}+ experiment={experiment}+ />+ </>+ )}<QuickSurveyModalcontext={{ type: QuickSurveyType.EXPERIMENT, experiment }}- isOpen={surveyModalOpen}- onCancel={() => setSurveyModalOpen(false)}+ isOpen={isQuickSurveyModalOpen}+ onCancel={() => closeQuickSurveyModal()}/></>)@@ -366,58 +178,3 @@ function ExperimentDebugToggle(): JSX.Element {</ScenePanelActionsSection>)}--const ResetButton = (): JSX.Element => {- const { experiment } = useValues(experimentLogic)- const { resetRunningExperiment } = useActions(experimentLogic)-- const onClickReset = (): void => {- LemonDialog.open({- title: 'Reset analysis?',- content: (- <>- <div className="text-sm text-secondary max-w-md">- <p>- The experiment start and end dates will be reset and the experiment will go back to draft- mode.- </p>- <p>- All events collected thus far will still exist, but won't be applied to the experiment- unless you manually change the start date after launching the experiment again.- </p>- {hasFrozenExposureStamps(experiment) ? (- <p>- The <b>exposure freeze is removed</b>: the flag serves its original release conditions- again and the snapshot cohort is deleted. Everything else on the flag stays untouched.- </p>- ) : (- <p>- The <b>feature flag remains untouched</b>, so variants stay visible to users.- </p>- )}- </div>- {experiment.archived && (- <div className="text-sm text-secondary">Resetting will also unarchive the experiment.</div>- )}- </>- ),- primaryButton: {- children: 'Confirm',- type: 'primary',- onClick: resetRunningExperiment,- size: 'small',- },- secondaryButton: {- children: 'Cancel',- type: 'tertiary',- size: 'small',- },- })- }-- return (- <ButtonPrimitive variant="danger" menuItem onClick={onClickReset} data-attr="reset-experiment">- <IconRefresh /> Reset analysis- </ButtonPrimitive>- )-}diff --git a/frontend/src/scenes/experiments/ExperimentView/useExperimentActions.tsx b/frontend/src/scenes/experiments/ExperimentView/useExperimentActions.tsxnew file mode 100644index 000000000000..566f64de11d7--- /dev/null+++ b/frontend/src/scenes/experiments/ExperimentView/useExperimentActions.tsx@@ -0,0 +1,237 @@+import { useActions, useAsyncActions, useValues } from 'kea'+import { router } from 'kea-router'++import {+ IconArchive,+ IconCopy,+ IconDashboard,+ IconExternal,+ IconLock,+ IconMessage,+ IconPause,+ IconPeople,+ IconPlay,+ IconRefresh,+ IconTrash,+ IconUnlock,+} from '@posthog/icons'++import { LemonMenuItemLeafCallback } from 'lib/lemon-ui/LemonMenu'+import { userHasAccess } from 'lib/utils/accessControlUtils'+import { newInternalTab } from 'lib/utils/newInternalTab'+import { addProductIntentForCrossSell } from 'lib/utils/product-intents'+import { organizationLogic } from 'scenes/organizationLogic'+import { projectLogic } from 'scenes/projectLogic'+import { urls } from 'scenes/urls'++import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'+import { AccessControlLevel, AccessControlResourceType } from '~/types'++import {+ canArchiveExperiment,+ canFreezeExposure,+ confirmArchiveExperiment,+ confirmDeleteExperiment,+ confirmFreezeExposure,+ confirmResetExperiment,+ confirmUnfreezeExposure,+} from '../experimentActions'+import { experimentLogic } from '../experimentLogic'+import { isExperimentExposureFrozen, isExperimentPaused } from '../experimentsLogic'+import { modalsLogic } from '../modalsLogic'+import { isLegacyExperiment } from '../utils'++/** Keep `disabledReason` a plain string (LemonMenu also allows elements) so the+ * ScenePanel can use it as a `disabledReasons` key without silently dropping it. */+export type ExperimentActionItem = LemonMenuItemLeafCallback & { disabledReason?: string }++export interface ExperimentActionsSection {+ key: string+ items: ExperimentActionItem[]+}++/** The full action set for the current experiment, shared by the header's Actions+ * dropdown and the ScenePanel so the two surfaces can't drift apart. */+export function useExperimentActions(dataAttrPrefix: string = ''): ExperimentActionsSection[] {+ const {+ experiment,+ isExperimentLaunched,+ isExperimentRunning,+ isCreatingExperimentDashboard,+ freezeExposureLoading,+ unfreezeExposureLoading,+ } = useValues(experimentLogic)+ const {+ archiveExperiment,+ unarchiveExperiment,+ createExposureCohort,+ createExperimentDashboard,+ resetRunningExperiment,+ } = useActions(experimentLogic)+ // Promise-returning dispatch so the confirm dialogs can await completion (shouldAwaitSubmit).+ const { freezeExposure, unfreezeExposure } = useAsyncActions(experimentLogic)+ const {+ openDuplicateExperimentModal,+ openCopyToProjectModal,+ openQuickSurveyModal,+ openPauseExperimentModal,+ openResumeExperimentModal,+ } = useActions(modalsLogic)+ const { currentProjectId } = useValues(projectLogic)+ const { currentOrganization } = useValues(organizationLogic)++ // `experiment` defaults to the NEW_EXPERIMENT placeholder (id 'new') while the real+ // experiment loads — don't offer actions (e.g. Delete) against the placeholder.+ if (!experiment || experiment.id === 'new') {+ return []+ }++ const hasMultipleProjects = (currentOrganization?.projects?.length ?? 0) > 1+ const canEdit = userHasAccess(+ AccessControlResourceType.Experiment,+ AccessControlLevel.Editor,+ experiment.user_access_level+ )+ const canArchive = canEdit && canArchiveExperiment(experiment)+ const canDelete = canEdit+ const exposureCohortId = experiment.exposure_cohort+ const paused = isExperimentPaused(experiment)+ const showStateActions = isExperimentRunning && !!experiment.feature_flag++ const manageItems: (ExperimentActionItem | false)[] = [+ {+ label: 'Duplicate',+ icon: <IconCopy />,+ onClick: () => openDuplicateExperimentModal(),+ 'data-attr': `${dataAttrPrefix}duplicate-experiment`,+ },+ hasMultipleProjects && {+ label: 'Copy to project',+ icon: <IconCopy />,+ onClick: () => openCopyToProjectModal(),+ disabledReason: isLegacyExperiment(experiment)+ ? 'Copying is not supported for experiments using legacy metrics.'+ : undefined,+ 'data-attr': `${dataAttrPrefix}copy-experiment-to-project`,+ },+ isExperimentLaunched &&+ (exposureCohortId+ ? {+ // TODO: add custom back button to the destination page+ label: 'View exposure cohort',+ icon: <IconPeople />,+ sideIcon: <IconExternal />,+ onClick: () => newInternalTab(urls.cohort(exposureCohortId)),+ 'data-attr': `${dataAttrPrefix}view-exposure-cohort`,+ }+ : {+ label: 'Create exposure cohort',+ icon: <IconPeople />,+ onClick: () => createExposureCohort(),+ 'data-attr': `${dataAttrPrefix}create-exposure-cohort`,+ }),+ isExperimentLaunched && {+ label: 'Create dashboard',+ icon: <IconDashboard />,+ onClick: () => createExperimentDashboard(),+ disabledReason: isCreatingExperimentDashboard ? 'Creating dashboard...' : undefined,+ 'data-attr': `${dataAttrPrefix}create-experiment-dashboard`,+ },+ isExperimentLaunched &&+ !!experiment.feature_flag && {+ label: 'Create survey',+ icon: <IconMessage />,+ onClick: () => {+ openQuickSurveyModal()+ void addProductIntentForCrossSell({+ from: ProductKey.EXPERIMENTS,+ to: ProductKey.SURVEYS,+ intent_context: ProductIntentContext.QUICK_SURVEY_STARTED,+ })+ },+ 'data-attr': `${dataAttrPrefix}create-experiment-survey`,+ },+ ]++ const stateItems: (ExperimentActionItem | false)[] = [+ showStateActions &&+ paused && {+ label: 'Resume experiment',+ icon: <IconPlay />,+ onClick: () => openResumeExperimentModal(),+ 'data-attr': `${dataAttrPrefix}resume-experiment`,+ },+ showStateActions &&+ !paused &&+ canFreezeExposure(experiment) && {+ label: 'Freeze exposure',+ icon: <IconLock />,+ onClick: () => confirmFreezeExposure(() => freezeExposure()),+ disabledReason: freezeExposureLoading ? 'Freezing exposure...' : undefined,+ 'data-attr': `${dataAttrPrefix}freeze-exposure`,+ },+ showStateActions &&+ !paused &&+ isExperimentExposureFrozen(experiment) && {+ label: 'Unfreeze exposure',+ icon: <IconUnlock />,+ onClick: () => confirmUnfreezeExposure(() => unfreezeExposure()),+ disabledReason: unfreezeExposureLoading ? 'Unfreezing exposure...' : undefined,+ 'data-attr': `${dataAttrPrefix}unfreeze-exposure`,+ },+ showStateActions &&+ !paused && {+ label: 'Pause experiment',+ icon: <IconPause />,+ status: 'danger',+ onClick: () => openPauseExperimentModal(),+ 'data-attr': `${dataAttrPrefix}pause-experiment`,+ },+ isExperimentLaunched && {+ label: 'Reset analysis',+ icon: <IconRefresh />,+ status: 'danger',+ onClick: () => confirmResetExperiment(experiment, resetRunningExperiment),+ 'data-attr': `${dataAttrPrefix}reset-experiment`,+ },+ ]++ const dangerItems: (ExperimentActionItem | false)[] = [+ canArchive && {+ label: 'Archive experiment',+ icon: <IconArchive />,+ onClick: () => confirmArchiveExperiment(experiment, (disableFlag) => archiveExperiment(disableFlag)),+ 'data-attr': `${dataAttrPrefix}archive-experiment`,+ },+ canEdit &&+ !!experiment.archived && {+ label: 'Unarchive experiment',+ icon: <IconArchive />,+ onClick: () => unarchiveExperiment(),+ 'data-attr': `${dataAttrPrefix}unarchive-experiment`,+ },+ canDelete && {+ label: 'Delete experiment',+ icon: <IconTrash />,+ status: 'danger',+ onClick: () =>+ confirmDeleteExperiment({+ projectId: currentProjectId,+ experiment,+ onDelete: () => router.actions.push(urls.experiments()),+ }),+ 'data-attr': `${dataAttrPrefix}delete-experiment`,+ },+ ]++ return [+ { key: 'manage', items: manageItems },+ { key: 'state', items: stateItems },+ { key: 'danger', items: dangerItems },+ ]+ .map((section) => ({+ ...section,+ items: section.items.filter((item): item is ExperimentActionItem => !!item),+ }))+ .filter((section) => section.items.length > 0)+}diff --git a/frontend/src/scenes/experiments/experimentActions.tsx b/frontend/src/scenes/experiments/experimentActions.tsxindex 6484e6c44400..6298c570ae0b 100644--- a/frontend/src/scenes/experiments/experimentActions.tsx+++ b/frontend/src/scenes/experiments/experimentActions.tsx@@ -160,6 +160,52 @@ export function confirmArchiveExperiment(})}+export function confirmResetExperiment(+ experiment: Pick<Experiment, 'archived' | 'feature_flag'>,+ onConfirm: () => void+): void {+ LemonDialog.open({+ title: 'Reset analysis?',+ content: (+ <>+ <div className="text-sm text-secondary max-w-md">+ <p>+ The experiment start and end dates will be reset and the experiment will go back to draft mode.+ </p>+ <p>+ All events collected thus far will still exist, but won't be applied to the experiment unless+ you manually change the start date after launching the experiment again.+ </p>+ {hasFrozenExposureStamps(experiment) ? (+ <p>+ The <b>exposure freeze is removed</b>: the flag serves its original release conditions again+ and the snapshot cohort is deleted. Everything else on the flag stays untouched.+ </p>+ ) : (+ <p>+ The <b>feature flag remains untouched</b>, so variants stay visible to users.+ </p>+ )}+ </div>+ {experiment.archived && (+ <div className="text-sm text-secondary">Resetting will also unarchive the experiment.</div>+ )}+ </>+ ),+ primaryButton: {+ children: 'Confirm',+ type: 'primary',+ onClick: onConfirm,+ size: 'small',+ },+ secondaryButton: {+ children: 'Cancel',+ type: 'tertiary',+ size: 'small',+ },+ })+}+export function confirmDeleteExperiment(opts: {projectId: number | nullexperiment: Pick<Experiment, 'id' | 'name'>diff --git a/frontend/src/scenes/experiments/modalsLogic.ts b/frontend/src/scenes/experiments/modalsLogic.tsindex d5d10c297c72..537b3649ba95 100644--- a/frontend/src/scenes/experiments/modalsLogic.ts+++ b/frontend/src/scenes/experiments/modalsLogic.ts@@ -11,9 +11,11 @@ import { SharedMetric } from './SharedMetrics/sharedMetricLogic'export interface modalsLogicValues {currentProjectId: number | null // projectLogiccurrentTeamId: number | null // teamLogic+ isCopyToProjectModalOpen: booleanisCupedModalOpen: booleanisDescriptionModalOpen: booleanisDistributionModalOpen: boolean+ isDuplicateExperimentModalOpen: booleanisEditConclusionModalOpen: booleanisExperimentCollectionGoalModalOpen: booleanisExposureCriteriaModalOpen: boolean@@ -22,6 +24,7 @@ export interface modalsLogicValues {isPrimaryMetricModalOpen: booleanisPrimaryMetricSourceModalOpen: booleanisPrimarySharedMetricModalOpen: boolean+ isQuickSurveyModalOpen: booleanisReleaseConditionsModalOpen: booleanisResumeExperimentModalOpen: booleanisRunningTimeConfigModalOpen: boolean@@ -37,6 +40,9 @@ export interface modalsLogicActions {updateFlag: (flag: FeatureFlagType) => {flag: FeatureFlagType} // featureFlagsLogic+ closeCopyToProjectModal: () => {+ value: true+ }closeCupedModal: () => {value: true}@@ -46,6 +52,9 @@ export interface modalsLogicActions {closeDistributionModal: () => {value: true}+ closeDuplicateExperimentModal: () => {+ value: true+ }closeEditConclusionModal: () => {value: true}@@ -70,6 +79,9 @@ export interface modalsLogicActions {closePrimarySharedMetricModal: () => {value: true}+ closeQuickSurveyModal: () => {+ value: true+ }closeReleaseConditionsModal: () => {value: true}@@ -94,6 +106,9 @@ export interface modalsLogicActions {closeVariantDeltaTimeseriesModal: () => {value: true}+ openCopyToProjectModal: () => {+ value: true+ }openCupedModal: () => {value: true}@@ -103,6 +118,9 @@ export interface modalsLogicActions {openDistributionModal: () => {value: true}+ openDuplicateExperimentModal: () => {+ value: true+ }openEditConclusionModal: () => {value: true}@@ -127,6 +145,9 @@ export interface modalsLogicActions {openPrimarySharedMetricModal: (sharedMetricId: SharedMetric['id'] | null) => {sharedMetricId: number | null}+ openQuickSurveyModal: () => {+ value: true+ }openReleaseConditionsModal: () => {value: true}@@ -200,6 +221,12 @@ export const modalsLogic = kea<modalsLogicType>([closeVariantDeltaTimeseriesModal: true,openRunningTimeConfigModal: true,closeRunningTimeConfigModal: true,+ openDuplicateExperimentModal: true,+ closeDuplicateExperimentModal: true,+ openCopyToProjectModal: true,+ closeCopyToProjectModal: true,+ openQuickSurveyModal: true,+ closeQuickSurveyModal: true,}),reducers({isExperimentCollectionGoalModalOpen: [@@ -335,5 +362,26 @@ export const modalsLogic = kea<modalsLogicType>([closeRunningTimeConfigModal: () => false,},],+ isDuplicateExperimentModalOpen: [+ false,+ {+ openDuplicateExperimentModal: () => true,+ closeDuplicateExperimentModal: () => false,+ },+ ],+ isCopyToProjectModalOpen: [+ false,+ {+ openCopyToProjectModal: () => true,+ closeCopyToProjectModal: () => false,+ },+ ],+ isQuickSurveyModalOpen: [+ false,+ {+ openQuickSurveyModal: () => true,+ closeQuickSurveyModal: () => false,+ },+ ],}),])diff --git a/frontend/src/scenes/experiments/stories/ExperimentStoppedWithConclusion.stories.tsx b/frontend/src/scenes/experiments/stories/ExperimentStoppedWithConclusion.stories.tsxnew file mode 100644index 000000000000..05b583e85a49--- /dev/null+++ b/frontend/src/scenes/experiments/stories/ExperimentStoppedWithConclusion.stories.tsx@@ -0,0 +1,60 @@+import { Meta, StoryObj } from '@storybook/react'++import { makeDelay } from 'lib/utils/async'+import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'+import EXPERIMENT_WITH_FUNNEL_METRIC from '~/mocks/fixtures/api/experiments/experiment_with_funnel_metric.json'+import EXPOSURE_QUERY_RESULT from '~/mocks/fixtures/api/experiments/exposure_query_result.json'+import FUNNELS_METRIC_RESULT from '~/mocks/fixtures/api/experiments/funnel_metric_result.json'+import { NodeKind } from '~/queries/schema/schema-general'++const EXPERIMENT_STOPPED_WITH_CONCLUSION = {+ ...EXPERIMENT_WITH_FUNNEL_METRIC,+ end_date: '2025-01-20T14:39:00Z',+ conclusion: 'won',+ conclusion_comment: 'The test variant improved conversion by 12%, so we shipped it to everyone.',+}++const meta: Meta = {+ component: App,+ title: 'Scenes-App/Experiments',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2025-01-27',+ pageUrl: urls.experiment(EXPERIMENT_STOPPED_WITH_CONCLUSION.id),+ },+ decorators: [+ mswDecorator({+ get: {+ [`/api/projects/:team_id/experiments/${EXPERIMENT_STOPPED_WITH_CONCLUSION.id}/`]:+ EXPERIMENT_STOPPED_WITH_CONCLUSION,+ [`/api/projects/:team_id/experiment_holdouts`]: [],+ [`/api/projects/:team_id/experiment_saved_metrics/`]: [],+ [`/api/projects/:team_id/feature_flags/${EXPERIMENT_STOPPED_WITH_CONCLUSION.feature_flag.id}/`]: {},+ [`/api/projects/:team_id/feature_flags/${EXPERIMENT_STOPPED_WITH_CONCLUSION.feature_flag.id}/status/`]:+ {},+ [`/api/environments/:team_id/default_release_conditions/`]: [],+ },+ post: {+ '/api/environments/:team_id/query/:kind': async ({ request }) => {+ const body = (await request.json()) as Record<string, any>++ if (body.query.kind === NodeKind.ExperimentExposureQuery) {+ return [200, EXPOSURE_QUERY_RESULT]+ }++ return [200, FUNNELS_METRIC_RESULT]+ },+ },+ }),+ ],+}+export default meta++type Story = StoryObj<{}>++// Small delay to ensure charts render completely+export const ExperimentStoppedWithConclusion: Story = { play: makeDelay(500) }