: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(wizard): hand the setup report off to the app (#75734)
Fernando Gomes34044519f6d5
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e79e39426b84..54058553a25c 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7623,17 +7623,17 @@ snapshots:scenes-other-onboarding-legacy-product-selection--base--light:hash: v1.k794b7964.d5a6e4d5e44b84e7a1b0a9eb095fb62a08eea227968860911c9e23757eb99d33.mrMEqKjXZgfMivqJdaamdN2nJVc-I_8Sccv6XXQylg8scenes-other-onboarding-shared-installation-progress--all-states--dark:- hash: v1.k794b7964.ebc77004f3ed2739bf9f824cc8291f1516fd30ae503a2f13e5a322a7cdf57613.ZHmXxoJNvy8sinEkadiq2GQsihmvPseDr7WiIY1wO5g+ hash: v1.k794b7964.701a00d919735a8e926d138dbf37d3f999ffe860a38366ffad441d2ea9007dc3.At1SVb1kbXJdi1oQ6SNRG2h9FaXngLNhQiIfeDfBvagscenes-other-onboarding-shared-installation-progress--all-states--light:- hash: v1.k794b7964.d4d3b47f954d5f43a73a66dc29e885e94e5a09575d21cbfba9d8209b8284d9a2.fP9Jt39r3NTu_IElQmz-pISGpEjruyU-fe8xgvghp08+ hash: v1.k794b7964.851e5525b9f7c4955768768dbe9be7e523626507c62719983a9987d88f377d28.N_3uzrW7wz7rBbjVkEfSPqnZCm37zpUXHdQC8c8tLEoscenes-other-onboarding-shared-installation-progress--completed--dark:- hash: v1.k794b7964.d2fdb0dfb10d93ae58d7d9a5cca2b0078ddb92de8f07340f99abbe970b204c29.Wml3hzGqTjQVPrTV50wkCSK4mqqx6wVkbpNM07WdbJc+ hash: v1.k794b7964.a5c39954664721c5f485671e2144a599f4bee52af9d43d3eba9d5469d10b34fb.RwKIupLIPaIjkqA-87qce-fCE6iJ9J4FlanTULVNY24scenes-other-onboarding-shared-installation-progress--completed--light:- hash: v1.k794b7964.74b0637f974fc0281ca86808393158b9d5949394896c369a0454b54db6416303.UgEYkmdUPnElm5kCjQC7Nqtk0BVXpYqvS_iQxMQII74+ hash: v1.k794b7964.bcf5d2def507944709285c026e238335307c02ad344b7216536be2b9e29b344f.PO-TsJat5OfrttiFuq4wkZMAOx3I5QROXVLzBPvGg18scenes-other-onboarding-shared-installation-progress--completed-local-handoff--dark:- hash: v1.k794b7964.a1bbfc19bd743396afb9f0fc6c754fec526b3fa6365df8cf7d1ddab0113580a3.spFKy1nJRNCPBrgKdpMlhaVjXrRvup7VhCD2t6ECO4Q+ hash: v1.k794b7964.bbc57991c178d0788c6fab71dd72d254361384e0399da3c68e13d045ed1d17da.29t13LRsYq53GL20sxOGDEheK9WcztzEdoPAqVjAcawscenes-other-onboarding-shared-installation-progress--completed-local-handoff--light:- hash: v1.k794b7964.b70acf5dde641c02c9e5dc873e4e5645d5e9e8d310e30a6fa7515eef50b2c883.I306JX9K5dYkqwtcrwVjlgYVHwpuaZ-sM25phr676EU+ hash: v1.k794b7964.8ea61ff9bac8ab7b7d8c9b21deae5a8f6082d3ae397de87d12f6363bd2002f3a._AVZdbGBN7ZivWe9YKDJr0zGoX164EHUTgIUdG7rRkwscenes-other-onboarding-shared-installation-progress--completed-merged--dark:hash: v1.k794b7964.e41a47c6d198618b61635ee98c7424dcd8893284a69cf72c2cd18bbcbf1bce4c.Q8Ahyvmp_7fhazPC-B3XSNQd9igBc1zLpI5tzQYOMqcscenes-other-onboarding-shared-installation-progress--completed-merged--light:@@ -7718,10 +7718,14 @@ snapshots:hash: v1.k794b7964.5a35f0677ffb11febcba8084a0ccb558ecff39d861a8cd8c6501671f47a1fac2.Of5i_K-cfe3g96_a6dHtRI0PeaDjaJ0rdWZMi6O4aG0scenes-other-onboarding-shared-wizard-cloud-run--run-it-yourself--light:hash: v1.k794b7964.8cff144ac77c6006b48a62a014070b994affcef9058056e2a95b8f4e22084c76.hP6I6QLsGi3k_TebVwrWapvf_CjCVBsmTFQ81_8HVfo+ scenes-other-onboarding-shared-wizard-handoff-dialog--opened--dark:+ hash: v1.k794b7964.810fb1774d7f9ebf7b63cab5e3b5a45606bb9f498c3aff4ee6ee4d45bbb33123.jD9rqBcIaYTHx4mQTQs73wzG3zM_WtCv8UutSWtnny0+ scenes-other-onboarding-shared-wizard-handoff-dialog--opened--light:+ hash: v1.k794b7964.4d516d425a6ca045ff7bcc0645341bd4c2e4ed0d1a4a5be97c8ae6ed27ea4839.L7gQvpwmqU9bjiJVp5-SCjjQsl8zwTkNhKAzGc4TidMscenes-other-onboarding-shared-wizard-sync-card--all-states--dark:- hash: v1.k794b7964.65526a55e7a2c0658e60e0c330a015430f561d3d80b3c2463408d6120b6cd078.a3tsBW_wyWyuhTAvUbgNVRx6rqStiMURSToOppQEIbg+ hash: v1.k794b7964.4de365c2b65ca7d49ff0f39a2a040b2e08ba2e5d8f7cb7ca9fde78b966fc038b.RAPRNUnyG1v_M-N5gkvUBP7EQpdV3HlqmTYmRAbxzRoscenes-other-onboarding-shared-wizard-sync-card--all-states--light:- hash: v1.k794b7964.f744986e88baa2e34e13bb3c2dd9cfdec58e6e1741599ef7be96174720f3396a.IU3v7Hpl82zzZjvuQxEnRkXUTF0GEPAF2NBWdwCqcZg+ hash: v1.k794b7964.920b94b7310ba6ca3c115f434164d806fd25300237347e583ec8c46d9cc01b1d.MBbUyGnBshoWMOTUiPa01Ngs6G8SPFQFBZjy2iDl27oscenes-other-onboarding-shared-wizard-sync-card--cloud-keeping-ci-green--dark:hash: v1.k794b7964.fba9c3af456f60a00dec760305609433d1d8ffb609f1573352f71cb29f1fa6b2.2tmy7T0O1t2rw1SYTOXCMCePVPleYZWjuUnc4EU5a7Qscenes-other-onboarding-shared-wizard-sync-card--cloud-keeping-ci-green--light:@@ -7735,9 +7739,9 @@ snapshots:scenes-other-onboarding-shared-wizard-sync-card--completed--light:hash: v1.k794b7964.466de6282ec983ff5917df90ea8d0e65106e91957af246554375d8ea140b22f5.Nn7X9ZeY0nRHXoYWbI7DphrUf5qfvB-31Pr8bn-a9LQscenes-other-onboarding-shared-wizard-sync-card--completed-local--dark:- hash: v1.k794b7964.33d722e02d5a53770da3e3d9358fae107fe29d3cdb98f8dc7945f4f6e82dbfb2.t7QGs-4jsBwmqsmcGHK7eW33QvNrDQg6Ph9CeN5Hy4o+ hash: v1.k794b7964.5be2ade3340eb7d67a5996891d3c3d2575f94b9abd4a462f1276ee3466cf4425.E2i7G97orrTue7-H34-0pofN2nuykAjrbge_a_79EHoscenes-other-onboarding-shared-wizard-sync-card--completed-local--light:- hash: v1.k794b7964.8f248577fa64ea554f49153a5e139bc874561111328e10f7fb94ae55f6f31d2e.TW1BWApDo6cYwwv5TfISjmQWk1XeY-gQr-rFe3kntpg+ hash: v1.k794b7964.c33efb6554e27c18637f34cb1282973d7919a237fe5ee632ccc8bda15e1210d1.NM3GIOLmjmkD8NfAV0ud6NHgstOSbmiteNlBicx8SEoscenes-other-onboarding-shared-wizard-sync-card--connecting--dark:hash: v1.k794b7964.61398434096848c5eb49dc43a6649548981357049ad0e237bee837e83da9eaf7.wPw2Z4LDdDur-vsryi8JhcHJ-LFpgwc1rVX6rmn1Ng0scenes-other-onboarding-shared-wizard-sync-card--connecting--light:diff --git a/frontend/src/scenes/AuthenticatedShell.tsx b/frontend/src/scenes/AuthenticatedShell.tsxindex 14900b9b8470..f142149bd6cc 100644--- a/frontend/src/scenes/AuthenticatedShell.tsx+++ b/frontend/src/scenes/AuthenticatedShell.tsx@@ -8,6 +8,7 @@ import { ToastCloseButton } from 'lib/lemon-ui/LemonToast/LemonToast'import { apiStatusLogic } from 'lib/logic/apiStatusLogic'import { eventIngestionRestrictionLogic } from 'lib/logic/eventIngestionRestrictionLogic'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { WizardHandoffDialog } from 'scenes/onboarding/shared/wizard-sync/WizardHandoffDialog'import { WizardSyncDebugPanel } from 'scenes/onboarding/shared/wizard-sync/WizardSyncDebugPanel'import { WizardSyncFab } from 'scenes/onboarding/shared/wizard-sync/WizardSyncFab'@@ -42,6 +43,9 @@ export default function AuthenticatedShell({ children }: { children: React.React<ImpersonationNotice /><SelfReadOnlyNotice /><WizardSyncFab />+ {/* Separate from the FAB: the FAB stands down while an inline panel shows the run,+ but the doc dialog must be able to open from any surface. */}+ <WizardHandoffDialog /><WizardSyncDebugPanel />{featureFlags[FEATURE_FLAGS.EXPERIMENTS_DW_AA_TEST] === 'test' && (<div data-attr="experiments-dw-aa-test-variant" className="hidden" />diff --git a/frontend/src/scenes/inbox/components/shell/InstallationCard.tsx b/frontend/src/scenes/inbox/components/shell/InstallationCard.tsxindex cd7fc5c21b61..b74c0e830022 100644--- a/frontend/src/scenes/inbox/components/shell/InstallationCard.tsx+++ b/frontend/src/scenes/inbox/components/shell/InstallationCard.tsx@@ -2,6 +2,7 @@ import { useActions, useValues } from 'kea'import { useEffect } from 'react'import { cn } from 'lib/utils/css-classes'+import { onboardingEventUsageLogic } from 'scenes/onboarding/onboardingEventUsageLogic'import { currentTaskLabel, syncHeadline, toneTextClass } from 'scenes/onboarding/shared/wizard-sync/helpers'import { useRunElapsedSeconds } from 'scenes/onboarding/shared/wizard-sync/hooks'import { installationProgressLogic } from 'scenes/onboarding/shared/wizard-sync/installationProgressLogic'@@ -19,7 +20,8 @@ export function InstallationCard({ workflowId }: { workflowId: string }): JSX.Elconst { installationProgress, latestSession } = useValues(installationProgressLogic({ mode: 'local', workflowId }))const { claimInlinePanel, releaseInlinePanel } = useActions(wizardSyncUiLogic)const { dialogOpen } = useValues(wizardSyncUiLogic)- const { openDialog, closeDialog } = useActions(wizardSyncUiLogic)+ const { openDialog, closeDialog, openHandoffDoc } = useActions(wizardSyncUiLogic)+ const { reportWizardSyncHandoffDocOpened } = useActions(onboardingEventUsageLogic)// This card is the local run's surface while the rail shows it, so the detached widget stands// down for that run. A cloud run in flight at the same time keeps its own surface.@@ -38,6 +40,16 @@ export function InstallationCard({ workflowId }: { workflowId: string }): JSX.El// `currentTaskLabel` over the raw step so a run waiting on the user surfaces the question// it is blocked on, which is the whole point of noticing it from here.const detail = currentTaskLabel(installationProgress)++ const handoffText = installationProgress.handoffText+ const runKey = latestSession?.session_id+ const handleViewReport =+ handoffText && runKey+ ? () => {+ reportWizardSyncHandoffDocOpened({ runKey, mode: 'local', trigger: 'button' })+ openHandoffDoc({ key: runKey, text: handoffText })+ }+ : undefinedreturn (<><button@@ -66,6 +78,7 @@ export function InstallationCard({ workflowId }: { workflowId: string }): JSX.Elmode="local"isOpen={dialogOpen}onClose={closeDialog}+ onViewReport={handleViewReport}/></>)diff --git a/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts b/frontend/src/scenes/onboarding/onboardingEventUsageLogic.tsindex f69929aec24d..0b7098723b0e 100644--- a/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts+++ b/frontend/src/scenes/onboarding/onboardingEventUsageLogic.ts@@ -51,11 +51,9 @@ function wizardSyncEventProps(featureFlags: FeatureFlagsSet): {// deduping here, keyed by run, keeps the funnel's denominators honest without every surface// carrying its own guard.const reportedHandoffShownRuns = new Set<string>()-const reportedDashboardCtaShownRuns = new Set<string>()export function resetCloudRunExperimentExposureForTests(): void {reportedHandoffShownRuns.clear()- reportedDashboardCtaShownRuns.clear()}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -106,28 +104,19 @@ export interface onboardingEventUsageLogicActions {reportSelfDrivingOnboardingStepViewed: (stepId: SelfDrivingOnboardingStepId) => {stepId: SelfDrivingOnboardingStepId}- reportWizardSyncDashboardCtaClicked: (props: {- mode: 'cloud' | 'local'- runKey: string- surface: 'fab' | 'inline'- }) => {+ reportWizardSyncExpanded: (props: { mode: 'cloud' | 'local'; phase: string; runKey: string }) => {mode: 'cloud' | 'local'+ phase: stringrunKey: string- surface: 'fab' | 'inline'}- reportWizardSyncDashboardCtaShown: (props: {+ reportWizardSyncHandoffDocOpened: (props: {mode: 'cloud' | 'local'runKey: string- surface: 'fab' | 'inline'+ trigger: 'auto' | 'button'}) => {mode: 'cloud' | 'local'runKey: string- surface: 'fab' | 'inline'- }- reportWizardSyncExpanded: (props: { mode: 'cloud' | 'local'; phase: string; runKey: string }) => {- mode: 'cloud' | 'local'- phase: string- runKey: string+ trigger: 'auto' | 'button'}reportWizardSyncHandoffShown: (props: {mode: 'cloud' | 'local'@@ -211,24 +200,19 @@ export const onboardingEventUsageLogic = kea<onboardingEventUsageLogicType>([phase: stringelapsedSeconds: number}) => props,- // The completed-handoff funnel: exposure (a run's completed state rendered anywhere), the- // dashboard CTA becoming visible, and the CTA click. Deduped per run per pageload here, so- // surfaces can report unconditionally. No dashboard names or ids — same rule as repo names.+ // The completed-handoff funnel: exposure (a run's completed state rendered anywhere) and+ // the handoff doc dialog opening. Exposure is deduped per run per pageload here, so+ // surfaces can report unconditionally. No doc content — same rule as repo names.reportWizardSyncHandoffShown: (props: {runKey: stringmode: 'cloud' | 'local'surface: 'inline' | 'fab'prOpened: boolean}) => props,- reportWizardSyncDashboardCtaShown: (props: {+ reportWizardSyncHandoffDocOpened: (props: {runKey: stringmode: 'cloud' | 'local'- surface: 'inline' | 'fab'- }) => props,- reportWizardSyncDashboardCtaClicked: (props: {- runKey: string- mode: 'cloud' | 'local'- surface: 'inline' | 'fab'+ trigger: 'auto' | 'button'}) => props,}),listeners(({ values }) => ({@@ -343,25 +327,13 @@ export const onboardingEventUsageLogic = kea<onboardingEventUsageLogicType>([...wizardSyncEventProps(values.featureFlags),})},- reportWizardSyncDashboardCtaShown: ({ runKey, mode, surface }) => {- if (reportedDashboardCtaShownRuns.has(runKey)) {- return- }- reportedDashboardCtaShownRuns.add(runKey)- posthog.capture('wizard sync dashboard cta shown', {- run_key: runKey,- mode,- surface,- ...wizardSyncEventProps(values.featureFlags),- })- },- // Clicks are NOT deduped: a user returning to the dashboard through the CTA twice is real- // engagement, and the shown-event denominator is already stable.- reportWizardSyncDashboardCtaClicked: ({ runKey, mode, surface }) => {- posthog.capture('wizard sync dashboard cta clicked', {+ // Opens are NOT deduped: reopening the doc through the button is real engagement, and the+ // auto trigger fires at most once per run by construction (wizardSyncUiLogic's seen keys).+ reportWizardSyncHandoffDocOpened: ({ runKey, mode, trigger }) => {+ posthog.capture('wizard sync handoff doc opened', {run_key: runKey,mode,- surface,+ trigger,...wizardSyncEventProps(values.featureFlags),})},diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsxindex e2ead28c831c..d73cb96a2210 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressContent.tsx@@ -1,12 +1,11 @@import { type ReactNode } from 'react'import * as wizardPng from '@posthog/brand/hoggies/png/wizard-1'-import { IconDashboard, IconPullRequest, IconRocket, IconSearch, IconTerminal, IconX } from '@posthog/icons'+import { IconDocument, IconPullRequest, IconRocket, IconSearch, IconTerminal, IconX } from '@posthog/icons'import { LemonBanner, LemonButton, Spinner } from '@posthog/lemon-ui'import { pngHoggie } from 'lib/brand/hoggies'import { cn } from 'lib/utils/css-classes'-import { urls } from 'scenes/urls'import { CheckList } from '../components/CheckList'import { prNameLabel } from './helpers'@@ -15,7 +14,6 @@ import { SELF_DRIVING_UPCOMING_STEPS, syncCopy, UPCOMING_STEPS } from './installimport { InstallationMode, InstallationProgress } from './installationProgressLogic'import { StepIcon } from './StepIcon'import { Timeline } from './Timeline'-import { DetectedDashboard } from './wizardDashboardLogic'import { resolveWorkflowId, SELF_DRIVING_WORKFLOW_ID } from './workflows'const HedgehogWizard = pngHoggie(wizardPng)@@ -31,8 +29,7 @@ export function InstallationProgressContent({continueHint,progress,mode,- dashboard,- onDashboardClick,+ onViewReport,onDismiss,onRetryLocally,}: {@@ -43,10 +40,9 @@ export function InstallationProgressContent({workflowId?: string/** Shown while the run is in flight, to say it keeps going if the user navigates away. */continueHint?: ReactNode- /** Dashboard the wizard built, when detected — surfaced as the completed state's payoff. */- dashboard?: DetectedDashboard | null- /** Telemetry hook for the dashboard CTA — navigation itself rides the button's `to`. */- onDashboardClick?: () => void+ /** Opens the run's handoff doc (the setup report) — the completed state's payoff. Only rendered+ * when the progress actually carries a doc. */+ onViewReport?: () => voidonDismiss?: () => void/** When set, a failed run offers a "Run it yourself" button (switches the install step to the local* command). Omitted where no local fallback exists (e.g. the floating FAB), which shows only docs. */@@ -248,23 +244,16 @@ export function InstallationProgressContent({</LemonBanner>)}- {phase === 'completed' && dashboard && (- <div className="flex flex-col gap-2">- <p className="text-sm text-muted m-0">- The wizard also set up a dashboard for you. It fills up as soon as your events arrive. Feel free- to look around.- </p>- <LemonButton- type={prUrl ? 'secondary' : 'primary'}- to={urls.dashboard(dashboard.id)}- icon={<IconDashboard />}- center- tooltip={dashboard.name ?? undefined}- onClick={onDashboardClick}- >- Preview your dashboard- </LemonButton>- </div>+ {phase === 'completed' && progress.handoffText && onViewReport && (+ <LemonButton+ type={prUrl ? 'secondary' : 'primary'}+ onClick={onViewReport}+ icon={<IconDocument />}+ center+ data-attr="wizard-sync-view-report"+ >+ View setup report+ </LemonButton>)}</div>)diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsxindex ebf9bf3e2c86..8bc7ad8059b0 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsx@@ -54,10 +54,21 @@ function progress(overrides: Partial<InstallationProgress>): InstallationProgresisCurrent: true,pendingInput: null,startedBy: null,+ handoffText: null,...overrides,}}+const SAMPLE_REPORT = [+ '# PostHog setup report',+ '',+ 'Installed `posthog-js` and wired up event capture in `app/providers.tsx`.',+ '',+ '## Verify before merging',+ '- [ ] Events arrive on the Activity page',+ '- [ ] The API key lives in `.env.local`, not in source',+].join('\n')+export const Connecting: Story = {args: { progress: progress({ phase: 'connecting' }), mode: 'cloud' },}@@ -95,14 +106,15 @@ export const Completed: Story = {phase: 'completed',steps: steps(['completed', 'completed', 'completed', 'completed']),prUrl: 'https://github.com/acme-co/web/pull/42',+ handoffText: SAMPLE_REPORT,}),mode: 'cloud',- dashboard: { id: 1, name: 'My app analytics' },},+ argTypes: { onViewReport: { action: 'view-report' } },}// The local run's final handoff: the wizard finished on the user's machine, so the review + deploy-// steps are theirs — plus the dashboard the wizard built as the payoff CTA.+// steps are theirs — plus the setup report the agent wrote as the payoff CTA.export const CompletedLocalHandoff: Story = {args: {progress: progress({@@ -113,11 +125,11 @@ export const CompletedLocalHandoff: Story = {{ id: 'c', label: 'Wired up event capture', status: 'completed', detail: null },{ id: 'd', label: 'Created a dashboard', status: 'completed', detail: null },],+ handoffText: SAMPLE_REPORT,}),mode: 'local',- dashboard: { id: 1, name: 'My app analytics' },},- argTypes: { onDismiss: { action: 'dismissed' } },+ argTypes: { onDismiss: { action: 'dismissed' }, onViewReport: { action: 'view-report' } },}// The PR is open but the run keeps going (keeping CI green): "Pull request ready" headline + the review@@ -270,7 +282,7 @@ export const AllStates: Story = {<InstallationProgressContentprogress={args!.progress!}mode={args!.mode}- dashboard={args!.dashboard}+ onViewReport={() => {}}onRetryLocally={() => {}}/></div>diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsxindex a868ff4e4124..e3e32161b1ba 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.tsx@@ -5,7 +5,6 @@ import { onboardingEventUsageLogic } from '../../onboardingEventUsageLogic'import { finishedLocalRunLogic } from './finishedLocalRunLogic'import { InstallationProgressContent } from './InstallationProgressContent'import { installationProgressLogic } from './installationProgressLogic'-import { wizardDashboardLogic } from './wizardDashboardLogic'import { wizardSyncUiLogic } from './wizardSyncUiLogic'/**@@ -41,11 +40,9 @@ export function InstallationProgressView({const { installationProgress, latestSession } = useValues(installationProgressLogic({ mode, runId, taskId, workflowId }))- const { claimInlinePanel, releaseInlinePanel } = useActions(wizardSyncUiLogic)- const { detectedDashboard } = useValues(wizardDashboardLogic)+ const { claimInlinePanel, releaseInlinePanel, openHandoffDoc } = useActions(wizardSyncUiLogic)const { dismissLocalRun } = useActions(finishedLocalRunLogic)- const { reportWizardSyncHandoffShown, reportWizardSyncDashboardCtaShown, reportWizardSyncDashboardCtaClicked } =- useActions(onboardingEventUsageLogic)+ const { reportWizardSyncHandoffShown, reportWizardSyncHandoffDocOpened } = useActions(onboardingEventUsageLogic)// While shown inline on the install step, hide the floating FAB so the same run isn't in two places.useEffect(() => {@@ -58,7 +55,6 @@ export function InstallationProgressView({const runKey = mode === 'cloud' ? runId : latestSession?.session_idconst completed = installationProgress.phase === 'completed'- const dashboard = completed ? detectedDashboard : nullconst prOpened = !!installationProgress.prUrl// The completed-handoff funnel (exposure + CTA impression), deduped per run inside the events@@ -68,12 +64,15 @@ export function InstallationProgressView({reportWizardSyncHandoffShown({ runKey, mode, surface: 'inline', prOpened })}}, [completed, runKey, mode, prOpened, reportWizardSyncHandoffShown])- const dashboardVisible = !!dashboard- useEffect(() => {- if (dashboardVisible && runKey) {- reportWizardSyncDashboardCtaShown({ runKey, mode, surface: 'inline' })- }- }, [dashboardVisible, runKey, mode, reportWizardSyncDashboardCtaShown])++ const handoffText = installationProgress.handoffText+ const handleViewReport =+ handoffText && runKey+ ? () => {+ reportWizardSyncHandoffDocOpened({ runKey, mode, trigger: 'button' })+ openHandoffDoc({ key: runKey, text: handoffText })+ }+ : undefined// Local runs always get a dismissal: it releases the install-step takeover and the FAB in one// move, and nothing else knows the session to clear. Cloud dismissal stays with the caller@@ -87,10 +86,7 @@ export function InstallationProgressView({continueHint={continueHint}progress={installationProgress}mode={mode}- dashboard={dashboard}- onDashboardClick={- runKey ? () => reportWizardSyncDashboardCtaClicked({ runKey, mode, surface: 'inline' }) : undefined- }+ onViewReport={handleViewReport}onDismiss={onDismiss ?? defaultLocalDismiss}onRetryLocally={onRetryLocally}/>diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardHandoffDialog.stories.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardHandoffDialog.stories.tsxnew file mode 100644index 000000000000..39f3a1c70e5b--- /dev/null+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardHandoffDialog.stories.tsx@@ -0,0 +1,56 @@+import { Meta, StoryObj } from '@storybook/react'+import { useActions, useMountedLogic } from 'kea'+import { useEffect } from 'react'++import { WizardHandoffDialog } from './WizardHandoffDialog'+import { wizardSyncUiLogic } from './wizardSyncUiLogic'++const SAMPLE_REPORT = [+ '# PostHog setup report',+ '',+ 'Installed `posthog-js` and wired up event capture for a Next.js app.',+ '',+ '## What changed',+ '- Added `instrumentation-client.ts` with the PostHog init',+ '- Wrapped the app in `PostHogProvider` in `app/providers.tsx`',+ '- Added `NEXT_PUBLIC_POSTHOG_KEY` to `.env.local`',+ '',+ '## Events instrumented',+ '| Event | Where |',+ '| --- | --- |',+ '| `signed_up` | `app/signup/page.tsx` |',+ '| `checkout_started` | `app/checkout/page.tsx` |',+ '',+ '## Verify before merging',+ '- [ ] Events arrive on the Activity page',+ '- [ ] The API key lives in `.env.local`, not in source',+ '- [ ] `pnpm build` passes',+].join('\n')++// The dialog reads from wizardSyncUiLogic, so the story opens a doc through the same action the+// announce path and the "View setup report" buttons use.+function OpenedHandoffDialog(): JSX.Element {+ useMountedLogic(wizardSyncUiLogic)+ const { openHandoffDoc } = useActions(wizardSyncUiLogic)+ useEffect(() => {+ openHandoffDoc({ key: 'story-run', text: SAMPLE_REPORT })+ }, [openHandoffDoc])+ return <WizardHandoffDialog />+}++const meta: Meta = {+ title: 'Scenes-Other/Onboarding/Shared/Wizard Handoff Dialog',+ component: WizardHandoffDialog,+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ testOptions: { waitForLoadersToDisappear: false },+ },+}+export default meta++type Story = StoryObj<typeof WizardHandoffDialog>++export const Opened: Story = {+ render: () => <OpenedHandoffDialog />,+}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardHandoffDialog.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardHandoffDialog.tsxnew file mode 100644index 000000000000..af8cb84ca0ce--- /dev/null+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardHandoffDialog.tsx@@ -0,0 +1,33 @@+import { useActions, useValues } from 'kea'++import { LemonModal } from '@posthog/lemon-ui'++import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'++import { wizardSyncUiLogic } from './wizardSyncUiLogic'++/**+ * The handoff doc dialog: renders the markdown report a wizard run produced. Mounted once app-wide+ * (next to the FAB) rather than per surface, so the one-time auto-open works no matter which scene+ * the user is on; the run surfaces reopen it through `openHandoffDoc`.+ */+export function WizardHandoffDialog(): JSX.Element {+ const { handoffDoc } = useValues(wizardSyncUiLogic)+ const { closeHandoffDoc } = useActions(wizardSyncUiLogic)+ return (+ <LemonModal+ isOpen={!!handoffDoc}+ onClose={closeHandoffDoc}+ title="Setup report"+ description="The agent wrote this report about the run it just finished."+ width={640}+ >+ {/* ph-no-capture: the report describes the customer's codebase (file paths, event+ names, framework detail) and must not reach autocapture. disableImages: the text is+ agent output, so an inline image would fire a request to an arbitrary URL. */}+ <div className="ph-no-capture" data-attr="wizard-handoff-doc">+ <LemonMarkdown disableImages>{handoffDoc?.text ?? ''}</LemonMarkdown>+ </div>+ </LemonModal>+ )+}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsxindex 60c1ed310b01..9deee463afde 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsx@@ -59,6 +59,7 @@ function progress(overrides: Partial<InstallationProgress>): InstallationProgresisCurrent: true,pendingInput: null,startedBy: null,+ handoffText: null,...overrides,}}@@ -182,7 +183,7 @@ export const Completed: Story = {},}-// A finished local run: no PR to review, so the dashboard the wizard built is the footer payoff,+// A finished local run: no PR to review, so the setup report the agent wrote is the footer payoff,// and the X reads as a real dismissal.export const CompletedLocal: Story = {args: {@@ -195,10 +196,11 @@ export const CompletedLocal: Story = {{ id: 'b', label: 'Installed the PostHog SDK', status: 'completed', detail: null },{ id: 'c', label: 'Wired up event capture', status: 'completed', detail: null },],+ handoffText: '# PostHog setup report\n\nInstalled `posthog-js` and wired up event capture.',}),- dashboard: { id: 1, name: 'My app analytics' },dismissTooltip: 'Dismiss',},+ argTypes: { onViewReport: { action: 'view-report' } },}// A run still nominally in flight that has gone quiet: the clock is replaced by the reason it stopped@@ -239,7 +241,7 @@ export const AllStates: Story = {{ label: 'Local, running', args: LocalRunning.args },{ label: 'Local, started by a teammate', args: LocalRunningStartedByTeammate.args },{ label: 'Completed', args: Completed.args },- { label: 'Completed, local (dashboard payoff)', args: CompletedLocal.args },+ { label: 'Completed, local (report payoff)', args: CompletedLocal.args },{ label: 'Stalled', args: Stalled.args },{ label: 'Failed', args: Failed.args },]@@ -254,7 +256,7 @@ export const AllStates: Story = {mode={args!.mode!}stale={args!.stale}startedByLabel={args!.startedByLabel}- dashboard={args!.dashboard}+ onViewReport={() => {}}onExpand={() => {}}onDismiss={() => {}}/>diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsxindex c35d6e6c14c0..b7764735d81e 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsx@@ -1,8 +1,7 @@-import { IconCloud, IconDashboard, IconExpand45, IconLaptop, IconPullRequest, IconX } from '@posthog/icons'+import { IconCloud, IconDocument, IconExpand45, IconLaptop, IconPullRequest, IconX } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'import { cn } from 'lib/utils/css-classes'-import { urls } from 'scenes/urls'import {currentTaskLabel,@@ -18,7 +17,6 @@ import {import { InstallationProgress } from './installationProgressLogic'import { PipStrip } from './PipStrip'import { StatusGlyph } from './StatusGlyph'-import { DetectedDashboard } from './wizardDashboardLogic'export type WizardSyncMode = 'cloud' | 'local'@@ -43,8 +41,7 @@ export function WizardSyncCard({elapsedSeconds,mode,stale = false,- dashboard,- onDashboardClick,+ onViewReport,onExpand,onDismiss,dismissTooltip = 'Dismiss',@@ -57,10 +54,9 @@ export function WizardSyncCard({stale?: boolean/** A teammate's name for a local run they started (null when it's the viewer's own run or unknown). */startedByLabel?: string | null- /** Dashboard the wizard built, when detected — the completed card's payoff for runs with no PR. */- dashboard?: DetectedDashboard | null- /** Telemetry hook for the dashboard CTA — navigation itself rides the button's `to`. */- onDashboardClick?: () => void+ /** Opens the run's handoff doc (the setup report) — the completed card's payoff for runs with+ * no PR. Only rendered when the progress actually carries a doc. */+ onViewReport?: () => voidonExpand: () => voidonDismiss?: () => void/** What the X actually does here — "Minimize" while the run is live, "Dismiss" once terminal. */@@ -151,19 +147,19 @@ export function WizardSyncCard({<span className="truncate max-w-32">{prNameLabel(progress.prUrl)}</span></LemonButton>)}- {progress.phase === 'completed' && !progress.prUrl && dashboard && (+ {progress.phase === 'completed' && !progress.prUrl && progress.handoffText && onViewReport && (<LemonButtonsize="xsmall"type="primary"- to={urls.dashboard(dashboard.id)}- icon={<IconDashboard />}+ icon={<IconDocument />}onClick={(e) => {e.stopPropagation()- onDashboardClick?.()+ onViewReport()}}- tooltip="The wizard set this up for you. It fills up as your events arrive"+ tooltip="What the agent set up, and what to check before you commit"+ data-attr="wizard-sync-card-view-report">- Preview dashboard+ Setup report</LemonButton>)}<LemonButtondiff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncDialog.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncDialog.tsxindex c2b2c75bff7c..09af569a19a3 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncDialog.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncDialog.tsx@@ -5,7 +5,6 @@ import { cn } from 'lib/utils/css-classes'import { elapsedLabel, localModeLabel, syncHeadline, toneTextClass } from './helpers'import { InstallationProgressContent } from './InstallationProgressContent'import { InstallationProgress } from './installationProgressLogic'-import { DetectedDashboard } from './wizardDashboardLogic'import { WizardSyncMode } from './WizardSyncCard'// The expanded "all the details" dialog: the full pipeline plus the terminal payoff or failure.@@ -15,30 +14,29 @@ export function WizardSyncDialog({progress,elapsedSeconds,mode,- dashboard,isOpen,onClose,onClear,onCancel,+ onViewReport,cancelling = false,stale = false,startedByLabel,- onDashboardClick,}: {progress: InstallationProgresselapsedSeconds: numbermode: WizardSyncMode- dashboard?: DetectedDashboard | nullisOpen: booleanonClose: () => voidonClear?: () => voidonCancel?: () => void+ /** Opens the run's handoff doc (the setup report) when the progress carries one. */+ onViewReport?: () => voidcancelling?: boolean/** The run has gone quiet for long enough that it can be dismissed without orphaning live work. */stale?: boolean/** A teammate's name for a local run they started (null when it's the viewer's own run or unknown). */startedByLabel?: string | null- onDashboardClick?: () => void}): JSX.Element {const isTerminal = progress.phase === 'completed' || progress.phase === 'error'return (@@ -51,12 +49,7 @@ export function WizardSyncDialog({{elapsedLabel(elapsedSeconds, stale)}</span></div>- <InstallationProgressContent- progress={progress}- mode={mode}- dashboard={dashboard}- onDashboardClick={onDashboardClick}- />+ <InstallationProgressContent progress={progress} mode={mode} onViewReport={onViewReport} />{/* A stale run gets the same exit as a terminal one: nothing is reporting on it, soleaving Cancel as the only control would strand the user behind a request thatcannot bring it back. Cancel stays available below for as long as the run is notdiff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncSurface.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncSurface.tsxindex 7980d283728e..27700bf290e9 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncSurface.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncSurface.tsx@@ -8,7 +8,6 @@ import { onboardingEventUsageLogic } from '../../onboardingEventUsageLogic'import { isRunStale, resolveStartedByLabel } from './helpers'import { useNow } from './hooks'import { InstallationProgress } from './installationProgressLogic'-import { wizardDashboardLogic } from './wizardDashboardLogic'import { WizardSyncCard, WizardSyncMode } from './WizardSyncCard'import { WizardSyncDialog } from './WizardSyncDialog'import { WizardSyncLauncher } from './WizardSyncLauncher'@@ -51,7 +50,7 @@ export function WizardSyncSurface({cancelling?: boolean}): JSX.Element {const { dismissedKey, dialogOpen } = useValues(wizardSyncUiLogic)- const { dismiss, restore, openDialog, closeDialog } = useActions(wizardSyncUiLogic)+ const { dismiss, restore, openDialog, closeDialog, openHandoffDoc } = useActions(wizardSyncUiLogic)const { user } = useValues(userLogic)const startedByLabel = resolveStartedByLabel(progress.startedBy, user?.email)const {@@ -60,10 +59,8 @@ export function WizardSyncSurface({reportWizardSyncRestored,reportWizardSyncRunDismissed,reportWizardSyncHandoffShown,- reportWizardSyncDashboardCtaShown,- reportWizardSyncDashboardCtaClicked,+ reportWizardSyncHandoffDocOpened,} = useActions(onboardingEventUsageLogic)- const { detectedDashboard } = useValues(wizardDashboardLogic)// `now` also feeds the staleness check, which needs a live clock while the run is non-terminal.const endMs = endedAt ? new Date(endedAt).getTime() : NaNconst now = useNow(!Number.isNaN(endMs))@@ -75,7 +72,6 @@ export function WizardSyncSurface({// Only cloud runs can zombie like this: their handle is persisted browser state that outlives the// run, where a local run is gated by the session detector's own liveness poll.const stale = mode === 'cloud' && !isTerminal && isRunStale(startedAt, lastActivityAt, streamLost, now)- const dashboard = progress.phase === 'completed' ? detectedDashboard : nullconst eventProps = { runKey, mode, phase: progress.phase }// The completed-handoff funnel (exposure + CTA impression) — deduped per run inside the events@@ -87,13 +83,13 @@ export function WizardSyncSurface({reportWizardSyncHandoffShown({ runKey, mode, surface: 'fab', prOpened })}}, [completed, runKey, mode, prOpened, reportWizardSyncHandoffShown])- const dashboardVisible = !!dashboard- useEffect(() => {- if (dashboardVisible) {- reportWizardSyncDashboardCtaShown({ runKey, mode, surface: 'fab' })- }- }, [dashboardVisible, runKey, mode, reportWizardSyncDashboardCtaShown])- const handleDashboardClick = (): void => reportWizardSyncDashboardCtaClicked({ runKey, mode, surface: 'fab' })+ const handoffText = progress.handoffText+ const handleViewReport = handoffText+ ? () => {+ reportWizardSyncHandoffDocOpened({ runKey, mode, trigger: 'button' })+ openHandoffDoc({ key: runKey, text: handoffText })+ }+ : undefined// One-shot: a double-click can land two dispatches before the surface unmounts, which would// double-fire the dismissal telemetry and re-run onClear.const clearedRef = useRef(false)@@ -135,8 +131,7 @@ export function WizardSyncSurface({mode={mode}stale={stale}startedByLabel={startedByLabel}- dashboard={dashboard}- onDashboardClick={handleDashboardClick}+ onViewReport={handleViewReport}onExpand={() => {reportWizardSyncExpanded(eventProps)openDialog()@@ -156,8 +151,7 @@ export function WizardSyncSurface({mode={mode}stale={stale}startedByLabel={startedByLabel}- dashboard={dashboard}- onDashboardClick={handleDashboardClick}+ onViewReport={handleViewReport}isOpen={dialogOpen}onClose={closeDialog}onClear={handleClear}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/finishedLocalRunLogic.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/finishedLocalRunLogic.tsindex e069336c32b3..86814a558eed 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/finishedLocalRunLogic.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/finishedLocalRunLogic.ts@@ -5,7 +5,7 @@ import { projectLogic } from 'scenes/projectLogic'import type { WizardSessionDTOApi } from 'products/wizard/frontend/generated/api.schemas'import { startedByFromSession } from './helpers'-import { wizardDashboardLogic } from './wizardDashboardLogic'+import { wizardSyncUiLogic } from './wizardSyncUiLogic'/** A terminal local wizard run, snapshotted so its handoff outlives the session stream. */export interface FinishedLocalRunHandle {@@ -18,6 +18,8 @@ export interface FinishedLocalRunHandle {tasks: { id: string; title: string; status: string }[]error: { message?: string } | nullstartedBy?: { name: string; email: string } | null+ /** The run's markdown handoff doc, kept so the doc dialog outlives the stream too. */+ handoffText?: string | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -30,9 +32,11 @@ export interface finishedLocalRunLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface finishedLocalRunLogicActions {- detectWizardDashboard: (args_0: { startedAt: string }) => {- startedAt: string- } // wizardDashboardLogic+ handoffDocReceived: (doc: { key: string; startedByEmail: string | null; text: string }) => {+ key: string+ startedByEmail: string | null+ text: string+ } // wizardSyncUiLogicdismissLocalRun: (sessionId: string) => {sessionId: string}@@ -75,7 +79,7 @@ export const finishedLocalRunLogic = kea<finishedLocalRunLogicType>([path(['scenes', 'onboarding', 'finishedLocalRunLogic']),connect(() => ({values: [projectLogic, ['currentProjectId']],- actions: [wizardDashboardLogic, ['detectWizardDashboard']],+ actions: [wizardSyncUiLogic, ['handoffDocReceived']],})),actions({recordFinishedLocalRun: (session: WizardSessionDTOApi) => ({ session }),@@ -138,17 +142,22 @@ export const finishedLocalRunLogic = kea<finishedLocalRunLogicType>([tasks: (session.tasks ?? []).map((t) => ({ id: t.id, title: t.title, status: t.status })),error: (session.error as { message?: string } | null) ?? null,startedBy: startedByFromSession(session),+ handoffText: session.handoff_text ?? null,})- if (session.run_phase === 'completed') {- actions.detectWizardDashboard({ startedAt: session.started_at })- }},})),afterMount(({ actions, values }) => {- // A completed handle restored from a previous pageload still deserves its dashboard CTA.+ // A handle restored from a previous pageload may carry a doc the user never saw (the run+ // finished after they left) — announce it so the one-time auto-open can still happen. The+ // live path's announcements come from the Installation layer's session bookkeeping instead.+ // Completed only, mirroring that path: the reopen buttons don't exist on errored runs.const handle = values.finishedLocalRun- if (handle?.runPhase === 'completed') {- actions.detectWizardDashboard({ startedAt: handle.startedAt })+ if (handle?.runPhase === 'completed' && handle.handoffText) {+ actions.handoffDocReceived({+ key: handle.sessionId,+ text: handle.handoffText,+ startedByEmail: handle.startedBy?.email ?? null,+ })}}),])diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgress.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgress.tsindex 5ca3c44052ce..082f1d8304a3 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgress.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgress.ts@@ -27,6 +27,19 @@ export function isSessionFresh(session: WizardSessionDTOApi, now: number): boolereturn !Number.isNaN(updatedAt) && now - updatedAt < SESSION_CURRENT_THRESHOLD_MS}+// Tolerance for the sandbox clock minting `started_at` slightly behind our kickoff stamp.+const RUN_SESSION_SKEW_MS = 5 * 60 * 1000++// Whether a session belongs to this cloud run: it started inside the run's own window. Used for+// the handoff doc, which must outlive the recency gate — the wizard stage ends hours before the+// pipeline does, so by completion the session is long past `isSessionFresh`, yet its doc is still+// this run's report. A session from a previous run keeps failing this check by starting earlier.+export function isSessionFromRun(session: WizardSessionDTOApi, runStartedAt: string): boolean {+ const sessionStart = new Date(session.started_at).getTime()+ const runStart = new Date(runStartedAt).getTime()+ return !Number.isNaN(sessionStart) && !Number.isNaN(runStart) && sessionStart >= runStart - RUN_SESSION_SKEW_MS+}+// A dead wizard can't clear its own prompt (the clearing push never arrives), so the attention state// must go quiet with the session: gated on the server's staleness verdict and a live (running) phase.export function pendingInputFromSession(session: WizardSessionDTOApi | null): WizardPendingInput | null {@@ -81,7 +94,9 @@ export function cloudProgress(taskConnectionStatus: string,latestSession: WizardSessionDTOApi | null,isStalled: boolean = false,- now: number = Date.now()+ now: number = Date.now(),+ /** When this run kicked off (from the persisted handle) — scopes the handoff doc to the run. */+ runStartedAt: string | null = null): InstallationProgress {let phase: InstallationPhaselet stalledError: { title: string; detail: string | null } | null = null@@ -222,6 +237,17 @@ export function cloudProgress(}): null+ // The doc rides the run-window check, not the recency gate: the cloud wizard finishes (and+ // publishes its report) hours before the pipeline completes, so by the time the completed+ // surfaces would show the button the session is long stale. Without a run window (no handle),+ // fall back to the recency-gated session rather than trusting an arbitrary old row.+ const handoffSession =+ latestSession && runStartedAt !== null+ ? isSessionFromRun(latestSession, runStartedAt)+ ? latestSession+ : null+ : session+return {phase,steps,@@ -231,6 +257,7 @@ export function cloudProgress(isCurrent: phase !== 'idle',pendingInput: phase === 'running' ? pendingInputFromSession(session) : null,startedBy: startedByFromSession(session),+ handoffText: handoffSession?.handoff_text ?? null,}}@@ -254,6 +281,7 @@ export function localProgress(isCurrent: false,pendingInput: null,startedBy: null,+ handoffText: null,}}@@ -303,6 +331,7 @@ export function localProgress(isCurrent: sessionIsCurrent && !dismissed,pendingInput: phase === 'running' && !dismissed ? pendingInputFromSession(latestSession) : null,startedBy: startedByFromSession(latestSession),+ handoffText: latestSession.handoff_text ?? null,}}@@ -321,5 +350,6 @@ export function progressFromFinishedLocalRun(handle: FinishedLocalRunHandle): InisCurrent: true,pendingInput: null,startedBy: handle.startedBy ?? null,+ handoffText: handle.handoffText ?? null,}}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.tsindex 9c3a85a1ae2b..beee0e9082f8 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.ts@@ -326,6 +326,11 @@ describe('installationProgressLogic merge', () => {expect(localProgress(session({ run_phase: 'completed' }), 'open', true).prUrl).toBeNull()})+ it('carries the handoff doc so the report button and dialog can render it', () => {+ expect(localProgress(session({ handoff_text: '# report' }), 'open', true).handoffText).toBe('# report')+ expect(localProgress(session(), 'open', true).handoffText).toBeNull()+ })+it('isCurrent mirrors the sticky freshness flag, never a bare session', () => {// A stale terminal row replayed by the SSE on connect must not read as a run in flight —// that is what used to hijack the install step before the freshness guard.@@ -430,6 +435,7 @@ describe('installationProgressLogic merge', () => {isCurrent: true,pendingInput: null,startedBy: null,+ handoffText: null,})})@@ -509,6 +515,41 @@ describe('installationProgressLogic merge', () => {})})+ describe('cloudProgress handoff doc run-window gate', () => {+ const NOW_MS = new Date('2026-01-01T06:00:00Z').getTime()+ // The wizard stage published its doc at ~00:00 and the pipeline completed hours later, so+ // the session is far past the recency gate by the time the completed surfaces render.+ const staleWithDoc = session({+ started_at: '2026-01-01T00:00:00Z',+ updated_at: '2026-01-01T00:05:00Z',+ run_phase: 'completed',+ handoff_text: '# report',+ })+ const completedRun = taskState({ status: 'completed' })++ it("keeps the doc from this run's session long after it went stale", () => {+ // Regression: gating the doc on isSessionFresh meant cloud users could never see it —+ // the button checks phase === completed, which flips hours after the wizard stage.+ const result = cloudProgress(completedRun, [], 'open', staleWithDoc, false, NOW_MS, '2025-12-31T23:55:00Z')+ expect(result.handoffText).toBe('# report')+ })++ it("rejects a session that predates the run (a previous run's doc)", () => {+ const result = cloudProgress(completedRun, [], 'open', staleWithDoc, false, NOW_MS, '2026-01-01T01:00:00Z')+ expect(result.handoffText).toBeNull()+ })++ it('falls back to the recency gate when no run window is known', () => {+ expect(cloudProgress(completedRun, [], 'open', staleWithDoc, false, NOW_MS).handoffText).toBeNull()+ const freshWithDoc = session({+ updated_at: '2026-01-01T05:59:00Z',+ run_phase: 'completed',+ handoff_text: '# report',+ })+ expect(cloudProgress(completedRun, [], 'open', freshWithDoc, false, NOW_MS).handoffText).toBe('# report')+ })+ })+describe('cloudProgress session freshness gate', () => {const NOW_MS = new Date('2026-01-01T00:00:30Z').getTime()it('ignores a stale session for both the timeline and the error fallback', () => {@@ -558,12 +599,14 @@ describe('installationProgressLogic merge', () => {markSessionCurrent: jest.MockrecordFinishedLocalRun: jest.MocksupersedeFinishedLocalRun: jest.Mock+ handoffDocReceived: jest.MockreportWizardSyncSessionDetected: jest.MockreportWizardSyncSessionFinished: jest.Mock} => ({markSessionCurrent: jest.fn(),recordFinishedLocalRun: jest.fn(),supersedeFinishedLocalRun: jest.fn(),+ handoffDocReceived: jest.fn(),reportWizardSyncSessionDetected: jest.fn(),reportWizardSyncSessionFinished: jest.fn(),})@@ -636,6 +679,34 @@ describe('installationProgressLogic merge', () => {expect(actions.recordFinishedLocalRun).not.toHaveBeenCalled()})+ it.each([+ // The doc must ride the same freshness gate as everything else (a stale row's doc+ // re-announced on every app load would fight the once-only auto-open downstream), and+ // it must wait for the completed push: the reopen buttons only exist on completed runs,+ // so announcing an errored (or still-running) run's doc would burn the one auto-open on+ // a dialog the user can never get back to.+ ['fresh completed session with a doc', fresh({ run_phase: 'completed', handoff_text: '# report' }), 1],+ ['fresh completed session without a doc', fresh({ run_phase: 'completed' }), 0],+ ['fresh running session with a doc', fresh({ handoff_text: '# report' }), 0],+ ['fresh errored session with a doc', fresh({ run_phase: 'error', handoff_text: '# report' }), 0],+ [+ 'stale completed session with a doc',+ session({ run_phase: 'completed', handoff_text: '# report', updated_at: '2020-01-01T00:00:00Z' }),+ 0,+ ],+ ])('announces the handoff doc only for a %s', (_name, s, expectedCalls) => {+ const actions = spyActions()+ runLocalSessionBookkeeping(s, null, POSTHOG_INTEGRATION_WORKFLOW_ID, actions)+ expect(actions.handoffDocReceived).toHaveBeenCalledTimes(expectedCalls)+ if (expectedCalls > 0) {+ expect(actions.handoffDocReceived).toHaveBeenCalledWith({+ key: s.session_id,+ text: '# report',+ startedByEmail: null,+ })+ }+ })+it('tolerates a malformed session with null tasks', () => {const actions = spyActions()const s = fresh({ session_id: 'null-tasks', tasks: null as unknown as WizardSessionDTOApi['tasks'] })diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.tsindex 105b3ef1bec2..e70d8452a020 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.ts@@ -31,7 +31,7 @@ import {watchWorkflowWhileMounted,wizardActiveSessionDetectorLogic,} from './wizardActiveSessionDetectorLogic'-import { wizardDashboardLogic } from './wizardDashboardLogic'+import { wizardSyncUiLogic } from './wizardSyncUiLogic'import { resolveWorkflowId } from './workflows'// Per-session telemetry guards, deliberately module-scoped rather than on the kea `cache`: the logic@@ -132,6 +132,9 @@ export interface InstallationProgress {pendingInput: WizardPendingInput | null/** Who started the run (null when unknown). `email` is for the "is this me?" check. */startedBy: { name: string; email: string } | null+ /** Markdown handoff doc the wizard produced (its setup report), once the run has one. Sticky on+ * the session row, so it survives later pushes and the finished-run snapshot. */+ handoffText: string | null}export interface InstallationProgressLogicProps {@@ -200,9 +203,6 @@ export interface installationProgressLogicActions {taskRunStreamCompleted: () => {value: true} // taskRunStreamLogic- detectWizardDashboard: (args_0: { startedAt: string }) => {- startedAt: string- } // wizardDashboardLogicconnectSession: () => {value: true} // wizardSessionStreamLogic@@ -212,6 +212,11 @@ export interface installationProgressLogicActions {sessionUpdated: (session: WizardSessionDTOApi) => {session: WizardSessionDTOApi} // wizardSessionStreamLogic+ handoffDocReceived: (doc: { key: string; startedByEmail: string | null; text: string }) => {+ key: string+ startedByEmail: string | null+ text: string+ } // wizardSyncUiLogicmarkSessionCurrent: () => {value: true}@@ -230,7 +235,9 @@ export interface installationProgressLogicMeta {sessionIsCurrent: boolean,isStalled: boolean,dismissedSessionId: string | null,- arg: any+ activeCloudRun: CloudRunHandle | null,+ arg: any,+ arg2: any) => InstallationProgress}}@@ -288,8 +295,8 @@ export const installationProgressLogic = kea<installationProgressLogicType>([['reportWizardSyncSessionDetected', 'reportWizardSyncSessionFinished'],finishedLocalRunLogic,['recordFinishedLocalRun', 'supersedeFinishedLocalRun'],- wizardDashboardLogic,- ['detectWizardDashboard'],+ wizardSyncUiLogic,+ ['handoffDocReceived'],],})),actions({@@ -316,7 +323,9 @@ export const installationProgressLogic = kea<installationProgressLogicType>([s.sessionIsCurrent,s.isStalled,s.dismissedSessionId,+ s.activeCloudRun,(_, props) => props.mode,+ (_, props) => props.runId,],(taskRunState: TaskRunStreamState | null,@@ -327,10 +336,22 @@ export const installationProgressLogic = kea<installationProgressLogicType>([sessionIsCurrent: boolean,isStalled: boolean,dismissedSessionId: string | null,- mode+ activeCloudRun: CloudRunHandle | null,+ mode,+ runId): InstallationProgress =>mode === 'cloud'- ? cloudProgress(taskRunState, progressSteps, taskConnectionStatus, latestSession, isStalled)+ ? cloudProgress(+ taskRunState,+ progressSteps,+ taskConnectionStatus,+ latestSession,+ isStalled,+ Date.now(),+ // The kickoff stamp scopes the handoff doc to this run (see cloudProgress);+ // a handle for a different run means no window rather than a wrong one.+ activeCloudRun?.runId === runId ? (activeCloudRun?.startedAt ?? null) : null+ ): localProgress(latestSession,sessionConnectionStatus,@@ -339,7 +360,7 @@ export const installationProgressLogic = kea<installationProgressLogicType>([),],}),- listeners(({ actions, props, cache, values }) => ({+ listeners(({ actions, props, cache }) => ({// Once the cloud run is terminal there is nothing left for the session source to enrich —// release this instance's share so an undismissed finished run doesn't keep a session// stream/poll alive app-wide. The share accounting protects a co-mounted local instance,@@ -349,14 +370,6 @@ export const installationProgressLogic = kea<installationProgressLogicType>([return}releaseSessionShare(sessionStreamKey(props), instanceKey(props), actions.disconnectSession)- // The cloud wizard builds a dashboard too — look it up so the completed surfaces can- // link to it. startedAt travels on the persisted run handle; without it there's no run- // window to scope the search to, so skip.- const startedAt =- values.activeCloudRun?.runId === props.runId ? values.activeCloudRun?.startedAt : undefined- if (values.taskRunState?.status === 'completed' && startedAt) {- actions.detectWizardDashboard({ startedAt })- }},// Local-run bookkeeping, owned by the single local-mode instance so cloud instances (which// share the session stream purely for wizard-stage detail) don't double-fire it.@@ -405,6 +418,7 @@ export const installationProgressLogic = kea<installationProgressLogicType>([// session schedule its teardown grace window// - finished-run handle: snapshot a fresh terminal run so its handoff surface outlives the// stream, and supersede the previous run's handle once a new run goes live+// - handoff doc: announce a fresh session's doc so the one-time auto-open dialog can fireexport function runLocalSessionBookkeeping(session: WizardSessionDTOApi,prev: WizardSessionDTOApi | null,@@ -413,6 +427,7 @@ export function runLocalSessionBookkeeping(markSessionCurrent: () => voidrecordFinishedLocalRun: (session: WizardSessionDTOApi) => voidsupersedeFinishedLocalRun: (sessionId: string) => void+ handoffDocReceived: (doc: { key: string; text: string; startedByEmail: string | null }) => voidreportWizardSyncSessionDetected: (props: {workflowId: stringskillId: string@@ -444,6 +459,21 @@ export function runLocalSessionBookkeeping(} else {actions.supersedeFinishedLocalRun(session.session_id)}+ // Freshness-gated like the rest: a stale row's doc was either seen already or belongs to a+ // run nobody is watching. The seen-keys guard makes redeliveries a no-op. Completed only:+ // the buttons that reopen the doc are gated on the completed phase, so announcing it for an+ // errored run would burn the one auto-open on a dialog the user can never get back to.+ if (+ session.run_phase === 'completed' &&+ typeof session.handoff_text === 'string' &&+ session.handoff_text.length > 0+ ) {+ actions.handoffDocReceived({+ key: session.session_id,+ text: session.handoff_text,+ startedByEmail: session.created_by?.email ?? null,+ })+ }// Reach metric: count each live wizard session the sync surfaces, once per session_id.// Gated on freshness so stale terminal rows sitting in the DB — which never reach the// user — don't inflate the funnel.diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.tsindex 1541cb002cec..70a14f550fa2 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.ts@@ -27,6 +27,7 @@ function makeSession(overrides: Partial<WizardSessionDTOApi> = {}): WizardSessioevent_plan: null,error: null,pending_input: null,+ handoff_text: null,created_by: null,created_at: new Date().toISOString(),updated_at: new Date().toISOString(),diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardDashboardLogic.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardDashboardLogic.test.tsdeleted file mode 100644index 768c1221fa6a..000000000000--- a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardDashboardLogic.test.ts+++ /dev/null@@ -1,43 +0,0 @@-import { pickWizardDashboard } from './wizardDashboardLogic'--// The run started at 00:10; the skew window reaches back to 00:08.-const STARTED_AT = '2026-01-01T00:10:00Z'--function dash(- overrides: Partial<Parameters<typeof pickWizardDashboard>[0][number]> = {}-): Parameters<typeof pickWizardDashboard>[0][number] {- return {- id: 1,- name: 'Product analytics',- created_at: '2026-01-01T00:15:00Z',- deleted: false,- creation_mode: 'default',- ...overrides,- }-}--describe('pickWizardDashboard', () => {- it.each([- // Wrongly matching here surfaces a "See your dashboard" CTA pointing at somebody's- // pre-existing or template dashboard — worse than showing nothing.- ['created during the run', [dash()], 1],- ['created before the run', [dash({ created_at: '2026-01-01T00:00:00Z' })], null],- ['created within the clock-skew window', [dash({ created_at: '2026-01-01T00:09:00Z' })], 1],- ['a template dashboard', [dash({ creation_mode: 'template' })], null],- ['a deleted dashboard', [dash({ deleted: true })], null],- ['an unparseable created_at', [dash({ created_at: 'not-a-date' })], null],- [- 'multiple matches → newest wins',- [dash({ id: 1, created_at: '2026-01-01T00:12:00Z' }), dash({ id: 2, created_at: '2026-01-01T00:20:00Z' })],- 2,- ],- ['no dashboards at all', [], null],- ])('%s', (_name, dashboards, expectedId) => {- const result = pickWizardDashboard(dashboards, STARTED_AT)- expect(result?.id ?? null).toBe(expectedId)- })-- it('returns null when the run start time is unparseable', () => {- expect(pickWizardDashboard([dash()], 'not-a-date')).toBeNull()- })-})diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardDashboardLogic.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardDashboardLogic.tsdeleted file mode 100644index ed1239f14781..000000000000--- a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardDashboardLogic.ts+++ /dev/null@@ -1,123 +0,0 @@-import { MakeLogicType, connect, kea, path } from 'kea'-import { loaders } from 'kea-loaders'--import { projectLogic } from 'scenes/projectLogic'--import { dashboardsList } from 'products/dashboards/frontend/generated/api'-import type { DashboardBasicApi } from 'products/dashboards/frontend/generated/api.schemas'--// The wizard stamps started_at from its own clock (the user's machine or the sandbox), while-// dashboard created_at is server time — tolerate a skewed CLI clock so a dashboard created in the-// first seconds of a run isn't filtered out.-const CLOCK_SKEW_MS = 2 * 60 * 1000--// One page is plenty: detection runs during onboarding, where the project holds at most a handful-// of dashboards. If the wizard's dashboard falls outside this page the CTA silently doesn't show.-const DETECTION_PAGE_SIZE = 100--export interface DetectedDashboard {- id: number- name: string | null-}--type DashboardCandidate = Pick<DashboardBasicApi, 'id' | 'name' | 'created_at' | 'deleted' | 'creation_mode'>--/**- * The dashboard most likely created by the wizard during this run: the newest non-template- * dashboard created after the run started (with clock-skew tolerance). Heuristic by design — the- * wizard doesn't report the dashboard it built, so a dashboard the user created mid-run can match.- * Returns null when nothing plausible exists, in which case no CTA is shown.- */-export function pickWizardDashboard(dashboards: DashboardCandidate[], startedAt: string): DetectedDashboard | null {- const startedAtMs = new Date(startedAt).getTime()- if (Number.isNaN(startedAtMs)) {- return null- }- const cutoff = startedAtMs - CLOCK_SKEW_MS- const candidates = dashboards.filter((d) => {- if (d.deleted || d.creation_mode === 'template') {- return false- }- const createdAt = new Date(d.created_at).getTime()- return !Number.isNaN(createdAt) && createdAt >= cutoff- })- candidates.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())- const top = candidates[0]- return top ? { id: top.id, name: top.name ?? null } : null-}--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface wizardDashboardLogicValues {- currentProjectId: number | null // projectLogic- detectedDashboard: DetectedDashboard | null- detectedDashboardLoading: boolean-}--// Generated by kea-typegen. Update if you're an agent, ignore if you're human.-export interface wizardDashboardLogicActions {- detectWizardDashboard: ({ startedAt }: { startedAt: string }) => {- startedAt: string- }- detectWizardDashboardFailure: (- error: string,- errorObject?: any- ) => {- error: string- errorObject?: any- }- detectWizardDashboardSuccess: (- detectedDashboard: DetectedDashboard | null,- payload?: {- startedAt: string- }- ) => {- detectedDashboard: DetectedDashboard | null- payload?: {- startedAt: string- }- }-}--export type wizardDashboardLogicType = MakeLogicType<wizardDashboardLogicValues, wizardDashboardLogicActions>--/**- * Detects the dashboard the wizard was instructed to build, so completed-run surfaces can hand the- * user straight to it. Fired by the Installation layer when a run (local or cloud) completes;- * fetches once per (project, run start) and fails silent — the dashboard CTA is a bonus, never a- * blocker.- */-export const wizardDashboardLogic = kea<wizardDashboardLogicType>([- path(['scenes', 'onboarding', 'wizardDashboardLogic']),- connect(() => ({- values: [projectLogic, ['currentProjectId']],- })),- loaders(({ values, cache }) => ({- detectedDashboard: [- null as DetectedDashboard | null,- {- detectWizardDashboard: async ({ startedAt }: { startedAt: string }, breakpoint) => {- const projectId = values.currentProjectId- if (projectId === null) {- return values.detectedDashboard- }- // One fetch per run: every surface that shows the completed state dispatches- // this, and re-listing dashboards for each of them buys nothing.- const attempted: Set<string> = (cache.attemptedRuns ??= new Set())- const key = `${projectId}:${startedAt}`- if (attempted.has(key)) {- return values.detectedDashboard- }- attempted.add(key)- try {- const page = await dashboardsList(String(projectId), { limit: DETECTION_PAGE_SIZE })- breakpoint()- return pickWizardDashboard(page.results ?? [], startedAt) ?? values.detectedDashboard- } catch {- // Detection is best-effort: a failed list just means no dashboard CTA.- return values.detectedDashboard- }- },- },- ],- })),-])diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.test.tsindex 81f8f1a6740f..e800141a9b4f 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.test.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.test.ts@@ -1,3 +1,7 @@+import { MOCK_DEFAULT_USER } from 'lib/api.mock'++import { userLogic } from 'scenes/userLogic'+import { initKeaTests } from '~/test/init'import { wizardSyncUiLogic } from './wizardSyncUiLogic'@@ -43,4 +47,45 @@ describe('wizardSyncUiLogic inline panel refcount', () => {expect(logic.values.inlineCloudPanelMounted).toBe(false)expect(logic.values.inlinePanelMounted).toBe(true)})++ // The one-time auto-open is the feature's contract: the SSE replays the latest session on every+ // connect, so without the seen guard the doc dialog would pop on every reload and navigation.+ // seenHandoffDocKeys persists to localStorage, so each test uses its own doc keys.+ describe('handoff doc auto-open', () => {+ it('opens on the first announcement only, keyed per run', () => {+ logic.actions.handoffDocReceived({ key: 'run-1', text: '# report', startedByEmail: null })+ expect(logic.values.handoffDoc).toEqual({ key: 'run-1', text: '# report' })++ logic.actions.closeHandoffDoc()+ logic.actions.handoffDocReceived({ key: 'run-1', text: '# report', startedByEmail: null })+ expect(logic.values.handoffDoc).toBeNull()++ logic.actions.handoffDocReceived({ key: 'run-2', text: '# other', startedByEmail: null })+ expect(logic.values.handoffDoc).toEqual({ key: 'run-2', text: '# other' })+ })++ it('a doc already read through the button never auto-opens later', () => {+ logic.actions.openHandoffDoc({ key: 'run-3', text: '# report' })+ logic.actions.closeHandoffDoc()++ logic.actions.handoffDocReceived({ key: 'run-3', text: '# report', startedByEmail: null })+ expect(logic.values.handoffDoc).toBeNull()+ })++ it("does not auto-open for a teammate's run", () => {+ userLogic.mount()+ userLogic.actions.loadUserSuccess(MOCK_DEFAULT_USER)++ logic.actions.handoffDocReceived({ key: 'run-4', text: '# report', startedByEmail: '[email protected]' })+ expect(logic.values.handoffDoc).toBeNull()++ // The runner themselves (or an unattributed run) still gets the auto-open.+ logic.actions.handoffDocReceived({+ key: 'run-5',+ text: '# report',+ startedByEmail: MOCK_DEFAULT_USER.email,+ })+ expect(logic.values.handoffDoc).toEqual({ key: 'run-5', text: '# report' })+ })+ })})diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.tsindex 8118a8378228..27509c0105ba 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardSyncUiLogic.ts@@ -1,32 +1,69 @@-import { MakeLogicType, actions, kea, path, reducers, selectors } from 'kea'+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'++import { userLogic } from 'scenes/userLogic'++import type { UserType } from '~/types'++import { onboardingEventUsageLogic } from '../../onboardingEventUsageLogic'++// Enough to outlast any realistic run history on one browser without letting the persisted list+// grow forever.+const SEEN_HANDOFF_DOC_KEYS_CAP = 20/** Where a run is executing: in the user's terminal, or on our infrastructure. */export type WizardSyncMode = 'cloud' | 'local'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface wizardSyncUiLogicValues {+ user: UserType | null // userLogicdialogOpen: booleandismissedKey: string | null+ handoffDoc: {+ key: string+ text: string+ } | nullinlineCloudPanelMounted: booleaninlineLocalPanelMounted: booleaninlinePanelCounts: Record<WizardSyncMode, number>inlinePanelMounted: boolean+ seenHandoffDocKeys: string[]}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface wizardSyncUiLogicActions {+ reportWizardSyncHandoffDocOpened: (props: {+ mode: 'cloud' | 'local'+ runKey: string+ trigger: 'auto' | 'button'+ }) => {+ mode: 'cloud' | 'local'+ runKey: string+ trigger: 'auto' | 'button'+ } // onboardingEventUsageLogicclaimInlinePanel: (mode: WizardSyncMode) => {mode: WizardSyncMode}closeDialog: () => {value: true}+ closeHandoffDoc: () => {+ value: true+ }dismiss: (key: string) => {key: string}+ handoffDocReceived: (doc: { key: string; startedByEmail: string | null; text: string }) => {+ key: string+ startedByEmail: string | null+ text: string+ }openDialog: () => {value: true}+ openHandoffDoc: (doc: { key: string; text: string }) => {+ key: string+ text: string+ }releaseInlinePanel: (mode: WizardSyncMode) => {mode: WizardSyncMode}@@ -61,11 +98,19 @@ export type wizardSyncUiLogicType = MakeLogicType<* rather than showing it twice. Refcounted: a boolean would let one panel's unmount un-hide the* widget while another is still showing. Tracked per mode because cloud and local runs can be in* flight at once, and a surface that only ever renders one of them must not silence the other.+ * - `handoffDoc`: the markdown handoff doc dialog currently showing (content is fed by whichever+ * source announced or opened it). `seenHandoffDocKeys` (persisted) makes the announce-driven+ * open a strictly once-per-run event: SSE replays, remounts, and reloads re-announce the same+ * doc, and only the first announcement may pop the dialog. The button reopens it at will.** The widget itself owns no run data; the per-mode inner components feed it the normalized progress.*/export const wizardSyncUiLogic = kea<wizardSyncUiLogicType>([path(['scenes', 'onboarding', 'wizardSyncUiLogic']),+ connect(() => ({+ values: [userLogic, ['user']],+ actions: [onboardingEventUsageLogic, ['reportWizardSyncHandoffDocOpened']],+ })),actions({dismiss: (key: string) => ({ key }),restore: true,@@ -73,6 +118,12 @@ export const wizardSyncUiLogic = kea<wizardSyncUiLogicType>([closeDialog: true,claimInlinePanel: (mode: WizardSyncMode) => ({ mode }),releaseInlinePanel: (mode: WizardSyncMode) => ({ mode }),+ // A run's handoff doc was delivered (live session push, SSE replay, or a persisted+ // finished-run handle restored on pageload). Announcements are idempotent; the listener+ // decides whether this one gets the one-time auto-open.+ handoffDocReceived: (doc: { key: string; text: string; startedByEmail: string | null }) => doc,+ openHandoffDoc: (doc: { key: string; text: string }) => doc,+ closeHandoffDoc: true,}),reducers({dismissedKey: [@@ -98,6 +149,23 @@ export const wizardSyncUiLogic = kea<wizardSyncUiLogicType>([releaseInlinePanel: (state, { mode }) => ({ ...state, [mode]: Math.max(0, state[mode] - 1) }),},],+ handoffDoc: [+ null as { key: string; text: string } | null,+ {+ openHandoffDoc: (_, { key, text }) => ({ key, text }),+ closeHandoffDoc: () => null,+ },+ ],+ seenHandoffDocKeys: [+ [] as string[],+ { persist: true },+ {+ // Any open counts as seen — a doc the user already read through the button must not+ // auto-open later.+ openHandoffDoc: (state, { key }) =>+ state.includes(key) ? state : [...state, key].slice(-SEEN_HANDOFF_DOC_KEYS_CAP),+ },+ ],}),selectors({inlineCloudPanelMounted: [@@ -115,4 +183,21 @@ export const wizardSyncUiLogic = kea<wizardSyncUiLogicType>([inlineCloudPanelMounted || inlineLocalPanelMounted,],}),+ listeners(({ actions, values }) => ({+ handoffDocReceived: ({ key, text, startedByEmail }) => {+ if (values.seenHandoffDocKeys.includes(key)) {+ return+ }+ // A teammate's run: popping a dialog because someone else's terminal finished would be+ // an interruption, not a handoff. They still get the button on the run's surfaces.+ // Not marked seen, so the doc can still auto-open for the teammate who did run it.+ const ownEmail = values.user?.email+ if (startedByEmail && ownEmail && startedByEmail !== ownEmail) {+ return+ }+ actions.openHandoffDoc({ key, text })+ // Announcements only come from local runs (cloud runs surface their doc via the button).+ actions.reportWizardSyncHandoffDocOpened({ runKey: key, mode: 'local', trigger: 'auto' })+ },+ })),])diff --git a/products/wizard/backend/facade/contracts.py b/products/wizard/backend/facade/contracts.pyindex 168436dc7e86..f523ccb18e4e 100644--- a/products/wizard/backend/facade/contracts.py+++ b/products/wizard/backend/facade/contracts.py@@ -40,6 +40,7 @@ class WizardSessionDTO:event_plan: dict[str, Any] | Noneerror: dict[str, Any] | Nonepending_input: dict[str, Any] | None+ handoff_text: str | Nonecreated_by: WizardSessionUserDTO | Nonecreated_at: datetimeupdated_at: datetime@@ -63,6 +64,7 @@ class UpsertWizardSessionRequest:event_plan: dict[str, Any] | None = Noneerror: dict[str, Any] | None = Nonepending_input: dict[str, Any] | None = None+ handoff_text: str | None = None@dataclass(frozen=True)@@ -77,5 +79,6 @@ class UpsertWizardSessionInput:event_plan: dict[str, Any] | Noneerror: dict[str, Any] | Nonepending_input: dict[str, Any] | None+ handoff_text: str | None = None# Set on create only, never overwritten on later pushes for the same run.created_by_id: int | None = Nonediff --git a/products/wizard/backend/logic/sessions.py b/products/wizard/backend/logic/sessions.pyindex 36d95f37e2cb..242876aed0ed 100644--- a/products/wizard/backend/logic/sessions.py+++ b/products/wizard/backend/logic/sessions.py@@ -57,6 +57,13 @@ def upsert_session(params: UpsertWizardSessionInput) -> tuple[WizardSessionDTO,if event_plan is None and params.run_phase == RunPhase.COMPLETED and previous_session:event_plan = previous_session.event_plan+ # Monotonic within a session: the doc arrives late in the run, so a push without it+ # (an ordering race between debounced snapshots, or an older CLI) must not wipe it.+ # A new run is a new session_id, so nothing ever needs to clear the field.+ handoff_text = params.handoff_text+ if not handoff_text and previous_session:+ handoff_text = previous_session.handoff_text+defaults = {"workflow_id": params.workflow_id,"skill_id": params.skill_id,@@ -73,6 +80,7 @@ def upsert_session(params: UpsertWizardSessionInput) -> tuple[WizardSessionDTO,"event_plan": event_plan,"error": params.error,"pending_input": params.pending_input,+ "handoff_text": handoff_text,}# created_by only in create_defaults so a later push for the same run can't reattribute it.instance, created = WizardSession.objects.update_or_create(@@ -164,6 +172,7 @@ def _to_dto(instance: WizardSession) -> WizardSessionDTO:event_plan=instance.event_plan,error=instance.error,pending_input=instance.pending_input,+ handoff_text=instance.handoff_text,created_by=(WizardSessionUserDTO(id=created_by.id, first_name=created_by.first_name, email=created_by.email)if created_by is not Nonediff --git a/products/wizard/backend/migrations/0005_wizardsession_handoff_text.py b/products/wizard/backend/migrations/0005_wizardsession_handoff_text.pynew file mode 100644index 000000000000..d6fd03007089--- /dev/null+++ b/products/wizard/backend/migrations/0005_wizardsession_handoff_text.py@@ -0,0 +1,17 @@+# Generated by Django 5.2.14 on 2026-07-30 18:16++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("wizard", "0004_wizardsession_created_by"),+ ]++ operations = [+ migrations.AddField(+ model_name="wizardsession",+ name="handoff_text",+ field=models.TextField(blank=True, null=True),+ ),+ ]diff --git a/products/wizard/backend/migrations/max_migration.txt b/products/wizard/backend/migrations/max_migration.txtindex 146cb913701c..af339652e44a 100644--- a/products/wizard/backend/migrations/max_migration.txt+++ b/products/wizard/backend/migrations/max_migration.txt@@ -1 +1 @@-0004_wizardsession_created_by+0005_wizardsession_handoff_textdiff --git a/products/wizard/backend/models.py b/products/wizard/backend/models.pyindex 239f84a0b245..5157cbc45265 100644--- a/products/wizard/backend/models.py+++ b/products/wizard/backend/models.py@@ -42,6 +42,10 @@ class WizardSession(UUIDModel, TeamScopedRootMixin, CreatedMetaFields):# Null means no input is pending — each push replaces it, so the CLI clearing the# question is just the next upsert without the field.pending_input = models.JSONField(null=True, blank=True)+ # The markdown handoff doc (the wizard's setup report) once the run has produced one.+ # Unlike the fields above it is monotonic within a session: a push without it keeps+ # the stored value (see upsert_session), since the doc arrives late in the run.+ handoff_text = models.TextField(null=True, blank=True)updated_at = models.DateTimeField(auto_now=True)diff --git a/products/wizard/backend/presentation/serializers.py b/products/wizard/backend/presentation/serializers.pyindex 1e92ca4f7ad0..d25752940b6b 100644--- a/products/wizard/backend/presentation/serializers.py+++ b/products/wizard/backend/presentation/serializers.py@@ -13,6 +13,11 @@ from products.wizard.backend.facade.contracts import UpsertWizardSessionRequest,MAX_PROMPT_LENGTH = 2000MAX_PROMPTS = 10+# Bound on the handoff doc. It IS a document (the wizard's setup report, a few KB of markdown in+# practice), but the row is streamed over SSE and republished on every later upsert, so cap it well+# below anything a hostile push could use to balloon the channel. The CLI truncates to the same cap.+MAX_HANDOFF_TEXT_LENGTH = 64 * 1024+class PendingInputSerializer(serializers.Serializer):"""The in-flight `wizard_ask` question. Typed rather than a free-form dict so the shape the@@ -73,6 +78,12 @@ class WizardSessionSerializer(DataclassSerializer):"attribution existed). Lets the UI name whose run it is."),},+ "handoff_text": {+ "help_text": (+ "Markdown handoff doc the wizard produced for this run (its setup report), "+ "or null while the run hasn't written one. Sticky once set."+ ),+ },}@@ -87,6 +98,18 @@ class UpsertWizardSessionRequestSerializer(DataclassSerializer):"Null/absent means no input is pending; a push without it clears the previous prompt."),)+ # trim_whitespace would mangle markdown that opens with indentation (e.g. a code block).+ handoff_text = serializers.CharField(+ required=False,+ allow_null=True,+ allow_blank=True,+ trim_whitespace=False,+ max_length=MAX_HANDOFF_TEXT_LENGTH,+ help_text=(+ "Markdown handoff doc for the run (the wizard's setup report). Send it once the run "+ "has produced one; omitting it on later pushes keeps the stored value."+ ),+ )class Meta:dataclass = UpsertWizardSessionRequestdiff --git a/products/wizard/backend/presentation/views.py b/products/wizard/backend/presentation/views.pyindex 9027bea634e9..d70a1ef4a253 100644--- a/products/wizard/backend/presentation/views.py+++ b/products/wizard/backend/presentation/views.py@@ -296,6 +296,7 @@ class WizardSessionViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):event_plan=req.event_plan,error=req.error,pending_input=req.pending_input,+ handoff_text=req.handoff_text,created_by_id=created_by_id,))diff --git a/products/wizard/backend/tests/test_logic.py b/products/wizard/backend/tests/test_logic.pyindex 0b4b441c7ce0..5d9f5304e306 100644--- a/products/wizard/backend/tests/test_logic.py+++ b/products/wizard/backend/tests/test_logic.py@@ -67,6 +67,20 @@ def test_upsert_round_trips_pending_input(team):assert cleared.pending_input is None+def test_upsert_handoff_text_survives_pushes_without_it(team):+ with_doc, _ = wizard_facade.upsert(_input(team.id, handoff_text="# Setup report"))+ assert with_doc.handoff_text == "# Setup report"++ # Unlike pending_input, the doc is monotonic: later full-state pushes without it keep it.+ for omitted in (None, ""):+ preserved, _ = wizard_facade.upsert(_input(team.id, handoff_text=omitted))+ assert preserved.handoff_text == "# Setup report"++ rewritten, _ = wizard_facade.upsert(_input(team.id, handoff_text="# Setup report, revised"))+ assert rewritten.handoff_text == "# Setup report, revised"++@pytest.mark.django_db@patch("products.wizard.backend.logic.sessions.sync_wizard_event_definitions.delay")def test_upsert_with_same_session_id_replaces_state(_mock_sync, team):diff --git a/products/wizard/backend/tests/test_presentation.py b/products/wizard/backend/tests/test_presentation.pyindex 7ae6e9e8789b..e77f2e34d258 100644--- a/products/wizard/backend/tests/test_presentation.py+++ b/products/wizard/backend/tests/test_presentation.py@@ -374,6 +374,17 @@ class TestWizardSessionViewSet(APIBaseTest):self.assertEqual(data["event_plan"], {"events": [{"name": "$pageview"}]})self.assertEqual(data["error"], {"type": "TimeoutError", "message": "Anthropic API timed out"})+ def test_handoff_text_persists_across_pushes_without_it(self):+ # Leading indentation must survive validation: the doc is markdown, where it is syntax.+ doc = " indented code block\n\n# Setup report"+ response = self.client.post(self._url(), self._payload(handoff_text=doc), format="json")+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)+ self.assertEqual(response.json()["handoff_text"], doc)++ response = self.client.post(self._url(), self._payload(), format="json")+ self.assertEqual(response.status_code, status.HTTP_200_OK)+ self.assertEqual(response.json()["handoff_text"], doc)+def test_stream_requires_workflow_id(self):# No params → 400 from the view-level validation (workflow_id is the# only required query param; skill_id is optional for pattern subscribe).diff --git a/products/wizard/backend/tests/test_pubsub.py b/products/wizard/backend/tests/test_pubsub.pyindex eea6f12bd129..24bec1615f61 100644--- a/products/wizard/backend/tests/test_pubsub.py+++ b/products/wizard/backend/tests/test_pubsub.py@@ -28,6 +28,7 @@ def _dto(team_id: int = 1) -> WizardSessionDTO:event_plan=None,error=None,pending_input=None,+ handoff_text=None,created_by=None,created_at=now,updated_at=now,diff --git a/products/wizard/frontend/generated/api.schemas.ts b/products/wizard/frontend/generated/api.schemas.tsindex b358a4e55400..42492345605e 100644--- a/products/wizard/frontend/generated/api.schemas.ts+++ b/products/wizard/frontend/generated/api.schemas.ts@@ -106,6 +106,11 @@ export interface WizardSessionDTOApi {event_plan: WizardSessionDTOApiEventPlan/** @nullable */error: WizardSessionDTOApiError+ /**+ * Markdown handoff doc the wizard produced for this run (its setup report), or null while the run hasn't written one. Sticky once set.+ * @nullable+ */+ handoff_text: string | null/** The user who initiated this wizard run (null for runs created before attribution existed). Lets the UI name whose run it is. */created_by: WizardSessionUserDTOApi | nullcreated_at: string@@ -140,6 +145,12 @@ export type UpsertWizardSessionRequestApiError = { [key: string]: unknown } | nuexport interface UpsertWizardSessionRequestApi {/** Populated while the wizard is blocked on a question in the terminal. Null/absent means no input is pending; a push without it clears the previous prompt. */pending_input?: PendingInputApi | null+ /**+ * Markdown handoff doc for the run (the wizard's setup report). Send it once the run has produced one; omitting it on later pushes keeps the stored value.+ * @maxLength 65536+ * @nullable+ */+ handoff_text?: string | null/*** Stable identifier the wizard mints for this run (format: '{workflow_id}-{skill_id}-{started_at_iso}'). Reposting with the same session_id upserts the existing row.* @maxLength 255diff --git a/products/wizard/frontend/generated/api.zod.ts b/products/wizard/frontend/generated/api.zod.tsindex 49ee3e1f4bf1..61607177ffa5 100644--- a/products/wizard/frontend/generated/api.zod.ts+++ b/products/wizard/frontend/generated/api.zod.ts@@ -21,6 +21,8 @@ export const wizardSessionsCreateBodyPendingInputOnePromptsItemMax = 2000export const wizardSessionsCreateBodyPendingInputOnePromptsMax = 10+export const wizardSessionsCreateBodyHandoffTextMax = 65536+export const wizardSessionsCreateBodySessionIdMax = 255export const wizardSessionsCreateBodyWorkflowIdMax = 255@@ -70,6 +72,13 @@ export const WizardSessionsCreateBody = /* @__PURE__ */ zod.describe('Populated while the wizard is blocked on a question in the terminal. Null\/absent means no input is pending; a push without it clears the previous prompt.'),+ handoff_text: zod+ .string()+ .max(wizardSessionsCreateBodyHandoffTextMax)+ .nullish()+ .describe(+ "Markdown handoff doc for the run (the wizard's setup report). Send it once the run has produced one; omitting it on later pushes keeps the stored value."+ ),session_id: zod.string().max(wizardSessionsCreateBodySessionIdMax)diff --git a/products/wizard/frontend/wizardSessionStreamLogic.test.ts b/products/wizard/frontend/wizardSessionStreamLogic.test.tsindex 6d8a05e9258b..dfb919b9c802 100644--- a/products/wizard/frontend/wizardSessionStreamLogic.test.ts+++ b/products/wizard/frontend/wizardSessionStreamLogic.test.ts@@ -34,6 +34,7 @@ function makeSession(overrides: Partial<WizardSessionDTOApi> = {}): WizardSessioevent_plan: null,error: null,pending_input: null,+ handoff_text: null,created_by: null,created_at: '2026-01-01T00:00:00Z',updated_at: '2026-01-01T00:00:00Z',diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex ae0c317fd024..6c67277b9ee4 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -48730,6 +48730,11 @@ export namespace Schemas {event_plan: WizardSessionDTOEventPlan;/** @nullable */error: WizardSessionDTOError;+ /**+ * Markdown handoff doc the wizard produced for this run (its setup report), or null while the run hasn't written one. Sticky once set.+ * @nullable+ */+ handoff_text: string | null;/** The user who initiated this wizard run (null for runs created before attribution existed). Lets the UI name whose run it is. */created_by: WizardSessionUserDTO | null;created_at: string;@@ -72096,6 +72101,12 @@ export namespace Schemas {export interface UpsertWizardSessionRequest {/** Populated while the wizard is blocked on a question in the terminal. Null/absent means no input is pending; a push without it clears the previous prompt. */pending_input?: PendingInput | null;+ /**+ * Markdown handoff doc for the run (the wizard's setup report). Send it once the run has produced one; omitting it on later pushes keeps the stored value.+ * @maxLength 65536+ * @nullable+ */+ handoff_text?: string | null;/*** Stable identifier the wizard mints for this run (format: '{workflow_id}-{skill_id}-{started_at_iso}'). Reposting with the same session_id upserts the existing row.* @maxLength 255