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(signals): Add code diff view to inbox report detail (#67143)

Michael Matloka92c78f86538d
diff --git a/frontend/package.json b/frontend/package.json
index 035516c0592c..bb1deb60f94d 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -65,6 +65,7 @@
"@microlink/react-json-view": "^1.31.18",
"@microsoft/fetch-event-source": "^2.0.1",
"@monaco-editor/react": "4.7.0",
+ "@pierre/diffs": "1.2.11",
"@posthog/brand": "catalog:",
"@posthog/docs-onboarding": "workspace:*",
"@posthog/esbuilder": "workspace:*",
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index e70e16c2b4f0..ad44b50d2ce3 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5597,29 +5597,45 @@ snapshots:
scenes-app-inbox-cards--skeleton--light:
hash: v1.k794b7964.24c19ab5df1e4ccb843b1ad726752e3a98aeadaa08595e66cb4b41aff1a9e9a1.Y3z44tkU4jsAYUyXxfl72fTuZ0MKA6_S6TTNCKt5jSg
scenes-app-inbox-detail--pull-request--dark:
- hash: v1.k794b7964.8a719ba5bba724738cf13d7e04cdb527258d18a20d7d2aecca82398f1f1dda22.3BrWr9eZXx4EPXoj0DM19MHiK9e3W1KW3FgoccSbyLI
+ hash: v1.k794b7964.558fbac4feb3a254d8b89774b84aec8af6f2497cb63a1abc54dae3d9a14fd903.HNZJcHva3GIr93LDRrFAZJ9FcuTeMuYXddFEKqyYSLA
scenes-app-inbox-detail--pull-request--light:
- hash: v1.k794b7964.4ee33dac9422ce123f4809501d98db3dbbd29b69e4f40d25e14a05841d81a4bb.4ui7BVAv-AqoQRCZDzszdiw61RWQayxIyWZwQjtm12A
+ hash: v1.k794b7964.d01573dc4bcf730d961dff9a77fb58d6dd26c5f6bda1de49b6bced2cf5a2ad01.2PlZaynqheuLKN2uUUABzXA3zSXAhYFSvZHgBU5xBo4
scenes-app-inbox-detail--report--dark:
- hash: v1.k794b7964.bed931ee3ebab86eb24d8ddf462342305953b9b333b0912786ab5cede62ddfa2.JbnHb4LRLAqQOLN8w3uPdaE2YKui6kf0ANwyk2EqDjQ
+ hash: v1.k794b7964.8c1f738263f29cccfd7c77f27d869d7fbde8184f6258021ea7eec9d4b95924d5.IG0i3o5AyPRfES6cKwvTMNgC_i7L9GKJhFkB5uf0ktE
scenes-app-inbox-detail--report--light:
- hash: v1.k794b7964.5788b584f665ff06fac3727074bab99e3e49eda1e1b4f7f4020fbdf5b56c41a6.I--NHWPeD0hh8wEJF8n8zJn1bKXQrbhzgYvBt7mZFQA
+ hash: v1.k794b7964.bccb4f7d4fecec10d524a77ed20e5e1a9187c18d1dd26ad9de28d5a4bf2b11d6.g5a45qosejirXaTgF-oas2F6DC8Ojq03QVccq_asYIg
scenes-app-inbox-detail--report-minimal--dark:
- hash: v1.k794b7964.1ad932768247964d7ba9440b9c9cf17acbd47a82309b3a1bb125d51aac5d7843.he9eJUpJg5IHFDNvIYxVgBwc-52oTsGGj1vKnJOcUlc
+ hash: v1.k794b7964.1ec786372e2de8e5bffa7a6386b36970a06e366ae78ded335b42c9f455f15872.pDGH8q-nBDWCmXSIjg7iu4I-AB46RlzXV2avzspBqno
scenes-app-inbox-detail--report-minimal--light:
- hash: v1.k794b7964.0d41bcb80f75889f19bb97431a0ea86a2128d00eafd5a07c5f7ac5acc3e7d14e.7a4HLQtAa2T29HhTiXgo4hhzixjc70hJlL6tOGxN5IE
+ hash: v1.k794b7964.fb09befb575e839a8b3c1852645b23b8abf74ac533739686d267e7a12d239ded.M_ahGhq9QpvWP3UKTV1X_JeMU_ioP9SOSPgXx36eaRU
scenes-app-inbox-detail--run-failed--dark:
- hash: v1.k794b7964.7bf5ec102fe3cf7e523b8abe82aa38d120b854ab3a44a56610aea33279e184ea.R3JiyhN_djiElTD8XECw6qhErhjJ_xBa2c1XfTkUoGQ
+ hash: v1.k794b7964.eab202d2a248dd7ba9966aeaeb14dcebd10e69a2ec51ba6c3eeb6fda50c79924.8wDIdRbRsgVnTAOsyg2vwDRL-nI71Z0SX_7vS8PcM8o
scenes-app-inbox-detail--run-failed--light:
- hash: v1.k794b7964.f37650c6534dccb4bfc66b03fa60253b0b351eb88bd13529f0a4e26a3f4f72f4.rHzcoM0_IyR3M-Q2d9RHYOm8lp2yJT9j3jkLQcyUw-M
+ hash: v1.k794b7964.3769561ec996e0a00fae4c41b0fc5c2f1fd78de9729012ddc2447937c5cb6cbc._G4rbADSNfCIw3skgnu9CUQW0UFSwf61bpqEp2cyIYQ
scenes-app-inbox-detail--run-in-progress--dark:
- hash: v1.k794b7964.f160cafe45011ce8a27d166d2b1c8c102cd26eddcb54cfe592dfeb098bec63c8.G_pEQ5ts1KwR41svCt83d7HaepQLCGCrWNZXtzGsnxU
+ hash: v1.k794b7964.4c9ccb97de99181b56bfc148daec91e3e70929a3e9a03307a259fd47f5abfcbc.rZI0XKaAy3QC5bm8UXsPFHXdGByzRKEWyIpQqgzkj3c
scenes-app-inbox-detail--run-in-progress--light:
- hash: v1.k794b7964.fbf710b96b6c86c03594dbfc214674dfb2da25eba880ec0469cbf1f3b068225c.3H-omKdrADqcUy9CYdekw-W5am55ai9HhlNuecKjUVM
+ hash: v1.k794b7964.3506c71bb2e9f58e45948ac658b3102b9d9b9eef2f07222c54e7737c17e4127e.nJHuYlfBpMXA9D6N7sZsc47ujM0uK7xGdkne-TQ6WC0
scenes-app-inbox-detail--run-ready--dark:
- hash: v1.k794b7964.e36695d83d6502285783b7f7030bef2d25c7e71d6385611b04236a3c683293e4.oUkVq4Fh4_s8gHq9c5cXmhUQSXFLGrvyv-dI1SGmcpA
+ hash: v1.k794b7964.ec61adbb145f4102d4c74c1da235391295946024897c49e02d4dab42f2311928.TyUsqfcnj4hfH72A8eBlY-tjcl6pE0QBnURbOthc_MQ
scenes-app-inbox-detail--run-ready--light:
- hash: v1.k794b7964.7f940d67d5626a00a6970f16a0d3baff59ce5b896e8b0c0967c3fe7f483a1045.woobfMUZ9Hz0XHCYw6w_WvNoS25BhDJr6mk8XkMb9AI
+ hash: v1.k794b7964.7a9e06f9564f4707655bede8d1f35ae2eab2819b02fdd50f8ec9702bd3591fed.tzCwp608W15YZFQLIopTKj-ODYUeOgSq3l7ymz2lmto
+ scenes-app-inbox-pullrequestdiffview--default--dark:
+ hash: v1.k794b7964.564cd678d9da50089c918c63d37c816257091c6c9d7d2f957dc9c96f596d34dc.8ICzP4d5gRBF0h4CT87lZgk82tCHyXIOsszi6P3JQ-M
+ scenes-app-inbox-pullrequestdiffview--default--light:
+ hash: v1.k794b7964.afebf7310803b4becfba1a68ac02d84491193f5156667ee8018a778ebca3f096.g0fdB7Bgu5NoGbqJd4vpH-w2ZXvNeM1XRdL6jisbDcQ
+ scenes-app-inbox-pullrequestdiffview--empty--dark:
+ hash: v1.k794b7964.e78ddf6ae8b9d27875ad89d20e32a3ff2ecb89faefb6859cdf170f67a20c7b15.JY0BvLD55swLWGcDtTgDqosDPwl4FHSomlkURGl_VHw
+ scenes-app-inbox-pullrequestdiffview--empty--light:
+ hash: v1.k794b7964.15fb2f0cd39015e2bdd3a705bbccd352c5f7e1525f5d53e58d7da942efa913ad.N0xhpkqIodZ-AY199lFhmytSBmhHkIpe21IK86if6P8
+ scenes-app-inbox-pullrequestdiffview--split--dark:
+ hash: v1.k794b7964.0d7710cf50481ecf4218b672f3f4b824b6f67d02e62ccc35c7715c9e41e1b73a.CdOddf4lA4YZ4sJoGSX1aEjlCxiDC8pwxgfd4EX31UM
+ scenes-app-inbox-pullrequestdiffview--split--light:
+ hash: v1.k794b7964.74769e897f6f9a035062fc6a3469f4c3d8300bc2d8c0cbe8bb84b77ca7c82cdd.27loOLbRLwOF7dws2J2thcoZDUDx-_IMP8Ob-nGXxrk
+ scenes-app-inbox-pullrequestdiffview--truncated--dark:
+ hash: v1.k794b7964.1e2e9e56c222e92ab274b52918a348fc47cb5e882b88dc6f36c903c49e21a887.ALrlAbPYXmJMZmkSFjmK9wSL5U6omag62rWMzzLF_yM
+ scenes-app-inbox-pullrequestdiffview--truncated--light:
+ hash: v1.k794b7964.fb773b4c098b2f55cb393d1b9af9051deea9eee9a830940209e388ba916c01d4.kS1w3ZNx__r01yrTZZy7XXog7oqnDTDdJtfBBhnp4pk
scenes-app-inbox-scene--empty--dark:
hash: v1.k794b7964.0730c341122d1d593f4e6acf7a176e05bdd79e9ca6bf5f785a909fd57ad274f1.V4Hgc6xF9-5hiq75aqzZWcbiemdqMe3fdbcMqVHbg7U
scenes-app-inbox-scene--empty--light:
diff --git a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts b/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts
index 81b215755ca8..b97efeabfe56 100644
--- a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts
+++ b/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts
@@ -454,6 +454,50 @@ export function mockRunLog(): string {
return JSON.stringify(entry)
}
+/**
+ * A realistic multi-file unified diff for the `commit` artefact diff endpoint, matching the mocked
+ * "fix invites" commit. Two TypeScript files so the rendered diff exercises Pierre's syntax
+ * highlighting, hunk headers, and a multi-file layout.
+ */
+export function mockBranchDiff(): { diff: string; truncated: boolean } {
+ const diff = `diff --git a/frontend/src/scenes/invites/inviteLogic.ts b/frontend/src/scenes/invites/inviteLogic.ts
+index 1a2b3c4..5d6e7f8 100644
+--- a/frontend/src/scenes/invites/inviteLogic.ts
++++ b/frontend/src/scenes/invites/inviteLogic.ts
+@@ -42,9 +42,13 @@ export const inviteLogic = kea<inviteLogicType>([
+ listeners(({ values, actions }) => ({
+ submitInvites: async () => {
+- const recipients = values.invites
++ const recipients = values.invites.filter((invite) => invite.email.trim().length > 0)
++ if (recipients.length === 0) {
++ lemonToast.error('Add at least one recipient before sending invites.')
++ return
++ }
+ await api.invites.bulkCreate(recipients)
+ actions.loadInvites()
+ },
+ })),
+diff --git a/frontend/src/scenes/invites/InviteRow.tsx b/frontend/src/scenes/invites/InviteRow.tsx
+index 9c8b7a6..2f3e4d5 100644
+--- a/frontend/src/scenes/invites/InviteRow.tsx
++++ b/frontend/src/scenes/invites/InviteRow.tsx
+@@ -10,7 +10,7 @@ export function InviteRow({ invite, onChange }: InviteRowProps): JSX.Element {
+ return (
+ <div className="flex items-center gap-2">
+ <LemonInput
+- value={invite.email}
++ value={invite.email}
++ status={invite.email.trim() ? undefined : 'danger'}
+ onChange={(email) => onChange({ ...invite, email })}
+ placeholder="[email protected]"
+ />
+ </div>
+ )
+ }
+`
+ return { diff, truncated: false }
+}
+
export const mockSourceConfigs = {
results: [
{
diff --git a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
index 81c879bb6cda..50eb4e87cdb9 100644
--- a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
@@ -29,7 +29,7 @@ import { SignalCard } from '../../SignalCard'
import { SignalReport, SignalReportStatus } from '../../types'
import { deriveHeadline, parsePrRepoSlug, parsePrUrlParts } from '../../utils/reportPresentation'
import { getSourceProductMeta } from '../badges/sourceProductIcons'
-import { DetailSection, RightColumnSection } from './DetailSection'
+import { DetailSection } from './DetailSection'
import { ReportActivitySection } from './ReportActivitySection'
import { ReportDetailBadges } from './ReportDetail'
import { ReportTasksSection } from './ReportTasksSection'
@@ -336,7 +336,7 @@ export function AgentRunDetail({ report }: { report: SignalReport }): JSX.Elemen
<div className="flex flex-col min-w-0 gap-5">
{evidenceCount > 0 && (
- <RightColumnSection
+ <DetailSection
icon={<IconSearch />}
title="Evidence so far"
rightSlot={
@@ -357,7 +357,7 @@ export function AgentRunDetail({ report }: { report: SignalReport }): JSX.Elemen
))}
</div>
)}
- </RightColumnSection>
+ </DetailSection>
)}
<ReportTasksSection report={report} />
<ReportActivitySection report={report} />
diff --git a/frontend/src/scenes/inbox/components/detail/DetailSection.tsx b/frontend/src/scenes/inbox/components/detail/DetailSection.tsx
index 1c4ff83b00cb..0335e018b9a4 100644
--- a/frontend/src/scenes/inbox/components/detail/DetailSection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/DetailSection.tsx
@@ -5,30 +5,8 @@ import { IconChevronRight } from '@posthog/icons'
interface DetailSectionProps {
icon: ReactNode
title: string
- rightSlot?: ReactNode
- children: ReactNode
-}
-
-/** Prominent content section with a spanning divider, used for the main column (Summary, Evidence). */
-export function DetailSection({ icon, title, rightSlot, children }: DetailSectionProps): JSX.Element {
- return (
- <div className="flex flex-col gap-3">
- <div className="flex items-center gap-3 min-w-0 cursor-default select-none">
- <div className="flex items-center gap-2 min-w-0">
- <span className="flex shrink-0 items-center text-secondary [&_svg]:size-[0.9375rem]">{icon}</span>
- <span className="truncate font-semibold text-sm text-primary tracking-tight">{title}</span>
- </div>
- <div className="h-px min-w-4 flex-1 bg-border-light" />
- {rightSlot && <div className="shrink-0">{rightSlot}</div>}
- </div>
- <div>{children}</div>
- </div>
- )
-}
-
-interface RightColumnSectionProps {
- icon: ReactNode
- title: string
+ /** Metadata rendered immediately after the title, before the divider (e.g. a branch tag, info icon). */
+ afterTitle?: ReactNode
rightSlot?: ReactNode
children: ReactNode
/** When set, the header toggles the body open/closed. */
@@ -38,47 +16,51 @@ interface RightColumnSectionProps {
}
/**
- * Slim caption header used by sections in the detail-view right column (Runs, Reviewers).
- * Lighter than `DetailSection` so the side column reads as supporting detail. Optionally
- * collapsible — the header becomes a toggle while `rightSlot` stays outside it so its own
- * controls remain clickable.
+ * Content section with an icon + title header and a spanning divider, used throughout the report
+ * detail (Summary, Files changed, Reviewers, Runs, Activity). Optionally collapsible — the header
+ * becomes a toggle while `rightSlot` stays outside it so its own controls remain clickable.
*/
-export function RightColumnSection({
+export function DetailSection({
icon,
title,
+ afterTitle,
rightSlot,
children,
collapsible = false,
defaultCollapsed = false,
-}: RightColumnSectionProps): JSX.Element {
+}: DetailSectionProps): JSX.Element {
const [collapsed, setCollapsed] = useState(defaultCollapsed)
const open = !collapsible || !collapsed
- const caption = (
- <>
- <span className="flex shrink-0 items-center [&_svg]:size-3">{icon}</span>
- <span className="font-medium text-[0.6875rem] uppercase tracking-wider">{title}</span>
- </>
+ const heading = (
+ <div className="flex items-center gap-2 min-w-0">
+ <span className="flex shrink-0 items-center text-secondary [&_svg]:size-[0.9375rem]">{icon}</span>
+ <span className="truncate font-semibold text-sm text-primary tracking-tight">{title}</span>
+ </div>
)
return (
- <div className="flex flex-col gap-2">
- <div className="flex items-center justify-between gap-2 select-none text-tertiary">
- {collapsible ? (
- <button
- type="button"
- aria-expanded={open}
- onClick={() => setCollapsed((c) => !c)}
- className="flex items-center gap-2 rounded text-left transition-colors hover:text-secondary"
- >
- <IconChevronRight
- className={`size-3 shrink-0 transition-transform ${open ? 'rotate-90' : ''}`}
- />
- {caption}
- </button>
- ) : (
- <div className="flex items-center gap-2 cursor-default">{caption}</div>
- )}
+ <div className="flex flex-col gap-3">
+ <div className="flex items-center gap-3 min-w-0 select-none">
+ <div className="flex items-center gap-2 min-w-0">
+ {collapsible ? (
+ <button
+ type="button"
+ aria-expanded={open}
+ onClick={() => setCollapsed((c) => !c)}
+ className="flex items-center gap-1.5 min-w-0 rounded text-left transition-colors hover:text-primary"
+ >
+ <IconChevronRight
+ className={`size-3 shrink-0 text-tertiary transition-transform ${open ? 'rotate-90' : ''}`}
+ />
+ {heading}
+ </button>
+ ) : (
+ heading
+ )}
+ {afterTitle && <div className="shrink-0">{afterTitle}</div>}
+ </div>
+ <div className="h-px min-w-4 flex-1 bg-border-light" />
{rightSlot && <div className="shrink-0">{rightSlot}</div>}
</div>
{open && <div>{children}</div>}
diff --git a/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx b/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx
index 34f2437d090c..3917c93ab896 100644
--- a/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx
+++ b/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx
@@ -6,6 +6,7 @@ import { mswDecorator } from '~/mocks/browser'
import {
makeReport,
mockArtefacts,
+ mockBranchDiff,
mockReviewers,
mockRunLog,
mockSignals,
@@ -30,6 +31,7 @@ const detailMocks = mswDecorator({
200,
mockArtefacts(req.params.reportId as string),
],
+ '/api/projects/:id/signals/reports/:reportId/artefacts/:artefactId/diff/': () => [200, mockBranchDiff()],
'/api/projects/:id/signals/reports/:reportId/signals': (req) => [
200,
{ report: null, signals: mockSignals(req.params.reportId as string, 4) },
diff --git a/frontend/src/scenes/inbox/components/detail/PullRequestDiffPanel.tsx b/frontend/src/scenes/inbox/components/detail/PullRequestDiffPanel.tsx
new file mode 100644
index 000000000000..f794ace3f461
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/PullRequestDiffPanel.tsx
@@ -0,0 +1,68 @@
+import { useValues } from 'kea'
+import { useState } from 'react'
+
+import { IconCode, IconGitBranch } from '@posthog/icons'
+import { LemonSegmentedButton, LemonSkeleton, LemonTag, Tooltip } from '@posthog/lemon-ui'
+
+import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
+import { SignalReport } from '../../types'
+import { CommitContent } from './artefactTypes'
+import { DetailSection } from './DetailSection'
+import { PullRequestDiffView } from './PullRequestDiffView'
+
+const DIFF_STYLE_OPTIONS = [
+ { value: 'unified' as const, label: 'Unified' },
+ { value: 'split' as const, label: 'Split' },
+]
+
+/**
+ * Full-width "Files changed" section: the report's branch diff against the repository default branch,
+ * rendered GitHub-style and read-only. The diff itself is loaded by `inboxReportDetailLogic` (keyed to
+ * the report, cascading off the artefact load) — this component just renders the current state. The
+ * diff reflects the latest `commit` artefact's branch tip, so it tracks the work as the branch moves.
+ */
+export function PullRequestDiffPanel({ report, commit }: { report: SignalReport; commit: CommitContent }): JSX.Element {
+ const { reportDiff, reportDiffError } = useValues(inboxReportDetailLogic({ reportId: report.id, report }))
+ const [diffStyle, setDiffStyle] = useState<'unified' | 'split'>('unified')
+
+ return (
+ <DetailSection
+ icon={<IconCode />}
+ title="Files changed"
+ afterTitle={
+ <Tooltip title={`Comparing ${commit.repository}@${commit.branch} against the default branch`}>
+ <LemonTag type="muted" className="font-mono">
+ <IconGitBranch className="shrink-0" />
+ <span className="truncate">{commit.branch}</span>
+ </LemonTag>
+ </Tooltip>
+ }
+ rightSlot={
+ <LemonSegmentedButton
+ size="small"
+ value={diffStyle}
+ onChange={setDiffStyle}
+ options={DIFF_STYLE_OPTIONS}
+ />
+ }
+ >
+ <div className="flex flex-col gap-3">
+ {reportDiffError ? (
+ <p className="m-0 py-4 text-sm text-danger">{reportDiffError}</p>
+ ) : reportDiff ? (
+ <PullRequestDiffView
+ diff={reportDiff.diff}
+ truncated={reportDiff.truncated}
+ cacheKey={commit.commit_sha}
+ diffStyle={diffStyle}
+ />
+ ) : (
+ <div className="flex flex-col gap-2">
+ <LemonSkeleton className="h-8 w-full" />
+ <LemonSkeleton className="h-24 w-full" />
+ </div>
+ )}
+ </div>
+ </DetailSection>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/PullRequestDiffView.stories.tsx b/frontend/src/scenes/inbox/components/detail/PullRequestDiffView.stories.tsx
new file mode 100644
index 000000000000..3387227ec6fb
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/PullRequestDiffView.stories.tsx
@@ -0,0 +1,64 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { PullRequestDiffView } from './PullRequestDiffView'
+
+type Story = StoryObj<typeof PullRequestDiffView>
+
+const meta: Meta<typeof PullRequestDiffView> = {
+ title: 'Scenes-App/Inbox/PullRequestDiffView',
+ component: PullRequestDiffView,
+ tags: ['autodocs'],
+}
+export default meta
+
+const SAMPLE_DIFF = `diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts
+index 1234567..89abcde 100644
+--- a/frontend/src/lib/utils.ts
++++ b/frontend/src/lib/utils.ts
+@@ -1,6 +1,7 @@
+ export function greet(name: string): string {
+- return 'Hello ' + name
++ // Friendlier greeting
++ return \`Hello, \${name}!\`
+ }
+
+ export const VERSION = '1.0.0'
+diff --git a/README.md b/README.md
+index 0000000..1111111 100644
+--- a/README.md
++++ b/README.md
+@@ -1,3 +1,3 @@
+ # Project
+-Old description.
++New description with more detail.
+
+`
+
+export const Default: Story = {
+ args: {
+ diff: SAMPLE_DIFF,
+ truncated: false,
+ },
+}
+
+export const Split: Story = {
+ args: {
+ diff: SAMPLE_DIFF,
+ truncated: false,
+ diffStyle: 'split',
+ },
+}
+
+export const Truncated: Story = {
+ args: {
+ diff: SAMPLE_DIFF,
+ truncated: true,
+ },
+}
+
+export const Empty: Story = {
+ args: {
+ diff: '',
+ truncated: false,
+ },
+}
diff --git a/frontend/src/scenes/inbox/components/detail/PullRequestDiffView.tsx b/frontend/src/scenes/inbox/components/detail/PullRequestDiffView.tsx
new file mode 100644
index 000000000000..37bbce84b840
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/PullRequestDiffView.tsx
@@ -0,0 +1,131 @@
+import { type ChangeTypes, type FileDiffMetadata, type FileDiffOptions, parsePatchFiles } from '@pierre/diffs'
+import { FileDiff } from '@pierre/diffs/react'
+import { useValues } from 'kea'
+import { ReactNode, useMemo } from 'react'
+
+import { IconArrowRight, IconMinus, IconPencil, IconPlus } from '@posthog/icons'
+import { Tooltip } from '@posthog/lemon-ui'
+
+import { themeLogic } from '~/layout/navigation-3000/themeLogic'
+
+// Shiki bundled themes that read closest to GitHub's diff view; Pierre swaps between them based on
+// `themeType`, which we drive off PostHog's own light/dark state.
+const DIFF_THEME = { light: 'github-light', dark: 'github-dark' } as const
+
+// Pierre's own file header uses a prose-font filename and an unlabelled glyph. We render our own header
+// with a monospace path and a colour-coded, tooltipped status icon so the change type is unambiguous.
+const CHANGE_META: Record<ChangeTypes, { label: string; icon: ReactNode; className: string }> = {
+ new: { label: 'Added', icon: <IconPlus />, className: 'text-success' },
+ deleted: { label: 'Deleted', icon: <IconMinus />, className: 'text-danger' },
+ change: { label: 'Modified', icon: <IconPencil />, className: 'text-secondary' },
+ 'rename-pure': { label: 'Renamed', icon: <IconArrowRight />, className: 'text-secondary' },
+ 'rename-changed': { label: 'Renamed', icon: <IconArrowRight />, className: 'text-secondary' },
+}
+
+/** Our own file header (rendered into Pierre's light-DOM header slot): status icon + monospace path + counts. */
+function FileDiffHeader({ file }: { file: FileDiffMetadata }): JSX.Element {
+ const meta = CHANGE_META[file.type] ?? { label: 'Changed', icon: <IconPencil />, className: 'text-secondary' }
+ let additions = 0
+ let deletions = 0
+ for (const hunk of file.hunks) {
+ additions += hunk.additionLines
+ deletions += hunk.deletionLines
+ }
+ const path = file.prevName ? `${file.prevName} → ${file.name}` : file.name
+
+ return (
+ <div className="flex items-center gap-2 min-w-0 border-b border-primary px-3 py-2">
+ <Tooltip title={meta.label}>
+ <span className={`flex shrink-0 items-center ${meta.className}`}>{meta.icon}</span>
+ </Tooltip>
+ <span className="truncate font-mono text-xs text-secondary" title={path}>
+ {path}
+ </span>
+ <span className="ml-auto flex shrink-0 items-center gap-2 font-mono text-xs tabular-nums">
+ {deletions > 0 && <span className="text-danger">-{deletions}</span>}
+ {additions > 0 && <span className="text-success">+{additions}</span>}
+ </span>
+ </div>
+ )
+}
+
+/**
+ * Read-only, GitHub-style rendering of a unified diff string (the branch-vs-default-branch patch the
+ * backend returns for a `commit` artefact). Each file in the patch is rendered with `@pierre/diffs`,
+ * which gives Shiki syntax highlighting and hunk expansion out of the box; we swap its file header for
+ * our own (`renderCustomHeader`) so it reads in PostHog's visual language. Inspection only — no
+ * commenting. The worker pool is disabled so highlighting runs without a separately-served worker
+ * bundle; diffs are size-bounded by the backend (see `truncated`), so main-thread is fine.
+ */
+export function PullRequestDiffView({
+ diff,
+ truncated,
+ cacheKey,
+ diffStyle = 'unified',
+}: {
+ diff: string
+ truncated: boolean
+ /** Stable prefix for Pierre's render cache — pass the commit sha so re-renders reuse highlighting. */
+ cacheKey?: string
+ /** Unified (stacked) or split (side-by-side) layout, like GitHub's diff view toggle. */
+ diffStyle?: 'unified' | 'split'
+}): JSX.Element {
+ const { isDarkModeOn } = useValues(themeLogic)
+
+ // Distinguish a parse failure from a genuinely empty diff — otherwise both render the same
+ // "no changes" message, hiding from the user that their real changes failed to parse.
+ const [parseFailed, files] = useMemo<[boolean, FileDiffMetadata[]]>(() => {
+ if (!diff.trim()) {
+ return [false, []]
+ }
+ try {
+ return [false, parsePatchFiles(diff, cacheKey).flatMap((patch) => patch.files)]
+ } catch {
+ return [true, []]
+ }
+ }, [diff, cacheKey])
+
+ const options = useMemo<FileDiffOptions<undefined>>(
+ () => ({
+ theme: DIFF_THEME,
+ themeType: isDarkModeOn ? 'dark' : 'light',
+ diffStyle,
+ stickyHeader: true,
+ overflow: 'scroll',
+ }),
+ [isDarkModeOn, diffStyle]
+ )
+
+ if (parseFailed) {
+ return <p className="m-0 text-sm text-danger">Couldn't parse this diff — it may be in an unexpected format.</p>
+ }
+
+ if (files.length === 0) {
+ return <p className="m-0 text-sm text-tertiary">No file changes to display for this branch.</p>
+ }
+
+ return (
+ <div className="flex flex-col gap-3">
+ {files.map((file) => (
+ // Card chrome around each file so the diff sits in PostHog's visual language (bordered,
+ // rounded surface); @pierre/diffs renders the syntax-highlighted body inside.
+ <div
+ key={`${file.name}-${file.cacheKey ?? file.newObjectId ?? ''}`}
+ className="overflow-hidden rounded-lg border border-primary bg-surface-primary"
+ >
+ <FileDiff
+ fileDiff={file}
+ options={options}
+ renderCustomHeader={(fileDiff) => <FileDiffHeader file={fileDiff} />}
+ disableWorkerPool
+ />
+ </div>
+ ))}
+ {truncated ? (
+ <p className="m-0 text-xs text-tertiary italic">
+ Diff truncated — open the pull request in GitHub for the full change.
+ </p>
+ ) : null}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx b/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx
index c71330bb98bc..cb6d407a39bf 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx
@@ -5,7 +5,7 @@ import { IconClockRewind } from '@posthog/icons'
import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
import { SignalReport } from '../../types'
import { ArtefactLogList } from './ArtefactLogList'
-import { RightColumnSection } from './DetailSection'
+import { DetailSection } from './DetailSection'
/**
* The report's chronological work-log: every artefact (judgments, findings, code references, diffs,
@@ -26,7 +26,7 @@ export function ReportActivitySection({ report }: { report: SignalReport }): JSX
const knownTasks = new Map((reportTasks ?? []).map((entry) => [entry.task.id, entry.task]))
return (
- <RightColumnSection
+ <DetailSection
icon={<IconClockRewind />}
title="Activity"
collapsible
@@ -38,6 +38,6 @@ export function ReportActivitySection({ report }: { report: SignalReport }): JSX
}
>
<ArtefactLogList reportId={report.id} artefacts={reportArtefacts} knownTasks={knownTasks} />
- </RightColumnSection>
+ </DetailSection>
)
}
diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
index 2b82b71393db..a2a38a3139fb 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
@@ -1,16 +1,8 @@
import { useValues } from 'kea'
import { ReactNode } from 'react'
-import {
- IconArrowLeft,
- IconCode,
- IconDocument,
- IconEllipsis,
- IconExternal,
- IconPullRequest,
- IconSearch,
-} from '@posthog/icons'
-import { LemonButton, Link, Tooltip } from '@posthog/lemon-ui'
+import { IconArrowLeft, IconDocument, IconEllipsis, IconExternal, IconPullRequest, IconSearch } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { IconLink } from 'lib/lemon-ui/icons'
@@ -27,7 +19,6 @@ import { SignalCard } from '../../SignalCard'
import { InboxTabKey, INBOX_TAB_LABEL, SignalReport, SignalReportStatus, SignalSourceProduct } from '../../types'
import {
displayConventionalCommitTitle,
- ParsedPrUrlParts,
parseConventionalCommitTitle,
parsePrUrlParts,
safeHttpUrl,
@@ -37,7 +28,9 @@ import { SignalReportPriorityBadge } from '../badges/SignalReportPriorityBadge'
import { SignalReportStatusBadge } from '../badges/SignalReportStatusBadge'
import { hasKnownSourceProduct, knownSourceProductEntries, SourceProductIconRow } from '../badges/sourceProductIcons'
import { ConventionalCommitScopeTag } from '../cards/ReportCard'
-import { RightColumnSection } from './DetailSection'
+import { CommitContent } from './artefactTypes'
+import { DetailSection } from './DetailSection'
+import { PullRequestDiffPanel } from './PullRequestDiffPanel'
import { ReportActivitySection } from './ReportActivitySection'
import { ReportDetailAction, useReportDetailActions } from './ReportDetailActions'
import { ReportTasksSection } from './ReportTasksSection'
@@ -238,6 +231,8 @@ interface InboxDetailFrameProps {
summary: { icon: ReactNode; title: string }
/** Extra primary action(s) rendered after the shared report actions. */
primaryAction?: ReactNode
+ /** Full-width section rendered below the two-column overview (the Graphite-style diff). */
+ diffSection?: ReactNode
/** Extra sections (Tasks, Reviewers) – defaults applied by callers. */
children?: ReactNode
}
@@ -253,6 +248,7 @@ export function InboxDetailFrame({
tab,
summary,
primaryAction,
+ diffSection,
children,
}: InboxDetailFrameProps): JSX.Element {
const { reportSignals, reportSignalsLoading, priorityExplanation, actionabilityExplanation } = useValues(
@@ -293,6 +289,56 @@ export function InboxDetailFrame({
onClick: action.onClick,
}))
+ const overviewBody = (
+ <div className="grid grid-cols-1 @5xl:grid-cols-[minmax(0,80ch)_minmax(22rem,1fr)] gap-5">
+ <div className="min-w-0">
+ <DetailSection icon={summary.icon} title={summary.title}>
+ {report.summary ? (
+ <LemonMarkdown
+ className="text-sm text-secondary leading-relaxed break-words [&>*+*]:mt-3 [&_li]:my-1 [&_ul]:my-2 [&_ol]:my-2 [&_h1]:mt-5 [&_h2]:mt-5 [&_h3]:mt-4"
+ disableImages
+ >
+ {report.summary}
+ </LemonMarkdown>
+ ) : (
+ <p className={`text-sm text-tertiary m-0${summaryPending ? ' italic' : ''}`}>
+ No summary yet – an agent is still investigating.
+ </p>
+ )}
+ </DetailSection>
+ </div>
+
+ <div className="flex flex-col min-w-0 gap-5">
+ {/* Pull request (when present) first, then reviewers, evidence, runs, and activity. */}
+ {children}
+ <SuggestedReviewersSection report={report} />
+ {hasEvidence && (
+ <DetailSection
+ icon={<IconSearch />}
+ title="Evidence"
+ rightSlot={
+ <span className="text-[0.6875rem] text-tertiary tabular-nums">
+ {evidenceCount} finding{evidenceCount === 1 ? '' : 's'}
+ </span>
+ }
+ >
+ {reportSignalsLoading && reportSignals === null ? (
+ <EvidenceSkeleton count={evidenceCount} />
+ ) : (
+ <div className="flex flex-col gap-3">
+ {signals.map((signal: SignalNode) => (
+ <SignalCard key={signal.signal_id} signal={signal} />
+ ))}
+ </div>
+ )}
+ </DetailSection>
+ )}
+ <ReportTasksSection report={report} />
+ <ReportActivitySection report={report} />
+ </div>
+ </div>
+ )
+
return (
<div className="@container w-full max-w-[calc(160ch+5rem)] mx-auto px-6 py-5 text-sm">
<div className="flex flex-col gap-3.5 mb-6 pb-5 border-b border-primary">
@@ -365,99 +411,38 @@ export function InboxDetailFrame({
</div>
</div>
- <div className="grid grid-cols-1 @5xl:grid-cols-[minmax(0,80ch)_minmax(22rem,1fr)] gap-5">
- <div className="min-w-0">
- <RightColumnSection icon={summary.icon} title={summary.title}>
- {report.summary ? (
- <LemonMarkdown
- className="text-sm text-secondary leading-relaxed break-words [&>*+*]:mt-3 [&_li]:my-1 [&_ul]:my-2 [&_ol]:my-2 [&_h1]:mt-5 [&_h2]:mt-5 [&_h3]:mt-4"
- disableImages
- >
- {report.summary}
- </LemonMarkdown>
- ) : (
- <p className={`text-sm text-tertiary m-0${summaryPending ? ' italic' : ''}`}>
- No summary yet – an agent is still investigating.
- </p>
- )}
- </RightColumnSection>
- </div>
-
- <div className="flex flex-col min-w-0 gap-5">
- {/* Pull request (when present) first, then reviewers, evidence, and runs. */}
- {children}
- <SuggestedReviewersSection report={report} />
- {hasEvidence && (
- <RightColumnSection
- icon={<IconSearch />}
- title="Evidence"
- rightSlot={
- <span className="text-[0.6875rem] text-tertiary tabular-nums">
- {evidenceCount} finding{evidenceCount === 1 ? '' : 's'}
- </span>
- }
- >
- {reportSignalsLoading && reportSignals === null ? (
- <EvidenceSkeleton count={evidenceCount} />
- ) : (
- <div className="flex flex-col gap-3">
- {signals.map((signal: SignalNode) => (
- <SignalCard key={signal.signal_id} signal={signal} />
- ))}
- </div>
- )}
- </RightColumnSection>
- )}
- <ReportTasksSection report={report} />
- <ReportActivitySection report={report} />
- </div>
+ <div className="flex flex-col gap-8">
+ {overviewBody}
+ {/* Full-width diff below the overview, Graphite-style — always visible, not tabbed away. */}
+ {diffSection}
</div>
</div>
)
}
-/**
- * PR identity banner: the `repoSlug#number` ref, mono, with a PR glyph, linking out to GitHub.
- * Surfaced as the first right-column section when the report has a shipped implementation PR.
- */
-function PullRequestBanner({ prUrl, prRef }: { prUrl: string; prRef: ParsedPrUrlParts }): JSX.Element {
- return (
- <Link
- to={prUrl}
- target="_blank"
- disableClientSideRouting
- className="group flex items-center gap-3 rounded border border-primary bg-surface-primary px-4 py-3 no-underline text-inherit transition-colors duration-150 hover:border-primary hover:bg-surface-secondary"
- >
- <span className="flex items-center justify-center size-7 shrink-0 rounded-full bg-success-highlight text-success">
- <IconPullRequest className="text-base" />
- </span>
- <span className="font-mono text-[13px] text-primary truncate">
- {prRef.repoSlug}#{prRef.number}
- </span>
- <Tooltip title="Open in GitHub">
- <span className="shrink-0 text-tertiary transition-colors group-hover:text-default">
- <IconExternal className="text-base" />
- </span>
- </Tooltip>
- </Link>
- )
-}
-
-/**
- * Unified report detail for Pull requests / Reports / Not actionable. The PR banner +
- * "Open in GitHub" action surface only when the report has a shipped implementation PR;
- * otherwise it reads as a plain report. Runs keep their own `AgentRunDetail`.
- */
/** Point a PR URL at its diff/files tab, without double-appending if it's already there. */
function prFilesUrl(prUrl: string): string {
return prUrl.replace(/\/+$/, '').replace(/(\/files)?$/, '/files')
}
+/**
+ * Unified report detail for Pull requests / Reports / Not actionable. The "Open in GitHub" action
+ * surfaces only when the report has a shipped implementation PR; otherwise it reads as a plain
+ * report. When the report has a "Commit pushed" artefact, a full-width "Files changed" section at the
+ * bottom renders the branch's diff against the default branch. Runs keep their own `AgentRunDetail`.
+ */
export function ReportDetail({ report, tab }: { report: SignalReport; tab: InboxTabKey }): JSX.Element {
+ const { latestCommitArtefact } = useValues(inboxReportDetailLogic({ reportId: report.id, report }))
+
const prUrl = safeHttpUrl(report.implementation_pr_url)
const prRef = prUrl ? parsePrUrlParts(prUrl) : null
const hasPr = !!(prRef && prUrl)
+ // The report's branch to diff comes from the latest "Commit pushed" artefact; only offer the diff
+ // tab when that artefact carries the repo + branch the diff endpoint needs.
+ const commit = latestCommitArtefact ? (latestCommitArtefact.content as CommitContent) : null
+ const canDiff = !!(commit?.repository && commit?.branch)
+
return (
<InboxDetailFrame
report={report}
@@ -477,12 +462,11 @@ export function ReportDetail({ report, tab }: { report: SignalReport; tab: Inbox
</LemonButton>
) : undefined
}
- >
- {hasPr ? (
- <RightColumnSection icon={<IconCode />} title="Diff">
- <PullRequestBanner prUrl={prFilesUrl(prUrl)} prRef={prRef} />
- </RightColumnSection>
- ) : null}
- </InboxDetailFrame>
+ diffSection={
+ canDiff && commit && latestCommitArtefact ? (
+ <PullRequestDiffPanel report={report} commit={commit} />
+ ) : undefined
+ }
+ />
)
}
diff --git a/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx b/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
index c7205494aece..2a70194c8ed2 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
@@ -9,7 +9,7 @@ import { TaskRunStatus } from 'products/posthog_ai/frontend/types/taskTypes'
import { inboxReportDetailLogic, ReportTaskEntry } from '../../logics/inboxReportDetailLogic'
import { SignalReport } from '../../types'
-import { RightColumnSection } from './DetailSection'
+import { DetailSection } from './DetailSection'
import { TaskRunStatusDot } from './taskRunDisplay'
/**
@@ -24,12 +24,12 @@ export function ReportTasksSection({ report }: { report: SignalReport }): JSX.El
if (reportTasksLoading && !reportTasks) {
return (
- <RightColumnSection icon={<IconTerminal />} title="Runs">
+ <DetailSection icon={<IconTerminal />} title="Runs">
<div className="flex items-center gap-2 text-xs text-tertiary py-1">
<Spinner className="size-3" />
Loading runs…
</div>
- </RightColumnSection>
+ </DetailSection>
)
}
@@ -38,13 +38,13 @@ export function ReportTasksSection({ report }: { report: SignalReport }): JSX.El
}
return (
- <RightColumnSection icon={<IconTerminal />} title="Runs">
+ <DetailSection icon={<IconTerminal />} title="Runs">
<div className="flex flex-col gap-0.5">
{reportTasks.map((entry: ReportTaskEntry) => (
<TaskRow key={entry.task.id} entry={entry} reportId={report.id} report={report} />
))}
</div>
- </RightColumnSection>
+ </DetailSection>
)
}
diff --git a/frontend/src/scenes/inbox/components/detail/SuggestedReviewersSection.tsx b/frontend/src/scenes/inbox/components/detail/SuggestedReviewersSection.tsx
index 6a706652db02..6e84f387bbfb 100644
--- a/frontend/src/scenes/inbox/components/detail/SuggestedReviewersSection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/SuggestedReviewersSection.tsx
@@ -12,7 +12,7 @@ import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
import { EnrichedReviewer, SignalReport } from '../../types'
const MAX_VISIBLE_REVIEWERS = 5
-import { RightColumnSection } from './DetailSection'
+import { DetailSection } from './DetailSection'
import {
AvailableReviewerOption,
getReviewerOptionDisplayName,
@@ -105,16 +105,18 @@ export function SuggestedReviewersSection({ report }: { report: SignalReport }):
}
return (
- <RightColumnSection
+ <DetailSection
icon={<IconPeople />}
title="Reviewers"
+ afterTitle={
+ <Tooltip title="Suggested reviewers are tracked in PostHog. To request a review on GitHub, add them on the pull request directly.">
+ <span className="-m-1 flex cursor-help items-center p-1 text-base text-tertiary">
+ <IconInfo />
+ </span>
+ </Tooltip>
+ }
rightSlot={
<div className="flex items-center gap-2">
- <Tooltip title="Suggested reviewers are tracked in PostHog. To request a review on GitHub, add them on the pull request directly.">
- <span className="-m-1 flex cursor-help items-center p-1 text-base text-tertiary">
- <IconInfo />
- </span>
- </Tooltip>
{isUpdatingReviewers && <Spinner className="size-3" />}
<LemonDropdown
visible={addOpen}
@@ -221,7 +223,7 @@ export function SuggestedReviewersSection({ report }: { report: SignalReport }):
)}
</div>
)}
- </RightColumnSection>
+ </DetailSection>
)
}
diff --git a/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts b/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
index 1eaa863e9dea..9f64aa3bfb93 100644
--- a/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
+++ b/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
@@ -5,9 +5,12 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { SignalNode } from 'scenes/debug/signals/types'
+import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
import { Task, TaskRunStatus } from 'products/posthog_ai/frontend/types/taskTypes'
+import { signalsReportArtefactsDiff } from 'products/signals/frontend/generated/api'
+import type { CommitDiffResponseApi } from 'products/signals/frontend/generated/api.schemas'
import {
deriveTaskPurpose,
@@ -199,6 +202,22 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
},
},
],
+ // The report's branch diff (its `commit` artefact's branch vs the repo default branch), rendered
+ // in the "Files changed" section. Loaded here rather than in the component so the fetch is keyed
+ // to the report and cascades off the artefact load — once artefacts resolve we know the latest
+ // commit artefact, and re-fetch only when a *new* commit lands (not on every 5s activity poll).
+ reportDiff: [
+ null as CommitDiffResponseApi | null,
+ {
+ loadReportDiff: async ({ artefactId }: { artefactId: string }) => {
+ const teamId = teamLogic.values.currentTeamId
+ if (!teamId) {
+ return null
+ }
+ return await signalsReportArtefactsDiff(String(teamId), props.reportId, artefactId)
+ },
+ },
+ ],
})),
reducers({
@@ -236,6 +255,25 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
setReport: () => [],
},
],
+ // Human-readable diff-load failure (kea-loaders only exposes a boolean loading flag). A failed
+ // compare usually means the branch was merged, deleted, or force-rewritten away.
+ reportDiffError: [
+ null as string | null,
+ {
+ loadReportDiff: () => null,
+ loadReportDiffSuccess: () => null,
+ loadReportDiffFailure: () =>
+ "Couldn't load the diff — the branch may have been merged, deleted, or rewritten.",
+ },
+ ],
+ // The commit artefact the current `reportDiff` was loaded for, so the artefact poll re-fetches
+ // the diff only when a new commit lands rather than on every tick.
+ diffArtefactId: [
+ null as string | null,
+ {
+ loadReportDiff: (_, { artefactId }) => artefactId,
+ },
+ ],
}),
selectors({
@@ -259,6 +297,19 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
(s) => [s.report],
(report: SignalReport | null): boolean => (report ? ACTIVE_STATUSES.includes(report.status) : false),
],
+ // The most recent `commit` artefact — its branch is treated as the report's branch to diff
+ // against the repository default branch. A report's code work may span several pushes; the
+ // latest commit's branch tip is the current state worth inspecting.
+ latestCommitArtefact: [
+ (s) => [s.reportArtefacts],
+ (reportArtefacts: SignalReportArtefact[] | null): SignalReportArtefact | null => {
+ const commits = (reportArtefacts ?? []).filter((a) => a.type === 'commit')
+ if (commits.length === 0) {
+ return null
+ }
+ return commits.reduce((latest, a) => (a.created_at > latest.created_at ? a : latest))
+ },
+ ],
// Rationale behind the priority / actionability judgments, pulled from the already-loaded artefacts.
priorityExplanation: [
(s) => [s.reportArtefacts],
@@ -389,9 +440,14 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
},
// The artefact log is the single source for the activity timeline AND the task associations,
// so deriving the linked tasks hangs off each successful artefact load rather than issuing a
- // second identical fetch.
+ // second identical fetch. The branch diff also cascades from here (once artefacts resolve we
+ // know the latest commit artefact), but only re-fetches when a *new* commit lands.
loadReportArtefactsSuccess: () => {
actions.loadReportTasks()
+ const commit = values.latestCommitArtefact
+ if (commit && commit.id !== values.diffArtefactId) {
+ actions.loadReportDiff({ artefactId: commit.id })
+ }
},
// Poll the artefact log only while the report is active; stop once it reaches a terminal status
// (or is unloaded). Tasks are re-derived via `loadReportArtefactsSuccess`. Mirrors desktop
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8fe1f35fadfb..e652e2056a8f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -537,6 +537,9 @@ importers:
'@monaco-editor/react':
specifier: 4.7.0
+ '@pierre/diffs':
+ specifier: 1.2.11
'@posthog/brand':
specifier: 'catalog:'
version: 0.3.0([email protected])
@@ -9634,6 +9637,36 @@ packages:
peerDependencies:
'@parcel/core': ^2.16.4
+ '@pierre/[email protected]':
+ resolution: {integrity: sha512-lSkl5C7eb8Zq7Ote0+J5ZdVOlI72r2EU3vW4+06wULSQqkIMP8mkxG70lVj593b1XYlsM2hCvuyt0cKTA96plQ==}
+ peerDependencies:
+ react: 18.3.1
+ react-dom: 18.3.1
+
+ '@pierre/[email protected]':
+ resolution: {integrity: sha512-sWHv11TMoqKxKDgTIk5VbhQjdPhs8DCcBxbjh3mRlS3YOM/OcrWoGX6MM8eBGn9cUu3M46Py0JnxsG2nJaFTuA==}
+ engines: {vscode: ^1.0.0}
+
+ '@pierre/[email protected]':
+ resolution: {integrity: sha512-1thlEtJbqdyLzc1ZS2KQa1q7FzDGHT4dTEdKHoyQjOMeWWOmbVG5/ndEfOKfAb5Fzkz8cNJrOjFLiZoDH/A03A==}
+ peerDependencies:
+ '@pierre/theme': ^1.0.0
+ '@shikijs/themes': ^3.0.0 || ^4.0.0
+ react: 18.3.1
+ react-dom: 18.3.1
+ shiki: ^3.0.0 || ^4.0.0
+ peerDependenciesMeta:
+ '@pierre/theme':
+ optional: true
+ '@shikijs/themes':
+ optional: true
+ react:
+ optional: true
+ react-dom:
+ optional: true
+ shiki:
+ optional: true
+
resolution: {integrity: sha512-nezytU2pw587fQstUu1AsJZDVEynjskwOL+kibwcdxsMBFqPsFFNA7xl0ii/gXuDi6M0xj3mfRJj8pBSc2jCfA==}
@@ -10587,18 +10620,50 @@ packages:
react:
optional: true
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-EooU3i9F6IAE8kEu+AnGf9DFZWkQBZ+hJn3tLVbsH+61mtQiva5biai66fAA6nvFPXkLgvrh7BrR7YcJU83xQQ==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-hTv/KiFf2tpiqlACPiztGGurEARWIutB8YUhcrA1pUC7VzzwKO+g5crUocrLztrZ5ro5Z4hbXg7bYclETn3gSQ==}
+ engines: {node: '>=20'}
+
'@shikijs/[email protected]':
resolution: {integrity: sha512-1nWINwKXxKKLqPibT5f4pAFLej9oZzQTsby8942OTlsJzOBZ0MWKiwzMsd+jhzu8YPCHAswGnnN1YtQfirL35g==}
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-1vMdN3gHfnKfLYwecUI2ITJI4RhHt96xEaJumVn7Heb0IlJ8WQMIH0Voak+2j22BpSNKdnOfB/pCTPnPm2gq7A==}
+ engines: {node: '>=20'}
+
'@shikijs/[email protected]':
resolution: {integrity: sha512-2Ep4W3Re5aB1/62RSYQInK9mM3HsLeB91cHqznAJMuylqjzNVAVCMnNWRHFtcNHXsoNRayP9z1qj4Sq3nMqYXg==}
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-rnlqFbBRSys9bT4gl/5rw9RnS0W/I84ZldXPkO7cvlEMoV85TyF/aU01N7/NbSR776RNLjrJKjfFUXJR6wN1Cg==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-CPkz64PTa5diRW1ggzMZH9VM/du4RNChYgVtgqrFcgruvIybmCvySv8GkiHSczUHXYuuR8TdKEwFx+UnZMpgdg==}
+ engines: {node: '>=20'}
+
'@shikijs/[email protected]':
resolution: {integrity: sha512-5qySYa1ZgAT18HR/ypENL9cUSGOeI2x+4IvYJu4JgVJdizn6kG4ia5Q1jDEOi7gTbN4RbuYtmHh0W3eccOrjMA==}
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-Avgt05YiT+Y3prjIc9lmQxhJzHBcCfR6cjiFW4OyaMBbt2A6trX5rfjUzx+Vj/mE9qpArYjatnqo9XPjQNW/AQ==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-5/elhJEcUrxdyQ95SSx0HzrnbzVPuipk6TYiXZL67tHhw8J+4N5shzmrTYyCaudiSnpuuwPdpaVtciwRFwSA7A==}
+ engines: {node: '>=20'}
+
'@shikijs/[email protected]':
resolution: {integrity: sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ==}
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-oc8b9U2SYvofKZk8e/737nIX0qwf6eV2vHFATeObAu7r+mUVpLs8Re0BmVkIjAWAYgkmG/CzLNo7rzuBzRu/wQ==}
+ engines: {node: '>=20'}
+
'@shikijs/[email protected]':
resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
@@ -14765,6 +14830,10 @@ packages:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
+ resolution: {integrity: sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==}
+ engines: {node: '>=0.3.1'}
+
resolution: {integrity: sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==}
engines: {node: '>=0.3.1'}
@@ -17705,6 +17774,9 @@ packages:
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg==}
+
resolution: {integrity: sha512-4LjoFv2eEPwYDPg/CUdBJQSDfPyzXCRrVW1X7jrx/trgxnxkHFjnVZINbzvzxjN70dxychOfg+FTYwBiS3pQ5A==}
peerDependencies:
@@ -18547,6 +18619,12 @@ packages:
resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==}
+
+ resolution: {integrity: sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==}
+
resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==}
engines: {node: '>=18'}
@@ -20193,6 +20271,15 @@ packages:
resolution: {integrity: sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg==}
+ resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==}
+
+ resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==}
+
+ resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==}
+
resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==}
engines: {node: '>= 0.4'}
@@ -20650,6 +20737,10 @@ packages:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-NKKjWzR6LIGL3sXBrWDw9sDS9cxx42/DkysaNqJEeOWE8Kix5gpak0bc00OfDVEO4oyXSyz8+aRaqKoBD1yo7A==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==}
engines: {node: '>= 0.4'}
@@ -21941,8 +22032,8 @@ packages:
resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==}
engines: {node: '>= 10.0.0'}
- resolution: {integrity: sha512-tHPy3gZ+31XdhMpVqugfnDxUjpQwYN+LENEa5L+dJCCQ+ECFUTtqae/lrOCWeRwa3kVfFmOG/RjHHpZeDI+axg==}
+ resolution: {integrity: sha512-IAAk7vf2Hp4VkhIuVtYPVz6B0ez41e0+nfm6rYXleEhMT4P6UHTuH64iNYIdt2b3mxWzzfttyhVU4HWDa6xIYQ==}
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
@@ -29462,6 +29553,30 @@ snapshots:
transitivePeerDependencies:
- napi-wasm
+ dependencies:
+ '@pierre/theme': 1.0.3
+ '@shikijs/transformers': 4.3.0
+ diff: 8.0.3
+ hast-util-to-html: 9.0.5
+ lru_map: 0.4.1
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ shiki: 4.3.0
+ transitivePeerDependencies:
+ - '@shikijs/themes'
+
+ '@pierre/[email protected]': {}
+
+ optionalDependencies:
+ '@pierre/theme': 1.0.3
+ '@shikijs/themes': 4.3.0
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ shiki: 4.3.0
+
'@pixi/[email protected]': {}
@@ -30416,24 +30531,67 @@ snapshots:
'@types/react': 18.3.27
react: 18.3.1
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/primitive': 4.3.0
+ '@shikijs/types': 4.3.0
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.4
+ hast-util-to-html: 9.0.5
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.3.0
+ '@shikijs/vscode-textmate': 10.0.2
+ oniguruma-to-es: 4.3.6
+
'@shikijs/[email protected]':
dependencies:
'@shikijs/types': 3.23.0
'@shikijs/vscode-textmate': 10.0.2
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.3.0
+ '@shikijs/vscode-textmate': 10.0.2
+
'@shikijs/[email protected]':
dependencies:
'@shikijs/types': 3.23.0
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.3.0
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.3.0
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.4
+
'@shikijs/[email protected]':
dependencies:
'@shikijs/types': 3.23.0
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.3.0
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/core': 4.3.0
+ '@shikijs/types': 4.3.0
+
'@shikijs/[email protected]':
dependencies:
'@shikijs/vscode-textmate': 10.0.2
'@types/hast': 3.0.4
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.4
+
'@shikijs/[email protected]': {}
'@sideway/[email protected]':
@@ -35359,6 +35517,8 @@ snapshots:
+
@@ -39807,6 +39967,8 @@ snapshots:
+
dependencies:
react: 18.3.1
@@ -41000,6 +41162,14 @@ snapshots:
dependencies:
mimic-function: 5.0.1
+
+ dependencies:
+ oniguruma-parser: 0.12.2
+ regex: 6.1.0
+ regex-recursion: 6.0.2
+
dependencies:
default-browser: 5.5.0
@@ -42825,7 +42995,7 @@ snapshots:
dependencies:
react: 18.3.1
- unlayer-types: 1.439.0
+ unlayer-types: 1.440.0
dependencies:
@@ -43099,6 +43269,16 @@ snapshots:
dependencies:
'@babel/runtime': 7.29.2
+ dependencies:
+ regex-utilities: 2.3.0
+
+
+ dependencies:
+ regex-utilities: 2.3.0
+
dependencies:
call-bind: 1.0.8
@@ -43640,6 +43820,17 @@ snapshots:
+ dependencies:
+ '@shikijs/core': 4.3.0
+ '@shikijs/engine-javascript': 4.3.0
+ '@shikijs/engine-oniguruma': 4.3.0
+ '@shikijs/langs': 4.3.0
+ '@shikijs/themes': 4.3.0
+ '@shikijs/types': 4.3.0
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.4
+
dependencies:
es-errors: 1.3.0
@@ -45145,7 +45336,7 @@ snapshots: