: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
refactor(workflows): share the ai-first create page and handoff logic (#102212)
Harley Alexander10f20fe8c86b
diff --git a/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsx b/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsxnew file mode 100644index 000000000000..2cbcdafdc64d--- /dev/null+++ b/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsx@@ -0,0 +1,90 @@+import { useActions, useValues } from 'kea'+import { useEffect } from 'react'++import { LemonBanner } from '@posthog/lemon-ui'++import { cn } from 'lib/utils/css-classes'+import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'+import { SuggestionCard } from 'scenes/max/components/SuggestionCard'++import { runnerPanelLogic } from 'products/posthog_ai/frontend/api/logics'+import { SidePanelRunner } from 'products/posthog_ai/frontend/api/runner'++import { AiFirstHandoffLogicProps, aiFirstHandoffLogic } from './aiFirstHandoffLogic'++export interface AiFirstSuggestion {+ title: string+ description: string+ prompt: string+}++export interface AiFirstCreateSceneProps {+ handoff: AiFirstHandoffLogicProps+ /** Banner copy that says what this page trials. */+ banner: string+ escapeHatchLabel: string+ onEscapeHatch: () => void+ suggestions: AiFirstSuggestion[]+ suggestionIcon: JSX.Element+ /** Rendered between the composer and the suggestions while no run is active, e.g. a row of starting points. */+ belowComposer?: React.ReactNode+ // pinned: `data-attr` root. The page, its escape hatch (`-open-editor`) and its cards (`-suggestion`) hang off it.+ dataAttr: string+}++/** An AI-first "new entity" page: the side panel's runner rendered full page, with a way back to the editor. */+export function AiFirstCreateScene({+ handoff,+ banner,+ escapeHatchLabel,+ onEscapeHatch,+ suggestions,+ suggestionIcon,+ belowComposer,+ dataAttr,+}: AiFirstCreateSceneProps): JSX.Element {+ const { composerShown, escapeHatchClicked, fillComposer } = useActions(aiFirstHandoffLogic(handoff))+ useEffect(() => composerShown(), [composerShown])+ const { activeCreation } = useValues(runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }))++ return (+ // Natural height while drafting so the cards sit under the composer; full page once a run starts.+ <div className="flex flex-col grow min-h-0" data-attr={dataAttr}>+ {/* The escape hatch stays up during a run, so a turn that never creates the entity has a way out. */}+ <LemonBanner+ type="ai"+ className="m-2 shrink-0"+ action={{+ children: escapeHatchLabel,+ onClick: () => {+ escapeHatchClicked()+ onEscapeHatch()+ },+ 'data-attr': `${dataAttr}-open-editor`,+ }}+ >+ {banner}+ </LemonBanner>+ <div className={cn('flex flex-col', activeCreation ? 'grow min-h-0' : 'shrink-0 mt-auto')}>+ <SidePanelRunner panelId={MAX_SIDE_PANEL_ID} />+ </div>+ {!activeCreation && (+ <div className="flex flex-col items-center gap-4 shrink-0 pb-6 mb-auto">+ {belowComposer}+ <div className="grid grid-cols-1 @min-[40rem]/main-content:grid-cols-2 gap-1 w-full max-w-2xl px-4">+ {suggestions.map((suggestion) => (+ <SuggestionCard+ key={suggestion.prompt}+ title={suggestion.title}+ description={suggestion.description}+ icon={suggestionIcon}+ onClick={() => fillComposer(suggestion.prompt)}+ data-attr={`${dataAttr}-suggestion`}+ />+ ))}+ </div>+ </div>+ )}+ </div>+ )+}diff --git a/products/workflows/frontend/Workflows/newWorkflowAgentLogic.test.ts b/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.test.tssimilarity index 53%rename from products/workflows/frontend/Workflows/newWorkflowAgentLogic.test.tsrename to frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.test.tsindex 7078b3c33975..f29377676a0d 100644--- a/products/workflows/frontend/Workflows/newWorkflowAgentLogic.test.ts+++ b/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.test.ts@@ -14,17 +14,16 @@ import { SidePanelTab } from '~/types'import { composerSeedLogic, runnerPanelLogic, toolStreamEventsLogic } from 'products/posthog_ai/frontend/api/logics'import type { ToolStreamEvent } from 'products/posthog_ai/frontend/api/types'-import { newWorkflowAgentLogic } from './newWorkflowAgentLogic'+import { AiFirstHandoffLogicProps, aiFirstHandoffLogic } from './aiFirstHandoffLogic'-const WORKFLOW_ID = '2f1e9c3a-5b7d-4e8f-9a0b-1c2d3e4f5a6b'-const OLDER_ID = '7a1b2c3d-0000-4e8f-9a0b-1c2d3e4f5a6b'+const CREATED_ID = '2f1e9c3a-5b7d-4e8f-9a0b-1c2d3e4f5a6b'const NAME = 'Win back inactive users'function createEvent(overrides: Partial<ToolStreamEvent>): ToolStreamEvent {return {streamKey: 'draft-1',toolCallId: 'call-1',- toolName: 'workflows-create',+ toolName: 'things-create',rawToolName: 'exec',phase: 'completed',source: 'live',@@ -32,7 +31,7 @@ function createEvent(overrides: Partial<ToolStreamEvent>): ToolStreamEvent {toolCallId: 'call-1',rawServerName: 'posthog',rawToolName: 'exec',- input: { command: `call workflows-create ${JSON.stringify({ name: NAME })}` },+ input: { command: `call things-create ${JSON.stringify({ name: NAME })}` },// Large creates come back as a "saved to file" notice, so the id never rides the output.output: { content: 'Error: result exceeds maximum allowed tokens.', isError: false },status: 'completed',@@ -42,29 +41,28 @@ function createEvent(overrides: Partial<ToolStreamEvent>): ToolStreamEvent {}}-describe('newWorkflowAgentLogic', () => {- let logic: ReturnType<typeof newWorkflowAgentLogic.build>+describe('aiFirstHandoffLogic', () => {+ let logic: ReturnType<typeof aiFirstHandoffLogic.build>+ let findCreatedId: jest.Mock<Promise<string | null>, [Record<string, unknown> | undefined]>++ const handoff = (): AiFirstHandoffLogicProps => ({+ toolName: 'things-create',+ findCreatedId,+ urlFor: (id) => `/things/${id}`,+ notOpenedMessage: 'Your thing was created, but it could not be opened.',+ eventPrefix: 'thing ai composer',+ createdEvent: 'thing ai composer created thing',+ createdIdProperty: 'thing_id',+ })beforeEach(() => {- useMocks({- ...maxMocks,- get: {- ...maxMocks.get,- // Ordered by update time like the real list, so the same-named older draft comes first.- '/api/environments/:team_id/hog_flows/': {- results: [- { id: OLDER_ID, name: NAME, created_at: '2026-09-01T00:00:00Z' },- { id: WORKFLOW_ID, name: NAME, created_at: '2026-09-15T00:00:00Z' },- ],- count: 2,- },- },- })+ useMocks(maxMocks)initKeaTests()+ findCreatedId = jest.fn(async (innerInput) => (innerInput?.name === NAME ? CREATED_ID : null))sidePanelStateLogic.mount()sidePanelStateLogic.actions.setSidePanelAvailable(true)- router.actions.push('/workflows/new/workflow', {}, {})- logic = newWorkflowAgentLogic()+ router.actions.push('/things/new', {}, {})+ logic = aiFirstHandoffLogic(handoff())logic.mount()runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }).actions.setActiveCreation({ streamKey: 'draft-1' })})@@ -98,27 +96,46 @@ describe('newWorkflowAgentLogic', () => {seeds.unmount()})- it('opens the side panel and routes to the draft once this run creates a workflow', async () => {+ // The exec path keeps the created record on the result's metadata. Names are not unique, so a record's id+ // wins over the name lookup, which only covers a truncated output.+ it.each([+ {+ name: 'the id on the output record',+ output: {+ content: [{ type: 'text', text: 'Created' }],+ _meta: { 'com.posthog.mcp/app_data': { id: CREATED_ID, name: NAME } },+ },+ lookups: 0,+ },+ {+ name: 'a name lookup when the output carries no record',+ output: { content: 'Error: result exceeds maximum allowed tokens.', isError: false },+ lookups: 1,+ },+ ])('opens the side panel and routes to the entity by $name', async ({ output, lookups }) => {await expectLogic(logic, () => {- toolStreamEventsLogic.actions.emitToolEvent(createEvent({}))+ toolStreamEventsLogic.actions.emitToolEvent(+ createEvent({ invocation: { ...createEvent({}).invocation, output } })+ )}).toFinishAllListeners()+ expect(findCreatedId).toHaveBeenCalledTimes(lookups)expect(sidePanelStateLogic.values.selectedTab).toBe(SidePanelTab.Max)expect(sidePanelStateLogic.values.sidePanelOpen).toBe(true)- expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe(`/workflows/${WORKFLOW_ID}/workflow`)+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe(`/things/${CREATED_ID}`)})- // The draft is already saved, so a lookup that fails or matches nothing must say where it went.+ // The entity is already saved, so a lookup that fails or matches nothing must say where it went.it.each([- { name: 'the lookup fails', response: () => [500, { detail: 'boom' }] },- { name: 'no workflow matches', response: () => [200, { results: [], count: 0 }] },+ { name: 'the lookup fails', finder: () => Promise.reject(new Error('boom')) },+ { name: 'nothing matches', finder: () => Promise.resolve(null) },{name: 'the create call sent no name',- overrides: { invocation: { input: { command: 'call workflows-create {}' } } },+ overrides: { invocation: { input: { command: 'call things-create {}' } } },},- ])('says the draft could not be opened when $name', async ({ response, overrides }) => {- if (response) {- useMocks({ get: { '/api/environments/:team_id/hog_flows/': response } })+ ])('says the entity could not be opened when $name', async ({ finder, overrides }) => {+ if (finder) {+ findCreatedId.mockImplementation(finder)}const toast = jest.spyOn(lemonToast, 'error')@@ -128,25 +145,46 @@ describe('newWorkflowAgentLogic', () => {)}).toFinishAllListeners()- expect(toast).toHaveBeenCalledTimes(1)+ expect(toast).toHaveBeenCalledWith('Your thing was created, but it could not be opened.')expect(sidePanelStateLogic.values.sidePanelOpen).toBe(false)- expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe('/workflows/new/workflow')+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe('/things/new')toast.mockRestore()})+ // The panel logic outlives this page, so the lookup's continuation must not route from a page left behind.+ it('does not route once the page is left during the lookup', async () => {+ const flush = (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0))+ const panel = runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID })+ panel.mount()+ let resolveFinder: (id: string | null) => void = () => {}+ findCreatedId.mockImplementation(() => new Promise((resolve) => (resolveFinder = resolve)))++ toolStreamEventsLogic.actions.emitToolEvent(createEvent({}))+ await flush()+ logic.unmount()+ resolveFinder(CREATED_ID)+ await flush()++ expect(sidePanelStateLogic.values.sidePanelOpen).toBe(false)+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe('/things/new')++ panel.unmount()+ })+// The bus is global: a replay, another run's create, or a still-streaming call must not move the user.it.each([{ name: 'a replayed event', overrides: { source: 'replay' as const } },{ name: 'another stream', overrides: { streamKey: 'other-run' } },{ name: 'an unfinished call', overrides: { phase: 'started' as const } },- { name: 'a different tool', overrides: { toolName: 'workflows-get' } },+ { name: 'a different tool', overrides: { toolName: 'things-get' } },])('ignores $name', async ({ overrides }) => {await expectLogic(logic, () => {toolStreamEventsLogic.actions.emitToolEvent(createEvent(overrides))}).toFinishAllListeners()+ expect(findCreatedId).not.toHaveBeenCalled()expect(sidePanelStateLogic.values.sidePanelOpen).toBe(false)- expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe('/workflows/new/workflow')+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe('/things/new')})})diff --git a/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.ts b/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.tsnew file mode 100644index 000000000000..8cb0a58dd748--- /dev/null+++ b/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.ts@@ -0,0 +1,205 @@+import { LogicWrapper, MakeLogicType, actions, connect, kea, key, listeners, path, props } from 'kea'+import { router } from 'kea-router'+import posthog from 'posthog-js'++import { lemonToast } from 'lib/lemon-ui/LemonToast'+import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'++import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'+import { SidePanelTab } from '~/types'++import {+ composerSeedLogic,+ getToolOutputRecord,+ resolveToolCall,+ runnerPanelLogic,+ toolStreamEventsLogic,+} from 'products/posthog_ai/frontend/api/logics'+import type { ActiveCreation, ComposerSeed } from 'products/posthog_ai/frontend/api/logics'+import type { ToolStreamEvent } from 'products/posthog_ai/frontend/api/types'++export interface AiFirstHandoffLogicProps {+ /** MCP tool whose completed call means the entity exists. One handoff instance per tool. */+ toolName: string+ /**+ * Fallback for a completed call whose output carries no created record. Finds the entity from the+ * call's parsed input. Returns null when it cannot say which one.+ */+ findCreatedId: (innerInput: Record<string, unknown> | undefined) => Promise<string | null>+ /** The editor page for the created entity. */+ urlFor: (id: string) => string+ /** Toast for a saved entity the page could not open. Say where to find it. */+ notOpenedMessage: string+ // pinned: analytics event names. The surface's events are `${eventPrefix} viewed`, `${eventPrefix} submitted`,+ // `${eventPrefix} escape hatch clicked`, and `createdEvent` with the id under `createdIdProperty`.+ eventPrefix: string+ createdEvent: string+ createdIdProperty: string+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface aiFirstHandoffLogicValues {+ activeCreation: ActiveCreation | null // runnerPanelLogic+ selectedTab: SidePanelTab | null // sidePanelStateLogic+ sidePanelOpen: boolean // sidePanelStateLogic+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface aiFirstHandoffLogicActions {+ setSeed: (seed: ComposerSeed) => {+ seed: ComposerSeed+ } // composerSeedLogic+ clearActiveCreation: () => {+ value: true+ } // runnerPanelLogic+ setActiveCreation: (creation: ActiveCreation) => {+ creation: ActiveCreation+ } // runnerPanelLogic+ setHistoryExpanded: (expanded: boolean) => {+ expanded: boolean+ } // runnerPanelLogic+ closeSidePanel: (tab?: SidePanelTab | undefined) => {+ tab: SidePanelTab | undefined+ } // sidePanelStateLogic+ openSidePanel: (+ tab: SidePanelTab,+ options?: string | undefined+ ) => {+ options: string | undefined+ tab: SidePanelTab+ } // sidePanelStateLogic+ emitToolEvent: (event: ToolStreamEvent) => {+ event: ToolStreamEvent+ } // toolStreamEventsLogic+ composerShown: () => {+ value: true+ }+ escapeHatchClicked: () => {+ value: true+ }+ fillComposer: (prompt: string) => {+ prompt: string+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface aiFirstHandoffLogicMeta {+ key: string+}++export type aiFirstHandoffLogicType = MakeLogicType<+ aiFirstHandoffLogicValues,+ aiFirstHandoffLogicActions,+ AiFirstHandoffLogicProps,+ aiFirstHandoffLogicMeta+>++/**+ * The MCP exec path keeps the created record on the result's metadata for PostHog AI runs, even when the+ * text the model reads is truncated. Its `id` is the only exact correlation; a name lookup is a guess.+ */+function createdIdFromOutput(event: ToolStreamEvent): string | null {+ const record = getToolOutputRecord({ rawOutput: event.invocation.output, status: event.invocation.status })+ return typeof record?.id === 'string' && record.id ? record.id : null+}++/**+ * The AI-first "new entity" page is the side panel's own runner rendered full page. A completed create+ * call for `toolName` on this run opens the panel and routes to the created entity, so the same thread+ * continues against its editor.+ */+export const aiFirstHandoffLogic: LogicWrapper<aiFirstHandoffLogicType> = kea<aiFirstHandoffLogicType>([+ props({} as AiFirstHandoffLogicProps),+ key(({ toolName }) => toolName),+ path((key) => ['scenes', 'max', 'aiFirstCreate', 'aiFirstHandoffLogic', key]),+ connect(() => ({+ values: [+ runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }),+ ['activeCreation'],+ sidePanelStateLogic,+ ['sidePanelOpen', 'selectedTab'],+ ],+ actions: [+ runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }),+ ['setActiveCreation', 'clearActiveCreation', 'setHistoryExpanded'],+ sidePanelStateLogic,+ ['openSidePanel', 'closeSidePanel'],+ toolStreamEventsLogic,+ ['emitToolEvent'],+ composerSeedLogic({ panelId: MAX_SIDE_PANEL_ID }),+ ['setSeed'],+ ],+ })),+ actions({+ composerShown: true,+ escapeHatchClicked: true,+ fillComposer: (prompt: string) => ({ prompt }),+ }),+ listeners(({ actions, cache, props, values }) => ({+ // Runs after the previous scene left the panel registry, so its close is not read as dismissing the auto-open.+ composerShown: () => {+ // The panel is shared with the side panel: a run or history list left open there must not replace the composer.+ actions.clearActiveCreation()+ actions.setHistoryExpanded(false)+ // An unsent prompt typed in the panel is still in the shared form. An empty seed is how a host clears it.+ actions.setSeed({ prompt: '', autoSubmit: false })+ if (values.sidePanelOpen && values.selectedTab === SidePanelTab.Max) {+ actions.closeSidePanel()+ }+ posthog.capture(`${props.eventPrefix} viewed`)+ },+ escapeHatchClicked: () => {+ posthog.capture(`${props.eventPrefix} escape hatch clicked`)+ },+ // A suggestion only fills the composer (no auto-submit) so the prompt can be tweaked before the agent starts.+ fillComposer: ({ prompt }) => {+ actions.setSeed({ prompt, autoSubmit: false })+ const textarea = document.querySelector<HTMLTextAreaElement>('[data-attr="task-composer-input"]')+ textarea?.focus()+ textarea?.setSelectionRange(prompt.length, prompt.length)+ },+ setActiveCreation: ({ creation }, _breakpoint, _action, previousState) => {+ // The first set for a stream key is the send; later ones attach the task and run ids.+ const previous = runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }).selectors.activeCreation(previousState)+ if (previous?.streamKey !== creation.streamKey) {+ posthog.capture(`${props.eventPrefix} submitted`)+ }+ },+ emitToolEvent: async ({ event }) => {+ if (+ event.source !== 'live' ||+ event.phase !== 'completed' ||+ event.toolName !== props.toolName ||+ event.streamKey !== values.activeCreation?.streamKey ||+ cache.handedOff+ ) {+ return+ }+ // Held from while the logic is alive: a remount puts a live manager back on the cache.+ const disposables = cache.disposables+ let createdId = createdIdFromOutput(event)+ if (!createdId) {+ try {+ createdId = await props.findCreatedId(resolveToolCall(event.invocation).innerInput)+ } catch {+ // A rejected lookup reads like no match: the entity is saved and the run stays on screen.+ createdId = null+ }+ }+ // The page can be left, or the composer cleared or re-sent, while the lookup is in flight. The+ // shared panel logic outlives this page, so a left page must not read values or route from here.+ if (disposables.isDisposed || cache.handedOff || event.streamKey !== values.activeCreation?.streamKey) {+ return+ }+ if (!createdId) {+ lemonToast.error(props.notOpenedMessage)+ return+ }+ cache.handedOff = true+ posthog.capture(props.createdEvent, { [props.createdIdProperty]: createdId })+ // Open the panel before leaving the page so the runner instance stays mounted with its run.+ actions.openSidePanel(SidePanelTab.Max)+ router.actions.push(props.urlFor(createdId))+ },+ })),+])diff --git a/frontend/src/scenes/max/aiFirstCreate/aiFirstMode.ts b/frontend/src/scenes/max/aiFirstCreate/aiFirstMode.tsnew file mode 100644index 000000000000..de456544b3ff--- /dev/null+++ b/frontend/src/scenes/max/aiFirstCreate/aiFirstMode.ts@@ -0,0 +1,43 @@+import { FeatureFlagKey } from 'lib/constants'+import { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'++import type { ComposerOverride } from 'products/posthog_ai/frontend/api/logics'++// pinned: URL search param for the surface a new entity opens on. A URL that says neither opens the editor.+export const EDITOR_MODE_PARAM = 'mode'+export const EDITOR_MODE_VALUE = 'editor'+export const AI_COMPOSER_MODE_VALUE = 'ai'++/** Reading the flag captures `$feature_flag_called`, the experiment's exposure, so callers run this after every cheaper check. */+export function isAiFirstVariant(flagKey: FeatureFlagKey, featureFlags: FeatureFlagsSet): boolean {+ const variant = featureFlags[flagKey]+ return variant === true || variant === 'test'+}++/**+ * Whether a "new" URL asks for the AI composer and this person is on the variant that answers it.+ * `eligibleRoute` carries the surface's own checks (the route is its new route and the URL carries no+ * starting point), and it runs before the flag read so an existing entity never records an exposure.+ */+export function aiComposerAvailable(+ flagKey: FeatureFlagKey,+ featureFlags: FeatureFlagsSet,+ sceneIntegrationEnabled: boolean,+ searchParams: Record<string, any>,+ eligibleRoute: boolean+): boolean {+ return (+ sceneIntegrationEnabled &&+ eligibleRoute &&+ searchParams[EDITOR_MODE_PARAM] === AI_COMPOSER_MODE_VALUE &&+ isAiFirstVariant(flagKey, featureFlags)+ )+}++export const AI_FIRST_COMPOSER_OVERRIDE: ComposerOverride = {+ hideRepositorySelector: true,+ hideSuggestions: true,+ hideRecentTasks: true,+ // Not a takeover host, and the side panel is closed here, so nothing would receive the replay click.+ hideOnboardingReplay: true,+}diff --git a/products/posthog_ai/frontend/api/logics.ts b/products/posthog_ai/frontend/api/logics.tsindex 66d21cba0fba..87181c775cad 100644--- a/products/posthog_ai/frontend/api/logics.ts+++ b/products/posthog_ai/frontend/api/logics.ts@@ -66,6 +66,7 @@ export type { ToolStreamSubscription } from '../logics/toolStreamEventsLogic'export { useToolStreamListener } from '../hooks/useToolStream'export type { UseToolStreamListenerOptions } from '../hooks/useToolStream'export { resolveToolCall } from '../utils/toolResolver'+export { getToolOutputRecord } from '../utils/getToolOutputRecord'// --- Foreground stream registry + MCP tool apply-back (headless) ---// `foregroundStreamLogic` marks the single stream rendered in the side panel the user is watching; adiff --git a/products/posthog_ai/frontend/api/tools.ts b/products/posthog_ai/frontend/api/tools.tsindex 5ad1b00a06af..bc7d7a53dd1c 100644--- a/products/posthog_ai/frontend/api/tools.ts+++ b/products/posthog_ai/frontend/api/tools.ts@@ -16,5 +16,5 @@ export { findAllDiffContent, getDiffStats, languageFromPath } from '../componentexport type { ToolCallDiffContent } from '../components/tool/toolDiffContent'export { DiffEvidenceCard } from '../components/tool/DiffEvidenceCard'export type { DiffEvidenceCardProps } from '../components/tool/DiffEvidenceCard'-export { getToolOutputRecord, asRecord } from '../components/tool/getToolOutputRecord'+export { getToolOutputRecord, asRecord } from '../utils/getToolOutputRecord'export { MessageTemplate } from '../messages/MessageTemplate'diff --git a/products/posthog_ai/frontend/components/tool/widgets/CreateNotebookWidget.tsx b/products/posthog_ai/frontend/components/tool/widgets/CreateNotebookWidget.tsxindex 2489ce903e2b..a7de577d07df 100644--- a/products/posthog_ai/frontend/components/tool/widgets/CreateNotebookWidget.tsx+++ b/products/posthog_ai/frontend/components/tool/widgets/CreateNotebookWidget.tsx@@ -5,9 +5,9 @@ import { IconOpenInNew } from 'lib/lemon-ui/icons'import { urls } from 'scenes/urls'import { MessageTemplate } from '../../../messages/MessageTemplate'+import { getToolOutputRecord } from '../../../utils/getToolOutputRecord'import { DataToolRow } from '../DataToolRow'import { GenericMcpToolRenderer } from '../GenericMcpToolRenderer'-import { getToolOutputRecord } from '../getToolOutputRecord'import type { ToolRendererProps } from '../toolRegistry'/** The notebook fields the widget renders, pulled from the REST payload. */diff --git a/products/posthog_ai/frontend/components/tool/widgets/extractors.ts b/products/posthog_ai/frontend/components/tool/widgets/extractors.tsindex 3f19569d155c..ffd04675dff2 100644--- a/products/posthog_ai/frontend/components/tool/widgets/extractors.ts+++ b/products/posthog_ai/frontend/components/tool/widgets/extractors.ts@@ -19,7 +19,7 @@ import { RecordingUniversalFilters } from '~/types'import type { ToolCallMessage } from 'products/posthog_ai/frontend/types/toolTypes'-import { getToolOutputRecord } from '../getToolOutputRecord'+import { getToolOutputRecord } from '../../../utils/getToolOutputRecord'/*** Shared shape extractors for the sandbox MCP tool renderer widgets. Each turns a flatteneddiff --git a/products/posthog_ai/frontend/components/tool/getToolOutputRecord.ts b/products/posthog_ai/frontend/utils/getToolOutputRecord.tssimilarity index 76%rename from products/posthog_ai/frontend/components/tool/getToolOutputRecord.tsrename to products/posthog_ai/frontend/utils/getToolOutputRecord.tsindex 44512c765038..902285809254 100644--- a/products/posthog_ai/frontend/components/tool/getToolOutputRecord.ts+++ b/products/posthog_ai/frontend/utils/getToolOutputRecord.ts@@ -1,10 +1,13 @@-import type { ToolCallMessage } from '../../types/toolTypes'+import type { ToolCallMessage } from '../types/toolTypes'export function asRecord(value: unknown): Record<string, unknown> | null {return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : null}-export function getToolOutputRecord(message: ToolCallMessage): Record<string, unknown> | null {+/** The handler record behind a tool result. Takes a thread message or the `{ rawOutput, status }` of a stream event. */+export function getToolOutputRecord(+ message: Pick<ToolCallMessage, 'rawOutput' | 'status'>+): Record<string, unknown> | null {const output = asRecord(message.rawOutput)if (!output || output.isError === true || message.status === 'failed') {return nulldiff --git a/products/workflows/frontend/Workflows/NewWorkflowAgent.tsx b/products/workflows/frontend/Workflows/NewWorkflowAgent.tsxindex 510de1fced47..45aac82deea5 100644--- a/products/workflows/frontend/Workflows/NewWorkflowAgent.tsx+++ b/products/workflows/frontend/Workflows/NewWorkflowAgent.tsx@@ -1,73 +1,30 @@-import { useActions, useValues } from 'kea'-import { useEffect } from 'react'+import { useActions } from 'kea'-import { LemonBanner } from '@posthog/lemon-ui'--import { cn } from 'lib/utils/css-classes'-import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'-import { SuggestionCard } from 'scenes/max/components/SuggestionCard'+import { AiFirstCreateScene } from 'scenes/max/aiFirstCreate/AiFirstCreateScene'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'-import { composerSeedLogic, runnerPanelLogic } from 'products/posthog_ai/frontend/api/logics'-import { SidePanelRunner } from 'products/posthog_ai/frontend/api/runner'--import { newWorkflowAgentLogic } from './newWorkflowAgentLogic'+import { NEW_WORKFLOW_HANDOFF } from './newWorkflowHandoff'import { newWorkflowLogic } from './newWorkflowLogic'import { NewWorkflowModal } from './NewWorkflowModal'import { NEW_WORKFLOW_SUGGESTIONS } from './workflowAgentContext'-/** The AI-first "New workflow" screen: the side panel's runner rendered full page, with a way back to the editor. */+/** The AI-first "New workflow" screen: the composer first, with the template modal behind the escape hatch. */export function NewWorkflowAgent(): JSX.Element {- const { composerShown } = useActions(newWorkflowAgentLogic)const { openEditorFromAiComposer } = useActions(newWorkflowLogic)- useEffect(() => composerShown(), [composerShown])- const { activeCreation } = useValues(runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }))- // A card only fills the composer (no auto-submit) so the prompt can be tweaked before the agent starts.- const { setSeed } = useActions(composerSeedLogic({ panelId: MAX_SIDE_PANEL_ID }))- const fillComposer = (prompt: string): void => {- setSeed({ prompt, autoSubmit: false })- const textarea = document.querySelector<HTMLTextAreaElement>('[data-attr="task-composer-input"]')- textarea?.focus()- textarea?.setSelectionRange(prompt.length, prompt.length)- }return (- // Natural height while drafting so the cards sit under the composer; full page once a run starts.- <div className="flex flex-col grow min-h-0" data-attr="new-workflow-agent">- {/* The escape hatch stays up during a run, so a turn that never creates the draft has a way out. */}- <LemonBanner- type="ai"- className="m-2 shrink-0"- action={{- children: 'Use the editor instead',- onClick: openEditorFromAiComposer,- 'data-attr': 'new-workflow-agent-open-editor',- }}- >- We're trialling building workflows with PostHog AI. Describe what you want and it drafts the workflow- for you to refine.- </LemonBanner>- <div className={cn('flex flex-col', activeCreation ? 'grow min-h-0' : 'shrink-0 mt-auto')}>- <SidePanelRunner panelId={MAX_SIDE_PANEL_ID} />- </div>- {!activeCreation && (- <div className="flex flex-col items-center gap-4 shrink-0 pb-6 mb-auto">- <div className="grid grid-cols-1 @min-[40rem]/main-content:grid-cols-2 gap-1 w-full max-w-2xl px-4">- {NEW_WORKFLOW_SUGGESTIONS.map((suggestion) => (- <SuggestionCard- key={suggestion.prompt}- title={suggestion.title}- description={suggestion.description}- icon={iconForType('workflows')}- onClick={() => fillComposer(suggestion.prompt)}- data-attr="new-workflow-agent-suggestion"- />- ))}- </div>- </div>- )}+ <>+ <AiFirstCreateScene+ handoff={NEW_WORKFLOW_HANDOFF}+ banner="We're trialling building workflows with PostHog AI. Describe what you want and it drafts the workflow for you to refine."+ escapeHatchLabel="Use the editor instead"+ onEscapeHatch={openEditorFromAiComposer}+ suggestions={NEW_WORKFLOW_SUGGESTIONS}+ suggestionIcon={iconForType('workflows')}+ dataAttr="new-workflow-agent"+ /><NewWorkflowModal />- </div>+ </>)}diff --git a/products/workflows/frontend/Workflows/WorkflowScene.tsx b/products/workflows/frontend/Workflows/WorkflowScene.tsxindex 2982671831bc..418007590927 100644--- a/products/workflows/frontend/Workflows/WorkflowScene.tsx+++ b/products/workflows/frontend/Workflows/WorkflowScene.tsx@@ -12,6 +12,7 @@ import { useDebouncedValue } from 'lib/hooks/useDebouncedValue'import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'+import { AI_FIRST_COMPOSER_OVERRIDE } from 'scenes/max/aiFirstCreate/aiFirstMode'import { sceneAgentPanelLogic } from 'scenes/max/sceneAgentPanelLogic'import { useSceneAgentPanel } from 'scenes/max/useSceneAgentPanel'import { SceneExport } from 'scenes/sceneTypes'@@ -31,7 +32,6 @@ import { Workflow } from './Workflow'import {EMAIL_EDITOR_AGENT_HEADLINES,NEW_WORKFLOW_AGENT_HEADLINES,- NEW_WORKFLOW_COMPOSER_OVERRIDE,WORKFLOW_AGENT_HEADLINES,buildNewWorkflowComposerContext,buildWorkflowAgentContext,@@ -131,7 +131,7 @@ export function WorkflowScene(props: WorkflowSceneLogicProps): JSX.Element {: editingEmail? EMAIL_EDITOR_AGENT_HEADLINES: WORKFLOW_AGENT_HEADLINES,- composer: showAiComposer ? NEW_WORKFLOW_COMPOSER_OVERRIDE : undefined,+ composer: showAiComposer ? AI_FIRST_COMPOSER_OVERRIDE : undefined,active: !!originalWorkflow || workflowSceneProps.id === 'new',// The composer is the page while drafting; the panel opens itself once the draft exists.autoOpen: !showAiComposer,diff --git a/products/workflows/frontend/Workflows/newWorkflowAgentLogic.ts b/products/workflows/frontend/Workflows/newWorkflowAgentLogic.tsdeleted file mode 100644index 1977e008cd20..000000000000--- a/products/workflows/frontend/Workflows/newWorkflowAgentLogic.ts+++ /dev/null@@ -1,157 +0,0 @@-import { MakeLogicType, actions, connect, kea, listeners, path } from 'kea'-import { router } from 'kea-router'-import posthog from 'posthog-js'--import api from 'lib/api'-import { lemonToast } from 'lib/lemon-ui/LemonToast'-import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'-import { urls } from 'scenes/urls'--import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'-import { SidePanelTab } from '~/types'--import {- composerSeedLogic,- resolveToolCall,- runnerPanelLogic,- toolStreamEventsLogic,-} from 'products/posthog_ai/frontend/api/logics'-import type { ActiveCreation, ComposerSeed } from 'products/posthog_ai/frontend/api/logics'-import type { ToolStreamEvent } from 'products/posthog_ai/frontend/api/types'--// pinned: MCP tool name from products/workflows/mcp/tools.yaml-const CREATE_WORKFLOW_TOOL = 'workflows-create'--/** The tool output is truncated, so the draft is found by exact name, newest `created_at` first. No name means no guess. */-export async function findCreatedWorkflowId(name: unknown): Promise<string | null> {- const search = typeof name === 'string' && name.trim() ? name.trim() : undefined- if (!search) {- return null- }- const { results } = await api.hogFlows.getHogFlows({ search, limit: 5 })- const match = results- .filter((workflow) => workflow.name === search)- .sort((a, b) => b.created_at.localeCompare(a.created_at))[0]- return match?.id ?? null-}--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface newWorkflowAgentLogicValues {- activeCreation: ActiveCreation | null // runnerPanelLogic- selectedTab: SidePanelTab | null // sidePanelStateLogic- sidePanelOpen: boolean // sidePanelStateLogic-}--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface newWorkflowAgentLogicActions {- setSeed: (seed: ComposerSeed) => {- seed: ComposerSeed- } // composerSeedLogic- clearActiveCreation: () => {- value: true- } // runnerPanelLogic- setActiveCreation: (creation: ActiveCreation) => {- creation: ActiveCreation- } // runnerPanelLogic- setHistoryExpanded: (expanded: boolean) => {- expanded: boolean- } // runnerPanelLogic- closeSidePanel: (tab?: SidePanelTab | undefined) => {- tab: SidePanelTab | undefined- } // sidePanelStateLogic- openSidePanel: (- tab: SidePanelTab,- options?: string | undefined- ) => {- options: string | undefined- tab: SidePanelTab- } // sidePanelStateLogic- emitToolEvent: (event: ToolStreamEvent) => {- event: ToolStreamEvent- } // toolStreamEventsLogic- composerShown: () => {- value: true- }-}--export type newWorkflowAgentLogicType = MakeLogicType<newWorkflowAgentLogicValues, newWorkflowAgentLogicActions>--/** The composer is the side panel's own runner: a completed `workflows-create` opens the panel and routes to the draft. */-export const newWorkflowAgentLogic = kea<newWorkflowAgentLogicType>([- path(['products', 'workflows', 'frontend', 'newWorkflowAgentLogic']),- connect(() => ({- values: [- runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }),- ['activeCreation'],- sidePanelStateLogic,- ['sidePanelOpen', 'selectedTab'],- ],- actions: [- runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }),- ['setActiveCreation', 'clearActiveCreation', 'setHistoryExpanded'],- sidePanelStateLogic,- ['openSidePanel', 'closeSidePanel'],- toolStreamEventsLogic,- ['emitToolEvent'],- composerSeedLogic({ panelId: MAX_SIDE_PANEL_ID }),- ['setSeed'],- ],- })),- actions({- composerShown: true,- }),- listeners(({ actions, cache, values }) => ({- // Runs after the previous scene left the panel registry, so its close is not read as dismissing the auto-open.- composerShown: () => {- // The panel is shared with the side panel: a run or history list left open there must not replace the composer.- actions.clearActiveCreation()- actions.setHistoryExpanded(false)- // An unsent prompt typed in the panel is still in the shared form. An empty seed is how a host clears it.- actions.setSeed({ prompt: '', autoSubmit: false })- if (values.sidePanelOpen && values.selectedTab === SidePanelTab.Max) {- actions.closeSidePanel()- }- posthog.capture('workflow ai composer viewed')- },- setActiveCreation: ({ creation }, _breakpoint, _action, previousState) => {- // The first set for a stream key is the send; later ones attach the task and run ids.- const previous = runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }).selectors.activeCreation(previousState)- if (previous?.streamKey !== creation.streamKey) {- posthog.capture('workflow ai composer submitted')- }- },- emitToolEvent: async ({ event }) => {- if (- event.source !== 'live' ||- event.phase !== 'completed' ||- event.toolName !== CREATE_WORKFLOW_TOOL ||- event.streamKey !== values.activeCreation?.streamKey ||- cache.handedOff- ) {- return- }- let workflowId: string | null = null- try {- workflowId = await findCreatedWorkflowId(resolveToolCall(event.invocation).innerInput?.name)- } catch {- // A rejected list call reads like no match: the draft is saved and the run stays on screen.- workflowId = null- }- // The composer can be cleared or re-sent while the lookup is in flight.- if (cache.handedOff || event.streamKey !== values.activeCreation?.streamKey) {- return- }- if (!workflowId) {- lemonToast.error(- 'Your workflow was created, but it could not be opened. Find it in the workflows list.'- )- return- }- cache.handedOff = true- posthog.capture('workflow ai composer created workflow', { workflow_id: workflowId })- // Open the panel before leaving the page so the runner instance stays mounted with its run.- actions.openSidePanel(SidePanelTab.Max)- router.actions.push(urls.workflow(workflowId, 'workflow'))- },- })),-])diff --git a/products/workflows/frontend/Workflows/newWorkflowHandoff.test.ts b/products/workflows/frontend/Workflows/newWorkflowHandoff.test.tsnew file mode 100644index 000000000000..c2ea02367f14--- /dev/null+++ b/products/workflows/frontend/Workflows/newWorkflowHandoff.test.ts@@ -0,0 +1,36 @@+import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { findCreatedWorkflowId } from './newWorkflowHandoff'++const WORKFLOW_ID = '2f1e9c3a-5b7d-4e8f-9a0b-1c2d3e4f5a6b'+const OLDER_ID = '7a1b2c3d-0000-4e8f-9a0b-1c2d3e4f5a6b'+const NAME = 'Win back inactive users'++describe('findCreatedWorkflowId', () => {+ beforeEach(() => {+ useMocks({+ get: {+ // Ordered by update time like the real list, so the same-named older draft comes first.+ '/api/environments/:team_id/hog_flows/': {+ results: [+ { id: OLDER_ID, name: NAME, created_at: '2026-09-01T00:00:00Z' },+ { id: WORKFLOW_ID, name: NAME, created_at: '2026-09-15T00:00:00Z' },+ { id: 'other', name: `${NAME} v2`, created_at: '2026-09-16T00:00:00Z' },+ ],+ count: 3,+ },+ },+ })+ initKeaTests()+ })++ // The list is a substring search, so only the exact name counts, and the newest of those is the draft just made.+ it.each([+ { name: 'the newest exact match', input: NAME, expected: WORKFLOW_ID },+ { name: 'null for a blank name', input: ' ', expected: null },+ { name: 'null for a non-string name', input: 42, expected: null },+ ])('returns $name', async ({ input, expected }) => {+ await expect(findCreatedWorkflowId(input)).resolves.toBe(expected)+ })+})diff --git a/products/workflows/frontend/Workflows/newWorkflowHandoff.ts b/products/workflows/frontend/Workflows/newWorkflowHandoff.tsnew file mode 100644index 000000000000..db20be8e2af5--- /dev/null+++ b/products/workflows/frontend/Workflows/newWorkflowHandoff.ts@@ -0,0 +1,37 @@+import type { AiFirstHandoffLogicProps } from 'scenes/max/aiFirstCreate/aiFirstHandoffLogic'+import { projectLogic } from 'scenes/projectLogic'+import { urls } from 'scenes/urls'++import { hogFlowsList } from '../generated/api'++// pinned: MCP tool name from products/workflows/mcp/tools.yaml+const CREATE_WORKFLOW_TOOL = 'workflows-create'++/**+ * Fallback for a completed create whose output carries no record: the draft is found by exact name, newest+ * `created_at` first. No name means no guess.+ */+export async function findCreatedWorkflowId(name: unknown): Promise<string | null> {+ const search = typeof name === 'string' && name.trim() ? name.trim() : undefined+ if (!search) {+ return null+ }+ const projectId = String(projectLogic.findMounted()?.values.currentProjectId)+ const { results } = await hogFlowsList(projectId, { search, limit: 5 })+ const match = results+ .filter((workflow) => workflow.name === search)+ .sort((a, b) => b.created_at.localeCompare(a.created_at))[0]+ return match?.id ?? null+}++/** A completed `workflows-create` opens the panel and routes to the draft. */+export const NEW_WORKFLOW_HANDOFF: AiFirstHandoffLogicProps = {+ toolName: CREATE_WORKFLOW_TOOL,+ findCreatedId: (innerInput) => findCreatedWorkflowId(innerInput?.name),+ urlFor: (id) => urls.workflow(id, 'workflow'),+ notOpenedMessage: 'Your workflow was created, but it could not be opened. Find it in the workflows list.',+ // pinned: analytics event names+ eventPrefix: 'workflow ai composer',+ createdEvent: 'workflow ai composer created workflow',+ createdIdProperty: 'workflow_id',+}diff --git a/products/workflows/frontend/Workflows/newWorkflowLogic.ts b/products/workflows/frontend/Workflows/newWorkflowLogic.tsindex afa53dfe043a..f305b3ea9d98 100644--- a/products/workflows/frontend/Workflows/newWorkflowLogic.ts+++ b/products/workflows/frontend/Workflows/newWorkflowLogic.ts@@ -5,28 +5,24 @@ import posthog from 'posthog-js'import { FEATURE_FLAGS } from 'lib/constants'import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'+import {+ AI_COMPOSER_MODE_VALUE,+ EDITOR_MODE_PARAM,+ EDITOR_MODE_VALUE,+ aiComposerAvailable,+ isAiFirstVariant,+} from 'scenes/max/aiFirstCreate/aiFirstMode'import { sceneAgentPanelLogic } from 'scenes/max/sceneAgentPanelLogic'import { urls } from 'scenes/urls'import type { HogFlowTemplate } from './hogflows/types'import { TRIGGER_PREFILL_PARAM } from './workflowTriggerPrefill'-// pinned: URL search param for the surface a new workflow opens on. A URL that says neither opens the editor.-export const EDITOR_MODE_PARAM = 'mode'-export const EDITOR_MODE_VALUE = 'editor'-export const AI_COMPOSER_MODE_VALUE = 'ai'-/** The new-workflow URL for an entry that means "start from nothing", the only kind the composer answers. */export function urlForNewWorkflowComposer(): string {return combineUrl(urls.workflowNew(), { [EDITOR_MODE_PARAM]: AI_COMPOSER_MODE_VALUE }).url}-/** Reading the flag captures `$feature_flag_called`, the experiment's exposure, so this runs after every cheaper check. */-function isAiFirstVariant(featureFlags: FeatureFlagsSet): boolean {- const variant = featureFlags[FEATURE_FLAGS.WORKFLOWS_AI_FIRST_NEW]- return variant === true || variant === 'test'-}-// The editor scene is `/workflows/:id/:tab`, and only the `new` id can show the composer.function isNewWorkflowRoute(pathname: string): boolean {const [, section, id] = removeProjectIdIfPresent(pathname).split('/')@@ -128,7 +124,7 @@ export const newWorkflowLogic = kea<newWorkflowLogicType>([aiFirstNewEnabled: [(s) => [s.featureFlags, s.sceneIntegrationEnabled],(featureFlags: FeatureFlagsSet, sceneIntegrationEnabled: boolean): boolean =>- sceneIntegrationEnabled && isAiFirstVariant(featureFlags),+ sceneIntegrationEnabled && isAiFirstVariant(FEATURE_FLAGS.WORKFLOWS_AI_FIRST_NEW, featureFlags),],// Deep links with a starting point stay on the editor. Checked here so the scene never reads the flag early.aiComposerAvailable: [@@ -139,13 +135,16 @@ export const newWorkflowLogic = kea<newWorkflowLogicType>([searchParams: Record<string, any>,location: { pathname: string }): boolean =>- sceneIntegrationEnabled &&- isNewWorkflowRoute(location.pathname) &&- !searchParams.templateId &&- !searchParams.editTemplateId &&- !searchParams[TRIGGER_PREFILL_PARAM] &&- searchParams[EDITOR_MODE_PARAM] === AI_COMPOSER_MODE_VALUE &&- isAiFirstVariant(featureFlags),+ aiComposerAvailable(+ FEATURE_FLAGS.WORKFLOWS_AI_FIRST_NEW,+ featureFlags,+ sceneIntegrationEnabled,+ searchParams,+ isNewWorkflowRoute(location.pathname) &&+ !searchParams.templateId &&+ !searchParams.editTemplateId &&+ !searchParams[TRIGGER_PREFILL_PARAM]+ ),],}),listeners(({ actions, values }) => ({@@ -161,7 +160,6 @@ export const newWorkflowLogic = kea<newWorkflowLogicType>([}},openEditorFromAiComposer: () => {- posthog.capture('workflow ai composer escape hatch clicked')actions.showNewWorkflowModal()},createWorkflowFromTemplate: ({ template }) => {diff --git a/products/workflows/frontend/Workflows/workflowAgentContext.ts b/products/workflows/frontend/Workflows/workflowAgentContext.tsindex 3f7415cdd344..050e12a2bdfe 100644--- a/products/workflows/frontend/Workflows/workflowAgentContext.ts+++ b/products/workflows/frontend/Workflows/workflowAgentContext.ts@@ -1,8 +1,8 @@import { redactSecretHogFunctionInputs } from 'scenes/hog-functions/hog-function-utils'+import type { AiFirstSuggestion } from 'scenes/max/aiFirstCreate/AiFirstCreateScene'import { CyclotronJobInputSchemaType, CyclotronJobInputType, HogFunctionTemplateType } from '~/types'-import type { ComposerOverride } from 'products/posthog_ai/frontend/api/logics'import { AttachedContextItem } from 'products/posthog_ai/frontend/api/types'import { isEmailAction, isFunctionAction, isTriggerFunction } from './hogflows/steps/types'@@ -66,22 +66,8 @@ export const EMAIL_EDITOR_AGENT_HEADLINES: string[] = ['How should this email loexport const NEW_WORKFLOW_AGENT_HEADLINES: string[] = ['What workflow would you like to build today?']-export const NEW_WORKFLOW_COMPOSER_OVERRIDE: ComposerOverride = {- hideRepositorySelector: true,- hideSuggestions: true,- hideRecentTasks: true,- // Not a takeover host, and the side panel is closed here, so nothing would receive the replay click.- hideOnboardingReplay: true,-}--export interface NewWorkflowSuggestion {- title: string- description: string- prompt: string-}-// The first is the data-driven ask; the rest follow the templates users pick most often.-export const NEW_WORKFLOW_SUGGESTIONS: NewWorkflowSuggestion[] = [+export const NEW_WORKFLOW_SUGGESTIONS: AiFirstSuggestion[] = [{title: 'Improve my conversion',description: 'Look at the funnel and draft a campaign for the biggest drop-off',