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.

fix(signals): refresh monitoring details through settlement (#124306)

Mikayla Thompson33c679a9064c
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index b9854b582991..9682fe541b39 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -149,7 +149,7 @@ This aggregation path persists requests only. The report-level assessment worker
All-pass resolution also records a durable tracker-completion request. A separate one-minute sweep consumes pending requests directly, outside the check coordinator and its time budget. It has a 45-second soft limit and 60-second hard limit. Tracker closure serializes deliveries and verifies the same attempt is still effectively resolved before contacting the provider; archiving preserves that verified outcome, while reopening or replacing the attempt makes its request obsolete. Each claimed request reserves its next attempt five minutes ahead, so failures and interrupted workers cannot monopolize every sweep. Successful tracker closing comments are recorded independently of the provider close, and Redis lock failures use the normal retry path. Completed or obsolete requests are marked processed, and a partial index orders outstanding work by its next retry.
-Manual completion preserves its open-PR closure intent on the frozen attempt. After verification passes, the sweep uses the existing best-effort PR closure path with a stable comment marker, then completes the tracker issue.
+Manual completion preserves its open-PR closure intent on the frozen attempt. After verification passes, the sweep uses the existing best-effort PR closure path with a stable comment marker, then completes the tracker issue. Open Monitoring detail panes refresh their status and explanations. Settled task snapshots are reused for up to one minute, with immediate refresh when a new linked run appears in the artefacts. Periodic refresh also discovers new runs that reuse a task without adding an artefact.
The request stays pending until every requested PR close and tracker close succeeds or is no longer needed, including reports without a tracker issue. Scheduled GitHub delivery uses the batch lane. Budget denial stops the sweep, and provider rate limits delay the request until at least the indicated retry time.
diff --git a/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx b/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx
index 4fc55aaff73c..8751ff0a6fe6 100644
--- a/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx
+++ b/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx
@@ -295,5 +295,7 @@ describe('ReportContextMenu', () => {
expect(await screen.findByText(dialog)).toBeInTheDocument()
expect(stateRequests).toEqual([])
+ fireEvent.click(screen.getByText('Cancel'))
+ await waitFor(() => expect(screen.queryByText(dialog)).not.toBeInTheDocument())
})
})
diff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts
index defca29d6fe1..682759cd1829 100644
--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts
@@ -38,49 +38,93 @@ const linkedTask = (purpose: ReportTaskPurpose, status: TaskRunStatus | null, pr
}) as unknown as ReportTaskEntry
describe('inboxReportDetailLogic', () => {
- it('orders report runs newest first across purposes using their first association', async () => {
- const runs = [
- { taskId: 'implementation-old', type: 'implementation', startedAt: '2026-01-01T01:00:00Z' },
- { taskId: 'research', type: 'research', startedAt: '2026-01-01T02:00:00Z' },
- { taskId: 'implementation-new', type: 'implementation', startedAt: '2026-01-01T03:00:00Z' },
- { taskId: 'scout', type: 'scout', startedAt: '2026-01-01T04:00:00Z' },
- { taskId: 'implementation-old', type: 'implementation', startedAt: '2026-01-01T05:00:00Z' },
- ]
- useMocks({
- get: {
- '/api/projects/:team_id/signals/reports/:id/feedback_state/': { sentiment: null, note: '' },
- '/api/projects/:team_id/signals/reports/:id/artefacts/': {
- results: runs.map(({ taskId, type, startedAt }, index) => ({
- id: `task-run-${index}`,
- type: 'task_run',
- content: { task_id: taskId, product: 'signals', type },
- created_at: startedAt,
- })),
+ it.each([SignalReportStatus.READY, SignalReportStatus.MONITORING])(
+ 'orders report runs and refreshes settled tasks appropriately in %s',
+ async (status) => {
+ let latestRunId: string | null = null
+ let taskLatestRunId = 'old-run'
+ let now = Date.now()
+ const clock = jest.spyOn(Date, 'now').mockImplementation(() => now)
+ const taskRequests: string[] = []
+ const runs = [
+ { taskId: 'implementation-old', type: 'implementation', startedAt: '2026-01-01T01:00:00Z' },
+ { taskId: 'research', type: 'research', startedAt: '2026-01-01T02:00:00Z' },
+ { taskId: 'implementation-new', type: 'implementation', startedAt: '2026-01-01T03:00:00Z' },
+ { taskId: 'scout', type: 'scout', startedAt: '2026-01-01T04:00:00Z' },
+ { taskId: 'implementation-old', type: 'implementation', startedAt: '2026-01-01T05:00:00Z' },
+ ]
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/:id/feedback_state/': { sentiment: null, note: '' },
+ '/api/projects/:team_id/signals/reports/:id/artefacts/': () => ({
+ results: runs.map(({ taskId, type, startedAt }, index) => ({
+ id: `task-run-${index}`,
+ type: 'task_run',
+ content: {
+ task_id: taskId,
+ product: 'signals',
+ type,
+ run_id: taskId === runs[0].taskId ? latestRunId : null,
+ },
+ created_at: startedAt,
+ })),
+ }),
+ '/api/projects/:team_id/signals/reports/:id/signals/': { signals: [] },
+ '/api/projects/:team_id/signals/reports/:id/checks/': { results: [] },
+ '/api/projects/:team_id/signals/reports/available_reviewers/': [],
+ '/api/projects/:team_id/tasks/:id/': (req) => {
+ taskRequests.push(String(req.params.id))
+ return [
+ 200,
+ {
+ id: req.params.id,
+ latest_run: {
+ id: req.params.id === runs[0].taskId ? taskLatestRunId : 'old-run',
+ status: TaskRunStatus.COMPLETED,
+ },
+ },
+ ]
+ },
},
- '/api/projects/:team_id/signals/reports/:id/signals/': { signals: [] },
- '/api/projects/:team_id/signals/reports/:id/checks/': { results: [] },
- '/api/projects/:team_id/signals/reports/available_reviewers/': [],
- '/api/projects/:team_id/tasks/:id/': (req) => [
- 200,
- { id: req.params.id, latest_run: { status: TaskRunStatus.COMPLETED } },
- ],
- },
- })
- initKeaTests()
- const logic = inboxReportDetailLogic({ reportId: REPORT.id, report: REPORT })
- logic.mount()
- try {
- await expectLogic(logic).toFinishAllListeners()
- expect(logic.values.reportTasks?.map((entry) => entry.task.id)).toEqual([
- 'scout',
- 'implementation-new',
- 'research',
- 'implementation-old',
- ])
- } finally {
- logic.unmount()
+ })
+ initKeaTests()
+ const logic = inboxReportDetailLogic({ reportId: REPORT.id, report: { ...REPORT, status } })
+ logic.mount()
+ try {
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.reportTasks?.map((entry) => entry.task.id)).toEqual([
+ 'scout',
+ 'implementation-new',
+ 'research',
+ 'implementation-old',
+ ])
+ expect(taskRequests).toHaveLength(4)
+ logic.actions.loadReportArtefacts()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(taskRequests).toHaveLength(status === SignalReportStatus.MONITORING ? 4 : 8)
+ const beforeNewRun = taskRequests.length
+ latestRunId = 'replacement-run'
+ taskLatestRunId = latestRunId
+ logic.actions.loadReportArtefacts()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(taskRequests).toHaveLength(beforeNewRun + (status === SignalReportStatus.MONITORING ? 1 : 4))
+ taskLatestRunId = 'run-without-artefact'
+ now += 60_000
+ logic.actions.loadReportArtefacts()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(
+ logic.values.reportTasks?.find((entry) => entry.task.id === runs[0].taskId)?.task.latest_run?.id
+ ).toBe(taskLatestRunId)
+ const afterRefresh = taskRequests.length
+ logic.actions.loadReportArtefacts()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(taskRequests).toHaveLength(afterRefresh + (status === SignalReportStatus.MONITORING ? 0 : 4))
+ } finally {
+ clock.mockRestore()
+ logic.unmount()
+ }
}
- })
+ )
describe('report editing', () => {
let logic: ReturnType<typeof inboxReportDetailLogic.build>
@@ -1176,7 +1220,13 @@ describe('inboxReportDetailLogic', () => {
],
})
let requests = 0
- let reportStatus = REPORT.status
+ let reportStatus = SignalReportStatus.MONITORING
+ const monitoringReport = { ...REPORT, status: reportStatus }
+ const reloadReport = jest.fn()
+ const sceneSpy = jest.spyOn(inboxSceneLogic, 'findMounted').mockReturnValue({
+ values: { selectedReportId: REPORT.id, selectedReportLoading: false },
+ actions: { loadSelectedReport: reloadReport },
+ } as unknown as ReturnType<typeof inboxSceneLogic.build>)
const check = {
id: 'monitoring-check',
status: 'active',
@@ -1221,21 +1271,27 @@ describe('inboxReportDetailLogic', () => {
},
})
try {
- logic = inboxReportDetailLogic({ reportId: REPORT.id, report: REPORT })
+ logic = inboxReportDetailLogic({ reportId: REPORT.id, report: monitoringReport })
logic.mount()
await expectLogic(logic).toFinishAllListeners()
+ const reloadArtefacts = jest.spyOn(logic.actions, 'loadReportArtefacts')
expect(requests).toBe(1)
jest.advanceTimersByTime(60000)
await expectLogic(logic).toFinishAllListeners()
expect(requests).toBe(2)
+ expect(reloadReport).toHaveBeenCalledWith({ id: REPORT.id })
+ expect(reloadArtefacts).toHaveBeenCalled()
expect(logic.values.reportChecks?.[0].monitoring_timing?.state).toBe('window_ended')
- inboxReportDetailLogic({ reportId: REPORT.id, report: { ...REPORT } })
+ inboxReportDetailLogic({ reportId: REPORT.id, report: { ...monitoringReport } })
await expectLogic(logic).toFinishAllListeners()
expect(requests).toBe(2)
+ reloadArtefacts.mockClear()
+ reloadReport.mockClear()
reportStatus = status
inboxReportDetailLogic({ reportId: REPORT.id, report: { ...REPORT, status } })
await expectLogic(logic).toFinishAllListeners()
expect(requests).toBe(3)
+ expect(reloadArtefacts).toHaveBeenCalledTimes(1)
expect(logic.values.reportChecks?.[0].monitoring_timing?.state).toBe(
status === SignalReportStatus.SUPPRESSED ? 'archived' : undefined
)
@@ -1243,8 +1299,11 @@ describe('inboxReportDetailLogic', () => {
jest.advanceTimersByTime(60000)
await expectLogic(logic).toFinishAllListeners()
expect(requests).toBe(3)
+ expect(reloadReport).not.toHaveBeenCalled()
+ expect(reloadArtefacts).toHaveBeenCalledTimes(1)
} finally {
logic.unmount()
+ sceneSpy.mockRestore()
jest.useRealTimers()
}
}
diff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
index 31afdbd55d47..008a9440137d 100644
--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
@@ -209,8 +209,16 @@ const ACTIVE_STATUSES: SignalReportStatus[] = [
]
const REPORT_TASKS_POLL_INTERVAL_MS = 5000
+const TERMINAL_TASK_CACHE_TTL_MS = 60000
const REPORT_CHECK_TIMING_POLL_INTERVAL_MS = 60000
+function refreshSelectedReport(reportId: string): void {
+ const scene = inboxSceneLogic.findMounted()
+ if (scene?.values.selectedReportId === reportId && !scene.values.selectedReportLoading) {
+ scene.actions.loadSelectedReport({ id: reportId })
+ }
+}
+
// PR CI checks refresh cadence while the detail is open — a running build's status stays current
// without hammering GitHub. Mirrors the desktop PR-review view's 15s poll.
const PR_CHECKS_POLL_INTERVAL_MS = 15000
@@ -1018,10 +1026,18 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
// 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 snapshots: Map<string, { fetchedAt: number; artefactRunId?: string | null }> =
+ (cache.reportTaskSnapshots ??= new Map())
const artefacts = values.reportArtefacts ?? []
const associations = new Map<
string,
- { purpose: ReportTaskPurpose; purposeLabel: string; startedAt: string }
+ {
+ purpose: ReportTaskPurpose
+ purposeLabel: string
+ startedAt: string
+ latestRunId?: string | null
+ latestRunAt: string
+ }
>()
for (const artefact of artefacts) {
if (artefact.type !== 'task_run') {
@@ -1037,17 +1053,44 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
}
const existing = associations.get(content.task_id)
if (!existing) {
- associations.set(content.task_id, { ...derived, startedAt: artefact.created_at })
+ associations.set(content.task_id, {
+ ...derived,
+ startedAt: artefact.created_at,
+ latestRunId: content.run_id,
+ latestRunAt: 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 })
+ associations.set(content.task_id, {
+ ...existing,
+ ...derived,
+ startedAt: artefact.created_at,
+ })
+ } else if (artefact.created_at > existing.latestRunAt) {
+ associations.set(content.task_id, {
+ ...existing,
+ latestRunId: content.run_id,
+ latestRunAt: artefact.created_at,
+ })
}
}
let incomplete = false
const entries = await Promise.all(
[...associations.entries()].map(async ([taskId, meta]): Promise<ReportTaskEntry | null> => {
+ const cached = values.reportTasks?.find((entry) => entry.task.id === taskId)
+ const snapshot = snapshots.get(taskId)
+ if (
+ values.report?.status === SignalReportStatus.MONITORING &&
+ cached?.task.latest_run &&
+ TERMINAL_RUN_STATUSES.includes(cached.task.latest_run.status) &&
+ snapshot?.artefactRunId === meta.latestRunId &&
+ Date.now() - (snapshot?.fetchedAt ?? -Infinity) < TERMINAL_TASK_CACHE_TTL_MS
+ ) {
+ return { task: cached.task, ...meta }
+ }
try {
const task = await api.tasks.get(taskId)
+ snapshots.set(taskId, { fetchedAt: Date.now(), artefactRunId: meta.latestRunId })
return { task, ...meta }
} catch (error) {
// A deleted/inaccessible task drops out of the list rather than failing the load.
@@ -2175,10 +2218,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
})
if (settled) {
actions.loadReportChecks()
- const scene = inboxSceneLogic.findMounted()
- if (scene?.values.selectedReportId === props.reportId) {
- scene.actions.loadSelectedReport({ id: props.reportId })
- }
+ refreshSelectedReport(props.reportId)
}
},
// A PR task started from this pane is not in the artefact log the gate was computed from, so
@@ -2225,6 +2265,9 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
actions.setReport(props.report ?? null)
if (props.report?.status !== oldProps.report?.status) {
actions.loadReportChecks()
+ if (oldProps.report?.status === SignalReportStatus.MONITORING) {
+ actions.loadReportArtefacts()
+ }
}
}
}),
@@ -2247,6 +2290,12 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
}
cache.disposables.add(() => {
const interval = setInterval(() => {
+ if (values.report?.status === SignalReportStatus.MONITORING) {
+ if (!values.reportArtefactsLoading) {
+ actions.loadReportArtefacts()
+ }
+ refreshSelectedReport(props.reportId)
+ }
if (
values.report?.status !== SignalReportStatus.RESOLVED &&
values.report?.status !== SignalReportStatus.CLOSED &&