: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): send explicit reviewer edits from desktop and mobile (#121356)
Dylan Martinc75dc178edbd
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsx b/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsxindex 263f9b642e61..323a8401ce2d 100644--- a/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsx+++ b/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsx@@ -117,6 +117,8 @@ describe("SuggestedReviewerAvatarStack", () => {expect(mocks.mutate).toHaveBeenCalledWith({artefactId: "reviewers-1",content: [{ user_uuid: "user-bob" }],+ action: "remove",+ targets: [{ user_uuid: "user-me" }],optimisticReviewers: [teammate],});expect(mocks.track).toHaveBeenCalledWith(diff --git a/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.tsx b/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.tsxindex 7308c39af215..0e46ef681749 100644--- a/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.tsx+++ b/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewerAvatarStack.tsx@@ -103,6 +103,8 @@ export function SuggestedReviewerAvatarStack({updateReviewers({artefactId: reviewerArtefact.id,content: toSuggestedReviewerWriteContent(next),+ action: "remove",+ targets: toSuggestedReviewerWriteContent([currentReviewer]),optimisticReviewers: next,});};diff --git a/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewers.tsx b/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewers.tsxindex 73030f3bf960..2161e6573695 100644--- a/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewers.tsx+++ b/products/desktop/apps/mobile/src/features/inbox/components/SuggestedReviewers.tsx@@ -69,6 +69,8 @@ export function SuggestedReviewers({updateReviewers({artefactId: artefact.id,content: toSuggestedReviewerWriteContent(next),+ action: "remove",+ targets: toSuggestedReviewerWriteContent([target]),optimisticReviewers: next,});};@@ -103,6 +105,8 @@ export function SuggestedReviewers({...toSuggestedReviewerWriteContent(reviewers),{ user_uuid: option.uuid },],+ action: "add",+ targets: [{ user_uuid: option.uuid }],optimisticReviewers: [...reviewers, optimisticEntry],});};diff --git a/products/desktop/apps/mobile/src/features/inbox/hooks/useInboxReports.ts b/products/desktop/apps/mobile/src/features/inbox/hooks/useInboxReports.tsindex c76000f4ea0f..91085e37ef94 100644--- a/products/desktop/apps/mobile/src/features/inbox/hooks/useInboxReports.ts+++ b/products/desktop/apps/mobile/src/features/inbox/hooks/useInboxReports.ts@@ -1,3 +1,4 @@+import type { SuggestedReviewerEdit } from "@posthog/api-client/posthog-client";import {buildArchiveListOrdering,buildPriorityFilterParam,@@ -237,7 +238,7 @@ export function useInboxReportSignals(reportId: string | null) {});}-interface UpdateSuggestedReviewersVariables {+interface UpdateSuggestedReviewersVariables extends SuggestedReviewerEdit {artefactId: string;content: SuggestedReviewerWriteEntry[];optimisticReviewers: SuggestedReviewer[];@@ -253,9 +254,12 @@ export function useUpdateSuggestedReviewers(reportId: string) {UpdateSuggestedReviewersVariables,{ previous: SignalReportArtefactsResponse | undefined }>({- mutationFn: ({ artefactId, content }) =>+ mutationFn: ({ artefactId, content, action, targets }) =>getPostHogApiClient()- .updateSignalReportArtefact(reportId, artefactId, content)+ .updateSignalReportArtefact(reportId, artefactId, content, {+ action,+ targets,+ }).then(() => undefined),onMutate: async ({ artefactId, optimisticReviewers }) => {await queryClient.cancelQueries({ queryKey });diff --git a/products/desktop/packages/api-client/endpoint-allowlist.json b/products/desktop/packages/api-client/endpoint-allowlist.jsonindex 981a2ef85170..f163ff98f7d1 100644--- a/products/desktop/packages/api-client/endpoint-allowlist.json+++ b/products/desktop/packages/api-client/endpoint-allowlist.json@@ -79,6 +79,7 @@"PersonRecord","ProjectBackwardCompat","SessionRecording",+ "SignalReportArtefactWrite","Survey","TaskCreate","TaskDetailDTO",diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.tsindex d82ba515819f..c8e84325d3c6 100644--- a/products/desktop/packages/api-client/src/generated.ts+++ b/products/desktop/packages/api-client/src/generated.ts@@ -20733,6 +20733,27 @@ export namespace Schemas {*/states: Record<string, boolean>;};+ /**+ * * `add` - Add+ * * `remove` - Remove+ * * `replace` - Replace+ * * `confirm` - Confirm+ */+ export type ReviewerEditActionEnum =+ | "add"+ | "remove"+ | "replace"+ | "confirm";+ export type ReviewerState = {+ /**+ * Current reviewer artefact ID, or null before the first list.+ */+ reviewers_id: string | null;+ /**+ * Current corrections artefact ID, or null before corrections are stored.+ */+ corrections_id: string | null;+ };export type RowFilterColumn = {/*** Column name to use as `column` in a row filter.@@ -20789,6 +20810,28 @@ export namespace Schemas {*/event_count: number | null;};+ /**+ * Single entry in a PUT body for a `suggested_reviewers` artefact.+ *+ * Each entry must identify a reviewer by at least one of `github_login` or `user_uuid`. A+ * `user_uuid` only has to name an org member on this team — a member with no linked GitHub+ * account is stored by uuid and routes like any other reviewer.+ */+ export type SuggestedReviewerEntryWrite = Partial<{+ github_login: string;+ user_uuid: string;+ github_name: string;+ reason: string | null;+ }>;+ export type SignalReportArtefactWrite = {+ action?: (ReviewerEditActionEnum & unknown) | undefined;+ expected_reviewers?: ReviewerState | undefined;+ /**+ * People to add, remove, or keep in a replacement. Send an empty list for confirmation.+ */+ content: Array<SuggestedReviewerEntryWrite>;+ targets?: Array<SuggestedReviewerEntryWrite> | undefined;+ };/*** Mixin for serializers to add user access control fields*/diff --git a/products/desktop/packages/api-client/src/posthog-client.test.ts b/products/desktop/packages/api-client/src/posthog-client.test.tsindex 2ac0041517b3..eae898b104c8 100644--- a/products/desktop/packages/api-client/src/posthog-client.test.ts+++ b/products/desktop/packages/api-client/src/posthog-client.test.ts@@ -3011,16 +3011,21 @@ describe("PostHogAPIClient", () => {it.each([{- name: "PUTs the full-replacement content and returns the parsed artefact",+ name: "adds only the target and keeps the full list for older servers",+ edit: { action: "add" as const, targets: [{ user_uuid: "uuid-1" }] },input: [{ github_login: "octocat" }, { user_uuid: "uuid-1" }],responseContent: [OCTOCAT_REVIEWER],},{- name: "sends an empty content array when clearing reviewers",+ name: "removes only the target with an empty legacy fallback",+ edit: {+ action: "remove" as const,+ targets: [{ github_login: "octocat" }],+ },input: [],responseContent: [],},- ])("$name", async ({ input, responseContent }) => {+ ])("$name", async ({ input, responseContent, edit }) => {const fetch = vi.fn().mockResolvedValue({ok: true,json: async () => ({@@ -3036,6 +3041,7 @@ describe("PostHogAPIClient", () => {"report-1","art-1",input,+ edit,);expect(result.type).toBe("suggested_reviewers");@@ -3044,7 +3050,7 @@ describe("PostHogAPIClient", () => {expect.objectContaining({method: "put",path: ARTEFACT_PATH,- overrides: { body: JSON.stringify({ content: input }) },+ overrides: { body: JSON.stringify({ content: input, ...edit }) },}),);});@@ -3058,7 +3064,10 @@ describe("PostHogAPIClient", () => {const client = makeClient(fetch);await expect(- client.updateSignalReportArtefact("report-1", "art-1", []),+ client.updateSignalReportArtefact("report-1", "art-1", [], {+ action: "remove",+ targets: [{ github_login: "octocat" }],+ }),).rejects.toThrow("Only suggested_reviewers");});@@ -3075,7 +3084,10 @@ describe("PostHogAPIClient", () => {const client = makeClient(fetch);await expect(- client.updateSignalReportArtefact("report-1", "art-1", []),+ client.updateSignalReportArtefact("report-1", "art-1", [], {+ action: "remove",+ targets: [{ github_login: "octocat" }],+ }),).rejects.toThrow("Unexpected response");});@@ -3092,13 +3104,18 @@ describe("PostHogAPIClient", () => {});const client = makeClient(fetch);- await client.setSignalReportReviewers("report-1", content);+ await client.setSignalReportReviewers("report-1", content, {+ action: "add",+ targets: content,+ });expect(fetch).toHaveBeenCalledWith(expect.objectContaining({method: "put",path: "/api/projects/123/signals/reports/report-1/reviewers/",- overrides: { body: JSON.stringify({ content }) },+ overrides: {+ body: JSON.stringify({ content, action: "add", targets: content }),+ },}),);});diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.tsindex 03e39ac6e861..f084966c08a9 100644--- a/products/desktop/packages/api-client/src/posthog-client.ts+++ b/products/desktop/packages/api-client/src/posthog-client.ts@@ -446,6 +446,14 @@ export interface TaskSessionStorageAccess {export const COMMENT_SCOPES = ["task_artifact", "canvas", "task"] as const;export type CommentScope = (typeof COMMENT_SCOPES)[number];+export type SuggestedReviewerEdit = {+ action: Extract<+ NonNullable<Schemas.SignalReportArtefactWrite["action"]>,+ "add" | "remove"+ >;+ targets: NonNullable<Schemas.SignalReportArtefactWrite["targets"]>;+};+/** Named `Resource*` so it never collides with the DOM's global `Comment`.* Optimistic rows do not have a server version yet, while item_context is a* real JSON value despite the generated serializer's historically narrow type. */@@ -6137,6 +6145,7 @@ export class PostHogAPIClient {reportId: string,artefactId: string,content: SuggestedReviewerWriteEntry[],+ edit: SuggestedReviewerEdit,): Promise<SuggestedReviewersArtefact> {const teamId = await this.getTeamId();const url = new URL(@@ -6149,7 +6158,7 @@ export class PostHogAPIClient {url,path,overrides: {- body: JSON.stringify({ content }),+ body: JSON.stringify({ content, ...edit }),},});@@ -6168,6 +6177,7 @@ export class PostHogAPIClient {async setSignalReportReviewers(reportId: string,content: SuggestedReviewerWriteEntry[],+ edit: SuggestedReviewerEdit,): Promise<SuggestedReviewersArtefact> {const teamId = await this.getTeamId();const path = `/api/projects/${teamId}/signals/reports/${reportId}/reviewers/`;@@ -6177,7 +6187,7 @@ export class PostHogAPIClient {url,path,overrides: {- body: JSON.stringify({ content }),+ body: JSON.stringify({ content, ...edit }),},});diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsxindex fd062c4dd389..c6158b06b185 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportReviewersSection.tsx@@ -47,6 +47,8 @@ export function ReportReviewersSection({ report }: { report: SignalReport }) {updateReviewers({content: toSuggestedReviewerWriteContent(next),+ action: "remove",+ targets: toSuggestedReviewerWriteContent([reviewer]),optimisticReviewers: next,},{diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.test.tsxindex cc94dff4a183..775aaa8cd55f 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.test.tsx@@ -83,6 +83,8 @@ describe("ReviewerSearchList", () => {expect(mocks.updateReviewers).toHaveBeenCalledWith({content: [{ user_uuid: "reviewer-1" }],+ action: "add",+ targets: [{ user_uuid: "reviewer-1" }],optimisticReviewers: [expect.objectContaining({github_login: "ada",diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.tsxindex c6de71d34400..7ba8db4aa700 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ReviewerSearchList.tsx@@ -103,6 +103,8 @@ export function ReviewerSearchList({updateReviewers({content: toSuggestedReviewerWriteContent(next),+ action: "remove",+ targets: toSuggestedReviewerWriteContent([existing]),optimisticReviewers: next,},{@@ -146,6 +148,8 @@ export function ReviewerSearchList({...toSuggestedReviewerWriteContent(reviewers),{ user_uuid: option.uuid },],+ action: "add",+ targets: [{ user_uuid: option.uuid }],optimisticReviewers: [...reviewers, optimisticEntry],},{diff --git a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsxindex e55385db04c1..9dd05de70ea3 100644--- a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.test.tsx@@ -157,6 +157,8 @@ describe("SuggestedReviewerAvatarStack", () => {{// The write names the kept reviewer by PostHog user, so it keeps routing if they unlink GitHub.content: [{ user_uuid: "user-bob" }],+ action: "remove",+ targets: [{ user_uuid: "user-me" }],optimisticReviewers: [teammate],},expect.objectContaining({diff --git a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.tsx b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.tsxindex 9cff508fba23..91f4347472dc 100644--- a/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/SuggestedReviewerAvatarStack.tsx@@ -112,6 +112,8 @@ export function SuggestedReviewerAvatarStack({updateReviewers({content: toSuggestedReviewerWriteContent(nextReviewers),+ action: "remove",+ targets: toSuggestedReviewerWriteContent([currentReviewer]),optimisticReviewers: nextReviewers,},{diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.tsindex e654182c406f..da1da7a3dfb0 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts@@ -578,9 +578,8 @@ export function useInboxBulkActions(/*** Remove the current user from each selected report's suggested reviewers.- * The artefact PUT replaces the whole list, so per report we fetch the latest- * `suggested_reviewers` artefact, drop the entry matching the current user's- * uuid, and write the rest back. Reports where the user isn't listed are a+ * Keep a full-list fallback for older servers and send only the current user's+ * UUID as the removal target. Reports where the user isn't listed are a* no-op (fetched only for reports the list already flags via* `is_suggested_reviewer`).*/@@ -609,6 +608,7 @@ export function useInboxBulkActions(reportId,artefact.id,toReviewerWriteContent(next),+ { action: "remove", targets: [{ user_uuid: input.meUuid }] },);}),{diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.test.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.test.tsxindex e34f7d475352..a7d025a287cf 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.test.tsx@@ -102,13 +102,17 @@ describe("Inbox report queries", () => {await act(async () => {await result.current.mutateAsync({content: [{ github_login: "octocat" }],+ action: "remove",+ targets: [{ github_login: "hubot" }],optimisticReviewers: next,});});- expect(mockSetReviewers).toHaveBeenCalledWith(REPORT_ID, [- { github_login: "octocat" },- ]);+ expect(mockSetReviewers).toHaveBeenCalledWith(+ REPORT_ID,+ [{ github_login: "octocat" }],+ { action: "remove", targets: [{ github_login: "hubot" }] },+ );const cached = queryClient.getQueryData<SignalReportArtefactsResponse>(key);const reviewerRows = (cached?.results ?? []).filter(@@ -138,6 +142,8 @@ describe("Inbox report queries", () => {await act(async () => {await result.current.mutateAsync({content: [{ github_login: "octocat" }],+ action: "remove",+ targets: [{ github_login: "hubot" }],optimisticReviewers: [reviewer("octocat")],});});@@ -162,6 +168,8 @@ describe("Inbox report queries", () => {try {await result.current.mutateAsync({content: [{ github_login: "octocat" }],+ action: "remove",+ targets: [{ github_login: "hubot" }],optimisticReviewers: [reviewer("octocat")],});} catch (error) {diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.tsindex 830834506632..e68848a3d1f1 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.ts+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReports.ts@@ -1,3 +1,4 @@+import type { SuggestedReviewerEdit } from "@posthog/api-client/posthog-client";import {INBOX_REPORT_DETAIL_STALE_TIME_MS,inboxReportKeys,@@ -225,7 +226,7 @@ export function useInboxReportSignals();}-interface UpdateSuggestedReviewersVariables {+interface UpdateSuggestedReviewersVariables extends SuggestedReviewerEdit {/** Reviewer list sent to the server (it appends a new suggested_reviewers status row). */content: SuggestedReviewerWriteEntry[];/** Read-shape list used to optimistically show the new current reviewers. */@@ -247,7 +248,8 @@ export function useUpdateSuggestedReviewers(reportId: string) {Error,UpdateSuggestedReviewersVariables>(- (client, { content }) => client.setSignalReportReviewers(reportId, content),+ (client, { content, action, targets }) =>+ client.setSignalReportReviewers(reportId, content, { action, targets }),{onMutate: async ({ optimisticReviewers }) => {await queryClient.cancelQueries({ queryKey });