: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): keep the sibling tabs reachable with no workflows yet (#93761)
Rafael Audibert107203891a63
diff --git a/.agents/skills/building-product-empty-states/SKILL.md b/.agents/skills/building-product-empty-states/SKILL.mdindex 807f37fb222d..aa82617a8d55 100644--- a/.agents/skills/building-product-empty-states/SKILL.md+++ b/.agents/skills/building-product-empty-states/SKILL.md@@ -67,6 +67,7 @@ Statuses: `loading` (not yet known - the gate holds a spinner, never flashes the- **Wizard vs primary action**: SDK-installed products set `wizard: { slug }` (the slug must exist in `@posthog/wizard`); creation-first products (flags, surveys) set `primaryAction` instead. Self-hosted degrades automatically: no cloud → the terminal hides and the manual path is promoted. If the create action needs hooks (e.g. it opens PostHog AI via `useMaxTool`, like user research's "New topic"), provide a `PrimaryAction` component instead of `primaryAction` - it renders in the same slot and takes precedence.- **Permissions and selectors on the primary action**: set `primaryAction.accessControl` to the same resource type and level the gated scene's own create button uses. Without it a viewer gets an enabled button and only learns they can't create when the form fails to save. Set `primaryAction.dataAttr` to the attr that scene button carries, so an end-to-end spec keeps one selector whether it lands on the scene or the empty state. A `PrimaryAction` component wraps its own `AccessControlAction`.- **`featureFlag`**: set it when the scene is already flag-gated (so the scene's own gate keeps handling flag-off) or to roll the empty state out gradually.+- **Scene modules that serve more than one surface**: `scenes` narrows where the gate applies, and omitting it gates everything the module serves. A plain scene id covers that whole scene (web analytics gates only `Scene.WebAnalyticsWebVitals`). When one scene id serves several tabs, pass `{ scene, tabs }` and list every value of the `tab` route param you gate, including `undefined` for the URL with no tab segment - `products/workflows/frontend/emptyState/workflowsEmptyState.tsx` gates its workflow list while channels, opt-outs, suppression, and reputation stay reachable with no workflows yet. Gating the scene instead would take those tabs down with it.- **Hedgehog**: a `pngHoggie(...)`-wrapped module — import only inside the product chunk (eager-graph guard: `frontend/bin/check-eager-graph.mjs`). Never hardcode image URLs (e.g. Cloudinary) — `@posthog/brand` assets only.- **`text` is keyed by mode**: provide the `needs-setup` base; add a `waiting-for-data` entry only if your product has that middle state (missing fields fall back to the base). Sentence case, benefit-first, no AI tells (see "User-facing copy" in `CLAUDE.md`).- **Key `primaryAction` by mode when it only fits one**: a one-click opt-in ("Enable session recording") is done once the status is `waiting-for-data`, and clicking it again re-sends the same team update. Pass `primaryAction: { 'needs-setup': { ... } }` and the button, along with the `hint` that introduces it, leaves the waiting screen. A single flat action still covers both modes - keep that when it reads correctly either way (support's "Open support settings").diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.test.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.test.tsxindex 507ff45418c9..dddfd4d26e70 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.test.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.test.tsx@@ -2,6 +2,9 @@ import { cleanup, render, screen } from '@testing-library/react'import { kea, path } from 'kea'import { router } from 'kea-router'+import { sceneLogic } from 'scenes/sceneLogic'+import { Scene } from 'scenes/sceneTypes'+import { useMocks } from '~/mocks/jest'import { ProductKey } from '~/queries/schema/schema-general'import { initKeaTests } from '~/test/init'@@ -24,6 +27,17 @@ const noopStatusLogic = kea([path(['lib', 'components', 'ProductEmptyState', 'teconst emptyState: SceneProductEmptyState = { config, statusLogic: noopStatusLogic }+const tabScopedEmptyState: SceneProductEmptyState = {+ config: {+ ...config,+ productKey: ProductKey.WORKFLOWS,+ productName: 'Workflows',+ text: { 'needs-setup': { headline: 'Set up workflows', lead: 'Lead' } },+ },+ statusLogic: noopStatusLogic,+ scenes: [{ scene: Scene.Workflows, tabs: [undefined, 'workflows'] }],+}+describe('ProductEmptyStateGate', () => {beforeEach(() => {useMocks({@@ -61,4 +75,28 @@ describe('ProductEmptyStateGate', () => {expect(!!screen.queryByText('Set up experiments')).toBe(expectedForced)expect(!!screen.queryByText('the real scene')).toBe(!expectedForced)})++ // One scene serves every workflows tab, so gating the scene would take the sibling tabs+ // down with it: a project with no workflows could not reach channels or opt-outs at all.+ it.each([+ [undefined, true],+ ['workflows', true],+ ['channels', false],+ ['opt-outs', false],+ ])('gates the %s tab: %s', (tab, expectedGated) => {+ const statusLogic = productSetupStatusLogic({ productKey: ProductKey.WORKFLOWS })+ statusLogic.mount()+ statusLogic.actions.setDetectedStatus('needs-setup')+ sceneLogic.mount()+ sceneLogic.actions.setScene(Scene.Workflows, undefined, { params: {}, searchParams: {}, hashParams: {} })++ render(+ <ProductEmptyStateGate emptyState={tabScopedEmptyState} params={{ tab }}>+ <div>the real scene</div>+ </ProductEmptyStateGate>+ )++ expect(!!screen.queryByText('Set up workflows')).toBe(expectedGated)+ expect(!!screen.queryByText('the real scene')).toBe(!expectedGated)+ })})diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsxindex 835625d612bf..93fe6dc9e883 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx@@ -14,7 +14,7 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { ProductEmptyState } from './ProductEmptyState'import { productSetupStatusLogic } from './productSetupStatusLogic'import { SetupReminderContext } from './setupReminderContext'-import type { ProductEmptyStateConfig, ProductEmptyStateMode, SceneProductEmptyState } from './types'+import type { GatedScene, ProductEmptyStateConfig, ProductEmptyStateMode, SceneProductEmptyState } from './types'/*** Search param that puts the setup screen on a scene that already has data, so anyone can@@ -37,8 +37,21 @@ function forcedModeFromParam(value: unknown): ProductEmptyStateMode | null {return null}+function coversCurrentSurface(+ gated: GatedScene,+ activeSceneId: string | null,+ params: Record<string, string | undefined>+): boolean {+ if (typeof gated === 'string') {+ return gated === activeSceneId+ }+ return gated.scene === activeSceneId && gated.tabs.includes(params.tab)+}+export interface ProductEmptyStateGateProps {emptyState: SceneProductEmptyState+ /** The scene's route params, as passed to the scene component. Read by `scenes`. */+ params?: Record<string, string | undefined>children: ReactNode}@@ -55,16 +68,19 @@ export interface ProductEmptyStateGateProps {* `?empty_state=1` on any gated scene forces the setup screen regardless of status,* so the screen can be reviewed on a project that already has data.*/-export function ProductEmptyStateGate({ emptyState, children }: ProductEmptyStateGateProps): JSX.Element {+export function ProductEmptyStateGate({ emptyState, params, children }: ProductEmptyStateGateProps): JSX.Element {const { featureFlags } = useValues(featureFlagLogic)const { activeSceneId } = useValues(sceneLogic)- // When the empty state is flag-gated or scoped to specific scenes, stay a strict+ // When the empty state is flag-gated or scoped to specific scenes or tabs, stay a strict// no-op otherwise — don't even mount detection (the inner component mounts it).if (emptyState.featureFlag && !featureFlags[emptyState.featureFlag]) {return <>{children}</>}- if (emptyState.scenes && (!activeSceneId || !emptyState.scenes.includes(activeSceneId))) {+ if (+ emptyState.scenes &&+ !emptyState.scenes.some((gated) => coversCurrentSurface(gated, activeSceneId, params ?? {}))+ ) {return <>{children}</>}return <ProductEmptyStateGateInner emptyState={emptyState}>{children}</ProductEmptyStateGateInner>diff --git a/frontend/src/lib/components/ProductEmptyState/types.ts b/frontend/src/lib/components/ProductEmptyState/types.tsindex c22f6f89142c..7c9ceee07592 100644--- a/frontend/src/lib/components/ProductEmptyState/types.ts+++ b/frontend/src/lib/components/ProductEmptyState/types.ts@@ -166,10 +166,21 @@ export interface SceneProductEmptyState {*/featureFlag?: FeatureFlagKey/**- * Only gate these scene ids (`Scene` values), for scene modules that serve- * several scenes (tabs) where just one is the product being gated - e.g. the- * web analytics module, where only the web vitals tab has a setup state.- * Omit to gate every scene the module serves.+ * Only gate these surfaces, for a scene module that serves more than one. Omit to gate+ * every scene the module serves.+ *+ * A plain scene id covers that whole scene, which is all the web analytics module needs:+ * its web vitals tab is a scene of its own. A scene that serves several tabs under ONE+ * scene id needs the object form, because gating the scene would take the sibling tabs+ * down with it - workflows serves channels, opt-outs, suppression, and reputation, which+ * a person may well configure before a first workflow exists.*/- scenes?: string[]+ scenes?: GatedScene[]}++/**+ * A scene id, or a scene id narrowed to some of its tabs. `tabs` lists every value of the+ * `tab` route param the gate covers, including `undefined` for the URL that carries no tab+ * segment - `/workflows` and `/workflows/workflows` are the same tab.+ */+export type GatedScene = string | { scene: string; tabs: (string | undefined)[] }diff --git a/frontend/src/scenes/App.tsx b/frontend/src/scenes/App.tsxindex 660ad00e8f4d..8fffca1d0493 100644--- a/frontend/src/scenes/App.tsx+++ b/frontend/src/scenes/App.tsx@@ -164,7 +164,9 @@ function AppScene(): JSX.Element | null {// Scenes that declare an empty state are gated behind the product's// setup screen until the product has data (or the user skips).const resolvedNode = emptyState ? (- <ProductEmptyStateGate emptyState={emptyState}>{sceneNode}</ProductEmptyStateGate>+ <ProductEmptyStateGate emptyState={emptyState} params={activeSceneComponentParams}>+ {sceneNode}+ </ProductEmptyStateGate>) : (sceneNode)diff --git a/products/workflows/frontend/emptyState/workflowsEmptyState.tsx b/products/workflows/frontend/emptyState/workflowsEmptyState.tsxindex 947319ce1817..3a3e69f35c9a 100644--- a/products/workflows/frontend/emptyState/workflowsEmptyState.tsx+++ b/products/workflows/frontend/emptyState/workflowsEmptyState.tsx@@ -3,6 +3,7 @@ import { IconDecisionTree } from '@posthog/icons'import { pngHoggie } from 'lib/brand/hoggies'import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'+import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { ProductKey } from '~/queries/schema/schema-general'@@ -14,6 +15,10 @@ const HedgehogWorkflows = pngHoggie(workflowsPng)export const workflowsEmptyState: SceneProductEmptyState = {statusLogic: workflowsSetupLogic,+ // One scene serves every tab here, but only the workflow list is the product being gated.+ // Channels, the message library, opt-outs, suppression, and reputation configure resources+ // that stand on their own, and a person often sets a channel up before a first workflow.+ scenes: [{ scene: Scene.Workflows, tabs: [undefined, 'workflows'] }],config: {productKey: ProductKey.WORKFLOWS,productName: 'Workflows',