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(review_hog): replace the recent reviews list with a paginated table (#114922)

Julian Bezeb0a7b1e268f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index fcdb87a96cec..ae2870b75b8f 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -14551,33 +14551,37 @@ snapshots:
scenes-app-workflows-createaitaskconnectors--unavailable-connector--light:
hash: v1.k794b7964.c4fdab3ab5190ace67d354d7010b49cbd37e9ec72feaa3fab9760d1f1010c8b0.S5qBDGrQNUo7qygcV1_MG_nu9RWeaMnoOFrYdhnV97E
scenes-code-review--default--dark:
- hash: v1.k794b7964.bc9f861ae414c77c708f83bcce1d75dd8e80a0ee047c460b5f9fc5237cef9553.ikrttudHPdJsnmv_6RaTTSycICrnK3Qzpd2LyTyzEBw
+ hash: v1.k794b7964.eb8b4296ce3d2504dbd45f201ef4e7ae3777ee2dbb14e43938bddad9ecdd365d.k4dc64JPINoJGFgXpk56-CFj7LKTj7lW86TsKL5Tu3U
scenes-code-review--default--light:
- hash: v1.k794b7964.c77495f653dd58b7f416382d1dd00d955693da7158132495cb0a11b1ec498934.AVOYB9lL8QLhGEBF2keAhwqcomgKmg7gajLvh9cq2No
+ hash: v1.k794b7964.d4b1ff7f1676554d128b92edd4b5b968077bd0aeb2c2e5a9d1def52599e24176.HiPu-lyNhWPTZfzqFQLGodCobRcLMccxrQcNIe9Gfw0
scenes-code-review--flag-disabled-for-staff--dark:
hash: v1.k794b7964.af1b6736f5a6e6ffb329599ed7407d25dbee0939861cd554e0c94b84b2970a7c.HwLX1pgZqjpFAoG4ni16T0wtf1PJQkw0Evr2jBw2vG4
scenes-code-review--flag-disabled-for-staff--light:
hash: v1.k794b7964.a71251e301794f51a0a9140ab1442fada37b1cc0fb54095a5eb19499e0cb1b34.3GhhJCqNfLkY2WdBTTn0LHJifxiCqyEJ7viaHaoCoGA
scenes-code-review--narrow--dark:
- hash: v1.k794b7964.5c511c2c23d0f62b5341d355884ec1dd55d78daba0d5a57b288ea800ab7259af.dFLrjO1GHVsOIab7mzozoXFiBQyPne7TNYZ5xodTG4A
+ hash: v1.k794b7964.b2b9613d05b0eef2e5fcd32a31c4bc95c5048b635dfb05c8929d94c76b754979.UrI4IFf3t9xF2cQLahFBNyLvtmAe3iBpgvcGI0utJT0
scenes-code-review--narrow--light:
- hash: v1.k794b7964.3f623416d580dbc799c05c0c71cb56a4d12db877c984c482a447fe91fd8c66f0.f4ZkK14Qjd5x3d7u7lstnxUc0z04MadleQL2KpFhNG4
+ hash: v1.k794b7964.afeef57d84f381c04507c77246b5db937cc7d29187549e6e9b12d2e359fd8d42._EM_TEUS4trBZou9toi4uVqsXW90nXTElFSbERoU1oI
scenes-code-review--narrow-settings--dark:
hash: v1.k794b7964.30e27208a1f2cd718962075ca898f14bd761e441ce9036b5ce1399fe2cdbe8e9.Per5PlPRaSDZNkhiLwOJcA_mfCNaA3JGY5USALMsd10
scenes-code-review--narrow-settings--light:
hash: v1.k794b7964.b5b6931c1780d1f0208323cc930d8983e95cb1a63cdeaf9efb9206d3298e6c98.d9mwbeuHYVDPANqB6KZ_ds9NM0ApXckCMMR0iepHugs
scenes-code-review--review-drawer-deep--dark:
- hash: v1.k794b7964.3d0c356cbfdec3793670287abc63521fce410b72c34ec987d6b0465e40f795a6.dNKe3NSj7mZL96kEZTR2n1v2DKjve6eJ2YDxeQKLiQk
+ hash: v1.k794b7964.b6e8d258613e64e43d690058f64d0137f64e50776ff245fa9e679eb0c4617985.Z_imJ8KRX2pmZPy_KbumlnqY18-GIjBfQbGte1aKroA
scenes-code-review--review-drawer-deep--light:
- hash: v1.k794b7964.b71bb2476197904ac98be6a048ab93ea1d42ba372eead2feae34a453cfae6c78.jY5EuW83OorvyQdp7-sbU_fq_YH_j8sXZMWDq8wERBM
+ hash: v1.k794b7964.50506b0d0ea81e9e6ebc22f9940471c2e903862a5e6f8ff57cdc8b2ee48b6ed8.A4Bv44413QWuwyN-VwqPPtOLfJca3_klGmhv1uy7CC0
scenes-code-review--review-drawer-standard--dark:
- hash: v1.k794b7964.15d432a648fa4f9c3014fb9eb2575a3fabef538e54a6b1c68ee365c3575c1903.KeVrff6VhdQx8AdPek8I7jfXGtRk5MCEybrtb_ZoCoA
+ hash: v1.k794b7964.68380dfe548cca4101c4e33251293cd6fcaa74f54d38b9ec262876b47ee5a4fd.0sXpaZNPPgkLvVq2VRLmOkVj_tMPkK7b_kOG6zuxsFE
scenes-code-review--review-drawer-standard--light:
- hash: v1.k794b7964.b53341de7580b5171efd0dfee295ee2f4ef30dd69a057b3ef14e25b0d31709b3.g6L5bNqhOk1MwKDUX-iRS4LFjAKSrpZ6Znmuhv55FhY
+ hash: v1.k794b7964.648ce34c5a73ffcfd104439d1496d666bfc36d436c23f2b9ea9b46eae46cc669.aQtxuCv23MxvQfNtn7kI5NWuxJIah7znd_etlPziI30
scenes-code-review--review-drawer-standard-not-posted--dark:
- hash: v1.k794b7964.3da9d89ad94f5333211ef5c3cde37558bc75dd9f854fd87cda69b6d404376f0f.uEOCy1EExEg8oV2sGDRMTKDUhhZbqxP0ScaTWrMO5eI
+ hash: v1.k794b7964.f23f04d89e56e9350f2eaac36a5b4db9694562f184c939cfa3874fb393f9c75f.KFxW9rOt6e1gvurZEmhaRY5AUyJ9ukxBhF0u4BD0ReM
scenes-code-review--review-drawer-standard-not-posted--light:
- hash: v1.k794b7964.c790ba3ca42d480a5302e3bd201ebc014c829ddf55dfbe12be1603c064224006.fmHTLnmtcBwkGjb02XFr1np5mOBjiq-lRNPMlHmD8ck
+ hash: v1.k794b7964.b7953b7643dd5a156fcc89380323525d6b435502fb268a0caa8dfd92c38c68bc.Wfan0GMCc6UKQVCfqfkIlUzMlPZSP-0s43dBThpSEvk
+ scenes-code-review--running-review--dark:
+ hash: v1.k794b7964.f4b556098140dce06b4dcbc9115fd1236f990d1a85f03a72c4659f8de157efc8._as2opVdhBSDEFLUuDccuDwakn8dfC2SFYhGIQH5WA4
+ scenes-code-review--running-review--light:
+ hash: v1.k794b7964.63c1f2fdc259d9f836f7d5d10662a0cf3dcb126782fc5dd79b419650cddff949.Ifn0U5N6KEnj0rsGu6ZFGXiwsvyeUBu9dUcMOn8FlwM
scenes-code-review--saved-inbox-opt-ins--dark:
hash: v1.k794b7964.ad93f63add9cc729094908a1c95fd2d5a16cdc3cf60491d478103e0f8ef29e68.XWH14JWiIxuAv5FK2GruOU2sleoiBQ2AX9vCrVT3lk8
scenes-code-review--saved-inbox-opt-ins--light:
diff --git a/products/review_hog/frontend/CodeReviewScene.stories.tsx b/products/review_hog/frontend/CodeReviewScene.stories.tsx
index 3148230844c3..56b48aec40d9 100644
--- a/products/review_hog/frontend/CodeReviewScene.stories.tsx
+++ b/products/review_hog/frontend/CodeReviewScene.stories.tsx
@@ -103,7 +103,8 @@ function completedReview(overrides: Partial<ReviewRecentReviewApi>): ReviewRecen
}
}
-const recentReviews: ReviewRecentReviewApi[] = [
+// The first two back the drawer stories: a Deep review and a Standard review.
+const reviewRows: ReviewRecentReviewApi[] = [
completedReview({}),
completedReview({
id: 'review-2',
@@ -145,6 +146,33 @@ const recentReviews: ReviewRecentReviewApi[] = [
}),
]
+// A first review still running: no completed turn yet, so no findings and no drawer.
+const runningReview = completedReview({
+ id: 'review-running',
+ repository: 'example-org/example-api',
+ pr_number: 212,
+ pr_title: 'Paginate the reviews table',
+ pr_author: 'example-teammate',
+ github_url: 'https://github.com/example-org/example-api/pull/212',
+ head_branch: 'feat/reviews-table',
+ run_count: 0,
+ last_run_at: null,
+ published: false,
+ turn_published: false,
+ review_mode: null,
+ review_design: null,
+ status_comment_url: null,
+ full_review_published: false,
+ in_progress: true,
+ progress: { review_stage: 'reviewing', done: 3, total: 8 },
+ must_fix_count: 0,
+ should_fix_count: 0,
+ consider_count: 0,
+})
+
+// More reviews than one page, so the pager shows.
+const REVIEW_TOTAL = 61
+
function finding(overrides: Partial<ReviewFindingApi>): ReviewFindingApi {
return {
title: 'Retry loop never gives up on a permanent error',
@@ -176,7 +204,7 @@ function reviewDetail(review: ReviewRecentReviewApi, overrides: Partial<ReviewDe
}
}
-const deepReviewDetail = reviewDetail(recentReviews[0], {
+const deepReviewDetail = reviewDetail(reviewRows[0], {
run_urgency_threshold: 'should_fix',
findings: [
finding({}),
@@ -239,7 +267,7 @@ const deepReviewDetail = reviewDetail(recentReviews[0], {
// A single-agent turn stamps one placeholder verdict on every finding instead of a validator's reasoning.
const SINGLE_AGENT_NOTE = 'Not validated separately. A Standard review publishes its findings directly.'
-const standardReviewDetail = reviewDetail(recentReviews[1], {
+const standardReviewDetail = reviewDetail(reviewRows[1], {
findings: [
finding({
title: 'Digest window uses the server timezone',
@@ -646,7 +674,20 @@ const meta: Meta<typeof CodeReviewScene> = {
previous: null,
count: members.length,
},
- '/api/projects/:team_id/review_hog/reviews/': { results: recentReviews, has_more: false },
+ // Before `reviews/:id/`, which would otherwise take `table` for a review id.
+ '/api/projects/:team_id/review_hog/reviews/table/': ({ request }) => {
+ // A running row keeps its spinner, so only the story that shows it opts in.
+ const rows = context.parameters.withRunningReview ? [runningReview, ...reviewRows] : reviewRows
+ const running = new URL(request.url).searchParams.get('status') === 'running'
+ return [
+ 200,
+ {
+ count: running ? rows.length - reviewRows.length : REVIEW_TOTAL,
+ running_count: rows.length - reviewRows.length,
+ results: running ? rows.filter((row) => row.in_progress) : rows,
+ },
+ ]
+ },
'/api/projects/:team_id/review_hog/reviews/perspective_stats/': perspectiveStats,
'/api/projects/:team_id/review_hog/reviews/:id/': ({ params }) => {
const detail = reviewDetails[String(params.id)]
@@ -798,6 +839,18 @@ export const Default: Story = {
},
}
+export const RunningReview: Story = {
+ parameters: {
+ withRunningReview: true,
+ testOptions: { waitForLoadersToDisappear: false, waitForSelector: '[data-attr="code-review-reviews-table"]' },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement)
+ await expect(await canvas.findByText('Reviewing 3/8')).toBeVisible()
+ await expect(canvas.getByText('Running · 1')).toBeVisible()
+ },
+}
+
export const Settings: Story = {
parameters: { tab: 'settings' },
play: async ({ canvasElement }) => {
@@ -900,6 +953,9 @@ const narrowDecorator: Decorator = (Story): JSX.Element => (
export const Narrow: Story = {
decorators: [narrowDecorator],
+ play: async ({ canvasElement }) => {
+ await expect(await within(canvasElement).findByText('Add retry to the export job')).toBeVisible()
+ },
}
export const NarrowSettings: Story = {
diff --git a/products/review_hog/frontend/CodeReviewScene.tsx b/products/review_hog/frontend/CodeReviewScene.tsx
index fe5e1e6b7868..936c1774a4c2 100644
--- a/products/review_hog/frontend/CodeReviewScene.tsx
+++ b/products/review_hog/frontend/CodeReviewScene.tsx
@@ -11,12 +11,10 @@ import {
LemonTabs,
LemonTag,
Link,
- Spinner,
Tooltip,
} from '@posthog/lemon-ui'
import { NotFound } from 'lib/components/NotFound'
-import { TZLabel } from 'lib/components/TZLabel'
import { FEATURE_FLAGS } from 'lib/constants'
import { LemonCard } from 'lib/lemon-ui/LemonCard'
import { LemonCollapse } from 'lib/lemon-ui/LemonCollapse'
@@ -35,8 +33,6 @@ import type {
ReviewFindingApi,
ReviewIssuePriorityEnumApi,
ReviewRecentReviewApi,
- ReviewResolutionStatusApi,
- ReviewTriggerReviewModeEnumApi,
} from 'products/review_hog/frontend/generated/api.schemas'
import {
ReviewHogReviewsListScope,
@@ -46,7 +42,11 @@ import {
import { AdoptSkillModal } from './AdoptSkillModal'
import { PipelineDetailModal } from './PipelineDetailModal'
-import { CodeReviewTab, REVIEWS_PAGE_SIZE, ReviewDrawerTab, reviewHogSettingsLogic } from './reviewHogSettingsLogic'
+import { reviewTitle } from './reviewDisplay'
+import { CodeReviewTab, ReviewDrawerTab, reviewHogSettingsLogic } from './reviewHogSettingsLogic'
+import { ReviewModeTag } from './ReviewModeTag'
+import { ReviewsFilters } from './ReviewsFilters'
+import { ReviewsTable } from './ReviewsTable'
import { SectionHeader } from './SectionHeader'
import { DeepArea } from './settings/DeepArea'
import { InboxSection } from './settings/InboxSection'
@@ -75,7 +75,7 @@ const REVIEWS_SCOPE_OPTIONS: {
]
/**
- * Filter on the recent-reviews list. It also scopes the proof card and the effectiveness cards on
+ * Scope of the reviews table. It also scopes the proof card and the effectiveness cards on
* the Settings tab. Skill toggles stay per-user regardless of scope.
*/
function ReviewsScopeFilter(): JSX.Element {
@@ -95,7 +95,7 @@ function StatsWindowLabel({ reportCount }: { reportCount: number }): JSX.Element
const { reviewsScope } = useValues(reviewHogSettingsLogic)
const scopeOption = REVIEWS_SCOPE_OPTIONS.find((option) => option.value === reviewsScope)
return (
- <Tooltip title={`${scopeOption?.tooltip}. Set by the Mine / Everyone filter on recent reviews.`}>
+ <Tooltip title={`${scopeOption?.tooltip}. Set by the Mine / Everyone filter on reviews.`}>
<span className="text-xxs text-tertiary">
<span translate="no">{`Last ${reportCount} completed review${reportCount === 1 ? '' : 's'} · ${scopeOption?.label}`}</span>
</span>
@@ -210,67 +210,11 @@ function perspectiveLabel(skillName: string): string {
return prettifySkillName(skillName)
}
-const COUNT_CHIPS: {
- key: 'must_fix_count' | 'should_fix_count' | 'consider_count'
- label: string
- dot: string
- text: string
-}[] = [
- { key: 'must_fix_count', label: 'must fix', dot: 'bg-danger', text: 'text-danger' },
- { key: 'should_fix_count', label: 'should fix', dot: 'bg-warning', text: 'text-warning' },
- { key: 'consider_count', label: 'consider', dot: 'bg-border-bold', text: 'text-secondary' },
-]
-
-function FindingCounts({ review }: { review: ReviewRecentReviewApi }): JSX.Element {
- const total = review.must_fix_count + review.should_fix_count + review.consider_count
- if (total === 0) {
- return <span>No findings</span>
- }
- return (
- <span className="flex items-center gap-2.5">
- {COUNT_CHIPS.filter((chip) => review[chip.key] > 0).map((chip) => (
- <span key={chip.key} className="flex items-center gap-1 whitespace-nowrap">
- <span className={`size-1.5 rounded-full ${chip.dot}`} />
- <span className={`font-semibold tabular-nums ${chip.text}`}>{review[chip.key]}</span>
- <span>{chip.label}</span>
- </span>
- ))}
- </span>
- )
-}
-
-/** Leading status dot: red when the review found a blocker, gold for other findings, green for a clean pass. */
-function ReviewStatusDot({ review }: { review: ReviewRecentReviewApi }): JSX.Element {
- const total = review.must_fix_count + review.should_fix_count + review.consider_count
- const color = review.must_fix_count > 0 ? 'bg-danger' : total > 0 ? 'bg-warning' : 'bg-success'
- return (
- <span className="flex w-6 shrink-0 justify-center">
- <span className={`size-2 rounded-full ${color}`} />
- </span>
- )
-}
-
/** A Standard turn on the single-agent design: no chunks, no perspective selection, no separate validation. */
function isSingleAgentReview(review: ReviewRecentReviewApi | null): boolean {
return review?.review_design === ReviewTurnDesignEnumApi.SingleAgent
}
-const REVIEW_MODE_LABEL: Record<ReviewTriggerReviewModeEnumApi, string> = {
- flash: 'Standard',
- full: 'Deep',
-}
-
-function ReviewModeTag({ review }: { review: ReviewRecentReviewApi }): JSX.Element | null {
- if (!review.review_mode) {
- return null
- }
- return (
- <LemonTag type="muted" size="small">
- {REVIEW_MODE_LABEL[review.review_mode]}
- </LemonTag>
- )
-}
-
/** Lens count from the sessions that ran: one session is the main pass, the rest are lenses. Null when the turn recorded none. */
function singleAgentLensCount(review: ReviewRecentReviewApi): number | null {
return review.perspective_count ? review.perspective_count - 1 : null
@@ -283,22 +227,6 @@ function singleAgentCounts(review: ReviewRecentReviewApi): { posted: number; rai
return { posted, raised: raised !== null && raised > posted ? raised : null }
}
-/** The funnel line for a single-agent turn, which has no validation step to count. */
-function SingleAgentFindingsLine({ review }: { review: ReviewRecentReviewApi }): JSX.Element {
- const { posted, raised } = singleAgentCounts(review)
- return (
- <span>
- Posted <span className="font-semibold text-default">{posted}</span>
- {raised !== null && (
- <>
- {' '}
- of <span className="font-semibold text-default">{raised}</span> raised
- </>
- )}
- </span>
- )
-}
-
/** The drawer header for a single-agent turn: how it ran, and why the posted count can be lower than the raised count. */
function SingleAgentDrawerSummary({ review }: { review: ReviewDetailApi }): JSX.Element {
const { setReviewDrawerTab } = useActions(reviewHogSettingsLogic)
@@ -338,328 +266,18 @@ function SingleAgentDrawerSummary({ review }: { review: ReviewDetailApi }): JSX.
)
}
-function reviewTitle(review: ReviewRecentReviewApi): string {
- return review.pr_title ?? `${review.repository}#${review.pr_number ?? review.head_branch}`
-}
-
-function progressLabel(review: ReviewRecentReviewApi): string {
- if (!review.progress) {
- return 'Review in progress'
- }
- // Steps match the pipeline as users think of it: chunking → pick perspectives → review →
- // dedupe → validation → finalize. Fetching folds into step 1.
- const { review_stage, done, total } = review.progress
- const percent = done !== null && total !== null && total > 0 ? ` · ${Math.round((done / total) * 100)}%` : ''
- switch (review_stage) {
- case 'fetching':
- return 'Step 1/6 · Preparing the diff'
- case 'chunking':
- return 'Step 1/6 · Splitting into chunks'
- case 'selecting':
- return 'Step 2/6 · Picking perspectives'
- case 'reviewing':
- return `Step 3/6 · Running review passes${percent}`
- case 'deduplicating':
- return 'Step 4/6 · Merging overlapping findings'
- case 'validating':
- return `Step 5/6 · Validating findings${percent}`
- case 'finalizing':
- return 'Step 6/6 · Finalizing the review'
- case 'single_agent_preparing':
- return 'Step 1/3 · Preparing the diff'
- case 'single_agent_reviewing':
- return 'Step 2/3 · Reviewing the pull request'
- case 'single_agent_finalizing':
- return 'Step 3/3 · Finalizing the review'
- }
-}
-
-/** The live resolution run's row label, e.g. "Resolving comments · 6/10 · 5 fixed, 1 needs you". */
-function resolutionLabel(resolution: ReviewResolutionStatusApi): string {
- const outcomes = [
- resolution.fixed > 0 ? `${resolution.fixed} fixed` : null,
- resolution.needs_attention > 0
- ? `${resolution.needs_attention} need${resolution.needs_attention === 1 ? 's' : ''} you`
- : null,
- ].filter(Boolean)
- return `Resolving comments · ${resolution.done}/${resolution.total}${outcomes.length ? ` · ${outcomes.join(', ')}` : ''}`
-}
-
-/** A first review still running: no findings to expand into yet, just the live stage. */
-function RunningReviewRow({ review }: { review: ReviewRecentReviewApi }): JSX.Element {
- const { showReviewAuthor } = useValues(reviewHogSettingsLogic)
- const showAuthor = showReviewAuthor(review)
- return (
- <div className="flex items-center gap-3 px-4 py-3">
- <span className="flex w-6 shrink-0 justify-center">
- <Spinner className="text-lg" />
- </span>
- <div className="min-w-0 flex-1">
- <div className="truncate text-sm font-semibold">{reviewTitle(review)}</div>
- <div className="mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-secondary">
- <span className="whitespace-nowrap font-mono text-tertiary">
- {review.repository}#{review.pr_number ?? review.head_branch}
- </span>
- {showAuthor && (
- <>
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap">by {review.pr_author}</span>
- </>
- )}
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap font-medium text-warning">
- {review.resolution?.resolution_status === 'resolving'
- ? resolutionLabel(review.resolution)
- : progressLabel(review)}
- </span>
- </div>
- </div>
- <LemonButton size="small" type="secondary" to={review.github_url} targetBlank sideIcon={<IconExternal />}>
- {review.github_url.includes('/pull/') ? 'View PR' : 'View branch'}
- </LemonButton>
- </div>
- )
-}
-
-/** One expandable review row: essentials collapsed; PR facts + funnel + findings entry when open. */
-function RecentReviewRow({ review }: { review: ReviewRecentReviewApi }): JSX.Element {
- const { expandedReviewIds, showReviewAuthor } = useValues(reviewHogSettingsLogic)
- const { toggleReviewRowExpanded, openReviewDetail } = useActions(reviewHogSettingsLogic)
- const expanded = expandedReviewIds.includes(review.id)
- const validated = review.must_fix_count + review.should_fix_count + review.consider_count
- const showAuthor = showReviewAuthor(review)
-
- // A first review has no completed turn to expand into — it renders as a live progress row.
- if (review.in_progress && review.run_count === 0) {
- return <RunningReviewRow review={review} />
- }
-
- return (
- <div className="flex flex-col">
- <div
- role="button"
- tabIndex={0}
- aria-expanded={expanded}
- onClick={() => toggleReviewRowExpanded(review.id)}
- onKeyDown={(e) => e.key === 'Enter' && toggleReviewRowExpanded(review.id)}
- className="flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-fill-highlight-50"
- >
- <ReviewStatusDot review={review} />
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className="truncate text-sm font-semibold">{reviewTitle(review)}</span>
- {review.resolution?.resolution_status === 'resolving' ? (
- <LemonTag type="warning" size="small" className="inline-flex items-center gap-1">
- <Spinner className="text-xs" /> {resolutionLabel(review.resolution)}
- </LemonTag>
- ) : review.in_progress ? (
- <LemonTag type="warning" size="small" className="inline-flex items-center gap-1">
- <Spinner className="text-xs" /> Re-reviewing · {progressLabel(review)}
- </LemonTag>
- ) : review.resolution?.resolution_status === 'stopped' ? (
- <LemonTag type="muted" size="small">
- Resolution didn't finish · stopped at {review.resolution.done}/{review.resolution.total}
- </LemonTag>
- ) : null}
- {!review.published && (
- <LemonTag type="muted" size="small">
- Not published
- </LemonTag>
- )}
- <ReviewModeTag review={review} />
- </div>
- <div className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-secondary">
- <span className="whitespace-nowrap font-mono text-tertiary">
- {review.repository}#{review.pr_number ?? review.head_branch}
- </span>
- {showAuthor && (
- <>
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap">by {review.pr_author}</span>
- </>
- )}
- <span className="text-tertiary">·</span>
- <FindingCounts review={review} />
- {review.last_run_at && (
- <>
- <span className="text-tertiary">·</span>
- <TZLabel time={review.last_run_at} />
- </>
- )}
- </div>
- </div>
- {/* stopPropagation so the buttons don't also toggle the row */}
- <div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
- <LemonButton
- size="small"
- type="secondary"
- to={review.github_url}
- targetBlank
- sideIcon={<IconExternal />}
- >
- {review.github_url.includes('/pull/') ? 'View PR' : 'View branch'}
- </LemonButton>
- <LemonButton
- size="small"
- type="tertiary"
- aria-label={expanded ? 'Hide review details' : 'Show review details'}
- icon={<IconChevronDown className={expanded ? 'rotate-180' : ''} />}
- onClick={() => toggleReviewRowExpanded(review.id)}
- />
- </div>
- </div>
- {expanded && (
- <div className="flex flex-col gap-2 border-t border-primary bg-fill-highlight-50 py-3 pl-13 pr-4">
- <div className="flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-secondary">
- {review.pr_author && <span className="whitespace-nowrap">by {review.pr_author}</span>}
- {review.additions !== null && review.deletions !== null && (
- <>
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap font-mono">
- <span className="text-success">+{review.additions}</span>{' '}
- <span className="text-danger">−{review.deletions}</span>
- </span>
- </>
- )}
- {review.changed_files !== null && (
- <>
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap">{review.changed_files} files changed</span>
- </>
- )}
- {review.files_reviewed !== null && (
- <>
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap">{review.files_reviewed} reviewed</span>
- </>
- )}
- {review.chunk_count !== null && (
- <>
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap">
- {review.chunk_count} chunk{review.chunk_count === 1 ? '' : 's'}
- </span>
- </>
- )}
- <span className="text-tertiary">·</span>
- <span className="whitespace-nowrap">
- {review.run_count} review turn{review.run_count === 1 ? '' : 's'}
- </span>
- </div>
- <div className="text-xs text-secondary">
- {isSingleAgentReview(review) ? (
- <SingleAgentFindingsLine review={review} />
- ) : (
- <>
- <span className="font-semibold text-default">{review.candidate_count}</span> findings
- raised → <span className="font-semibold text-default">{validated}</span> kept after
- validation →{' '}
- <span className="font-semibold text-default">{review.dismissed_count}</span> dismissed
- </>
- )}
- </div>
- <div className="flex flex-wrap items-center gap-2">
- <LemonButton size="small" type="secondary" onClick={() => openReviewDetail(review)}>
- View findings
- </LemonButton>
- {review.status_comment_url && (
- <LemonButton
- size="small"
- type="tertiary"
- to={review.status_comment_url}
- targetBlank
- sideIcon={<IconExternal />}
- >
- View status comment
- </LemonButton>
- )}
- </div>
- </div>
- )}
- </div>
- )
-}
-
-/** Proof card and review list with their scope filter, hidden entirely until the project has reviews. */
-function RecentReviewsSection(): JSX.Element | null {
- const {
- recentReviews,
- recentReviewsPageLoading,
- moreReviewsAvailable,
- reviewsExpanding,
- reviewsScope,
- hasUserChosenReviewsScope,
- } = useValues(reviewHogSettingsLogic)
- const { showMoreReviews, showFewerReviews } = useActions(reviewHogSettingsLogic)
- const everyone = reviewsScope === ReviewHogReviewsListScope.Everyone
- const loadedEmpty = recentReviews !== null && recentReviews.length === 0
-
- // Settled-and-empty on the Everyone scope means the project has no reviews at all — hide
- // the section entirely (an in-flight load keeps it mounted with skeletons instead of flashing
- // it away mid-switch). An empty Mine scope keeps the section, with an empty state pointing
- // at the scope filter in the section header.
- if (loadedEmpty && everyone && !recentReviewsPageLoading) {
- return null
- }
- // A stale EMPTY list must not render an empty state while a reload (scope switch, auto-default)
- // is in flight — but previous ROWS are kept during refreshes, so the in-progress poll never
- // flashes skeletons.
- const emptyAwaitingReload = loadedEmpty && (recentReviewsPageLoading || !hasUserChosenReviewsScope)
-
+function ReviewsSection(): JSX.Element {
+ const { reviewsScope } = useValues(reviewHogSettingsLogic)
return (
<section className="flex flex-col gap-4">
- <SectionHeader icon={<IconPullRequest />} title="Recent reviews" action={<ReviewsScopeFilter />}>
- {everyone
- ? 'The latest PostHog Review runs on pull requests across this project. Expand a review for its details and findings.'
- : 'The latest PostHog Review runs on pull requests you authored, plus reviews you started. Expand a review for its details and findings.'}
+ <SectionHeader icon={<IconPullRequest />} title="Reviews" action={<ReviewsScopeFilter />}>
+ {reviewsScope === ReviewHogReviewsListScope.Everyone
+ ? 'PostHog Review runs on pull requests across this project, latest activity first. Open a review for its findings.'
+ : 'PostHog Review runs on pull requests you authored, plus reviews you started, latest activity first. Open a review for its findings.'}
</SectionHeader>
<ProofCard />
- <LemonCard hoverEffect={false} className="divide-y divide-primary p-0">
- {recentReviews === null || emptyAwaitingReload ? (
- [0, 1, 2].map((i) => (
- <div key={i} className="flex items-center gap-3 px-4 py-3">
- <span className="flex w-6 shrink-0 justify-center">
- <LemonSkeleton.Circle className="size-2" />
- </span>
- <div className="flex min-w-0 flex-1 flex-col gap-1.5">
- <LemonSkeleton className="h-4 w-80 max-w-full" />
- <LemonSkeleton className="h-3 w-56 max-w-full" />
- </div>
- <LemonSkeleton className="h-8 w-24 shrink-0" />
- </div>
- ))
- ) : recentReviews.length ? (
- <>
- {recentReviews.map((review) => (
- <RecentReviewRow key={review.id} review={review} />
- ))}
- {(moreReviewsAvailable || recentReviews.length > REVIEWS_PAGE_SIZE) && (
- <div className="flex justify-center gap-2 px-4 py-1.5">
- {moreReviewsAvailable && (
- <LemonButton
- size="small"
- type="tertiary"
- onClick={showMoreReviews}
- loading={reviewsExpanding}
- >
- Show more
- </LemonButton>
- )}
- {recentReviews.length > REVIEWS_PAGE_SIZE && (
- <LemonButton size="small" type="tertiary" onClick={showFewerReviews}>
- Show fewer
- </LemonButton>
- )}
- </div>
- )}
- </>
- ) : (
- <div className="px-4 py-6 text-center text-sm text-secondary">
- No reviews of your pull requests or reviews you started yet. Pick "Everyone" above to see the
- whole team's.
- </div>
- )}
- </LemonCard>
+ <ReviewsFilters />
+ <ReviewsTable />
</section>
)
}
@@ -687,7 +305,7 @@ function TriggerReviewSection(): JSX.Element {
<section className="flex flex-col gap-4">
<SectionHeader icon={<IconGithub />} title="Review a pull request">
Start a Deep review of any pull request the GitHub App can access. The review is posted back to the pull
- request and shows up under recent reviews. Your perspectives and other review skills apply to Deep
+ request and shows up under Reviews below. Your perspectives and other review skills apply to Deep
reviews only.
</SectionHeader>
<form
@@ -1214,7 +832,7 @@ function ReviewDetailDrawer(): JSX.Element {
{review.repository}#{review.pr_number ?? review.head_branch}
{review.pr_author ? ` · by ${review.pr_author}` : ''}
</span>
- <ReviewModeTag review={review} />
+ <ReviewModeTag mode={review.review_mode} />
{review.status_comment_url && (
<Link to={review.status_comment_url} target="_blank" targetBlankIcon>
Status comment
@@ -1277,7 +895,7 @@ function ActivityTab(): JSX.Element {
return (
<>
<TriggerReviewSection />
- <RecentReviewsSection />
+ <ReviewsSection />
<PipelineSection />
</>
)
diff --git a/products/review_hog/frontend/reviewHogSettingsLogic.test.ts b/products/review_hog/frontend/reviewHogSettingsLogic.test.ts
index 658388f40b91..00a165b0b2c3 100644
--- a/products/review_hog/frontend/reviewHogSettingsLogic.test.ts
+++ b/products/review_hog/frontend/reviewHogSettingsLogic.test.ts
@@ -8,11 +8,11 @@ import { initKeaTests } from '~/test/init'
import {
ReviewHogReviewsListScope,
+ type ReviewReviewsTablePageApi,
ReviewTriggerRequestRunModeEnumApi,
} from 'products/review_hog/frontend/generated/api.schemas'
import {
- MAX_REVIEWS_LIMIT,
REVIEW_SKILL_PREFIX_BY_KIND,
REVIEWS_PAGE_SIZE,
defaultAdoptSlug,
@@ -34,12 +34,12 @@ function reviewDetail(id: string, runUrgencyThreshold: string | null): Record<st
}
}
-// More project-wide reviews than the API's maximum limit, so both "Show more" growth and its
-// ceiling are reachable.
-const everyoneReviews = Array.from({ length: MAX_REVIEWS_LIMIT + REVIEWS_PAGE_SIZE }, (_, i) => ({
+// More project-wide reviews than one page, so paging is reachable.
+const everyoneReviews = Array.from({ length: REVIEWS_PAGE_SIZE * 2 + 3 }, (_, i) => ({
id: `r${i}`,
repository: 'example-org/example-repo',
in_progress: false,
+ run_count: 1,
}))
describe('reviewHogSettingsLogic', () => {
@@ -48,14 +48,7 @@ describe('reviewHogSettingsLogic', () => {
beforeEach(() => {
useMocks({
get: {
- // The user has no reviews of their own; the project has a dozen.
- '/api/projects/:team_id/review_hog/reviews/': ({ request }) => {
- const url = new URL(request.url)
- const limit = Number(url.searchParams.get('limit') ?? REVIEWS_PAGE_SIZE)
- const pool =
- url.searchParams.get('scope') === ReviewHogReviewsListScope.Everyone ? everyoneReviews : []
- return [200, { results: pool.slice(0, limit), has_more: pool.length > limit }]
- },
+ // The user has no reviews of their own; the project has a few pages.
'/api/projects/:team_id/review_hog/reviews/table/': ({ request }) => {
const url = new URL(request.url)
const limit = Number(url.searchParams.get('limit'))
@@ -102,13 +95,13 @@ describe('reviewHogSettingsLogic', () => {
logic.mount()
await expectLogic(logic)
- .toDispatchActions(['loadRecentReviewsSuccess', 'applyDefaultReviewsScope', 'loadRecentReviewsSuccess'])
+ .toDispatchActions(['loadReviewsSuccess', 'applyDefaultReviewsScope', 'loadReviewsSuccess'])
.toMatchValues({
reviewsScope: ReviewHogReviewsListScope.Everyone,
// The auto-default is not an explicit choice — a later real one must still win.
hasUserChosenReviewsScope: false,
})
- expect(logic.values.recentReviews).toHaveLength(REVIEWS_PAGE_SIZE)
+ expect(logic.values.reviews).toHaveLength(REVIEWS_PAGE_SIZE)
// The auto-default must not write the URL: hydrating `?reviews_scope=` from a link marks
// the scope as explicitly chosen, so mirroring the fallback would make it permanent.
expect(router.values.searchParams.reviews_scope).toBeUndefined()
@@ -156,11 +149,11 @@ describe('reviewHogSettingsLogic', () => {
it('a started review clears the input, reloads the list, and resets the in-flight flag', async () => {
logic.mount()
- // Consume the mount-time auto-default so its loadRecentReviews can't satisfy the assertion below.
+ // Consume the mount-time auto-default so its loadReviews can't satisfy the assertion below.
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
logic.actions.setTriggerPrUrl('https://github.com/PostHog/posthog.com/pull/1')
@@ -168,7 +161,7 @@ describe('reviewHogSettingsLogic', () => {
.toDispatchActions([
'submitTriggerReview',
'startTriggeredReviewWatch',
- 'loadRecentReviews',
+ 'loadReviews',
'submitTriggerReviewFinished',
])
.toMatchValues({ triggeringReview: false, triggerPrUrl: '' })
@@ -191,9 +184,9 @@ describe('reviewHogSettingsLogic', () => {
})
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
logic.actions.setTriggerPrUrl('https://github.com/PostHog/posthog.com/pull/1')
@@ -219,16 +212,16 @@ describe('reviewHogSettingsLogic', () => {
})
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
logic.actions.setTriggerPrUrl('https://github.com/PostHog/posthog.com/pull/1')
await expectLogic(logic, () =>
logic.actions.submitTriggerReview(ReviewTriggerRequestRunModeEnumApi.ResolveOnly)
)
- .toDispatchActions(['submitTriggerReview', 'loadRecentReviews', 'submitTriggerReviewFinished'])
+ .toDispatchActions(['submitTriggerReview', 'loadReviews', 'submitTriggerReviewFinished'])
.toNotHaveDispatchedActions(['startTriggeredReviewWatch'])
.toMatchValues({ triggeringReview: false, triggerPrUrl: '', awaitingTriggeredReview: false })
expect(requestBody).toMatchObject({ run_mode: 'resolve_only' })
@@ -248,9 +241,9 @@ describe('reviewHogSettingsLogic', () => {
})
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
logic.actions.setTriggerPrUrl('https://github.com/PostHog/posthog.com/pull/1')
@@ -271,14 +264,14 @@ describe('reviewHogSettingsLogic', () => {
})
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
logic.actions.setTriggerPrUrl('https://github.com/PostHog/posthog.com/pull/1')
await expectLogic(logic, () => logic.actions.submitTriggerReview())
- .toDispatchActions(['submitTriggerReview', 'loadRecentReviews', 'submitTriggerReviewFinished'])
+ .toDispatchActions(['submitTriggerReview', 'loadReviews', 'submitTriggerReviewFinished'])
.toNotHaveDispatchedActions(['startTriggeredReviewWatch'])
.toMatchValues({ triggeringReview: false, triggerPrUrl: '', awaitingTriggeredReview: false })
})
@@ -294,15 +287,15 @@ describe('reviewHogSettingsLogic', () => {
})
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
logic.actions.setTriggerPrUrl('https://github.com/PostHog/posthog.com/pull/1')
await expectLogic(logic, () => logic.actions.submitTriggerReview())
.toDispatchActions(['submitTriggerReview', 'submitTriggerReviewFinished'])
- .toNotHaveDispatchedActions(['loadRecentReviews', 'startTriggeredReviewWatch'])
+ .toNotHaveDispatchedActions(['loadReviews', 'startTriggeredReviewWatch'])
.toMatchValues({
triggeringReview: false,
triggerPrUrl: 'https://github.com/PostHog/posthog.com/pull/1',
@@ -326,7 +319,7 @@ describe('reviewHogSettingsLogic', () => {
})
logic.mount()
await expectLogic(logic)
- .toDispatchActions(['loadRecentReviewsSuccess', 'applyDefaultReviewsScope', 'loadRecentReviewsSuccess'])
+ .toDispatchActions(['loadReviewsSuccess', 'applyDefaultReviewsScope', 'loadReviewsSuccess'])
.toFinishAllListeners()
// The Settings tab's skill counts read the viewer's own Deep reviews, so the Activity switch
// must never reload or rescope them.
@@ -340,7 +333,7 @@ describe('reviewHogSettingsLogic', () => {
// 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()
+ expect(logic.values.reviews).toBeNull()
await expectLogic(logic).toDispatchActions(['loadPerspectiveStatsSuccess'])
expect(listScopes()[listScopes().length - 1]).toBe(ReviewHogReviewsListScope.Mine)
expect(statsScopes.filter((scope) => scope === 'own_deep')).toHaveLength(ownDeepLoads)
@@ -350,60 +343,30 @@ describe('reviewHogSettingsLogic', () => {
logic.mount()
// Consume the mount-time auto-default, so the not-dispatched window below starts after it.
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
await expectLogic(logic, () => logic.actions.setReviewsScope(ReviewHogReviewsListScope.Mine))
- .toDispatchActions(['loadRecentReviewsSuccess'])
+ .toDispatchActions(['loadReviewsSuccess'])
.toNotHaveDispatchedActions(['applyDefaultReviewsScope'])
.toMatchValues({
reviewsScope: ReviewHogReviewsListScope.Mine,
hasUserChosenReviewsScope: true,
- recentReviews: [],
+ reviews: [],
})
})
- it('grows the list by a page per "Show more" and collapses instantly on "Show fewer"', async () => {
- logic.mount()
- // Land on the everyone scope (auto-default) with the first page loaded.
- await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
- 'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
- ])
- expect(logic.values.moreReviewsAvailable).toBe(true)
-
- await expectLogic(logic, () => logic.actions.showMoreReviews())
- .toDispatchActions(['loadRecentReviewsSuccess'])
- .toMatchValues({ reviewsLimit: REVIEWS_PAGE_SIZE * 2 })
- expect(logic.values.recentReviews).toHaveLength(REVIEWS_PAGE_SIZE * 2)
-
- // The collapse must not wait for the reconciling refetch, and hiding loaded rows means
- // "Show more" must stay on offer regardless of the last response's flag.
- logic.actions.showFewerReviews()
- expect(logic.values.recentReviews).toHaveLength(REVIEWS_PAGE_SIZE)
- expect(logic.values.moreReviewsAvailable).toBe(true)
- await expectLogic(logic).toDispatchActions(['loadRecentReviewsSuccess']).toMatchValues({
- reviewsLimit: REVIEWS_PAGE_SIZE,
- })
-
- // A scope flip is a different list — it starts compact again.
- logic.actions.showMoreReviews()
- logic.actions.setReviewsScope(ReviewHogReviewsListScope.Mine)
- await expectLogic(logic).toMatchValues({ reviewsLimit: REVIEWS_PAGE_SIZE })
- })
-
- it('a table filter change resets the page and sends the filter with the request', async () => {
+ it('a filter change resets the page and sends the filter with the request', async () => {
// Page 2 of every review is rarely a page at all once a filter narrows the set; a kept page
// number would land the reader on an empty table.
const requests: URLSearchParams[] = []
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
useMocks({
get: {
@@ -426,7 +389,7 @@ describe('reviewHogSettingsLogic', () => {
expect(router.values.searchParams.reviews_page).toBeUndefined()
})
- it('restores table filters and the page from a link without resetting the page', async () => {
+ it('restores filters and the page from a link without resetting the page', async () => {
// Each filter setter resets the page, so an unguarded replay would drop every shared
// `reviews_page` back to page 1.
router.actions.push(urls.codeReview(), {
@@ -444,15 +407,6 @@ describe('reviewHogSettingsLogic', () => {
expect(logic.values.reviews?.[0].id).toBe(`r${REVIEWS_PAGE_SIZE}`)
})
- it('flags a failed table load so the table can show its error state', async () => {
- // A first load that fails must not read as an empty table.
- logic.mount()
- useMocks({ get: { '/api/projects/:team_id/review_hog/reviews/table/': () => [500, {}] } })
-
- await expectLogic(logic, () => logic.actions.setReviewsPage(2)).toDispatchActions(['loadReviewsFailure'])
- expect(logic.values).toMatchObject({ reviewsPage: null, reviewsFailed: true })
- })
-
it('buckets drawer findings by the stored run threshold, with the viewer proxy only for old rows', async () => {
// The run gated at must_fix while the viewer's own setting (mocked above) is should_fix.
// Bucketing by the viewer's setting would show the held-back should_fix finding as
@@ -491,7 +445,7 @@ describe('reviewHogSettingsLogic', () => {
},
})
logic.mount()
- await expectLogic(logic).toDispatchActions(['loadRecentReviewsSuccess'])
+ await expectLogic(logic).toDispatchActions(['loadReviewsSuccess'])
router.actions.push(urls.codeReview(), { review: 'r-9' })
await expectLogic(logic)
@@ -543,7 +497,7 @@ describe('reviewHogSettingsLogic', () => {
},
})
logic.mount()
- await expectLogic(logic).toDispatchActions(['loadRecentReviewsSuccess'])
+ await expectLogic(logic).toDispatchActions(['loadReviewsSuccess'])
router.actions.push(urls.codeReview(), { review: 'r-gone' })
await expectLogic(logic).toDispatchActions([
@@ -555,44 +509,32 @@ describe('reviewHogSettingsLogic', () => {
expect(router.values.searchParams.review).toBeUndefined()
})
- it('stops "Show more" at the API\'s maximum limit', async () => {
+ it('polls only while the page has a running review', async () => {
+ // A poll that never stops spends a request every 10s on an idle table; one that never
+ // starts leaves a running row's stage frozen.
+ const page = (inProgress: boolean): ReviewReviewsTablePageApi =>
+ ({
+ count: 1,
+ running_count: inProgress ? 1 : 0,
+ results: [
+ { id: 'r-live', repository: 'example-org/example-repo', in_progress: inProgress, run_count: 1 },
+ ],
+ }) as ReviewReviewsTablePageApi
logic.mount()
- await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
- 'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
- ])
-
- // Enough clicks to push an unclamped limit past the API's max, where the request would 400
- // and strand the user on a dead button.
- for (let i = 0; i < MAX_REVIEWS_LIMIT / REVIEWS_PAGE_SIZE; i++) {
- logic.actions.showMoreReviews()
- }
- await expectLogic(logic).toFinishAllListeners()
-
- expect(logic.values.reviewsLimit).toBe(MAX_REVIEWS_LIMIT)
- expect(logic.values.recentReviews).toHaveLength(MAX_REVIEWS_LIMIT)
- // More rows exist server-side, but the ceiling is reached — the button goes away rather
- // than offering a request the server rejects.
- expect(logic.values.moreReviewsAvailable).toBe(false)
- })
-
- it('keeps a slower baseline poll running when nothing is in progress', async () => {
- // Reviews started outside this page (the GitHub label, inbox auto-reviews, a teammate)
- // only ever appear via the baseline poll — reverting to dispose-on-idle makes the page
- // permanently stale until a manual refresh.
+ await expectLogic(logic)
+ .toDispatchActions(['loadReviewsSuccess', 'applyDefaultReviewsScope', 'loadReviewsSuccess'])
+ .toFinishAllListeners()
jest.useFakeTimers()
try {
- logic.mount()
- await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
- 'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
- ])
+ logic.actions.loadReviewsSuccess(page(true))
+ await expectLogic(logic, () => {
+ jest.advanceTimersByTime(10_000)
+ }).toDispatchActions(['loadReviews'])
+ logic.actions.loadReviewsSuccess(page(false))
await expectLogic(logic, () => {
- jest.advanceTimersByTime(30_000)
- }).toDispatchActions(['loadRecentReviews', 'loadRecentReviewsSuccess'])
+ jest.advanceTimersByTime(60_000)
+ }).toNotHaveDispatchedActions(['loadReviews'])
} finally {
jest.useRealTimers()
}
@@ -604,54 +546,54 @@ describe('reviewHogSettingsLogic', () => {
let finished = false
useMocks({
get: {
- '/api/projects/:team_id/review_hog/reviews/': () => [
+ '/api/projects/:team_id/review_hog/reviews/table/': () => [
200,
{
- results: [{ id: 'r-live', in_progress: !finished, run_count: finished ? 1 : 0 }],
- has_more: false,
+ count: 1,
+ running_count: finished ? 0 : 1,
+ results: [
+ {
+ id: 'r-live',
+ repository: 'example-org/example-repo',
+ in_progress: !finished,
+ run_count: finished ? 1 : 0,
+ },
+ ],
},
],
'/api/projects/:team_id/review_hog/reviews/r-live/': () => [200, reviewDetail('r-live', null)],
},
})
logic.mount()
- await expectLogic(logic).toDispatchActions(['loadRecentReviewsSuccess']).toFinishAllListeners()
+ await expectLogic(logic).toDispatchActions(['loadReviewsSuccess']).toFinishAllListeners()
logic.actions.openReviewDetailById('r-live')
await expectLogic(logic).toDispatchActions(['loadReviewDetailSuccess'])
finished = true
- await expectLogic(logic, () => logic.actions.loadRecentReviews()).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ await expectLogic(logic, () => logic.actions.loadReviews()).toDispatchActions([
+ 'loadReviewsSuccess',
'loadPerspectiveStats',
'loadReviewDetail',
])
})
- it('keeps the failure banner off for a background refresh blip', async () => {
+ it('keeps the rows on a background refresh blip and shows the error only with nothing loaded', async () => {
+ // A poll blip must not replace rows on screen with an error, and a first load that fails
+ // must not read as an empty table.
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
- useMocks({ get: { '/api/projects/:team_id/review_hog/reviews/': () => [500, {}] } })
-
- // The poll retries on its next tick and the prior rows stay on screen — flashing the
- // page-level banner over one blip would cry wolf every time a request hiccups.
- await expectLogic(logic, () => logic.actions.loadRecentReviews())
- .toDispatchActions(['loadRecentReviewsFailure'])
- .toNotHaveDispatchedActions(['markInitialLoadFailed'])
- expect(logic.values.initialLoadFailed).toBe(false)
- })
+ useMocks({ get: { '/api/projects/:team_id/review_hog/reviews/table/': () => [500, {}] } })
- it('flags a reviews failure with nothing loaded yet as an initial-load failure', async () => {
- // Without this the section sits on skeletons forever with no retry path offered.
- useMocks({ get: { '/api/projects/:team_id/review_hog/reviews/': () => [500, {}] } })
- logic.mount()
+ await expectLogic(logic, () => logic.actions.loadReviews()).toDispatchActions(['loadReviewsFailure'])
+ expect(logic.values.reviews).toHaveLength(REVIEWS_PAGE_SIZE)
- await expectLogic(logic).toDispatchActions(['loadRecentReviewsFailure', 'markInitialLoadFailed'])
- expect(logic.values.initialLoadFailed).toBe(true)
+ await expectLogic(logic, () => logic.actions.setReviewsPage(2)).toDispatchActions(['loadReviewsFailure'])
+ expect(logic.values).toMatchObject({ reviewsPage: null, reviewsFailed: true, initialLoadFailed: false })
})
it('checks the list immediately when the tab becomes visible again', async () => {
@@ -659,14 +601,14 @@ describe('reviewHogSettingsLogic', () => {
// which reads as stale exactly when the user comes back to look.
logic.mount()
await expectLogic(logic).toDispatchActions([
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
'applyDefaultReviewsScope',
- 'loadRecentReviewsSuccess',
+ 'loadReviewsSuccess',
])
await expectLogic(logic, () => {
document.dispatchEvent(new Event('visibilitychange'))
- }).toDispatchActions(['loadRecentReviews'])
+ }).toDispatchActions(['loadReviews'])
})
test.each([
diff --git a/products/review_hog/frontend/reviewHogSettingsLogic.ts b/products/review_hog/frontend/reviewHogSettingsLogic.ts
index 6da4097fd7ff..6da14fa2aac2 100644
--- a/products/review_hog/frontend/reviewHogSettingsLogic.ts
+++ b/products/review_hog/frontend/reviewHogSettingsLogic.ts
@@ -9,8 +9,6 @@ import type { SkillPickerGroup } from 'lib/components/SkillPicker/SkillPicker'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
-import { usersGithubLoginRetrieve } from '~/generated/core/api'
-
import { OriginProduct } from 'products/posthog_ai/frontend/types/taskTypes'
import {
reviewHogBlindSpotsList,
@@ -19,7 +17,6 @@ import {
reviewHogPerspectivesPartialUpdate,
reviewHogResolutionList,
reviewHogResolutionPartialUpdate,
- reviewHogReviewsList,
reviewHogReviewsPerspectiveStatsRetrieve,
reviewHogReviewsRetrieve,
reviewHogReviewsTableRetrieve,
@@ -39,7 +36,6 @@ import type {
ReviewPerspectiveStatItemApi,
ReviewPerspectiveStatsApi,
ReviewRecentReviewApi,
- ReviewRecentReviewsPageApi,
ReviewResolutionConfigApi,
ReviewReviewsTablePageApi,
ReviewUserSettingsApi,
@@ -77,15 +73,9 @@ export const REVIEW_PRIORITY_RANK: Record<ReviewIssuePriorityEnumApi, number> =
must_fix: 2,
}
-// While a review is running, the list refreshes on this cadence so the stage/progress row is live.
+// Poll cadence while the visible page has a running review, so its stage label stays live.
const IN_PROGRESS_POLL_INTERVAL_MS = 10_000
-// With nothing running the list still refreshes, just slower: reviews started outside this page
-// (the GitHub label, inbox auto-reviews, a teammate) have no other way to appear, and a finished
-// run's published state can land moments after its last in-progress response. Hidden tabs pause
-// the poll entirely, so the idle cadence only spends requests someone could actually see.
-const IDLE_POLL_INTERVAL_MS = 30_000
-
/** What the poll remembers about a row between responses, to spot a run finishing. */
interface ReviewRunMarker {
inProgress: boolean
@@ -97,11 +87,7 @@ interface ReviewRunMarker {
// it must not keep the list polling forever.
const TRIGGERED_REVIEW_WATCH_TIMEOUT_MS = 2 * 60 * 1000
-/** The review list's initial depth, the step each "Show more" adds, and what "Show fewer" collapses to. */
-export const REVIEWS_PAGE_SIZE = 5
-
-/** Mirrors MAX_REVIEWS_LIMIT in reviews.py — the API 400s above this, so growth must stop here. */
-export const MAX_REVIEWS_LIMIT = 100
+export const REVIEWS_PAGE_SIZE = 25
/** The detail's valid findings split by the user's urgency threshold: on the PR vs. kept back. */
export interface ReviewFindingsSplit {
@@ -262,10 +248,8 @@ export interface reviewHogSettingsLogicValues {
judged: number
kept: number
} | null
- expandedReviewIds: string[]
hasUserChosenReviewsScope: boolean
initialLoadFailed: boolean
- moreReviewsAvailable: boolean
openedReview: ReviewRecentReviewApi | null
openedReviewId: string | null
perspectiveScoreboard: PerspectiveScore[] | null
@@ -274,9 +258,6 @@ export interface reviewHogSettingsLogicValues {
perspectives: ReviewPerspectiveConfigApi[] | null
perspectivesLoading: boolean
pipelineDetailOpen: boolean
- recentReviews: ReviewRecentReviewApi[] | null
- recentReviewsPage: ReviewRecentReviewsPageApi | null
- recentReviewsPageLoading: boolean
resolutionSkills: ReviewResolutionConfigApi[] | null
resolutionSkillsLoading: boolean
reviewDetail: ReviewDetailApi | null
@@ -286,10 +267,8 @@ export interface reviewHogSettingsLogicValues {
reviewFindingsSplit: ReviewFindingsSplit | null
reviews: ReviewRecentReviewApi[] | null
reviewsCurrentPage: number
- reviewsExpanding: boolean
reviewsFailed: boolean
reviewsFiltered: boolean
- reviewsLimit: number
reviewsMode: ReviewHogReviewsTableRetrieveReviewMode | null
reviewsPage: ReviewReviewsTablePageApi | null
reviewsPageLoading: boolean
@@ -302,15 +281,12 @@ export interface reviewHogSettingsLogicValues {
seenRepositories: string[]
settings: ReviewUserSettingsApi | null
settingsLoading: boolean
- showReviewAuthor: (review: ReviewRecentReviewApi) => boolean
triggerPrUrl: string
triggerUrlHasFullReview: boolean
triggerUrlResolving: boolean
triggeringReview: boolean
validators: ReviewValidatorConfigApi[] | null
validatorsLoading: boolean
- viewerGithubLogin: string | null
- viewerGithubLoginLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -420,21 +396,6 @@ export interface reviewHogSettingsLogicActions {
perspectives: ReviewPerspectiveConfigApi[]
payload?: any
}
- loadRecentReviews: (_?: any) => any
- loadRecentReviewsFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadRecentReviewsSuccess: (
- recentReviewsPage: ReviewRecentReviewsPageApi,
- payload?: any
- ) => {
- recentReviewsPage: ReviewRecentReviewsPageApi
- payload?: any
- }
loadResolutionSkills: () => any
loadResolutionSkillsFailure: (
error: string,
@@ -510,21 +471,6 @@ export interface reviewHogSettingsLogicActions {
validators: ReviewValidatorConfigApi[]
payload?: any
}
- loadViewerGithubLogin: () => any
- loadViewerGithubLoginFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadViewerGithubLoginSuccess: (
- viewerGithubLogin: string | null,
- payload?: any
- ) => {
- viewerGithubLogin: string | null
- payload?: any
- }
markInitialLoadFailed: () => {
value: true
}
@@ -593,12 +539,6 @@ export interface reviewHogSettingsLogicActions {
setTriggerPrUrl: (prUrl: string) => {
prUrl: string
}
- showFewerReviews: () => {
- value: true
- }
- showMoreReviews: () => {
- value: true
- }
startSkillAuthorTask: (kind: ReviewSkillKind) => {
kind: ReviewSkillKind
}
@@ -636,9 +576,6 @@ export interface reviewHogSettingsLogicActions {
enabled: boolean
skillName: string
}
- toggleReviewRowExpanded: (reviewId: string) => {
- reviewId: string
- }
updateSettings: (patch: PatchedReviewUserSettingsApi) => PatchedReviewUserSettingsApi
updateSettingsFailure: (
error: string,
@@ -684,8 +621,6 @@ export interface reviewHogSettingsLogicMeta {
validators: ReviewValidatorConfigApi[] | null,
resolutionSkills: ReviewResolutionConfigApi[] | null
) => string | null
- recentReviews: (recentReviewsPage: ReviewRecentReviewsPageApi | null) => ReviewRecentReviewApi[] | null
- moreReviewsAvailable: (recentReviewsPage: ReviewRecentReviewsPageApi | null, reviewsLimit: number) => boolean
reviews: (reviewsPage: ReviewReviewsTablePageApi | null) => ReviewRecentReviewApi[] | null
reviewsFiltered: (
reviewsRepository: string | null,
@@ -698,12 +633,8 @@ export interface reviewHogSettingsLogicMeta {
reviewDetail: ReviewDetailApi | null,
settings: ReviewUserSettingsApi | null
) => ReviewFindingsSplit | null
- triggerUrlHasFullReview: (triggerPrUrl: string, recentReviews: ReviewRecentReviewApi[] | null) => boolean
- triggerUrlResolving: (triggerPrUrl: string, recentReviews: ReviewRecentReviewApi[] | null) => boolean
- showReviewAuthor: (
- reviewsScope: ReviewHogReviewsListScope,
- viewerGithubLogin: string | null
- ) => (review: ReviewRecentReviewApi) => boolean
+ triggerUrlHasFullReview: (triggerPrUrl: string, reviews: ReviewRecentReviewApi[] | null) => boolean
+ triggerUrlResolving: (triggerPrUrl: string, reviews: ReviewRecentReviewApi[] | null) => boolean
perspectiveScoreboard: (reviewDetail: ReviewDetailApi | null) => PerspectiveScore[] | null
}
}
@@ -747,10 +678,7 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
closePipelineDetail: true,
setActiveTab: (tab: CodeReviewTab) => ({ tab }),
setReviewDrawerTab: (tab: ReviewDrawerTab) => ({ tab }),
- toggleReviewRowExpanded: (reviewId: string) => ({ reviewId }),
setReviewsScope: (scope: ReviewHogReviewsListScope) => ({ scope }),
- showMoreReviews: true,
- showFewerReviews: true,
setReviewsPage: (page: number) => ({ page }),
setReviewsRepository: (repository: string | null) => ({ repository }),
setReviewsMode: (mode: ReviewHogReviewsTableRetrieveReviewMode | null) => ({ mode }),
@@ -787,8 +715,7 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
) => ({ runMode }),
submitTriggerReviewStarted: true,
submitTriggerReviewFinished: true,
- // Keeps the recent-reviews poll on the tight cadence until a just-triggered review's report
- // row appears; without it the poll only tightens when some review is already visibly running.
+ // Keeps the table polling until a just-triggered review's report row appears.
startTriggeredReviewWatch: true,
stopTriggeredReviewWatch: true,
// Flags a load failure as the page-level one. Dispatched by the failure listeners only when
@@ -859,19 +786,6 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
},
},
],
- recentReviewsPage: [
- null as ReviewRecentReviewsPageApi | null,
- {
- // The default param keeps the action zero-arg in the generated logic type.
- loadRecentReviews: async (_ = null, breakpoint) => {
- const { reviewsScope: scope, reviewsLimit: limit } = values
- const response = await reviewHogReviewsList(currentProjectId(), { scope, limit })
- // A scope or limit change mid-flight dispatched a newer load — drop this stale response.
- breakpoint()
- return response
- },
- },
- ],
reviewsPage: [
null as ReviewReviewsTablePageApi | null,
{
@@ -907,21 +821,6 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
},
},
],
- // The viewer's linked GitHub login. Under "Mine", it tells the viewer's own pull requests
- // apart from teammates' pull requests that the viewer reviewed.
- viewerGithubLogin: [
- null as string | null,
- {
- loadViewerGithubLogin: async () => {
- try {
- return (await usersGithubLoginRetrieve('@me'))?.github_login ?? null
- } catch {
- // Without a login every author shows, which is the safe fallback.
- return null
- }
- },
- },
- ],
perspectiveStats: [
null as ReviewPerspectiveStatsApi | null,
{
@@ -1034,58 +933,12 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
openReviewDetailById: () => 'published' as ReviewDrawerTab,
},
],
- expandedReviewIds: [
- [] as string[],
- {
- toggleReviewRowExpanded: (state, { reviewId }) =>
- 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) =>
- state
- ? {
- ...state,
- results: state.results.slice(0, REVIEWS_PAGE_SIZE),
- has_more: state.has_more || state.results.length > REVIEWS_PAGE_SIZE,
- }
- : state,
- },
- // How many rows the review list asks for — grows by a page per "Show more".
- reviewsLimit: [
- REVIEWS_PAGE_SIZE as number,
- {
- showMoreReviews: (state) => Math.min(state + REVIEWS_PAGE_SIZE, MAX_REVIEWS_LIMIT),
- showFewerReviews: () => REVIEWS_PAGE_SIZE,
- // A different scope is a different list — start it compact again.
- setReviewsScope: () => REVIEWS_PAGE_SIZE,
- applyDefaultReviewsScope: () => REVIEWS_PAGE_SIZE,
- },
- ],
- // Drives the "Show more" button's loading state — the loader's own `loading` would also
- // flash on every 10s in-progress poll.
- reviewsExpanding: [
- false,
- {
- showMoreReviews: () => true,
- showFewerReviews: () => false,
- loadRecentReviewsSuccess: () => false,
- loadRecentReviewsFailure: () => false,
- },
- ],
reviewsPage: {
// Drop rows that no longer match the controls so the table shows loading. Poll refreshes keep them.
setReviewsScope: () => null,
@@ -1160,7 +1013,7 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
},
},
],
- // The "Mine / Everyone" filter on the recent-reviews list: it scopes the list AND every stat
+ // The "Mine / Everyone" filter on the reviews table: it scopes the list AND every stat
// surface fed by perspectiveStats (proof card, effectiveness cards on the Settings tab).
// Skill lists and their toggles stay per-user regardless.
reviewsScope: [
@@ -1190,10 +1043,10 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
loadBlindSpotsFailure: () => true,
loadValidatorsFailure: () => true,
loadResolutionSkillsFailure: () => true,
- // recentReviews/perspectiveStats failures arrive via markInitialLoadFailed instead:
- // their loaders also run on background polls, where a one-off failure just retries
- // on the next tick, and only a failure with nothing loaded yet (sections stuck on
- // skeletons, no retry path) is a page-level one.
+ // perspectiveStats failures arrive via markInitialLoadFailed instead: its loader
+ // also runs after a watched run finishes, where a one-off failure is not a
+ // page-level one. Only a failure with nothing loaded yet (cards stuck on skeletons,
+ // no retry path) is. The reviews table shows its own error state.
markInitialLoadFailed: () => true,
},
],
@@ -1373,18 +1226,6 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
return validateAdoptSlug(adoptSlug, adoptSkillKind, takenNames)
},
],
- recentReviews: [
- (s) => [s.recentReviewsPage],
- (recentReviewsPage: ReviewRecentReviewsPageApi | null): ReviewRecentReviewApi[] | null =>
- recentReviewsPage?.results ?? null,
- ],
- moreReviewsAvailable: [
- (s) => [s.recentReviewsPage, s.reviewsLimit],
- (recentReviewsPage: ReviewRecentReviewsPageApi | null, reviewsLimit: number): boolean =>
- // At the API's ceiling the button must go away even though more rows exist —
- // offering it would send a limit the server rejects.
- (recentReviewsPage?.has_more ?? false) && reviewsLimit < MAX_REVIEWS_LIMIT,
- ],
reviews: [
(s) => [s.reviewsPage],
(reviewsPage: ReviewReviewsTablePageApi | null): ReviewRecentReviewApi[] | null =>
@@ -1435,12 +1276,12 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
// Flash does not run on a pull request after a Full review was published there. Only PRs the
// list shows are known here; the trigger endpoint refuses the others with the same reason.
triggerUrlHasFullReview: [
- (s) => [s.triggerPrUrl, s.recentReviews],
- (triggerPrUrl: string, recentReviews: ReviewRecentReviewApi[] | null): boolean => {
+ (s) => [s.triggerPrUrl, s.reviews],
+ (triggerPrUrl: string, reviews: ReviewRecentReviewApi[] | null): boolean => {
const target = parsePrPath(triggerPrUrl)
return (
!!target &&
- (recentReviews ?? []).some(
+ (reviews ?? []).some(
(review) => review.full_review_published && parsePrPath(review.github_url) === target
)
)
@@ -1449,12 +1290,12 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
// Mirrors the server-side busy-guard for PRs the list already shows, so the trigger button
// explains the refusal up front instead of surfacing it as a submit error.
triggerUrlResolving: [
- (s) => [s.triggerPrUrl, s.recentReviews],
- (triggerPrUrl: string, recentReviews: ReviewRecentReviewApi[] | null): boolean => {
+ (s) => [s.triggerPrUrl, s.reviews],
+ (triggerPrUrl: string, reviews: ReviewRecentReviewApi[] | null): boolean => {
const target = parsePrPath(triggerPrUrl)
return (
!!target &&
- (recentReviews ?? []).some(
+ (reviews ?? []).some(
(review) =>
review.resolution?.resolution_status === 'resolving' &&
parsePrPath(review.github_url) === target
@@ -1462,16 +1303,6 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
)
},
],
- // On Everyone, whose PR it is matters at a glance. On Mine, the author shows only when it is
- // not the viewer, which happens for reviews the viewer started on a teammate's pull request.
- showReviewAuthor: [
- (s) => [s.reviewsScope, s.viewerGithubLogin],
- (scope: ReviewHogReviewsListScope, viewerGithubLogin: string | null) =>
- (review: ReviewRecentReviewApi): boolean =>
- !!review.pr_author &&
- (scope === ReviewHogReviewsListScope.Everyone ||
- review.pr_author.toLowerCase() !== viewerGithubLogin?.toLowerCase()),
- ],
perspectiveScoreboard: [
(s) => [s.reviewDetail],
(reviewDetail: ReviewDetailApi | null): PerspectiveScore[] | null => {
@@ -1491,28 +1322,25 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
}),
listeners(({ actions, values, cache }) => ({
- // The poll never stops while the page is mounted (hidden tabs pause it); it only changes
- // cadence: tight while a review is running or freshly triggered so the stage row moves,
- // relaxed otherwise so externally-started reviews still appear. Re-adding under the same
- // key replaces the previous timer, so every response re-arms the poll at the right speed.
- loadRecentReviewsSuccess: () => {
- const anyInProgress = values.recentReviews?.some((review) => review.in_progress) ?? false
- // The watch deliberately runs its full bounded window instead of stopping when an
- // in-progress row shows up: an unrelated already-running review would satisfy that check
- // and could finish before the triggered row appears, relaxing the cadence too early. The
- // cost is at most the watch window of tight 10s polls after a fast run completes.
- const pollInterval =
- anyInProgress || values.awaitingTriggeredReview ? IN_PROGRESS_POLL_INTERVAL_MS : IDLE_POLL_INTERVAL_MS
- cache.disposables.add(() => {
- const pollTimer = window.setInterval(() => actions.loadRecentReviews(), pollInterval)
- return () => clearInterval(pollTimer)
- }, 'reviewsPoll')
+ // Every response decides again whether to poll; re-adding under the same key replaces the timer.
+ loadReviewsSuccess: () => {
+ const anyInProgress = values.reviews?.some((review) => review.in_progress) ?? false
+ // The watch runs its full window: an unrelated running review would satisfy an early-stop check
+ // and could finish before the triggered row appears.
+ if (anyInProgress || values.awaitingTriggeredReview) {
+ cache.disposables.add(() => {
+ const pollTimer = window.setInterval(() => actions.loadReviews(), IN_PROGRESS_POLL_INTERVAL_MS)
+ return () => clearInterval(pollTimer)
+ }, 'reviewsPoll')
+ } else {
+ cache.disposables.dispose('reviewsPoll')
+ }
// A run finishing moves numbers beyond the list: the stats cards aggregate completed
// turns, and an open drawer still shows the report's previous turn. A poll response is
// the only place a completion becomes visible, so fan the refresh out from here.
const previousRuns: Map<string, ReviewRunMarker> | undefined = cache.lastSeenRuns
const currentRuns = new Map<string, ReviewRunMarker>()
- for (const review of values.recentReviews ?? []) {
+ for (const review of values.reviews ?? []) {
currentRuns.set(review.id, { inProgress: review.in_progress, runCount: review.run_count })
}
cache.lastSeenRuns = currentRuns
@@ -1535,19 +1363,19 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
}
}
}
- // No reviews of the user's own PRs: default to the whole project so the block isn't
- // empty — only until the user picks a scope themselves.
+ // No own reviews: default to the whole project, unless the user chose a scope or a filter is set.
if (
- !values.recentReviews?.length &&
+ values.reviewsPage?.count === 0 &&
values.reviewsScope === ReviewHogReviewsListScope.Mine &&
- !values.hasUserChosenReviewsScope
+ !values.hasUserChosenReviewsScope &&
+ !values.reviewsFiltered
) {
actions.applyDefaultReviewsScope(ReviewHogReviewsListScope.Everyone)
}
},
startTriggeredReviewWatch: () => {
// Bounded: a run that dies before creating its report row must not poll forever. The
- // next list load after expiry sees no in-progress rows and disposes the poll itself.
+ // next table load after expiry sees no in-progress rows and disposes the poll itself.
cache.disposables.add(() => {
const expiryTimer = window.setTimeout(
() => actions.stopTriggeredReviewWatch(),
@@ -1562,16 +1390,14 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
setReviewsScope: () => {
// A different scope is a different list; start the finished-run comparison fresh.
cache.lastSeenRuns = undefined
- actions.loadRecentReviews()
+ actions.loadReviews()
actions.loadPerspectiveStats()
},
applyDefaultReviewsScope: () => {
cache.lastSeenRuns = undefined
- actions.loadRecentReviews()
+ actions.loadReviews()
actions.loadPerspectiveStats()
},
- showMoreReviews: () => actions.loadRecentReviews(),
- showFewerReviews: () => actions.loadRecentReviews(),
setReviewsPage: () => actions.loadReviews(),
setReviewsRepository: () => actions.loadReviews(),
setReviewsMode: () => actions.loadReviews(),
@@ -1580,12 +1406,11 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
clearReviewsFilters: () => actions.loadReviews(),
loadAll: () => {
actions.loadSettings()
- actions.loadViewerGithubLogin()
actions.loadPerspectives()
actions.loadBlindSpots()
actions.loadValidators()
actions.loadResolutionSkills()
- actions.loadRecentReviews()
+ actions.loadReviews()
actions.loadPerspectiveStats()
actions.loadDeepSkillStats()
},
@@ -1600,14 +1425,6 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
// The global loaders toast already surfaced the error; just reconcile the optimistic state.
actions.loadSettings()
},
- // A background refresh failing is not a page-level failure: the poll retries on its next
- // tick and the prior rows stay on screen. Only a failure with nothing loaded yet (the
- // sections would sit on skeletons with no retry path) raises the error banner.
- loadRecentReviewsFailure: () => {
- if (values.recentReviewsPage === null) {
- actions.markInitialLoadFailed()
- }
- },
loadPerspectiveStatsFailure: () => {
if (values.perspectiveStats === null) {
actions.markInitialLoadFailed()
@@ -1768,10 +1585,10 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
if (response.status === 'already_reviewed') {
// No run started — the PR's current commit already has a published review.
lemonToast.info(
- 'This pull request was already reviewed at its current commit. Find it under recent reviews.'
+ 'This pull request was already reviewed at its current commit. Find it under Reviews.'
)
} else if (response.status === 'joined_running_review') {
- lemonToast.info('Your request joined the review queue. Find it under recent reviews.')
+ lemonToast.info('Your request joined the review queue. Find it under Reviews.')
} else if (runMode === ReviewTriggerRequestRunModeEnumApi.ResolveOnly) {
// Resolve-only runs don't create the report activity the review watch polls for,
// so a toast is the feedback: progress shows up on the pull request itself.
@@ -1779,12 +1596,12 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
'Resolving comments on the pull request. Replies and fixes will land there as threads settle.'
)
} else {
- lemonToast.success('Review started. It will appear under recent reviews as it runs.')
+ lemonToast.success('Review started. It will appear under Reviews as it runs.')
// The review's report row is created seconds later by the workflow's fetch step,
// so one immediate reload usually misses it — arm the watch before reloading.
actions.startTriggeredReviewWatch()
}
- actions.loadRecentReviews()
+ actions.loadReviews()
} catch (error: any) {
// The trigger endpoint's rejections come back as `{error: "..."}` bodies.
lemonToast.error(error?.data?.error || error?.detail || error?.message || 'Failed to start the review')
@@ -1945,7 +1762,7 @@ export const reviewHogSettingsLogic = kea<reviewHogSettingsLogicType>([
() => {
const onVisibilityChange = (): void => {
if (!document.hidden) {
- actions.loadRecentReviews()
+ actions.loadReviews()
}
}
document.addEventListener('visibilitychange', onVisibilityChange)