fix(inbox): make "Entire project" scope show project-wide reports#2699
Merged
Conversation
The report-list ordering always appended `-is_suggested_reviewer`, floating the current user's reports to the top of every page. Since only the first page (100 reports) is loaded, the "Entire project" scope showed nothing but the user's own reports — identical to "For you". Drop the `-is_suggested_reviewer` ordering tiebreak and instead apply the reviewer scope server-side via the existing `suggested_reviewers` param: "For you" now filters on the current user's uuid, teammate scopes on theirs, and "Entire project" sends nothing so the whole project comes back. Generated-By: PostHog Code Task-Id: 715efc4f-94d6-44a6-a85b-ececa0905c66
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
packages/ui/src/features/inbox/hooks/useInboxAllReports.ts:69-73
**Double-fetch when `currentUser` is loading for "For you" scope**
When `scope === "for-you"` and `currentUser` hasn't resolved yet, `currentUser?.uuid` is `undefined`, so `reviewerUuid` evaluates to `null`. The hook immediately fires a project-wide query (no `suggested_reviewers` param). Once `currentUser` loads, the query key changes and a second, correctly-scoped query fires. The displayed list is still correct thanks to the client-side `matchesReviewerScope` guard, but an extra project-wide fetch is made on every mount — notable here because only the first page (100 reports) is loaded, meaning the initial project-wide result set is larger than needed and is then discarded.
Consider guarding the query with an `enabled` flag: `ignoreScope || scope !== INBOX_SCOPE_FOR_YOU || currentUser?.uuid != null`.
### Issue 2 of 2
packages/core/src/inbox/reportFiltering.test.ts:101-117
The three positive `buildSignalReportListOrdering` tests share the same structure and could be collapsed into a single parameterised test per the team's preference. This also makes it easy to add new field/direction combinations in one place.
```suggestion
it.each([
["total_weight", "desc", "status,-total_weight"],
["created_at", "asc", "status,created_at"],
["signal_count", "desc", "status,-signal_count"],
] as const)(
"orders by status then %s (%s)",
(field, direction, expected) => {
expect(buildSignalReportListOrdering(field, direction)).toBe(expected);
},
);
```
Reviews (1): Last reviewed commit: "fix(inbox): make "Entire project" scope ..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Selecting the Entire project reviewer scope in the inbox still only showed reports where you are the suggested reviewer — identical to For you.
Root cause
buildSignalReportListOrderingalways appended-is_suggested_reviewer, floating the current user's reports to the top of every status group. Because the inbox only loads the first page (REPORTS_PAGE_SIZE = 100, no infinite scroll wired) and projects have thousands of reports, that first page was entirely the user's own reports. Bothfor-youandentire-projectsent nosuggested_reviewersparam, so the only thing distinguishing them was a client-side filter applied on top of an already user-dominated page.Fix
Remove the always-on
-is_suggested_reviewerordering tiebreak and apply the reviewer scope server-side via the existingsuggested_reviewersquery param instead:suggested_reviewers=<current user uuid>(the float was what previously fed this scope, so it now filters explicitly).suggested_reviewers=<teammate uuid>(unchanged).suggested_reviewers, orderedstatus,<field>→ first page is the project-wide top reports.ignoreScope) → unchanged (still project-wide).orderingandsuggested_reviewersare part of the React Query key, so each scope is its own cached query and switching refetches cleanly.Files
packages/core/src/inbox/reportFiltering.ts— drop the-is_suggested_reviewertiebreak.packages/ui/src/features/inbox/hooks/useInboxAllReports.ts— resolve current user; filter For-you server-side by uuid.packages/core/src/inbox/reportFiltering.test.ts— updated ordering expectations + guard.Testing
reportFilteringunit tests pass.Created with PostHog Code