Skip to content

Add With User / No User filter to Peers#590

Open
braginini wants to merge 1 commit intomainfrom
feature/peers-with-users-without
Open

Add With User / No User filter to Peers#590
braginini wants to merge 1 commit intomainfrom
feature/peers-with-users-without

Conversation

@braginini
Copy link
Copy Markdown
Contributor

@braginini braginini commented Mar 20, 2026

Screen.Recording.2026-03-20.at.15.27.36.mov

Summary by CodeRabbit

Release Notes

  • New Features
    • Added filtering capability to view peers by user association status.
    • New "With Users" and "No Users" filter buttons for improved peer visibility and management.
    • Filter selections are preserved when switching between other peer views.

@braginini braginini requested review from heisbrot and mlsmaycon March 20, 2026 14:51
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

A new has_user column filter and corresponding toggle button group ("With Users" / "No Users") were added to the Peers table component. The filter state is preserved when switching between other filter types and participates in existing filter initialization and reset workflows.

Changes

Cohort / File(s) Summary
Peers Table User Association Filtering
src/modules/peers/PeersTable.tsx
Added has_user column (derived from user_id presence), integrated into columnVisibility configuration, extended filter preservation logic across "All/Online/Offline" and "Pending Approvals" filters, introduced conditional "With Users"/"No Users" toggle button group (visible when not in user mode), and updated filter initialization to include has_user state management.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A table grows more clever today,
With users now sorted in a new way,
Toggle them off, toggle them on,
By morning, the peers list is done!
Users or ghosts—the choice is yours,
While filters dance through open doors. 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new filter feature ('With User / No User') to the Peers table, which aligns with the file changes that implement this filtering functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/peers-with-users-without
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/modules/peers/PeersTable.tsx (1)

463-479: ⚠️ Potential issue | 🟠 Major

Missing group_names filter preservation in Pending Approvals handler.

The Pending Approvals button handler preserves has_user but no longer preserves the group_names filter. This is inconsistent with the All/Online/Offline handlers which preserve both filters. Clicking "Pending Approvals" will unexpectedly clear any active group filter.

🐛 Proposed fix to preserve group_names filter
  let hasUserFilter = table
    .getColumn("has_user")
    ?.getFilterValue();
+ let groupFilters = table
+   .getColumn("group_names")
+   ?.getFilterValue();

  table.setColumnFilters([
    {
      id: "connected",
      value: undefined,
    },
    {
      id: "approval_required",
      value: current,
    },
+   {
+     id: "group_names",
+     value: groupFilters ?? [],
+   },
    {
      id: "has_user",
      value: hasUserFilter,
    },
  ]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/peers/PeersTable.tsx` around lines 463 - 479, The Pending
Approvals handler is preserving has_user but not the group_names filter, causing
active group filters to be cleared; capture the current group_names filter
(e.g., const groupNamesFilter =
table.getColumn("group_names")?.getFilterValue()) in the same way hasUserFilter
is captured and include it in the table.setColumnFilters call (add { id:
"group_names", value: groupNamesFilter }) so Pending Approvals preserves the
group filter like the All/Online/Offline handlers.
🧹 Nitpick comments (1)
src/modules/peers/PeersTable.tsx (1)

336-493: Consider extracting filter update logic to reduce duplication.

The All/Online/Offline/Pending Approvals buttons share a common pattern of preserving group_names and has_user filters while modifying connected/approval_required. A helper function could reduce repetition:

const updateFilters = (
  table: Table<Peer>,
  connected: boolean | undefined,
  approvalRequired: boolean | undefined,
) => {
  const groupFilters = table.getColumn("group_names")?.getFilterValue();
  const hasUserFilter = table.getColumn("has_user")?.getFilterValue();
  table.setPageIndex(0);
  table.setColumnFilters([
    { id: "connected", value: connected },
    { id: "approval_required", value: approvalRequired },
    { id: "group_names", value: groupFilters ?? [] },
    { id: "has_user", value: hasUserFilter },
  ]);
  resetSelectedRows();
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/peers/PeersTable.tsx` around lines 336 - 493, The button click
handlers duplicate the same filter-preserving logic; extract a helper (e.g.,
updateFilters) that accepts the Table<Peer> instance and the desired connected
and approval_required values, reads group_names and has_user via
table.getColumn(...).getFilterValue(), calls table.setPageIndex(0), calls
table.setColumnFilters([...]) with the preserved filters and the passed
connected/approval_required, then calls resetSelectedRows(); replace each inline
handler in the All/Online/Offline/Pending Approvals ButtonGroup.Button and
Button to call this helper with the appropriate connected/approval_required
arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/modules/peers/PeersTable.tsx`:
- Around line 463-479: The Pending Approvals handler is preserving has_user but
not the group_names filter, causing active group filters to be cleared; capture
the current group_names filter (e.g., const groupNamesFilter =
table.getColumn("group_names")?.getFilterValue()) in the same way hasUserFilter
is captured and include it in the table.setColumnFilters call (add { id:
"group_names", value: groupNamesFilter }) so Pending Approvals preserves the
group filter like the All/Online/Offline handlers.

---

Nitpick comments:
In `@src/modules/peers/PeersTable.tsx`:
- Around line 336-493: The button click handlers duplicate the same
filter-preserving logic; extract a helper (e.g., updateFilters) that accepts the
Table<Peer> instance and the desired connected and approval_required values,
reads group_names and has_user via table.getColumn(...).getFilterValue(), calls
table.setPageIndex(0), calls table.setColumnFilters([...]) with the preserved
filters and the passed connected/approval_required, then calls
resetSelectedRows(); replace each inline handler in the
All/Online/Offline/Pending Approvals ButtonGroup.Button and Button to call this
helper with the appropriate connected/approval_required arguments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 313c8e18-8182-4046-9115-18903db50f23

📥 Commits

Reviewing files that changed from the base of the PR and between aff2365 and 5da13a8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • src/modules/peers/PeersTable.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