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(desktop): clarify suggested reviewer layout (#106814)

Mikayla Thompsone050fde5ab05
diff --git a/products/desktop/docs/SELF-DRIVING-REPORTS.md b/products/desktop/docs/SELF-DRIVING-REPORTS.md
index d7a955f9b8e7..a4582cf8a688 100644
--- a/products/desktop/docs/SELF-DRIVING-REPORTS.md
+++ b/products/desktop/docs/SELF-DRIVING-REPORTS.md
@@ -15,7 +15,7 @@ Marking a draft ready does not approve or merge it. Existing merge checks still
Eligible pull requests show Refund in the header. The existing feature flag, billing checks, and confirmation dialog still apply.
The report ends with feedback after its evidence, reviewers, and other supporting sections.
-The suggested reviewer views show each reviewer source and reason. Reviewers with the same reason appear in one compact group.
+The suggested reviewer views show each reviewer source and reason. Each reason appears above its indented reviewer or reviewers, without a separate box. The remove control stays visible, and Add Reviewer appears as a button at the bottom of the section.
The recommendation keeps its boxed layout and its Ask about it and Dismiss controls.
Informational recommendations, including Likely already fixed, use a blue callout. Decisions use an amber callout.
diff --git a/products/desktop/packages/core/src/inbox/artefacts.test.ts b/products/desktop/packages/core/src/inbox/artefacts.test.ts
index 67eafcbc2290..413aa1348481 100644
--- a/products/desktop/packages/core/src/inbox/artefacts.test.ts
+++ b/products/desktop/packages/core/src/inbox/artefacts.test.ts
@@ -74,7 +74,7 @@ describe("artefacts", () => {
).toBe("Ben W.");
});
- it("groups repeated reviewer reasons within the same source category", () => {
+ it("groups reviewers by reason and source, including single reviewers", () => {
const sharedReason = "Maintains the request execution parser.";
const reviewer = (
id: string,
@@ -123,13 +123,19 @@ describe("artefacts", () => {
"reason-group",
JSON.stringify(["reason-group", sharedReason, "other", "Code history"]),
],
- ["person", "rowan"],
+ [
+ "reason-group",
+ JSON.stringify(["reason-group", `${sharedReason} `, "scout", null]),
+ ],
["person", "casey"],
]);
expect(items[0]?.kind === "reason-group" && items[0].reviewers).toEqual([
expect.objectContaining({ github_login: "avery" }),
expect.objectContaining({ github_login: "morgan" }),
]);
+ expect(items[2]?.kind === "reason-group" && items[2].reviewers).toEqual([
+ expect.objectContaining({ github_login: "rowan" }),
+ ]);
});
it("moves the current user to the front", () => {
diff --git a/products/desktop/packages/core/src/inbox/artefacts.ts b/products/desktop/packages/core/src/inbox/artefacts.ts
index 828516e0905a..035d068b5648 100644
--- a/products/desktop/packages/core/src/inbox/artefacts.ts
+++ b/products/desktop/packages/core/src/inbox/artefacts.ts
@@ -131,23 +131,11 @@ export function buildSuggestedReviewerItems(
reviewers: SuggestedReviewer[],
): SuggestedReviewerItem[] {
const items: SuggestedReviewerItem[] = [];
- const reasonCounts = new Map<string, number>();
const reasonGroups = new Map<string, SuggestedReviewerReasonGroupItem>();
for (const reviewer of reviewers) {
const reason = suggestedReviewerExplanation(reviewer);
- if (reason) {
- const groupKey = suggestedReviewerReasonGroupKey(reviewer, reason);
- reasonCounts.set(groupKey, (reasonCounts.get(groupKey) ?? 0) + 1);
- }
- }
-
- for (const reviewer of reviewers) {
- const reason = suggestedReviewerExplanation(reviewer);
- const groupKey = reason
- ? suggestedReviewerReasonGroupKey(reviewer, reason)
- : null;
- if (!reason || !groupKey || reasonCounts.get(groupKey) === 1) {
+ if (!reason) {
items.push({
kind: "person",
key: suggestedReviewerKey(reviewer),
@@ -156,6 +144,7 @@ export function buildSuggestedReviewerItems(
continue;
}
+ const groupKey = suggestedReviewerReasonGroupKey(reviewer, reason);
const existing = reasonGroups.get(groupKey);
if (existing) {
existing.reviewers.push(reviewer);
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.stories.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.stories.tsx
new file mode 100644
index 000000000000..935cbd2f1635
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.stories.tsx
@@ -0,0 +1,77 @@
+import type { SignalReport, SuggestedReviewer } from "@posthog/shared/types";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { ReportReviewersSectionView } from "./ReportReviewersSection";
+
+const report: SignalReport = {
+ id: "report-1",
+ title: "Review request handling",
+ summary: "Summary",
+ status: "ready",
+ total_weight: 1,
+ signal_count: 1,
+ artefact_count: 1,
+ created_at: "2026-08-20T09:00:00Z",
+ updated_at: "2026-08-20T09:00:00Z",
+};
+
+function reviewer(
+ id: string,
+ name: string,
+ fields: Partial<SuggestedReviewer>,
+): SuggestedReviewer {
+ return {
+ github_login: id,
+ github_name: name,
+ relevant_commits: [],
+ user: {
+ id: 1,
+ uuid: id,
+ first_name: name,
+ last_name: "",
+ email: `${id}@example.com`,
+ },
+ ...fields,
+ };
+}
+
+const sharedReason = "Maintains request handling and retry behavior.";
+
+const meta: Meta<typeof ReportReviewersSectionView> = {
+ title: "Inbox/Reports/Suggested reviewers section",
+ component: ReportReviewersSectionView,
+ parameters: { layout: "centered" },
+ decorators: [
+ (Story) => (
+ <div className="w-[22rem]">
+ <Story />
+ </div>
+ ),
+ ],
+ args: { report, disabled: false, onRemove: () => undefined },
+};
+
+export default meta;
+type Story = StoryObj<typeof ReportReviewersSectionView>;
+
+export const GroupedReviewers: Story = {
+ args: {
+ reviewers: [
+ reviewer("avery", "Avery Chen", {
+ reason: sharedReason,
+ explanation: sharedReason,
+ source_skill: "signals-scout-runtime-ownership",
+ source_label: "Runtime ownership scout",
+ }),
+ reviewer("jordan", "Jordan Lee", {
+ reason: sharedReason,
+ explanation: sharedReason,
+ source_skill: "signals-scout-runtime-ownership",
+ source_label: "Runtime ownership scout",
+ }),
+ reviewer("rowan", "Rowan Patel", {
+ explanation: "Recently changed the affected transport.",
+ source_label: "Code history",
+ }),
+ ],
+ },
+};
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.test.tsx
index 572f11d1a9f0..c3157583e3f7 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.test.tsx
@@ -35,9 +35,19 @@ describe("ReportReviewersSection", () => {
render(<ReportReviewersSection report={report} />);
expect(screen.getByText("Suggested reviewers")).toBeInTheDocument();
+ const emptyMessage = screen.getByText("No suggested reviewers yet.");
+ const addButton = screen.getByRole("button", { name: "Add Reviewer" });
+ expect(emptyMessage).toBeInTheDocument();
expect(
- screen.getByText("No suggested reviewers. Select Add to suggest one."),
+ emptyMessage.compareDocumentPosition(addButton) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
+ expect(
+ screen.getByText("Suggested reviewers").closest("header"),
+ ).not.toContainElement(addButton);
+ expect(screen.queryByText("0")).not.toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: "About suggested reviewers" }),
).toBeInTheDocument();
- expect(screen.getByText("Add")).toBeInTheDocument();
});
});
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx
index 77cb86b6001c..fd062c4dd389 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx
@@ -31,7 +31,6 @@ export function ReportReviewersSection({ report }: { report: SignalReport }) {
const { data } = useInboxReportArtefacts(report.id);
const artefact = selectSuggestedReviewersArtefact(data?.results ?? []);
const reviewers = useMemo(() => artefact?.content ?? [], [artefact]);
- const [addOpen, setAddOpen] = useState(false);
const { mutate: updateReviewers, isPending } = useUpdateSuggestedReviewers(
report.id,
);
@@ -64,75 +63,93 @@ export function ReportReviewersSection({ report }: { report: SignalReport }) {
);
};
+ return (
+ <ReportReviewersSectionView
+ report={report}
+ reviewers={reviewers}
+ disabled={isPending}
+ onRemove={removeReviewer}
+ />
+ );
+}
+
+export function ReportReviewersSectionView({
+ report,
+ reviewers,
+ disabled,
+ onRemove,
+}: {
+ report: SignalReport;
+ reviewers: SuggestedReviewer[];
+ disabled: boolean;
+ onRemove: (reviewer: SuggestedReviewer) => void;
+}) {
+ const [addOpen, setAddOpen] = useState(false);
+
return (
<DetailSection
Icon={UsersThreeIcon}
title="Suggested reviewers"
collapsible
- rightSlot={
- <div className="flex items-center gap-2">
- <Tooltip>
- <TooltipTrigger
- render={
- <button
- type="button"
- aria-label="About suggested reviewers"
- className="rounded-sm p-0.5 text-muted-foreground hover:bg-fill-hover hover:text-foreground"
- />
- }
- >
- <InfoIcon size={12} />
- </TooltipTrigger>
- <TooltipContent side="top" className="max-w-80">
- PostHog uses these suggestions to route the report. Add reviewers
- on the pull request to request a GitHub review.
- </TooltipContent>
- </Tooltip>
- <span className="text-[12px] text-gray-10 tabular-nums">
- {reviewers.length}
- </span>
- <Popover open={addOpen} onOpenChange={setAddOpen}>
- <PopoverTrigger
- render={
- <Button
- type="button"
- variant="link-muted"
- size="xs"
- disabled={isPending}
- data-attr="inbox-report-add-reviewer"
- >
- {isPending ? <Spinner /> : <PlusIcon size={12} />}
- Add
- </Button>
- }
- />
- <PopoverContent
- align="end"
- side="bottom"
- sideOffset={6}
- className="min-w-[280px] max-w-[320px] p-0"
- >
- <ReviewerSearchList
- report={report}
- surface="detail_pane"
- enabled={addOpen}
- />
- </PopoverContent>
- </Popover>
- </div>
- }
>
{reviewers.length === 0 ? (
<p className="m-0 text-muted-foreground text-xs">
- No suggested reviewers. Select Add to suggest one.
+ No suggested reviewers yet.
</p>
) : (
<SuggestedReviewersList
reviewers={reviewers}
- disabled={isPending}
- onRemove={removeReviewer}
+ disabled={disabled}
+ onRemove={onRemove}
/>
)}
+ <div className="mt-3 flex items-center justify-between gap-2">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ aria-label="About suggested reviewers"
+ className="rounded-sm p-0.5 text-muted-foreground hover:bg-fill-hover hover:text-foreground"
+ />
+ }
+ >
+ <InfoIcon size={12} />
+ </TooltipTrigger>
+ <TooltipContent side="top" className="max-w-80">
+ PostHog uses these suggestions to route the report. Add reviewers on
+ the pull request to request a GitHub review.
+ </TooltipContent>
+ </Tooltip>
+ <Popover open={addOpen} onOpenChange={setAddOpen}>
+ <PopoverTrigger
+ render={
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={disabled}
+ data-attr="inbox-report-add-reviewer"
+ >
+ {disabled ? <Spinner /> : <PlusIcon size={14} />}
+ Add Reviewer
+ </Button>
+ }
+ />
+ <PopoverContent
+ align="end"
+ side="bottom"
+ sideOffset={6}
+ className="min-w-[280px] max-w-[320px] p-0"
+ >
+ <ReviewerSearchList
+ report={report}
+ surface="detail_pane"
+ enabled={addOpen}
+ />
+ </PopoverContent>
+ </Popover>
+ </div>
</DetailSection>
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.test.tsx
index 5412aba00643..cf1a7330b49d 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.test.tsx
@@ -21,6 +21,57 @@ function ungroupedReviewer(index: number): SuggestedReviewer {
}
describe("SuggestedReviewersList", () => {
+ it("shows a single reviewer's reason before the indented reviewer", () => {
+ render(
+ <SuggestedReviewersList
+ reviewers={[ungroupedReviewer(0)]}
+ disabled={false}
+ onRemove={vi.fn()}
+ />,
+ );
+
+ const reasonElement = screen.getByText("Owns area 0.");
+ const reviewerElement = screen.getByText("Dev 0");
+ expect(
+ reasonElement.compareDocumentPosition(reviewerElement) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
+ expect(reviewerElement.closest(".pl-3")).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Remove Dev 0" })).toBeVisible();
+ });
+
+ it("shows the shared reason before its indented reviewers and always shows remove controls", () => {
+ const reason = "Maintains request handling.";
+ const reviewers = [0, 1].map((index) => ({
+ ...ungroupedReviewer(index),
+ reason,
+ explanation: reason,
+ }));
+
+ render(
+ <SuggestedReviewersList
+ reviewers={reviewers}
+ disabled={false}
+ onRemove={vi.fn()}
+ />,
+ );
+
+ const reasonElement = screen.getByText(reason);
+ const firstReviewer = screen.getByText("Dev 0");
+ expect(
+ reasonElement.compareDocumentPosition(firstReviewer) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
+ expect(firstReviewer.closest(".pl-3")).toBeInTheDocument();
+ expect(reasonElement.parentElement?.parentElement).not.toHaveClass(
+ "border",
+ );
+ expect(screen.getAllByRole("button", { name: /^Remove / })).toHaveLength(2);
+ expect(
+ screen.getByRole("button", { name: "Remove Dev 0" }),
+ ).not.toHaveClass("opacity-0");
+ });
+
it.each([
[
"a hover",
diff --git a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.tsx b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.tsx
index 04fb1d468036..2451a29ace10 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewersList.tsx
@@ -3,7 +3,6 @@ import {
buildSuggestedReviewerItems,
isScoutSuggestedReviewer,
suggestedReviewerDisplayName,
- suggestedReviewerExplanation,
suggestedReviewerSourceLabel,
} from "@posthog/core/inbox/artefacts";
import {
@@ -114,7 +113,6 @@ function RemoveReviewerButton({
aria-label={`Remove ${displayName}`}
disabled={disabled}
data-attr="inbox-report-remove-reviewer"
- className="opacity-0 group-focus-within:opacity-100 group-hover:opacity-100"
onClick={() => onRemove(reviewer)}
>
<XIcon size={12} />
@@ -131,10 +129,9 @@ function SuggestedReviewerPerson({
disabled: boolean;
onRemove?: (reviewer: SuggestedReviewer) => void;
}) {
- const explanation = suggestedReviewerExplanation(reviewer);
const sourceLabel = suggestedReviewerSourceLabel(reviewer);
return (
- <div className="group grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-2 gap-y-1 rounded-sm px-1.5 py-1.5 hover:bg-fill-hover">
+ <div className="grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-2 rounded-sm px-1.5 py-1.5 hover:bg-fill-hover">
<ReviewerIdentity reviewer={reviewer} />
{isScoutSuggestedReviewer(reviewer) ? (
<ScoutSourceBadge scoutNames={[sourceLabel]} />
@@ -148,13 +145,6 @@ function SuggestedReviewerPerson({
onRemove={onRemove}
/>
) : null}
- {explanation ? (
- <p
- className={`col-span-3 m-0 min-w-0 break-words text-muted-foreground text-xs leading-snug ${reviewer.user ? "" : "opacity-70"}`}
- >
- {explanation}
- </p>
- ) : null}
</div>
);
}
@@ -179,8 +169,21 @@ function SuggestedReviewerReasonGroup({
}
return (
- <div className="overflow-hidden rounded-sm border border-border bg-muted/40">
- <div className="flex flex-col p-1">
+ <div className="min-w-0 py-1">
+ <div className="flow-root min-w-0">
+ <div className="float-right ml-2 flex min-w-0 flex-wrap justify-end gap-1">
+ {scoutNames.size > 0 ? (
+ <ScoutSourceBadge scoutNames={[...scoutNames]} />
+ ) : null}
+ {[...otherSourceLabels].map((sourceLabel) => (
+ <ReviewerSourceBadge key={sourceLabel} label={sourceLabel} />
+ ))}
+ </div>
+ <p className="m-0 min-w-0 break-words text-muted-foreground text-xs leading-snug">
+ {reason}
+ </p>
+ </div>
+ <div className="mt-1 flex flex-col pl-3">
{reviewers.map((reviewer) => (
<div
key={
@@ -189,7 +192,7 @@ function SuggestedReviewerReasonGroup({
reviewer.github_login ??
suggestedReviewerDisplayName(reviewer)
}
- className="group flex min-w-0 items-center gap-2 rounded-sm py-0.5 pr-0.5 pl-1.5 hover:bg-fill-hover"
+ className="flex min-w-0 items-center gap-2 rounded-sm py-0.5 pr-0.5 hover:bg-fill-hover"
>
<div className="min-w-0 flex-1">
<ReviewerIdentity reviewer={reviewer} />
@@ -204,19 +207,6 @@ function SuggestedReviewerReasonGroup({
</div>
))}
</div>
- <div className="flow-root min-w-0 border-border border-t px-2.5 py-2">
- <div className="float-right ml-2 flex min-w-0 flex-wrap justify-end gap-1">
- {scoutNames.size > 0 ? (
- <ScoutSourceBadge scoutNames={[...scoutNames]} />
- ) : null}
- {[...otherSourceLabels].map((sourceLabel) => (
- <ReviewerSourceBadge key={sourceLabel} label={sourceLabel} />
- ))}
- </div>
- <p className="m-0 min-w-0 break-words text-muted-foreground text-xs leading-snug">
- {reason}
- </p>
- </div>
</div>
);
}