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(inbox): make scout findings linkable (#64940)

Andrew Maguire09537cf19cf3
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx
index a53628d23d27..f4acb1b754eb 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx
@@ -95,6 +95,7 @@ function ScoutSignalsSection({ skillName }: { skillName: string }): JSX.Element
const { emissionRows, emissionsLoading, emissionsLoadFailed, runsWindowLoadedOnce, runsWindowComplete } = useValues(
scoutDetailLogic({ skillName })
)
+ const { selectedScoutFindingId } = useValues(inboxSceneLogic)
// "Loading" until the fleet's runs window has settled once AND this scout's emissions have
// resolved — otherwise a fresh deep-link would flash the empty state before we know the
@@ -102,6 +103,10 @@ function ScoutSignalsSection({ skillName }: { skillName: string }): JSX.Element
// quiet-scout empty state from flickering to a skeleton every 60s poll.
const loading = !runsWindowLoadedOnce || emissionsLoading
const hasRows = emissionRows.length > 0
+ // The unique emission the deep-link resolves to: the newest row whose finding matches.
+ const deepLinkedEmissionId = selectedScoutFindingId
+ ? (emissionRows.find(({ emission }) => emission.finding_id === selectedScoutFindingId)?.emission.id ?? null)
+ : null
return (
<div className="flex flex-col gap-2">
@@ -123,7 +128,17 @@ function ScoutSignalsSection({ skillName }: { skillName: string }): JSX.Element
) : (
<>
{emissionRows.map(({ emission, run, report }) => (
- <ScoutEmissionCard key={emission.id} emission={emission} run={run} report={report} />
+ <ScoutEmissionCard
+ key={emission.id}
+ skillName={skillName}
+ emission={emission}
+ run={run}
+ report={report}
+ // `finding_id` repeats across runs (it's a dedup trace id, not unique), so only
+ // mark the newest matching emission — rows are newest-first — to keep the
+ // highlight/scroll deterministic for a single shared link.
+ isDeepLinked={emission.id === deepLinkedEmissionId}
+ />
))}
{!runsWindowComplete && (
<span className="text-xs text-muted">
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx
index 5394384d0338..fe0346620a99 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx
@@ -1,10 +1,13 @@
-import { useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
import { IconArrowRight, IconChevronDown, IconExternal } from '@posthog/icons'
-import { Link } from '@posthog/lemon-ui'
+import { LemonButton, Link } from '@posthog/lemon-ui'
+import { IconLink } from 'lib/lemon-ui/icons'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { humanFriendlyDetailedTime } from 'lib/utils/datetime'
+import { addProjectIdIfMissing } from 'lib/utils/kea-router'
import { urls } from 'scenes/urls'
import { LinkedSignalReport, SignalScoutEmission, SignalScoutRunSummary } from '../../../types'
@@ -24,40 +27,81 @@ function MonoId({ label, value }: { label: string; value: string }): JSX.Element
* One emitted finding in the scout detail Signals section. Shares the collapse/expand grammar of
* the run rows: a header (chevron · severity · confidence · timestamp) that stays visible, a 2-line
* markdown preview when collapsed, and the full markdown plus an id/task-run footer when expanded.
+ *
+ * `isDeepLinked` marks the finding the current `/inbox/scouts/<skill>/<finding>` URL points at — it
+ * auto-expands, highlights, and scrolls itself into view so a shared link lands on the right card.
*/
export function ScoutEmissionCard({
+ skillName,
emission,
run,
report,
+ isDeepLinked = false,
}: {
+ skillName: string
emission: SignalScoutEmission
run: SignalScoutRunSummary
/** The inbox report this finding grouped into, if resolved — renders the "In report" deep-link chip. */
report: LinkedSignalReport | null
+ /** True when this finding is the one the current URL deep-links to. */
+ isDeepLinked?: boolean
}): JSX.Element {
- const [expanded, setExpanded] = useState(false)
+ const [expanded, setExpanded] = useState(isDeepLinked)
const confidencePercent = Math.round((emission.confidence ?? 0) * 100)
+ const cardRef = useRef<HTMLDivElement>(null)
+
+ // A deep-linked finding may mount after the URL is already settled (emissions load async), so
+ // bring it into view and open it once it appears. Keyed on the finding id so re-selecting a
+ // different finding in the same list re-triggers, not on every render.
+ useEffect(() => {
+ if (isDeepLinked) {
+ setExpanded(true)
+ cardRef.current?.scrollIntoView({ block: 'center', behavior: 'smooth' })
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [isDeepLinked, emission.finding_id])
+
+ const copyFindingLink = (): void => {
+ void copyToClipboard(
+ `${window.location.origin}${addProjectIdIfMissing(urls.inboxScout(skillName, emission.finding_id))}`,
+ 'finding link'
+ )
+ }
return (
- <div className="flex flex-col rounded border border-primary bg-bg-light">
- <button
- type="button"
- onClick={() => setExpanded((value) => !value)}
- className="flex items-center gap-2 px-3 py-2 text-left"
- aria-expanded={expanded}
- >
- <IconChevronDown
- className={`size-4 shrink-0 text-muted transition-transform ${expanded ? '' : '-rotate-90'}`}
+ <div
+ ref={cardRef}
+ className={`flex flex-col rounded border bg-bg-light ${
+ isDeepLinked ? 'border-accent bg-accent-highlight-secondary' : 'border-primary'
+ }`}
+ >
+ <div className="flex items-center">
+ <button
+ type="button"
+ onClick={() => setExpanded((value) => !value)}
+ className="flex flex-1 items-center gap-2 px-3 py-2 text-left"
+ aria-expanded={expanded}
+ >
+ <IconChevronDown
+ className={`size-4 shrink-0 text-muted transition-transform ${expanded ? '' : '-rotate-90'}`}
+ />
+ <SignalReportPriorityBadge priority={emission.severity} />
+ <span className="whitespace-nowrap text-[11px] text-muted tabular-nums">
+ {confidencePercent}% confidence
+ </span>
+ <span className="flex-1" />
+ <span className="whitespace-nowrap text-[11px] text-muted">
+ {humanFriendlyDetailedTime(emission.emitted_at)}
+ </span>
+ </button>
+ <LemonButton
+ size="xsmall"
+ icon={<IconLink />}
+ tooltip="Copy a link to this finding"
+ className="mr-2 shrink-0"
+ onClick={copyFindingLink}
/>
- <SignalReportPriorityBadge priority={emission.severity} />
- <span className="whitespace-nowrap text-[11px] text-muted tabular-nums">
- {confidencePercent}% confidence
- </span>
- <span className="flex-1" />
- <span className="whitespace-nowrap text-[11px] text-muted">
- {humanFriendlyDetailedTime(emission.emitted_at)}
- </span>
- </button>
+ </div>
<div className="px-3 pb-2 pl-9">
<LemonMarkdown
diff --git a/frontend/src/scenes/inbox/inboxSceneLogic.ts b/frontend/src/scenes/inbox/inboxSceneLogic.ts
index 4305e297ec98..97140a451b84 100644
--- a/frontend/src/scenes/inbox/inboxSceneLogic.ts
+++ b/frontend/src/scenes/inbox/inboxSceneLogic.ts
@@ -71,8 +71,13 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([
// detail renders without a spinner while the authoritative fetch runs in the background.
seedSelectedReport: (report: SignalReport | null) => ({ report }),
setActiveTab: (tab: InboxTabKey) => ({ tab }),
- // Scout detail surface: selecting a scout opens its full-width detail over the list.
- setSelectedScoutSkillName: (skillName: string | null) => ({ skillName }),
+ // Scout detail surface: selecting a scout opens its full-width detail over the list. An
+ // optional finding id deep-links to one emitted finding within that scout (highlighted +
+ // scrolled into view if it's still in the recent window).
+ setSelectedScoutSkillName: (skillName: string | null, findingId: string | null = null) => ({
+ skillName,
+ findingId,
+ }),
runSessionAnalysis: true,
runSessionAnalysisSuccess: true,
runSessionAnalysisFailure: (error: string) => ({ error }),
@@ -130,6 +135,14 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([
setSelectedScoutSkillName: (_, { skillName }) => skillName,
},
],
+ // The finding deep-linked within the selected scout, if any. Cleared whenever a scout is
+ // (re)selected without a finding — navigating to a scout from the fleet drops any prior finding.
+ selectedScoutFindingId: [
+ null as string | null,
+ {
+ setSelectedScoutSkillName: (_, { findingId }) => findingId,
+ },
+ ],
isRunningSessionAnalysis: [
false,
{
@@ -240,7 +253,7 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([
values.selectedReportId
? urls.inboxReport(values.activeTab, values.selectedReportId)
: values.selectedScoutSkillName
- ? urls.inboxScout(values.selectedScoutSkillName)
+ ? urls.inboxScout(values.selectedScoutSkillName, values.selectedScoutFindingId ?? undefined)
: urls.inbox(values.activeTab),
router.values.searchParams,
router.values.hashParams,
@@ -248,7 +261,7 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([
],
setSelectedScoutSkillName: () => [
values.selectedScoutSkillName
- ? urls.inboxScout(values.selectedScoutSkillName)
+ ? urls.inboxScout(values.selectedScoutSkillName, values.selectedScoutFindingId ?? undefined)
: values.selectedReportId
? urls.inboxReport(values.activeTab, values.selectedReportId)
: urls.inbox(values.activeTab),
@@ -294,10 +307,24 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([
},
[urls.inboxScout(':skillName')]: ({ skillName }: { skillName?: string }) => {
const name = skillName ?? null
- if (values.selectedScoutSkillName !== name) {
+ // Also reset the finding when landing on the bare scout URL after a finding deep-link.
+ if (values.selectedScoutSkillName !== name || values.selectedScoutFindingId !== null) {
actions.setSelectedScoutSkillName(name)
}
},
+ [urls.inboxScout(':skillName', ':findingId')]: ({
+ skillName,
+ findingId,
+ }: {
+ skillName?: string
+ findingId?: string
+ }) => {
+ const name = skillName ?? null
+ const finding = findingId ?? null
+ if (values.selectedScoutSkillName !== name || values.selectedScoutFindingId !== finding) {
+ actions.setSelectedScoutSkillName(name, finding)
+ }
+ },
[urls.inboxReport(':tab', ':reportId')]: ({ tab, reportId }: { tab?: string; reportId?: string }) => {
// This pattern also matches `/inbox/scouts/<skillName>`; the scout handler owns that path.
if (tab === 'scouts') {
diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.ts
index 6004c3b06d67..291b67ad2b0f 100644
--- a/frontend/src/scenes/scenes.ts
+++ b/frontend/src/scenes/scenes.ts
@@ -932,6 +932,8 @@ export const routes: Record<string, [Scene | string, string]> = {
[urls.inbox(':tab')]: [Scene.Inbox, 'inbox'],
// Registered before the generic report route: both are two-segment `/inbox/x/y` shapes.
[urls.inboxScout(':skillName')]: [Scene.Inbox, 'inbox'],
+ // Deep-link to a single scout finding: the bare scout route plus a trailing `/<finding>` segment.
+ [urls.inboxScout(':skillName', ':findingId')]: [Scene.Inbox, 'inbox'],
[urls.inboxReport(':tab', ':reportId')]: [Scene.Inbox, 'inbox'],
[urls.pipelineStatus()]: [Scene.PipelineStatus, 'pipelineStatus'],
[urls.sdkHealth()]: [Scene.SdkHealth, 'sdkHealth'],
diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts
index 9fa7e13943df..7828e108419c 100644
--- a/frontend/src/scenes/urls.ts
+++ b/frontend/src/scenes/urls.ts
@@ -300,7 +300,12 @@ export const urls = {
inbox: (tab?: InboxTabKey | ':tab'): string => `/inbox${tab ? `/${tab}` : ''}`,
inboxReport: (tab: InboxTabKey | ':tab', reportId: string | ':reportId'): string => `/inbox/${tab}/${reportId}`,
// Scout detail surface, full-width over the inbox list (the fleet section lives in the Configuration tab).
- inboxScout: (skillName: string | ':skillName'): string => `/inbox/scouts/${skillName}`,
+ // An optional finding id deep-links straight to one emitted finding (best-effort: only resolves while
+ // that finding is still in the scout's recent runs window).
+ inboxScout: (skillName: string | ':skillName', findingId?: string | ':findingId'): string => {
+ const segment = findingId ? `/${findingId === ':findingId' ? findingId : encodeURIComponent(findingId)}` : ''
+ return `/inbox/scouts/${skillName}${segment}`
+ },
webAnalyticsBotAnalytics: (): string => '/web/bots',
webAnalyticsHealth: (): string => '/web/health',
pipelineStatus: (): string => '/health/pipeline-status',