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): render the report artefact log in the cloud inbox (#65431)

Oliver Browne2f01bd674a6a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 332f7af33b95..f4fd2a42da65 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5469,29 +5469,29 @@ snapshots:
scenes-app-inbox-cards--skeleton--light:
hash: v1.k794b7964.24c19ab5df1e4ccb843b1ad726752e3a98aeadaa08595e66cb4b41aff1a9e9a1.Y3z44tkU4jsAYUyXxfl72fTuZ0MKA6_S6TTNCKt5jSg
scenes-app-inbox-detail--pull-request--dark:
- hash: v1.k794b7964.ac67048b0e7c3f4cf29e4b38823e3f995365fa7e541c59b308e92c1601a74742.fiRwUgQNIN7pBQOGzA2LTx2xd8dd7VfP985Mj7yBnXE
+ hash: v1.k794b7964.abb638b060300d12ddee995e5914fa10d39229558de7a8bf7490e5e2336143b1.i8u20UuA-aUOVPye5eaxeJOkl2LNIqVxqEt5x0thK_Q
scenes-app-inbox-detail--pull-request--light:
- hash: v1.k794b7964.a14ee8b2c4ee70239ec88c9d21cd8aca7e9b6e307b781976bd32155e5b597a8a.Jm0mMI-maDHgsb5C3ab56b178lZzqkRx9lbgqPmLtIo
+ hash: v1.k794b7964.f596ecf775dc2c15a9c9f3d2f880e50d4b0b4b51504089320b295335e2190ed7.lVjDufutx1EJPSC7KOiB5CLpSpe7LLajzKYAqIePht4
scenes-app-inbox-detail--report--dark:
- hash: v1.k794b7964.259f8ed5e3c1a493c90abb64ef41d96e3b9f8e94b9877c00ddc8f7835cfc6cdb.eHbLktOiH9NmNXvlX71F2d9_PyLdZg3xBCy8xfmLVRE
+ hash: v1.k794b7964.c41c6eaacd590b83aef8d6fdeac589d2564740e6abc13a63d7cc5e32d523b48c.VSRf6aX5xB84ZVEyp2uHWZxMENFfMHxO43e2PY5dTF0
scenes-app-inbox-detail--report--light:
- hash: v1.k794b7964.3866cb389c9dff632666c161c4dddd54838ec887131000ba060ea3a2156508fc.tlYIYqScTAQ9jVxsTvhiUyUT3sn8ZSdJWZ59eoiPIFU
+ hash: v1.k794b7964.1a91db030413d628d124fb5e0b787cab8ef865b74c5e34b93fa2fe5e59f22bc6.gUxHN25uyq6dzesvlJOLEKbFMZMUFw6p7mx83cBmLCc
scenes-app-inbox-detail--report-minimal--dark:
- hash: v1.k794b7964.33771cbe5dc0cb90c1a962dad910cf88807369236f3de09c711aa8e0e753642f.fn5ipDgqRJStxC4p-SBQc7yCuIoCQoIFUe7pecuTtCs
+ hash: v1.k794b7964.b62a4b261f03621b3c673572d0625e5d7849adf694fb4423086f74469e043414.YyuYFTT-yAKVwZpFjGu4AlMoRB10iFsklo1-ZZoS8J0
scenes-app-inbox-detail--report-minimal--light:
- hash: v1.k794b7964.8d3708d246d553b9d29d028f8ea7804c7ab9e33ebc6b2cddaaaa6f12d3dc1cfe.BW5bHBxSPVtSfQXDtTuZT5aEK4T-HzsJLzA2qhmRpVE
+ hash: v1.k794b7964.208a8797a503c49ce990dbc1d2311076f9d0a79405a11c33ffa3c142c46b8802.VS4_ToMckLQZXPu0QQBpRTBIQvnEdBGYu1lbHH-aDjU
scenes-app-inbox-detail--run-failed--dark:
- hash: v1.k794b7964.24a6a48235fc55e744f38faacb816d25379dfcb367726e9444d21d6e282145c6.XzXgb6YX-JIB-e71TaHj8jg8pc4xKfRybxgMK21e0C0
+ hash: v1.k794b7964.4631a330dcd36a55470a795a7fee35267c833ded9ba3355393391d4fad5995dd.Vou4U7RpSio3B7pZOpOtQ1tjGbWsEtArxWhC7j4p6aw
scenes-app-inbox-detail--run-failed--light:
- hash: v1.k794b7964.fd1cf8b6b12d828c5b84125bc64772ec23b0dac271ac42dc15fbd2e62956a3df.arjDseHyj4xrBHxKYt6x9s6jVnuF0sCPV5E_ZCzxb94
+ hash: v1.k794b7964.ef1a58753fe93c4452304281281bf94c4ca94cc1e22ab43e1e9242777fe9eec3.p1SlnoJWZjIvVS7_ENAGHZzUzX4oowa1uaAKC6J-iSs
scenes-app-inbox-detail--run-in-progress--dark:
- hash: v1.k794b7964.71b8c2315eaa8979c6abaf6de556baf1cb3139b8242f28016d60677f96340ec2.xuALS0wXmge0BuTvAouSfeIKZE_GZ8NmR-MhgAlTqyo
+ hash: v1.k794b7964.afb91fa62aac61d0f826082a8d2ffc10da141995a9caf3eb3cd3161c23733883._j0kYRPHD-17iVLpGt8MCw7AzO7gS9xhLjeSN9faZJk
scenes-app-inbox-detail--run-in-progress--light:
- hash: v1.k794b7964.c61995970036807317d228804325d6a542b468b690c375e91aa7cfe6767eb4d1.4e2PI0ItsnDkrBsk4ugLLLytmATlnTUE2Uf4qJtBXJc
+ hash: v1.k794b7964.71415cd63c30734a7853ae071ad1d4d924371ae236f9cc35a3e37bd2c1ee4c24.TL_hBUbUm1sm9y86ihIa_lsTXS1701oJlya4DOo_xE4
scenes-app-inbox-detail--run-ready--dark:
- hash: v1.k794b7964.3b9cffcdfe2ff247a8e96e83ad676e1a77b526d45195df95229ac59270619f9f.YPydasQ1CV9EzgOuKfN-JbSX6QtlFwbAsWFYcXNNbyc
+ hash: v1.k794b7964.489e3de0cd98f2dde9a629a3f295dd64917b55f5ee723a6126da336dd36cbddb.mN9an3Ut2ZRcx_ngAFpUobvuNga38KQOuz8i7JNgjxo
scenes-app-inbox-detail--run-ready--light:
- hash: v1.k794b7964.081a81c8b063f2ec4d539da5d37b330aecc970cbb0081defd13256b2d97bba4d.B_97A5t9x5YmeLTqC_tJOSfRzwcJbfURFpWzcTPtc0Q
+ hash: v1.k794b7964.ab7dd7badc02bcaab9fbcfaddb17930eaa8abf9f1936571441296cb9e8cb246f.iZzPaulpiIzqj0r1tcargjZMm5DOxqA3eca-zhEtW84
scenes-app-inbox-scene--empty--dark:
hash: v1.k794b7964.5e028d969ab0fde2b308bbc3bbc78ef671a5892454486d07739b43dd9a11fe2f.-cAwhDDmKAi9Ps2rzFpfUBl7Dc5RaHFxzLfHDR2XJRo
scenes-app-inbox-scene--empty--light:
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 18133db67c2b..a70476d95008 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -19,7 +19,6 @@ import {
SignalReportArtefact,
SignalReportArtefactResponse,
SignalReportStateRequest,
- SignalReportTask,
SignalScoutConfig,
SignalScoutConfigUpdate,
SignalScoutEmission,
@@ -1192,10 +1191,6 @@ export class ApiRequest {
return this.signalReports(teamId).addPathComponent(id)
}
- public signalReportTasks(reportId: SignalReport['id'], teamId?: TeamType['id']): ApiRequest {
- return this.signalReport(reportId, teamId).addPathComponent('tasks')
- }
-
// Per-user signal autonomy config (singleton keyed by user). Not project-scoped.
public signalUserAutonomy(userId: string | '@me' = '@me'): ApiRequest {
return this.addPathComponent('users').addPathComponent(userId).addPathComponent('signal_autonomy')
@@ -5140,10 +5135,6 @@ const api = {
async reingest(id: SignalReport['id']): Promise<{ status: string; report_id: string }> {
return await new ApiRequest().signalReport(id).withAction('reingest').create()
},
- // SignalReport ↔ Task linkage (read-only list). Backend: SignalReportTaskViewSet.
- async tasks(reportId: SignalReport['id']): Promise<PaginatedResponse<SignalReportTask>> {
- return await new ApiRequest().signalReportTasks(reportId).get()
- },
// State transitions: suppress (dismiss) or snooze back to potential. Backend: `state` action.
async setState(id: SignalReport['id'], data: SignalReportStateRequest): Promise<SignalReport> {
return await new ApiRequest().signalReport(id).withAction('state').create({ data })
diff --git a/frontend/src/scenes/inbox/InboxScene.stories.tsx b/frontend/src/scenes/inbox/InboxScene.stories.tsx
index 33d731803557..2c22b5916fac 100644
--- a/frontend/src/scenes/inbox/InboxScene.stories.tsx
+++ b/frontend/src/scenes/inbox/InboxScene.stories.tsx
@@ -5,7 +5,6 @@ import { mswDecorator } from '~/mocks/browser'
import {
allReports,
mockArtefacts,
- mockReportTasks,
mockReviewers,
mockSignals,
mockSourceConfigs,
@@ -32,10 +31,6 @@ const sceneMocks = mswDecorator({
200,
{ report: null, signals: mockSignals(req.params.reportId as string, 4) },
],
- '/api/projects/:id/signals/reports/:reportId/tasks': (req) => [
- 200,
- mockReportTasks(req.params.reportId as string),
- ],
'/api/projects/:id/tasks/:taskId': (req) => [200, mockTask(req.params.taskId as string)],
'/api/projects/:id/signals/source_configs': () => [200, mockSourceConfigs],
'/api/projects/:id/external_data_sources': () => [200, { results: [], count: 0 }],
diff --git a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts b/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts
index c7d116eb8ba5..66e32fe0d0a1 100644
--- a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts
+++ b/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts
@@ -309,30 +309,54 @@ export function mockArtefacts(reportId: string): { results: any[]; count: number
],
created_at: BASE_DATE,
},
- ]
- return { results, count: results.length }
-}
-
-export function mockReportTasks(reportId: string): { results: any[]; count: number; next: null; previous: null } {
- return {
- results: [
- {
- id: `${reportId}-t1`,
- relationship: 'research',
+ // Task↔report associations now live in the artefact log as `task_run` artefacts; the
+ // detail logic derives the Runs list + purpose from these (no more `/tasks/` endpoint).
+ {
+ id: `${reportId}-tr-research`,
+ type: 'task_run',
+ content: {
task_id: `${reportId}-task-research`,
- created_at: BASE_DATE,
+ run_id: `${reportId}-task-research-run`,
+ product: 'signals',
+ type: 'research',
},
- {
- id: `${reportId}-t2`,
- relationship: 'implementation',
+ created_at: BASE_DATE,
+ task_id: `${reportId}-task-research`,
+ },
+ {
+ id: `${reportId}-tr-impl`,
+ type: 'task_run',
+ content: {
task_id: `${reportId}-task-impl`,
- created_at: BASE_DATE,
+ run_id: `${reportId}-task-impl-run`,
+ product: 'signals',
+ type: 'implementation',
},
- ],
- count: 2,
- next: null,
- previous: null,
- }
+ created_at: BASE_DATE,
+ task_id: `${reportId}-task-impl`,
+ },
+ // A handful of log artefacts so the Activity timeline has something to render.
+ {
+ id: `${reportId}-note`,
+ type: 'note',
+ content: { note: 'Confirmed the validation gap reproduces on an empty recipient row.' },
+ created_at: BASE_DATE,
+ created_by: { id: 1, uuid: 'u-1', email: '[email protected]', first_name: 'Octo', last_name: 'Cat' },
+ },
+ {
+ id: `${reportId}-commit`,
+ type: 'commit',
+ content: {
+ repository: 'PostHog/posthog',
+ branch: 'inbox/fix-invites',
+ commit_sha: 'a1b2c3d4e5f6a1b2c3d4e5f6',
+ message: 'fix(invites): reject empty recipient rows before submit',
+ },
+ created_at: BASE_DATE,
+ task_id: `${reportId}-task-impl`,
+ },
+ ]
+ return { results, count: results.length }
}
function makeTaskRun(taskId: string, runId: string, status: string): any {
diff --git a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
index 7dafc3de6b57..d23df59c1e91 100644
--- a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
@@ -30,9 +30,10 @@ import { SignalReport, SignalReportStatus } from '../../types'
import { deriveHeadline, parsePrRepoSlug, parsePrUrlParts } from '../../utils/reportPresentation'
import { getSourceProductMeta } from '../badges/sourceProductIcons'
import { DetailSection, RightColumnSection } from './DetailSection'
+import { ReportActivitySection } from './ReportActivitySection'
import { ReportDetailBadges } from './ReportDetail'
import { ReportTasksSection } from './ReportTasksSection'
-import { RELATIONSHIP_LABEL, TaskRunStatusDot } from './taskRunDisplay'
+import { TaskRunStatusDot } from './taskRunDisplay'
/**
* Ready-state run output: a polished outcome card that links to the produced PR or report,
@@ -270,7 +271,7 @@ function TaskLogSection({ report }: { report: SignalReport }): JSX.Element {
label: (
<span className="flex items-center gap-1.5">
<TaskRunStatusDot status={entry.task.latest_run?.status ?? TaskRunStatus.NOT_STARTED} />
- {RELATIONSHIP_LABEL[entry.relationship]}
+ {entry.purposeLabel}
</span>
),
}))}
@@ -353,6 +354,7 @@ export function AgentRunDetail({ report }: { report: SignalReport }): JSX.Elemen
</RightColumnSection>
)}
<ReportTasksSection report={report} />
+ <ReportActivitySection report={report} />
</div>
</div>
</div>
diff --git a/frontend/src/scenes/inbox/components/detail/ArtefactCommit.tsx b/frontend/src/scenes/inbox/components/detail/ArtefactCommit.tsx
new file mode 100644
index 000000000000..1c472012ea4f
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/ArtefactCommit.tsx
@@ -0,0 +1,109 @@
+import { useValues } from 'kea'
+import { useEffect, useState } from 'react'
+
+import { IconChevronDown, IconChevronRight } from '@posthog/icons'
+import { Spinner } from '@posthog/lemon-ui'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { signalsReportArtefactsDiff } from 'products/signals/frontend/generated/api'
+import type { CommitDiffResponseApi } from 'products/signals/frontend/generated/api.schemas'
+
+import { CommitContent } from './artefactTypes'
+import { DiffBlock } from './DiffBlock'
+
+/**
+ * A `commit` artefact: the message, short sha + repo@branch, and a collapsible "View diff" that
+ * lazily fetches the commit-vs-parent diff from the backend on first expand. Missing / rewritten
+ * commits surface a clean message; oversized diffs show a truncation notice. Mirrors desktop
+ * `ArtefactCommit`.
+ */
+export function ArtefactCommit({
+ reportId,
+ artefactId,
+ content,
+}: {
+ reportId: string
+ artefactId: string
+ content: CommitContent
+}): JSX.Element {
+ const { currentTeamId } = useValues(teamLogic)
+ const [expanded, setExpanded] = useState(false)
+ const [diff, setDiff] = useState<CommitDiffResponseApi | null>(null)
+ const [loading, setLoading] = useState(false)
+ const [error, setError] = useState<string | null>(null)
+
+ // Fetch the diff only once, on first expand — commit diffs are immutable, so there's no reason
+ // to refetch. Keyed on artefactId so a recycled component instance refetches for a new commit;
+ // `currentTeamId` is a dep so a late-arriving team still triggers the fetch once available.
+ useEffect(() => {
+ if (!expanded || diff || loading || error || !currentTeamId) {
+ return
+ }
+ setLoading(true)
+ let cancelled = false
+ signalsReportArtefactsDiff(String(currentTeamId), reportId, artefactId)
+ .then((response) => {
+ if (!cancelled) {
+ setDiff(response)
+ }
+ })
+ .catch(() => {
+ if (!cancelled) {
+ setError("Couldn't load this commit's diff — it may have been rewritten or removed.")
+ }
+ })
+ .finally(() => {
+ if (!cancelled) {
+ setLoading(false)
+ }
+ })
+ return () => {
+ cancelled = true
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [expanded, artefactId, currentTeamId])
+
+ return (
+ <div>
+ <span className="block text-default text-xs">{content.message}</span>
+ <span className="block font-mono text-tertiary text-[11px]">
+ {content.commit_sha.slice(0, 12)} · {content.repository}@{content.branch}
+ </span>
+ {content.note?.trim() ? <span className="block text-secondary text-xs mt-1">{content.note}</span> : null}
+
+ <button
+ type="button"
+ onClick={() => setExpanded((v) => !v)}
+ className="mt-1.5 flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-secondary transition-colors hover:bg-fill-highlight-50"
+ >
+ {expanded ? <IconChevronDown /> : <IconChevronRight />}
+ {expanded ? 'Hide diff' : 'View diff'}
+ </button>
+
+ {expanded ? (
+ <div className="mt-1.5">
+ {loading ? (
+ <div className="flex items-center gap-2 text-[11px] text-tertiary py-1">
+ <Spinner className="size-3" />
+ Fetching diff…
+ </div>
+ ) : error ? (
+ <span className="text-[11px] text-danger">{error}</span>
+ ) : diff && diff.diff.trim() ? (
+ <>
+ <DiffBlock diff={diff.diff} />
+ {diff.truncated ? (
+ <span className="mt-1 block text-[11px] text-tertiary italic">
+ Diff truncated — open the commit in GitHub for the full change.
+ </span>
+ ) : null}
+ </>
+ ) : (
+ <span className="text-[11px] text-tertiary">No changes recorded for this commit.</span>
+ )}
+ </div>
+ ) : null}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsx b/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsx
new file mode 100644
index 000000000000..350b1f2ae077
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsx
@@ -0,0 +1,378 @@
+import { useValues } from 'kea'
+import { useState } from 'react'
+
+import { IconChevronDown, IconChevronRight, IconExternal } from '@posthog/icons'
+import { LemonTag, Link } from '@posthog/lemon-ui'
+
+import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
+import { TZLabel } from 'lib/components/TZLabel'
+import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
+import { capitalizeFirstLetter } from 'lib/utils/strings'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+
+import { Task } from 'products/tasks/frontend/types'
+
+import { EnrichedReviewer, SignalReportActionability, SignalReportPriority, SignalReportArtefact } from '../../types'
+import { SignalReportActionabilityBadge } from '../badges/SignalReportActionabilityBadge'
+import { SignalReportPriorityBadge } from '../badges/SignalReportPriorityBadge'
+import { ArtefactCommit } from './ArtefactCommit'
+import { ArtefactTaskRun } from './ArtefactTaskRun'
+import {
+ artefactAttributionLabel,
+ artefactLocationLabel,
+ artefactTypeLabel,
+ CodeReferenceContent,
+ CommitContent,
+ DismissalContent,
+ LineReferenceContent,
+ NoteContent,
+ SignalFindingContent,
+ TaskRunArtefactContent,
+} from './artefactTypes'
+
+/** Map a file extension to a CodeSnippet language for syntax highlighting; falls back to plain text. */
+function languageFromPath(path: string | undefined): Language {
+ const ext = path?.split('.').pop()?.toLowerCase()
+ switch (ext) {
+ case 'ts':
+ case 'tsx':
+ return Language.TypeScript
+ case 'js':
+ case 'jsx':
+ case 'mjs':
+ case 'cjs':
+ return Language.JavaScript
+ case 'py':
+ return Language.Python
+ case 'go':
+ return Language.Go
+ case 'rb':
+ return Language.Ruby
+ case 'java':
+ return Language.Java
+ case 'kt':
+ return Language.Kotlin
+ case 'php':
+ return Language.PHP
+ case 'cs':
+ return Language.CSharp
+ case 'swift':
+ return Language.Swift
+ case 'sql':
+ return Language.SQL
+ case 'json':
+ return Language.JSON
+ case 'yaml':
+ case 'yml':
+ return Language.YAML
+ case 'sh':
+ case 'bash':
+ return Language.Bash
+ case 'html':
+ case 'xml':
+ return Language.XML
+ default:
+ return Language.Text
+ }
+}
+
+/** Replace dashes/underscores with spaces and capitalize — for enum-ish strings (dismissal reasons). */
+function prettify(value: string): string {
+ return capitalizeFirstLetter(value.replace(/[-_]/g, ' '))
+}
+
+/** A short relevance / context note above a code block. */
+function RelevanceNote({ note }: { note?: string }): JSX.Element | null {
+ if (!note?.trim()) {
+ return null
+ }
+ return <span className="block text-secondary text-xs">{note}</span>
+}
+
+/** A read-only highlighted code block sized for the activity log. */
+function CodeRefBlock({ code, language }: { code: string; language: Language }): JSX.Element {
+ return (
+ <div className="mt-1.5">
+ <CodeSnippet language={language} compact wrap>
+ {code}
+ </CodeSnippet>
+ </div>
+ )
+}
+
+/** Judgment rationale, hidden behind a "Show reasoning" toggle. */
+function CollapsibleReasoning({ text }: { text: string }): JSX.Element {
+ const [expanded, setExpanded] = useState(false)
+ return (
+ <div className="flex flex-col gap-1">
+ <button
+ type="button"
+ onClick={() => setExpanded((v) => !v)}
+ className="flex w-fit items-center gap-1 rounded px-1 py-0.5 text-xs text-secondary transition-colors hover:bg-fill-highlight-50"
+ >
+ {expanded ? <IconChevronDown /> : <IconChevronRight />}
+ {expanded ? 'Hide reasoning' : 'Show reasoning'}
+ </button>
+ {expanded ? <span className="text-secondary text-xs">{text}</span> : null}
+ </div>
+ )
+}
+
+/** A `note` artefact: a one-line preview that expands to the full markdown body. */
+function CollapsibleNote({ note, author }: { note: string; author?: string }): JSX.Element {
+ const [expanded, setExpanded] = useState(false)
+ const preview = note.split('\n').find((line) => line.trim()) ?? note
+ return (
+ <div className="flex w-full min-w-0 flex-col gap-1">
+ <button
+ type="button"
+ onClick={() => setExpanded((v) => !v)}
+ className="flex w-full min-w-0 items-center gap-1 rounded px-1 py-0.5 text-left text-xs text-secondary transition-colors hover:bg-fill-highlight-50"
+ >
+ {expanded ? <IconChevronDown className="shrink-0" /> : <IconChevronRight className="shrink-0" />}
+ <span className="truncate">{expanded ? 'Hide note' : preview}</span>
+ </button>
+ {expanded ? (
+ <div className="min-w-0">
+ <LemonMarkdown className="text-xs text-secondary leading-normal" disableImages>
+ {note}
+ </LemonMarkdown>
+ {author?.trim() ? <span className="mt-1 block text-tertiary text-[11px]">— {author}</span> : null}
+ </div>
+ ) : null}
+ </div>
+ )
+}
+
+/** The suggested-reviewers list as a point-in-time log entry. */
+function ReviewersBody({ reviewers }: { reviewers: EnrichedReviewer[] }): JSX.Element {
+ if (reviewers.length === 0) {
+ return <span className="text-tertiary text-xs">No reviewers assigned.</span>
+ }
+ return (
+ <div className="flex flex-col gap-1">
+ {reviewers.map((reviewer) => {
+ const name = reviewer.user?.first_name || reviewer.github_name || reviewer.github_login
+ return (
+ <div key={reviewer.github_login} className="flex items-center gap-2 text-xs">
+ <img
+ src={`https://github.com/${reviewer.github_login}.png?size=28`}
+ alt=""
+ loading="lazy"
+ className="size-[18px] shrink-0 rounded-full bg-fill-highlight-50"
+ />
+ <span className="truncate text-default">{name}</span>
+ <Link
+ to={`https://github.com/${reviewer.github_login}`}
+ target="_blank"
+ disableClientSideRouting
+ className="ml-auto flex shrink-0 items-center gap-0.5 font-mono text-tertiary text-[11px]"
+ >
+ @{reviewer.github_login}
+ <IconExternal />
+ </Link>
+ </div>
+ )
+ })}
+ </div>
+ )
+}
+
+/** Per-type body for one artefact row. Content is read defensively — legacy rows may lack fields. */
+function ArtefactBody({
+ reportId,
+ artefact,
+ knownTasks,
+}: {
+ reportId: string
+ artefact: SignalReportArtefact
+ knownTasks?: Map<string, Task>
+}): JSX.Element {
+ const content = artefact.content
+
+ switch (artefact.type) {
+ case 'code_reference': {
+ const c = content as CodeReferenceContent
+ return (
+ <div>
+ <RelevanceNote note={c.relevance_note} />
+ {c.contents ? <CodeRefBlock code={c.contents} language={languageFromPath(c.file_path)} /> : null}
+ </div>
+ )
+ }
+ case 'line_reference': {
+ const c = content as LineReferenceContent
+ return (
+ <div>
+ <RelevanceNote note={c.note} />
+ {c.contents ? <CodeRefBlock code={c.contents} language={languageFromPath(c.file_path)} /> : null}
+ </div>
+ )
+ }
+ case 'commit':
+ return <ArtefactCommit reportId={reportId} artefactId={artefact.id} content={content as CommitContent} />
+ case 'task_run': {
+ const c = content as TaskRunArtefactContent
+ return <ArtefactTaskRun content={c} knownTask={knownTasks?.get(c.task_id) ?? null} />
+ }
+ case 'note': {
+ const c = content as NoteContent
+ return <CollapsibleNote note={c.note} author={c.author} />
+ }
+ case 'priority_judgment': {
+ const c = content as { priority?: SignalReportPriority; explanation?: string }
+ return (
+ <div className="flex flex-col gap-1">
+ <SignalReportPriorityBadge priority={c.priority} />
+ {c.explanation ? <CollapsibleReasoning text={c.explanation} /> : null}
+ </div>
+ )
+ }
+ case 'actionability_judgment': {
+ const c = content as {
+ actionability?: SignalReportActionability
+ already_addressed?: boolean
+ explanation?: string
+ }
+ return (
+ <div className="flex flex-col gap-1">
+ <div className="flex items-center gap-2 flex-wrap">
+ <SignalReportActionabilityBadge actionability={c.actionability} />
+ {c.already_addressed ? (
+ <LemonTag size="small" type="warning">
+ Already addressed
+ </LemonTag>
+ ) : null}
+ </div>
+ {c.explanation ? <CollapsibleReasoning text={c.explanation} /> : null}
+ </div>
+ )
+ }
+ case 'safety_judgment': {
+ const c = content as { choice?: boolean; explanation?: string }
+ return (
+ <div className="flex flex-col gap-1">
+ <LemonTag size="small" type={c.choice ? 'success' : 'danger'}>
+ {c.choice ? 'Safe to act on' : 'Unsafe'}
+ </LemonTag>
+ {c.explanation ? <CollapsibleReasoning text={c.explanation} /> : null}
+ </div>
+ )
+ }
+ case 'signal_finding': {
+ const c = content as SignalFindingContent
+ const paths = c.relevant_code_paths ?? []
+ return (
+ <div className="flex flex-col gap-1">
+ <div className="flex items-center gap-2 flex-wrap">
+ <span className="font-mono text-tertiary text-[11px]">{c.signal_id}</span>
+ <LemonTag size="small" type={c.verified ? 'success' : 'muted'}>
+ {c.verified ? 'Verified' : 'Unverified'}
+ </LemonTag>
+ </div>
+ {paths.length > 0 ? (
+ <div className="flex flex-col">
+ {paths.map((path) => (
+ <span key={path} className="truncate font-mono text-secondary text-[11px]">
+ {path}
+ </span>
+ ))}
+ </div>
+ ) : null}
+ </div>
+ )
+ }
+ case 'suggested_reviewers':
+ return <ReviewersBody reviewers={(content as unknown as EnrichedReviewer[]) ?? []} />
+ case 'dismissal': {
+ const c = content as DismissalContent
+ return (
+ <div className="flex flex-col gap-1">
+ {c.reason ? (
+ <LemonTag size="small" type="muted">
+ {prettify(c.reason)}
+ </LemonTag>
+ ) : null}
+ {c.note ? <RelevanceNote note={c.note} /> : null}
+ </div>
+ )
+ }
+ default: {
+ const preview = typeof (content as { content?: unknown })?.content === 'string'
+ return <span className="text-tertiary text-xs">{preview ? String((content as any).content) : ''}</span>
+ }
+ }
+}
+
+/** One log row: a header (type · location · attribution · timestamp) over the per-type body. */
+function ArtefactRow({
+ reportId,
+ artefact,
+ knownTasks,
+}: {
+ reportId: string
+ artefact: SignalReportArtefact
+ knownTasks?: Map<string, Task>
+}): JSX.Element {
+ const { isDev } = useValues(preflightLogic)
+ const [showRaw, setShowRaw] = useState(false)
+ const location = artefactLocationLabel(artefact)
+ const attribution = artefactAttributionLabel(artefact)
+
+ return (
+ <div className="rounded border border-primary bg-surface-primary p-3">
+ <div className="mb-1.5 flex items-center gap-2 min-w-0">
+ <span className="shrink-0 font-semibold text-xs text-default">{artefactTypeLabel(artefact.type)}</span>
+ {location ? <span className="truncate font-mono text-tertiary text-[11px]">{location}</span> : null}
+ <div className="ml-auto flex shrink-0 items-center gap-2">
+ {attribution ? <span className="text-tertiary text-[11px]">by {attribution}</span> : null}
+ {isDev ? (
+ <button
+ type="button"
+ onClick={() => setShowRaw((v) => !v)}
+ className="rounded px-1 font-mono text-tertiary text-[11px] transition-colors hover:bg-fill-highlight-50"
+ title="Toggle raw JSON (dev only)"
+ >
+ {'{ }'}
+ </button>
+ ) : null}
+ <TZLabel time={artefact.created_at} className="text-tertiary text-[11px]" />
+ </div>
+ </div>
+ <ArtefactBody reportId={reportId} artefact={artefact} knownTasks={knownTasks} />
+ {isDev && showRaw ? (
+ <pre className="mt-2 max-h-72 overflow-auto rounded bg-fill-highlight-50 p-2 text-[10px] leading-tight">
+ {JSON.stringify(artefact, null, 2)}
+ </pre>
+ ) : null}
+ </div>
+ )
+}
+
+/**
+ * The report's work-log: every artefact rendered chronologically with a tailored body — judgments,
+ * findings, code references, diffs, commits, task runs, notes, and reviewers. Mirrors desktop
+ * `ArtefactLogList`. Returns null when there are no artefacts.
+ */
+export function ArtefactLogList({
+ reportId,
+ artefacts,
+ knownTasks,
+}: {
+ reportId: string
+ artefacts: SignalReportArtefact[]
+ /** Tasks the detail logic already resolved, keyed by id — `task_run` rows reuse these instead of refetching. */
+ knownTasks?: Map<string, Task>
+}): JSX.Element | null {
+ if (artefacts.length === 0) {
+ return null
+ }
+ const ordered = [...artefacts].sort((a, b) => a.created_at.localeCompare(b.created_at))
+ return (
+ <div className="flex flex-col gap-2">
+ {ordered.map((artefact) => (
+ <ArtefactRow key={artefact.id} reportId={reportId} artefact={artefact} knownTasks={knownTasks} />
+ ))}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx b/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
new file mode 100644
index 000000000000..793dcfcfb556
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
@@ -0,0 +1,115 @@
+import { useEffect, useState } from 'react'
+
+import { IconChevronDown, IconChevronRight } from '@posthog/icons'
+import { LemonTag } from '@posthog/lemon-ui'
+
+import api from 'lib/api'
+import { identifierToHuman } from 'lib/utils/strings'
+import { SandboxRunViewer } from 'scenes/max/sandbox/components/SandboxRunViewer'
+import { isTerminalRunStatus } from 'scenes/max/sandboxStreamLogic'
+
+import { Task, TaskRunStatus } from 'products/tasks/frontend/types'
+
+import { isCustomAgentTaskRun, taskRunTypeLabel, TaskRunArtefactContent } from './artefactTypes'
+import { TaskRunStatusDot } from './taskRunDisplay'
+
+/**
+ * A `task_run` artefact: the linked task badged from its `(product, type)` (signals-pipeline runs
+ * show Research / Implementation / Repo selection; custom agents show their humanized product +
+ * type), expanding to the task's run transcript via the shared `SandboxRunViewer`. Mirrors desktop
+ * `ArtefactTaskRun` (which embeds `TaskLogsPanel`). The task is resolved lazily and the row is
+ * disabled until it loads.
+ */
+export function ArtefactTaskRun({
+ content,
+ knownTask,
+}: {
+ content: TaskRunArtefactContent
+ /** The resolved task, when the detail logic already fetched it (research/implementation runs) —
+ * lets the row skip a redundant `GET /tasks/{id}`. Falls back to a lazy fetch otherwise. */
+ knownTask?: Task | null
+}): JSX.Element {
+ const [expanded, setExpanded] = useState(false)
+ const [fetchedTask, setFetchedTask] = useState<Task | null>(null)
+ const [loading, setLoading] = useState(false)
+ const [error, setError] = useState(false)
+ const task = knownTask ?? fetchedTask
+
+ useEffect(() => {
+ // The detail logic already resolved this task — no need to fetch it again.
+ if (knownTask || !content.task_id) {
+ return
+ }
+ setLoading(true)
+ let cancelled = false
+ api.tasks
+ .get(content.task_id)
+ .then((result) => {
+ if (!cancelled) {
+ setFetchedTask(result)
+ }
+ })
+ .catch(() => {
+ if (!cancelled) {
+ setError(true)
+ }
+ })
+ .finally(() => {
+ if (!cancelled) {
+ setLoading(false)
+ }
+ })
+ return () => {
+ cancelled = true
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [content.task_id, knownTask])
+
+ const status = task?.latest_run?.status ?? TaskRunStatus.NOT_STARTED
+ // Prefer the run the artefact actually recorded; a task that's been re-run has a newer
+ // `latest_run`, so falling back to it would show the wrong transcript. A specific older run has
+ // an unknown status, so force the static replay rather than opening an SSE stream for it.
+ const isHistoricalRun = !!content.run_id && content.run_id !== task?.latest_run?.id
+ const runId = content.run_id ?? task?.latest_run?.id ?? null
+ const replayOnly = isHistoricalRun || isTerminalRunStatus(task?.latest_run?.status)
+ const isCustom = isCustomAgentTaskRun(content)
+
+ if (error) {
+ return <span className="text-[11px] text-danger">Couldn't load this task.</span>
+ }
+
+ return (
+ <div>
+ <button
+ type="button"
+ disabled={!task}
+ onClick={() => setExpanded((v) => !v)}
+ className="flex w-full items-center gap-2 rounded px-1 py-0.5 text-left text-xs transition-colors enabled:hover:bg-fill-highlight-50 disabled:cursor-default"
+ >
+ {expanded ? (
+ <IconChevronDown className="shrink-0 text-tertiary" />
+ ) : (
+ <IconChevronRight className="shrink-0 text-tertiary" />
+ )}
+ <TaskRunStatusDot status={status} />
+ <LemonTag size="small" type="muted">
+ {taskRunTypeLabel(content)}
+ </LemonTag>
+ {isCustom ? (
+ <LemonTag size="small" type="completion">
+ {identifierToHuman(content.product)}
+ </LemonTag>
+ ) : null}
+ <span className="truncate text-secondary">
+ {loading ? 'Loading task…' : (task?.title ?? content.task_id)}
+ </span>
+ </button>
+
+ {expanded && task && runId ? (
+ <div className="mt-2 h-[420px] overflow-hidden rounded border border-primary bg-surface-primary">
+ <SandboxRunViewer taskId={task.id} runId={runId} replayOnly={replayOnly} />
+ </div>
+ ) : null}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/DiffBlock.tsx b/frontend/src/scenes/inbox/components/detail/DiffBlock.tsx
new file mode 100644
index 000000000000..52b9f785580a
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/DiffBlock.tsx
@@ -0,0 +1,32 @@
+import clsx from 'clsx'
+
+/**
+ * Renders a unified diff with add/remove/hunk coloring. Mirrors desktop `DiffBlock`: each line is
+ * classed by its leading character (`+`/`-`/`@@`), with `+++`/`---` file headers treated as context.
+ */
+export function DiffBlock({ diff }: { diff: string }): JSX.Element {
+ const lines = diff.replace(/\n$/, '').split('\n')
+ return (
+ <pre className="max-h-96 overflow-auto rounded border border-primary bg-surface-primary p-2 text-[11px] leading-[1.45] font-mono m-0">
+ {lines.map((line, i) => {
+ const added = line.startsWith('+') && !line.startsWith('+++')
+ const removed = line.startsWith('-') && !line.startsWith('---')
+ const hunk = line.startsWith('@@')
+ return (
+ <span
+ key={i}
+ className={clsx(
+ 'block whitespace-pre',
+ added && 'bg-success-highlight text-success',
+ removed && 'bg-danger-highlight text-danger',
+ hunk && 'text-tertiary',
+ !added && !removed && !hunk && 'text-default'
+ )}
+ >
+ {line === '' ? ' ' : line}
+ </span>
+ )
+ })}
+ </pre>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx b/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx
index cfce5781875a..34f2437d090c 100644
--- a/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx
+++ b/frontend/src/scenes/inbox/components/detail/InboxDetail.stories.tsx
@@ -6,7 +6,6 @@ import { mswDecorator } from '~/mocks/browser'
import {
makeReport,
mockArtefacts,
- mockReportTasks,
mockReviewers,
mockRunLog,
mockSignals,
@@ -35,10 +34,6 @@ const detailMocks = mswDecorator({
200,
{ report: null, signals: mockSignals(req.params.reportId as string, 4) },
],
- '/api/projects/:id/signals/reports/:reportId/tasks': (req) => [
- 200,
- mockReportTasks(req.params.reportId as string),
- ],
'/api/projects/:id/signals/reports/available_reviewers': () => [200, mockReviewers],
// Terminal run status so the inline run viewer replays its static log instead of opening SSE.
'/api/projects/:id/tasks/:taskId': (req) => [200, mockTask(req.params.taskId as string, 'completed')],
diff --git a/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx b/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx
new file mode 100644
index 000000000000..b96e2593063d
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/ReportActivitySection.tsx
@@ -0,0 +1,41 @@
+import { useValues } from 'kea'
+
+import { IconClockRewind } from '@posthog/icons'
+
+import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
+import { SignalReport } from '../../types'
+import { ArtefactLogList } from './ArtefactLogList'
+import { RightColumnSection } from './DetailSection'
+
+/**
+ * The report's chronological work-log: every artefact (judgments, findings, code references, diffs,
+ * commits, task runs, notes, reviewers) rendered as a timeline entry. Reads the artefacts the detail
+ * logic already loads (and polls while the report is active), so it stays in sync with the rest of
+ * the detail view. Hidden entirely until at least one artefact exists. Mirrors desktop
+ * `ReportActivitySection`.
+ */
+export function ReportActivitySection({ report }: { report: SignalReport }): JSX.Element | null {
+ const { reportArtefacts, reportTasks } = useValues(inboxReportDetailLogic({ reportId: report.id, report }))
+
+ if (!reportArtefacts || reportArtefacts.length === 0) {
+ return null
+ }
+
+ // The logic already resolved the research/implementation tasks; hand them to the `task_run` rows
+ // so they don't re-fetch the same tasks the Runs section just loaded.
+ const knownTasks = new Map((reportTasks ?? []).map((entry) => [entry.task.id, entry.task]))
+
+ return (
+ <RightColumnSection
+ icon={<IconClockRewind />}
+ title="Activity"
+ rightSlot={
+ <span className="text-[0.6875rem] text-tertiary tabular-nums">
+ {reportArtefacts.length} {reportArtefacts.length === 1 ? 'entry' : 'entries'}
+ </span>
+ }
+ >
+ <ArtefactLogList reportId={report.id} artefacts={reportArtefacts} knownTasks={knownTasks} />
+ </RightColumnSection>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
index 7bacb390320a..586837a582ac 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
@@ -30,6 +30,7 @@ import { SignalReportStatusBadge } from '../badges/SignalReportStatusBadge'
import { hasKnownSourceProduct, knownSourceProductEntries, SourceProductIconRow } from '../badges/sourceProductIcons'
import { ConventionalCommitScopeTag } from '../cards/ReportCard'
import { RightColumnSection } from './DetailSection'
+import { ReportActivitySection } from './ReportActivitySection'
import { ReportDetailActions } from './ReportDetailActions'
import { ReportTasksSection } from './ReportTasksSection'
import { SuggestedReviewersSection } from './SuggestedReviewersSection'
@@ -355,6 +356,7 @@ export function InboxDetailFrame({
</RightColumnSection>
)}
<ReportTasksSection report={report} />
+ <ReportActivitySection report={report} />
</div>
</div>
</div>
diff --git a/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx b/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
index aaccd9ac9b90..174e7f931bf0 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
@@ -10,12 +10,12 @@ import { Task, TaskRunStatus } from 'products/tasks/frontend/types'
import { inboxReportDetailLogic, ReportTaskEntry } from '../../logics/inboxReportDetailLogic'
import { SignalReport } from '../../types'
import { RightColumnSection } from './DetailSection'
-import { RELATIONSHIP_LABEL, TaskRunStatusDot } from './taskRunDisplay'
+import { TaskRunStatusDot } from './taskRunDisplay'
/**
- * Renders the report's linked tasks inline (latest status + relationship). Each row opens the
- * report's run detail (`AgentRunDetail`), where the task's run log renders inline. Only
- * `implementation` and `research` relationships are shown, implementation-first.
+ * Renders the report's linked tasks inline (latest status + purpose). Each row opens the
+ * report's run detail (`AgentRunDetail`), where the task's run log renders inline. The purpose
+ * label is derived from each task's `task_run` artefact; `repo_selection` runs are filtered out.
*/
export function ReportTasksSection({ report }: { report: SignalReport }): JSX.Element | null {
const { reportTasks, reportTasksLoading } = useValues(inboxReportDetailLogic({ reportId: report.id, report }))
@@ -47,7 +47,7 @@ export function ReportTasksSection({ report }: { report: SignalReport }): JSX.El
}
function TaskRow({ entry, reportId }: { entry: ReportTaskEntry; reportId: string }): JSX.Element {
- const { task, relationship } = entry
+ const { task, purposeLabel } = entry
const status = task.latest_run?.status ?? TaskRunStatus.NOT_STARTED
// Open this report's run detail (the inbox Runs route); `inboxSceneLogic` handles the cross-tab
// open. The task's run log renders inline there — no need to leave the inbox for the Tasks UI.
@@ -57,7 +57,7 @@ function TaskRow({ entry, reportId }: { entry: ReportTaskEntry; reportId: string
className="group flex items-center gap-2 rounded px-1.5 py-1 text-left text-xs no-underline transition-colors hover:bg-fill-highlight-50"
>
<TaskRunStatusDot status={status} />
- <span className="shrink-0 text-secondary">{RELATIONSHIP_LABEL[relationship]}</span>
+ <span className="shrink-0 text-secondary">{purposeLabel}</span>
<span className="ml-auto truncate text-tertiary">{getTaskTitle(task)}</span>
<IconChevronRight className="shrink-0 text-tertiary opacity-0 transition-opacity group-hover:opacity-100" />
</Link>
diff --git a/frontend/src/scenes/inbox/components/detail/artefactTypes.ts b/frontend/src/scenes/inbox/components/detail/artefactTypes.ts
new file mode 100644
index 000000000000..173786c25be7
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/artefactTypes.ts
@@ -0,0 +1,182 @@
+// Pure (no-React) artefact helpers shared by the detail logic and the activity-log renderers.
+// Mirrors the PostHog Code inbox's artefact-log domain helpers. Content shapes stay loose
+// (`Record<string, any>` on the artefact) and are read through these typed accessors so legacy
+// rows with extra/missing keys never crash a render.
+
+import { identifierToHuman } from 'lib/utils/strings'
+
+import { SignalReportArtefact } from '../../types'
+
+/** Built-in signals pipeline product identifier on a `task_run` artefact. */
+export const SIGNALS_PRODUCT = 'signals'
+
+// ── Per-type content shapes (read defensively; treat every field as possibly absent) ─────────
+
+export interface CodeReferenceContent {
+ file_path: string
+ start_line?: number
+ end_line?: number
+ contents?: string
+ relevance_note?: string
+}
+
+export interface LineReferenceContent {
+ file_path: string
+ line?: number
+ note?: string
+ contents?: string
+}
+
+export interface CommitContent {
+ repository: string
+ branch: string
+ commit_sha: string
+ message: string
+ note?: string
+}
+
+export interface TaskRunArtefactContent {
+ task_id: string
+ run_id?: string | null
+ product: string
+ type: string
+}
+
+export interface NoteContent {
+ note: string
+ author?: string
+}
+
+export interface SignalFindingContent {
+ signal_id: string
+ relevant_code_paths?: string[]
+ verified?: boolean
+}
+
+export interface DismissalContent {
+ reason?: string
+ note?: string
+}
+
+// ── Type labels ──────────────────────────────────────────────────────────────────────────────
+
+/** Human label for each artefact type as it reads in the activity log header. */
+export const ARTEFACT_TYPE_LABELS: Record<string, string> = {
+ code_reference: 'Code referenced',
+ line_reference: 'Line highlighted',
+ commit: 'Commit pushed',
+ task_run: 'Task run',
+ note: 'Note added',
+ priority_judgment: 'Priority assessed',
+ actionability_judgment: 'Actionability assessed',
+ safety_judgment: 'Safety assessed',
+ signal_finding: 'Signal investigated',
+ suggested_reviewers: 'Reviewers suggested',
+ repo_selection: 'Repo selected',
+ dismissal: 'Report dismissed',
+ video_segment: 'Video segment',
+}
+
+export function artefactTypeLabel(type: string): string {
+ return ARTEFACT_TYPE_LABELS[type] ?? type
+}
+
+/**
+ * The mono `file:line` location string shown next to the type label, or null when the artefact
+ * type carries no location.
+ */
+export function artefactLocationLabel(artefact: SignalReportArtefact): string | null {
+ if (artefact.type === 'code_reference') {
+ const c = artefact.content as CodeReferenceContent
+ if (!c?.file_path) {
+ return null
+ }
+ if (c.start_line && c.end_line && c.start_line !== c.end_line) {
+ return `${c.file_path}:${c.start_line}-${c.end_line}`
+ }
+ return c.start_line ? `${c.file_path}:${c.start_line}` : c.file_path
+ }
+ if (artefact.type === 'line_reference') {
+ const c = artefact.content as LineReferenceContent
+ if (!c?.file_path) {
+ return null
+ }
+ return c.line ? `${c.file_path}:${c.line}` : c.file_path
+ }
+ return null
+}
+
+/**
+ * Attribution byline source: "{first name or email}" for a human write, "agent" for a
+ * task-attributed write, or null for a system/pipeline write (no byline). Only one of
+ * `created_by` / `task_id` is set per row.
+ */
+export function artefactAttributionLabel(artefact: SignalReportArtefact): string | null {
+ if (artefact.created_by) {
+ return artefact.created_by.first_name?.trim() || artefact.created_by.email
+ }
+ if (artefact.task_id) {
+ return 'agent'
+ }
+ return null
+}
+
+// ── Task-run purpose derivation (replaces the legacy SignalReportTask `relationship`) ──────────
+
+/** A task↔report association's derived purpose. `other` covers custom-agent runs. */
+export type ReportTaskPurpose = 'research' | 'implementation' | 'other'
+
+/** Sort order for linked-task rows: implementation first, then research, then everything else. */
+export const PURPOSE_ORDER: ReportTaskPurpose[] = ['implementation', 'research', 'other']
+
+export interface DerivedPurpose {
+ purpose: ReportTaskPurpose
+ purposeLabel: string
+}
+
+/**
+ * Derive a task's purpose + display label from its `task_run` artefact's `(product, type)` pair.
+ * Returns null for `repo_selection` (pipeline plumbing, never displayed). The built-in signals
+ * pipeline maps research/implementation to typed purposes; any other pair is `other`, labelled
+ * from the humanized product + type. Mirrors the desktop `derivePurpose`.
+ */
+export function deriveTaskPurpose(content: TaskRunArtefactContent): DerivedPurpose | null {
+ if (content.product === SIGNALS_PRODUCT) {
+ if (content.type === 'research') {
+ return { purpose: 'research', purposeLabel: 'Research' }
+ }
+ if (content.type === 'implementation') {
+ return { purpose: 'implementation', purposeLabel: 'Implementation' }
+ }
+ if (content.type === 'repo_selection') {
+ return null
+ }
+ return { purpose: 'other', purposeLabel: `Signals — ${identifierToHuman(content.type)}` }
+ }
+ return {
+ purpose: 'other',
+ purposeLabel: `${identifierToHuman(content.product)} — ${identifierToHuman(content.type)}`,
+ }
+}
+
+/**
+ * Short type label for a `task_run` artefact's badge in the activity log. Unlike `deriveTaskPurpose`
+ * this never returns null — `repo_selection` is shown here ("Repo selection") because the activity
+ * log is the full work-log, whereas the Runs list hides selection plumbing.
+ */
+export function taskRunTypeLabel(content: TaskRunArtefactContent): string {
+ if (content.product === SIGNALS_PRODUCT) {
+ const labels: Record<string, string> = {
+ research: 'Research',
+ implementation: 'Implementation',
+ repo_selection: 'Repo selection',
+ }
+ return labels[content.type] ?? identifierToHuman(content.type)
+ }
+ return identifierToHuman(content.type)
+}
+
+/** Whether a `task_run` artefact came from a custom agent (non-signals product). */
+export function isCustomAgentTaskRun(content: TaskRunArtefactContent): boolean {
+ return content.product !== SIGNALS_PRODUCT
+}
diff --git a/frontend/src/scenes/inbox/components/detail/taskRunDisplay.tsx b/frontend/src/scenes/inbox/components/detail/taskRunDisplay.tsx
index fefd26071518..93e577ec70ba 100644
--- a/frontend/src/scenes/inbox/components/detail/taskRunDisplay.tsx
+++ b/frontend/src/scenes/inbox/components/detail/taskRunDisplay.tsx
@@ -2,15 +2,6 @@ import clsx from 'clsx'
import { TaskRunStatus } from 'products/tasks/frontend/types'
-import { SignalReportTaskRelationship } from '../../types'
-
-/** Human label for a report→task relationship, shown next to a run in the inbox. */
-export const RELATIONSHIP_LABEL: Record<SignalReportTaskRelationship, string> = {
- research: 'Research',
- implementation: 'Implementation',
- repo_selection: 'Repo selection',
-}
-
/** Run statuses that count as terminal. Mirrors desktop `isTerminalStatus`. */
export const TERMINAL_STATUSES: TaskRunStatus[] = [
TaskRunStatus.COMPLETED,
diff --git a/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts b/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
index 56abf3fc37ed..872e9a88cae0 100644
--- a/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
+++ b/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
@@ -3,12 +3,18 @@ import { loaders } from 'kea-loaders'
import { lemonToast } from '@posthog/lemon-ui'
-import api, { PaginatedResponse } from 'lib/api'
+import api from 'lib/api'
import { SignalNode } from 'scenes/debug/signals/types'
import { userLogic } from 'scenes/userLogic'
import { Task, TaskRunStatus } from 'products/tasks/frontend/types'
+import {
+ deriveTaskPurpose,
+ PURPOSE_ORDER,
+ ReportTaskPurpose,
+ TaskRunArtefactContent,
+} from '../components/detail/artefactTypes'
import {
AvailableReviewerOption,
buildAddReviewerOptions,
@@ -20,30 +26,32 @@ import {
SignalReportArtefact,
SignalReportArtefactResponse,
SignalReportStatus,
- SignalReportTask,
- SignalReportTaskRelationship,
} from '../types'
import type { inboxReportDetailLogicType } from './inboxReportDetailLogicType'
/** Run statuses that count as terminal. Mirrors desktop `isTerminalStatus` / `ReportTasksSection`. */
const TERMINAL_RUN_STATUSES: TaskRunStatus[] = [TaskRunStatus.COMPLETED, TaskRunStatus.FAILED, TaskRunStatus.CANCELLED]
+// The task↔report association is the `task_run` artefact log now (the legacy `/tasks/` endpoint is
+// gone), and the activity timeline renders the whole log. Pull a generous page so early entries
+// (the first task runs, repo selection) stay visible on reports with many findings — matching the
+// limit the kickoff flow already uses to find the repo-selection artefact.
+const ARTEFACT_FETCH_LIMIT = 1000
+
export interface InboxReportDetailLogicProps {
reportId: string
/** The selected report, fed in by the shell so task polling can stop once it reaches a terminal status. */
report?: SignalReport | null
}
-/** A linked task plus the relationship and when the link was created. Mirrors desktop `ReportTaskData`. */
+/** A linked task plus its derived purpose and when the association was first recorded. Mirrors desktop `ReportTaskData`. */
export interface ReportTaskEntry {
task: Task
- relationship: SignalReportTaskRelationship
+ purpose: ReportTaskPurpose
+ purposeLabel: string
startedAt: string
}
-// Only these relationships are rendered, implementation-first. Mirrors desktop `useReportTasks`.
-const DISPLAYED_RELATIONSHIPS: SignalReportTaskRelationship[] = ['implementation', 'research']
-
// While the report is still being worked, poll linked tasks every 5s. Mirrors desktop.
const ACTIVE_STATUSES: SignalReportStatus[] = [
SignalReportStatus.CANDIDATE,
@@ -102,12 +110,14 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
setSelectedTaskId: (taskId: string | null) => ({ taskId }),
}),
- loaders(({ props }) => ({
+ loaders(({ props, values }) => ({
reportArtefacts: [
null as SignalReportArtefact[] | null,
{
loadReportArtefacts: async () => {
- const response: SignalReportArtefactResponse = await api.signalReports.artefacts(props.reportId)
+ const response: SignalReportArtefactResponse = await api.signalReports.artefacts(props.reportId, {
+ limit: ARTEFACT_FETCH_LIMIT,
+ })
return response.results
},
},
@@ -124,20 +134,55 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
reportTasks: [
null as ReportTaskEntry[] | null,
{
+ // The task↔report association lives in the `task_run` artefact log: each artefact's
+ // `(product, type)` derives the task's purpose. We group by task id (earliest
+ // association wins for `startedAt`), drop `repo_selection` (pipeline plumbing), then
+ // resolve each task. Mirrors desktop `useReportTasks`. Derives from the already-loaded
+ // `reportArtefacts` (re-run after each artefact load) rather than re-fetching them.
loadReportTasks: async () => {
- const response: PaginatedResponse<SignalReportTask> = await api.signalReports.tasks(props.reportId)
- const relevant = response.results.filter((rt) => DISPLAYED_RELATIONSHIPS.includes(rt.relationship))
+ const artefacts = values.reportArtefacts ?? []
+ const associations = new Map<
+ string,
+ { purpose: ReportTaskPurpose; purposeLabel: string; startedAt: string }
+ >()
+ for (const artefact of artefacts) {
+ if (artefact.type !== 'task_run') {
+ continue
+ }
+ const content = artefact.content as TaskRunArtefactContent
+ if (!content?.task_id) {
+ continue
+ }
+ const derived = deriveTaskPurpose(content)
+ if (!derived) {
+ continue
+ }
+ const existing = associations.get(content.task_id)
+ if (!existing) {
+ associations.set(content.task_id, { ...derived, startedAt: artefact.created_at })
+ } else if (artefact.created_at < existing.startedAt) {
+ // Keep the earliest association's timestamp + purpose for this task.
+ associations.set(content.task_id, { ...derived, startedAt: artefact.created_at })
+ }
+ }
const entries = await Promise.all(
- relevant.map(async (rt): Promise<ReportTaskEntry> => {
- const task = await api.tasks.get(rt.task_id)
- return { task, relationship: rt.relationship, startedAt: rt.created_at }
+ [...associations.entries()].map(async ([taskId, meta]): Promise<ReportTaskEntry | null> => {
+ try {
+ const task = await api.tasks.get(taskId)
+ return { task, ...meta }
+ } catch {
+ // A deleted/inaccessible task drops out of the list rather than failing the load.
+ return null
+ }
})
)
- return entries.sort(
- (a, b) =>
- DISPLAYED_RELATIONSHIPS.indexOf(a.relationship) -
- DISPLAYED_RELATIONSHIPS.indexOf(b.relationship)
- )
+ return entries
+ .filter((entry): entry is ReportTaskEntry => entry !== null)
+ .sort(
+ (a, b) =>
+ PURPOSE_ORDER.indexOf(a.purpose) - PURPOSE_ORDER.indexOf(b.purpose) ||
+ new Date(a.startedAt).getTime() - new Date(b.startedAt).getTime()
+ )
},
},
],
@@ -263,7 +308,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
if (!reportTasks) {
return false
}
- const researchTasks = reportTasks.filter((rt) => rt.relationship === 'research')
+ const researchTasks = reportTasks.filter((rt) => rt.purpose === 'research')
if (researchTasks.length < 2) {
return false
}
@@ -330,13 +375,20 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
actions.setOptimisticReviewers(null)
}
},
- // Poll linked tasks only while the report is active; stop once it reaches a terminal status
- // (or is unloaded). Mirrors desktop `useReportTasks` gating. The keyed disposable replaces
- // any running interval on re-add and is torn down automatically on unmount / tab hide.
+ // 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.
+ loadReportArtefactsSuccess: () => {
+ actions.loadReportTasks()
+ },
+ // 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
+ // `useReportTasks` gating. The keyed disposable replaces any running interval on re-add and is
+ // torn down automatically on unmount / tab hide.
setReport: () => {
if (values.isReportActive) {
cache.disposables.add(() => {
- const interval = setInterval(() => actions.loadReportTasks(), REPORT_TASKS_POLL_INTERVAL_MS)
+ const interval = setInterval(() => actions.loadReportArtefacts(), REPORT_TASKS_POLL_INTERVAL_MS)
return () => clearInterval(interval)
}, 'reportTasksPoll')
} else {
@@ -353,9 +405,9 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
}),
afterMount(({ actions, props }) => {
+ // `loadReportTasks` is cascaded from `loadReportArtefactsSuccess`, so it isn't called here.
actions.loadReportArtefacts()
actions.loadReportSignals()
- actions.loadReportTasks()
actions.loadAvailableReviewers()
// Seed the report from props so polling is gated on its status from the first tick.
actions.setReport(props.report ?? null)
diff --git a/frontend/src/scenes/inbox/types.ts b/frontend/src/scenes/inbox/types.ts
index 6eaa711aa00c..922fbb89e90d 100644
--- a/frontend/src/scenes/inbox/types.ts
+++ b/frontend/src/scenes/inbox/types.ts
@@ -6,6 +6,7 @@ import {
SignalSourceProduct,
SignalSourceType,
} from '~/queries/schema/schema-signals'
+import type { UserBasicType } from '~/types'
export type { EnrichedReviewer, RelevantCommit }
export { SignalSourceProduct, SignalSourceType }
@@ -70,6 +71,12 @@ export interface SignalReportArtefact {
type: string
content: Record<string, any>
created_at: string
+ /** Log artefacts are editable in place; null for write-once rows. */
+ updated_at?: string | null
+ /** Set when a human produced the artefact (drives the "by {name}" attribution byline). */
+ created_by?: UserBasicType | null
+ /** Set when an agent task produced the artefact (attribution reads "by agent"). */
+ task_id?: string | null
}
export interface SignalReportArtefactResponse {
@@ -155,6 +162,9 @@ export const INBOX_SCOPE_FOR_YOU: InboxScope = 'for-you'
export const INBOX_SCOPE_ENTIRE_PROJECT: InboxScope = 'entire-project'
// ── SignalReport ↔ Task linkage ─────────────────────────────────────────────
+// The task↔report association is the `task_run` artefact log (see artefactTypes.ts). The
+// relationship vocabulary below is retained only for the task-creation kickoff path, where the
+// backend still accepts `signal_report_task_relationship` (implementation) when starting a PR run.
export const SIGNAL_REPORT_TASK_RELATIONSHIPS = ['repo_selection', 'research', 'implementation'] as const
@@ -162,13 +172,6 @@ export type SignalReportTaskRelationship = (typeof SIGNAL_REPORT_TASK_RELATIONSH
export const SIGNAL_REPORT_TASK_IMPLEMENTATION_RELATIONSHIP: SignalReportTaskRelationship = 'implementation'
-export interface SignalReportTask {
- id: string
- relationship: SignalReportTaskRelationship
- task_id: string
- created_at: string
-}
-
// ── Autonomy config (per-user override; backend SignalUserAutonomyConfigView) ─
export interface SignalUserAutonomyConfig {