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.

fix(replay-vision): name scanner scouts per scanner and fix their report surfaces (#87665)

Tue Haulund2a32d49e8c69
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutCard.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutCard.tsx
index c8c1eb9254dc..c0068af38123 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutCard.tsx
@@ -59,6 +59,7 @@ export function ScannerScoutCard({
scoutConfigs,
scoutConfigsLoading,
scoutReportsLoading,
+ scoutReportsFailed,
scoutConfigsForScanner,
latestReportRow,
expanded,
@@ -67,7 +68,7 @@ export function ScannerScoutCard({
manualRunScoutIds,
enrolled,
} = useValues(logic)
- const { runScoutNow, loadScoutConfigs, toggleExpanded } = useActions(logic)
+ const { runScoutNow, loadScoutConfigs, loadScoutReports, toggleExpanded } = useActions(logic)
const { ref: digestRef, height: digestHeight } = useResizeObserver()
const overflows = (digestHeight ?? 0) > DIGEST_CLIP_PX
const clipped = overflows && !expanded
@@ -164,6 +165,19 @@ export function ScannerScoutCard({
// land before the reports do, so without this the card states that verdict on every
// cold load, then replaces it once the reports resolve.
<LemonSkeleton className="h-16 w-full" />
+ ) : !latestReportRow && scoutReportsFailed ? (
+ // A failed load is not a quiet scanner, and Run now below spends credits.
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <span className="text-sm text-muted">Couldn't load this scanner's reports.</span>
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => loadScoutReports()}
+ data-attr="vision-scanner-scout-reports-retry"
+ >
+ Try again
+ </LemonButton>
+ </div>
) : latestReportRow ? (
<>
{/* The surface stays on the outer element: masking it too would fade the panel's
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.scss b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.scss
new file mode 100644
index 000000000000..50cb91780419
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.scss
@@ -0,0 +1,23 @@
+// A digest with a chart is tall enough to scroll, and the app-wide thumb (`--trace-3000` on a
+// surface-colored track) is near-invisible against the modal, so the content reads as clipped
+// rather than scrollable. Repaint it with the scroll-thumb token, which is defined for both
+// themes. Scrollbar pseudo-elements have no Tailwind equivalent, which is why this is SCSS.
+.ScannerScoutReportModal {
+ .LemonModal__content {
+ scrollbar-width: thin;
+ scrollbar-color: var(--color-bg-fill-scroll-thumb) transparent;
+
+ &::-webkit-scrollbar {
+ width: 0.5rem;
+ }
+
+ &::-webkit-scrollbar-track {
+ background: transparent;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background: var(--color-bg-fill-scroll-thumb);
+ border-radius: var(--radius);
+ }
+ }
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.tsx
index f4bce2d80361..c167e422255a 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutReportModal.tsx
@@ -1,3 +1,4 @@
+import './ScannerScoutReportModal.scss'
import './ScannerSummary.scss'
import { useActions, useValues } from 'kea'
@@ -11,6 +12,7 @@ import { urls } from 'scenes/urls'
import type { ReportChartApi } from 'products/signals/frontend/generated/api.schemas'
import { ReportChartCard } from 'products/signals/frontend/inbox/components/detail/ReportChart'
+import { resolveChartPlacements } from 'products/signals/frontend/inbox/utils/chartPlacement'
import { prettifyScoutSkillName } from 'products/signals/frontend/inbox/utils/scoutRunsWindow'
import { scannerScoutLogic } from '../scannerScoutLogic'
@@ -32,12 +34,31 @@ export function ScannerScoutReportModal({
return null
}
+ const charts = (openedReport?.charts ?? []) as ReportChartApi[]
+ const summary = openedReport?.summary || openedReport?.title || ''
+ // The same parse the inbox uses, rather than a regex over the markdown: a reference inside a
+ // code span or a table cell is not a placement, and getting that wrong draws a chart twice or
+ // not at all.
+ const placements = resolveChartPlacements(
+ summary,
+ charts.map((chart) => chart.chart_id)
+ )
+ const byId = new Map(charts.map((chart) => [chart.chart_id, chart]))
+ const renderChartRef = (chartId: string, sourceOffset?: number): JSX.Element | null => {
+ const chart = byId.get(chartId)
+ return sourceOffset !== undefined && placements.inlineByOffset.get(sourceOffset) === chartId && chart ? (
+ <ReportChartCard chart={chart} />
+ ) : null
+ }
+ const trailingCharts = charts.filter((chart) => !placements.inlineIds.has(chart.chart_id))
+
const loading = openedReportLoading || openedReport?.report_id !== openReportId
return (
<LemonModal
isOpen
onClose={closeReport}
+ className="ScannerScoutReportModal"
width={720}
title={loading ? 'Report' : openedReport?.title || 'Untitled report'}
description={
@@ -68,15 +89,17 @@ export function ScannerScoutReportModal({
<div className="rounded bg-surface-secondary px-3 py-2">
{/* Agent-written content derived from recordings: render non-PostHog images
as links, not auto-fetched <img>s. */}
- <LemonMarkdown className="ScannerSummaryMarkdown text-sm" disableImages>
- {openedReport?.summary || openedReport?.title || ''}
+ <LemonMarkdown
+ className="ScannerSummaryMarkdown text-sm [&_[data-attr=report-chart]]:my-4"
+ disableImages
+ renderChartRef={renderChartRef}
+ >
+ {summary}
</LemonMarkdown>
</div>
- {/* Rendered after the body rather than placed inline: the summary's
- `[label](chart:<id>)` links are what the inbox uses to position them, and
- that placement machinery lives with the inbox's own report view. */}
- {(openedReport?.charts ?? []).map((chart) => (
- <ReportChartCard key={chart.chart_id} chart={chart as ReportChartApi} />
+ {/* Whatever the prose never referenced. The inbox does the same. */}
+ {trailingCharts.map((chart) => (
+ <ReportChartCard key={chart.chart_id} chart={chart} />
))}
</div>
)}
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutRow.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutRow.tsx
index 56cfe8390f7f..42a37b446518 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerScoutRow.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerScoutRow.tsx
@@ -4,6 +4,7 @@ import { IconChevronRight, IconEye, IconGear, IconTrash } from '@posthog/icons'
import { LemonButton, LemonDialog, LemonSwitch, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
+import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { LemonTable } from 'lib/lemon-ui/LemonTable'
import { cn } from 'lib/utils/css-classes'
import { teamLogic } from 'scenes/teamLogic'
@@ -28,8 +29,25 @@ export function ScannerScoutRow({
config: SignalScoutConfigApi
}): JSX.Element {
const logic = scannerScoutLogic({ scannerId, scannerName })
- const { updatingScoutIds, deletingScoutIds, expandedSkillNames, reportsBySkill } = useValues(logic)
- const { openScoutSettings, updateScoutConfig, deleteScout, toggleScoutExpanded, openReport } = useActions(logic)
+ const {
+ updatingScoutIds,
+ deletingScoutIds,
+ manualRunScoutIds,
+ expandedSkillNames,
+ reportsBySkill,
+ scoutReportsLoading,
+ scoutReportsFailed,
+ rollups,
+ } = useValues(logic)
+ const {
+ openScoutSettings,
+ updateScoutConfig,
+ deleteScout,
+ toggleScoutExpanded,
+ openReport,
+ runScoutNow,
+ loadScoutReports,
+ } = useActions(logic)
const { currentTeam } = useValues(teamLogic)
const { scanner } = useValues(replayScannerLogic({ id: scannerId }))
// Deleting a scout or switching it off changes what this scanner watches.
@@ -37,6 +55,11 @@ export function ScannerScoutRow({
const updating = updatingScoutIds.includes(config.id)
const expanded = expandedSkillNames.includes(config.skill_name)
const reports = reportsBySkill.get(config.skill_name) ?? []
+ // The request returns as soon as the workflow is dispatched, so the button's own loading state
+ // clears in a second while the run takes minutes. Without this the button looks ready again and
+ // the next click is refused by the backend's in-flight check with a bare 409.
+ const runDisabledReason =
+ editDisabledReason ?? (rollups.get(config.skill_name)?.runningRun ? 'This scout is already running' : undefined)
const timezone = currentTeam?.timezone ?? 'UTC'
const now = new Date()
@@ -116,7 +139,45 @@ export function ScannerScoutRow({
</Tooltip>
</div>
</div>
- {expanded && (
+ {expanded && scoutReportsLoading && reports.length === 0 && (
+ <div className="border-t border-primary px-4 py-2 pl-12">
+ <LemonSkeleton className="h-8 w-full" />
+ </div>
+ )}
+ {expanded && !scoutReportsLoading && scoutReportsFailed && (
+ <div className="flex flex-wrap items-center justify-between gap-2 border-t border-primary px-4 py-2 pl-12">
+ <span className="text-sm text-muted">Couldn't load this scout's reports.</span>
+ <LemonButton
+ size="small"
+ type="secondary"
+ onClick={() => loadScoutReports()}
+ data-attr="vision-scout-row-reports-retry"
+ >
+ Try again
+ </LemonButton>
+ </div>
+ )}
+ {/* "No reports filed yet" is a verdict about reports that arrived, and Run now spends
+ credits, so neither belongs on a roster whose reports failed to load or have not
+ loaded: both leave the list empty, and neither means the scout filed nothing. */}
+ {expanded && !scoutReportsLoading && !scoutReportsFailed && reports.length === 0 && (
+ <div className="flex flex-wrap items-center justify-between gap-2 border-t border-primary px-4 py-2 pl-12">
+ <span className="text-sm text-muted">
+ No reports filed yet. The first arrives after the next scheduled run.
+ </span>
+ <LemonButton
+ size="small"
+ type="secondary"
+ loading={manualRunScoutIds.includes(config.id)}
+ disabledReason={runDisabledReason}
+ onClick={() => runScoutNow(config.id)}
+ data-attr="vision-scout-row-run-now"
+ >
+ Run now
+ </LemonButton>
+ </div>
+ )}
+ {expanded && !scoutReportsLoading && !scoutReportsFailed && reports.length > 0 && (
<div className="border-t border-primary px-4 py-2 pl-12">
{/* Same shape as the scanner's observation history, so the two lists read alike. */}
<LemonTable
@@ -125,7 +186,6 @@ export function ScannerScoutRow({
size="small"
rowKey="report_id"
dataSource={reports}
- emptyState="No reports filed yet."
columns={[
{
title: '',
diff --git a/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts b/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts
index 795b10c741f3..1bf181f1e0e3 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts
@@ -13,12 +13,29 @@ describe('scannerScout', () => {
const scannerId = '0198B7C4-1111-2222-3333-444455556666'
it('slugifies user names into valid, unique skill names and humanizes them back', () => {
- const name = scoutNameToSkillName('Checkout friction (weekly)', [])
- expect(name).toBe('signals-scout-checkout-friction-weekly')
+ const name = scoutNameToSkillName('Checkout friction (weekly)', 'Rage clicks', [])
+ expect(name).toBe('signals-scout-rage-clicks-checkout-friction-weekly')
expect(name).toMatch(/^signals-scout-[a-z0-9-]+$/)
- expect(scoutNameToSkillName('Checkout friction (weekly)', [name])).toBe(`${name}-2`)
- expect(scoutNameToSkillName('', [])).toBe('signals-scout-digest')
- expect(scoutNameToSkillName('x'.repeat(100), []).length).toBeLessThanOrEqual(64)
+ expect(scoutNameToSkillName('Checkout friction (weekly)', 'Rage clicks', [name])).toBe(`${name}-2`)
+ expect(scoutNameToSkillName('', 'Rage clicks', [])).toBe('signals-scout-rage-clicks-digest')
+ expect(scoutNameToSkillName('x'.repeat(100), 'Rage clicks', []).length).toBeLessThanOrEqual(64)
+ })
+
+ it('numbers a scout per scanner rather than across the team', () => {
+ // Skill names are unique per team, so deriving one from the label alone made the second
+ // scanner's first daily digest `signals-scout-daily-digest-2`, and the number climbed with
+ // every scanner the team set up.
+ const first = scoutNameToSkillName('Daily digest', 'Checkout rage clicks', [])
+ const second = scoutNameToSkillName('Daily digest', 'Signup drop-off', [first])
+ expect(first).toBe('signals-scout-checkout-rage-clicks-daily-digest')
+ expect(second).toBe('signals-scout-signup-drop-off-daily-digest')
+ })
+
+ it('keeps the label whole when the scanner name would overrun the cap', () => {
+ // The label is what tells two scouts on one scanner apart; the scanner name is context.
+ const name = scoutNameToSkillName('new issue watch', 'x'.repeat(80), [])
+ expect(name.length).toBeLessThanOrEqual(64)
+ expect(name.endsWith('-new-issue-watch')).toBe(true)
})
it('claims only the scouts recorded as belonging to this scanner', () => {
diff --git a/products/replay_vision/frontend/replay_scanners/scannerScout.ts b/products/replay_vision/frontend/replay_scanners/scannerScout.ts
index d46b6e1dc046..49b990a9cf41 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerScout.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerScout.ts
@@ -19,18 +19,36 @@ export function isScannerScoutConfig(config: SignalScoutConfigApi, scannerId: st
// Every morning at 9:00 in the project timezone: the default cadence for every template.
export const SCANNER_SCOUT_CRON = '0 9 * * *'
+const SKILL_NAME_MAX_LENGTH = 64
+const SKILL_NAME_PREFIX = 'signals-scout-'
+// Room for the `-2`..`-99` a collision appends.
+const COLLISION_SUFFIX_LENGTH = 3
+
+function slugify(value: string): string {
+ return value
+ .toLowerCase()
+ .replace(/[\s_]+/g, '-')
+ .replace(/[^a-z0-9-]+/g, '')
+ .replace(/-{2,}/g, '-')
+ .replace(/^-|-$/g, '')
+}
+
/** Turns the name a person typed into a valid, unique `signals-scout-*` skill name, suffixing
- * while taken. */
-export function scoutNameToSkillName(label: string, takenNames: string[]): string {
- const slug =
- label
- .toLowerCase()
- .replace(/[\s_]+/g, '-')
- .replace(/[^a-z0-9-]+/g, '')
- .replace(/-{2,}/g, '-')
- .replace(/^-|-$/g, '') || 'digest'
- // Leave room for a collision suffix under the 64-char cap.
- const base = `signals-scout-${slug}`.slice(0, 61).replace(/-$/, '')
+ * while taken.
+ *
+ * The scanner's name goes in the slug because skill names are unique per team, not per scanner.
+ * Without it the second scanner's "Daily digest" becomes `signals-scout-daily-digest-2`, which
+ * reads as a second digest on that scanner rather than the first, and the numbering climbs with
+ * every scanner a team sets up. */
+export function scoutNameToSkillName(label: string, scannerName: string, takenNames: string[]): string {
+ const labelSlug = slugify(label) || 'digest'
+ // The label is what tells two scouts on one scanner apart, so it keeps its full length and the
+ // scanner name gives way when the two together would overrun the cap.
+ const room = SKILL_NAME_MAX_LENGTH - SKILL_NAME_PREFIX.length - COLLISION_SUFFIX_LENGTH - labelSlug.length - 1
+ const scannerSlug = slugify(scannerName).slice(0, Math.max(0, room)).replace(/-$/, '')
+ const base = `${SKILL_NAME_PREFIX}${[scannerSlug, labelSlug].filter(Boolean).join('-')}`
+ .slice(0, SKILL_NAME_MAX_LENGTH - COLLISION_SUFFIX_LENGTH)
+ .replace(/-$/, '')
const taken = new Set(takenNames)
if (!taken.has(base)) {
return base
@@ -111,7 +129,7 @@ ${focus.skip}
Every successful run leaves exactly one report for the date, and it is the digest: never one report per finding, and never a run that files nothing.
-Title it \`<your scout name> (<scanner name>): YYYY-MM-DD\`, dating it with the run's date in the project timezone. Your scout name is your own \`skill_name\` with the \`signals-scout-\` prefix dropped and dashes turned into spaces. Leading with it is what keeps two scouts on one scanner from writing the same title, which matters because of the next line.
+Title it \`<your scout name>: YYYY-MM-DD\`, dating it with the run's date in the project timezone. Your scout name is your own \`skill_name\` with the \`signals-scout-\` prefix dropped, dashes turned into spaces, and the first letter capitalized: \`signals-scout-checkout-trend-watch\` titles as \`Checkout trend watch: 2026-01-31\`. It already carries the scanner, so nothing else has to, and it is what keeps two scouts from writing the same title, which matters because of the next line.
Before writing, \`inbox-reports-list\` and compare titles exactly: if today's title already exists, \`scout-edit-report\` it rather than authoring a second one. Otherwise \`scout-emit-report\`. Never two reports for the same date, and never a second emit later in the same run — each one delivers again.
Write the report so it stands alone for a reader with no prior context:
@@ -119,10 +137,11 @@ Write the report so it stands alone for a reader with no prior context:
- Open with the takeaway in one line, then at most three bullets ordered by impact.
- Each bullet: what changed, with only the numbers needed to judge it; why it matters; the evidence-backed cause or best next investigation; and the specific next action.
- Ground every claim in observations you actually read, as real markdown links to the recording: \`[what it shows](/project/<project_id>/replay/<session_id>?t=<seconds>)\`, so the link opens on the moment being claimed. A bare \`[obs 3]\` is not a link and leaves the reader nowhere to go. Two or three per bullet is plenty; link the clearest cases, not every one.
+- Link what another scout already reported rather than restating it: \`[already documented](/project/<project_id>/inbox/<report_id>)\`, taking the id from \`inbox-reports-list\`. Several scouts watch this scanner and read the same window, so without the link one finding gets filed three times.
- Close with what you checked, and name anything you could not cover and why.
When nothing clears the bar, still file the report, with the verdict \`Nothing notable\` and a short coverage line ("42 observations across 30 sessions, distributions steady"). ${focus.priority}
-These are watcher findings: \`actionability=requires_human_input\`, \`repository=NO_REPO\`. After writing, keep a \`report:\` scratchpad pointer so the next run finds today's report instead of duplicating it.
+These are watcher findings: \`repository=NO_REPO\`. Set \`actionability\` by what the report asks of its reader. \`requires_human_input\` only when someone has to decide or act on what you found: it lands in the inbox awaiting input, and a digest that reports a quiet day does not belong in that queue. Otherwise \`immediately_actionable\`, which surfaces the report without asking anything of anyone. Never \`not_actionable\`: it suppresses the report, which empties the scanner's digest card and stops delivery, so a quiet day reads as a run that never happened. After writing, keep a \`report:\` scratchpad pointer so the next run finds today's report instead of duplicating it.
## Charts, when the shape is the point
diff --git a/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.test.ts b/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.test.ts
index ad7543fc4664..4e5f671c2154 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.test.ts
@@ -7,7 +7,11 @@ import { signalsScoutConfigDestroy } from 'products/signals/frontend/generated/a
import type { SignalScoutConfigApi } from 'products/signals/frontend/generated/api.schemas'
import { scoutFleetLogic } from 'products/signals/frontend/inbox/logics/scoutFleetLogic'
-import { visionScannersScoutReportsList, visionScannersScoutReportsRetrieve } from '../generated/api'
+import {
+ visionScannersScoutReportsList,
+ visionScannersScoutReportsRetrieve,
+ visionScannersScoutsCreate,
+} from '../generated/api'
import type { ScoutReportApi } from '../generated/api.schemas'
import { scannerScoutLogic } from './scannerScoutLogic'
@@ -22,6 +26,7 @@ const mockReportRetrieve = visionScannersScoutReportsRetrieve as jest.MockedFunc
typeof visionScannersScoutReportsRetrieve
>
const mockScoutConfigDestroy = signalsScoutConfigDestroy as jest.MockedFunction<typeof signalsScoutConfigDestroy>
+const mockScoutsCreate = visionScannersScoutsCreate as jest.MockedFunction<typeof visionScannersScoutsCreate>
const mockHogFunctionsRetrieve = hogFunctionsRetrieve as jest.MockedFunction<typeof hogFunctionsRetrieve>
const mockHogFunctionsPartialUpdate = hogFunctionsPartialUpdate as jest.MockedFunction<typeof hogFunctionsPartialUpdate>
@@ -175,4 +180,45 @@ describe('scannerScoutLogic', () => {
deleted: true,
})
})
+
+ it('renames and retries when another tab already took the name', async () => {
+ // Skill names are unique per team, so a scout created in one tab leaves this tab's roster
+ // stale and its derived name already taken.
+ await mountWithReports([])
+ mockScoutsCreate
+ .mockRejectedValueOnce(Object.assign(new Error('conflict'), { status: 409 }))
+ .mockResolvedValueOnce({ created: true, config: makeConfig() } as any)
+
+ logic.actions.createScout({
+ name: 'Daily digest',
+ body: 'Watch this scanner.',
+ cron: '0 9 * * *',
+ outputDestinations: {},
+ webhookUrl: '',
+ })
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(mockScoutsCreate).toHaveBeenCalledTimes(2)
+ const [firstName, secondName] = mockScoutsCreate.mock.calls.map((call) => (call[2] as any).name)
+ expect(firstName).toBe('signals-scout-rage-clicks-on-checkout-daily-digest')
+ expect(secondName).toBe('signals-scout-rage-clicks-on-checkout-daily-digest-2')
+ })
+
+ it('separates a failed report load from a scout that filed nothing', async () => {
+ // Both leave the list empty. Reading a failure as "filed nothing" offers Run now, and that
+ // click spends credits on a scout whose reports may already exist.
+ mockReportsList.mockRejectedValueOnce(new Error('boom'))
+ logic = scannerScoutLogic({ scannerId: SCANNER_ID, scannerName: 'Rage clicks on checkout' })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.scoutReports).toEqual([])
+ expect(logic.values.scoutReportsFailed).toBe(true)
+
+ mockReportsList.mockResolvedValueOnce([makeReport()])
+ logic.actions.loadScoutReports()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.scoutReportsFailed).toBe(false)
+ })
})
diff --git a/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.ts
index f380312bd784..bf9e1dd86230 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerScoutLogic.ts
@@ -125,6 +125,7 @@ export interface scannerScoutLogicValues {
scoutDelivery: ScoutDelivery | null
scoutDeliveryLoading: boolean
scoutReports: ScoutReportApi[]
+ scoutReportsFailed: boolean
scoutReportsLoading: boolean
settingsSaving: boolean
settingsSkillName: string | null
@@ -476,6 +477,17 @@ export const scannerScoutLogic = kea<scannerScoutLogicType>([
setScoutConfigsFailed: (_, { failed }) => failed,
},
],
+ // A failed load leaves `scoutReports` empty, which is the same shape as a scout that has
+ // filed nothing. Reading one as the other offers Run now for reports that may already
+ // exist, and that click spends credits.
+ scoutReportsFailed: [
+ false,
+ {
+ loadScoutReports: () => false,
+ loadScoutReportsSuccess: () => false,
+ loadScoutReportsFailure: () => true,
+ },
+ ],
// Which report the reader opened, if any.
openReportId: [
null as string | null,
@@ -739,15 +751,23 @@ export const scannerScoutLogic = kea<scannerScoutLogicType>([
actions.createScoutFinished()
return
}
- const skillName = scoutNameToSkillName(
- form.name,
- (values.scoutConfigs ?? []).map((config) => config.skill_name)
- )
- try {
- // Through Replay Vision rather than the Signals scout endpoint: this route
- // checks the caller may edit this scanner and records the scout as belonging to
- // it. The Signals endpoint cannot make that check, so it cannot record an owner.
- const created = await visionScannersScoutsCreate(
+ // Through Replay Vision rather than the Signals scout endpoint: this route checks
+ // the caller may edit this scanner and records the scout as belonging to it. The
+ // Signals endpoint cannot make that check, so it cannot record an owner.
+ //
+ // Names a previous attempt burned count as taken alongside the loaded roster: a
+ // 409 means the name exists on the team even though this tab's roster doesn't show
+ // it, either because another tab just created it or because a deleted scout still
+ // holds it. Feeding it back lets the next attempt pick the following suffix instead
+ // of asking the person to refresh.
+ const burnedNames: string[] = []
+ const create = async (): Promise<SignalScoutConfigApi> => {
+ const skillName = scoutNameToSkillName(form.name, props.scannerName, [
+ ...(values.scoutConfigs ?? []).map((config) => config.skill_name),
+ ...burnedNames,
+ ])
+ burnedNames.push(skillName)
+ const result = await visionScannersScoutsCreate(
String(teamLogic.values.currentProjectId),
props.scannerId,
scannerScoutCreatePayload(props.scannerName, {
@@ -757,6 +777,20 @@ export const scannerScoutLogic = kea<scannerScoutLogicType>([
outputDestinations: form.outputDestinations,
})
)
+ return result.config
+ }
+ try {
+ let config: SignalScoutConfigApi | null = null
+ for (let attempt = 0; attempt < 3 && !config; attempt++) {
+ try {
+ config = await create()
+ } catch (error: any) {
+ if (error?.status !== 409 || attempt === 2) {
+ throw error
+ }
+ }
+ }
+ const created = { config: config! }
const delivered = await reconcileDelivery(created.config, form)
lemonToast.success(
delivered
@@ -765,8 +799,7 @@ export const scannerScoutLogic = kea<scannerScoutLogicType>([
)
actions.loadScoutConfigs()
} catch (error: any) {
- // Deleting a scout archives its skill, and an archived skill still holds its
- // name, so a rebuilt name can collide with one no live config shows.
+ // Three names in a row were taken, which no longer happens by accident.
const conflict = error?.status === 409 || String(error?.detail ?? '').includes('name')
lemonToast.error(
conflict