: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
fix(workflows): open the workflow from a link without a tab (#123882)
Harley Alexander22fabbe005b9
diff --git a/products/workflows/frontend/WorkflowsScene.test.ts b/products/workflows/frontend/WorkflowsScene.test.tsnew file mode 100644index 000000000000..44203b5c6804--- /dev/null+++ b/products/workflows/frontend/WorkflowsScene.test.ts@@ -0,0 +1,26 @@+import { router } from 'kea-router'++import { removeProjectIdIfPresent } from 'lib/utils/kea-router'++import { initKeaTests } from '~/test/init'++import { workflowsSceneLogic } from './WorkflowsScene'++const WORKFLOW_ID = '0190f1a2-7c3b-7000-8000-000000000001'++describe('workflowsSceneLogic', () => {+ beforeEach(() => {+ initKeaTests()+ workflowsSceneLogic.mount()+ })++ it.each([+ ['a bare workflow id opens that workflow', `/workflows/${WORKFLOW_ID}`, `/workflows/${WORKFLOW_ID}/workflow`],+ ['a known tab stays on the list', '/workflows/templates', '/workflows/templates'],+ ['an unknown tab stays on the list', '/workflows/not-a-tab', '/workflows/not-a-tab'],+ ])('%s', (_, path, expectedPath) => {+ router.actions.push(path)++ expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(expectedPath)+ })+})diff --git a/products/workflows/frontend/WorkflowsScene.tsx b/products/workflows/frontend/WorkflowsScene.tsxindex 7ef8549feef0..f5f1b364f010 100644--- a/products/workflows/frontend/WorkflowsScene.tsx+++ b/products/workflows/frontend/WorkflowsScene.tsx@@ -8,6 +8,7 @@ import { AccessControlAction } from 'lib/components/AccessControlAction'import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonTabs } from 'lib/lemon-ui/LemonTabs'import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'+import { isUUIDLike } from 'lib/utils/guards'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'import { addProductIntent } from 'lib/utils/product-intents'import { capitalizeFirstLetter } from 'lib/utils/strings'@@ -153,6 +154,11 @@ export const workflowsSceneLogic = kea<workflowsSceneLogicType>([}},[urls.workflows(':tab' as WorkflowsSceneTab)]: ({ tab }) => {+ // A shared link often drops the tab segment, so `/workflows/<id>` lands here with the id as the tab.+ if (tab && isUUIDLike(tab)) {+ router.actions.replace(urls.workflow(tab, 'workflow'), router.values.searchParams)+ return+ }let possibleTab: WorkflowsSceneTab = (tab as WorkflowsSceneTab) ?? 'workflows'possibleTab = WORKFLOW_SCENE_TABS.includes(possibleTab) ? possibleTab : 'workflows'