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.

fix(workflows): let the email preview fill the step panel (#102974)

Meikel Ratz973f6b6f2564
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 66971ce91cdc..8c587ed7afd2 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6440,6 +6440,14 @@ snapshots:
hash: v1.k794b7964.28ef96bdb240694b8b0786bccdeec07dffc677410a0977d2b16d7794ccc85c14.cVh6dFIr01Hi6QIOwO31L9RqOP4rLQJUHKMucRSdljE
products-workflows-editor-configuration-panel--conditional-branch--light:
hash: v1.k794b7964.cf5243dc2191758d2b098416822df172ac32e54c51f7b8ff5d441fa54cdf9501.PUjF_kDSbjW4Kd9AJGy1JSIwipvVVWu4tZ4QSL9TumA
+ products-workflows-editor-configuration-panel--email--dark:
+ hash: v1.k794b7964.8bd1cbc2e385de536325edd73c88c9d7ca6c469d14c6801f9cf5893fbf59f363.I7QY9S5gNoHyFoLb41azlksnSKoKvszQM0s_BqKPkNE
+ products-workflows-editor-configuration-panel--email--light:
+ hash: v1.k794b7964.c76c115fc4b460ebf446dc8c8acd54688971e26283a01d301685ebeda2d3e2ea.qkOGhLmcF7sP8YNkidOuc8zElAwseH99JkZFujJd6r4
+ products-workflows-editor-configuration-panel--email-in-side-panel--dark:
+ hash: v1.k794b7964.faf53b9a4d005ad3060d92afe75740f31b4c5ab5840ecc27424a071be838b917.WTXI5PDrqeV7jVvJPKBLlk2IAamg8rvuE401W9jfW2U
+ products-workflows-editor-configuration-panel--email-in-side-panel--light:
+ hash: v1.k794b7964.9e86cca822a41ea7e1c64e06b6864854ab6b5b1dbb294c9b0f4c31fcbaa18219.mIezlbVnd2sl6GYR87DTOpzdGxEzrcEyp1vIhYqzBYI
products-workflows-editor-configuration-panel--logs--dark:
hash: v1.k794b7964.beabe0c2c69154a7e7b8e5709226f710bbb707c7a2a96ea3b908e7b5348ad177.l8BzDM-8b8Z6jYzADnoiRggNuU02m3lgVa6vtNm2VOw
products-workflows-editor-configuration-panel--logs--light:
diff --git a/frontend/src/lib/components/CyclotronJob/CyclotronJobInputs.tsx b/frontend/src/lib/components/CyclotronJob/CyclotronJobInputs.tsx
index e8f9aa2182db..4e713d82f037 100644
--- a/frontend/src/lib/components/CyclotronJob/CyclotronJobInputs.tsx
+++ b/frontend/src/lib/components/CyclotronJob/CyclotronJobInputs.tsx
@@ -75,6 +75,10 @@ export function coerceTemplateValueForDisplay(value: unknown, templating: 'hog'
return String(value)
}
+// An email input renders a preview that takes the height its host gives it, so every wrapper
+// between the host and the preview grows. Inert where the host is sized by its content.
+const isEmailInput = (type: CyclotronJobInputSchemaType['type']): boolean => type === 'email' || type === 'native_email'
+
const INPUT_TYPE_LIST = [
'string',
'number',
@@ -126,6 +130,9 @@ export type CyclotronJobInputsProps = {
emailSaveIndicator?: ReactNode
parentConfiguration?: CyclotronJobInputConfiguration
onInputSchemaChange?: (schema: CyclotronJobInputSchemaType[]) => void
+ // Classes for the column the inputs are laid out in, so a host with height to spare can let
+ // it grow (the workflow builder's step panel does this for email steps)
+ className?: string
showSource: boolean
sampleGlobalsWithInputs: CyclotronJobInvocationGlobalsWithInputs | null
}
@@ -142,6 +149,7 @@ export function CyclotronJobInputs({
emailSaveIndicator,
showSource,
sampleGlobalsWithInputs,
+ className,
}: CyclotronJobInputsProps): JSX.Element | null {
if (!configuration.inputs_schema?.length) {
return <span className="italic text-secondary">This function does not require any input variables.</span>
@@ -164,7 +172,7 @@ export function CyclotronJobInputs({
}}
>
<SortableContext disabled={!showSource} items={inputSchemaIds} strategy={verticalListSortingStrategy}>
- <div className="flex flex-col gap-3">
+ <div className={clsx('flex flex-col gap-3', className)}>
{configuration.inputs_schema
?.filter((i: CyclotronJobInputSchemaType) => !i.hidden)
.map((schema: CyclotronJobInputSchemaType) => {
@@ -977,6 +985,7 @@ function CyclotronJobInputWithSchema({
return (
<div
ref={setNodeRef}
+ className={clsx(isEmailInput(schema.type) && 'flex flex-1 flex-col')}
// eslint-disable-next-line react/forbid-dom-props
style={{
transform: CSS.Transform.toString(transform),
@@ -985,7 +994,7 @@ function CyclotronJobInputWithSchema({
>
{!editing ? (
<LemonField.Pure
- className="gap-1"
+ className={clsx('gap-1', isEmailInput(schema.type) && 'flex-1')}
error={error}
help={
<>
diff --git a/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx b/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx
index 37cbb13d6970..852ff3333b80 100644
--- a/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx
+++ b/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx
@@ -216,7 +216,7 @@ function DestinationEmailTemplaterForm({
</div>
</>
) : (
- <LemonField name="html" className="flex relative flex-col">
+ <LemonField name="html" className="flex relative flex-col flex-1">
{({ value }: ChildFunctionProps) => (
<>
<div
@@ -233,7 +233,14 @@ function DestinationEmailTemplaterForm({
/>
</div>
- <iframe srcDoc={value} sandbox="" title="Email template preview" className="flex-1" />
+ {/* The floor keeps the preview readable where the host gives it no
+ spare height to grow into */}
+ <iframe
+ srcDoc={value}
+ sandbox=""
+ title="Email template preview"
+ className="flex-1 min-h-40"
+ />
</>
)}
</LemonField>
@@ -735,7 +742,7 @@ function NativeEmailTemplaterForm({
</div>
</>
) : (
- <LemonField name="html" className="flex relative flex-col">
+ <LemonField name="html" className="flex relative flex-col flex-1">
{({ value }: ChildFunctionProps) => (
<>
<div
@@ -752,7 +759,14 @@ function NativeEmailTemplaterForm({
/>
</div>
- <iframe srcDoc={value} sandbox="" title="Email template preview" className="flex-1" />
+ {/* The floor keeps the preview readable where the host gives it no
+ spare height to grow into */}
+ <iframe
+ srcDoc={value}
+ sandbox=""
+ title="Email template preview"
+ className="flex-1 min-h-40"
+ />
</>
)}
</LemonField>
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx
index 58ee4a581299..0965a9e812aa 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx
@@ -6,6 +6,8 @@ import { useEffect } from 'react'
import { FEATURE_FLAGS } from 'lib/constants'
import { mswDecorator } from '~/mocks/browser'
+import _hogFunctionTemplatesDestinations from '~/mocks/fixtures/_hogFunctionTemplatesDestinations.json'
+import { HogFunctionTemplateType } from '~/types'
import { NEW_WORKFLOW, WorkflowLogicProps, workflowLogic } from '../../workflowLogic'
import { hogFlowEditorLogic, HogFlowEditorMode } from '../hogFlowEditorLogic'
@@ -14,6 +16,34 @@ import { HogFlowEditorPanel } from './HogFlowEditorPanel'
const LOGIC_PROPS: WorkflowLogicProps = { id: 'storybook-configuration-panel' }
+// The email template is hidden, so it is not in the shared destinations fixture. Mirrors
+// nodejs/src/cdp/templates/_destinations/email/email.template.ts.
+const EMAIL_TEMPLATE: HogFunctionTemplateType = {
+ id: 'template-email',
+ type: 'destination',
+ name: 'Email',
+ description: 'The email message to send. Configure the recipient, sender, subject, and content.',
+ status: 'hidden',
+ free: false,
+ code: '',
+ code_language: 'hog',
+ icon_url: '/static/posthog-icon.svg',
+ inputs_schema: [
+ {
+ type: 'native_email',
+ key: 'email',
+ label: 'Email message',
+ integration: 'email',
+ required: true,
+ secret: false,
+ description: 'The email message to send. Configure the recipient, sender, subject, and content.',
+ },
+ ],
+}
+
+const EMAIL_PREVIEW_HTML =
+ '<html><body style="margin:0;font-family:sans-serif"><div style="background:#1d1f27;color:#fff;padding:24px">PostHog</div><div style="padding:24px"><h1 style="margin:0 0 8px">Welcome aboard</h1><p>Your account is ready to go.</p></div></body></html>'
+
const PANEL_WORKFLOW: HogFlow = {
...NEW_WORKFLOW,
id: LOGIC_PROPS.id!,
@@ -60,6 +90,28 @@ const PANEL_WORKFLOW: HogFlow = {
},
},
},
+ {
+ id: 'email',
+ type: 'function_email',
+ name: 'Send welcome email',
+ description: 'Welcome the account to the product.',
+ config: {
+ template_id: 'template-email',
+ inputs: {
+ email: {
+ value: {
+ to: { email: '{{ person.properties.email }}', name: '' },
+ from: { email: '[email protected]', name: 'Example' },
+ subject: 'Welcome aboard',
+ preheader: '',
+ text: 'Your account is ready to go.',
+ html: EMAIL_PREVIEW_HTML,
+ },
+ templating: 'liquid',
+ },
+ },
+ },
+ },
{
id: 'conditional',
type: 'conditional_branch',
@@ -100,7 +152,8 @@ const PANEL_WORKFLOW: HogFlow = {
edges: [
{ from: 'trigger', to: 'delay', type: 'continue' },
{ from: 'delay', to: 'webhook', type: 'continue' },
- { from: 'webhook', to: 'conditional', type: 'continue' },
+ { from: 'webhook', to: 'email', type: 'continue' },
+ { from: 'email', to: 'conditional', type: 'continue' },
{ from: 'conditional', to: 'cohort', type: 'branch', index: 0 },
{ from: 'conditional', to: 'exit', type: 'branch', index: 1 },
{ from: 'conditional', to: 'exit', type: 'continue' },
@@ -113,6 +166,7 @@ const PANEL_WORKFLOW: HogFlow = {
type PanelStoryProps = {
mode: HogFlowEditorMode
selectedNodeId: string | null
+ layout?: 'floating' | 'panel'
}
const meta: Meta<typeof HogFlowEditorPanel> = {
@@ -127,6 +181,10 @@ const meta: Meta<typeof HogFlowEditorPanel> = {
get: {
'/api/environments/:team_id/hog_flows/:id/': PANEL_WORKFLOW,
'/api/environments/:team_id/messaging_categories': { count: 0, results: [] },
+ '/api/projects/:team_id/hog_function_templates': {
+ count: _hogFunctionTemplatesDestinations.results.length + 1,
+ results: [...(_hogFunctionTemplatesDestinations.results as unknown[]), EMAIL_TEMPLATE],
+ },
},
patch: {
'/api/environments/:team_id/hog_flows/:id/': async ({ request }) => [
@@ -157,7 +215,7 @@ const meta: Meta<typeof HogFlowEditorPanel> = {
}
export default meta
-function PanelStory({ mode, selectedNodeId }: PanelStoryProps): JSX.Element {
+function PanelStory({ mode, selectedNodeId, layout = 'floating' }: PanelStoryProps): JSX.Element {
const { originalWorkflow } = useValues(workflowLogic(LOGIC_PROPS))
const { nodes } = useValues(hogFlowEditorLogic(LOGIC_PROPS))
const { setWorkflowValues } = useActions(workflowLogic(LOGIC_PROPS))
@@ -180,9 +238,18 @@ 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">
- <HogFlowEditorPanel />
- </div>
+ {layout === 'panel' ? (
+ // Mirrors the tree view's host: a full-height row where the panel sits
+ // beside the tree, so the panel is as tall as the editor
+ <div className="@container/workflow-editor relative flex h-screen overflow-hidden @max-[48rem]/workflow-editor:flex-col @max-[48rem]/workflow-editor:overflow-y-auto">
+ <div className="min-w-0 flex-1 bg-background" />
+ <HogFlowEditorPanel layout="panel" />
+ </div>
+ ) : (
+ <div className="relative h-screen w-[37rem] overflow-hidden bg-surface-primary">
+ <HogFlowEditorPanel />
+ </div>
+ )}
</BindLogic>
</BindLogic>
</ReactFlowProvider>
@@ -203,6 +270,12 @@ Trigger.args = { mode: 'build', selectedNodeId: 'trigger' }
export const Webhook: StoryFn<PanelStoryProps> = Template.bind({})
Webhook.args = { mode: 'build', selectedNodeId: 'webhook' }
+export const Email: StoryFn<PanelStoryProps> = Template.bind({})
+Email.args = { mode: 'build', selectedNodeId: 'email' }
+
+export const EmailInSidePanel: StoryFn<PanelStoryProps> = Template.bind({})
+EmailInSidePanel.args = { mode: 'build', selectedNodeId: 'email', layout: 'panel' }
+
export const ConditionalBranch: StoryFn<PanelStoryProps> = Template.bind({})
ConditionalBranch.args = { mode: 'build', selectedNodeId: 'conditional' }
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuildDetail.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuildDetail.tsx
index e934d0f8cee8..1a9675215087 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuildDetail.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuildDetail.tsx
@@ -90,6 +90,10 @@ export function HogFlowEditorPanelBuildDetail(): JSX.Element | null {
direction="vertical"
className="flex-1 min-h-0"
innerClassName="flex flex-col gap-2 p-3"
+ // The scroll area wraps the step config in its own content element, so the flex
+ // column above stops there. An email step's preview takes the height the panel
+ // gives it, so that wrapper has to grow as well.
+ contentClassName={isEmailAction(action) ? 'flex flex-1 flex-col' : undefined}
styledScrollbars
>
<ErrorBoundary exceptionProps={{ feature: 'workflow-step-config' }}>
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/components/HogFlowFunctionConfiguration.tsx b/products/workflows/frontend/Workflows/hogflows/steps/components/HogFlowFunctionConfiguration.tsx
index 23ab2bed95ed..db9dea063d15 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/components/HogFlowFunctionConfiguration.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/components/HogFlowFunctionConfiguration.tsx
@@ -226,6 +226,9 @@ export function HogFlowFunctionConfiguration({
const renderInputs = (schema: typeof inputsSchema): JSX.Element => (
<CyclotronJobInputs
+ // The email step is just its message, so the preview takes whatever height the panel
+ // has left rather than sitting above a blank gap
+ className={isEmailStep ? 'flex-1' : undefined}
errors={errors}
warnings={warnings}
emailFieldErrors={emailFieldErrors}