: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): surface the agent's pending question in the sync widget (#74324)
Fernando Gomesc28bb08b34ab
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex d523fc46ad38..d1a56ba7831f 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7758,6 +7758,14 @@ snapshots:hash: v1.k794b7964.8ebd0fb0b9db1f2cc68bcb63d890a44003403e27688a938e5cb04fbffb3b5d5e.aKxLz7jngQZcJL6b0nrArk3V-pDEoGNoPsYUiGbIYy4scenes-other-onboarding-shared-wizard-sync-card--local-running--light:hash: v1.k794b7964.644de0941a464befbdd1c1173307918762ec7bf580d08b6bb73e0170da71ab57.roPN1jIIWT47y5Xh3Gluqd744nCUVhJkfniX1oq__3M+ scenes-other-onboarding-shared-wizard-sync-card--local-waiting-for-input--dark:+ hash: v1.k794b7964.882a0f73b32a910ae1582ef69720f025078bc35867e04d6a03e4931999999ae1.udwLNxP_oZh1qhyS1Ce07RtoSfNpckSBGlOxC41rVp0+ scenes-other-onboarding-shared-wizard-sync-card--local-waiting-for-input--light:+ hash: v1.k794b7964.9369015b4d74aebf27366e91a570c6d59f1cf2424f3b4c8de7bab1bf2a6cee16.Xu1mzkKb3bbUjVa7FC-lADj0seNneKJtEBvNaPcZwvI+ scenes-other-onboarding-shared-wizard-sync-card--local-waiting-for-sensitive-input--dark:+ hash: v1.k794b7964.f074463c40fd8b34d0ca55c651b409fb35668ecc69fefb4e631208b3f5db1bde.zioGxlu5eKa64EXl2wzmAT4K-EC_0eK5uoUMxZIu98Y+ scenes-other-onboarding-shared-wizard-sync-card--local-waiting-for-sensitive-input--light:+ hash: v1.k794b7964.57524d53d6835dd9472c87a6aca291266fb8e8971d95ba311842386f94347fc8.sMjUBzJVzLkCThwa5LT8ntVK63w5tJ0lYltmn2pD70Escenes-other-onboarding-shared-wizard-sync-card--playground--dark:hash: v1.k794b7964.c69534afe39d0311b0ed3247beb145b94381706a25f2e6c7b5d3415c87564375.ViSw0_amXLmDYynCEuR_kgnY5Ncm4ULveglgIJoTIaUscenes-other-onboarding-shared-wizard-sync-card--playground--light:diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsxindex fd57ce6fdd6f..a698543c981c 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/InstallationProgressView.stories.tsx@@ -45,7 +45,16 @@ function steps(}function progress(overrides: Partial<InstallationProgress>): InstallationProgress {- return { phase: 'running', steps: [], error: null, prUrl: null, prMerged: false, isCurrent: true, ...overrides }+ return {+ phase: 'running',+ steps: [],+ error: null,+ prUrl: null,+ prMerged: false,+ isCurrent: true,+ pendingInput: null,+ ...overrides,+ }}export const Connecting: Story = {diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsxindex 8635e0518863..47a1262fd012 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.stories.tsx@@ -50,13 +50,67 @@ function cloudSteps(}function progress(overrides: Partial<InstallationProgress>): InstallationProgress {- return { phase: 'running', steps: [], error: null, prUrl: null, prMerged: false, isCurrent: true, ...overrides }+ return {+ phase: 'running',+ steps: [],+ error: null,+ prUrl: null,+ prMerged: false,+ isCurrent: true,+ pendingInput: null,+ ...overrides,+ }}export const Connecting: Story = {args: { mode: 'cloud', elapsedSeconds: 3, progress: progress({ phase: 'connecting' }) },}+// Local, the agent is blocked on a wizard_ask in the terminal: the question leads the card in the+// warning tone. The call to go back to the terminal leads; the question sits under it.+export const LocalWaitingForInput: Story = {+ args: {+ mode: 'local',+ elapsedSeconds: 74,+ progress: progress({+ steps: [+ { id: '0', label: 'Detect framework', status: 'completed', detail: null },+ { id: '1', label: 'Install the SDK', status: 'in_progress', detail: null },+ { id: '2', label: 'Instrument events', status: 'pending', detail: null },+ ],+ pendingInput: {+ id: 'ask-1',+ askedAt: '2026-01-01T00:01:00Z',+ questionCount: 1,+ sensitive: false,+ prompts: ['Which region is your project in?'],+ },+ }),+ },+}++// A secret was asked for, so no prompt text is published and the call to action stands alone.+export const LocalWaitingForSensitiveInput: Story = {+ args: {+ mode: 'local',+ elapsedSeconds: 74,+ progress: progress({+ steps: [+ { id: '0', label: 'Detect framework', status: 'completed', detail: null },+ { id: '1', label: 'Install the SDK', status: 'in_progress', detail: null },+ { id: '2', label: 'Instrument events', status: 'pending', detail: null },+ ],+ pendingInput: {+ id: 'ask-2',+ askedAt: '2026-01-01T00:01:00Z',+ questionCount: 1,+ sensitive: true,+ prompts: [],+ },+ }),+ },+}+// Cloud, wizard phase: the wizard's live sub-task ("Capturing events") leads the card.export const CloudWizardRunning: Story = {args: {diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsxindex aeb97d96e0ef..2a383c290a8a 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncCard.tsx@@ -5,6 +5,7 @@ import {IconExpand45,IconLaptop,IconPullRequest,+ IconQuestion,IconWarning,IconX,} from '@posthog/icons'@@ -17,6 +18,7 @@ import {currentTaskLabel,elapsedLabel,formatElapsed,+ pendingQuestionLabel,pipClass,prNameLabel,stepCounts,@@ -40,6 +42,9 @@ export function StatusGlyph({ progress }: { progress: InstallationProgress }): Jif (progress.prMerged) {return <IconPullRequest className="text-purple text-xl shrink-0" />}+ if (progress.pendingInput) {+ return <IconQuestion className="text-warning text-xl shrink-0" />+ }return <Spinner className="text-xl shrink-0 text-accent" textColored />}@@ -86,6 +91,7 @@ export function WizardSyncCard({}): JSX.Element {const { completed, total } = stepCounts(progress.steps)const task = currentTaskLabel(progress)+ const question = pendingQuestionLabel(progress)const isRunning = progress.phase !== 'completed' && progress.phase !== 'error'return (@@ -111,6 +117,13 @@ export function WizardSyncCard({{task}</p><p className="m-0 text-xs text-muted truncate">{syncHeadline(progress)}</p>+ {question && (+ // ph-no-capture: the prompt is whatever the wizard asked, so it can+ // carry project detail that must not reach autocapture.+ <p className="m-0 text-xs text-tertiary truncate ph-no-capture" title={question}>+ {question}+ </p>+ )}</div><span className="text-xs text-muted tabular-nums shrink-0" title={formatElapsed(elapsedSeconds)}>{elapsedLabel(elapsedSeconds, stale)}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncFab.tsx b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncFab.tsxindex 808f34a1782b..9c94deb13180 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncFab.tsx+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/WizardSyncFab.tsx@@ -194,7 +194,9 @@ function WizardSyncSurface({const endMs = endedAt ? new Date(endedAt).getTime() : NaNconst now = useNow(!Number.isNaN(endMs))const elapsedSeconds = startedAt ? elapsedSecondsFrom(startedAt, Number.isNaN(endMs) ? now : endMs) : 0- const minimized = dismissedKey === runKey+ // Input-required overrides minimize: the user who tucked the widget away mid-run is exactly the+ // one who will miss the prompt. The server clearing pending_input restores their choice.+ const minimized = dismissedKey === runKey && !progress.pendingInputconst isTerminal = progress.phase === 'completed' || progress.phase === 'error'// 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.diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.test.tsindex 943aa794bb65..fc4822a81a17 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.test.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.test.ts@@ -1,14 +1,16 @@import {activeStep,+ currentTaskLabel,elapsedLabel,formatElapsed,isRunStale,isStreamLost,+ pendingQuestionLabel,prName,STALE_RUN_MAX_AGE_MS,STALE_RUN_SILENCE_MS,} from './helpers'-import type { InstallationStep } from './installationProgressLogic'+import type { InstallationProgress, InstallationStep } from './installationProgressLogic'import type { TaskRunConnectionStatus } from './taskRunStreamLogic'const NOW = new Date('2026-01-01T12:00:00Z').getTime()@@ -115,4 +117,36 @@ describe('wizard-sync helpers', () => {])('prName(%s) → %s', (url, expected) => {expect(prName(url)).toBe(expected)})++ describe('a pending question', () => {+ const withQuestion = (prompts: string[], sensitive = false): InstallationProgress =>+ ({+ phase: 'running',+ steps: [{ id: '1', label: 'Install the SDK', status: 'in_progress', detail: null }],+ error: null,+ prUrl: null,+ prMerged: false,+ isCurrent: true,+ pendingInput: { id: 'ask-1', askedAt: iso(0), questionCount: 1, sensitive, prompts },+ }) as InstallationProgress++ // The user is looking at the app, not the terminal, so the prominent line has to be the+ // instruction to go back there. Leading with the question buried that.+ it('leads with the call to action, not the question', () => {+ const progress = withQuestion(['Which region is your project in?'])+ expect(currentTaskLabel(progress)).toBe('Your terminal needs your attention')+ expect(currentTaskLabel(progress)).not.toContain('region')+ })++ it('carries the question separately, so it can render below the call to action', () => {+ expect(pendingQuestionLabel(withQuestion(['Which region is your project in?']))).toBe(+ 'Which region is your project in?'+ )+ })++ it('has no question to show for a sensitive ask', () => {+ expect(pendingQuestionLabel(withQuestion([], true))).toBeNull()+ expect(currentTaskLabel(withQuestion([], true))).toBe('Your terminal needs your attention')+ })+ })})diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.tsindex f0a1b47fedec..9c1c74adb429 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/helpers.ts@@ -87,6 +87,9 @@ export function syncHeadline(progress: InstallationProgress): string {if (progress.prUrl) {return 'Pull request ready'}+ if (progress.pendingInput) {+ return 'Waiting for your answer'+ }if (progress.phase === 'connecting') {return 'Getting ready'}@@ -112,6 +115,12 @@ export function currentTaskLabel(progress: InstallationProgress): string | nullif (progress.phase === 'completed') {return progress.prUrl ? 'Pull request is ready to review' : 'Everything is wired up'}+ if (progress.pendingInput) {+ // The run is blocked and the user is usually looking at the app, not the terminal, so the+ // prominent line is the call to go back there. The question itself is secondary, since+ // knowing there is one is what unblocks the run.+ return 'Your terminal needs your attention'+ }const step = activeStep(progress.steps)if (step) {return step.detail ?? step.label@@ -119,6 +128,14 @@ export function currentTaskLabel(progress: InstallationProgress): string | nullreturn progress.phase === 'connecting' ? 'Connecting to your run' : 'Getting things ready'}+/**+ * The pending question, shown below the call to action rather than in place of it. Null when nothing+ * is pending and for sensitive asks, which publish no prompt text at all.+ */+export function pendingQuestionLabel(progress: InstallationProgress): string | null {+ return progress.pendingInput?.prompts[0] ?? null+}+export function stepCounts(steps: InstallationStep[]): { completed: number; total: number } {return {completed: steps.filter((s) => s.status === 'completed').length,@@ -149,6 +166,9 @@ export function toneTextClass(progress: InstallationProgress): string {if (progress.phase === 'error') {return 'text-danger'}+ if (progress.pendingInput) {+ return 'text-warning'+ }return 'text-accent'}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.tsindex 64335d2e907f..499f96cb29f8 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.test.ts@@ -5,6 +5,7 @@ import {cloudProgress,isSessionFresh,localProgress,+ pendingInputFromSession,progressFromFinishedLocalRun,resetWizardSyncTelemetryForTests,runLocalSessionBookkeeping,@@ -327,6 +328,51 @@ describe('installationProgressLogic merge', () => {})})+ describe('pendingInput', () => {+ const pending = {+ id: 'ask-1',+ asked_at: '2026-01-01T00:00:10Z',+ question_count: 1,+ sensitive: false,+ prompts: ['Which region is your project in?'],+ }++ it('surfaces an open wizard_ask on a live session', () => {+ const result = localProgress(session({ run_phase: 'running', pending_input: pending }), 'open', true)+ expect(result.pendingInput).toEqual({+ id: 'ask-1',+ askedAt: '2026-01-01T00:00:10Z',+ questionCount: 1,+ sensitive: false,+ prompts: ['Which region is your project in?'],+ })+ })++ it.each([+ // A dead wizard never sends the clearing push — staleness is the only way out.+ ['stale session', session({ run_phase: 'running', pending_input: pending, is_stale: true })],+ ['terminal session', session({ run_phase: 'completed', pending_input: pending })],+ ['no pending_input on the row', session({ run_phase: 'running', pending_input: null })],+ ])('gated off for a %s', (_name, s) => {+ expect(pendingInputFromSession(s)).toBeNull()+ })++ it('withholds prompts on sensitive asks even if the row carries them', () => {+ const result = pendingInputFromSession(+ session({ run_phase: 'running', pending_input: { ...pending, sensitive: true } })+ )+ expect(result?.sensitive).toBe(true)+ expect(result?.prompts).toEqual([])+ })++ it('the next push without the field reads as dismissed', () => {+ const withQuestion = localProgress(session({ run_phase: 'running', pending_input: pending }), 'open', true)+ const cleared = localProgress(session({ run_phase: 'running', pending_input: null }), 'open', true)+ expect(withQuestion.pendingInput).not.toBeNull()+ expect(cleared.pendingInput).toBeNull()+ })+ })+describe('progressFromFinishedLocalRun', () => {const handle = (overrides: Partial<FinishedLocalRunHandle> = {}): FinishedLocalRunHandle => ({sessionId: 's',@@ -355,6 +401,7 @@ describe('installationProgressLogic merge', () => {prUrl: null,prMerged: false,isCurrent: true,+ pendingInput: null,})})diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.tsindex ac430791452b..848bf4956406 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/installationProgressLogic.ts@@ -48,6 +48,29 @@ export function isSessionFresh(session: WizardSessionDTOApi, now: number): boolereturn !Number.isNaN(updatedAt) && now - updatedAt < SESSION_CURRENT_THRESHOLD_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 {+ if (!session || session.is_stale || session.run_phase !== 'running') {+ return null+ }+ const raw = session.pending_input+ if (!raw?.id) {+ return null+ }+ // The prompt text goes straight into JSX, and the type is the serializer's promise rather than a+ // runtime guarantee, so keep non-strings out: a row written before the field was typed would+ // otherwise crash the render of an app-wide widget.+ const prompts = Array.isArray(raw.prompts) ? raw.prompts.filter((p): p is string => typeof p === 'string') : []+ return {+ id: raw.id,+ askedAt: raw.asked_at ?? session.updated_at,+ questionCount: raw.question_count ?? 1,+ sensitive: raw.sensitive === true,+ prompts: raw.sensitive === true ? [] : prompts,+ }+}+// Per-session telemetry guards, deliberately module-scoped rather than on the kea `cache`: the logic// unmounts whenever its last consumer does (FAB gate flips, install step navigated away), and a// remount wipes `cache` — so a cache-based guard would let the SSE redeliver a still-in-flight@@ -97,6 +120,16 @@ export interface InstallationStep {source?: 'wizard'}+/** The wizard's in-flight `wizard_ask` prompt, published on the session row while the CLI is+ * blocked on the user. Sensitive asks (secrets) carry no prompt text by design. */+export interface WizardPendingInput {+ id: string+ askedAt: string+ questionCount: number+ sensitive: boolean+ prompts: string[]+}+export interface InstallationProgress {phase: InstallationPhasesteps: InstallationStep[]@@ -105,6 +138,9 @@ export interface InstallationProgress {/** The bound PR was merged (webhook-recorded on the run's output). */prMerged: booleanisCurrent: boolean+ /** Set while the wizard is waiting on the user in the terminal — the widget's attention state.+ * Cleared by the next session push without the field (answered, cancelled, or timed out). */+ pendingInput: WizardPendingInput | null}export interface InstallationProgressLogicProps {@@ -292,6 +328,7 @@ export function cloudProgress(prUrl,prMerged,isCurrent: phase !== 'idle',+ pendingInput: phase === 'running' ? pendingInputFromSession(session) : null,}}@@ -313,6 +350,7 @@ export function localProgress(prUrl: null,prMerged: false,isCurrent: false,+ pendingInput: null,}}@@ -342,7 +380,15 @@ export function localProgress(}: null- return { phase, steps, error, prUrl: null, prMerged: false, isCurrent: sessionIsCurrent && !dismissed }+ return {+ phase,+ steps,+ error,+ prUrl: null,+ prMerged: false,+ isCurrent: sessionIsCurrent && !dismissed,+ pendingInput: phase === 'running' && !dismissed ? pendingInputFromSession(latestSession) : null,+ }}// A finished local run rendered from its persisted snapshot, after the live session stream has@@ -358,6 +404,7 @@ export function progressFromFinishedLocalRun(handle: FinishedLocalRunHandle): InprUrl: null,prMerged: false,isCurrent: true,+ pendingInput: null,}}diff --git a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.ts b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.tsindex b2c7c213f87d..4acdcb47f8f7 100644--- a/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.ts+++ b/frontend/src/scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic.test.ts@@ -26,6 +26,7 @@ function makeSession(overrides: Partial<WizardSessionDTOApi> = {}): WizardSessiotasks: [],event_plan: null,error: null,+ pending_input: null,created_at: new Date().toISOString(),updated_at: new Date().toISOString(),is_stale: false,diff --git a/products/wizard/backend/facade/contracts.py b/products/wizard/backend/facade/contracts.pyindex 6257a157d565..a405850a4231 100644--- a/products/wizard/backend/facade/contracts.py+++ b/products/wizard/backend/facade/contracts.py@@ -32,6 +32,7 @@ class WizardSessionDTO:tasks: tuple[WizardTaskDTO, ...]event_plan: dict[str, Any] | Noneerror: dict[str, Any] | None+ pending_input: dict[str, Any] | Nonecreated_at: datetimeupdated_at: datetimeis_stale: bool@@ -49,6 +50,7 @@ class UpsertWizardSessionRequest:tasks: tuple[WizardTaskDTO, ...]event_plan: dict[str, Any] | None = Noneerror: dict[str, Any] | None = None+ pending_input: dict[str, Any] | None = None@dataclass(frozen=True)@@ -62,3 +64,4 @@ class UpsertWizardSessionInput:tasks: tuple[WizardTaskDTO, ...]event_plan: dict[str, Any] | Noneerror: dict[str, Any] | None+ pending_input: dict[str, Any] | Nonediff --git a/products/wizard/backend/logic/sessions.py b/products/wizard/backend/logic/sessions.pyindex a98160efab48..f7e7f80bb80a 100644--- a/products/wizard/backend/logic/sessions.py+++ b/products/wizard/backend/logic/sessions.py@@ -57,6 +57,7 @@ def upsert_session(params: UpsertWizardSessionInput) -> tuple[WizardSessionDTO,],"event_plan": event_plan,"error": params.error,+ "pending_input": params.pending_input,},)if previous_run_phase != RunPhase.COMPLETED.value and params.run_phase == RunPhase.COMPLETED:@@ -140,6 +141,7 @@ def _to_dto(instance: WizardSession) -> WizardSessionDTO:),event_plan=instance.event_plan,error=instance.error,+ pending_input=instance.pending_input,created_at=instance.created_at,updated_at=instance.updated_at,)diff --git a/products/wizard/backend/migrations/0003_wizardsession_pending_input.py b/products/wizard/backend/migrations/0003_wizardsession_pending_input.pynew file mode 100644index 000000000000..abe9605b19cd--- /dev/null+++ b/products/wizard/backend/migrations/0003_wizardsession_pending_input.py@@ -0,0 +1,17 @@+# Generated by Django 5.2.14 on 2026-07-28 18:37++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("wizard", "0002_wizardsession_team_wf_start_idx"),+ ]++ operations = [+ migrations.AddField(+ model_name="wizardsession",+ name="pending_input",+ field=models.JSONField(blank=True, null=True),+ ),+ ]diff --git a/products/wizard/backend/migrations/max_migration.txt b/products/wizard/backend/migrations/max_migration.txtindex 395ea576b21a..e7f6648296ff 100644--- a/products/wizard/backend/migrations/max_migration.txt+++ b/products/wizard/backend/migrations/max_migration.txt@@ -1 +1 @@-0002_wizardsession_team_wf_start_idx+0003_wizardsession_pending_inputdiff --git a/products/wizard/backend/models.py b/products/wizard/backend/models.pyindex 5639a4448e2d..84cbe8afa6f2 100644--- a/products/wizard/backend/models.py+++ b/products/wizard/backend/models.py@@ -28,6 +28,10 @@ class WizardSession(UUIDModel, TeamScopedRootMixin):tasks = models.JSONField(default=list)event_plan = models.JSONField(null=True, blank=True)error = models.JSONField(null=True, blank=True)+ # An in-flight wizard_ask prompt ({id, asked_at, question_count, sensitive, prompts?}).+ # 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)created_at = models.DateTimeField(auto_now_add=True)updated_at = models.DateTimeField(auto_now=True)diff --git a/products/wizard/backend/presentation/serializers.py b/products/wizard/backend/presentation/serializers.pyindex f650a3c2a379..783342318611 100644--- a/products/wizard/backend/presentation/serializers.py+++ b/products/wizard/backend/presentation/serializers.py@@ -1,13 +1,69 @@"""DRF serializers for wizard. Bound to facade DTOs, not Django models."""+from typing import Any++from rest_framework import serializersfrom rest_framework_dataclasses.serializers import DataclassSerializerfrom products.wizard.backend.facade.contracts import UpsertWizardSessionRequest, WizardSessionDTO+# Bounds on the pending question. A prompt is a terminal question, not a document, and the wizard+# asks one thing at a time; the caps keep a malformed or hostile push from growing the row that the+# app-wide widget reads on every page load.+MAX_PROMPT_LENGTH = 2000+MAX_PROMPTS = 10+++class PendingInputSerializer(serializers.Serializer):+ """The in-flight `wizard_ask` question. Typed rather than a free-form dict so the shape the+ widget renders is enforced at the edge instead of trusted from the producer."""++ id = serializers.CharField(+ max_length=255,+ help_text="Identifier the wizard mints for this question. Changes when a new question is asked.",+ )+ asked_at = serializers.DateTimeField(+ required=False,+ help_text="UTC timestamp when the wizard asked. Defaults to the session's update time when absent.",+ )+ question_count = serializers.IntegerField(+ required=False,+ min_value=1,+ max_value=100,+ help_text="How many questions this single ask covers.",+ )+ sensitive = serializers.BooleanField(+ required=False,+ default=False,+ help_text="Whether the answer is a secret. Sensitive questions never carry prompt text.",+ )+ prompts = serializers.ListField(+ required=False,+ max_length=MAX_PROMPTS,+ child=serializers.CharField(max_length=MAX_PROMPT_LENGTH, allow_blank=True),+ help_text="The question text shown to the user. Always empty for sensitive questions.",+ )++ def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:+ # Redact here rather than in the client: the sensitive contract has to hold for every+ # producer, and past this point the value is persisted, streamed over SSE, and logged.+ if attrs.get("sensitive"):+ attrs.pop("prompts", None)+ asked_at = attrs.get("asked_at")+ if asked_at is not None:+ # The field is a JSONField on the model, which can't hold a datetime.+ attrs["asked_at"] = asked_at.isoformat()+ return attrs+class WizardSessionSerializer(DataclassSerializer):"""Output: serialises a WizardSessionDTO returned by the facade."""+ pending_input = PendingInputSerializer(+ allow_null=True,+ help_text="The question the wizard is currently blocked on, or null when nothing is pending.",+ )+class Meta:dataclass = WizardSessionDTO@@ -15,6 +71,15 @@ class WizardSessionSerializer(DataclassSerializer):class UpsertWizardSessionRequestSerializer(DataclassSerializer):"""Input: validates the JSON the wizard CLI posts. team_id is derived from URL."""+ pending_input = PendingInputSerializer(+ required=False,+ allow_null=True,+ help_text=(+ "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."+ ),+ )+class Meta:dataclass = UpsertWizardSessionRequestextra_kwargs = {diff --git a/products/wizard/backend/presentation/views.py b/products/wizard/backend/presentation/views.pyindex 60c8291adfc6..799945ecfa37 100644--- a/products/wizard/backend/presentation/views.py+++ b/products/wizard/backend/presentation/views.py@@ -289,6 +289,7 @@ class WizardSessionViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):tasks=tuple(req.tasks),event_plan=req.event_plan,error=req.error,+ pending_input=req.pending_input,))response_status = status.HTTP_201_CREATED if created else status.HTTP_200_OKdiff --git a/products/wizard/backend/tests/test_logic.py b/products/wizard/backend/tests/test_logic.pyindex 2f7bced55caa..652d3d9227d5 100644--- a/products/wizard/backend/tests/test_logic.py+++ b/products/wizard/backend/tests/test_logic.py@@ -28,6 +28,7 @@ def _input(team_id: int, **overrides) -> UpsertWizardSessionInput:"tasks": (WizardTaskDTO(id="1", title="Install SDK", status=TaskStatus.IN_PROGRESS),),"event_plan": None,"error": None,+ "pending_input": None,}params.update(overrides)return UpsertWizardSessionInput(**params)@@ -45,6 +46,23 @@ def test_upsert_creates_new_session(team):assert dto.tasks[0].status == TaskStatus.IN_PROGRESS+def test_upsert_round_trips_pending_input(team):+ pending_input = {+ "id": "ask-1",+ "asked_at": "2026-05-19T10:05:00Z",+ "question_count": 1,+ "sensitive": False,+ "prompts": ["Which region is your project in?"],+ }+ with_question, _ = wizard_facade.upsert(_input(team.id, pending_input=pending_input))+ assert with_question.pending_input == pending_input++ # The wire is a full-state upsert: the next push without the field is the dismissal.+ cleared, _ = wizard_facade.upsert(_input(team.id))+ assert cleared.pending_input is None++@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 45dc13ea7cbe..f51d9a76342e 100644--- a/products/wizard/backend/tests/test_presentation.py+++ b/products/wizard/backend/tests/test_presentation.py@@ -380,3 +380,70 @@ class TestWizardSessionViewSet(APIBaseTest):return_value=flag_value,):self.assertEqual(_wizard_sync_killswitch_enabled("distinct-id"), expected)++ def test_sensitive_pending_input_is_stored_without_prompt_text(self):+ # Redaction has to happen before the row is written, since the same value is streamed over+ # SSE and logged — a client that sends the text anyway must not get it persisted.+ response = self.client.post(+ self._url(),+ self._payload(+ pending_input={+ "id": "ask-1",+ "asked_at": "2026-05-19T10:05:00Z",+ "question_count": 1,+ "sensitive": True,+ "prompts": ["Paste your API key"],+ }+ ),+ format="json",+ )++ self.assertEqual(response.status_code, status.HTTP_201_CREATED)+ self.assertNotIn("prompts", response.json()["pending_input"])++ session = WizardSession.objects.unscoped().get(team=self.team)+ stored = session.pending_input+ assert stored is not None+ self.assertNotIn("prompts", stored)+ self.assertTrue(stored["sensitive"])++ def test_pending_input_with_asked_at_survives_every_read_path(self):+ # asked_at is validated as a datetime but stored as a string, since the column is JSON.+ # Every read serializes that string back out through the same DateTimeField.+ create = self.client.post(+ self._url(),+ self._payload(pending_input={"id": "ask-1", "asked_at": "2026-05-19T10:05:00Z"}),+ format="json",+ )+ self.assertEqual(create.status_code, status.HTTP_201_CREATED)++ for label, url in [+ ("latest", self._url("latest/") + "?workflow_id=onboarding"),+ ("retrieve", self._url("onboarding-nextjs-2026-05-19T10:00:00Z/")),+ ("list", self._url()),+ ]:+ with self.subTest(read=label):+ response = self.client.get(url)+ self.assertEqual(response.status_code, status.HTTP_200_OK)+ body = response.json()+ payload = body["results"][0] if label == "list" else body+ self.assertEqual(payload["pending_input"]["id"], "ask-1")+ self.assertIn("asked_at", payload["pending_input"])++ @parameterized.expand(+ [+ ("prompt_not_a_string", {"prompts": [{}]}),+ ("prompt_too_long", {"prompts": ["x" * 2001]}),+ ("too_many_prompts", {"prompts": ["q"] * 11}),+ ("missing_id", {"id": None}),+ ("question_count_out_of_range", {"question_count": 0}),+ ]+ )+ def test_malformed_pending_input_is_rejected(self, _label, overrides):+ pending_input = {"id": "ask-1", "sensitive": False, "prompts": ["Which region?"]}+ pending_input.update(overrides)++ response = self.client.post(self._url(), self._payload(pending_input=pending_input), format="json")++ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)+ self.assertEqual(WizardSession.objects.unscoped().filter(team=self.team).count(), 0)diff --git a/products/wizard/backend/tests/test_pubsub.py b/products/wizard/backend/tests/test_pubsub.pyindex 64d7d6b58dc6..cee36a6cc581 100644--- a/products/wizard/backend/tests/test_pubsub.py+++ b/products/wizard/backend/tests/test_pubsub.py@@ -27,6 +27,7 @@ def _dto(team_id: int = 1) -> WizardSessionDTO:tasks=(WizardTaskDTO(id="1", title="Install SDK", status=TaskStatus.IN_PROGRESS),),event_plan=None,error=None,+ pending_input=None,created_at=now,updated_at=now,)diff --git a/products/wizard/backend/tests/test_stream.py b/products/wizard/backend/tests/test_stream.pyindex cc71e1f24604..c2fc37aad8b1 100644--- a/products/wizard/backend/tests/test_stream.py+++ b/products/wizard/backend/tests/test_stream.py@@ -27,6 +27,7 @@ def _input(team_id: int, **overrides) -> UpsertWizardSessionInput:"tasks": (WizardTaskDTO(id="1", title="Install SDK", status=TaskStatus.IN_PROGRESS),),"event_plan": None,"error": None,+ "pending_input": None,}params.update(overrides)return UpsertWizardSessionInput(**params)diff --git a/products/wizard/frontend/generated/api.schemas.ts b/products/wizard/frontend/generated/api.schemas.tsindex 06e167bbb6a4..c70c9e8abb12 100644--- a/products/wizard/frontend/generated/api.schemas.ts+++ b/products/wizard/frontend/generated/api.schemas.ts@@ -7,6 +7,34 @@* PostHog API - generated* OpenAPI spec version: 1.0.0*/+/**+ * The in-flight `wizard_ask` question. Typed rather than a free-form dict so the shape the+ * widget renders is enforced at the edge instead of trusted from the producer.+ */+export interface PendingInputApi {+ /**+ * Identifier the wizard mints for this question. Changes when a new question is asked.+ * @maxLength 255+ */+ id: string+ /** UTC timestamp when the wizard asked. Defaults to the session's update time when absent. */+ asked_at?: string+ /**+ * How many questions this single ask covers.+ * @minimum 1+ * @maximum 100+ */+ question_count?: number+ /** Whether the answer is a secret. Sensitive questions never carry prompt text. */+ sensitive?: boolean+ /**+ * The question text shown to the user. Always empty for sensitive questions.+ * @maxItems 10+ * @items.maxLength 2000+ */+ prompts?: string[]+}+/*** * `idle` - IDLE* * `running` - RUNNING@@ -59,6 +87,8 @@ export type WizardSessionDTOApiError = { [key: string]: unknown } | null* Output: serialises a WizardSessionDTO returned by the facade.*/export interface WizardSessionDTOApi {+ /** The question the wizard is currently blocked on, or null when nothing is pending. */+ pending_input: PendingInputApi | nullsession_id: stringteam_id: numberworkflow_id: string@@ -100,6 +130,8 @@ export type UpsertWizardSessionRequestApiError = { [key: string]: unknown } | nu* Input: validates the JSON the wizard CLI posts. team_id is derived from URL.*/export 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/*** 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 fde4f9662e55..49ee3e1f4bf1 100644--- a/products/wizard/frontend/generated/api.zod.ts+++ b/products/wizard/frontend/generated/api.zod.ts@@ -12,6 +12,15 @@ import * as zod from 'zod'/*** Upsert a wizard session. The `session_id` key is the idempotency anchor — reposting the same `session_id` replaces the existing row. Returns 201 on create, 200 on update.*/+export const wizardSessionsCreateBodyPendingInputOneIdMax = 255++export const wizardSessionsCreateBodyPendingInputOneQuestionCountMax = 100++export const wizardSessionsCreateBodyPendingInputOneSensitiveDefault = false+export const wizardSessionsCreateBodyPendingInputOnePromptsItemMax = 2000++export const wizardSessionsCreateBodyPendingInputOnePromptsMax = 10+export const wizardSessionsCreateBodySessionIdMax = 255export const wizardSessionsCreateBodyWorkflowIdMax = 255@@ -20,6 +29,47 @@ export const wizardSessionsCreateBodySkillIdMax = 255export const WizardSessionsCreateBody = /* @__PURE__ */ zod.object({+ pending_input: zod+ .union([+ zod+ .object({+ id: zod+ .string()+ .max(wizardSessionsCreateBodyPendingInputOneIdMax)+ .describe(+ 'Identifier the wizard mints for this question. Changes when a new question is asked.'+ ),+ asked_at: zod.iso+ .datetime({ offset: true })+ .optional()+ .describe(+ "UTC timestamp when the wizard asked. Defaults to the session's update time when absent."+ ),+ question_count: zod+ .number()+ .min(1)+ .max(wizardSessionsCreateBodyPendingInputOneQuestionCountMax)+ .optional()+ .describe('How many questions this single ask covers.'),+ sensitive: zod+ .boolean()+ .default(wizardSessionsCreateBodyPendingInputOneSensitiveDefault)+ .describe('Whether the answer is a secret. Sensitive questions never carry prompt text.'),+ prompts: zod+ .array(zod.string().max(wizardSessionsCreateBodyPendingInputOnePromptsItemMax))+ .max(wizardSessionsCreateBodyPendingInputOnePromptsMax)+ .optional()+ .describe('The question text shown to the user. Always empty for sensitive questions.'),+ })+ .describe(+ 'The in-flight `wizard_ask` question. Typed rather than a free-form dict so the shape the\nwidget renders is enforced at the edge instead of trusted from the producer.'+ ),+ zod.null(),+ ])+ .optional()+ .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.'+ ),session_id: zod.string().max(wizardSessionsCreateBodySessionIdMax)diff --git a/products/wizard/frontend/wizardSessionStreamLogic.test.ts b/products/wizard/frontend/wizardSessionStreamLogic.test.tsindex 93e5e47ad011..16631bfa620e 100644--- a/products/wizard/frontend/wizardSessionStreamLogic.test.ts+++ b/products/wizard/frontend/wizardSessionStreamLogic.test.ts@@ -33,6 +33,7 @@ function makeSession(overrides: Partial<WizardSessionDTOApi> = {}): WizardSessiotasks: [],event_plan: null,error: null,+ pending_input: null,created_at: '2026-01-01T00:00:00Z',updated_at: '2026-01-01T00:00:00Z',is_stale: false,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 8bf577663cd0..4512d7390993 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -47136,6 +47136,34 @@ export namespace Schemas {results: WebExperimentsAPI[];}+ /**+ * The in-flight `wizard_ask` question. Typed rather than a free-form dict so the shape the+ * widget renders is enforced at the edge instead of trusted from the producer.+ */+ export interface PendingInput {+ /**+ * Identifier the wizard mints for this question. Changes when a new question is asked.+ * @maxLength 255+ */+ id: string;+ /** UTC timestamp when the wizard asked. Defaults to the session's update time when absent. */+ asked_at?: string;+ /**+ * How many questions this single ask covers.+ * @minimum 1+ * @maximum 100+ */+ question_count?: number;+ /** Whether the answer is a secret. Sensitive questions never carry prompt text. */+ sensitive?: boolean;+ /**+ * The question text shown to the user. Always empty for sensitive questions.+ * @maxItems 10+ * @items.maxLength 2000+ */+ prompts?: string[];+ }+/*** * `idle` - IDLE* * `running` - RUNNING@@ -47190,6 +47218,8 @@ export namespace Schemas {* Output: serialises a WizardSessionDTO returned by the facade.*/export interface WizardSessionDTO {+ /** The question the wizard is currently blocked on, or null when nothing is pending. */+ pending_input: PendingInput | null;session_id: string;team_id: number;workflow_id: string;@@ -69911,6 +69941,8 @@ export namespace Schemas {* Input: validates the JSON the wizard CLI posts. team_id is derived from URL.*/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;/*** 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