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 right-click context menu on inbox report rows (#91955)

Chris Volzer5d03ff6d319c
diff --git a/products/signals/frontend/inbox/components/InboxReportList.tsx b/products/signals/frontend/inbox/components/InboxReportList.tsx
index 3608f525ae7c..4c4d715d902e 100644
--- a/products/signals/frontend/inbox/components/InboxReportList.tsx
+++ b/products/signals/frontend/inbox/components/InboxReportList.tsx
@@ -212,7 +212,7 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps
report={report}
sectionKey={INBOX_LEGACY_TAB_SECTION[tabKey]}
onDismiss={(reason, note) => dismissReport(report.id, reason, note)}
- onRestore={() => restoreReport(report.id)}
+ onRestore={() => restoreReport(report.id, 'list_row')}
/>
))}
{/* Skeleton cards continue the list while the next page loads – sleeker than a spinner. */}
diff --git a/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx b/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx
new file mode 100644
index 000000000000..a87360a133d7
--- /dev/null
+++ b/products/signals/frontend/inbox/components/cards/ReportContextMenu.test.tsx
@@ -0,0 +1,158 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { SignalReport, SignalReportStatus } from '../../types'
+import { ReportContextMenu } from './ReportContextMenu'
+
+jest.mock('posthog-js')
+jest.mock('lib/utils/copyToClipboard')
+
+const BROWSER_LINK_ROWS = ['Open link', 'Open link in new tab', 'Copy link']
+
+function makeReport(overrides: Partial<SignalReport> = {}): SignalReport {
+ return {
+ id: 'report-1',
+ title: 'Report one',
+ summary: 'summary',
+ status: SignalReportStatus.READY,
+ actionability: 'immediately_actionable',
+ total_weight: 0,
+ signal_count: 1,
+ relevant_user_count: null,
+ artefact_count: 0,
+ is_suggested_reviewer: false,
+ priority: 'P2',
+ created_at: '2026-06-11T10:00:00Z',
+ updated_at: '2026-06-11T10:00:00Z',
+ ...overrides,
+ }
+}
+
+function openMenu(report: SignalReport): void {
+ render(
+ <ReportContextMenu report={report} sectionKey="needs-decision">
+ <div data-attr="row">{report.title}</div>
+ </ReportContextMenu>
+ )
+ fireEvent.contextMenu(screen.getByText(report.title!))
+}
+
+function menuRowText(): (string | null)[] {
+ return screen.queryAllByRole('menuitem').map((item) => item.textContent)
+}
+
+describe('ReportContextMenu', () => {
+ let stateRequests: { reportId: string; body: Record<string, unknown> }[]
+
+ beforeEach(() => {
+ stateRequests = []
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/': { count: 0, next: null, previous: null, results: [] },
+ },
+ post: {
+ '/api/projects/:team_id/signals/reports/:report_id/state/': async ({ request, params }) => {
+ stateRequests.push({
+ reportId: params.report_id as string,
+ body: (await request.json()) as Record<string, unknown>,
+ })
+ return [200, {}]
+ },
+ },
+ })
+ initKeaTests()
+ })
+
+ // The menu content renders in a portal, so cleanup keeps one case's rows out of the next.
+ afterEach(cleanup)
+
+ // The menu must mirror the detail pane's eligibility rules; a drifted guard silently offers a
+ // dead-end action (a 409 transition, a duplicate PR) or hides a legitimate one. Every menu
+ // also carries the browser link actions the trigger suppresses on the row's native menu.
+ it.each([
+ {
+ name: 'a ready actionable report offers every action',
+ report: makeReport(),
+ expected: ['Create PR', 'Resolve', 'Dismiss', 'Reviewers'],
+ },
+ {
+ name: 'a report with a PR does not offer creating another',
+ report: makeReport({ implementation_pr_url: 'https://github.com/posthog/posthog/pull/1' }),
+ expected: ['Resolve', 'Dismiss', 'Reviewers'],
+ },
+ {
+ name: 'an in-progress report cannot be resolved yet',
+ report: makeReport({ status: SignalReportStatus.IN_PROGRESS, actionability: null }),
+ expected: ['Dismiss', 'Reviewers'],
+ },
+ {
+ name: 'a dismissed report only offers restore',
+ report: makeReport({ status: SignalReportStatus.SUPPRESSED }),
+ expected: ['Restore'],
+ },
+ ])('$name', ({ report, expected }) => {
+ openMenu(report)
+
+ expect(menuRowText()).toEqual([...expected, ...BROWSER_LINK_ROWS])
+ })
+
+ // A relative or wrong-tab URL would copy a link that 404s or opens the wrong list when pasted.
+ it('copies the absolute report detail link', () => {
+ openMenu(makeReport())
+
+ fireEvent.click(screen.getByText('Copy link'))
+
+ expect(jest.mocked(copyToClipboard)).toHaveBeenCalledWith('http://localhost/inbox/reports/report-1', 'link')
+ })
+
+ // Terminal rows must keep the browser's own context menu rather than an empty custom one.
+ it.each([
+ { name: 'a resolved report', report: makeReport({ status: SignalReportStatus.RESOLVED }) },
+ {
+ name: 'a refunded dismissed report',
+ report: makeReport({
+ status: SignalReportStatus.SUPPRESSED,
+ // The menu only checks refund presence, so the row's other fields don't matter here.
+ refund: { id: 'refund-1' } as unknown as SignalReport['refund'],
+ }),
+ },
+ ])('renders no menu for $name', ({ report }) => {
+ openMenu(report)
+
+ expect(menuRowText()).toEqual([])
+ })
+
+ // The submenu's whole point: a reason click persists that reason. A miswired option (wrong
+ // state, wrong reason value) would silently record the wrong verdict on every report.
+ it('resolves with the picked reason through the state API', async () => {
+ openMenu(makeReport())
+
+ fireEvent.click(screen.getByText('Resolve'))
+ fireEvent.click(await screen.findByText('PR was merged'))
+
+ await waitFor(() => {
+ expect(stateRequests).toEqual([
+ { reportId: 'report-1', body: { state: 'resolved', dismissal_reason: 'pr_merged' } },
+ ])
+ })
+ })
+
+ it('dismisses with the picked reason through the state API', async () => {
+ openMenu(makeReport())
+
+ fireEvent.click(screen.getByText('Dismiss'))
+ fireEvent.click(await screen.findByText("Won't fix - intentional behavior"))
+
+ await waitFor(() => {
+ expect(stateRequests).toEqual([
+ { reportId: 'report-1', body: { state: 'suppressed', dismissal_reason: 'wontfix_intentional' } },
+ ])
+ })
+ })
+})
diff --git a/products/signals/frontend/inbox/components/cards/ReportContextMenu.tsx b/products/signals/frontend/inbox/components/cards/ReportContextMenu.tsx
new file mode 100644
index 000000000000..dcc41973c4bb
--- /dev/null
+++ b/products/signals/frontend/inbox/components/cards/ReportContextMenu.tsx
@@ -0,0 +1,359 @@
+import { useActions } from 'kea'
+import { router } from 'kea-router'
+import { Fragment, ReactNode, useRef } from 'react'
+
+import {
+ IconArrowUpRight,
+ IconCheckCircle,
+ IconChevronRight,
+ IconCopy,
+ IconExternal,
+ IconHide,
+ IconPeople,
+ IconPullRequest,
+ IconUndo,
+} from '@posthog/icons'
+
+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
+import {
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuGroup,
+ ContextMenuItem,
+ ContextMenuSeparator,
+ ContextMenuSub,
+ ContextMenuSubContent,
+ ContextMenuSubTrigger,
+ ContextMenuTrigger,
+} from 'lib/ui/ContextMenu/ContextMenu'
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
+
+import { captureInboxReportAction } from '../../inboxAnalytics'
+import { inboxTaskKickoffLogic } from '../../inboxTaskKickoffLogic'
+import { reportListLogic, sectionListLogicProps } from '../../logics/reportListLogic'
+import { InboxReportSectionKey, SignalReport, SignalReportStatus } from '../../types'
+import {
+ DISMISSAL_REASON_OPTIONS,
+ DismissalReasonValue,
+ RESOLVE_REASON_OPTIONS,
+ ResolveReasonValue,
+} from '../../utils/dismissalReasons'
+import { inboxReportDetailUrl } from '../../utils/inboxReportUrls'
+import { canCreateImplementationPr, canResolveReport, hasOpenImplementationPr } from '../../utils/reportActions'
+import { displayConventionalCommitTitle } from '../../utils/reportPresentation'
+import { ReviewerSearchList } from '../detail/ReviewerSearchList'
+import { openDismissReportDialog } from '../shell/DismissReportDialog'
+import { openResolveReportDialog } from '../shell/ResolveReportDialog'
+
+/**
+ * Right-click menu on a report row in the flat inbox list: the report's major actions without
+ * opening its detail. Create PR, Resolve, Dismiss, and Reviewers follow the same eligibility rules
+ * as the detail pane (`utils/reportActions.ts`); a dismissed row offers Restore instead. Resolve
+ * and Dismiss nest their canonical reasons, and picking one applies immediately through the owning
+ * section's list logic, except "Something else…", which opens the existing dialog to collect the
+ * note that reason needs. Rows with no action (resolved, refunded) render without a menu, so the
+ * browser's own menu still works there. On rows with a menu the trigger suppresses that native
+ * menu over the row's link, so the standard link actions return as an explicit section at the
+ * bottom (open, open in new tab, copy link).
+ */
+export function ReportContextMenu({
+ report,
+ sectionKey,
+ children,
+}: {
+ report: SignalReport
+ /** The list state that owns the row; its keyed logic applies the optimistic update. */
+ sectionKey: InboxReportSectionKey
+ children: ReactNode
+}): JSX.Element {
+ const isDismissed = report.status === SignalReportStatus.SUPPRESSED
+ const isResolved = report.status === SignalReportStatus.RESOLVED
+ // Set when a menu item opens a dialog, read once when the menu closes right after.
+ const openedDialogRef = useRef(false)
+
+ // Resolved reports are terminal, and a refunded dismissed report cannot be restored.
+ if (isResolved || (isDismissed && !!report.refund)) {
+ return <>{children}</>
+ }
+
+ return (
+ <ContextMenu>
+ <ContextMenuTrigger asChild>
+ {/* Plain wrapper: the card component doesn't forward the ref the trigger needs. */}
+ <div className="flex min-w-0 flex-col">{children}</div>
+ </ContextMenuTrigger>
+ {/* The item tree lives in its own component so a closed row builds one element and
+ mounts no logic; `ContextMenuContent` renders its children only while open. */}
+ <ContextMenuContent
+ loop
+ className="min-w-48"
+ // The "Something else…" dialogs autofocus their note field, and the menu closes on
+ // the same click. Its closing focus restore runs after the dialog opens and would
+ // pull focus back to the row, so skip the restore for exactly that close.
+ onCloseAutoFocus={(event) => {
+ if (openedDialogRef.current) {
+ openedDialogRef.current = false
+ event.preventDefault()
+ }
+ }}
+ >
+ <ReportContextMenuItems
+ report={report}
+ sectionKey={sectionKey}
+ isDismissed={isDismissed}
+ onOpenDialog={() => (openedDialogRef.current = true)}
+ />
+ </ContextMenuContent>
+ </ContextMenu>
+ )
+}
+
+/** The open menu's items. Mounted only while the menu is open. */
+function ReportContextMenuItems({
+ report,
+ sectionKey,
+ isDismissed,
+ onOpenDialog,
+}: {
+ report: SignalReport
+ sectionKey: InboxReportSectionKey
+ isDismissed: boolean
+ /** Tells the menu a dialog is opening, so its close skips the focus restore. */
+ onOpenDialog: () => void
+}): JSX.Element {
+ const { dismissReport, resolveReport, restoreReport } = useActions(
+ reportListLogic(sectionListLogicProps(sectionKey))
+ )
+ // Kept mounted by `ReportsTab` beyond this menu's lifetime, so the create-PR listener survives
+ // the menu closing on click.
+ const { createPrFromReport } = useActions(inboxTaskKickoffLogic)
+
+ const reportTitle = displayConventionalCommitTitle(report.title, 'Untitled report')
+
+ const resolveWithReason = (reason: ResolveReasonValue, note: string): void => {
+ // pinned: `dismissal_reason` is the persisted field the reason lands in, for both verdicts.
+ // Only the structured reason — the free-form note can carry proprietary text.
+ captureInboxReportAction({
+ report,
+ actionType: 'resolve',
+ surface: 'context_menu',
+ extra: { dismissal_reason: reason },
+ })
+ resolveReport(report.id, reason, note)
+ }
+
+ const dismissWithReason = (reason: DismissalReasonValue, note: string): void => {
+ captureInboxReportAction({
+ report,
+ actionType: 'dismiss',
+ surface: 'context_menu',
+ extra: { dismissal_reason: reason, ...(note ? { dismissal_note: note } : {}) },
+ })
+ dismissReport(report.id, reason, note)
+ }
+
+ // "Something else…" needs the note the other reasons don't, so it goes through the dialog. So does
+ // any reason while the report still has an open implementation PR: resolving or dismissing closes
+ // that PR, so the dialog's warning and its confirm step stand in for the instant apply.
+ const pickResolveReason = (reason: ResolveReasonValue): void => {
+ if (reason === 'other' || hasOpenImplementationPr(report)) {
+ onOpenDialog()
+ openResolveReportDialog({
+ reportTitle,
+ hasOpenPr: hasOpenImplementationPr(report),
+ initialReason: reason,
+ onConfirm: ({ reason, note }) => resolveWithReason(reason, note),
+ })
+ return
+ }
+ resolveWithReason(reason, '')
+ }
+
+ const pickDismissReason = (reason: DismissalReasonValue): void => {
+ if (reason === 'other' || hasOpenImplementationPr(report)) {
+ onOpenDialog()
+ openDismissReportDialog({
+ reportTitle,
+ hasOpenPr: hasOpenImplementationPr(report),
+ initialReason: reason,
+ onConfirm: ({ reason, note }) => dismissWithReason(reason, note),
+ })
+ return
+ }
+ dismissWithReason(reason, '')
+ }
+
+ // The menu only mounts in the redesign flat list, whose rows link to the reports tab with no
+ // back param, so the default detail URL is exactly the row's own href.
+ const detailUrl = inboxReportDetailUrl(report.id)
+
+ // The trigger swallows the browser's native context menu over the row's link (a Radix
+ // behavior), so the link actions a person expects there come back as menu items.
+ const browserLinkItems = (
+ <>
+ <ContextMenuSeparator />
+ <ContextMenuGroup>
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={() => router.actions.push(detailUrl)}
+ data-attr="inbox-report-context-menu-open-link"
+ >
+ <IconArrowUpRight />
+ Open link
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={() => window.open(detailUrl, '_blank')}
+ data-attr="inbox-report-context-menu-open-link-new-tab"
+ >
+ <IconExternal />
+ Open link in new tab
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={() => void copyToClipboard(window.location.origin + detailUrl, 'link')}
+ data-attr="inbox-report-context-menu-copy-link"
+ >
+ <IconCopy />
+ Copy link
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ </ContextMenuGroup>
+ </>
+ )
+
+ const onCreatePr = (): void => {
+ captureInboxReportAction({
+ report,
+ actionType: 'create_pr',
+ surface: 'context_menu',
+ extra: { has_feedback: false },
+ })
+ // Self-guards on AI consent (toast) and navigates to the created run.
+ createPrFromReport(report)
+ }
+
+ if (isDismissed) {
+ return (
+ <>
+ <ContextMenuGroup>
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={() => restoreReport(report.id, 'context_menu')}
+ data-attr="inbox-report-context-menu-restore"
+ >
+ <IconUndo />
+ Restore
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ </ContextMenuGroup>
+ {browserLinkItems}
+ </>
+ )
+ }
+
+ return (
+ <>
+ <ContextMenuGroup>
+ {canCreateImplementationPr(report) && (
+ <>
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={onCreatePr}
+ data-attr="inbox-report-context-menu-create-pr"
+ >
+ <IconPullRequest />
+ Create PR
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ {/* Create PR acts on its own; the divider separates it from the verdict submenus. */}
+ <ContextMenuSeparator />
+ </>
+ )}
+ {canResolveReport(report) && (
+ <ContextMenuSub>
+ <ContextMenuSubTrigger asChild data-attr="inbox-report-context-menu-resolve">
+ <ButtonPrimitive menuItem>
+ <IconCheckCircle />
+ Resolve
+ <IconChevronRight className="ml-auto size-3" />
+ </ButtonPrimitive>
+ </ContextMenuSubTrigger>
+ {/* The base menu caps at 200px, which wraps the longer reason labels into the
+ buttons' fixed height. */}
+ <ContextMenuSubContent className="max-w-80">
+ <ContextMenuGroup>
+ {RESOLVE_REASON_OPTIONS.map((option) => (
+ <Fragment key={option.value}>
+ {/* The canned reasons apply instantly; "Something else…" opens
+ the note dialog, so it sits apart. */}
+ {option.value === 'other' && <ContextMenuSeparator />}
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={() => pickResolveReason(option.value)}
+ data-attr="inbox-report-context-menu-resolve-reason"
+ >
+ {option.label}
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ </Fragment>
+ ))}
+ </ContextMenuGroup>
+ </ContextMenuSubContent>
+ </ContextMenuSub>
+ )}
+ <ContextMenuSub>
+ <ContextMenuSubTrigger asChild data-attr="inbox-report-context-menu-dismiss">
+ <ButtonPrimitive menuItem>
+ <IconHide />
+ Dismiss
+ <IconChevronRight className="ml-auto size-3" />
+ </ButtonPrimitive>
+ </ContextMenuSubTrigger>
+ <ContextMenuSubContent className="max-w-80">
+ <ContextMenuGroup>
+ {DISMISSAL_REASON_OPTIONS.map((option) => (
+ <Fragment key={option.value}>
+ {option.value === 'other' && <ContextMenuSeparator />}
+ <ContextMenuItem asChild>
+ <ButtonPrimitive
+ menuItem
+ onClick={() => pickDismissReason(option.value)}
+ data-attr="inbox-report-context-menu-dismiss-reason"
+ >
+ {option.label}
+ </ButtonPrimitive>
+ </ContextMenuItem>
+ </Fragment>
+ ))}
+ </ContextMenuGroup>
+ </ContextMenuSubContent>
+ </ContextMenuSub>
+ <ContextMenuSub>
+ <ContextMenuSubTrigger asChild data-attr="inbox-report-context-menu-reviewers">
+ <ButtonPrimitive menuItem>
+ <IconPeople />
+ Reviewers
+ <IconChevronRight className="ml-auto size-3" />
+ </ButtonPrimitive>
+ </ContextMenuSubTrigger>
+ {/* The picker sizes itself; the base menu's 200px cap would clip it. */}
+ <ContextMenuSubContent className="max-w-none">
+ {/* Mounts the report detail logic on open, which loads the same reviewer
+ artefact and member search as the detail pane. */}
+ <ReviewerSearchList report={report} surface="context_menu" />
+ </ContextMenuSubContent>
+ </ContextMenuSub>
+ </ContextMenuGroup>
+ {browserLinkItems}
+ </>
+ )
+}
diff --git a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx
index e86f6ec214ed..b32db1f35343 100644
--- a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx
@@ -23,6 +23,7 @@ import { inboxDetailLayoutLogic } from '../../logics/inboxDetailLayoutLogic'
import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
import { SignalCard } from '../../SignalCard'
import { SignalReport, SignalReportStatus } from '../../types'
+import { canCreateImplementationPr } from '../../utils/reportActions'
import {
displayConventionalCommitTitle,
parseConventionalCommitTitle,
@@ -45,7 +46,7 @@ import { PullRequestDiffPending, PullRequestDiffStat, PullRequestDiffStatSkeleto
import { PullRequestFilesChanged } from './PullRequestFilesChanged'
import { ReportActivitySection } from './ReportActivitySection'
import { ReportChart } from './ReportChart'
-import { canCreateImplementationPr, useReportDetailActions } from './ReportDetailActions'
+import { useReportDetailActions } from './ReportDetailActions'
import { ReportFeedbackFooter } from './ReportFeedbackFooter'
import { ReportSummaryBody } from './ReportSummaryBody'
import { ReportTasksSection } from './ReportTasksSection'
diff --git a/products/signals/frontend/inbox/components/detail/ReportDetailActions.tsx b/products/signals/frontend/inbox/components/detail/ReportDetailActions.tsx
index 1b8a79db147c..0076a2d6195b 100644
--- a/products/signals/frontend/inbox/components/detail/ReportDetailActions.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportDetailActions.tsx
@@ -12,7 +12,8 @@ import { captureInboxReportAction } from '../../inboxAnalytics'
import { inboxSceneLogic } from '../../inboxSceneLogic'
import { inboxBulkActionsLogic } from '../../logics/inboxBulkActionsLogic'
import { INBOX_REPORT_SECTION_LIST_PARAMS, reportListLogic } from '../../logics/reportListLogic'
-import { ACTIONABLE_ACTIONABILITY_VALUES, SignalReport, SignalReportStatus } from '../../types'
+import { SignalReport, SignalReportStatus } from '../../types'
+import { canResolveReport } from '../../utils/reportActions'
import { useReportDismiss } from '../cards/useReportDismiss'
import { useReportRefund } from '../cards/useReportRefund'
import { useReportResolve } from './useReportResolve'
@@ -35,26 +36,6 @@ export interface ReportDetailAction {
primary?: boolean
}
-/**
- * Should the Create PR action be offered? Mirrors desktop `canCreateImplementationPr` /
- * the server-side autostart rules: only when ready & actionable, or blocked on user input.
- */
-export function canCreateImplementationPr(report: SignalReport): boolean {
- if (report.implementation_pr_url) {
- return false
- }
- if (report.already_addressed === true) {
- return false
- }
- if (report.status === 'pending_input') {
- return true
- }
- if (report.status === 'ready') {
- return report.actionability != null && ACTIONABLE_ACTIONABILITY_VALUES.includes(report.actionability)
- }
- return false
-}
-
/**
* Detail-pane actions as data: Resolve, Dismiss/Restore, and Refund. Create PR and Discuss are each
* rendered separately as a standalone dropdown button (`CreatePrButton`, `DiscussReportButton`)
@@ -134,7 +115,7 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction
})
if (dismissedList) {
// The list logic fires the `restore` analytics; just drive navigation here.
- dismissedList.actions.restoreReport(report.id)
+ dismissedList.actions.restoreReport(report.id, 'detail_pane')
router.actions.push(urls.inbox(activeTab))
return
}
@@ -183,11 +164,7 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction
]
}
- // Offer Resolve only where the backend accepts a direct transition to RESOLVED — a researched
- // report (ready or pending_input). Other live statuses (potential, candidate, in_progress,
- // failed) return 409, so don't show a dead-end affordance. Mirrors `canCreateImplementationPr`
- // and the server transition guard.
- const canResolve = report.status === SignalReportStatus.READY || report.status === SignalReportStatus.PENDING_INPUT
+ const canResolve = canResolveReport(report)
const resolve: ReportDetailAction = {
key: 'resolve',
diff --git a/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx b/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx
index a34f15425ba8..4f4821cecf7f 100644
--- a/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx
@@ -18,6 +18,7 @@ import { captureInboxReportAction } from '../../inboxAnalytics'
import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
import { SignalCard } from '../../SignalCard'
import { InboxTabKey, INBOX_TAB_LABEL, SignalReport, SignalReportStatus, SignalSourceProduct } from '../../types'
+import { canCreateImplementationPr } from '../../utils/reportActions'
import {
displayConventionalCommitTitle,
parseConventionalCommitTitle,
@@ -51,7 +52,7 @@ import {
} from './PullRequestDiffPanel'
import { ReportActivitySection } from './ReportActivitySection'
import { ReportChart } from './ReportChart'
-import { canCreateImplementationPr, useReportDetailActions } from './ReportDetailActions'
+import { useReportDetailActions } from './ReportDetailActions'
import { ReportFeedbackFooter } from './ReportFeedbackFooter'
import { ReportTasksSection } from './ReportTasksSection'
import { SuggestedReviewersSection } from './SuggestedReviewersSection'
diff --git a/products/signals/frontend/inbox/components/detail/ReviewerSearchList.tsx b/products/signals/frontend/inbox/components/detail/ReviewerSearchList.tsx
new file mode 100644
index 000000000000..5af8d8b25820
--- /dev/null
+++ b/products/signals/frontend/inbox/components/detail/ReviewerSearchList.tsx
@@ -0,0 +1,192 @@
+import { useActions, useValues } from 'kea'
+import { useMemo, useState } from 'react'
+
+import { IconCheck } from '@posthog/icons'
+import { LemonInput, Spinner } from '@posthog/lemon-ui'
+
+import { PersonDisplay } from 'scenes/persons/PersonDisplay'
+
+import { captureInboxReportAction, InboxReportActionSurface } from '../../inboxAnalytics'
+import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
+import { EnrichedReviewer, SignalReport } from '../../types'
+import {
+ AvailableReviewerOption,
+ getReviewerOptionDisplayName,
+ reviewerMatchesOption,
+ reviewersToWriteContent,
+} from './reviewerDisplay'
+
+/**
+ * Remove one suggested reviewer, optimistically, and record the removal. One implementation for
+ * the picker's untoggle and the detail section's per-row remove button, so the write payload and
+ * the analytics cannot diverge.
+ */
+export function removeSuggestedReviewer({
+ report,
+ surface,
+ target,
+ reviewers,
+ updateReviewers,
+}: {
+ report: SignalReport
+ surface: InboxReportActionSurface
+ target: EnrichedReviewer
+ reviewers: EnrichedReviewer[]
+ updateReviewers: (content: Record<string, string>[], optimistic: EnrichedReviewer[]) => void
+}): void {
+ captureInboxReportAction({
+ report,
+ actionType: 'remove_suggested_reviewer',
+ surface,
+ // Match the shared cross-client contract: the real GitHub login when known, plus the user
+ // uuid desktop always sends, so a breakdown by either property lines web up with desktop.
+ extra: {
+ suggested_reviewer_login: target.github_login || undefined,
+ suggested_reviewer_uuid: target.user?.uuid,
+ },
+ })
+ const next = reviewers.filter((r) => r !== target)
+ updateReviewers(reviewersToWriteContent(next), next)
+}
+
+/**
+ * Searchable org-member list that toggles a report's suggested reviewers, with optimistic updates.
+ * Rendered by the detail pane's "Add" popover and by the report context menu's Reviewers submenu,
+ * so both surfaces offer the same picker. Mounting it mounts the report detail logic, which loads
+ * the reviewer artefact and the searchable members.
+ */
+export function ReviewerSearchList({
+ report,
+ surface,
+}: {
+ report: SignalReport
+ /** Which surface hosts the list, for the add/remove reviewer analytics. */
+ surface: InboxReportActionSurface
+}): JSX.Element {
+ const logic = inboxReportDetailLogic({ reportId: report.id, report })
+ const { displayReviewers, addReviewerOptions, availableReviewersLoading, isUpdatingReviewers, reportArtefacts } =
+ useValues(logic)
+ const { updateReviewers, searchAvailableReviewers } = useActions(logic)
+ // A write is a full replacement, and `displayReviewers` is null until the artefact log lands. The
+ // context menu mounts this logic fresh, so the member search can resolve before the artefacts; a
+ // click in that window would build the write from an empty base and silently wipe every existing
+ // reviewer. Wait for the artefacts (as the detail pane's `SuggestedReviewersSection` already does)
+ // before the rows become clickable. `reportArtefacts !== null` with no reviewer artefact is a real
+ // empty list, so this doesn't block adding the first reviewer.
+ const reviewersLoaded = reportArtefacts !== null
+ const [query, setQuery] = useState('')
+
+ const baseReviewers = displayReviewers ?? []
+ // Assigned set keyed by user uuid (how `reviewerMatchesOption` matches), so the membership
+ // check is O(1) per option instead of scanning every reviewer per keystroke.
+ const assignedUuids = useMemo(
+ () => new Set(baseReviewers.map((r) => r.user?.uuid).filter(Boolean)),
+ [baseReviewers]
+ )
+ const meUuid = addReviewerOptions[0]?.user_uuid
+
+ const toggleOption = (option: AvailableReviewerOption): void => {
+ const existing = baseReviewers.find((r) => reviewerMatchesOption(r, option))
+ if (existing) {
+ removeSuggestedReviewer({ report, surface, target: existing, reviewers: baseReviewers, updateReviewers })
+ return
+ }
+ const optimisticEntry: EnrichedReviewer = {
+ github_login: '',
+ github_name: option.name || null,
+ relevant_commits: [],
+ user: {
+ id: 0,
+ uuid: option.user_uuid,
+ email: option.email,
+ first_name: option.name,
+ last_name: '',
+ },
+ }
+ const next = [...baseReviewers, optimisticEntry]
+ captureInboxReportAction({
+ report,
+ actionType: 'add_suggested_reviewer',
+ surface,
+ // The web option carries only the PostHog user uuid, never a GitHub login, so record it
+ // under suggested_reviewer_uuid to match the shared cross-client event contract.
+ extra: { suggested_reviewer_uuid: option.user_uuid },
+ })
+ updateReviewers([...reviewersToWriteContent(baseReviewers), { user_uuid: option.user_uuid }], next)
+ }
+
+ return (
+ <div
+ className="flex w-72 flex-col gap-2 p-1"
+ // Inside a Radix submenu, keystrokes are typeahead over the menu items and some keys
+ // close the submenu. Keep everything except Escape in the search input; Escape still
+ // reaches the menu so it can close.
+ onKeyDown={(event) => {
+ if (event.key !== 'Escape') {
+ event.stopPropagation()
+ }
+ }}
+ >
+ <LemonInput
+ type="search"
+ size="small"
+ // Search inputs default to a 240px cap, which reads as a broken layout in a panel
+ // only slightly wider; span the panel instead.
+ fullWidth
+ autoFocus
+ placeholder="Search users…"
+ value={query}
+ onChange={(value) => {
+ setQuery(value)
+ searchAvailableReviewers(value)
+ }}
+ />
+ <div className="flex max-h-72 flex-col overflow-y-auto">
+ {availableReviewersLoading || !reviewersLoaded ? (
+ <span className="flex items-center gap-2 px-1 py-2 text-xs text-tertiary">
+ <Spinner className="size-3" />
+ Searching…
+ </span>
+ ) : addReviewerOptions.length === 0 ? (
+ <span className="px-1 py-2 text-xs text-tertiary">No users found.</span>
+ ) : (
+ addReviewerOptions.map((option) => {
+ const assigned = assignedUuids.has(option.user_uuid)
+ const isMe = meUuid === option.user_uuid
+ return (
+ <button
+ key={option.user_uuid}
+ type="button"
+ // The row toggles a reviewer both ways and shows state only through a
+ // decorative check, so announce it: a screen reader needs the pressed
+ // state to tell adding from removing before activation.
+ aria-pressed={assigned}
+ disabled={isUpdatingReviewers}
+ className="flex w-full items-start justify-between gap-2 rounded px-1.5 py-1 text-left transition-colors hover:bg-fill-highlight-50 disabled:opacity-60"
+ onClick={() => toggleOption(option)}
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ <PersonDisplay
+ person={{
+ properties: {
+ email: option.email,
+ name: option.name,
+ },
+ }}
+ displayName={getReviewerOptionDisplayName(option, isMe)}
+ withIcon="xs"
+ noLink
+ noPopover
+ />
+ </div>
+ <span className="flex size-4 shrink-0 items-center justify-center text-primary">
+ {assigned && <IconCheck className="text-sm" />}
+ </span>
+ </button>
+ )
+ })
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/products/signals/frontend/inbox/components/detail/SuggestedReviewersSection.tsx b/products/signals/frontend/inbox/components/detail/SuggestedReviewersSection.tsx
index 4d9feca1e103..202cf0713fb3 100644
--- a/products/signals/frontend/inbox/components/detail/SuggestedReviewersSection.tsx
+++ b/products/signals/frontend/inbox/components/detail/SuggestedReviewersSection.tsx
@@ -1,24 +1,18 @@
import { useActions, useValues } from 'kea'
-import { useMemo, useState } from 'react'
+import { useState } from 'react'
-import { IconCheck, IconInfo, IconPeople, IconPlus, IconX } from '@posthog/icons'
-import { LemonButton, LemonInput, Link, Spinner, Tooltip } from '@posthog/lemon-ui'
+import { IconInfo, IconPeople, IconPlus, IconX } from '@posthog/icons'
+import { LemonButton, Link, Spinner, Tooltip } from '@posthog/lemon-ui'
import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown'
import { PersonDisplay } from 'scenes/persons/PersonDisplay'
-import { captureInboxReportAction } from '../../inboxAnalytics'
import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
import { EnrichedReviewer, SignalReport } from '../../types'
const MAX_VISIBLE_REVIEWERS = 5
import { DetailSection } from './DetailSection'
-import {
- AvailableReviewerOption,
- getReviewerOptionDisplayName,
- reviewerMatchesOption,
- reviewersToWriteContent,
-} from './reviewerDisplay'
+import { removeSuggestedReviewer, ReviewerSearchList } from './ReviewerSearchList'
/**
* Suggested reviewers for the report, read from the `suggested_reviewers` artefact, with add/remove
@@ -27,23 +21,13 @@ import {
*/
export function SuggestedReviewersSection({ report }: { report: SignalReport }): JSX.Element | null {
const logic = inboxReportDetailLogic({ reportId: report.id, report })
- const { displayReviewers, addReviewerOptions, availableReviewersLoading, isUpdatingReviewers, reportArtefacts } =
- useValues(logic)
- const { updateReviewers, searchAvailableReviewers } = useActions(logic)
+ const { displayReviewers, isUpdatingReviewers, reportArtefacts } = useValues(logic)
+ const { updateReviewers } = useActions(logic)
const [addOpen, setAddOpen] = useState(false)
- const [query, setQuery] = useState('')
const [showAllReviewers, setShowAllReviewers] = useState(false)
- const reviewers = displayReviewers
- const baseReviewers = reviewers ?? []
- // Assigned set keyed by user uuid (how `reviewerMatchesOption` matches), so the add-list
- // membership check is O(1) per option instead of scanning every reviewer per keystroke.
- const assignedUuids = useMemo(
- () => new Set(baseReviewers.map((r) => r.user?.uuid).filter(Boolean)),
- [baseReviewers]
- )
- const meUuid = addReviewerOptions[0]?.user_uuid
+ const baseReviewers = displayReviewers ?? []
// Wait for the artefact log to load before rendering, so we don't flash an empty state that then
// fills in. Once loaded, always render — a report with zero reviewers still shows the "Add" affordance
@@ -52,46 +36,8 @@ export function SuggestedReviewersSection({ report }: { report: SignalReport }):
return null
}
- const fireAction = (
- action: 'add_suggested_reviewer' | 'remove_suggested_reviewer',
- login?: string | null
- ): void => {
- captureInboxReportAction({
- report,
- actionType: action,
- surface: 'detail_pane',
- extra: { suggested_reviewer_login: login || undefined },
- })
- }
-
- const removeReviewer = (target: EnrichedReviewer): void => {
- const next = baseReviewers.filter((r) => r !== target)
- fireAction('remove_suggested_reviewer', target.github_login)
- updateReviewers(reviewersToWriteContent(next), next)
- }
-
- const toggleOption = (option: AvailableReviewerOption): void => {
- const existing = baseReviewers.find((r) => reviewerMatchesOption(r, option))
- if (existing) {
- removeReviewer(existing)
- return
- }
- const optimisticEntry: EnrichedReviewer = {
- github_login: '',
- github_name: option.name || null,
- relevant_commits: [],
- user: {
- id: 0,
- uuid: option.user_uuid,
- email: option.email,
- first_name: option.name,
- last_name: '',
- },
- }
- const next = [...baseReviewers, optimisticEntry]
- fireAction('add_suggested_reviewer', option.user_uuid)
- updateReviewers([...reviewersToWriteContent(baseReviewers), { user_uuid: option.user_uuid }], next)
- }
+ const removeReviewer = (target: EnrichedReviewer): void =>
+ removeSuggestedReviewer({ report, surface: 'detail_pane', target, reviewers: baseReviewers, updateReviewers })
return (
<DetailSection
@@ -110,69 +56,10 @@ export function SuggestedReviewersSection({ report }: { report: SignalReport }):
{isUpdatingReviewers && <Spinner className="size-3" />}
<LemonDropdown
visible={addOpen}
- onClickOutside={() => {
- setAddOpen(false)
- setQuery('')
- }}
+ onClickOutside={() => setAddOpen(false)}
closeOnClickInside={false}
placement="bottom-end"
- overlay={
- <div className="flex flex-col gap-2 w-72 p-1">
- <LemonInput
- type="search"
- size="small"
- autoFocus
- placeholder="Search users…"
- value={query}
- onChange={(value) => {
- setQuery(value)
- searchAvailableReviewers(value)
- }}
- />
- <div className="max-h-72 overflow-y-auto flex flex-col">
- {availableReviewersLoading ? (
- <span className="flex items-center gap-2 px-1 py-2 text-xs text-tertiary">
- <Spinner className="size-3" />
- Searching…
- </span>
- ) : addReviewerOptions.length === 0 ? (
- <span className="px-1 py-2 text-xs text-tertiary">No users found.</span>
- ) : (
- addReviewerOptions.map((option) => {
- const assigned = assignedUuids.has(option.user_uuid)
- const isMe = meUuid === option.user_uuid
- return (
- <button
- key={option.user_uuid}
- type="button"
- disabled={isUpdatingReviewers}
- className="flex w-full items-start justify-between gap-2 rounded px-1.5 py-1 text-left transition-colors hover:bg-fill-highlight-50 disabled:opacity-60"
- onClick={() => toggleOption(option)}
- >
- <div className="flex items-center gap-2 min-w-0">
- <PersonDisplay
- person={{
- properties: {
- email: option.email,
- name: option.name,
- },
- }}
- displayName={getReviewerOptionDisplayName(option, isMe)}
- withIcon="xs"
- noLink
- noPopover
- />
- </div>
- <span className="flex size-4 shrink-0 items-center justify-center text-primary">
- {assigned && <IconCheck className="text-sm" />}
- </span>
- </button>
- )
- })
- )}
- </div>
- </div>
- }
+ overlay={<ReviewerSearchList report={report} surface="detail_pane" />}
>
<LemonButton
size="xsmall"
diff --git a/products/signals/frontend/inbox/components/detail/useReportResolve.ts b/products/signals/frontend/inbox/components/detail/useReportResolve.ts
index 014073db0fd8..99bbd5dd46f5 100644
--- a/products/signals/frontend/inbox/components/detail/useReportResolve.ts
+++ b/products/signals/frontend/inbox/components/detail/useReportResolve.ts
@@ -6,6 +6,7 @@ import api from 'lib/api'
import { captureInboxReportAction, InboxReportActionSurface } from '../../inboxAnalytics'
import { SignalReport } from '../../types'
+import { hasOpenImplementationPr } from '../../utils/reportActions'
import { openResolveReportDialog } from '../shell/ResolveReportDialog'
/**
@@ -26,7 +27,7 @@ export function useReportResolve({
}): { isResolving: boolean; onResolveClick: (event: React.MouseEvent) => void } {
const [isResolving, setIsResolving] = useState(false)
// The backend closes an open implementation PR on resolve; the dialog and the toast say so.
- const hasOpenPr = !!report.implementation_pr_url && report.implementation_pr_merged !== true
+ const hasOpenPr = hasOpenImplementationPr(report)
const onResolveClick = (event: React.MouseEvent): void => {
event.preventDefault()
diff --git a/products/signals/frontend/inbox/components/shell/DismissReportDialog.tsx b/products/signals/frontend/inbox/components/shell/DismissReportDialog.tsx
index 83be372ab914..c3ea1e055aab 100644
--- a/products/signals/frontend/inbox/components/shell/DismissReportDialog.tsx
+++ b/products/signals/frontend/inbox/components/shell/DismissReportDialog.tsx
@@ -16,8 +16,13 @@ interface OpenDismissReportDialogParams {
reportTitle?: string | null
/** When greater than 1, copy reflects a bulk dismiss of the current selection. */
selectedCount?: number
+ /** Whether the report has an implementation PR that is still open. Dismissing closes it, so the copy says so. */
+ hasOpenPr?: boolean
/** Show a digit keycap on each reason and let 1..9 pick it. On for triage mode, where the whole flow is keyboard-driven. */
hotkeys?: boolean
+ /** Preselect this reason. The context menu's "Something else…" opens the dialog with it set,
+ * so the person only has to write the note. */
+ initialReason?: DismissalReasonValue
/** Called with the chosen reason + note once the user confirms. */
onConfirm: (result: DismissReportDialogResult) => void | Promise<void>
}
@@ -37,7 +42,9 @@ const REASON_RADIO_OPTIONS: LemonRadioOption<DismissalReasonValue>[] = DISMISSAL
export function openDismissReportDialog({
reportTitle,
selectedCount = 1,
+ hasOpenPr = false,
hotkeys = false,
+ initialReason,
onConfirm,
}: OpenDismissReportDialogParams): void {
const isBulk = selectedCount > 1
@@ -45,15 +52,19 @@ export function openDismissReportDialog({
? `Dismiss ${selectedCount} reports?`
: `Dismiss report "${reportTitle?.trim() ? reportTitle : 'Untitled report'}"?`
const description = isBulk
- ? 'These reports leave your inbox. Your feedback is saved on each report, and your note goes to the agents that filed them.'
- : 'This report leaves your inbox. Your feedback is saved on the report, and your note goes to the agent that filed it.'
+ ? `These reports leave your inbox. Your feedback is saved on each report, and your note goes to the agents that filed them.${
+ hasOpenPr ? ' Any open pull request for these reports is closed.' : ''
+ }`
+ : `This report leaves your inbox. Your feedback is saved on the report, and your note goes to the agent that filed it.${
+ hasOpenPr ? ' The pull request opened for this report is closed.' : ''
+ }`
LemonDialog.openForm({
title,
description,
maxWidth: '36rem',
overlayClassName: '!items-center',
- initialValues: { reason: null as DismissalReasonValue | null, note: '' },
+ initialValues: { reason: initialReason ?? null, note: '' },
content: (
<div className="flex flex-col gap-3">
<LemonField name="reason" label="Reason">
@@ -67,6 +78,12 @@ export function openDismissReportDialog({
</LemonField>
<LemonField name="note" label="Note" info="Optional. The agent reads it on its next run.">
<LemonTextArea
+ // stopPropagation keeps Enter in this multi-line note from reaching the dialog
+ // form and dismissing the report (and closing its PR) mid-sentence.
+ stopPropagation
+ // With the reason already chosen, the note is the only thing left to type.
+ // Never focus otherwise: the hotkey flow reads digits as reason picks.
+ autoFocus={initialReason != null}
placeholder="What made this report wrong, or not worth fixing?"
maxLength={4000}
minRows={5}
diff --git a/products/signals/frontend/inbox/components/shell/ResolveReportDialog.tsx b/products/signals/frontend/inbox/components/shell/ResolveReportDialog.tsx
index 0cc8aef3ca89..e31965f10103 100644
--- a/products/signals/frontend/inbox/components/shell/ResolveReportDialog.tsx
+++ b/products/signals/frontend/inbox/components/shell/ResolveReportDialog.tsx
@@ -20,6 +20,9 @@ interface OpenResolveReportDialogParams {
hasOpenPr?: boolean
/** Show a digit keycap on each reason and let 1..9 pick it. On for triage mode, where the whole flow is keyboard-driven. */
hotkeys?: boolean
+ /** Preselect this reason. The context menu's "Something else…" opens the dialog with it set,
+ * so the person only has to write the note. */
+ initialReason?: ResolveReasonValue
/** Called with the chosen reason + note once the user confirms. */
onConfirm: (result: ResolveReportDialogResult) => void | Promise<void>
}
@@ -41,6 +44,7 @@ export function openResolveReportDialog({
selectedCount = 1,
hasOpenPr = false,
hotkeys = false,
+ initialReason,
onConfirm,
}: OpenResolveReportDialogParams): void {
const isBulk = selectedCount > 1
@@ -58,7 +62,7 @@ export function openResolveReportDialog({
description,
maxWidth: '36rem',
overlayClassName: '!items-center',
- initialValues: { reason: null as ResolveReasonValue | null, note: '' },
+ initialValues: { reason: initialReason ?? null, note: '' },
content: (
<div className="flex flex-col gap-3">
<LemonField name="reason" label="Reason">
@@ -79,6 +83,9 @@ export function openResolveReportDialog({
// stopPropagation keeps Enter in this multi-line note from reaching the dialog
// form and resolving the report (and closing its PR) mid-sentence.
stopPropagation
+ // With the reason already chosen, the note is the only thing left to type.
+ // Never focus otherwise: the hotkey flow reads digits as reason picks.
+ autoFocus={initialReason != null}
placeholder="Link to the pull request or commit, or what fixed it."
maxLength={4000}
minRows={3}
diff --git a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx
index 0452406e5348..a96b98c2ed3b 100644
--- a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx
+++ b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx
@@ -1,4 +1,4 @@
-import { useValues } from 'kea'
+import { useMountedLogic, useValues } from 'kea'
import { JSX, useCallback, useEffect, useRef } from 'react'
import { IconNotebook } from '@posthog/icons'
@@ -11,6 +11,7 @@ import { urls } from 'scenes/urls'
import { captureInboxViewed } from '../../inboxAnalytics'
import { inboxSceneLogic } from '../../inboxSceneLogic'
+import { inboxTaskKickoffLogic } from '../../inboxTaskKickoffLogic'
import { inboxFiltersLogic, isDefaultStateFilter } from '../../logics/inboxFiltersLogic'
import { reportListLogic, sectionListLogicProps } from '../../logics/reportListLogic'
import {
@@ -23,6 +24,7 @@ import {
import { mergeReportRows, selectedFlatListSections } from '../../utils/flatReportList'
import { CardSkeleton } from '../cards/CardSkeleton'
import { ReportCard } from '../cards/ReportCard'
+import { ReportContextMenu } from '../cards/ReportContextMenu'
import { InboxWaitingForWork } from '../emptyState/InboxWaitingForWork'
import { SelfDrivingInstallingHint } from '../SelfDrivingInstallingHint'
import { InboxBulkSelectionBar } from '../shell/InboxBulkSelectionBar'
@@ -192,6 +194,9 @@ function emptyListCopy(scope: InboxScope, narrowed: boolean): string {
*/
export function ReportsTab(): JSX.Element {
const { isStaff } = useValues(inboxSceneLogic)
+ // The row context menus dispatch to this logic and unmount when a menu closes; pinning it here
+ // keeps an in-flight create-PR listener alive past the click that closed the menu.
+ useMountedLogic(inboxTaskKickoffLogic)
const { hasActiveFilters, visibleStateFilter, scope, sortField, sortDirection } = useValues(inboxFiltersLogic)
const sections = useSectionStates()
useInboxViewedEvent(sections)
@@ -349,14 +354,18 @@ export function ReportsTab(): JSX.Element {
) : (
<div className="@container flex flex-col gap-1.5">
{rows.map(({ report, sectionKey }) => (
- <ReportCard
- key={report.id}
- report={report}
- sectionKey={sectionKey}
- onRestore={() =>
- reportListLogic(sectionListLogicProps(sectionKey)).actions.restoreReport(report.id)
- }
- />
+ <ReportContextMenu key={report.id} report={report} sectionKey={sectionKey}>
+ <ReportCard
+ report={report}
+ sectionKey={sectionKey}
+ onRestore={() =>
+ reportListLogic(sectionListLogicProps(sectionKey)).actions.restoreReport(
+ report.id,
+ 'list_row'
+ )
+ }
+ />
+ </ReportContextMenu>
))}
{/* Skeleton cards continue the list while the next pages load – sleeker than a spinner. */}
{pageLoading && <CardSkeleton count={2} variant="cards" dashed />}
diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.ts
index 685e34243162..1d5714bccaef 100644
--- a/products/signals/frontend/inbox/inboxAnalytics.ts
+++ b/products/signals/frontend/inbox/inboxAnalytics.ts
@@ -54,8 +54,14 @@ export const INBOX_EVENTS = {
type InboxEvent = (typeof INBOX_EVENTS)[keyof typeof INBOX_EVENTS]
-/** Action surface an `Inbox report action` fired from. */
-export type InboxReportActionSurface = 'detail_pane' | 'detail_footer' | 'list_row' | 'bulk_bar' | 'triage_mode'
+/** Action surface an `Inbox report action` fired from. `context_menu` is the right-click menu on a list row. */
+export type InboxReportActionSurface =
+ | 'detail_pane'
+ | 'detail_footer'
+ | 'list_row'
+ | 'bulk_bar'
+ | 'triage_mode'
+ | 'context_menu'
/** How a report detail was opened. `triage` is the open-report shortcut in triage mode. */
export type InboxReportOpenMethod = 'click' | 'deeplink' | 'triage' | 'unknown'
diff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
index 27828cb25b0f..0c97fea3a4dc 100644
--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
@@ -716,8 +716,12 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
// Org members with a linked GitHub identity who can be added as reviewers.
// Filtered server-side via `query` (the backend ranks + caps at 100) so the picker
// isn't limited to the alphabetical first page. Empty query loads the default page.
- loadAvailableReviewers: async ({ query }: { query?: string } = {}) => {
- return await api.signalReports.availableReviewers(query)
+ loadAvailableReviewers: async ({ query }: { query?: string } = {}, breakpoint) => {
+ const reviewers = await api.signalReports.availableReviewers(query)
+ // Discard this result if a newer search superseded it while the request was in
+ // flight, so a slower earlier response cannot overwrite the newer rows.
+ breakpoint()
+ return reviewers
},
},
],
diff --git a/products/signals/frontend/inbox/logics/inboxTriageLogic.ts b/products/signals/frontend/inbox/logics/inboxTriageLogic.ts
index bb085a87a825..4cf575de664e 100644
--- a/products/signals/frontend/inbox/logics/inboxTriageLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxTriageLogic.ts
@@ -3,13 +3,13 @@ import { actionToUrl, combineUrl, router, urlToAction } from 'kea-router'
import { urls } from 'scenes/urls'
-import { canCreateImplementationPr } from '../components/detail/ReportDetailActions'
import { openDismissReportDialog } from '../components/shell/DismissReportDialog'
import { openResolveReportDialog } from '../components/shell/ResolveReportDialog'
import { captureInboxReportAction } from '../inboxAnalytics'
import { inboxSceneLogic } from '../inboxSceneLogic'
import { inboxTaskKickoffLogic } from '../inboxTaskKickoffLogic'
import { INBOX_PRIMARY_REPORT_SECTION_KEY, InboxReportSectionKey, SignalReport } from '../types'
+import { canCreateImplementationPr } from '../utils/reportActions'
import { displayConventionalCommitTitle } from '../utils/reportPresentation'
import { INBOX_REPORT_SECTION_LIST_PARAMS, reportListLogic } from './reportListLogic'
diff --git a/products/signals/frontend/inbox/logics/reportListLogic.ts b/products/signals/frontend/inbox/logics/reportListLogic.ts
index 99e9455347eb..dc860cbb2a00 100644
--- a/products/signals/frontend/inbox/logics/reportListLogic.ts
+++ b/products/signals/frontend/inbox/logics/reportListLogic.ts
@@ -10,7 +10,7 @@ import { userLogic } from 'scenes/userLogic'
import type { UserType } from '~/types'
-import { captureInboxReportAction } from '../inboxAnalytics'
+import { captureInboxReportAction, type InboxReportActionSurface } from '../inboxAnalytics'
import {
ACTIONABLE_ACTIONABILITY_VALUES,
INBOX_LEGACY_PRIMARY_REPORT_SECTION_KEY,
@@ -281,8 +281,12 @@ export interface reportListLogicActions {
reason: 'already_fixed' | 'fixed_outside_posthog' | 'other' | 'pr_merged'
reportId: string
}
- restoreReport: (reportId: string) => {
+ restoreReport: (
+ reportId: string,
+ surface: InboxReportActionSurface
+ ) => {
reportId: string
+ surface: InboxReportActionSurface
}
}
@@ -377,7 +381,7 @@ export const reportListLogic = kea<reportListLogicType>([
loadMore: true,
dismissReport: (reportId: string, reason: DismissalReasonValue, note: string) => ({ reportId, reason, note }),
resolveReport: (reportId: string, reason: ResolveReasonValue, note: string) => ({ reportId, reason, note }),
- restoreReport: (reportId: string) => ({ reportId }),
+ restoreReport: (reportId: string, surface: InboxReportActionSurface) => ({ reportId, surface }),
removeReport: (reportId: string) => ({ reportId }),
refresh: true,
}),
@@ -651,13 +655,13 @@ export const reportListLogic = kea<reportListLogicType>([
},
// Restore a suppressed report back to the inbox (transition to `potential`). Optimistically
// drops it from Dismissed; the report re-enters the pipeline and resurfaces elsewhere.
- restoreReport: async ({ reportId }) => {
+ restoreReport: async ({ reportId, surface }) => {
const report = values.reports.find((r) => r.id === reportId)
actions.removeReport(reportId)
try {
await api.signalReports.setState(reportId, { state: 'potential' })
// Fire only after the restore persists, matching ReportDetailActions' fallback path.
- captureInboxReportAction({ report, actionType: 'restore', surface: 'list_row' })
+ captureInboxReportAction({ report, actionType: 'restore', surface })
lemonToast.success('Report restored to inbox')
// Restore maps through restore_target_status server-side, so the report lands back in
// whichever section its pre-suppression status names (a report suppressed while ready
diff --git a/products/signals/frontend/inbox/utils/reportActions.ts b/products/signals/frontend/inbox/utils/reportActions.ts
new file mode 100644
index 000000000000..cc45ee834666
--- /dev/null
+++ b/products/signals/frontend/inbox/utils/reportActions.ts
@@ -0,0 +1,39 @@
+// Pure eligibility predicates for report actions, shared by the detail pane, the triage flow, and
+// the list row context menu, so the surfaces cannot drift apart. Mirrors desktop `reportActions.ts`.
+
+import { ACTIONABLE_ACTIONABILITY_VALUES, SignalReport, SignalReportStatus } from '../types'
+
+/**
+ * Should the Create PR action be offered? Mirrors desktop `canCreateImplementationPr` /
+ * the server-side autostart rules: only when ready & actionable, or blocked on user input.
+ */
+export function canCreateImplementationPr(report: SignalReport): boolean {
+ if (report.implementation_pr_url) {
+ return false
+ }
+ if (report.already_addressed === true) {
+ return false
+ }
+ if (report.status === 'pending_input') {
+ return true
+ }
+ if (report.status === 'ready') {
+ return report.actionability != null && ACTIONABLE_ACTIONABILITY_VALUES.includes(report.actionability)
+ }
+ return false
+}
+
+/**
+ * Offer Resolve only where the backend accepts a direct transition to RESOLVED — a researched
+ * report (ready or pending_input). Other live statuses (potential, candidate, in_progress,
+ * failed) return 409, so don't show a dead-end affordance. Mirrors `canCreateImplementationPr`
+ * and the server transition guard.
+ */
+export function canResolveReport(report: SignalReport): boolean {
+ return report.status === SignalReportStatus.READY || report.status === SignalReportStatus.PENDING_INPUT
+}
+
+/** The backend closes an open implementation PR on resolve; surfaces use this to say so. */
+export function hasOpenImplementationPr(report: SignalReport): boolean {
+ return !!report.implementation_pr_url && report.implementation_pr_merged !== true
+}