Make inbox sidebar badge follow active filters#2751
Conversation
The left sidebar inbox badge called useInboxAllReports({ ignoreFilters: true }),
so it always showed the total pull-request count regardless of the source
(e.g. Scouts), priority, or search filters the user applied in the inbox. That
left the badge contradicting the count next to the Pull requests tab, which is
confusing.
Drop ignoreFilters so the badge tracks the same filtered count the Pull
requests tab shows. Scope (For you / Entire project) already followed the user's
choice and still does.
Generated-By: PostHog Code
Task-Id: 8109cd32-837e-42f2-929e-b762c683b86e
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/ui/src/features/sidebar/components/SidebarNavSection.tsx:89
**Superfluous store subscriptions after removing `ignoreFilters`**
Without `ignoreFilters: true`, the hook now subscribes to `searchQuery`, `sortField`, and `sortDirection` from the filter store, but neither of these affects `counts.pulls` (the only field the sidebar uses). `pullRequestCountQuery` — the source of `counts.pulls` — only uses `source_product`, `priority`, and `suggested_reviewers`. The result is that every search keystroke and every sort-order change re-renders `SidebarNavSection` and re-runs the `scopedReports` memo (including `filterReportsBySearch`), without the badge value ever changing. It won't cause a visible bug but is extra work on a component that's always mounted. Consider adding a `pullRequestsOnly` path (or a narrower `ignoreSearchAndSort` flag) to prevent these subscriptions for the sidebar context.
Reviews (1): Last reviewed commit: "Make inbox sidebar badge follow active f..." | Re-trigger Greptile |
| // tracks the inbox's active source/priority/search filters (and the user's | ||
| // For-you / project scope) so it never shows a total that contradicts the | ||
| // filtered list the user is looking at. | ||
| const { counts: inboxCounts } = useInboxAllReports(); |
There was a problem hiding this comment.
Superfluous store subscriptions after removing
ignoreFilters
Without ignoreFilters: true, the hook now subscribes to searchQuery, sortField, and sortDirection from the filter store, but neither of these affects counts.pulls (the only field the sidebar uses). pullRequestCountQuery — the source of counts.pulls — only uses source_product, priority, and suggested_reviewers. The result is that every search keystroke and every sort-order change re-renders SidebarNavSection and re-runs the scopedReports memo (including filterReportsBySearch), without the badge value ever changing. It won't cause a visible bug but is extra work on a component that's always mounted. Consider adding a pullRequestsOnly path (or a narrower ignoreSearchAndSort flag) to prevent these subscriptions for the sidebar context.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/sidebar/components/SidebarNavSection.tsx
Line: 89
Comment:
**Superfluous store subscriptions after removing `ignoreFilters`**
Without `ignoreFilters: true`, the hook now subscribes to `searchQuery`, `sortField`, and `sortDirection` from the filter store, but neither of these affects `counts.pulls` (the only field the sidebar uses). `pullRequestCountQuery` — the source of `counts.pulls` — only uses `source_product`, `priority`, and `suggested_reviewers`. The result is that every search keystroke and every sort-order change re-renders `SidebarNavSection` and re-runs the `scopedReports` memo (including `filterReportsBySearch`), without the badge value ever changing. It won't cause a visible bug but is extra work on a component that's always mounted. Consider adding a `pullRequestsOnly` path (or a narrower `ignoreSearchAndSort` flag) to prevent these subscriptions for the sidebar context.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4d8c36502
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Problem
When a user filters the inbox by a specific source (e.g. Scouts), priority, or search, the inbox count badge on the left sidebar did not update — it kept showing the total pull-request count across all sources. That left the sidebar badge contradicting the count shown next to the Pull requests tab inside the inbox, which is confusing.
Changes
The sidebar called
useInboxAllReports({ ignoreFilters: true }), which hard-pinned the source/priority/search filters to empty. DroppingignoreFiltersmakes the badge track the same filtered count the Pull requests tab shows, so the two always agree. Reviewer scope (For you / Entire project) already followed the user's choice and is unchanged.How did you test this?
pnpm --filter @posthog/ui typecheck— no type errors in the changed files (remaining errors are pre-existing unbuilt-dependency module-resolution issues unrelated to this change).Automatic notifications
Created with PostHog Code from a Slack thread