: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(workflows): make the ai-first trial banner quieter and dismissible (#115944)
Harley Alexanderfe9998bd1c8c
diff --git a/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsx b/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsxindex 2cbcdafdc64d..bf197509cd39 100644--- a/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsx+++ b/frontend/src/scenes/max/aiFirstCreate/AiFirstCreateScene.tsx@@ -1,7 +1,8 @@import { useActions, useValues } from 'kea'import { useEffect } from 'react'-import { LemonBanner } from '@posthog/lemon-ui'+import { IconSparkles } from '@posthog/icons'+import { LemonBanner, LemonButton } from '@posthog/lemon-ui'import { cn } from 'lib/utils/css-classes'import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'@@ -20,7 +21,7 @@ export interface AiFirstSuggestion {export interface AiFirstCreateSceneProps {handoff: AiFirstHandoffLogicProps- /** Banner copy that says what this page trials. */+ /** Banner copy that says what this page trials. The person can dismiss it, but not the escape hatch. */banner: stringescapeHatchLabel: stringonEscapeHatch: () => void@@ -43,28 +44,45 @@ export function AiFirstCreateScene({belowComposer,dataAttr,}: AiFirstCreateSceneProps): JSX.Element {- const { composerShown, escapeHatchClicked, fillComposer } = useActions(aiFirstHandoffLogic(handoff))+ const { composerShown, escapeHatchClicked, dismissBanner, fillComposer } = useActions(aiFirstHandoffLogic(handoff))+ const { bannerDismissed } = useValues(aiFirstHandoffLogic(handoff))useEffect(() => composerShown(), [composerShown])const { activeCreation } = useValues(runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }))+ const escapeHatch = (+ <LemonButton+ type="secondary"+ size="xsmall"+ className="shrink-0"+ onClick={() => {+ escapeHatchClicked()+ onEscapeHatch()+ }}+ data-attr={`${dataAttr}-open-editor`}+ >+ {escapeHatchLabel}+ </LemonButton>+ )+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>+ {bannerDismissed ? (+ <div className="flex justify-end shrink-0 m-2">{escapeHatch}</div>+ ) : (+ <LemonBanner+ type="info"+ icon={<IconSparkles className="LemonBanner__icon text-ai" />}+ onClose={dismissBanner}+ className="m-2 shrink-0"+ >+ <div className="flex flex-wrap items-center justify-between gap-2">+ <div className="text-secondary">{banner}</div>+ {escapeHatch}+ </div>+ </LemonBanner>+ )}<div className={cn('flex flex-col', activeCreation ? 'grow min-h-0' : 'shrink-0 mt-auto')}><SidePanelRunner panelId={MAX_SIDE_PANEL_ID} /></div>diff --git a/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.ts b/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.tsindex 8cb0a58dd748..70dd508f6b5a 100644--- a/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.ts+++ b/frontend/src/scenes/max/aiFirstCreate/aiFirstHandoffLogic.ts@@ -1,4 +1,4 @@-import { LogicWrapper, MakeLogicType, actions, connect, kea, key, listeners, path, props } from 'kea'+import { LogicWrapper, MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'@@ -31,7 +31,8 @@ export interface AiFirstHandoffLogicProps {/** 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} escape hatch clicked`, `${eventPrefix} banner dismissed`, and `createdEvent` with the id+ // under `createdIdProperty`.eventPrefix: stringcreatedEvent: stringcreatedIdProperty: string@@ -42,6 +43,7 @@ export interface aiFirstHandoffLogicValues {activeCreation: ActiveCreation | null // runnerPanelLogicselectedTab: SidePanelTab | null // sidePanelStateLogicsidePanelOpen: boolean // sidePanelStateLogic+ bannerDismissed: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -74,6 +76,9 @@ export interface aiFirstHandoffLogicActions {composerShown: () => {value: true}+ dismissBanner: () => {+ value: true+ }escapeHatchClicked: () => {value: true}@@ -133,8 +138,13 @@ export const aiFirstHandoffLogic: LogicWrapper<aiFirstHandoffLogicType> = kea<aiactions({composerShown: true,escapeHatchClicked: true,+ dismissBanner: true,fillComposer: (prompt: string) => ({ prompt }),}),+ reducers({+ // pinned: persisted under the logic path, so the toolName key keeps one dismissal per surface.+ bannerDismissed: [false, { persist: true }, { dismissBanner: () => true }],+ }),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: () => {@@ -151,6 +161,9 @@ export const aiFirstHandoffLogic: LogicWrapper<aiFirstHandoffLogicType> = kea<aiescapeHatchClicked: () => {posthog.capture(`${props.eventPrefix} escape hatch clicked`)},+ dismissBanner: () => {+ posthog.capture(`${props.eventPrefix} banner dismissed`)+ },// 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 })