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): rate inbox reports with thumbs at the end of the report (#73709)

Andrew Maguire5070d2c96d22
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index d5bb4bf83985..6692e89c5f10 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6167,9 +6167,9 @@ snapshots:
scenes-app-inbox-detail--pull-request--light:
hash: v1.k794b7964.81241ba93c915449049a4b7a031ee65786be1f86e02cbea1b48a4d03a2fcb565.PhkmcKNjTo65tyfb9uKFBd9pqXriYvXP28gY68MovUU
scenes-app-inbox-detail--pull-request-checks-passing--dark:
- hash: v1.k794b7964.fa8c3efea43e09e4e8d64328f4c5da65fb33540f4d5fd38f5bf14dfa30fb2a5c.yl4EHtqzsp958-ddmQfX-UHbZjKCj-2FzLvemFdEDwU
+ hash: v1.k794b7964.5ed98d815a1e187f3afb4d6e60d6ed46b296eb87d494081459a12c57ef16fcfb.li1JoDYyPIOMvLzJwnixH9CaCCKri55Nv0O_xmYIcTs
scenes-app-inbox-detail--pull-request-checks-passing--light:
- hash: v1.k794b7964.eeed41e7a22e885fd4594816445fa96e2da94c900007c5bda32c0dba2cb2fbc1.JzTydv37FrNThMEsks5YYUp6B7tHQAFtH15f7q6fqsw
+ hash: v1.k794b7964.c886b2e3ef4b45b6eab15baba4a06d32e910c6798bdbd9d39e581839ace3e46c.y2ipXvNwvhSqCWFlhnp1nIhQ2x3bnT_md_aUbfJN_vY
scenes-app-inbox-detail--report--dark:
hash: v1.k794b7964.5dbdb8db932b71d680cfe862320fdd7763f2e6fec0ba9619db3db30d3063e462.FVRwvM73SJe4aqe_th8_x5QTQB-S-ObnSWSZQWdcFQA
scenes-app-inbox-detail--report--light:
diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
index 2758f0202009..fad10595d26d 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
@@ -48,6 +48,7 @@ import {
} from './PullRequestDiffPanel'
import { ReportActivitySection } from './ReportActivitySection'
import { useReportDetailActions } from './ReportDetailActions'
+import { ReportFeedbackFooter } from './ReportFeedbackFooter'
import { ReportTasksSection } from './ReportTasksSection'
import { SuggestedReviewersSection } from './SuggestedReviewersSection'
@@ -323,9 +324,12 @@ export function InboxDetailFrame({
onClick: action.onClick,
}))
+ // The rating row is a third grid child rather than part of the main column: stacked (one column)
+ // that puts it last on the page, and on the two-column layout it's placed back under the main
+ // column so it still reads as the end of the report rather than the end of the sidebar.
const overviewBody = (
- <div className="grid grid-cols-1 @5xl:grid-cols-[minmax(0,80ch)_minmax(22rem,1fr)] gap-5">
- <div className="min-w-0 flex flex-col gap-5">
+ <div className="grid grid-cols-1 @5xl:grid-cols-[minmax(0,80ch)_minmax(22rem,1fr)] @5xl:grid-rows-[auto_1fr] gap-5">
+ <div className="min-w-0 flex flex-col gap-5 @5xl:col-start-1 @5xl:row-start-1">
<DetailSection icon={summary.icon} title={summary.title}>
{report.summary ? (
<LemonMarkdown
@@ -343,7 +347,7 @@ export function InboxDetailFrame({
{summaryFooter}
</div>
- <div className="flex flex-col min-w-0 gap-5">
+ <div className="flex flex-col min-w-0 gap-5 @5xl:col-start-2 @5xl:row-start-1 @5xl:row-span-2">
{/* Pull request (when present) first, then reviewers, evidence, runs, and activity. */}
{children}
<SuggestedReviewersSection report={report} />
@@ -373,6 +377,11 @@ export function InboxDetailFrame({
<ReportTasksSection report={report} />
<ReportActivitySection report={report} />
</div>
+
+ {/* `self-start` keeps this pinned under the summary when a tall sidebar stretches the row. */}
+ <div className="min-w-0 self-start @5xl:col-start-1 @5xl:row-start-2">
+ <ReportFeedbackFooter report={report} />
+ </div>
</div>
)
@@ -440,15 +449,18 @@ export function InboxDetailFrame({
</LemonButton>
))}
</div>
- <LemonMenu items={overflowMenuItems} placement="bottom-end">
- <LemonButton
- type="secondary"
- size="small"
- icon={<IconEllipsis />}
- aria-label="More actions"
- className="@4xl:hidden"
- />
- </LemonMenu>
+ {/* A resolved report past its refund window has no secondary actions at all. */}
+ {overflowMenuItems.length > 0 && (
+ <LemonMenu items={overflowMenuItems} placement="bottom-end">
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconEllipsis />}
+ aria-label="More actions"
+ className="@4xl:hidden"
+ />
+ </LemonMenu>
+ )}
</div>
</div>
</div>
@@ -468,7 +480,16 @@ export function InboxDetailFrame({
{diffBranchTag}
</span>
),
- content: <>{diffSection}</>,
+ // `LemonTabs` renders only the active tab, so the rating row is repeated
+ // at the end of the diff – otherwise reviewing a PR's code and stopping
+ // there leaves no way to rate the report. Both rows drive the same
+ // report-keyed logic, so a rating given on one reads back on the other.
+ content: (
+ <div className="flex flex-col gap-5">
+ {diffSection}
+ <ReportFeedbackFooter report={report} />
+ </div>
+ ),
},
]}
/>
diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx
index d75e7d6df2bc..4f8f1439546d 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx
@@ -2,13 +2,13 @@ import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { type MouseEvent, useState } from 'react'
-import { IconArchive, IconMessage, IconPullRequest, IconReceipt, IconUndo } from '@posthog/icons'
+import { IconArchive, IconPullRequest, IconReceipt, IconUndo } from '@posthog/icons'
import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { urls } from 'scenes/urls'
-import { captureInboxReportAction, captureInboxReportFeedback } from '../../inboxAnalytics'
+import { captureInboxReportAction } from '../../inboxAnalytics'
import { inboxSceneLogic } from '../../inboxSceneLogic'
import { inboxTaskKickoffLogic } from '../../inboxTaskKickoffLogic'
import { inboxBulkActionsLogic } from '../../logics/inboxBulkActionsLogic'
@@ -16,7 +16,6 @@ import { INBOX_FLAT_TAB_LIST_PARAMS, reportListLogic } from '../../logics/report
import { ACTIONABLE_ACTIONABILITY_VALUES, SignalReport, SignalReportStatus } from '../../types'
import { useReportArchive } from '../cards/useReportArchive'
import { useReportRefund } from '../cards/useReportRefund'
-import { openFeedbackReportDialog } from '../shell/FeedbackReportDialog'
/**
* One detail-pane action, rendered either inline as a `LemonButton` (wide layouts) or as a
@@ -55,10 +54,11 @@ function canCreateImplementationPr(report: SignalReport): boolean {
}
/**
- * Detail-pane actions as data: Feedback (always), Archive/Restore, and Create PR. Discuss is
- * rendered separately as a standalone dropdown button (`DiscussReportButton`) since it opens a
- * question popover rather than firing on click. Task creation is owned by `inboxTaskKickoffLogic`;
- * archiving reuses the shared `useReportArchive` dialog flow. Callers render these inline or inside a menu.
+ * Detail-pane actions as data: Archive/Restore, Refund, and Create PR. Discuss is rendered
+ * separately as a standalone dropdown button (`DiscussReportButton`) since it opens a question
+ * popover rather than firing on click; rating a report lives at the end of the body
+ * (`ReportFeedbackFooter`). Task creation is owned by `inboxTaskKickoffLogic`; archiving reuses the
+ * shared `useReportArchive` dialog flow. Callers render these inline or inside a menu.
*/
export function useReportDetailActions(report: SignalReport): ReportDetailAction[] {
const { isCreatingPr } = useValues(inboxTaskKickoffLogic)
@@ -144,28 +144,11 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction
}
}
- // Feedback is always available – it never changes the report's state, just records what the
- // user thinks of it (and its PR), so it stays even for resolved/archived reports.
- const feedback: ReportDetailAction = {
- key: 'feedback',
- label: 'Feedback',
- icon: <IconMessage />,
- tooltip: 'Tell us how useful this report was',
- onClick: () =>
- openFeedbackReportDialog({
- reportTitle: report.title ?? 'Untitled report',
- onConfirm: ({ sentiment, note }) => {
- captureInboxReportFeedback({ report, sentiment, note, surface: 'detail_pane' })
- lemonToast.success('Thanks for the feedback')
- },
- }),
- }
-
- // A resolved report is terminal – its PR already merged, so only feedback and Discuss (rendered
- // separately) apply. The PR can still be refunded (auto-approved by design; the weekly review
- // watches refunded-then-merged).
+ // A resolved report is terminal – its PR already merged, so only Discuss (rendered separately)
+ // applies. The PR can still be refunded (auto-approved by design; the weekly review watches
+ // refunded-then-merged).
if (isResolved) {
- return [feedback, ...(canRefund ? [refund] : [])]
+ return canRefund ? [refund] : []
}
// An already-archived report offers Restore instead of Archive (and no Create PR). A refunded
@@ -173,7 +156,6 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction
// archived-but-still-charged report can still be refunded.
if (isArchived) {
return [
- feedback,
...(canRefund ? [refund] : []),
...(report.refund
? []
@@ -191,7 +173,6 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction
}
const actions: ReportDetailAction[] = [
- feedback,
{
key: 'archive',
label: 'Archive',
diff --git a/frontend/src/scenes/inbox/components/detail/ReportFeedbackFooter.tsx b/frontend/src/scenes/inbox/components/detail/ReportFeedbackFooter.tsx
new file mode 100644
index 000000000000..f984e0ca66ad
--- /dev/null
+++ b/frontend/src/scenes/inbox/components/detail/ReportFeedbackFooter.tsx
@@ -0,0 +1,112 @@
+import { useActions, useValues } from 'kea'
+import { useState } from 'react'
+
+import { IconThumbsDown, IconThumbsDownFilled, IconThumbsUp, IconThumbsUpFilled } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea'
+
+import { InboxReportFeedbackSentiment } from '../../inboxAnalytics'
+import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
+import { SignalReport } from '../../types'
+
+// Matches the cap on the sibling inbox dialogs (Dismiss, Refund, Discuss); the note rides along as
+// an analytics property, so keep it under the client's per-property limit.
+const FEEDBACK_NOTE_MAX_LENGTH = 4000
+
+/**
+ * Thumbs rating at the end of the report body, where someone has just finished reading. The rating
+ * submits on the first click, so there's no text field to mistake for the dismissal reason. Only
+ * once it's recorded does an optional note appear, so the note can never gate the rating, and
+ * ignoring it leaves the flow exactly as it was.
+ */
+export function ReportFeedbackFooter({ report }: { report: SignalReport }): JSX.Element {
+ const logic = inboxReportDetailLogic({ reportId: report.id, report })
+ const { feedbackSentiment, feedbackNoteOpen, feedbackNoteDraft, feedbackNoteSent } = useValues(logic)
+ const { rateReport, openFeedbackNote, setFeedbackNoteDraft, submitFeedbackNote } = useActions(logic)
+
+ // Focus the note only when *this* instance opened it. `feedbackNoteOpen` is report-keyed state
+ // shared with the copy of this row on the other tab, and `LemonTabs` remounts tab content, so
+ // an unconditional `autoFocus` would grab focus and scroll on every tab switch with a draft open.
+ const [openedHere, setOpenedHere] = useState(false)
+
+ const isPositive = feedbackSentiment === 'positive'
+ const isNegative = feedbackSentiment === 'negative'
+ // Re-clicking the chosen thumb is a no-op rather than a second identical feedback event.
+ const rate = (sentiment: InboxReportFeedbackSentiment): void => {
+ if (feedbackSentiment !== sentiment) {
+ rateReport(sentiment)
+ }
+ }
+
+ return (
+ <div className="flex flex-col gap-2 pt-1">
+ {/* `select-none` stays on the rating row: on the wrapper it would also cover the note
+ textarea, where it blocks selecting text to edit or copy a draft. */}
+ <div className="flex items-center gap-2 flex-wrap text-xs text-tertiary select-none">
+ <span>{feedbackSentiment ? 'Thanks for the feedback' : 'Was this report useful?'}</span>
+ <div className="flex items-center gap-1">
+ <LemonButton
+ size="xsmall"
+ type={isPositive ? 'primary' : 'secondary'}
+ icon={isPositive ? <IconThumbsUpFilled /> : <IconThumbsUp />}
+ tooltip="Yes, this was useful"
+ aria-label="This report was useful"
+ aria-pressed={isPositive}
+ onClick={() => rate('positive')}
+ data-attr="inbox-report-feedback-thumbs-up"
+ />
+ <LemonButton
+ size="xsmall"
+ type={isNegative ? 'primary' : 'secondary'}
+ icon={isNegative ? <IconThumbsDownFilled /> : <IconThumbsDown />}
+ tooltip="No, this wasn't useful"
+ aria-label="This report was not useful"
+ aria-pressed={isNegative}
+ onClick={() => rate('negative')}
+ data-attr="inbox-report-feedback-thumbs-down"
+ />
+ </div>
+ {feedbackSentiment && !feedbackNoteOpen && !feedbackNoteSent && (
+ <LemonButton
+ size="xsmall"
+ type="tertiary"
+ onClick={() => {
+ setOpenedHere(true)
+ openFeedbackNote()
+ }}
+ data-attr="inbox-report-feedback-add-note"
+ >
+ Add a note
+ </LemonButton>
+ )}
+ {feedbackNoteSent && <span>Note added</span>}
+ </div>
+ {feedbackNoteOpen && (
+ <div className="flex flex-col items-start gap-2 max-w-prose">
+ <LemonTextArea
+ value={feedbackNoteDraft}
+ onChange={setFeedbackNoteDraft}
+ placeholder="What was useful or off?"
+ // The placeholder is the only visible prompt and it disappears on the first
+ // keystroke, so the field carries its own name for screen readers.
+ aria-label="Add a note about this report"
+ maxLength={FEEDBACK_NOTE_MAX_LENGTH}
+ rows={3}
+ autoFocus={openedHere}
+ data-attr="inbox-report-feedback-note"
+ />
+ <LemonButton
+ size="xsmall"
+ type="primary"
+ disabledReason={feedbackNoteDraft.trim() ? undefined : 'Write a note first'}
+ onClick={() => submitFeedbackNote(feedbackNoteDraft)}
+ data-attr="inbox-report-feedback-note-send"
+ >
+ Send
+ </LemonButton>
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/inbox/components/shell/FeedbackReportDialog.tsx b/frontend/src/scenes/inbox/components/shell/FeedbackReportDialog.tsx
deleted file mode 100644
index d342ff33d572..000000000000
--- a/frontend/src/scenes/inbox/components/shell/FeedbackReportDialog.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { IconThumbsDown, IconThumbsUp } from '@posthog/icons'
-
-import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-import { LemonRadio, LemonRadioOption } from 'lib/lemon-ui/LemonRadio'
-import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea'
-
-import { InboxReportFeedbackSentiment } from '../../inboxAnalytics'
-
-// Matches the note cap on the sibling inbox dialogs (Dismiss, Refund, Discuss); the note rides
-// along as an analytics property, so keep it under the client's per-property limit.
-const FEEDBACK_NOTE_MAX_LENGTH = 4000
-
-export interface FeedbackReportDialogResult {
- sentiment: InboxReportFeedbackSentiment
- note: string
-}
-
-interface OpenFeedbackReportDialogParams {
- /** Report title for the dialog copy. */
- reportTitle?: string | null
- /** Called with the chosen sentiment + note once the user submits. */
- onConfirm: (result: FeedbackReportDialogResult) => void | Promise<void>
-}
-
-const SENTIMENT_RADIO_OPTIONS: LemonRadioOption<InboxReportFeedbackSentiment>[] = [
- {
- value: 'positive',
- label: (
- <span className="inline-flex items-center gap-1.5">
- <IconThumbsUp className="shrink-0 text-success" />
- Helpful
- </span>
- ),
- },
- {
- value: 'negative',
- label: (
- <span className="inline-flex items-center gap-1.5">
- <IconThumbsDown className="shrink-0 text-danger" />
- Not helpful
- </span>
- ),
- },
-]
-
-/**
- * Opens the report feedback dialog: pick a thumbs sentiment plus an optional note, then submit.
- * Feedback-only — the report stays in the inbox (unlike {@link openDismissReportDialog}). The
- * caller wires `onConfirm` to fire the `Inbox report feedback` analytics event.
- */
-export function openFeedbackReportDialog({ reportTitle, onConfirm }: OpenFeedbackReportDialogParams): void {
- LemonDialog.openForm({
- title: `Feedback on "${reportTitle?.trim() ? reportTitle : 'Untitled report'}"`,
- description:
- 'Tell us how useful this report was. Your feedback helps the agent improve – it does not archive the report.',
- maxWidth: '30rem',
- initialValues: { sentiment: null as InboxReportFeedbackSentiment | null, note: '' },
- content: (
- <div className="flex flex-col gap-3">
- <LemonField name="sentiment" label="How useful was this?">
- {({ value, onChange }) => (
- <LemonRadio value={value} onChange={onChange} options={SENTIMENT_RADIO_OPTIONS} />
- )}
- </LemonField>
- <LemonField name="note" label="Anything to add?" info="Optional – helps the agent learn">
- <LemonTextArea
- placeholder="Optional: what was useful or off?"
- maxLength={FEEDBACK_NOTE_MAX_LENGTH}
- rows={4}
- // Keep Enter for newlines – without this it bubbles to the dialog's submit-on-Enter handler.
- stopPropagation
- />
- </LemonField>
- </div>
- ),
- errors: {
- sentiment: (sentiment) => (!sentiment ? "You haven't picked a rating" : undefined),
- },
- primaryButtonProps: { children: 'Send feedback' },
- shouldAwaitSubmit: true,
- onSubmit: async ({ sentiment, note }) => {
- if (!sentiment) {
- return
- }
- await onConfirm({ sentiment, note: (note ?? '').trim() })
- },
- })
-}
diff --git a/frontend/src/scenes/inbox/inboxAnalytics.ts b/frontend/src/scenes/inbox/inboxAnalytics.ts
index 6e77f52bde4d..3dd22e6d9976 100644
--- a/frontend/src/scenes/inbox/inboxAnalytics.ts
+++ b/frontend/src/scenes/inbox/inboxAnalytics.ts
@@ -19,6 +19,7 @@ export const INBOX_EVENTS = {
REPORT_CLOSED: 'Inbox report closed',
REPORT_ACTION: 'Inbox report action',
REPORT_FEEDBACK: 'Inbox report feedback',
+ REPORT_FEEDBACK_NOTE: 'Inbox report feedback note',
SOURCE_CONNECTED: 'Signal source connected',
SOURCE_INTEREST: 'signals source interest',
} as const
@@ -26,7 +27,7 @@ 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' | 'list_row' | 'bulk_bar'
+export type InboxReportActionSurface = 'detail_pane' | 'detail_footer' | 'list_row' | 'bulk_bar'
/** How a report detail was opened. */
export type InboxReportOpenMethod = 'click' | 'deeplink' | 'unknown'
@@ -34,7 +35,7 @@ export type InboxReportOpenMethod = 'click' | 'deeplink' | 'unknown'
/** How a report detail was closed. */
export type InboxReportCloseMethod = 'next_report' | 'deselected' | 'unmount'
-/** Sentiment captured by the report feedback button. */
+/** Sentiment captured by the report feedback thumbs. */
export type InboxReportFeedbackSentiment = 'positive' | 'negative'
/**
@@ -231,14 +232,15 @@ export function captureInboxReportAction(params: {
}
/**
- * Free-form feedback on a single report, fired from the detail pane's feedback button. Unlike a
- * dismiss, this is feedback-only: the report stays in the inbox. Carries the thumbs sentiment plus
- * the optional note text so we can read what people actually think of a report (and its PR).
+ * Feedback on a single report, fired from the thumbs at the end of the report body. Unlike a
+ * dismiss, this is feedback-only: the report stays in the inbox. The sentiment is the label the
+ * ranking work trains against, so it carries the same report classification as the impression and
+ * open events. `note` is optional — the thumbs submit on one click, with no note.
*/
export function captureInboxReportFeedback(params: {
report: SignalReport
sentiment: InboxReportFeedbackSentiment
- note: string
+ note?: string
surface: InboxReportActionSurface
}): void {
captureInboxEvent(INBOX_EVENTS.REPORT_FEEDBACK, {
@@ -250,6 +252,27 @@ export function captureInboxReportFeedback(params: {
})
}
+/**
+ * Optional free-text note, offered only once a rating is already recorded. It rides on its own
+ * event rather than re-firing {@link captureInboxReportFeedback} so sentiment stays exactly one
+ * event per rating; join back to the rating on `report_id`. Carries `sentiment` too so a note can
+ * be read without that join.
+ */
+export function captureInboxReportFeedbackNote(params: {
+ report: SignalReport
+ sentiment: InboxReportFeedbackSentiment
+ note: string
+ surface: InboxReportActionSurface
+}): void {
+ captureInboxEvent(INBOX_EVENTS.REPORT_FEEDBACK_NOTE, {
+ ...baseReportProperties(params.report),
+ sentiment: params.sentiment,
+ has_pr: !!params.report.implementation_pr_url,
+ note: params.note,
+ surface: params.surface,
+ })
+}
+
export function captureSignalSourceConnected(params: {
sourceProduct: string
sourceType: string
diff --git a/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts b/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
index ec12f40bc5e9..12b6fc6c302a 100644
--- a/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
+++ b/frontend/src/scenes/inbox/logics/inboxReportDetailLogic.ts
@@ -45,6 +45,11 @@ import {
buildAddReviewerOptions,
CurrentReviewerUser,
} from '../components/detail/reviewerDisplay'
+import {
+ captureInboxReportFeedback,
+ captureInboxReportFeedbackNote,
+ InboxReportFeedbackSentiment,
+} from '../inboxAnalytics'
import {
EnrichedReviewer,
SignalReport,
@@ -121,6 +126,10 @@ export interface inboxReportDetailLogicValues {
diffArtefactId: string | null
displayReviewers: EnrichedReviewer[] | null
expandedTaskIds: string[]
+ feedbackNoteDraft: string
+ feedbackNoteOpen: boolean
+ feedbackNoteSent: boolean
+ feedbackSentiment: InboxReportFeedbackSentiment | null
hasImplementationPr: boolean
isReResearch: boolean
isReportActive: boolean
@@ -277,9 +286,18 @@ export interface inboxReportDetailLogicActions {
reportTasks: ReportTaskEntry[]
payload?: any
}
+ openFeedbackNote: () => {
+ value: true
+ }
+ rateReport: (sentiment: InboxReportFeedbackSentiment) => {
+ sentiment: InboxReportFeedbackSentiment
+ }
searchAvailableReviewers: (query: string) => {
query: string
}
+ setFeedbackNoteDraft: (draft: string) => {
+ draft: string
+ }
setOptimisticReviewers: (reviewers: EnrichedReviewer[] | null) => {
reviewers: EnrichedReviewer[] | null
}
@@ -289,6 +307,9 @@ export interface inboxReportDetailLogicActions {
setSelectedTaskId: (taskId: string | null) => {
taskId: string | null
}
+ submitFeedbackNote: (note: string) => {
+ note: string
+ }
toggleExpandedTask: (taskId: string) => {
taskId: string
}
@@ -364,6 +385,13 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
setSelectedTaskId: (taskId: string | null) => ({ taskId }),
// Inline-expand a linked task's run log within the report detail's Runs section.
toggleExpandedTask: (taskId: string) => ({ taskId }),
+ // Thumbs feedback at the end of the report body. Analytics-only – nothing about the report changes.
+ rateReport: (sentiment: InboxReportFeedbackSentiment) => ({ sentiment }),
+ // Optional note, offered only after a rating is in. The rating is never held up waiting for it.
+ openFeedbackNote: true,
+ setFeedbackNoteDraft: (draft: string) => ({ draft }),
+ // The note rides on the payload: the reducers below clear the draft, and listeners run after them.
+ submitFeedbackNote: (note: string) => ({ note }),
}),
loaders(({ props, values }) => ({
@@ -539,6 +567,39 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
setReport: () => [],
},
],
+ // The thumbs rating this reader gave the open report, so the row can read the choice back.
+ // The logic is keyed by report id, so each report keeps its own rating for as long as it's open.
+ feedbackSentiment: [
+ null as InboxReportFeedbackSentiment | null,
+ {
+ rateReport: (_, { sentiment }) => sentiment,
+ },
+ ],
+ // Whether the optional note field is showing. Switching the rating closes an unsent note so
+ // the draft can't end up attached to a sentiment the reader has since changed their mind about.
+ feedbackNoteOpen: [
+ false,
+ {
+ openFeedbackNote: () => true,
+ rateReport: () => false,
+ submitFeedbackNote: () => false,
+ },
+ ],
+ feedbackNoteDraft: [
+ '',
+ {
+ setFeedbackNoteDraft: (_, { draft }) => draft,
+ rateReport: () => '',
+ submitFeedbackNote: () => '',
+ },
+ ],
+ feedbackNoteSent: [
+ false,
+ {
+ submitFeedbackNote: () => true,
+ rateReport: () => false,
+ },
+ ],
// Human-readable diff-load failure (kea-loaders only exposes a boolean loading flag). A failed
// compare usually means the branch was merged, deleted, or force-rewritten away.
reportDiffError: [
@@ -730,6 +791,25 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
}),
listeners(({ actions, values, cache, props }) => ({
+ rateReport: ({ sentiment }) => {
+ if (!values.report) {
+ return
+ }
+ captureInboxReportFeedback({ report: values.report, sentiment, surface: 'detail_footer' })
+ },
+ // Fires on its own event so the rating stays exactly one `Inbox report feedback` per click.
+ submitFeedbackNote: ({ note }) => {
+ const trimmed = note.trim()
+ if (!values.report || !values.feedbackSentiment || !trimmed) {
+ return
+ }
+ captureInboxReportFeedbackNote({
+ report: values.report,
+ sentiment: values.feedbackSentiment,
+ note: trimmed,
+ surface: 'detail_footer',
+ })
+ },
searchAvailableReviewers: async ({ query }, breakpoint) => {
await breakpoint(300)
actions.loadAvailableReviewers({ query: query.trim() || undefined })