: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(signals): show first-report investigation progress (#122560)
Georgiy Tarasovcab2c7ff2267
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 217dd0e3115e..eb7c6f8d1d21 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -11984,6 +11984,26 @@ snapshots:hash: v1.k794b7964.cf12f69004301572be1c6bc0c8927205b33d7e91052ee14c140ca28c6ca1737d.U2NxyypdkDl1-ZAX8zpHYqNKck9H6kp78eEmS8k2clMscenes-app-inbox-discussreportbutton--without-suggestions--light:hash: v1.k794b7964.9108dd99dd7c78fc3f18d4326d19f4ae6db81b0a925c742130145b315bfefce8.SDY7Xb9wigNSFb_k-94O75WyV7EloF11LgkDK9YH0Wo+ scenes-app-inbox-first-report--incomplete-without-run--dark:+ hash: v1.k794b7964.122115b27143f345177fbfe2632830a3ff15e59a24be5e6acd7649a403e05762.733G_JVmal6W3Gs2sM0WLJvn1SQ_4z9TAppwsGquVs0+ scenes-app-inbox-first-report--incomplete-without-run--light:+ hash: v1.k794b7964.ba6bef63c7f68f18285e1b618f55128223aa562346360ae429a20e559554912a.sJE2VlX2izfk5Yb1EkgU2KVEbxfCg_T0Y6Te84bJbzQ+ scenes-app-inbox-first-report--no-data--dark:+ hash: v1.k794b7964.1608ef38e17590abcb46d75e98d1d1d53fa0d4caee76426e0f1b7a8de4a49ca0.d04L1InklMlOHsXH_X01x4QcEFYMxl0wcfZuKcp0jRw+ scenes-app-inbox-first-report--no-data--light:+ hash: v1.k794b7964.0f127ac36b7dd455a9915a6a2bbad25f2cbc6e60d6f600f368c8d18ac65cd7ce.yB9sMpPaP0tIRLS8ebI15k8gp-_rw3X5Zms8vJ48bSI+ scenes-app-inbox-first-report--no-data-narrow--dark:+ hash: v1.k794b7964.3c1ff21d19eb6a29a66a6bdeb1a3d758bc9e947e60c6f9d6b4b841a191a9d81f.6Lt9mQRaiw1Ko-N3mNUAopimIjqDs_YR9eKI-vuPOso+ scenes-app-inbox-first-report--no-data-narrow--light:+ hash: v1.k794b7964.8a760fde0be568a914e4453aac2c128a6ec065c0a6c01ef91eb016cbf11cf5ae.f8H0eCk6dHfGuY7f9eWdK5mjitwkzbGGrjg2ANeiNMM+ scenes-app-inbox-first-report--running--dark:+ hash: v1.k794b7964.2bb4016dfbab0d8c8f1378706ab67bb51e84955b08685645596828789bb856d9.TZHjE1omnp-7XaQgd50zWuWvXUPdKlr-5ycTO7gJGJE+ scenes-app-inbox-first-report--running--light:+ hash: v1.k794b7964.4d6369a69c7adb8a3edeadc4acc9cacc45bb2cbe753a68b1e8d336fbf9404053.JH83D4JcoC0XR8h7FgHmPxWiV5CAP6ZUqPzVkBYM5qU+ scenes-app-inbox-first-report--running-narrow--dark:+ hash: v1.k794b7964.1489893faeb3232bcd9ae74915614d155359ce14793fdcc57962a757d646e078.p5QygOekc_jO7LrBCAySkt7BCZpUi8TMtoCeVntqh90+ scenes-app-inbox-first-report--running-narrow--light:+ hash: v1.k794b7964.d994a9d5e1c127959958aa3e468fce4945cea47afe00e61fd1d7df37ec27c4b9.Isj5PvJ7ELE3a--ZB3q2pv1l6D3-vjIV0-J7X8pcR94scenes-app-inbox-focused-setup--built-in-scouts--dark:hash: v1.k794b7964.9c362d9b9c26bb883910cfbdd1836a4527c166f4c96a2f5360e69023c79d5f0e.DuYijIxQuSoZCwSuCLHfE5vpQ9S7-wEi7vbYSPvUoQYscenes-app-inbox-focused-setup--built-in-scouts--light:@@ -12025,9 +12045,9 @@ snapshots:scenes-app-inbox-focused-setup--no-products-enabled--light:hash: v1.k794b7964.20b18f5ab4b378c6b06c45b3de05dd4ba1783f7995d842ac40c3555a1dd450c5.Tw6tZ6X7sU3V4qVx9jmSBj4rS04FnKis1tqfTQuAhgYscenes-app-inbox-focused-setup--quick-activated--dark:- hash: v1.k794b7964.3d8df0414c1d087d6a667af90bddbd3271f6b95adaa54fc585897716af61fd9f.u6S4EDAfiSdebn74czWvMD7KqQcsbtUqv9sUwoE5FGQ+ hash: v1.k794b7964.653864650883238be09ff223e227c4aef6d637308cd9cb5337bbd122ba0e16c6.KmAERZYNS8d-FYi019q153Z49JfnWLSi5oewFlizVZsscenes-app-inbox-focused-setup--quick-activated--light:- hash: v1.k794b7964.f6adadab19ce25a68cf6d5caa445aa92dd089693369d7c9dc6b378e37b3c2967.dNFD9VHrTi9mRU7-91C0-PTufBvRt73QTkqiJMpdHIU+ hash: v1.k794b7964.fd316d377c5a14dc45c7359ea18419d3da11c4c8a9e3c33edb29f7c20c42d82c.8bPWIes64TfbjuoTB-n963_IoRvpIj4q1ZATzDvvUj0scenes-app-inbox-focused-setup--quick-connected--dark:hash: v1.k794b7964.831e33166fedb9fb6c67e5b3e77eb5d03388c0cd4a0b99cbf56c0545cc7b0f64.O7Stc1-keommfRGI1kfTUU0Q9SLdVKZ0aUs2XSheRUkscenes-app-inbox-focused-setup--quick-connected--light:@@ -12153,9 +12173,9 @@ snapshots:scenes-app-inbox-scene--focused-onboarding--light:hash: v1.k794b7964.3e78ccccf98ee9e524c1bd460956be3291c4c00c15064f7318b8fa270d47e881.XsQxa59uXcfjEOekG3uzpT6CCN4aSLxlAik5lQyKLFYscenes-app-inbox-scene--focused-onboarding-complete--dark:- hash: v1.k794b7964.414a7eecf51038fad769cfe620b23bb48b6e3df4b00b6b6d53a6605c0f586514.sfr-mU-Cqlz1Z76x8U-c4jGYcc7oeT4ph0Y4wQIpGcs+ hash: v1.k794b7964.e6ecff68e551584f79fb2c0d24eaebdcc275f767663926734615d2301b57573b.-WxAZwfw5OPG7jSozZfpgCPJCQ4FKzxD1qHSQGWWULsscenes-app-inbox-scene--focused-onboarding-complete--light:- hash: v1.k794b7964.00c6338c2bdba734ec3883a530592381d92d4004245315edc2869f0ac3906239.3m-CF_ssrDqvSkbenzHSc055rtGkk88Ps3oLkPvF9Qc+ hash: v1.k794b7964.cf9af6b650777d2eac80e08944a56e9a6ebe07b95fd8f29a981716b7667e9b70.TsufTUwkucUTgfHUopvizIZuI_yfxudeBBJFxOy1nRoscenes-app-inbox-scene--inbox--dark:hash: v1.k794b7964.9e408067ea1f3714dcf8d9e812dde013bd58ce007872c1edadbabca46f30dae9.rsVWshwBIWY3KXFqChFMc0qts9C78Rkju8Cmq5Nofvoscenes-app-inbox-scene--inbox--light:diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.mdindex 6933994bf51d..50663209d9a2 100644--- a/products/signals/ARCHITECTURE.md+++ b/products/signals/ARCHITECTURE.md@@ -240,9 +240,9 @@ On re-promotion:Guided and quick activation enqueue a one-time `signals-scout-first-report` investigation immediately after onboarding commits, only for projects in a test arm of `self-driving-banger-scout` and with evidence of product or warehouse data. Dispatch checks scout-source eligibility before preparing context or probing data. Data evidence can be recorded event ingestion in the project or an environment, a positive warehouse sync count, or a successful live product probe. Warehouse eligibility uses recorded sync metadata without querying warehouse tables; the scout validates freshness during its investigation. Empty projects stop before workflow or sandbox startup and show `no_data`. When no other data evidence exists, failed or inconclusive product probes retry and eventually show `incomplete`, without starting an investigation. Outside the rollout and in the control arm, guided activation starts no immediate scout and quick activation retains its general-scout dispatch. The scout receives a bounded project inventory, recent event volumes, native-product data counts, and accessible warehouse table metadata before investigating. It searches across products, including product-analytics anomalies, and authors at most one report through the direct report channel. A project-scoped report idempotency key enforces that limit independently of agent instructions. A report that was visible keeps the investigation successful after resolution or dismissal. The skill owns investigation policy and orientation; the shared prompt defers to its procedure. Early replay and persistence use the same project-scoped key, so a saved report is returned before checking changed emission gates or repeating the safety judge.-The first-report scout is excluded from scheduled registration and suggestions. Non-staff users do not see it in the normal scout roster or scout pickers; its configuration, runs, skill, and task remain available through the normal project-scoped APIs. Its template remains visible in the Skills store like other canonical scout skills. Its structured close-out distinguishes insufficient data, no actionable finding, and an incomplete investigation. Onboarding returns persisted state and the scout run, task, and task run IDs for progress consumers. An in-app notification tells the activating user when a run finishes, including non-report outcomes. No-data skips have no run. Missing or failed data probes remain unknown rather than being presented as an empty project.+The first-report scout is excluded from scheduled registration and suggestions. Non-staff users do not see it in the normal scout roster or scout pickers; its configuration, runs, skill, and task remain available through the normal project-scoped APIs. Its template remains visible in the Skills store like other canonical scout skills. Onboarding returns the scout run, task, and task run IDs, and embeds the existing live run viewer so customers can follow the investigation in the inbox. The inbox folds the setup card to its header while a first-report state exists and shows one first-report card beneath it until a report exists: status and next steps in the left pane, the actual investigation in the right pane. A created report removes the card and refreshes the report list, so the first report appears as a normal row. A failed refresh shows a retry action even when the previous list was empty; retry reloads the failed sections and their counts. Empty projects see the existing onboarding example report instead of a run, without a connect-data callout. The panes stack in narrow containers. Running investigations show a rough 2½-minute estimate, and the terminal outcomes without a report retain their activity in the same place. The viewer follows the task until it finishes, including when a report appears before the final task output. Its structured close-out distinguishes insufficient data, no actionable finding, and an incomplete investigation. An in-app notification tells the activating user when a run finishes, including non-report outcomes. The page promises “We’ll notify you when your first report is ready” in every pre-report state only when the activating user is enrolled for the configured first-report email; completing a run without a report does not fulfill that promise. No-data skips have no run. Missing or failed data probes remain unknown rather than being presented as an empty project.-The first-report email can also select a first-report-scout finding that needs a human decision. The onboarding API exposes the notification email only to the enrolled activating user when the email feature and sender configuration are enabled.+The first-report email can also select a first-report-scout finding that needs a human decision. The onboarding UI promises an email only to the enrolled activating user when the email feature and sender configuration are enabled.The project-group experiment `self-driving-banger-scout` decides whether the first-report scout runs and which model it uses: `control` runs no first-report scout, `test-sol` selects GPT-6.1 Sol on Codex with high reasoning and priority service, and `test-deepseek` selects DeepSeek Flash 1017 Fast on Pi. Both test arms use the same scout skill. The runner refuses a control assignment. Disabled, unknown, and unavailable flag values prevent production first-report runs; explicit eval and private-trial runtime overrides bypass enrollment. Enrollment is recorded at onboarding completion and rechecked before dispatch and sandbox startup. Unavailable experiment evaluations during dispatch use the activation job’s bounded retries; an explicitly disabled or invalid assignment skips the investigation. The runtime assignment is recorded on the run and attached to lifecycle and report events. Onboarding job status events also include the first-report variant and pre-run outcome, so no-data skips are measurable without counting them as runs. The onboarding dispatch job captures exposure for every arm after the same guards: scout-source eligibility, fleet and spend limits, an active activating user, and data. The arms therefore share one denominator, and setup failures after dispatch remain in it.diff --git a/products/signals/frontend/inbox/components/emptyState/FirstReportProgress.stories.tsx b/products/signals/frontend/inbox/components/emptyState/FirstReportProgress.stories.tsxnew file mode 100644index 000000000000..d10eb1688144--- /dev/null+++ b/products/signals/frontend/inbox/components/emptyState/FirstReportProgress.stories.tsx@@ -0,0 +1,57 @@+import type { Meta, StoryObj } from '@storybook/react'+import { HttpResponse } from 'msw'++import { mswDecorator } from '~/mocks/browser'++import { mockRunLog, mockTask, mockTaskRun } from '../../__mocks__/inboxMocks'+import { FirstReportProgress } from './FirstReportProgress'++const meta: Meta<typeof FirstReportProgress> = {+ title: 'Scenes-App/Inbox/First report',+ component: FirstReportProgress,+ parameters: { mockDate: '2026-10-23T09:00:00Z' },+ render: (args): JSX.Element => (+ <div className="w-250">+ <FirstReportProgress {...args} />+ </div>+ ),+ args: {+ notificationEmail: '[email protected]',+ result: {+ status: 'running',+ task_id: 'task-1',+ task_run_id: 'run-1',+ started_at: '2026-10-23T09:00:00Z',+ },+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/tasks/:taskId': [200, mockTask('task-1', 'completed')],+ '/api/projects/:id/tasks/:taskId/runs/:runId': [200, mockTaskRun('task-1', 'run-1')],+ '/api/projects/:id/tasks/:taskId/runs/:runId/logs': () => new HttpResponse(mockRunLog()),+ },+ }),+ ],+}+export default meta+type Story = StoryObj<typeof meta>++export const Running: Story = {}+export const RunningNarrow: Story = {+ render: (args): JSX.Element => (+ <div className="w-130">+ <FirstReportProgress {...args} />+ </div>+ ),+}+export const NoData: Story = { args: { result: { status: 'no_data' } } }+export const NoDataNarrow: Story = {+ ...NoData,+ render: (args): JSX.Element => (+ <div className="w-130">+ <FirstReportProgress {...args} />+ </div>+ ),+}+export const IncompleteWithoutRun: Story = { args: { result: { status: 'incomplete' } } }diff --git a/products/signals/frontend/inbox/components/emptyState/FirstReportProgress.tsx b/products/signals/frontend/inbox/components/emptyState/FirstReportProgress.tsxnew file mode 100644index 000000000000..c8fb01453f35--- /dev/null+++ b/products/signals/frontend/inbox/components/emptyState/FirstReportProgress.tsx@@ -0,0 +1,145 @@+import { IconCheckCircle, IconClock, IconHourglass, IconInfo, IconLetter, IconWarning } from '@posthog/icons'+import { LemonButton, Spinner } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'+import { urls } from 'scenes/urls'++import { ReadonlyRunSurface } from 'products/posthog_ai/frontend/api/readableRun'++import type { FirstReportProgressState } from '../../logics/inboxSetupLogic'+import { RunStatusIndicator } from '../cards/runStatusVariant'+import { InboxReportPreview } from '../onboarding/InboxReportPreview'++export interface FirstReportProgressProps {+ result: FirstReportProgressState+ notificationEmail?: string | null+}++function FirstReportStatusGlyph({ status }: { status: FirstReportProgressState['status'] }): JSX.Element {+ switch (status) {+ case 'pending':+ return <RunStatusIndicator variant="queued" showLabel={false} />+ case 'running':+ return <RunStatusIndicator variant="live" showLabel={false} />+ case 'no_actionable_finding':+ return <IconCheckCircle className="shrink-0 text-lg text-success" />+ case 'incomplete':+ return <IconWarning className="shrink-0 text-lg text-warning" />+ case 'insufficient_data':+ return <IconInfo className="shrink-0 text-lg text-secondary" />+ case 'no_data':+ return <IconHourglass className="shrink-0 text-lg text-secondary" />+ }+}++export function FirstReportProgress({ result, notificationEmail }: FirstReportProgressProps): JSX.Element {+ const messages = {+ pending: ['Checking your project', 'We’re checking which data is available for your first investigation.'],+ running: ['Looking for your first report', 'We’re checking your project for an issue you can act on.'],+ no_data: ['Waiting for your first report', 'Your setup is ready. There isn’t any data to investigate yet.'],+ insufficient_data: [+ 'More data is needed',+ 'The investigation finished, but there isn’t enough data yet to produce a reliable report.',+ ],+ no_actionable_finding: [+ 'Your first investigation is complete',+ 'We checked your data and didn’t find anything worth reporting yet.',+ ],+ incomplete: [+ 'Your first investigation couldn’t finish',+ 'We couldn’t complete the investigation. This does not mean your project has no data. Review your connections and the investigation activity, if available.',+ ],+ }+ const [title, description] = messages[result.status]+ const isLive = result.status === 'pending' || result.status === 'running'++ return (+ <div className="@container w-full min-w-0">+ <div className="grid overflow-hidden rounded border border-primary bg-surface-primary @min-[48rem]:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]">+ <div className="flex min-w-0 flex-col gap-3 border-b border-primary p-5 @min-[48rem]:border-r @min-[48rem]:border-b-0">+ <div className="flex items-center gap-2.5">+ <FirstReportStatusGlyph status={result.status} />+ <h2 className="m-0 text-base font-semibold leading-snug">{title}</h2>+ </div>+ <p className="m-0 text-sm text-secondary">+ <span>{description}</span>+ {result.status === 'running' && (+ <span>+ {' '}+ This takes <strong>roughly 2½ minutes</strong>.+ </span>+ )}+ </p>+ {result.status === 'insufficient_data' && result.missing_data?.length ? (+ <ul className="m-0 text-sm text-secondary">+ {result.missing_data.map((item, index) => (+ <li key={index}>{item}</li>+ ))}+ </ul>+ ) : null}+ {result.started_at || notificationEmail ? (+ <div className="mt-auto flex flex-col gap-1.5 pt-1 text-xs text-tertiary">+ {result.started_at ? (+ <span className="flex items-center gap-1.5">+ <IconClock className="size-3.5 shrink-0" />+ <span>+ Started <TZLabel time={result.started_at} />+ </span>+ </span>+ ) : null}+ {notificationEmail ? (+ <span className="flex items-center gap-1.5">+ <IconLetter className="size-3.5 shrink-0" />+ <span>We’ll notify you when your first report is ready.</span>+ </span>+ ) : null}+ </div>+ ) : null}+ {result.status === 'incomplete' ? (+ <div className="flex flex-wrap gap-2">+ <LemonButton type="secondary" size="small" to={urls.inbox('settings')}>+ Review connections+ </LemonButton>+ </div>+ ) : null}+ </div>+ <div className="flex min-w-0 flex-col bg-surface-secondary">+ {result.task_id && result.task_run_id ? (+ // The viewer's virtualized thread owns scroll, so this box only bounds the height and clips.+ <section+ className="h-96 min-h-0 overflow-hidden"+ aria-label="First report investigation activity"+ >+ <ReadonlyRunSurface+ taskId={result.task_id}+ runId={result.task_run_id}+ interaction="live"+ threadRowClassName="px-4"+ threadListClassName="py-3"+ />+ </section>+ ) : result.status === 'no_data' ? (+ <section className="flex min-w-0 flex-col gap-3 p-5" aria-label="Example report">+ <h3 className="m-0 text-sm font-semibold">Example report</h3>+ <InboxReportPreview mode="waiting-for-data" />+ </section>+ ) : isLive ? (+ <span+ className="flex h-96 items-center justify-center gap-2 p-5 text-sm text-secondary"+ role="status"+ >+ <Spinner className="text-lg" />+ <span>+ {result.status === 'pending'+ ? 'Checking available data…'+ : 'Starting the investigation…'}+ </span>+ </span>+ ) : (+ <p className="m-0 p-5 text-sm text-secondary">No investigation activity is available.</p>+ )}+ </div>+ </div>+ </div>+ )+}diff --git a/products/signals/frontend/inbox/components/emptyState/InboxWaitingForWork.tsx b/products/signals/frontend/inbox/components/emptyState/InboxWaitingForWork.tsxindex 86481195ca68..c88fcf1b2a63 100644--- a/products/signals/frontend/inbox/components/emptyState/InboxWaitingForWork.tsx+++ b/products/signals/frontend/inbox/components/emptyState/InboxWaitingForWork.tsx@@ -10,6 +10,7 @@ import { inboxSetupLogic } from '../../logics/inboxSetupLogic'import { scoutFleetLogic } from '../../logics/scoutFleetLogic'import { signalSourcesLogic } from '../../signalSourcesLogic'import { SignalSourceConfig, SignalSourceProduct, SignalSourceType } from '../../types'+import { FirstReportProgress } from './FirstReportProgress'import { InstallingFlowRow } from './InstallingFlowRow'import { ScoutFlowRow } from './ScoutFlowRow'import { SignalSourceFlowRow } from './SignalSourceFlowRow'@@ -42,7 +43,7 @@ export function InboxWaitingForWork(): JSX.Element {const { sourceConfigs, sourceConfigsLoading, hasEmittingScanner } = useValues(signalSourcesLogic)const { scoutConfigs, scoutConfigsLoading } = useValues(scoutFleetLogic)const { isWizardRunning } = useValues(inboxOnboardingLogic)- const { completed } = useValues(inboxSetupLogic)+ const { completed, savedState, firstReportProgress } = useValues(inboxSetupLogic)const enabledSources = [...uniqueEnabledSources(sourceConfigs),...(completed && hasEmittingScanner@@ -63,14 +64,21 @@ export function InboxWaitingForWork(): JSX.Element {return (<div className="@container mx-auto flex w-full max-w-5xl flex-col gap-7 py-6">- <div className="flex flex-col items-center gap-2 text-center">- <h2 className="m-0 text-lg font-semibold">Your agents are working in the background</h2>- <p className="m-0 max-w-xl text-sm text-tertiary">- {completed- ? 'Your sources are listening and your scouts will run on their schedules. Reports appear here when they find something worth investigating.'- : 'Your signal sources and scouts are running in the background. When they find something actionable, a pull request will appear here.'}- </p>- </div>+ {completed && firstReportProgress ? (+ <FirstReportProgress+ result={firstReportProgress}+ notificationEmail={savedState?.first_report_notification_email}+ />+ ) : (+ <div className="flex flex-col items-center gap-2 text-center">+ <h2 className="m-0 text-lg font-semibold">Your agents are working in the background</h2>+ <p className="m-0 max-w-xl text-sm text-tertiary">+ {completed+ ? 'Your sources are listening and your scouts will run on their schedules. Reports appear here when they find something worth investigating.'+ : 'Your signal sources and scouts are running in the background. When they find something actionable, a pull request will appear here.'}+ </p>+ </div>+ )}<div className="grid items-start gap-8 @min-[40rem]:grid-cols-2"><section className="flex flex-col">diff --git a/products/signals/frontend/inbox/components/onboarding/InboxActivationPanel.tsx b/products/signals/frontend/inbox/components/onboarding/InboxActivationPanel.tsxindex 4c2a54c74fa9..86cdf02546de 100644--- a/products/signals/frontend/inbox/components/onboarding/InboxActivationPanel.tsx+++ b/products/signals/frontend/inbox/components/onboarding/InboxActivationPanel.tsx@@ -18,7 +18,9 @@ interface InboxActivationPanelProps {export function InboxActivationPanel({ hasReports = false }: InboxActivationPanelProps): JSX.Element {const { savedState, sourceNames, generalScout, suggestions, recommendationsReady, pollingExpired, currentTeamId } =useValues(inboxActivationLogic)- const [expanded, setExpanded] = useState(false)+ // The first report is the main content while that state exists, as a progress card and then as a+ // report row under this panel, so the panel starts folded to its header.+ const [expanded, setExpanded] = useState(!savedState?.first_report)const { reportRecommendationsShown } = useActions(inboxActivationLogic)useEffect(() => {captureInboxPanelViewed({ panel: 'onboarding' })@@ -46,7 +48,7 @@ export function InboxActivationPanel({ hasReports = false }: InboxActivationPane{expanded ? 'Show less' : 'Explore what’s enabled'}</LemonButton></div>- {(!hasReports || expanded) && (+ {expanded && (<><div className="flex flex-wrap gap-2">{sourceNames.map((name) => (@@ -59,7 +61,7 @@ export function InboxActivationPanel({ hasReports = false }: InboxActivationPaneexplore your code and all your data to uncover issues and connect patterns. Reports arrive withevidence and next steps.</p>- {!hasReports && generalScout?.enabled && (+ {!hasReports && !savedState?.first_report && generalScout?.enabled && (<p className="m-0 text-sm" aria-live="polite">{jobs?.scout === 'pending'? 'Preparing your first general scout run.'@@ -120,7 +122,7 @@ export function InboxActivationPanel({ hasReports = false }: InboxActivationPane<Spinner /><span>Preparing scout recommendations. They’ll appear here when ready.</span></div>- ) : jobs?.recommendations === 'failed' || jobs?.recommendations === 'skipped' || pollingExpired ? (+ ) : jobs?.recommendations === 'failed' || pollingExpired ? (<p className="m-0 text-sm text-secondary"><span>{pollingExpireddiff --git a/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsx b/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsxindex 3c8159c522f9..364dd4e62764 100644--- a/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsx+++ b/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsx@@ -3,7 +3,7 @@ import { MOCK_DEFAULT_USER } from 'lib/api.mock'/* oxlint-disable react-hooks/rules-of-hooks -- useMocks is a test helper, not a React hook */import '@testing-library/jest-dom'-import { cleanup, render, screen, waitFor } from '@testing-library/react'+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import posthog from 'posthog-js'import { userLogic } from 'scenes/userLogic'@@ -11,8 +11,11 @@ import { userLogic } from 'scenes/userLogic'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'+import type { FirstReportStateApi } from '../../../generated/api.schemas'import { INBOX_EVENTS } from '../../inboxAnalytics'import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'+import { inboxSetupLogic } from '../../logics/inboxSetupLogic'+import { reportListLogic, sectionListLogicProps } from '../../logics/reportListLogic'import { INBOX_SCOPE_ENTIRE_PROJECT, InboxReportSectionKey, SignalReport, SignalReportStatus } from '../../types'import { ReportsTab } from './ReportsTab'@@ -28,6 +31,13 @@ jest.mock('../cards/ReportContextMenu', () => ({jest.mock('../shell/InboxReportFilters', () => ({ InboxReportFilters: () => null }))jest.mock('../shell/InboxScopeFilter', () => ({ InboxScopeFilter: () => null }))jest.mock('../shell/InboxBulkSelectionBar', () => ({ InboxBulkSelectionBar: () => null }))+jest.mock('products/posthog_ai/frontend/api/readableRun', () => ({+ ReadonlyRunSurface: (props: { taskId: string; runId: string; interaction: string }) => (+ <div aria-label="Scout activity" data-interaction={props.interaction}>+ {props.taskId}/{props.runId}+ </div>+ ),+}))interface SectionCountStub {match: (params: URLSearchParams) => boolean@@ -63,6 +73,24 @@ function mockReportCounts(stubs: SectionCountStub[]): void {})}+function mockOnboarding(firstReport: FirstReportStateApi, notify: boolean): void {+ useMocks({+ get: {+ '/api/projects/:id/signals/onboarding/': {+ variant: 'test-ui',+ completed_at: new Date().toISOString(),+ draft: null,+ jobs: { scout: 'started', recommendations: 'skipped' },+ first_report: firstReport,+ first_report_completion_notification: true,+ first_report_notification_email: notify ? '[email protected]' : null,+ },+ '/api/projects/:id/signals/scout/suggestions/': { status: 'idle', items: [], generated_at: null },+ '/api/projects/:id/vision/scanners/': { results: [], next: null },+ },+ })+}+function makeReport(id: string, status: SignalReportStatus): SignalReport {return {id,@@ -122,6 +150,106 @@ describe('ReportsTab', () => {afterEach(cleanup)+ it.each<[FirstReportStateApi['status'], string, boolean]>([+ ['pending', 'Checking your project', true],+ ['running', 'Looking for your first report', true],+ ['no_data', 'Waiting for your first report', true],+ ['no_data', 'Waiting for your first report', false],+ ['insufficient_data', 'More data is needed', true],+ ['no_actionable_finding', 'Your first investigation is complete', true],+ ['incomplete', 'Your first investigation couldn’t finish', true],+ ])('shows %s: %s (notifications: %s)', async (status, heading, notify) => {+ mockReportCounts([])+ mockOnboarding(+ {+ status,+ ...(['no_data', 'pending', 'incomplete'].includes(status)+ ? {}+ : { task_id: 'task-1', task_run_id: 'run-1' }),+ },+ notify+ )+ const { container } = render(<ReportsTab />)+ expect(await screen.findByText(heading)).toBeVisible()+ expect(container.querySelector('[data-attr="inbox-activation-explore"]')).toHaveAttribute(+ 'aria-expanded',+ 'false'+ )+ expect(screen.queryByText('Recommended for your product')).not.toBeInTheDocument()+ if (status === 'no_data') {+ expect(screen.queryByLabelText('Scout activity')).not.toBeInTheDocument()+ expect(screen.getByLabelText('Example report')).toBeVisible()+ expect(screen.getByText('Trial users cannot upgrade to Pro')).toBeVisible()+ expect(screen.queryByText('Connect a data source')).not.toBeInTheDocument()+ } else {+ expect(screen.queryByLabelText('Example report')).not.toBeInTheDocument()+ if (status !== 'pending' && status !== 'incomplete') {+ expect(screen.getByLabelText('Scout activity')).toHaveTextContent('task-1/run-1')+ expect(screen.getByLabelText('Scout activity')).toHaveAttribute('data-interaction', 'live')+ }+ }+ if (status === 'running') {+ expect(screen.getByText(/roughly 2½ minutes/)).toBeVisible()+ }+ if (notify) {+ expect(screen.getByText(/We’ll notify you when your first report is ready/)).toBeVisible()+ } else {+ expect(screen.queryByText(/We’ll notify you when your first report is ready/)).not.toBeInTheDocument()+ }+ })++ // Polling flips the state while the card is on screen. The card has to go and the report has to+ // land in the list without a page reload.+ it.each(['none', 'rows', 'counts-and-rows'])(+ 'replaces the first-report card with the report (refresh failure: %s)',+ async (refreshFailure) => {+ mockReportCounts([])+ mockOnboarding({ status: 'running', task_id: 'task-1', task_run_id: 'run-1' }, true)+ inboxFiltersLogic.mount()+ inboxFiltersLogic.actions.setScope(INBOX_SCOPE_ENTIRE_PROJECT)++ const { container } = render(<ReportsTab />)+ expect(await screen.findByText('Looking for your first report')).toBeVisible()+ await waitFor(() =>+ expect(reportListLogic(sectionListLogicProps('needs-decision')).values.isLoaded).toBe(true)+ )++ const first = makeReport('first', SignalReportStatus.READY)+ let failRefresh = refreshFailure !== 'none'+ useMocks({+ get: {+ '/api/projects/:team_id/signals/reports/': ({ request }) => {+ const params = new URL(request.url).searchParams+ if (+ failRefresh &&+ (refreshFailure === 'counts-and-rows' || params.get('count_only') !== 'true')+ ) {+ return [503, { detail: 'Reports temporarily unavailable' }]+ }+ const results = params.get('view') === 'needs_decision' ? [first] : []+ return [200, { count: results.length, next: null, previous: null, results }]+ },+ },+ })+ mockOnboarding(+ { status: 'report_created', task_id: 'task-1', task_run_id: 'run-1', report_id: first.id },+ true+ )+ inboxSetupLogic.actions.loadSetup()++ if (failRefresh) {+ const retry = await screen.findByText('Retry')+ expect(container.querySelector('[data-attr="inbox-first-report-progress"]')).toBeNull()+ failRefresh = false+ fireEvent.click(retry)+ }+ await waitFor(() => expect(document.querySelector('[data-attr="report-card-first"]')).not.toBeNull())+ expect(screen.queryByText('Retry')).not.toBeInTheDocument()+ expect(container.querySelector('[data-attr="inbox-first-report-progress"]')).toBeNull()+ expect(screen.queryByText('Your first report is ready')).toBeNull()+ }+ )+// `Inbox viewed` fires once every count has settled, so it doubles as "the empty verdict is in".async function waitForCountsToSettle(): Promise<void> {await waitFor(() => {diff --git a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsxindex c799083082ff..d07951c8d8b1 100644--- a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx+++ b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx@@ -13,6 +13,7 @@ import { inboxTaskKickoffLogic } from '../../inboxTaskKickoffLogic'import { inboxActivationVisibilityLogic } from '../../logics/inboxActivationVisibilityLogic'import { inboxFiltersLogic, isDefaultStateFilter } from '../../logics/inboxFiltersLogic'import type { InboxRankingSortField } from '../../logics/inboxFiltersLogic'+import { inboxSetupLogic } from '../../logics/inboxSetupLogic'import { reportListLogic, sectionListLogicProps } from '../../logics/reportListLogic'import {INBOX_SCOPE_ENTIRE_PROJECT,@@ -26,6 +27,7 @@ import { rankingSortScore } from '../../utils/reportOrdering'import { CardSkeleton } from '../cards/CardSkeleton'import { ReportCard } from '../cards/ReportCard'import { ReportContextMenu } from '../cards/ReportContextMenu'+import { FirstReportProgress } from '../emptyState/FirstReportProgress'import { InboxWaitingForWork } from '../emptyState/InboxWaitingForWork'import { InboxMcpBanner } from '../InboxMcpBanner'import { InboxActivationPanel } from '../onboarding/InboxActivationPanel'@@ -206,6 +208,7 @@ function emptyListCopy(scope: InboxScope, narrowed: boolean): string {*/export function ReportsTab(): JSX.Element {const { showActivationPanel: showActivation } = useValues(inboxActivationVisibilityLogic)+ const { savedState, firstReportProgress } = useValues(inboxSetupLogic)const { isStaff } = useValues(inboxSceneLogic)// The row context menus dispatch to this logic and unmount when a menu closes; pinning it here// keeps an in-flight create-PR listener alive past the click that closed the menu.@@ -271,15 +274,19 @@ export function ReportsTab(): JSX.Element {settledOnceRef.current = true}const showFirstLoadSkeleton = firstLoadPending && (!settledOnceRef.current || rows.length === 0)- const anyLoadFailed = selectedSections.some((key) => sections[key].reportsLoadFailed && !sections[key].isLoaded)+ const anyLoadFailed = selectedSections.some((key) => sections[key].reportsLoadFailed)const pageLoading = selectedSections.some((key) => sections[key].reportsResponseLoading)const pageLoadFailed = selectedSections.some((key) => sections[key].pageLoadFailed)const hasMore = selectedSections.some((key) => sections[key].hasMore)- // `ensureLoaded` only fetches a state with nothing loaded and nothing in flight, so retrying- // after a partial failure refetches the failed states and leaves the loaded ones alone.const retryFailedSections = (): void => {- selectedSections.forEach((key) => reportListLogic(sectionListLogicProps(key)).actions.ensureLoaded())+ selectedSections.forEach((key) => {+ if (sections[key].reportsLoadFailed && !sections[key].reportsResponseLoading) {+ const { actions } = reportListLogic(sectionListLogicProps(key))+ actions.loadCount()+ actions.loadReports()+ }+ })}// `loadMore` self-guards on `hasMore` and in-flight requests, so this only refetches the pages// that actually failed.@@ -350,8 +357,16 @@ export function ReportsTab(): JSX.Element {<InboxBulkSelectionBar reports={rows.map(({ report }) => report)} /><InboxMcpBanner />{showActivation && <InboxActivationPanel hasReports={!inboxIsEmpty && rows.length > 0} />}+ {showActivation && firstReportProgress && (+ <div className="min-w-0" data-attr="inbox-first-report-progress">+ <FirstReportProgress+ result={firstReportProgress}+ notificationEmail={savedState?.first_report_notification_email}+ />+ </div>+ )}- {inboxIsEmpty ? (+ {inboxIsEmpty && !anyLoadFailed ? (showActivation ? null : (<InboxWaitingForWork />)@@ -368,6 +383,7 @@ export function ReportsTab(): JSX.Element {<LemonButtonsize="small"type="secondary"+ loading={pageLoading}onClick={retryFailedSections}data-attr="inbox-report-list-retry">@@ -400,6 +416,7 @@ export function ReportsTab(): JSX.Element {<LemonButtonsize="xsmall"type="secondary"+ loading={pageLoading}onClick={retryFailedSections}data-attr="inbox-report-list-retry">diff --git a/products/signals/frontend/inbox/logics/inboxActivationLogic.test.ts b/products/signals/frontend/inbox/logics/inboxActivationLogic.test.tsindex 2523044980bd..c70b8e767c19 100644--- a/products/signals/frontend/inbox/logics/inboxActivationLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxActivationLogic.test.ts@@ -128,4 +128,34 @@ describe('Inbox activation progress', () => {await jest.advanceTimersByTimeAsync(20_000)expect(stateReads).toBe(readsBeforeDeadline + 1)})++ it('follows the first report after activation settles and stops when the investigation finishes', async () => {+ await settle()+ state = {+ ...state,+ jobs: { scout: 'started', recommendations: 'skipped' },+ first_report: { status: 'pending' },+ }+ await jest.advanceTimersByTimeAsync(10_000)+ await settle()+ state = {+ ...state,+ first_report: {+ status: 'running',+ task_id: '11111111-1111-4111-8111-111111111111',+ task_run_id: '22222222-2222-4222-8222-222222222222',+ },+ }+ await jest.advanceTimersByTimeAsync(20_000)+ await settle()+ expect(logic.values.savedState?.first_report).toEqual(state.first_report)+ state = { ...state, first_report: { status: 'insufficient_data', missing_data: ['No completed signups yet.'] } }+ await jest.advanceTimersByTimeAsync(10_000)+ await settle()+ expect(logic.values.savedState?.first_report).toEqual(state.first_report)+ const completedReads = stateReads+ await jest.advanceTimersByTimeAsync(20_000)+ await settle()+ expect(stateReads).toBe(completedReads)+ })})diff --git a/products/signals/frontend/inbox/logics/inboxSetupLogic.ts b/products/signals/frontend/inbox/logics/inboxSetupLogic.tsindex 4e459588dd3b..796de98d808f 100644--- a/products/signals/frontend/inbox/logics/inboxSetupLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxSetupLogic.ts@@ -36,6 +36,7 @@ import {signalsSourceConfigsPartialUpdate,} from '../../generated/api'import type {+ FirstReportStateApi,InboxOnboardingDraftApi,InboxOnboardingStateApi,ScoutSuggestionItemApi,@@ -46,16 +47,23 @@ import type { AgentRosterSource } from '../components/config/agentRosterMeta'import { captureInboxWelcomeManualSetupClicked, captureSignalSourceConnected } from '../inboxAnalytics'import { signalSourcesLogic, WAREHOUSE_SOURCE_SETUP, type WarehouseBackedSource } from '../signalSourcesLogic'import type { SourceProductStatus } from '../signalSourcesLogic'+import { INBOX_REPORT_SECTION_KEYS } from '../types'import type { SignalSourceConfig } from '../types'import { newInboxSetupDraft, reconcileInboxSetupDraft, selectedSourceCount, setupSources } from '../utils/inboxSetup'import type { InboxSetupSource } from '../utils/inboxSetup'import { inboxSetupDefaultScouts, inboxSetupScoutChoices } from '../utils/inboxSetupScouts'import { quickInboxSetupDraft } from '../utils/quickInboxSetup'import { DEFAULT_SUGGESTION_INTERVAL_MINUTES } from '../utils/scoutSuggestions'+import { reportListLogic, sectionListLogicProps } from './reportListLogic'import { scoutFleetLogic } from './scoutFleetLogic'import type { SignalScoutConfig } from './scoutFleetLogic'import { scoutSuggestionsLogic } from './scoutSuggestionsLogic'+/** A first-report state the progress card still shows. A created report shows as a row in the report list instead. */+export interface FirstReportProgressState extends FirstReportStateApi {+ status: Exclude<FirstReportStateApi['status'], 'report_created'>+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface inboxSetupLogicValues {featureFlags: FeatureFlagsSet // featureFlagLogic@@ -87,6 +95,7 @@ export interface inboxSetupLogicValues {error: string | nullexperimentVariant: 'control' | 'test-github' | 'test-ui' | nullfailedOperation: 'activation' | 'other' | 'scouts' | 'sources' | null+ firstReportProgress: FirstReportProgressState | nullhasGithubIntegration: booleaninProgress: booleanisFinalStep: boolean@@ -297,6 +306,7 @@ export interface inboxSetupLogicMeta {) => booleaninProgress: (savedState: InboxOnboardingStateApi | null, started: boolean, resumingSetup: boolean) => booleancompleted: (savedState: InboxOnboardingStateApi | null) => boolean+ firstReportProgress: (savedState: InboxOnboardingStateApi | null) => FirstReportProgressState | nullsourceCount: (draft: InboxOnboardingDraftApi) => numberhasGithubIntegration: (githubIntegrations: IntegrationType[]) => booleanisFinalStep: (draft: InboxOnboardingDraftApi) => boolean@@ -327,6 +337,10 @@ export type inboxSetupLogicType = MakeLogicType<inboxSetupLogicMeta>+function isFirstReportProgress(report: FirstReportStateApi): report is FirstReportProgressState {+ return report.status !== 'report_created'+}+export const inboxSetupLogic = kea<inboxSetupLogicType>([path(['products', 'signals', 'inbox', 'inboxSetupLogic']),connect(() => ({@@ -605,6 +619,11 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([!state?.completed_at && (started || !!state?.draft || resuming),],completed: [(s) => [s.savedState], (state: InboxOnboardingStateApi | null): boolean => !!state?.completed_at],+ firstReportProgress: [+ (s) => [s.savedState],+ (state: InboxOnboardingStateApi | null): FirstReportProgressState | null =>+ state?.first_report && isFirstReportProgress(state.first_report) ? state.first_report : null,+ ],sourceCount: [(s) => [s.draft], (draft: InboxOnboardingDraftApi): number => selectedSourceCount(draft)],hasGithubIntegration: [(s) => [s.githubIntegrations],@@ -648,7 +667,7 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([: undefined,],}),- listeners(({ values, actions, cache }) => {+ listeners(({ values, actions, cache, selectors }) => {let pendingSave: Promise<void> | null = nulllet persistedDraft: InboxOnboardingDraftApi | null = nulllet requestedStep: InboxOnboardingDraftApi['step'] | undefined@@ -861,6 +880,19 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([})}},+ loadSetupSuccess: ({ savedState }, _, __, previousState) => {+ const previous = selectors.savedState(previousState)?.first_report+ if (+ previous &&+ previous.status !== 'report_created' &&+ savedState.first_report?.status === 'report_created'+ ) {+ // The report list does not poll, so without this the first report appears only after a page reload.+ INBOX_REPORT_SECTION_KEYS.forEach((sectionKey) => {+ reportListLogic.findMounted(sectionListLogicProps(sectionKey))?.actions.refresh()+ })+ }+ },loadSetupFailure: () => capture('self-driving onboarding failed', { failed_operation: 'load_setup' }),[signalSourcesLogic.actionTypes.loadSourceConfigsFailure]: () => {actions.setError('Could not load signal sources. Try again.', 'sources')@@ -1242,9 +1274,22 @@ export const inboxSetupLogic = kea<inboxSetupLogicType>([},}}),- afterMount(({ actions, values }) => {+ afterMount(({ actions, values, cache }) => {if (values.currentTeamId) {actions.loadSetup()}+ cache.disposables.add(() => {+ const timer = window.setInterval(() => {+ if (+ values.completed &&+ !values.savedStateLoading &&+ (values.savedState?.first_report?.status === 'pending' ||+ values.savedState?.first_report?.status === 'running')+ ) {+ actions.loadSetup()+ }+ }, 10000)+ return () => window.clearInterval(timer)+ })}),])