: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): attach open report context to posthog ai (#125612)
Georgiy Tarasov905110e89b5a
diff --git a/products/signals/frontend/inbox/components/detail/DiscussReportButton.stories.tsx b/products/signals/frontend/inbox/components/detail/DiscussReportButton.stories.tsxindex 1160c05a7a51..287aa1fd324c 100644--- a/products/signals/frontend/inbox/components/detail/DiscussReportButton.stories.tsx+++ b/products/signals/frontend/inbox/components/detail/DiscussReportButton.stories.tsx@@ -30,7 +30,7 @@ const meta: Meta<typeof ReportDiscussionComposer> = {parameters: { layout: 'centered' },decorators: [function ReportContext(Story, context): JSX.Element {- useAttachedContext([{ type: 'signal_report', key: report.id, label: `Report: ${report.title}` }])+ useAttachedContext([{ type: 'inbox_report', key: report.id, label: `Report: ${report.title}` }])return (<div className={context.name === 'Sidebar' ? 'w-[960px] max-w-[calc(100vw-2rem)]' : 'w-96 max-w-full'}><Story />diff --git a/products/signals/frontend/inbox/components/detail/DiscussReportButton.test.tsx b/products/signals/frontend/inbox/components/detail/DiscussReportButton.test.tsxindex 58273f7bdbfe..53bd3edbb0a4 100644--- a/products/signals/frontend/inbox/components/detail/DiscussReportButton.test.tsx+++ b/products/signals/frontend/inbox/components/detail/DiscussReportButton.test.tsx@@ -196,18 +196,18 @@ describe('DiscussReportButton', () => {it('keeps the report context attached', async () => {attachedContextLogic.actions.registerContext('report', [{- type: 'signal_report',+ type: 'inbox_report',key: 'report-1',- label: 'Report: Exceptions spiked',+ label: 'Self-driving Inbox Report',dismissible: false,},])const user = await openPanel(makeReport())- await user.click(screen.getByText('Report: Exceptions spiked'))+ await user.click(screen.getByText('Self-driving Inbox Report'))expect(attachedContextLogic.values.contextItems).toEqual([- expect.objectContaining({ type: 'signal_report', key: 'report-1' }),+ expect.objectContaining({ type: 'inbox_report', key: 'report-1' }),])})diff --git a/products/signals/frontend/inbox/components/detail/ReportAiPanel.tsx b/products/signals/frontend/inbox/components/detail/ReportAiPanel.tsxindex 7e3b1db903f5..321e90aeb976 100644--- a/products/signals/frontend/inbox/components/detail/ReportAiPanel.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportAiPanel.tsx@@ -15,9 +15,9 @@ export function ReportAiPanel({ panelId }: { panelId: string }): JSX.Element {report? [{- type: 'signal_report',+ type: 'inbox_report',key: report.id,- label: `Report: ${report.title || 'Untitled report'}`,+ label: 'Self-driving Inbox Report',dismissible: false,},]diff --git a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx b/products/signals/frontend/inbox/components/detail/ReportDetail.tsxindex 1ac46da85525..e93d92971142 100644--- a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx@@ -20,6 +20,8 @@ import { addProjectIdIfMissing } from 'lib/utils/kea-router'import { SignalNode } from 'scenes/debug/signals/types'import { urls } from 'scenes/urls'+import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'+import { captureInboxReportAction } from '../../inboxAnalytics'import { inboxDetailLayoutLogic } from '../../logics/inboxDetailLayoutLogic'import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'@@ -212,6 +214,21 @@ export function InboxDetailFrame({pullRequestNote,children,}: InboxDetailFrameProps): JSX.Element {+ const reportContextGroup = `inbox_report:${report.id}`+ useAttachedContext([+ { type: 'inbox_report', key: report.id, label: 'Self-driving Inbox Report', dismissGroup: reportContextGroup },+ {+ type: 'instructions',+ hidden: true,+ dismissGroup: reportContextGroup,+ value:+ 'The inbox_report item identifies the open Self-driving report. ' ++ 'Use inbox-reports-retrieve for report details and inbox-report-artefacts-list for evidence, notes, ' ++ 'code references, and task_run links. Read individual artefacts with inbox-report-artefacts-retrieve. ' ++ 'Follow task_id and run_id from task_run entries with tasks-retrieve, tasks-runs-retrieve, and ' ++ 'tasks-runs-session-logs-retrieve as needed. Load the signals skill for raw contributing signals.',+ },+ ])const { searchParams } = useValues(router)// A `?back=` internal path (set by surfaces embedding inbox cards, e.g. the customer analytics// feed) redirects the back button there instead of the inbox list tab.