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 grouped signal reports on the observation result (#103208)

Kim Svatos Dugan34b293cd67a5
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 64ea4814c43b..96bcf3b00c28 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10189,9 +10189,9 @@ snapshots:
scenes-app-replay-vision--observation-detail-feedback-prompt--light:
hash: v1.k794b7964.59677d24da0b5cb9cd755a5f5af898c7a9999560caa6c7a9f653c0cdb1cd9198.VziTZTShcVxzXQMyJRuUCTDfplGGmCGd7yESU8U1m4Q
scenes-app-replay-vision--observation-detail-monitor--dark:
- hash: v1.k794b7964.ef99171cd2a5ed8008fbd26ede08aa1c63539dd86331657f74ef887b6ce224e3.iw5USyEwKvl52slTujh069twP8ZiUjNOHpw0SLM7FBM
+ hash: v1.k794b7964.7591a846c3cdc88eabed6184b663488cc452441ff40eac493caaed3df17dfd1d.5XU5zVS7zu6YYlbsnmIf8nzWUHPsTYVSOT1MWox-MII
scenes-app-replay-vision--observation-detail-monitor--light:
- hash: v1.k794b7964.266af7318c0609fc4b1df50ffdc70b05f6a33d7f0cedbd8fcaff5040de483cb2.flvYykloNw1KibfSjtHG9M_L_Gl_knRVLMgWHk5TRxE
+ hash: v1.k794b7964.768885316fe8f5e6d6e766920805adb17331c67f5452cb81878273e718d46128.613JBEPeFxtEAhgh9tMgylbHMAk-bHGqX6WL2hhlLEI
scenes-app-replay-vision--scanner-alerts--dark:
hash: v1.k794b7964.87fdb6e06721ceec6ed9bb54eb0e48ab04c117a20e18d2b64a4253671999876f.4o_jktzFiZNieMvqKaefp4SP6mCmkG6X7OVBhkaXcWs
scenes-app-replay-vision--scanner-alerts--light:
diff --git a/products/replay_vision/frontend/observations/ObservationSignalReports.tsx b/products/replay_vision/frontend/observations/ObservationSignalReports.tsx
new file mode 100644
index 000000000000..422e5f543e99
--- /dev/null
+++ b/products/replay_vision/frontend/observations/ObservationSignalReports.tsx
@@ -0,0 +1,60 @@
+import { useValues } from 'kea'
+
+import { Link } from '@posthog/lemon-ui'
+
+import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
+import { urls } from 'scenes/urls'
+
+import { displayConventionalCommitTitle } from 'products/signals/frontend/inbox/utils/reportPresentation'
+
+import { LabeledRow } from '../components/LabeledRow'
+import { observationSignalReportsLogic } from './observationSignalReportsLogic'
+
+// Mounted only when the observation emitted something, so a no-signal observation never queries.
+function ReportLinks({ observationId }: { observationId: string }): JSX.Element {
+ const { signalReports, signalReportsLoading, signalReportsUnavailable } = useValues(
+ observationSignalReportsLogic({ observationId })
+ )
+
+ if (signalReportsLoading) {
+ return <LemonSkeleton className="h-4 w-40" />
+ }
+ if (signalReportsUnavailable) {
+ return <span className="text-muted">Could not load linked reports</span>
+ }
+ if (!signalReports?.length) {
+ // The lookup window is bounded, so an old observation can have a report this does not find.
+ return <span className="text-muted">No linked report found</span>
+ }
+ return (
+ <>
+ {signalReports.map((report) => (
+ <Link
+ key={report.id}
+ to={urls.inboxReport('reports', report.id)}
+ data-attr="vision-observation-open-signal-report"
+ >
+ {displayConventionalCommitTitle(report.title, 'Untitled report')}
+ </Link>
+ ))}
+ </>
+ )
+}
+
+/** The signals this observation emitted, and the inbox reports they were grouped into. */
+export function ObservationSignalReports({
+ observationId,
+ signalsCount,
+}: {
+ observationId: string
+ signalsCount: number
+}): JSX.Element {
+ return (
+ <LabeledRow label="Signals">
+ <div className="flex flex-col items-start gap-1">
+ <span>Emitted ({signalsCount})</span>
+ {signalsCount > 0 && <ReportLinks observationId={observationId} />}
+ </div>
+ </LabeledRow>
+ )
+}
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
index 812a1f2818e4..6ba2bceae01c 100644
--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -70,6 +70,7 @@ import { ObservationLabelControl } from './ObservationLabelControl'
import { observationLabelLogic } from './observationLabelLogic'
import { ObservationPinnedProperties } from './ObservationPinnedProperties'
import { ObservationShareButton } from './ObservationShareButton'
+import { ObservationSignalReports } from './ObservationSignalReports'
import {
neighborFilterParams,
observationDetailUrl,
@@ -441,6 +442,12 @@ export function ReplayObservationSceneComponent(): JSX.Element {
</Link>
</LabeledRow>
)}
+ {snapshot.emits_signals && (
+ <ObservationSignalReports
+ observationId={observation.id}
+ signalsCount={observation.scanner_result?.signals_count ?? 0}
+ />
+ )}
<ObservationLabelControl observationId={observation.id} initialLabel={observation.label} />
<CalibrationEntryPoint observation={observation} />
</div>
diff --git a/products/replay_vision/frontend/observations/observationSignalReportsLogic.ts b/products/replay_vision/frontend/observations/observationSignalReportsLogic.ts
new file mode 100644
index 000000000000..4ec125446761
--- /dev/null
+++ b/products/replay_vision/frontend/observations/observationSignalReportsLogic.ts
@@ -0,0 +1,101 @@
+import { MakeLogicType, actions, afterMount, kea, key, path, props, reducers } from 'kea'
+import { loaders } from 'kea-loaders'
+import posthog from 'posthog-js'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { visionObservationsSignalReportsList } from '../generated/api'
+import { ObservationSignalReportApi } from '../generated/api.schemas'
+
+export interface ObservationSignalReportsLogicProps {
+ observationId: string
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationSignalReportsLogicValues {
+ signalReports: ObservationSignalReportApi[] | null
+ signalReportsLoading: boolean
+ signalReportsUnavailable: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationSignalReportsLogicActions {
+ loadSignalReports: () => any
+ loadSignalReportsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSignalReportsSuccess: (
+ signalReports: ObservationSignalReportApi[] | null,
+ payload?: any
+ ) => {
+ signalReports: ObservationSignalReportApi[] | null
+ payload?: any
+ }
+ setSignalReportsUnavailable: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface observationSignalReportsLogicMeta {
+ key: string
+}
+
+export type observationSignalReportsLogicType = MakeLogicType<
+ observationSignalReportsLogicValues,
+ observationSignalReportsLogicActions,
+ ObservationSignalReportsLogicProps,
+ observationSignalReportsLogicMeta
+>
+
+/** Grouping runs after the scan finishes, so an empty list means "not grouped yet" as much as "never grouped". */
+export const observationSignalReportsLogic = kea<observationSignalReportsLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'observations', 'observationSignalReportsLogic']),
+ props({} as ObservationSignalReportsLogicProps),
+ key((props) => props.observationId),
+
+ actions({
+ setSignalReportsUnavailable: true,
+ }),
+
+ reducers({
+ // A failed read must not read as "no reports": the caller may simply lack inbox access.
+ signalReportsUnavailable: [
+ false,
+ {
+ setSignalReportsUnavailable: () => true,
+ loadSignalReports: () => false,
+ },
+ ],
+ }),
+
+ loaders(({ props, actions }) => ({
+ signalReports: [
+ null as ObservationSignalReportApi[] | null,
+ {
+ loadSignalReports: async () => {
+ const teamId = teamLogic.values.currentTeamId
+ if (!teamId) {
+ return null
+ }
+ try {
+ return await visionObservationsSignalReportsList(String(teamId), props.observationId)
+ } catch (e) {
+ // Supplementary context on an already-rendered page: fail quiet, don't toast over it.
+ posthog.captureException(e)
+ actions.setSignalReportsUnavailable()
+ return null
+ }
+ },
+ },
+ ],
+ })),
+
+ afterMount(({ actions }) => {
+ actions.loadSignalReports()
+ }),
+])