: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): redesigned inbox welcome page behind experiment flag (#79988)
Chris Volzercd06b4b70ab6
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex c04dca4fc09c..5c869157550d 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6386,10 +6386,18 @@ snapshots:hash: v1.k794b7964.9c0f77f61291c86c4d171c8c0b59684cc0b94eb68239488a5151e8eda4a7d27f.7phlMjtIUvtdFB8FLuy-G5iHj8QLvOrPm7v1rEPy4G0scenes-app-inbox-scene--self-driving-onboarding--light:hash: v1.k794b7964.8ef3184a453d8082e2e3b7ae2716c4f40ea8c99c1b5f8a579c5bbc138985ad09.LjMg91MLj3APANRgr6pCKk697oexyrwWR0kgBpE6s4s+ scenes-app-inbox-scene--self-driving-onboarding-redesign--dark:+ hash: v1.k794b7964.a9b064dbf70e2dff0e3147c17ed0d6b924faa2e2a1d3b7b3723e5683b9af10d0.TJpI5NRs856RifBeff4jnkxIvSFACvygFf-UKT9G9Yo+ scenes-app-inbox-scene--self-driving-onboarding-redesign--light:+ hash: v1.k794b7964.c2f7366b673e20e85513c454effae314d643958a3d2424e7902d572909f024fe.edek45zj8tVjVDjsqgddUJUnPKAHanQkzZwR5Ylr93Qscenes-app-inbox-scene--self-driving-paused--dark:hash: v1.k794b7964.bd2bee28eee6668bfd9f1e5c00191e38189bc27ac734c8adf8ddc55da8381b1b.HFfADdkZDnQv2BGCHc-yzXZ4Z0Rpk-xn9cn7uRUXIygscenes-app-inbox-scene--self-driving-paused--light:hash: v1.k794b7964.54f6835c7d4a343bd6c9efef4189805b8dc5ea3347380b5d772ce55abaad79be.P7Ramt_0TgHAl4YgBsBumQ1QVxkb2ds9GsTaxbNAKRQ+ scenes-app-inbox-scene--self-driving-verdict-pending--dark:+ hash: v1.k794b7964.570e5dddd645996b94ff94b2c563b32ced3793db3ab5ccf360d16126af3b9a0b.WC_VEZ1N_iX-o4r11w15QWfD8Nzo1gFerTznKiaIX84+ scenes-app-inbox-scene--self-driving-verdict-pending--light:+ hash: v1.k794b7964.1d230f03b5a074e0816ee4c5dd1b4591cfdf86bb602971a6233019985f1c2677.h7Zlyp6gh4AnCQRve-W4zeSDnhAhhqVM1FIqiYN1gNAscenes-app-inbox-signalsourcespanel--armed-but-tools-off--dark:hash: v1.k794b7964.4eccbb229cc622764d4ff5d455f089a98fdebe9f5d9cbbcc5280c44fd8bd7f3c.HlgmZbqLubOWZoCcRljJWPEDRVRx-fH9V0D0gZqc-_kscenes-app-inbox-signalsourcespanel--armed-but-tools-off--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 6bad44557592..17278acf2c81 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -341,6 +341,7 @@ export const FEATURE_FLAGS = {HOGQL_WAREHOUSE_ACCESS_CONTROL: 'hogql-warehouse-access-control', // owner: @a-lider #team-platform-features, gates per-object access control for warehouse tables and viewsIDENTITY_MATCHING: 'identity-matching', // owner: @fercgomes #team-growth, gates new identity matching scene on marketing analyticsINBOX_SLACK_NOTIFICATIONS: 'inbox-slack-notifications', // owner: #team-self-driving, gates the Slack notifications config card in the inbox+ INBOX_WELCOME_REDESIGN: 'inbox-welcome-redesign', // owner: #team-self-driving multivariate=control,test — experiment on the inbox self-driving welcome takeoverINSIGHT_DRAG_TO_ZOOM: 'insight-drag-to-zoom', // owner: @sampennington #team-product-analytics, gates x-axis drag-to-zoom on insight charts (trends today, SQL to follow)INSIGHT_SUBSCRIBE_PROMINENT_BUTTON: 'insight-subscribe-prominent-button', // owner: @mattp #team-analytics-platform multivariate=control,testJS_SNIPPET_VERSIONING: 'js-snippet-versioning', // owner: #team-client-librariesdiff --git a/products/signals/frontend/inbox/InboxScene.stories.tsx b/products/signals/frontend/inbox/InboxScene.stories.tsxindex 297ca1c19a72..b1f9cf421d5c 100644--- a/products/signals/frontend/inbox/InboxScene.stories.tsx+++ b/products/signals/frontend/inbox/InboxScene.stories.tsx@@ -14,6 +14,7 @@ import {mockTeamConfig,} from './__mocks__/inboxMocks'import { InboxScene } from './InboxScene'+import { INBOX_LAST_UI_STATE_STORAGE_KEY } from './logics/inboxOnboardingLogic'// Full Inbox scene with a populated report list. Use this to polish the holistic// layout: header, tab bar + single border, scope picker, filter bar, and the@@ -90,6 +91,44 @@ export const SelfDrivingOnboarding: Story = {],}+// The same fresh-project state with the welcome-redesign experiment's test arm pinned → the+// full-pane hero welcome (no tab row) instead of the locked "Welcome" tab.+export const SelfDrivingOnboardingRedesign: Story = {+ parameters: {+ // Story parameters replace the meta's, so the meta-level flag is re-listed here.+ featureFlags: { [FEATURE_FLAGS.PRODUCT_AUTONOMY]: true, [FEATURE_FLAGS.INBOX_WELCOME_REDESIGN]: 'test' },+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/signals/reports': () => [200, { results: [], count: 0, next: null, previous: null }],+ '/api/projects/:id/signals/source_configs': () => [200, { results: [], count: 0 }],+ '/api/projects/:id/signals/scout/configs': () => [200, []],+ },+ }),+ ],+}++// First-ever visit while the set-up verdict is still loading (config + count requests hang, no+// cached verdict) → the neutral skeleton, with no tab bar and no welcome page. Guards the+// regression where the normal tabbed inbox rendered first and was then swapped for the takeover.+export const SelfDrivingVerdictPending: Story = {+ decorators: [+ (StoryFn) => {+ // Other stories cache their settled verdict; this story is the no-history first visit.+ window.localStorage.removeItem(INBOX_LAST_UI_STATE_STORAGE_KEY)+ return <StoryFn />+ },+ mswDecorator({+ get: {+ '/api/projects/:id/signals/reports': () => new Promise(() => {}),+ '/api/projects/:id/signals/source_configs': () => new Promise(() => {}),+ '/api/projects/:id/signals/scout/configs': () => new Promise(() => {}),+ },+ }),+ ],+}+// Had self-driving before (reports exist) but nothing is watching now → the sleek re-enable banner// over the normal inbox, so existing work stays accessible. Reports are mocked explicitly (not// inherited) so "existing work" is unambiguous and the banner – not the takeover – is shown.diff --git a/products/signals/frontend/inbox/InboxScene.tsx b/products/signals/frontend/inbox/InboxScene.tsxindex 0592919f4c18..cfe33ce1469b 100644--- a/products/signals/frontend/inbox/InboxScene.tsx+++ b/products/signals/frontend/inbox/InboxScene.tsx@@ -13,10 +13,12 @@ import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { CardSkeleton } from './components/cards/CardSkeleton'import { ScoutDetailView } from './components/config/scouts/ScoutDetailView'import { ReportDetail, ReportDetailSkeleton } from './components/detail/ReportDetail'import { FindingsPanel } from './components/findings/FindingsPanel'import { InboxOnboardingBanner, InboxOnboardingTakeover } from './components/onboarding/InboxOnboarding'+import { InboxWelcomeRedesign } from './components/onboarding/InboxWelcomeRedesign'import { ScratchpadPanel } from './components/scratchpad/ScratchpadPanel'import { AgentSetupColumn } from './components/shell/AgentSetupColumn'import { InboxScopeSelect } from './components/shell/InboxScopeSelect'@@ -111,7 +113,7 @@ function ActiveTabBody({*/function InboxListView(): JSX.Element {const { activeTab, signalRuns, signalRunsLoading } = useValues(inboxSceneLogic)- const { onboardingMode } = useValues(inboxOnboardingLogic)+ const { onboardingMode, isWelcomeRedesign } = useValues(inboxOnboardingLogic)const { ref: widthRef, size } = useResizeBreakpoints({ 0: 'narrow', [SETUP_RAIL_MIN_PX]: 'wide' },{ initialSize: 'wide' }@@ -121,7 +123,10 @@ function InboxListView(): JSX.Element {// tab (the other tabs are visible but disabled) whose body is the onboarding card. The setup rail// is dropped too, so the onboarding is the whole story – just run the one command.const onboarding = onboardingMode === 'takeover'- const showRail = wide && !onboarding+ // The takeover verdict is still settling: commit to neither UI. Rendering the tab bar or the+ // rail here is what caused the normal inbox to flash in and get replaced by the welcome page.+ const pending = onboardingMode === 'pending'+ const showRail = wide && !onboarding && !pending// The rail and the Configuration tab are mutually exclusive – never leave 'config' active// (e.g. via a deep link) while the rail shows, or the rail and a config body would both appear.const effectiveTab = showRail && activeTab === 'config' ? 'pulls' : activeTab@@ -152,17 +157,29 @@ function InboxListView(): JSX.Element {<div className="flex flex-col min-h-0 flex-1 min-w-0">{/* pl-5 (20px) aligns the first tab label with the SceneTitleSection description above;pr-6 matches the report list's px-6 so the scope select shares the list's right edge. */}- <div className="flex items-end justify-between gap-2 border-b border-primary pl-5 pr-6 shrink-0">- <InboxTabBar showConfigTab={!wide} onboarding={onboarding} />- {!onboarding && isReportListTab(effectiveTab) && (- <div className="pb-1.5">- <InboxScopeSelect />- </div>- )}- </div>+ {/* The redesigned welcome (experiment test arm) is a full-pane page with no tab+ row at all; control keeps the locked "Welcome" tab over the disabled real tabs. */}+ {!isWelcomeRedesign && !pending && (+ <div className="flex items-end justify-between gap-2 border-b border-primary pl-5 pr-6 shrink-0">+ <InboxTabBar showConfigTab={!wide} onboarding={onboarding} />+ {!onboarding && isReportListTab(effectiveTab) && (+ <div className="pb-1.5">+ <InboxScopeSelect />+ </div>+ )}+ </div>+ )}<div className="flex-1 overflow-auto min-h-0">- {onboarding ? (- <InboxOnboardingTakeover />+ {pending ? (+ <div className="mx-auto max-w-4xl px-6 py-4">+ <CardSkeleton count={4} variant="cards" />+ </div>+ ) : onboarding ? (+ isWelcomeRedesign ? (+ <InboxWelcomeRedesign />+ ) : (+ <InboxOnboardingTakeover />+ )) : (<ActiveTabBodytab={effectiveTab}@@ -232,7 +249,7 @@ export function InboxScene(): JSX.Element {isFindingsOpen,} = useValues(inboxSceneLogic)const { runSessionAnalysis, setScratchpadOpen, setFindingsOpen } = useActions(inboxSceneLogic)- const { onboardingMode } = useValues(inboxOnboardingLogic)+ const { onboardingMode, isWelcomeRedesign } = useValues(inboxOnboardingLogic)const { isDev } = useValues(preflightLogic)const { searchParams } = useValues(router)@@ -268,10 +285,17 @@ export function InboxScene(): JSX.Element {name="Inbox"// The description explains the active tab so new users can orient themselves.// In the onboarding takeover the tabs are locked, so keep the overall pitch.+ // The redesigned welcome leads with its own full-size pitch, so a description+ // here would say the same thing twice. While the verdict is pending neither+ // description is safe to show – either would flash and swap.description={- onboardingMode === 'takeover'- ? 'Self-driving for your product. Look through code changes and reports from PostHog agents.'- : INBOX_TAB_DESCRIPTION[activeTab]+ onboardingMode === 'pending'+ ? null+ : onboardingMode === 'takeover'+ ? isWelcomeRedesign+ ? null+ : 'Self-driving for your product. Look through code changes and reports from PostHog agents.'+ : INBOX_TAB_DESCRIPTION[activeTab]}resourceType={{ type: 'inbox' }}actions={diff --git a/products/signals/frontend/inbox/components/onboarding/InboxOnboarding.tsx b/products/signals/frontend/inbox/components/onboarding/InboxOnboarding.tsxindex 6e26831b5a37..305168a1c0f7 100644--- a/products/signals/frontend/inbox/components/onboarding/InboxOnboarding.tsx+++ b/products/signals/frontend/inbox/components/onboarding/InboxOnboarding.tsx@@ -1,6 +1,7 @@import './InboxOnboarding.scss'import { useActions } from 'kea'+import { useEffect } from 'react'import { IconBolt, IconGithub, IconInfo, IconNotebook, IconPause, IconX } from '@posthog/icons'import { LemonButton, Tooltip } from '@posthog/lemon-ui'@@ -8,6 +9,11 @@ import { LemonButton, Tooltip } from '@posthog/lemon-ui'import { Logomark } from 'lib/brand'import { CommandBlock } from 'lib/components/CommandBlock/CommandBlock'+import {+ InboxWelcomeCopySurface,+ captureInboxWelcomeCommandCopied,+ captureInboxWelcomeViewed,+} from '../../inboxAnalytics'import { inboxOnboardingLogic } from '../../logics/inboxOnboardingLogic'import { PullRequestPreview, ReportPreview } from './InboxOnboardingPreviews'@@ -87,7 +93,13 @@ const BEATS: Beat[] = [* Reuses the shared `CommandBlock` (same one MCP install uses) with the `rainbow` AI gradient, so* it reads as "enable a capability" rather than a code dump.*/-function SelfDrivingCommand({ size = 'md' }: { size?: 'sm' | 'md' }): JSX.Element {+function SelfDrivingCommand({+ size = 'md',+ surface,+}: {+ size?: 'sm' | 'md'+ surface: InboxWelcomeCopySurface+}): JSX.Element {return (<CommandBlockcommand={SELF_DRIVING_WIZARD_COMMAND}@@ -95,6 +107,11 @@ function SelfDrivingCommand({ size = 'md' }: { size?: 'sm' | 'md' }): JSX.ElemenariaLabel="Copy self-driving setup command"decoration="rainbow"size={size}+ // The takeover is the control arm of the welcome experiment; the banner shows one+ // fixed layout regardless of arm, so its copies carry no variant.+ onCopy={() =>+ captureInboxWelcomeCommandCopied({ variant: surface === 'takeover' ? 'control' : null, surface })+ }// rounded-md sits one step inside the rounded-lg card/banner it nests in.className="!m-0 rounded-md border border-primary bg-surface-secondary hover:border-accent"/>@@ -128,7 +145,7 @@ function CommandCard(): JSX.Element {Run it in your project's repo. There are no in-app steps to click through.</p></div>- <SelfDrivingCommand size="md" />+ <SelfDrivingCommand size="md" surface="takeover" /><ul className="m-0 flex list-none flex-col gap-1.5 p-0">{WIZARD_SETS_UP.map((item) => (<li key={item.label} className="flex items-center gap-2.5 text-sm text-secondary">@@ -170,6 +187,10 @@ function BeatRow({ beat, index }: { beat: Beat; index: number }): JSX.Element {* report list – a plain centered column (not itself a card) that eases in with a subtle scale + fade.*/export function InboxOnboardingTakeover(): JSX.Element {+ useEffect(() => {+ captureInboxWelcomeViewed({ variant: 'control' })+ }, [])+return (<div className="InboxOnboardingTakeover mx-auto flex w-full max-w-3xl flex-col gap-6 px-4 py-6 sm:px-6 sm:py-12"><Hero />@@ -209,7 +230,7 @@ export function InboxOnboardingBanner(): JSX.Element {No scouts or sources are enabled right now.{' '}<strong>Switch self-driving back on with one command in your product's repo:</strong></p>- <SelfDrivingCommand size="sm" />+ <SelfDrivingCommand size="sm" surface="banner" /></div>)}diff --git a/products/signals/frontend/inbox/components/onboarding/InboxWelcomeRedesign.scss b/products/signals/frontend/inbox/components/onboarding/InboxWelcomeRedesign.scssnew file mode 100644index 000000000000..c46169f8bdba--- /dev/null+++ b/products/signals/frontend/inbox/components/onboarding/InboxWelcomeRedesign.scss@@ -0,0 +1,91 @@+// Styles for the redesigned self-driving welcome takeover (welcome-page experiment, test arm).+// The hero CTA is a deliberate terminal-dark block, so its colors are hardcoded rather than+// tokenized; everything else leans on the app tokens.++.InboxWelcomeRedesign {+ &__cta {+ background: #18181a;+ border-radius: 10px;++ // The flat offset elevation of the 3000 style (never blur); the border token doubles as+ // the shadow color so it reads correctly on both the light and dark app background.+ box-shadow: 0 3px 0 var(--color-border-primary);++ // The near-black block sits at the same lightness as the dark app background, so it+ // disappears into the page. Lift it into a raised surface instead — the one element the+ // page asks the user to act on has to read as a distinct block in both themes.+ [theme='dark'] & {+ background: var(--color-neutral-cool-750);+ }+ }++ &__copy-button {+ padding: 6px 12px;+ font-size: 11px;+ font-weight: 700;+ color: #111;+ cursor: pointer;+ background: var(--brand-yellow);+ border: none;+ border-radius: 6px;+ }++ &__stage {+ animation: InboxWelcomeRedesign__stage 9s infinite;++ &--pipeline {+ animation-delay: 3s;+ }++ &--inbox {+ animation-delay: 6s;+ }+ }++ &__arrow {+ animation: InboxWelcomeRedesign__arrow 3s ease-in-out infinite;++ &--second {+ animation-delay: 1.5s;+ }+ }+}++// Each stage lights up in sequence (signals at 0s, pipeline at 3s, inbox at 6s) so the diagram+// reads as a loop: signal sources -> scouts & pipeline -> your inbox.+@keyframes InboxWelcomeRedesign__stage {+ 0%,+ 30%,+ 100% {+ border-color: var(--color-border-primary);+ box-shadow: none;+ }++ 6%,+ 24% {+ border-color: var(--brand-red);+ box-shadow: 0 3px 0 rgb(245 78 0 / 18%);+ }+}++@keyframes InboxWelcomeRedesign__arrow {+ 0%,+ 100% {+ opacity: 0.35;+ transform: translateX(0);+ }++ 50% {+ opacity: 1;+ transform: translateX(5px);+ }+}++@media (prefers-reduced-motion: reduce) {+ .InboxWelcomeRedesign {+ &__stage,+ &__arrow {+ animation: none;+ }+ }+}diff --git a/products/signals/frontend/inbox/components/onboarding/InboxWelcomeRedesign.tsx b/products/signals/frontend/inbox/components/onboarding/InboxWelcomeRedesign.tsxnew file mode 100644index 000000000000..495d467ca003--- /dev/null+++ b/products/signals/frontend/inbox/components/onboarding/InboxWelcomeRedesign.tsx@@ -0,0 +1,206 @@+import './InboxWelcomeRedesign.scss'++import { useEffect, useRef, useState } from 'react'++import { IconRewindPlay, IconWarning } from '@posthog/icons'+import { LemonButton, LemonCard, LemonTag } from '@posthog/lemon-ui'++import { Logomark } from 'lib/brand'+import { IconSlack } from 'lib/lemon-ui/icons'+import { copyToClipboard } from 'lib/utils/copyToClipboard'++import { captureInboxWelcomeCommandCopied, captureInboxWelcomeViewed } from '../../inboxAnalytics'+import { SELF_DRIVING_WIZARD_COMMAND } from './InboxOnboarding'++/** How long the copy button reads "Copied" before flipping back. */+const COPIED_RESET_MS = 1600++/**+ * The hero CTA: the wizard command on a near-black block with a single yellow copy button.+ * The button is its own feedback ("Copy" -> "Copied"), so the clipboard toast is suppressed.+ */+function CommandCta(): JSX.Element {+ const [copied, setCopied] = useState(false)+ const resetTimerRef = useRef<number | null>(null)++ useEffect(() => {+ return () => {+ if (resetTimerRef.current !== null) {+ window.clearTimeout(resetTimerRef.current)+ }+ }+ }, [])++ const handleCopy = (): void => {+ void copyToClipboard(SELF_DRIVING_WIZARD_COMMAND, 'self-driving setup command', { silent: true })+ captureInboxWelcomeCommandCopied({ variant: 'redesign', surface: 'takeover' })+ setCopied(true)+ if (resetTimerRef.current !== null) {+ window.clearTimeout(resetTimerRef.current)+ }+ resetTimerRef.current = window.setTimeout(() => setCopied(false), COPIED_RESET_MS)+ }++ return (+ <div className="InboxWelcomeRedesign__cta flex flex-wrap items-center justify-center gap-x-3 gap-y-2.5 py-2.5 pl-4 pr-2.5">+ <span className="whitespace-nowrap font-mono text-sm text-white">+ <span className="select-none text-[#6f6f76]">$ </span>+ {SELF_DRIVING_WIZARD_COMMAND}+ </span>+ <button+ type="button"+ className="InboxWelcomeRedesign__copy-button"+ onClick={handleCopy}+ aria-label="Copy self-driving setup command"+ >+ {copied ? 'Copied' : 'Copy'}+ </button>+ </div>+ )+}++function StageLabel({ children }: { children: string }): JSX.Element {+ return <div className="text-center text-xs font-semibold text-secondary">{children}</div>+}++/** A card in the loop diagram, lighting up at its stage's moment in the 9s sequence. */+function StageCard({+ stage,+ className,+ children,+}: {+ stage: 'signals' | 'pipeline' | 'inbox'+ className?: string+ children: React.ReactNode+}): JSX.Element {+ return (+ <LemonCard+ hoverEffect={false}+ className={`InboxWelcomeRedesign__stage InboxWelcomeRedesign__stage--${stage} ${className ?? ''}`}+ >+ {children}+ </LemonCard>+ )+}++function Arrow({ second = false }: { second?: boolean }): JSX.Element {+ return (+ <div+ className={`InboxWelcomeRedesign__arrow ${+ second ? 'InboxWelcomeRedesign__arrow--second ' : ''+ }hidden pt-5 text-center text-2xl text-border-secondary md:block`}+ aria-hidden="true"+ >+ →+ </div>+ )+}++/**+ * The illustrative loop: signal sources -> scouts & pipeline -> a PR in your inbox. Never interactive+ * (pointer-events-none on the whole grid); the cards and the Review button are props, not UI.+ */+function LoopDiagram(): JSX.Element {+ return (+ <div className="pointer-events-none select-none grid grid-cols-1 items-center gap-x-1.5 gap-y-4 md:grid-cols-[1fr_34px_1fr_34px_1.2fr]">+ <div className="flex flex-col gap-2">+ <StageLabel>Signal sources</StageLabel>+ <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center">+ <IconRewindPlay className="text-sm text-[var(--color-product-session-replay-light)] dark:text-[var(--color-product-session-replay-dark)]" />+ </span>+ <span className="truncate text-xs">Rage clicks in checkout replay</span>+ </StageCard>+ <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center">+ <IconWarning className="text-sm text-[var(--color-product-error-tracking-light)] dark:text-[var(--color-product-error-tracking-dark)]" />+ </span>+ <span className="truncate font-mono text-xs">TypeError in checkout</span>+ </StageCard>+ <StageCard stage="signals" className="flex items-center gap-2 px-3 py-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center">+ <IconSlack className="size-4" />+ </span>+ <span className="truncate text-xs">"checkout hangs on Safari"</span>+ </StageCard>+ </div>+ <Arrow />+ <div className="flex flex-col gap-2">+ <StageLabel>Scouts & pipeline</StageLabel>+ <StageCard stage="pipeline" className="flex flex-col gap-1.5 px-3.5 py-3">+ <div className="flex items-center gap-2 text-[13px] font-semibold">+ <span className="size-[7px] shrink-0 rounded-full bg-success" />+ Reproduced the bug, wrote the fix+ </div>+ <div className="flex items-center gap-2">+ <span className="font-mono text-xs font-semibold text-success">+142</span>+ <span className="font-mono text-xs font-semibold text-danger">−38</span>+ <LemonTag type="success">Tests passing</LemonTag>+ </div>+ </StageCard>+ </div>+ <Arrow second />+ <div className="flex flex-col gap-2">+ <StageLabel>Your inbox</StageLabel>+ <StageCard stage="inbox" className="flex items-center gap-2.5 px-3.5 py-3">+ <span className="flex size-[26px] shrink-0 items-center justify-center rounded-md bg-fill-warning-highlight font-mono text-[11px] font-bold text-warning">+ P1+ </span>+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <div className="text-[13px] font-semibold">+ <code>fix(checkout)</code> restore Safari encode+ </div>+ <div className="text-[11.5px] text-tertiary">#486 · ready to merge</div>+ </div>+ <LemonButton type="primary" size="small" className="shrink-0">+ Review+ </LemonButton>+ </StageCard>+ </div>+ </div>+ )+}++/**+ * Redesigned self-driving welcome takeover (test arm of the `inbox-welcome-redesign` experiment;+ * `InboxOnboardingTakeover` is control). Leads with the payoff, makes the wizard command the one+ * CTA, and explains signal sources and the scouts & pipeline stage as labels over an animated loop instead of prose.+ * Rendered without the tab bar: this variant is a full-pane welcome, not a locked tab.+ */+export function InboxWelcomeRedesign(): JSX.Element {+ useEffect(() => {+ captureInboxWelcomeViewed({ variant: 'redesign' })+ }, [])++ return (+ <div className="InboxWelcomeRedesign flex min-h-full flex-col justify-center py-10">+ <div className="px-6 pb-12">+ <div className="mx-auto flex max-w-[720px] flex-col items-center text-center">+ <div className="mb-7">+ <Logomark jumpOnClick size="xl" />+ </div>+ <h1 className="mb-4 text-2xl font-bold leading-[1.1] tracking-[-0.02em] sm:text-[32px]">+ Ship fixes while you sleep+ </h1>+ <p className="mb-9 max-w-[560px] text-[15px] leading-[1.55] text-secondary">+ PostHog watches your session replays, errors, and Slack. When it finds something worth fixing,+ it writes the pull request. You review and merge.+ </p>+ <CommandCta />+ <p className="mt-3.5 max-w-[520px] text-[13px] text-tertiary">+ Run it in your repo. That's the whole setup: it connects GitHub and picks the signal sources and+ scouts to watch. PRs start landing in this inbox.+ </p>+ </div>+ </div>+ <div className="px-6 md:px-12">+ <div className="mx-auto max-w-[1060px]">+ <LoopDiagram />+ <p className="mt-6 text-center text-xs text-tertiary">+ Your first 3 PRs each month are free, then $15 per PR. Reports are always free.+ </p>+ </div>+ </div>+ </div>+ )+}diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex ce76c6110cbb..3221b15d6148 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -15,6 +15,8 @@ export const INBOX_CLIENT = 'cloud' as constexport const INBOX_EVENTS = {VIEWED: 'Inbox viewed',+ WELCOME_VIEWED: 'Inbox welcome viewed',+ WELCOME_COMMAND_COPIED: 'Inbox welcome command copied',PANEL_VIEWED: 'Inbox panel viewed',QUERY_CHANGED: 'Inbox query changed',REPORTS_IMPRESSED: 'Inbox reports impressed',@@ -186,6 +188,39 @@ function actionabilityBreakdown(reports: SignalReport[]): Record<string, number>}}+/** Which welcome takeover a user saw: the original stacked card or the redesigned hero. */+export type InboxWelcomeVariant = 'control' | 'redesign'++/** Where a wizard-command copy happened: the full welcome takeover or the re-enable banner. */+export type InboxWelcomeCopySurface = 'takeover' | 'banner'++/**+ * The self-driving welcome takeover rendered. `Inbox viewed` never fires for un-set-up teams (the+ * takeover replaces the report list), so this is the top-of-funnel event for setup conversion, and+ * the exposure marker for welcome-page experiments (`variant` mirrors the experiment arm).+ */+export function captureInboxWelcomeViewed(params: { variant: InboxWelcomeVariant }): void {+ captureInboxEvent(INBOX_EVENTS.WELCOME_VIEWED, {+ variant: params.variant,+ })+}++/**+ * The wizard setup command was copied. Previously only recoverable from autocapture (and+ * unreliably: `$el_text` is null on about half of clicks), so the setup funnel's first+ * conversion step gets its own event. `variant` is null on the banner, which shows one+ * fixed layout regardless of the welcome experiment.+ */+export function captureInboxWelcomeCommandCopied(params: {+ variant: InboxWelcomeVariant | null+ surface: InboxWelcomeCopySurface+}): void {+ captureInboxEvent(INBOX_EVENTS.WELCOME_COMMAND_COPIED, {+ variant: params.variant,+ surface: params.surface,+ })+}+export function captureInboxViewed(params: {tab: stringreports: SignalReport[]@@ -583,7 +618,7 @@ export function captureInboxRunOpened(params: {* inbox pageview fires either way. `reason` separates "we chose not to ask" from "nobody wanted it".*/export function captureInboxOnboardingDecided(params: {- mode: 'takeover' | 'banner' | 'none'+ mode: 'takeover' | 'banner' | 'none' | 'pending'reason: string | null}): void {captureInboxEvent(INBOX_EVENTS.ONBOARDING_DECIDED, {diff --git a/products/signals/frontend/inbox/logics/inboxOnboardingLogic.test.ts b/products/signals/frontend/inbox/logics/inboxOnboardingLogic.test.tsindex 76ee67ae534e..f55edddfe1b4 100644--- a/products/signals/frontend/inbox/logics/inboxOnboardingLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxOnboardingLogic.test.ts@@ -3,7 +3,10 @@ import { SELF_DRIVING_WORKFLOW_ID } from 'scenes/onboarding/shared/wizard-sync/wimport {computeOnboardingDecision,InboxOnboardingDecision,+ InboxOnboardingMode,+ InboxSettledUiState,OnboardingModeInputs,+ resolveDisplayMode,resolveWizardState,WizardStateInputs,} from './inboxOnboardingLogic'@@ -18,23 +21,24 @@ describe('inboxOnboardingLogic', () => {bannerDismissed: false,isWizardRunning: false,isWizardStateResolved: true,+ isRefetching: false,}it.each<[string, Partial<OnboardingModeInputs>, InboxOnboardingDecision]>([- // Until the config check resolves, stay on the normal inbox (its own skeleton) – never guess- // the takeover, which would jolt for a set-up user.- ['config still loading', { isSetupLoaded: false }, { mode: 'none', reason: 'setup_loading' }],+ // Until the config check resolves the takeover is still on the table – commit to neither+ // UI, or whichever renders first flashes and gets swapped for the other.+ ['config still loading', { isSetupLoaded: false }, { mode: 'pending', reason: 'setup_loading' }],// Config not loaded wins even if the set-up flag is incidentally true – we don't trust it yet.['config still loading, set-up flag ignored',{ isSetupLoaded: false, isSelfDrivingSetUp: true },- { mode: 'none', reason: 'setup_loading' },+ { mode: 'pending', reason: 'setup_loading' },],- // Not set up, counts still loading → keep the inbox until we can choose takeover vs banner.+ // Not set up, counts still loading → they decide takeover vs banner, so keep holding.['not set up, counts still loading',{ areCountsResolved: false },- { mode: 'none', reason: 'counts_loading' },+ { mode: 'pending', reason: 'counts_loading' },],// Set up (a source, scout, or scanner is watching) → no onboarding at all, and no wait on counts.['set up, empty inbox', { isSelfDrivingSetUp: true }, { mode: 'none', reason: 'already_set_up' }],@@ -48,6 +52,12 @@ describe('inboxOnboardingLogic', () => {{ isSelfDrivingSetUp: true, areCountsResolved: false },{ mode: 'none', reason: 'already_set_up' },],+ // ...and no wait on the wizard detector either – its answer can't flip a set-up verdict.+ [+ 'set up, wizard state unknown (skipped)',+ { isSelfDrivingSetUp: true, isWizardStateResolved: false },+ { mode: 'none', reason: 'already_set_up' },+ ],// Not set up + nothing in the inbox → full-pane takeover (nothing to block).['not set up, empty inbox', {}, { mode: 'takeover', reason: null }],// Not set up but work exists → non-blocking banner, so existing work stays accessible.@@ -82,18 +92,59 @@ describe('inboxOnboardingLogic', () => {['wizard state unknown, would otherwise take over',{ isWizardStateResolved: false },- { mode: 'none', reason: 'wizard_state_unknown' },+ { mode: 'pending', reason: 'wizard_state_unknown' },],+ // Known work rules the takeover out – every remaining outcome renders the normal inbox, so+ // show it immediately; the banner joins once the remaining checks settle.['wizard state unknown, would otherwise banner',{ isWizardStateResolved: false, hasExistingWork: true },{ mode: 'none', reason: 'wizard_state_unknown' },],+ [+ 'with work, config still loading',+ { isSetupLoaded: false, hasExistingWork: true },+ { mode: 'none', reason: 'setup_loading' },+ ],+ // A refetch in flight (wizard just finished, or the user came back to the tab) means+ // the loaded values may be stale – never commit to the takeover on them.+ [+ 'refetch in flight, would otherwise take over',+ { isRefetching: true },+ { mode: 'pending', reason: 'refetching' },+ ],+ // The refetch hold only guards the takeover; settled inbox verdicts stay put.+ [+ 'refetch in flight, set up',+ { isRefetching: true, isSelfDrivingSetUp: true },+ { mode: 'none', reason: 'already_set_up' },+ ],+ [+ 'refetch in flight, with work',+ { isRefetching: true, hasExistingWork: true },+ { mode: 'banner', reason: null },+ ],])('%s', (_label, overrides, expected) => {expect(computeOnboardingDecision({ ...base, ...overrides })).toEqual(expected)})})+ describe('resolveDisplayMode', () => {+ it.each<[string, InboxOnboardingMode, InboxSettledUiState | null, InboxOnboardingMode]>([+ // A settled verdict always wins – the cache must never override live inputs.+ ['settled none ignores cached takeover', 'none', 'takeover', 'none'],+ ['settled takeover ignores cached inbox', 'takeover', 'inbox', 'takeover'],+ ['settled banner ignores cache', 'banner', 'takeover', 'banner'],+ // While the verdict is settling, paint what this team saw last visit.+ ['pending falls back to cached takeover', 'pending', 'takeover', 'takeover'],+ ['pending falls back to cached inbox', 'pending', 'inbox', 'none'],+ // No history (very first visit) → the neutral skeleton.+ ['pending with no cache stays pending', 'pending', null, 'pending'],+ ])('%s', (_label, resolvedMode, lastSettledUiState, expected) => {+ expect(resolveDisplayMode(resolvedMode, lastSettledUiState)).toBe(expected)+ })+ })+describe('resolveWizardState', () => {const base: WizardStateInputs = {hasResolvedSessionState: false,diff --git a/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts b/products/signals/frontend/inbox/logics/inboxOnboardingLogic.tsindex b366d282755c..3a359a06836f 100644--- a/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxOnboardingLogic.ts@@ -1,9 +1,11 @@-import { MakeLogicType, actions, afterMount, connect, kea, path, reducers, selectors } from 'kea'+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'import { subscriptions } from 'kea-subscriptions'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { FEATURE_FLAGS } from 'lib/constants'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'import { wizardActiveSessionDetectorLogic } from 'scenes/onboarding/shared/wizard-sync/wizardActiveSessionDetectorLogic'import { SELF_DRIVING_WORKFLOW_ID } from 'scenes/onboarding/shared/wizard-sync/workflows'+import { teamLogic } from 'scenes/teamLogic'import type { SignalScoutConfigApi as SignalScoutConfig } from 'products/signals/frontend/generated/api.schemas'@@ -17,6 +19,10 @@ import { scoutFleetLogic } from './scoutFleetLogic'// their verdict almost immediately, long enough that a fleet-wide reload doesn't land as one spike.const MOUNT_CHECK_JITTER_MS = 3 * 1000+// Throttle for the return-to-tab refetch. The disposables plugin re-runs setup on every+// `visibilitychange → visible`; without a floor, alt-tab flapping turns into request bursts.+const VISIBILITY_REFETCH_THROTTLE_MS = 5 * 1000+// Ceiling on how long the wizard verdict may hold the prompt back. The verdict can never arrive:// the shortcut below needs the feature-flag payload, which an ad blocker can drop entirely, and a// detector whose endpoint keeps erroring only settles after enough consecutive failures. Both leave@@ -25,7 +31,14 @@ const MOUNT_CHECK_JITTER_MS = 3 * 1000const WIZARD_VERDICT_DEADLINE_MS = 15 * 1000/** How the self-driving onboarding presents itself over the inbox. */-export type InboxOnboardingMode = 'takeover' | 'banner' | 'none'+export type InboxOnboardingMode = 'takeover' | 'banner' | 'none' | 'pending'++/** What the inbox rendered last time the verdict settled: the welcome takeover, or the normal+ * inbox (with or without the banner). Cached per team so the next visit shows it instantly. */+export type InboxSettledUiState = 'takeover' | 'inbox'++/** localStorage key for the per-team last-settled UI state (see `lastSettledUiStateByTeam`). */+export const INBOX_LAST_UI_STATE_STORAGE_KEY = 'inbox-onboarding-last-ui-state'/*** Why the onboarding is not showing. `null` whenever it is.@@ -40,6 +53,7 @@ export type InboxOnboardingSuppressionReason =| 'setup_loading'| 'already_set_up'| 'counts_loading'+ | 'refetching'| 'banner_dismissed'| null@@ -101,15 +115,24 @@ export interface OnboardingModeInputs {/** The wizard detector has actually checked, so `isWizardRunning === false` is a verdict rather* than "nobody asked yet". */isWizardStateResolved: boolean+ /** A config/count refetch is in flight, so the loaded values may be about to change (e.g. the+ * wizard just finished, or the user returned to the tab). */+ isRefetching: boolean}/*** Pure decision for how (if at all) the onboarding shows.*- * `'none'` is the default: render the normal inbox, which shows its own list skeleton while loading.- * We only switch to a takeover/banner once we're *confident* self-driving isn't set up – so we stay- * on `'none'` (the familiar skeleton) until both the config check and, if needed, the report counts- * have settled. This avoids flashing the takeover/banner before we know the verdict.+ * While the takeover is still on the table but the inputs haven't settled, the verdict is+ * `'pending'`: the scene renders a neutral skeleton with no tab bar, so the user never sees the+ * normal inbox flash in and get replaced by the welcome takeover (or vice versa). As soon as any+ * settled input rules the takeover out – self-driving is set up, a wizard run is in flight, or+ * work already exists (the banner is additive, not a replacement) – the normal inbox shows+ * immediately without waiting on the rest.+ *+ * Each outcome carries the input it is waiting on (or the reason it is withheld), so telemetry can+ * tell a prompt nobody needed from one that never resolved. `resolveWizardState` bounds the one+ * wait that can hang forever.*/export function computeOnboardingDecision({isSetupLoaded,@@ -119,40 +142,75 @@ export function computeOnboardingDecision({bannerDismissed,isWizardRunning,isWizardStateResolved,+ isRefetching,}: OnboardingModeInputs): InboxOnboardingDecision {// A run in flight is setup in progress: sources and scouts land as it goes, so telling the user// to go and run the wizard would contradict the progress widget already showing it running.if (isWizardRunning) {return { mode: 'none', reason: 'wizard_running' }}- // The config and count loaders settle in under a second; the wizard detector answers on its own- // polling cadence. Until it has, "not running" is absence of evidence, and acting on it here is- // exactly the wrong-takeover case for someone landing in the inbox mid-run — so hold the normal- // inbox, same as the other unsettled inputs below. `resolveWizardState` bounds that wait.- if (!isWizardStateResolved) {- return { mode: 'none', reason: 'wizard_state_unknown' }+ // Set-up users go straight to their inbox the moment the config check lands – neither the+ // wizard detector nor the report counts could flip their verdict to an onboarding.+ if (isSetupLoaded && isSelfDrivingSetUp) {+ return { mode: 'none', reason: 'already_set_up' }}- // Until the config check resolves we don't know the verdict – stay on the normal inbox skeleton.+ // Work already in the inbox rules the takeover out: the only remaining outcomes (banner /+ // none) both render the normal inbox, so show it now rather than holding a skeleton. The+ // non-blocking banner joins once the config and wizard checks settle.+ if (areCountsResolved && hasExistingWork) {+ if (!isSetupLoaded) {+ return { mode: 'none', reason: 'setup_loading' }+ }+ if (!isWizardStateResolved) {+ return { mode: 'none', reason: 'wizard_state_unknown' }+ }+ return bannerDismissed ? { mode: 'none', reason: 'banner_dismissed' } : { mode: 'banner', reason: null }+ }+ // The takeover is still possible. Until every input has settled – configs (is anything+ // watching?), counts (is there work to keep?), and the wizard detector (is a run in flight?) –+ // committing to either UI risks flashing it and swapping it out, so hold the neutral skeleton.+ // A refetch in flight means the loaded values may be stale in the same way (the wizard just+ // finished, or the user returned to the tab), so it holds the takeover back too.if (!isSetupLoaded) {- return { mode: 'none', reason: 'setup_loading' }+ return { mode: 'pending', reason: 'setup_loading' }}- // Set-up users go straight to their inbox – no need to wait on the report counts.- if (isSelfDrivingSetUp) {- return { mode: 'none', reason: 'already_set_up' }+ if (!isWizardStateResolved) {+ return { mode: 'pending', reason: 'wizard_state_unknown' }}- // Not set up: the report counts decide takeover (empty inbox) vs. banner (work already exists).- // Keep the inbox skeleton until they settle, rather than guessing.if (!areCountsResolved) {- return { mode: 'none', reason: 'counts_loading' }+ return { mode: 'pending', reason: 'counts_loading' }}- if (hasExistingWork) {- return bannerDismissed ? { mode: 'none', reason: 'banner_dismissed' } : { mode: 'banner', reason: null }+ if (isRefetching) {+ return { mode: 'pending', reason: 'refetching' }}return { mode: 'takeover', reason: null }}+/**+ * What the inbox should render right now: the resolved verdict once it has settled, else the UI+ * the same team saw last time (the verdict is almost always the same visit to visit, and if it+ * isn't, the state genuinely changed and a swap is honest). The neutral skeleton is left only+ * for a team's very first visit, when there's no history to lean on.+ */+export function resolveDisplayMode(+ resolvedMode: InboxOnboardingMode,+ lastSettledUiState: InboxSettledUiState | null+): InboxOnboardingMode {+ if (resolvedMode !== 'pending') {+ return resolvedMode+ }+ if (lastSettledUiState === 'takeover') {+ return 'takeover'+ }+ if (lastSettledUiState === 'inbox') {+ return 'none'+ }+ return 'pending'+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface inboxOnboardingLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogicreceivedFeatureFlags: boolean // featureFlagLogicpullsCount: number | null // reportListLogicpullsCountLoading: boolean // reportListLogic@@ -160,26 +218,38 @@ export interface inboxOnboardingLogicValues {reportsCountLoading: boolean // reportListLogicenabledScoutsCount: number // scoutFleetLogicscoutConfigs: SignalScoutConfig[] | null // scoutFleetLogic+ scoutConfigsLoading: boolean // scoutFleetLogicenabledSourcesCount: number // signalSourcesLogichasEmittingScanner: boolean | null // signalSourcesLogicsourceConfigs: SignalSourceConfig[] | null // signalSourcesLogic+ sourceConfigsLoading: boolean // signalSourcesLogic+ currentTeamId: number | null // teamLogicactiveWorkflowId: string | null // wizardActiveSessionDetectorLogichasResolvedSessionState: boolean // wizardActiveSessionDetectorLogicwatchedWorkflows: string[] // wizardActiveSessionDetectorLogicareCountsResolved: booleanbannerDismissed: booleanhasExistingWork: boolean+ isRefetching: booleanisSelfDrivingSetUp: booleanisSetupLoaded: boolean+ isWelcomeRedesign: booleanisWizardRunning: booleanisWizardStateResolved: boolean+ lastSettledUiState: InboxSettledUiState | null+ lastSettledUiStateByTeam: Record<string, InboxSettledUiState>onboardingDecision: InboxOnboardingDecisiononboardingMode: InboxOnboardingMode+ resolvedOnboardingMode: InboxOnboardingModeverdictWaitExpired: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface inboxOnboardingLogicActions {+ loadPullsCount: () => any // reportListLogic+ loadReportsCount: () => any // reportListLogic+ loadScoutConfigs: () => any // scoutFleetLogic+ loadSourceConfigs: () => any // signalSourcesLogiccheckWizardSession: () => {value: true} // wizardActiveSessionDetectorLogic@@ -189,6 +259,16 @@ export interface inboxOnboardingLogicActions {expireWizardVerdictWait: () => {value: true}+ refreshSetupState: () => {+ value: true+ }+ setLastSettledUiState: (+ teamId: number,+ uiState: InboxSettledUiState+ ) => {+ teamId: number+ uiState: InboxSettledUiState+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -214,6 +294,12 @@ export interface inboxOnboardingLogicMeta {receivedFeatureFlags: boolean,verdictWaitExpired: boolean) => boolean+ isRefetching: (+ sourceConfigsLoading: boolean,+ scoutConfigsLoading: boolean,+ pullsCountLoading: boolean,+ reportsCountLoading: boolean+ ) => booleanonboardingDecision: (isSetupLoaded: boolean,isSelfDrivingSetUp: boolean,@@ -221,9 +307,19 @@ export interface inboxOnboardingLogicMeta {hasExistingWork: boolean,bannerDismissed: boolean,isWizardRunning: boolean,- isWizardStateResolved: boolean+ isWizardStateResolved: boolean,+ isRefetching: boolean) => InboxOnboardingDecision- onboardingMode: (onboardingDecision: InboxOnboardingDecision) => InboxOnboardingMode+ resolvedOnboardingMode: (onboardingDecision: InboxOnboardingDecision) => InboxOnboardingMode+ lastSettledUiState: (+ lastSettledUiStateByTeam: Record<string, InboxSettledUiState>,+ currentTeamId: number | null+ ) => InboxSettledUiState | null+ onboardingMode: (+ resolvedOnboardingMode: InboxOnboardingMode,+ lastSettledUiState: InboxSettledUiState | null+ ) => InboxOnboardingMode+ isWelcomeRedesign: (onboardingMode: InboxOnboardingMode, featureFlags: FeatureFlagsSet) => boolean}}@@ -255,9 +351,9 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([connect(() => ({values: [signalSourcesLogic,- ['sourceConfigs', 'enabledSourcesCount', 'hasEmittingScanner'],+ ['sourceConfigs', 'sourceConfigsLoading', 'enabledSourcesCount', 'hasEmittingScanner'],scoutFleetLogic,- ['scoutConfigs', 'enabledCount as enabledScoutsCount'],+ ['scoutConfigs', 'scoutConfigsLoading', 'enabledCount as enabledScoutsCount'],// Mount the pulls + reports count loaders directly (cheap limit=1 each) so we know// whether there's existing work even during a takeover, when the tab bar that usually// mounts these isn't rendered. Same keyed instances the tab bar uses – no double-fetch.@@ -269,16 +365,42 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([wizardActiveSessionDetectorLogic,['activeWorkflowId', 'hasResolvedSessionState', 'watchedWorkflows'],featureFlagLogic,- ['receivedFeatureFlags'],+ ['receivedFeatureFlags', 'featureFlags'],+ teamLogic,+ ['currentTeamId'],+ ],+ actions: [+ wizardActiveSessionDetectorLogic,+ ['check as checkWizardSession'],+ signalSourcesLogic,+ ['loadSourceConfigs'],+ scoutFleetLogic,+ ['loadScoutConfigs'],+ reportListLogic({ tabKey: 'pulls', listParams: INBOX_FLAT_TAB_LIST_PARAMS.pulls }),+ ['loadCount as loadPullsCount'],+ reportListLogic({ tabKey: 'reports', listParams: INBOX_FLAT_TAB_LIST_PARAMS.reports }),+ ['loadCount as loadReportsCount'],],- actions: [wizardActiveSessionDetectorLogic, ['check as checkWizardSession']],})),actions({dismissBanner: true,expireWizardVerdictWait: true,+ setLastSettledUiState: (teamId: number, uiState: InboxSettledUiState) => ({ teamId, uiState }),+ refreshSetupState: true,}),+ listeners(({ actions }) => ({+ // Re-pull everything the verdict is computed from. Fired when the wizard run ends and when+ // the user returns to a tab whose verdict still says "not set up".+ refreshSetupState: () => {+ actions.loadSourceConfigs()+ actions.loadScoutConfigs()+ actions.loadPullsCount()+ actions.loadReportsCount()+ },+ })),+reducers({bannerDismissed: [false,@@ -292,6 +414,16 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([expireWizardVerdictWait: () => true,},],+ // Keyed by team: the verdict is per team, and a cached verdict from another team must not+ // leak into this one's first paint after a project switch.+ lastSettledUiStateByTeam: [+ {} as Record<string, InboxSettledUiState>,+ { persist: true, storageKey: INBOX_LAST_UI_STATE_STORAGE_KEY },+ {+ setLastSettledUiState: (state, { teamId, uiState }) =>+ state[teamId] === uiState ? state : { ...state, [teamId]: uiState },+ },+ ],}),selectors({@@ -346,6 +478,20 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([verdictWaitExpired,}),],+ // A config or count request is in flight. While true, the verdict must not commit to the+ // takeover: the wizard may just have finished, and the loaded values are about to change.+ isRefetching: [+ (s) => [s.sourceConfigsLoading, s.scoutConfigsLoading, s.pullsCountLoading, s.reportsCountLoading],+ (+ sourceConfigsLoading: boolean,+ scoutConfigsLoading: boolean,+ pullsCountLoading: boolean,+ reportsCountLoading: boolean+ ): boolean => sourceConfigsLoading || scoutConfigsLoading || pullsCountLoading || reportsCountLoading,+ ],+ // The verdict from live inputs alone, with the input it is still waiting on. Kept separate+ // from `onboardingMode` so neither the cache writer nor the telemetry below ever reports a+ // guess that itself came from the cache.onboardingDecision: [(s) => [s.isSetupLoaded,@@ -355,6 +501,7 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([s.bannerDismissed,s.isWizardRunning,s.isWizardStateResolved,+ s.isRefetching,],(isSetupLoaded: boolean,@@ -363,7 +510,8 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([hasExistingWork: boolean,bannerDismissed: boolean,isWizardRunning: boolean,- isWizardStateResolved: boolean+ isWizardStateResolved: boolean,+ isRefetching: boolean): InboxOnboardingDecision =>computeOnboardingDecision({isSetupLoaded,@@ -373,17 +521,45 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([bannerDismissed,isWizardRunning,isWizardStateResolved,+ isRefetching,}),],- onboardingMode: [+ resolvedOnboardingMode: [(s) => [s.onboardingDecision],(onboardingDecision: InboxOnboardingDecision): InboxOnboardingMode => onboardingDecision.mode,],+ lastSettledUiState: [+ (s) => [s.lastSettledUiStateByTeam, s.currentTeamId],+ (+ lastSettledUiStateByTeam: Record<string, InboxSettledUiState>,+ currentTeamId: number | null+ ): InboxSettledUiState | null =>+ currentTeamId != null ? (lastSettledUiStateByTeam[currentTeamId] ?? null) : null,+ ],+ // What the scene renders: while the verdict is settling, fall back to what this team saw+ // last visit instead of a skeleton, so the loading state only ever shows on a first visit.+ onboardingMode: [+ (s) => [s.resolvedOnboardingMode, s.lastSettledUiState],+ (+ resolvedOnboardingMode: InboxOnboardingMode,+ lastSettledUiState: InboxSettledUiState | null+ ): InboxOnboardingMode => resolveDisplayMode(resolvedOnboardingMode, lastSettledUiState),+ ],+ // The featureFlags proxy fires the `$feature_flag_called` exposure the moment a flag is+ // read, so the read is guarded on the takeover actually showing: exposure has to mean+ // "this user saw the welcome page", or the experiment dilutes with users who never did.+ // Keyed off the display mode deliberately – a cache-predicted takeover still shows the+ // welcome page, so the exposure is real.+ isWelcomeRedesign: [+ (s) => [s.onboardingMode, s.featureFlags],+ (onboardingMode: InboxOnboardingMode, featureFlags: FeatureFlagsSet): boolean =>+ onboardingMode === 'takeover' && featureFlags[FEATURE_FLAGS.INBOX_WELCOME_REDESIGN] === 'test',+ ],}),- subscriptions(({ cache }) => ({+ subscriptions(({ actions, values, cache }) => ({// One event per distinct verdict per mount. The decision settles through several- // intermediate `none`s as its inputs load, so reporting every transition would drown the+ // intermediate holds as its inputs load, so reporting every transition would drown the// real answer; deduping on the pair keeps the loading states as the trail that explains it.onboardingDecision: (decision: InboxOnboardingDecision) => {const key = `${decision.mode}:${decision.reason ?? 'shown'}`@@ -393,6 +569,24 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([cache.reportedDecisions = (cache.reportedDecisions ?? new Set<string>()).add(key)captureInboxOnboardingDecided({ mode: decision.mode, reason: decision.reason })},+ // Remember what this team's verdict rendered as, so the next visit can paint it+ // immediately while the checks re-run. Watches the resolved mode (not the display mode)+ // so the cache is only ever written from settled inputs.+ resolvedOnboardingMode: (resolvedMode: InboxOnboardingMode) => {+ const teamId = values.currentTeamId+ if (resolvedMode === 'pending' || teamId == null) {+ return+ }+ actions.setLastSettledUiState(teamId, resolvedMode === 'takeover' ? 'takeover' : 'inbox')+ },+ // A wizard run ending in this tab means sources and scouts probably just landed: re-pull+ // them so the verdict flips to the real inbox without a page reload. `isRefetching` holds+ // the takeover back until the fresh data arrives.+ isWizardRunning: (isWizardRunning: boolean, previousIsWizardRunning: boolean | undefined) => {+ if (previousIsWizardRunning === true && !isWizardRunning) {+ actions.refreshSetupState()+ }+ },})),// The detector's own first poll is jittered up to 30s to spread deploy-reload herds; someone@@ -405,6 +599,26 @@ export const inboxOnboardingLogic = kea<inboxOnboardingLogicType>([// over a few seconds instead of arriving as one spike, while a user coming from onboarding// still gets their answer far inside the 30s window.afterMount(({ actions, values, cache }) => {+ // Refetch on return to the tab, but only while the verdict still says "not set up": that+ // is the copy-the-command flow (terminal → wizard → back to this tab), where the configs+ // and counts loaded at mount are exactly the stale ones. Set-up users are excluded, so an+ // inbox parked in a background tab doesn't re-pull four endpoints on every focus. The+ // setup re-runs on every `visibilitychange → visible`; the first run at mount is skipped+ // (the loaders fetch on their own mount) and alt-tab flapping is throttled.+ cache.disposables.add(() => {+ if (!cache.visibilityRefetchArmed) {+ cache.visibilityRefetchArmed = true+ return () => {}+ }+ const now = Date.now()+ const throttled = now - (cache.lastVisibilityRefetch ?? 0) < VISIBILITY_REFETCH_THROTTLE_MS+ if (!throttled && !(values.isSetupLoaded && values.isSelfDrivingSetUp)) {+ cache.lastVisibilityRefetch = now+ actions.refreshSetupState()+ }+ return () => {}+ }, 'refetch-on-return')+if (values.isWizardStateResolved) {return}