: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 source scanners and signal types as sub-rows (#101084)
Chris Volzer303bd557bf2f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex ca8a50b4ccba..e6c535935df4 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -8704,6 +8704,10 @@ snapshots:hash: v1.k794b7964.b198639b11e758bab18165f81f9c4ea2ec330192a9294bbc5cedb9beb56f2b97.fGVGYbxR7jztc-SOpgqlsGa8M5KM4X80uwKSMGQbouwscenes-app-inbox-signalsourcespanel--arming-blocked--light:hash: v1.k794b7964.6d6d67eeca4a12800dd28be02715472cea370dd7b8e506c74f3722ae98020b31.PvhDuOrtKkLXP3VLift16E-kkVTKt7IEkpZokgyDK1A+ scenes-app-inbox-signalsourcespanel--error-tracking-expanded--dark:+ hash: v1.k794b7964.dc82368880ce9cfb9af10463c3eedc2d8f82c10f1b08cbf3a1aa0e5e81c8f451.Ub2OUFCM-lT41xG2Tw4Cean8K9t7Z5lkXn0zz5eUk5I+ scenes-app-inbox-signalsourcespanel--error-tracking-expanded--light:+ hash: v1.k794b7964.d0ddc20080343593ec1c5534e9dcc534b1997d666b8a57cb2b6153bd3f54af5e.pQ7BNYwTYZXS4dB4pp7samdK7BQudfkh7fEEW_EuM2Iscenes-app-inbox-signalsourcespanel--event-definitions-unavailable--dark:hash: v1.k794b7964.28d04b89b0825769c9c2cb617fcdb0c5a1371d398da50a8ebd8cdfdf0e01164a.P3b-y2FIqJvXfMBwXfYLteMApq02-T0AKwFRbwfIQa0scenes-app-inbox-signalsourcespanel--event-definitions-unavailable--light:@@ -8716,6 +8720,10 @@ snapshots:hash: v1.k794b7964.f897b9dd52eae8ad29d04c46ba689c27f47602692b2144b0e75a97ef34fae702.AfAhw2Op6ddRNOGiTznSP6Wn5nrrM4iwiHZ-AaR3IRoscenes-app-inbox-signalsourcespanel--playground--light:hash: v1.k794b7964.13df8c7b214cfd00e7eba5fea6da33f833ac202b7d3a2ebbadd331440bb9f97a.xHWi11Tx7CmT7o1dwJvUjX1q6A5oFMQMHGwPfEi2elg+ scenes-app-inbox-signalsourcespanel--replay-vision-expanded--dark:+ hash: v1.k794b7964.91d6f2333d152b21b0a3c3defe243ad56ec48d54a06bfc5ec3e0538cde1c6325.LOyzhXttfKQhsSDIsee-zqgPzOZyCXi4lOFLef6FOT8+ scenes-app-inbox-signalsourcespanel--replay-vision-expanded--light:+ hash: v1.k794b7964.edaa8d90dcf46911f47d5c40ce2a6f2c8542000c2de472acde6959e2afbb0410.mBMhEdPIwxMd-Ktio7LCd0wegNurdVCgcRsT41hZ1kEscenes-app-inbox-signalsourcespanel--server-side-exceptions-only--dark:hash: v1.k794b7964.f897b9dd52eae8ad29d04c46ba689c27f47602692b2144b0e75a97ef34fae702.qixI7HhZb5rWIcR5HzZB9i8SidHDxo9eBF_dsAFvSewscenes-app-inbox-signalsourcespanel--server-side-exceptions-only--light:diff --git a/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsx b/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsxnew file mode 100644index 000000000000..e3f38379cd3f--- /dev/null+++ b/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsx@@ -0,0 +1,63 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { AgentsRoster } from './AgentsRoster'++const SCANNERS = Array.from({ length: 10 }, (_, index) => ({+ id: `scanner-${index}`,+ name: `Scanner ${index}`,+ description: `Watches step ${index}.`,+ scanner_type: 'monitor',+ enabled: true,+ emits_signals: false,+}))++const EMPTY_LIST = { count: 0, next: null, previous: null, results: [] }++describe('AgentsRoster', () => {+ beforeEach(() => {+ initKeaTests()+ useMocks({+ get: {+ '/api/projects/:team_id/signals/source_configs/': () => [200, { results: [] }],+ '/api/projects/:team_id/vision/scanners/': () => [+ 200,+ { count: SCANNERS.length, next: null, previous: null, results: SCANNERS },+ ],+ '/api/projects/:team_id/event_definitions/': () => [200, EMPTY_LIST],+ '/api/environments/:team_id/external_data_sources/': () => [200, EMPTY_LIST],+ },+ })+ // The roster only loads its sources behind this flag, so without it every list stays empty.+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.PRODUCT_AUTONOMY], {+ [FEATURE_FLAGS.PRODUCT_AUTONOMY]: true,+ })+ })+ afterEach(cleanup)++ // The cap keeps a long user-created list from burying the sources below it, but a filter that+ // could not reach past it would make a scanner unfindable by name.+ it('caps the scanner list, and lets both the filter and Show more reach past the cap', async () => {+ render(<AgentsRoster />)+ await userEvent.click(await screen.findByText('Replay vision'))++ expect(await screen.findByText('Scanner 7')).toBeInTheDocument()+ expect(screen.queryByText('Scanner 8')).not.toBeInTheDocument()++ await userEvent.type(screen.getByPlaceholderText('Filter scanners'), 'Scanner 9')+ expect(await screen.findByText('Scanner 9')).toBeInTheDocument()++ await userEvent.clear(screen.getByPlaceholderText('Filter scanners'))+ await userEvent.click(await screen.findByText('Show 2 more scanners'))+ expect(await screen.findByText('Scanner 9')).toBeInTheDocument()+ })+})diff --git a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx b/products/signals/frontend/inbox/components/config/AgentsRoster.tsxindex 87d8761c9bd4..ec549335f9a4 100644--- a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx+++ b/products/signals/frontend/inbox/components/config/AgentsRoster.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { memo, useCallback, useMemo, useState } from 'react'-import { IconArrowUpRight, IconChevronRight, IconGear, IconPlus } from '@posthog/icons'+import { IconArrowUpRight, IconChevronDown, IconChevronRight, IconGear, IconPlus } from '@posthog/icons'import {LemonBanner,LemonButton,@@ -58,9 +58,12 @@ function entityKindLabel(kind: string): string {return ENTITY_KIND_LABELS[kind] ?? kind}-/** Above this many entities the list gets a filter box rather than only a scroll bar. */+/** Above this many entities the list gets a filter box. */const ENTITY_FILTER_THRESHOLD = 8+/** The entity rows are part of the source list, so an unbounded one would push every source below it off screen. */+const ENTITY_VISIBLE_LIMIT = 8+function resolveAgentStatus(armed: boolean,syncStatus: SignalSourceConfigStatus | SyncStatusEnumApi | null | undefined@@ -181,27 +184,35 @@ function EntityRow({disabledReason?: string}): JSX.Element {return (- <div className="flex items-center gap-2 px-2 py-1 hover:bg-surface-secondary">- <LemonSwitch- size="small"- checked={entity.enabled}- onChange={onToggle}- disabledReason={disabledReason}- aria-label={entity.name}- />- <span- className={`max-w-60 shrink-0 truncate text-xs font-medium ${- entity.enabled ? 'text-default' : 'text-muted'- }`}- >- {entity.name}- </span>- {entity.kind && (- <LemonTag size="small" type="muted">- {entityKindLabel(entity.kind)}- </LemonTag>- )}- <span className="min-w-0 flex-1 truncate text-xs text-muted">{entity.detail}</span>+ <div className="flex h-10 items-center gap-2 border-t border-primary bg-surface-secondary pl-8 pr-2">+ <div className="flex min-w-0 flex-1 flex-col">+ <div className="flex items-center gap-1.5">+ <span+ className={`truncate text-[13px] font-medium leading-[18px] ${+ entity.enabled ? 'text-default' : 'text-muted'+ }`}+ >+ {entity.name}+ </span>+ {entity.kind && (+ <LemonTag className="shrink-0" size="small" type="muted">+ {entityKindLabel(entity.kind)}+ </LemonTag>+ )}+ </div>+ {entity.detail && <span className="truncate text-xs leading-4 text-muted">{entity.detail}</span>}+ </div>+ <div className="flex w-13 shrink-0 justify-end">+ <LemonSwitch+ checked={entity.enabled}+ onChange={onToggle}+ disabledReason={disabledReason}+ aria-label={entity.name}+ />+ </div>+ {/* Stands in for the parent row's xsmall icon-only chevron button, so a sub-row switch+ lines up under the parent switch instead of under the chevron. */}+ <span className="w-[26px] shrink-0" /></div>)}@@ -287,83 +298,98 @@ function Expansion({onRetryData,}: ExpansionProps): JSX.Element {const [filter, setFilter] = useState('')+ const [showAll, setShowAll] = useState(false)const { entities } = stateconst noun = agent.entityNoun ?? 'items'const query = filter.trim().toLowerCase()- const visible = query ? entities.filter((entity) => entity.name.toLowerCase().includes(query)) : entities- const enabledCount = entities.filter((entity) => entity.enabled).length+ const matching = query ? entities.filter((entity) => entity.name.toLowerCase().includes(query)) : entities+ // A filter already narrows the list, so the cap only applies while the person is browsing it.+ const capped = !query && !showAll+ const visible = capped ? matching.slice(0, ENTITY_VISIBLE_LIMIT) : matching+ const hiddenCount = matching.length - visible.length+ const expandedPastCap = !query && showAll && matching.length > ENTITY_VISIBLE_LIMITconst toolOff = tool?.enabled === false+ const steeringIsSet = state.steeringConfigs.some(sourceSteeringIsSet)+ // `ToolDataStatus` renders nothing for an unavailable status, so the meta line would be empty.+ const hasToolLine = !!tool && (toolOff || tool.dataStatus !== 'unavailable')+ const hasMetaLine = hasToolLine || !!onSteer || !!onConfigureFilters+ const newEntityButton = agent.manageUrl ? (+ <LemonButton size="xsmall" type="secondary" to={agent.manageUrl} icon={<IconPlus />} targetBlank>+ New {agent.entityNounSingular}+ </LemonButton>+ ) : null+ const docsLink = agent.docsUrl ? (+ <Link to={agent.docsUrl} target="_blank" className="whitespace-nowrap text-xs">+ Learn about {agent.docsLabel ?? agent.label}+ <IconArrowUpRight />+ </Link>+ ) : nullreturn (- <div className="flex flex-col gap-2 border-t border-primary bg-surface-secondary px-3 py-2.5">- {/* Never the tagline again: this line says what triggers a signal, not what is watched. */}- <p className="mb-0 text-xs text-secondary">- {agent.detail}{' '}- {agent.docsUrl && (- <Link to={agent.docsUrl} target="_blank" className="whitespace-nowrap text-xs">- Learn about {agent.docsLabel ?? agent.label}- <IconArrowUpRight />- </Link>+ <div className="flex flex-col border-t border-primary bg-surface-secondary">+ <div className="flex flex-col gap-1.5 py-2.5 pl-8 pr-3">+ {/* Never the tagline again: this line says what triggers a signal, not what is watched. */}+ {/* Each part is its own element: a page-translation extension detaches a bare text+ node, and React then throws when the link next to it appears or disappears. */}+ <p className="mb-0 text-xs text-secondary">+ <span>{agent.detail}</span>+ {!hasMetaLine && docsLink ? <span> {docsLink}</span> : null}+ </p>++ {hasMetaLine && (+ <div className="flex flex-wrap items-center justify-between gap-2">+ {toolOff && tool ? (+ <div className="flex items-center gap-2">+ <span className="text-xs text-warning">+ {tool.toolName} is off, so this source has nothing to read.+ </span>+ {tool.enablement && (+ <LemonButton+ type="secondary"+ size="xsmall"+ loading={enablingTool}+ onClick={() => onEnableTool(tool)}+ >+ Turn it on+ </LemonButton>+ )}+ </div>+ ) : tool ? (+ <ToolDataStatus agent={agent} status={tool.dataStatus} onRetry={onRetryData} />+ ) : (+ <span />+ )}+ <div className="flex items-center gap-2">+ {docsLink}+ {onSteer && (+ <LemonButton+ type="secondary"+ size="xsmall"+ icon={<IconGear />}+ onClick={onSteer}+ data-attr="signal-source-steering-open"+ >+ {steeringIsSet ? 'Edit guidance' : 'Add guidance'}+ </LemonButton>+ )}+ {onConfigureFilters && (+ <LemonButton type="secondary" size="xsmall" onClick={onConfigureFilters}>+ Configure filters+ </LemonButton>+ )}+ </div>+ </div>)}- </p>-- {toolOff && tool ? (- <div className="flex items-center gap-2">- <span className="text-xs text-warning">- {tool.toolName} is off, so this source has nothing to read.- </span>- {tool.enablement && (- <LemonButton- type="secondary"- size="xsmall"- loading={enablingTool}- onClick={() => onEnableTool(tool)}- >- Turn it on- </LemonButton>- )}- </div>- ) : tool ? (- <ToolDataStatus agent={agent} status={tool.dataStatus} onRetry={onRetryData} />- ) : null}-- {onConfigureFilters && (- <div className="flex items-center gap-2">- <span className="text-xs text-secondary">Limit which recordings this source analyzes.</span>- <LemonButton type="secondary" size="xsmall" onClick={onConfigureFilters}>- Configure filters- </LemonButton>- </div>- )}-- {onSteer && (- <div className="flex items-center gap-2">- <span className="text-xs text-secondary">- {state.steeringConfigs.some(sourceSteeringIsSet)- ? 'Guidance is set for this source.'- : 'Tell the agent what matters and what to skip.'}- </span>- <LemonButton- type="secondary"- size="xsmall"- icon={<IconGear />}- onClick={onSteer}- data-attr="signal-source-steering-open"- >- {state.steeringConfigs.some(sourceSteeringIsSet) ? 'Edit guidance' : 'Add guidance'}- </LemonButton>- </div>- )}+ </div>{state.entitiesLoading ? (- <LemonSkeleton className="h-16 w-full" />+ <div className="border-t border-primary py-2.5 pl-8 pr-3">+ <LemonSkeleton className="h-16 w-full" />+ </div>) : entities.length > 0 ? (- <div className="flex flex-col gap-1.5">- <div className="flex items-center gap-2">- <span className="text-xs font-medium text-default">- {enabledCount} of {entities.length} {noun} on- </span>- {entities.length > ENTITY_FILTER_THRESHOLD && (+ <>+ {entities.length > ENTITY_FILTER_THRESHOLD && (+ <div className="flex items-center border-t border-primary py-1.5 pl-8 pr-3"><LemonInputtype="search"size="xsmall"@@ -372,57 +398,59 @@ function Expansion({value={filter}onChange={setFilter}/>- )}- <div className="flex-1" />- {agent.manageUrl && (- <LemonButton- size="xsmall"- type="secondary"- to={agent.manageUrl}- icon={<IconPlus />}- targetBlank- >- New {agent.entityNounSingular}- </LemonButton>- )}- </div>- <div className="max-h-46 overflow-y-auto rounded border border-primary bg-surface-primary">- {visible.length === 0 ? (- <p className="mb-0 px-2 py-3 text-center text-xs text-muted">- No {noun} match that filter.- </p>- ) : (- visible.map((entity) => (- <EntityRow- key={entity.id}- entity={entity}- onToggle={() => onToggleEntity(entity.id)}- disabledReason={- state.loading- ? 'Saving'- : toolOff && !entity.enabled- ? `Turn on ${tool?.toolName} first. This source reads its data.`- : undefined- }- />- ))- )}- </div>- </div>+ </div>+ )}+ {visible.length === 0 ? (+ <p className="mb-0 border-t border-primary py-2 pl-8 pr-3 text-xs text-muted">+ No {noun} match that filter.+ </p>+ ) : (+ visible.map((entity) => (+ <EntityRow+ key={entity.id}+ entity={entity}+ onToggle={() => onToggleEntity(entity.id)}+ disabledReason={+ state.loading+ ? 'Saving'+ : toolOff && !entity.enabled+ ? `Turn on ${tool?.toolName} first. This source reads its data.`+ : undefined+ }+ />+ ))+ )}+ {(hiddenCount > 0 || expandedPastCap || newEntityButton) && (+ <div className="flex h-9 items-center justify-between border-t border-primary pl-8 pr-3">+ {hiddenCount > 0 ? (+ <LemonButton+ type="tertiary"+ size="xsmall"+ icon={<IconChevronDown />}+ onClick={() => setShowAll(true)}+ >+ Show {hiddenCount} more {noun}+ </LemonButton>+ ) : expandedPastCap ? (+ <LemonButton+ type="tertiary"+ size="xsmall"+ icon={<IconChevronDown className="rotate-180" />}+ onClick={() => setShowAll(false)}+ >+ Show fewer+ </LemonButton>+ ) : (+ <span />+ )}+ {newEntityButton}+ </div>+ )}+ </>) : agent.entityNoun ? (- <div className="flex items-center gap-2">+ <div className="flex items-center gap-2 border-t border-primary py-2.5 pl-8 pr-3"><span className="text-xs text-secondary">No {noun} yet.</span>- {agent.manageUrl && (- <LemonButton- size="xsmall"- type="secondary"- to={agent.manageUrl}- icon={<IconPlus />}- targetBlank- >- New {agent.entityNounSingular}- </LemonButton>- )}+ {newEntityButton}</div>) : null}</div>@@ -508,27 +536,29 @@ const AgentRow = memo(function AgentRow({<span className="w-38 shrink-0 truncate text-right text-xs text-muted">{entities.length > 0 && `${enabledCount} of ${entities.length} ${agent.entityNoun} on`}</span>- {/* eslint-disable-next-line react/no-unknown-property */}- <div className="flex w-13 shrink-0 justify-end" onClick={(e) => e.stopPropagation()}>- {loading ? (- <Spinner className="text-base" />- ) : requiresSetup ? (- <LemonButton type="secondary" size="xsmall" onClick={() => onToggle(agent.source)}>- Connect- </LemonButton>- ) : hasMasterSwitch ? (- <LemonSwitch- checked={armed}- onChange={() => onToggle(agent.source)}- disabledReason={- armingBlocked- ? `Turn on ${tool?.toolName} first. This source reads its data.`- : undefined- }- aria-label={`Arm ${agent.label}`}- />- ) : null}- </div>+ {(loading || requiresSetup || hasMasterSwitch) && (+ // eslint-disable-next-line react/no-unknown-property+ <div className="flex w-13 shrink-0 justify-end" onClick={(e) => e.stopPropagation()}>+ {loading ? (+ <Spinner className="text-base" />+ ) : requiresSetup ? (+ <LemonButton type="secondary" size="xsmall" onClick={() => onToggle(agent.source)}>+ Connect+ </LemonButton>+ ) : (+ <LemonSwitch+ checked={armed}+ onChange={() => onToggle(agent.source)}+ disabledReason={+ armingBlocked+ ? `Turn on ${tool?.toolName} first. This source reads its data.`+ : undefined+ }+ aria-label={`Arm ${agent.label}`}+ />+ )}+ </div>+ )}{/* A real button inside the clickable row, so keyboard users can reach theexpansion (and the controls inside it, like steering). */}<LemonButtondiff --git a/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx b/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsxindex e0a83defff49..22699f032c19 100644--- a/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx+++ b/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx@@ -1,8 +1,11 @@import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'import type { Meta, StoryObj } from '@storybook/react'+import { within } from '@testing-library/dom'+import userEvent from '@testing-library/user-event'import { useEffect } from 'react'+import { FEATURE_FLAGS } from 'lib/constants'import { teamLogic } from 'scenes/teamLogic'import { useStorybookMocks } from '~/mocks/browser'@@ -70,7 +73,7 @@ function sourceConfigsFor(state: PanelState): SignalSourceConfig[] {]}-/** Two scanners so the roster's per-scanner list has both an on and an off row to render. */+/** Ten scanners, so the roster's per-scanner list renders on and off rows, the filter, and the cap. */function scannersFor(state: PanelState): Record<string, unknown>[] {return [{@@ -89,6 +92,70 @@ function scannersFor(state: PanelState): Record<string, unknown>[] {enabled: true,emits_signals: false,},+ {+ id: 'scanner-pricing-rage',+ name: 'Rage clicks on pricing',+ description: 'Flags sessions with repeated rapid clicks on the pricing table.',+ scanner_type: 'monitor',+ enabled: true,+ emits_signals: state.replayVisionArmed,+ },+ {+ id: 'scanner-search-dead-ends',+ name: 'Search dead ends',+ description: 'Finds searches that return nothing and are abandoned.',+ scanner_type: 'monitor',+ enabled: true,+ emits_signals: false,+ },+ {+ id: 'scanner-frustration-score',+ name: 'Frustration score',+ description: 'Scores each session for signs of frustration from 0 to 10.',+ scanner_type: 'scorer',+ enabled: true,+ emits_signals: state.replayVisionArmed,+ },+ {+ id: 'scanner-session-summary',+ name: 'Session summary',+ description: 'Writes a short summary of what the user tried to do.',+ scanner_type: 'summarizer',+ enabled: true,+ emits_signals: false,+ },+ {+ id: 'scanner-settings-confusion',+ name: 'Settings confusion',+ description: 'Watches for back-and-forth between settings pages without saving.',+ scanner_type: 'monitor',+ enabled: true,+ emits_signals: false,+ },+ {+ id: 'scanner-billing-errors',+ name: 'Billing page errors',+ description: 'Catches error toasts and failed submissions on billing pages.',+ scanner_type: 'monitor',+ enabled: true,+ emits_signals: state.replayVisionArmed,+ },+ {+ id: 'scanner-signup-validation',+ name: 'Signup form errors',+ description: 'Watches for validation errors that block signup.',+ scanner_type: 'monitor',+ enabled: true,+ emits_signals: false,+ },+ {+ id: 'scanner-docs-search',+ name: 'Docs search intent',+ description: 'Groups in-product docs searches by what the user wanted.',+ scanner_type: 'classifier',+ enabled: true,+ emits_signals: false,+ },]}@@ -286,3 +353,19 @@ export const SourceConfigsUnavailable: Story = {sourceConfigsUnavailable: true,},}++/** Replay vision opened: user-created scanners as sub-rows, capped at eight, with a filter. */+export const ReplayVisionExpanded: Story = {+ parameters: { featureFlags: [FEATURE_FLAGS.INBOX_REDESIGN] },+ play: async ({ canvasElement }) => {+ await userEvent.click(await within(canvasElement).findByText('Replay vision', { exact: true }))+ },+}++/** Error tracking opened: a fixed list of signal types, so no filter, no cap, and no New button. */+export const ErrorTrackingExpanded: Story = {+ parameters: { featureFlags: [FEATURE_FLAGS.INBOX_REDESIGN] },+ play: async ({ canvasElement }) => {+ await userEvent.click(await within(canvasElement).findByText('Error tracking', { exact: true }))+ },+}