Skip to content

: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.

feat(replay_vision): show a loading bar while the goal draft generates (#90934)

Kim Svatos Duganc607fb3b0ca1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 41cd4c5e9aeb..1a7a8609ad5b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8192,6 +8192,10 @@ snapshots:
hash: v1.k794b7964.4ef60f727ace235099b7180e0b8e6e96a81e3626ce2ccae46f74c29508f85c15.Mp6FnYUKmqMQBB2sni9IukHvqlxQSXt5l1F91H6F8Zg
scenes-app-replay-vision--scanner-editor-goal-overview--light:
hash: v1.k794b7964.2820672a63528051df5cbb805e984c645eaf35a5f3437b59eaa70e90f1a5f118.S63d60T6vwVkop1Z_-KvK0rTZiRymODAiDvjaaJD7Do
+ scenes-app-replay-vision--scanner-editor-goal-overview-loading--dark:
+ hash: v1.k794b7964.fe62cd969ce6bd55970c1e9cf78fe6de964c46ec4fc544b7a7bcf40aa4b16011.sh_jB5tLnqum3YbI99V6GH8nWno2Ll-Mkram9K8qHLk
+ scenes-app-replay-vision--scanner-editor-goal-overview-loading--light:
+ hash: v1.k794b7964.cb882e5afca7dc0bf22f4d9341d7979f06500f25120c5020a1f797f6fa578486.davCiLjyEwLLRw5kh0JjVAtrghRONwHitTruNrTpoZ8
scenes-app-replay-vision--scanner-editor-triggers--dark:
hash: v1.k794b7964.5bc5dc77d7346163d92585657a949d38938bdbabf11a2a0341bc3a6b9c980c80.AL7y75QUTSwtUvG6XKJvD4CPhbEXC4TmNPkxG_57CQ4
scenes-app-replay-vision--scanner-editor-triggers--light:
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
index e1fa196ce72a..679f11350834 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -753,3 +753,21 @@ export const ScannerEditorGoalOverview: StoryObj = {
},
],
}
+
+// The overview while the draft is still generating: the loading bar and skeleton the user sees
+// right after submitting the two questions.
+export const ScannerEditorGoalOverviewLoading: StoryObj = {
+ parameters: {
+ pageUrl: urls.replayVisionScannerOverview('new'),
+ featureFlags: { [FEATURE_FLAGS.VISION_GOAL_BASED_CREATION_FLOW]: 'test' },
+ },
+ decorators: [
+ (StoryFn) => {
+ const logic = replayScannerLogic({ id: 'new' })
+ logic.mount()
+ // Hold the draft loader open so the overview renders its skeleton instead of a result.
+ logic.actions.draftScannerFromGoal('find out where people give up in billing', 5000)
+ return <StoryFn />
+ },
+ ],
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx
index f23e410d8e38..2293d4309ecb 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx
@@ -1,10 +1,13 @@
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
-import { useEffect } from 'react'
+import { useEffect, useState } from 'react'
+import { TextMorph } from 'torph/react'
import { IconInfo } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonSkeleton, LemonSnack, LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'
+import { LoadingBar } from 'lib/lemon-ui/LoadingBar'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
import { pluralize } from 'lib/utils/strings'
import { urls } from 'scenes/urls'
@@ -295,10 +298,58 @@ export function ScannerGoalOverview({ scannerId }: { scannerId: string }): JSX.E
)
}
+// Drafting a scanner runs a model call that takes several seconds, so the wait needs to read as
+// work in progress. These rotate above the skeleton, in the same spirit as the insights loader.
+const DRAFT_LOADING_MESSAGES = [
+ 'Reading your goal…',
+ 'Snuffling through your pages for a match…',
+ 'Counting hedgehogs and recordings…',
+ 'Weighing the budget against the traffic…',
+ 'Picking a model for the job…',
+ 'Drafting the scanner…',
+]
+
+const MESSAGE_INTERVAL_MS = 2500
+
+/** The rotating orange loading bar shown while the draft generates. */
+function DraftLoadingBar(): JSX.Element {
+ const frozen = inStorybook() || inStorybookTestRunner()
+ const [messageIndex, setMessageIndex] = useState(() =>
+ frozen ? 0 : Math.floor(Math.random() * DRAFT_LOADING_MESSAGES.length)
+ )
+
+ useEffect(() => {
+ // A frozen index keeps every Storybook snapshot identical.
+ if (frozen) {
+ return
+ }
+ const interval = setInterval(() => {
+ setMessageIndex((current) => {
+ let next = Math.floor(Math.random() * DRAFT_LOADING_MESSAGES.length)
+ if (next === current) {
+ next = (next + 1) % DRAFT_LOADING_MESSAGES.length
+ }
+ return next
+ })
+ }, MESSAGE_INTERVAL_MS)
+ return () => clearInterval(interval)
+ }, [frozen])
+
+ return (
+ <div className="flex flex-col items-center gap-1 py-2">
+ <TextMorph as="span" className="text-sm font-medium text-secondary">
+ {DRAFT_LOADING_MESSAGES[messageIndex]}
+ </TextMorph>
+ <LoadingBar />
+ </div>
+ )
+}
+
/** The overview's shape while the draft is still generating, so navigating there reads as progress. */
function ScannerGoalOverviewSkeleton(): JSX.Element {
return (
<div className="flex flex-col gap-3">
+ <DraftLoadingBar />
{['What it understood', 'Name', 'What it will ask', 'Eligible recordings', 'Sampling and budget'].map(
(label) => (
<div key={label} className="bg-bg-light border rounded-lg p-4 space-y-2">