Skip to content

Make inbox sidebar badge follow active filters#2751

Open
andrewm4894 wants to merge 1 commit into
mainfrom
posthog-code/inbox-badge-follows-filters
Open

Make inbox sidebar badge follow active filters#2751
andrewm4894 wants to merge 1 commit into
mainfrom
posthog-code/inbox-badge-follows-filters

Conversation

@andrewm4894

Copy link
Copy Markdown
Member

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. Dropping ignoreFilters makes 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).
  • Verified no existing tests assert the old sidebar-badge behavior.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from a Slack thread

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
@andrewm4894 andrewm4894 self-assigned this Jun 18, 2026
@andrewm4894 andrewm4894 marked this pull request as ready for review June 18, 2026 10:43
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit c4d8c36.

@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/ui/src/features/sidebar/components/SidebarNavSection.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant