: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
feat(review_hog): scope effectiveness stats with the page-level switch (#72046)
Alex Lebedev4a381aabd342
diff --git a/posthog/test/setup_receivers_baseline.txt b/posthog/test/setup_receivers_baseline.txtindex 213123f36c56..4706ab6dcedc 100644--- a/posthog/test/setup_receivers_baseline.txt+++ b/posthog/test/setup_receivers_baseline.txt@@ -63,6 +63,7 @@ post_delete:posthog.storage.team_access_cache_signal_handlers.team_deleted_auth_post_delete:products.access_control.backend.property_access_control._invalidate_restriction_cache_on_changepost_delete:products.actions.backend.models.action.action_deletedpost_delete:products.ai_observability.backend.models.llm_prompt.invalidate_llm_prompt_cache+post_delete:products.ai_observability.backend.models.llm_prompt.invalidate_llm_prompt_label_cachepost_delete:products.ai_observability.backend.models.provider_keys.provider_key_deletedpost_delete:products.cdp.backend.models.hog_functions.hog_function.team_inject_web_apps_changdpost_delete:products.cdp.backend.models.hook.hook_deleted@@ -131,6 +132,7 @@ post_save:products.actions.backend.models.action.action_savedpost_save:products.ai_observability.backend.models.clustering_job.create_default_clustering_jobs_for_new_teampost_save:products.ai_observability.backend.models.evaluations.evaluation_savedpost_save:products.ai_observability.backend.models.llm_prompt.invalidate_llm_prompt_cache+post_save:products.ai_observability.backend.models.llm_prompt.invalidate_llm_prompt_label_cachepost_save:products.ai_observability.backend.models.provider_keys.provider_key_savedpost_save:products.ai_observability.backend.models.taggers.tagger_savedpost_save:products.annotations.backend.activity_logging.annotation_created@@ -157,6 +159,7 @@ post_save:products.conversations.backend.signals.update_ticket_on_messagepost_save:products.data_modeling.backend.signals.sync_saved_query_name_to_nodepost_save:products.data_modeling.backend.signals.trigger_view_semantic_enrichmentpost_save:products.data_warehouse.backend.models.revenue_analytics_config.create_external_data_source_revenue_analytics_config+post_save:products.early_access_features.backend.signals.create_waitlist_survey_on_concept_stagepost_save:products.error_tracking.backend.signals.mirror_autocapture_opt_in_to_settingspost_save:products.event_definitions.backend.models.event_definition._invalidate_default_event_info_on_savepost_save:products.event_definitions.backend.models.property_definition._invalidate_has_person_email_on_savediff --git a/products/review_hog/DECISIONS.md b/products/review_hog/DECISIONS.mdindex 8625a56bd94b..8d179e8ddaf6 100644--- a/products/review_hog/DECISIONS.md+++ b/products/review_hog/DECISIONS.md@@ -696,6 +696,35 @@ The 5-row cap became the first page: the list grows by a page per "Show more" cljest — grow/collapse cycle (instant collapse, has_more preserved, scope flip resets the limit).Full suite: 503 backend + 3 jest green; `hogli build:openapi` regenerated cleanly (list function keeps its `reviewHogReviewsList` name).+#### ✅ BUILT 2026-07-17 — page-level scope: the stats follow the "For you / Entire project" switch++Supersedes the 2026-07-15 note that "`perspective_stats` stays personal": the split turned out to be+the confusing part — flipping the list to Entire project left the hero and effectiveness cards+silently personal, so the page showed one scope's list over another scope's numbers. One page-level+switch now governs both. User decisions (grilled 2026-07-17): scope stays **project** (team), not+org-wide; the switch moved to the **top of the page** (hero overline row), the Recent reviews+section lost its local copy; project-scope effectiveness rows show **every** skill that raised+findings (incl. teammates' customs — their names already surfaced via the everyone-scope detail+drawer, and hero totals must equal the sum of rows); **all four** stat surfaces flip (hero proof+card, Perspectives, Blind-spot, Validation criteria). Skill lists and toggles stay per-user — maybe+skills follow later, deliberately not in this iteration.++- **BE:** `GET reviews/perspective_stats/?scope=mine|everyone` (`PerspectiveStatsParamsSerializer`,+ default `mine`) — `everyone` reuses the list's `_reports` scope plumbing; aggregation unchanged.+- **Logic:** `loadPerspectiveStats` threads `values.reviewsScope` + takes a `breakpoint()`;+ the scope listeners reload stats alongside the list, and `perspectiveStats → null` /+ `recentReviewsPage → null` reducers on scope change drop the old data synchronously so the page+ skeletons consistently instead of showing the wrong scope's stats or rows (the list half was a+ PR-review finding: a failed reload would have stranded the other scope's rows on screen).+ Persisted `reviewsScope` / URL `?reviews_scope=` / auto-default semantics untouched.+- **UI:** `PageScopeSwitch` in the hero overline row; scope-aware copy — "findings worth the+ team's time" / "This project's last N reviews" / validator card reads "Validation · dismissed by+ validation" on project scope (the aggregate spans every author's active validator, so "your+ quality bar" would lie).+- Tests: BE — everyone-scope aggregation folds a teammate's report in + bad scope 400s (params-serializer+ wiring guard), extended into the existing stats test; jest — scope flip rescopes the stats request and+ nulls the stale value.+#### ✅ BUILT 2026-07-02 — authoring guide moved to a canonical skill (`review-hog-authoring`)The "Create your own …" frontend prompts were fat, self-describing instruction sets — andiff --git a/products/review_hog/backend/api/reviews.py b/products/review_hog/backend/api/reviews.pyindex 80e4127c89b6..b2988e6f7530 100644--- a/products/review_hog/backend/api/reviews.py+++ b/products/review_hog/backend/api/reviews.py@@ -82,6 +82,15 @@ class ReviewsListParamsSerializer(serializers.Serializer):)+class PerspectiveStatsParamsSerializer(serializers.Serializer):+ scope = serializers.ChoiceField(+ choices=[SCOPE_MINE, SCOPE_EVERYONE],+ default=SCOPE_MINE,+ help_text="Whose reviews to aggregate: `mine` for reviews of the requesting user's pull requests "+ "(the default), `everyone` for every review on this project.",+ )++class ReviewProgressSerializer(serializers.Serializer):review_stage = serializers.ChoiceField(choices=REVIEW_STAGES,@@ -443,8 +452,10 @@ class ReviewRecentReviewsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSetvalid findings at each effective priority, the reviewed PR's facts, and the pipeline shape ofthe latest turn. `list` covers the requesting user's reviews (reports where they are the actinguser) by default, or the whole project's via `scope=everyone` — mirroring the inbox's- "For you / Entire project" switch. `retrieve` adds the findings themselves (valid + dismissed)- and the published review body; it is project-wide so any listed review can be opened.+ "For you / Entire project" switch; `perspective_stats` honors the same `scope` so the+ effectiveness cards can follow the page-level switch. `retrieve` adds the findings themselves+ (valid + dismissed) and the published review body; it is project-wide so any listed review can+ be opened."""scope_object = "INTERNAL"@@ -545,19 +556,23 @@ class ReviewRecentReviewsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSetreturn Response(ReviewRecentReviewsPageSerializer({"results": items, "has_more": has_more}).data)@extend_schema(+ parameters=[PerspectiveStatsParamsSerializer],responses={200: OpenApiResponse(response=ReviewPerspectiveStatsSerializer,- description="Per-skill effectiveness across the user's recent completed reviews.",+ description="Per-skill effectiveness across the recent completed reviews in scope.",),},summary="Perspective effectiveness stats",description="How many findings each review skill (perspective or blind-spot sweep) raised across the "- "requesting user's recent completed reviews, and how many of those the validator kept vs dismissed.",+ "recent completed reviews in scope — the requesting user's by default, every review on this project "+ "with `scope=everyone` — and how many of those the validator kept vs dismissed.",)@action(methods=["GET"], detail=False)def perspective_stats(self, request: Request, **kwargs) -> Response:- team_id, queryset = self._reports(request)+ params = PerspectiveStatsParamsSerializer(data=request.query_params)+ params.is_valid(raise_exception=True)+ team_id, queryset = self._reports(request, scope=params.validated_data["scope"])reports = list(queryset.filter(last_run_at__isnull=False).order_by("-last_run_at")[:PERSPECTIVE_STATS_REPORT_LIMIT])diff --git a/products/review_hog/backend/tests/test_reviews_api.py b/products/review_hog/backend/tests/test_reviews_api.pyindex e0093e963566..70a1a7c15b61 100644--- a/products/review_hog/backend/tests/test_reviews_api.py+++ b/products/review_hog/backend/tests/test_reviews_api.py@@ -508,9 +508,10 @@ class TestRecentReviewsAPI(APIBaseTest):assert rows[0]["in_progress"] is Trueassert {r["pr_number"] for r in rows[1:]} <= set(range(1, 6))- def test_perspective_stats_aggregate_latest_turns_of_my_reviews(self) -> None:- # Effectiveness must aggregate each report's LATEST turn only and never mix in a teammate's- # reviews — stale turns or foreign reports would inflate a perspective's record.+ def test_perspective_stats_aggregate_latest_turns_per_scope(self) -> None:+ # Effectiveness must aggregate each report's LATEST turn only and, on the default scope,+ # never mix in a teammate's reviews — stale turns or foreign reports would inflate a+ # perspective's record.logic = "review-hog-perspective-logic-correctness"blind = "review-hog-blind-spots-general"first = self._report(pr_number=1, acting_user=self.user, run_count=2)@@ -533,6 +534,19 @@ class TestRecentReviewsAPI(APIBaseTest):{"skill_name": blind, "raised": 1, "kept": 1, "dismissed": 0},]+ # scope=everyone folds the teammate's reviews in — the page-level "Entire project" switch;+ # a filter regression here would keep project-wide stats silently personal.+ res = self.client.get(f"{self.url}perspective_stats/?scope=everyone")++ assert res.status_code == 200+ data = res.json()+ assert data["report_count"] == 3+ assert data["perspectives"] == [+ {"skill_name": blind, "raised": 2, "kept": 2, "dismissed": 0},+ {"skill_name": logic, "raised": 2, "kept": 1, "dismissed": 1},+ ]+ assert self.client.get(f"{self.url}perspective_stats/?scope=everything").status_code == 400+def test_retrieve_is_project_wide_but_never_cross_team(self) -> None:# Opening a teammate's review from the everyone-scope list must work, but another team's# report id must still 404 (tenant isolation), and garbage ids must not 500.diff --git a/products/review_hog/frontend/CodeReviewScene.tsx b/products/review_hog/frontend/CodeReviewScene.tsxindex 18aaa449206a..4536000ca894 100644--- a/products/review_hog/frontend/CodeReviewScene.tsx+++ b/products/review_hog/frontend/CodeReviewScene.tsx@@ -147,11 +147,40 @@ function SectionHeader({}/**- * Hero proof block: the validation funnel across the user's recent reviews, summed from the same- * stats the effectiveness cards use. Hidden for users with no reviewed findings yet.+ * Page-level scope switch: one control governing the hero proof card, the effectiveness cards,+ * and the recent-reviews list below. Skill toggles stay per-user regardless of scope.+ */+function PageScopeSwitch(): JSX.Element {+ const { reviewsScope } = useValues(reviewHogSettingsLogic)+ const { setReviewsScope } = useActions(reviewHogSettingsLogic)+ return (+ <LemonSegmentedButton+ size="small"+ value={reviewsScope}+ onChange={(value) => setReviewsScope(value)}+ options={[+ {+ value: ReviewHogReviewsListScope.Mine,+ label: 'For you',+ tooltip: 'Stats and reviews for pull requests you authored',+ },+ {+ value: ReviewHogReviewsListScope.Everyone,+ label: 'Entire project',+ tooltip: 'Stats and reviews for every pull request on this project',+ },+ ]}+ />+ )+}++/**+ * Hero proof block: the validation funnel across the in-scope recent reviews, summed from the same+ * stats the effectiveness cards use. Hidden while there are no reviewed findings in scope yet.*/function ProofCard(): JSX.Element | null {- const { perspectiveStats } = useValues(reviewHogSettingsLogic)+ const { perspectiveStats, reviewsScope } = useValues(reviewHogSettingsLogic)+ const everyone = reviewsScope === ReviewHogReviewsListScope.Everyoneif (perspectiveStats === null) {return <LemonSkeleton className="h-24 w-full" />@@ -167,13 +196,16 @@ function ProofCard(): JSX.Element | null {<LemonCard hoverEffect={false} className="mt-2 flex flex-col gap-3 p-5"><div className="flex flex-wrap items-baseline gap-x-2 gap-y-1"><span className="text-3xl font-bold tabular-nums text-warning">{kept}</span>- <span className="text-sm font-semibold">findings worth your time</span>+ <span className="text-sm font-semibold">+ {everyone ? "findings worth the team's time" : 'findings worth your time'}+ </span><span className="text-xs text-secondary">from <span className="font-semibold text-default">{raised}</span> raised ·{' '}<span className="font-semibold text-default">{dismissed}</span> filtered as noise</span><span className="ml-auto text-xxs text-tertiary">- Your last {perspectiveStats.report_count} review{perspectiveStats.report_count === 1 ? '' : 's'}+ {everyone ? "This project's last" : 'Your last'} {perspectiveStats.report_count} review+ {perspectiveStats.report_count === 1 ? '' : 's'}</span></div><div className="h-2.5 w-full overflow-hidden rounded-full bg-fill-highlight-100">@@ -494,14 +526,14 @@ function RecentReviewsSection(): JSX.Element | null {reviewsScope,hasUserChosenReviewsScope,} = useValues(reviewHogSettingsLogic)- const { setReviewsScope, showMoreReviews, showFewerReviews } = useActions(reviewHogSettingsLogic)+ const { showMoreReviews, showFewerReviews } = useActions(reviewHogSettingsLogic)const everyone = reviewsScope === ReviewHogReviewsListScope.Everyoneconst loadedEmpty = recentReviews !== null && recentReviews.length === 0// Settled-and-empty on the Entire project scope means the project has no reviews at all — hide- // the section entirely. The scope flips before the reload lands, so an in-flight load keeps the- // section mounted (skeleton below) instead of yanking the toggle away mid-click. An empty- // For-you scope keeps the section (with an empty state) so the scope switch stays reachable.+ // the section entirely (an in-flight load keeps it mounted with skeletons instead of flashing+ // it away mid-switch). An empty For-you scope keeps the section, with an empty state pointing+ // at the page-level scope switch.if (loadedEmpty && everyone && !recentReviewsPageLoading) {return null}@@ -513,30 +545,11 @@ function RecentReviewsSection(): JSX.Element | null {return (// The one section without a top hairline — it reads as a continuation of the hero.<section className="flex flex-col gap-4">- <div className="flex flex-wrap items-start justify-between gap-x-4 gap-y-2">- <SectionHeader icon={<IconPullRequest />} title={everyone ? 'Recent reviews' : 'Your recent reviews'}>- {everyone- ? 'The latest ReviewHog runs on pull requests across this project. Expand a review for its details and findings.'- : 'The latest ReviewHog runs on pull requests you authored. Expand a review for its details and findings.'}- </SectionHeader>- <LemonSegmentedButton- size="small"- value={reviewsScope}- onChange={(value) => setReviewsScope(value)}- options={[- {- value: ReviewHogReviewsListScope.Mine,- label: 'For you',- tooltip: 'Only reviews of pull requests you authored',- },- {- value: ReviewHogReviewsListScope.Everyone,- label: 'Entire project',- tooltip: 'Every ReviewHog review on this project',- },- ]}- />- </div>+ <SectionHeader icon={<IconPullRequest />} title={everyone ? 'Recent reviews' : 'Your recent reviews'}>+ {everyone+ ? 'The latest ReviewHog runs on pull requests across this project. Expand a review for its details and findings.'+ : 'The latest ReviewHog runs on pull requests you authored. Expand a review for its details and findings.'}+ </SectionHeader><LemonCard hoverEffect={false} className="divide-y divide-primary p-0">{recentReviews === null || emptyAwaitingReload ? ([0, 1, 2].map((i) => (@@ -578,7 +591,8 @@ function RecentReviewsSection(): JSX.Element | null {</>) : (<div className="px-4 py-6 text-center text-sm text-secondary">- No reviews of your pull requests yet. Switch to "Entire project" to see the whole team's.+ No reviews of your pull requests yet. Switch to "Entire project" at the top of the page to see+ the whole team's.</div>)}</LemonCard>@@ -1253,13 +1267,16 @@ function EffectivenessRows({}/**- * Aggregate effectiveness across the user's recent reviews for one reviewer kind: per skill, a bar- * of findings it raised split into validator-kept (green) vs dismissed (muted). Rendered once in- * the Perspectives section and once in the Blind-spot section, above each one's skill cards; both- * cards share one scale so bar lengths stay comparable. Hidden until there is data for the kind.+ * Aggregate effectiveness across the in-scope recent reviews for one reviewer kind: per skill, a+ * bar of findings it raised split into validator-kept (green) vs dismissed (muted). Rendered once+ * in the Perspectives section and once in the Blind-spot section, above each one's skill cards;+ * both cards share one scale so bar lengths stay comparable. Hidden until there is data for the+ * kind. On the Entire project scope this can list skills beyond the user's own cards below — the+ * stats describe the project, while the toggles stay per-user.*/function EffectivenessCard({ kind }: { kind: 'perspectives' | 'blind_spots' }): JSX.Element | null {- const { perspectiveStats } = useValues(reviewHogSettingsLogic)+ const { perspectiveStats, reviewsScope } = useValues(reviewHogSettingsLogic)+ const everyone = reviewsScope === ReviewHogReviewsListScope.Everyoneif (!perspectiveStats?.perspectives.length) {return null@@ -1280,8 +1297,9 @@ function EffectivenessCard({ kind }: { kind: 'perspectives' | 'blind_spots' }):<div className="flex flex-col gap-1"><span className="text-xxs font-semibold uppercase tracking-wide text-tertiary">Effectiveness</span><p className="m-0 text-xs text-secondary">- Findings each {noun} raised across your last {perspectiveStats.report_count} review- {perspectiveStats.report_count === 1 ? '' : 's'}, and how many survived validation.+ Findings each {noun} raised across {everyone ? "this project's" : 'your'} last{' '}+ {perspectiveStats.report_count} review{perspectiveStats.report_count === 1 ? '' : 's'}, and how many+ survived validation.</p></div><EffectivenessRows items={items} maxRaised={maxRaised} />@@ -1302,7 +1320,8 @@ function EffectivenessCard({ kind }: { kind: 'perspectives' | 'blind_spots' }):* aren't attributed to a validator skill), with dismissals as the headline — its job is filtering.*/function ValidatorEffectivenessCard(): JSX.Element | null {- const { perspectiveStats } = useValues(reviewHogSettingsLogic)+ const { perspectiveStats, reviewsScope } = useValues(reviewHogSettingsLogic)+ const everyone = reviewsScope === ReviewHogReviewsListScope.Everyoneif (!perspectiveStats?.perspectives.length) {return null@@ -1319,15 +1338,20 @@ function ValidatorEffectivenessCard(): JSX.Element | null {<div className="flex flex-col gap-1"><span className="text-xxs font-semibold uppercase tracking-wide text-tertiary">Effectiveness</span><p className="m-0 text-xs text-secondary">- Of the {judged} findings your reviewers raised across your last {perspectiveStats.report_count}{' '}- review{perspectiveStats.report_count === 1 ? '' : 's'}, this is how much noise your quality bar kept- off your pull requests.+ {everyone+ ? `Of the ${judged} findings reviewers raised across this project's last ${perspectiveStats.report_count} review${perspectiveStats.report_count === 1 ? '' : 's'}, this is how much noise validation kept off pull requests.`+ : `Of the ${judged} findings your reviewers raised across your last ${perspectiveStats.report_count} review${perspectiveStats.report_count === 1 ? '' : 's'}, this is how much noise your quality bar kept off your pull requests.`}</p></div>- <Tooltip title={`${judged} judged · ${kept} kept · ${dismissed} dismissed by validation`}>+ <Tooltip+ title={`${judged} judged · ${kept} kept · ${dismissed} dismissed by ${everyone ? 'validation' : 'your quality bar'}`}+ >{/* Unlike the reviewer cards, green here is the DISMISSED share — this card celebrates noise removed. */}<div className="flex items-center gap-3">- <span className="w-44 shrink-0 truncate text-xs">Your quality bar</span>+ <span className="w-44 shrink-0 truncate text-xs">+ {/* Project scope aggregates every author's active validator, not one user's bar. */}+ {everyone ? 'Validation' : 'Your quality bar'}+ </span><div className="flex h-2 flex-1 items-center">{dismissed > 0 && (<div@@ -1349,7 +1373,8 @@ function ValidatorEffectivenessCard(): JSX.Element | null {</Tooltip><div className="flex items-center gap-4 text-xs text-tertiary"><span className="flex items-center gap-1.5">- <span className="inline-block h-2 w-2 rounded-sm bg-success" /> Dismissed by your bar+ <span className="inline-block h-2 w-2 rounded-sm bg-success" />{' '}+ {everyone ? 'Dismissed by validation' : 'Dismissed by your bar'}</span><span className="flex items-center gap-1.5"><span className="inline-block h-2 w-2 rounded-sm bg-fill-highlight-100" /> Kept@@ -1515,11 +1540,15 @@ export function CodeReviewScene(): JSX.Element {/><div className="mx-auto flex w-full max-w-3xl flex-col gap-8 px-6 pb-30 pt-4"><section className="flex flex-col gap-3">- <div className="flex items-center gap-2">+ <div className="flex flex-wrap items-center gap-2"><span className="size-1.5 rounded-full bg-warning" /><span className="text-xxs font-semibold uppercase tracking-widest text-tertiary">Automated pull request review</span>+ {/* Top of the page so it visibly governs everything below it, not one section. */}+ <div className="ml-auto">+ <PageScopeSwitch />+ </div></div><h2 className="m-0 text-3xl font-bold" style={{ textWrap: 'balance' }}>ReviewHog reviews pull requests before humans dodiff --git a/products/review_hog/frontend/generated/api.schemas.ts b/products/review_hog/frontend/generated/api.schemas.tsindex 96e1a682fae7..77ffc6dfc7dc 100644--- a/products/review_hog/frontend/generated/api.schemas.ts+++ b/products/review_hog/frontend/generated/api.schemas.ts@@ -515,3 +515,22 @@ export const ReviewHogReviewsListScope = {Mine: 'mine',Everyone: 'everyone',} as const++export type ReviewHogReviewsPerspectiveStatsRetrieveParams = {+ /**+ * Whose reviews to aggregate: `mine` for reviews of the requesting user's pull requests (the default), `everyone` for every review on this project.+ *+ * * `mine` - mine+ * * `everyone` - everyone+ * @minLength 1+ */+ scope?: ReviewHogReviewsPerspectiveStatsRetrieveScope+}++export type ReviewHogReviewsPerspectiveStatsRetrieveScope =+ (typeof ReviewHogReviewsPerspectiveStatsRetrieveScope)[keyof typeof ReviewHogReviewsPerspectiveStatsRetrieveScope]++export const ReviewHogReviewsPerspectiveStatsRetrieveScope = {+ Mine: 'mine',+ Everyone: 'everyone',+} as constdiff --git a/products/review_hog/frontend/generated/api.ts b/products/review_hog/frontend/generated/api.tsindex 0cd0cefea574..0669dd77be95 100644--- a/products/review_hog/frontend/generated/api.ts+++ b/products/review_hog/frontend/generated/api.ts@@ -16,6 +16,7 @@ import type {ReviewBlindSpotsConfigApi,ReviewDetailApi,ReviewHogReviewsListParams,+ ReviewHogReviewsPerspectiveStatsRetrieveParams,ReviewPerspectiveConfigApi,ReviewPerspectiveStatsApi,ReviewRecentReviewsPageApi,@@ -172,19 +173,35 @@ export const reviewHogReviewsRetrieve = async (})}-export const getReviewHogReviewsPerspectiveStatsRetrieveUrl = (projectId: string) => {- return `/api/projects/${projectId}/review_hog/reviews/perspective_stats/`+export const getReviewHogReviewsPerspectiveStatsRetrieveUrl = (+ projectId: string,+ params?: ReviewHogReviewsPerspectiveStatsRetrieveParams+) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : String(value))+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/review_hog/reviews/perspective_stats/?${stringifiedParams}`+ : `/api/projects/${projectId}/review_hog/reviews/perspective_stats/`}/**- * How many findings each review skill (perspective or blind-spot sweep) raised across the requesting user's recent completed reviews, and how many of those the validator kept vs dismissed.+ * How many findings each review skill (perspective or blind-spot sweep) raised across the recent completed reviews in scope — the requesting user's by default, every review on this project with `scope=everyone` — and how many of those the validator kept vs dismissed.* @summary Perspective effectiveness stats*/export const reviewHogReviewsPerspectiveStatsRetrieve = async (projectId: string,+ params?: ReviewHogReviewsPerspectiveStatsRetrieveParams,options?: RequestInit): Promise<ReviewPerspectiveStatsApi> => {- return apiMutator<ReviewPerspectiveStatsApi>(getReviewHogReviewsPerspectiveStatsRetrieveUrl(projectId), {+ return apiMutator<ReviewPerspectiveStatsApi>(getReviewHogReviewsPerspectiveStatsRetrieveUrl(projectId, params), {...options,method: 'GET',})diff --git a/products/review_hog/frontend/reviewHogSettingsLogic.test.ts b/products/review_hog/frontend/reviewHogSettingsLogic.test.tsindex 9989d0308dd0..3e250b098c83 100644--- a/products/review_hog/frontend/reviewHogSettingsLogic.test.ts+++ b/products/review_hog/frontend/reviewHogSettingsLogic.test.ts@@ -175,6 +175,36 @@ describe('reviewHogSettingsLogic', () => {})})+ it('the scope switch rescopes the effectiveness stats along with the list', async () => {+ // The page-level switch must move the stat cards and the reviews list together — dropping+ // the stats reload from the scope listeners (or the scope param from the request) would+ // show one scope's list over the other scope's numbers, the exact confusion the switch+ // exists to fix.+ const statsScopes: (string | null)[] = []+ useMocks({+ get: {+ '/api/projects/:team_id/review_hog/reviews/perspective_stats/': ({ request }) => {+ statsScopes.push(new URL(request.url).searchParams.get('scope'))+ return [200, { report_count: 0, perspectives: [] }]+ },+ },+ })+ logic.mount()+ await expectLogic(logic)+ .toDispatchActions(['loadRecentReviewsSuccess', 'applyDefaultReviewsScope', 'loadRecentReviewsSuccess'])+ .toFinishAllListeners()+ // The mount-time auto-default to Entire project already rescoped the stats.+ expect(statsScopes[statsScopes.length - 1]).toBe(ReviewHogReviewsListScope.Everyone)++ logic.actions.setReviewsScope(ReviewHogReviewsListScope.Mine)+ // Old data drops synchronously so neither the cards nor the list ever show the other+ // scope's content — even if the reload were to fail.+ expect(logic.values.perspectiveStats).toBeNull()+ expect(logic.values.recentReviews).toBeNull()+ await expectLogic(logic).toDispatchActions(['loadPerspectiveStatsSuccess'])+ expect(statsScopes[statsScopes.length - 1]).toBe(ReviewHogReviewsListScope.Mine)+ })+it('respects an explicit scope choice even when that scope is empty', async () => {logic.mount()// Consume the mount-time auto-default, so the not-dispatched window below starts after it.diff --git a/products/review_hog/frontend/reviewHogSettingsLogic.ts b/products/review_hog/frontend/reviewHogSettingsLogic.tsindex fe8a6fdc3a7a..67dc55659bd0 100644--- a/products/review_hog/frontend/reviewHogSettingsLogic.ts+++ b/products/review_hog/frontend/reviewHogSettingsLogic.ts@@ -193,7 +193,7 @@ export interface reviewHogSettingsLogicActions {blindSpots: ReviewBlindSpotsConfigApi[]payload?: any}- loadPerspectiveStats: () => any+ loadPerspectiveStats: (_?: any) => anyloadPerspectiveStatsFailure: (error: string,errorObject?: any@@ -493,7 +493,15 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([perspectiveStats: [null as ReviewPerspectiveStatsApi | null,{- loadPerspectiveStats: async () => await reviewHogReviewsPerspectiveStatsRetrieve(currentProjectId()),+ // The default param keeps the action zero-arg in the generated logic type.+ loadPerspectiveStats: async (_ = null, breakpoint) => {+ const response = await reviewHogReviewsPerspectiveStatsRetrieve(currentProjectId(), {+ scope: values.reviewsScope,+ })+ // A scope change mid-flight dispatched a newer load — drop this stale response.+ breakpoint()+ return response+ },},],})),@@ -570,7 +578,18 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([state.includes(reviewId) ? state.filter((id) => id !== reviewId) : [...state, reviewId],},],+ perspectiveStats: {+ // A different scope is different data — drop the old numbers so the stat cards show+ // skeletons instead of the wrong scope's stats while the reload is in flight.+ setReviewsScope: () => null,+ applyDefaultReviewsScope: () => null,+ },recentReviewsPage: {+ // A different scope is a different list — drop it together with perspectiveStats so+ // the section shows skeletons instead of the other scope's rows (and never strands+ // them if the reload fails). Poll refreshes still keep prior rows.+ setReviewsScope: () => null,+ applyDefaultReviewsScope: () => null,// "Show fewer" collapses instantly from data already loaded; the listener's refetch// reconciles silently and breakpoint-drops any wider in-flight response (e.g. a poll).showFewerReviews: (state: ReviewRecentReviewsPageApi | null) =>@@ -604,8 +623,9 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([loadRecentReviewsFailure: () => false,},],- // Whose reviews the "recent reviews" block lists — mirrors the inbox's- // "For you / Entire project" switch.+ // The page-level "For you / Entire project" switch (mirroring the inbox's): it scopes the+ // recent-reviews list AND every stat surface fed by perspectiveStats (hero proof card,+ // effectiveness cards). Skill lists and their toggles stay per-user regardless.reviewsScope: [ReviewHogReviewsListScope.Mine as ReviewHogReviewsListScope,{ persist: true },@@ -768,8 +788,14 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([stopTriggeredReviewWatch: () => {cache.disposables.dispose('triggeredReviewWatch')},- setReviewsScope: () => actions.loadRecentReviews(),- applyDefaultReviewsScope: () => actions.loadRecentReviews(),+ setReviewsScope: () => {+ actions.loadRecentReviews()+ actions.loadPerspectiveStats()+ },+ applyDefaultReviewsScope: () => {+ actions.loadRecentReviews()+ actions.loadPerspectiveStats()+ },showMoreReviews: () => actions.loadRecentReviews(),showFewerReviews: () => actions.loadRecentReviews(),loadAll: () => {diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex f4527d82f99b..d04e759cbd2c 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -77678,6 +77678,25 @@ export namespace Schemas {Everyone: 'everyone',} as const;+ export type ReviewHogReviewsPerspectiveStatsRetrieveParams = {+ /**+ * Whose reviews to aggregate: `mine` for reviews of the requesting user's pull requests (the default), `everyone` for every review on this project.+ *+ * * `mine` - mine+ * * `everyone` - everyone+ * @minLength 1+ */+ scope?: ReviewHogReviewsPerspectiveStatsRetrieveScope;+ };++ export type ReviewHogReviewsPerspectiveStatsRetrieveScope = typeof ReviewHogReviewsPerspectiveStatsRetrieveScope[keyof typeof ReviewHogReviewsPerspectiveStatsRetrieveScope];+++ export const ReviewHogReviewsPerspectiveStatsRetrieveScope = {+ Mine: 'mine',+ Everyone: 'everyone',+ } as const;+export type SandboxCustomImagesListParams = {/*** Number of results to return per page.