Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughReplaces infinite-scroll client-side aggregation for witness voters with page-based server-side pagination: the UI uses a page query (including sort/direction), renders returned voters directly with client-side search, drives pagination from totalVoters, and removes "Load more" and client-side per-page slicing. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Dialog as WitnessVotersDialog
participant Query as ReactQuery
participant API as Hafbe API
User->>Dialog: open dialog / change page or sort
Dialog->>Query: useQuery(getWitnessVotersPageQueryOptions(witness,page,pageSize,sort,direction))
Query->>API: GET /witnesses/{witness}/voters?page=&pageSize=&sort=&direction=
API-->>Query: { voters, totalVoters, page }
Query-->>Dialog: data (voters, totalVoters)
Dialog->>Dialog: apply client-side search filter -> visible
Dialog-->>User: render visible voters and pagination controls (driven by totalVoters)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/sdk/src/modules/witnesses/queries/get-witnesses-query-options.ts (1)
125-138: Forward React QuerysignaltocallRESTfor proper request cancellation.Line 127 ignores the cancellation context, so rapid page/sort changes can keep stale requests in flight. Extract the
signalfrom thequeryFncontext and pass it tocallRESTto enable cancellation of in-flight requests.Suggested fix
return queryOptions({ queryKey: QueryKeys.witnesses.voters(witness, page, pageSize, sort, direction), - queryFn: async () => { + queryFn: async ({ signal }) => { return (await callREST( "hafbe", "/witnesses/{witness-name}/voters", { "witness-name": witness, "page-size": pageSize, page, sort, direction, - } + }, + undefined, + undefined, + signal )) as WitnessVotersResponse; },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/sdk/src/modules/witnesses/queries/get-witnesses-query-options.ts` around lines 125 - 138, The queryFn in get-witnesses-query-options.ts does not forward React Query's AbortSignal, so cancelable requests aren't used; update the async queryFn inside queryOptions to accept the context ({ signal }) or destructure signal from its params and pass that signal into callREST (the callREST invocation used to fetch "/witnesses/{witness-name}/voters") so in-flight requests are aborted when queries are cancelled (keep existing QueryKeys.witnesses.voters, page/pageSize/sort/direction usage).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/src/app/witnesses/_components/witness-voters-dialog.tsx`:
- Around line 79-81: The onChange handlers in witness-voters-dialog.tsx only
call setSearchText, which can leave the UI on a later page and show an empty
result; update those handlers (the ones calling setSearchText) to also reset
pagination to page 1 by invoking your pagination setter (e.g., setPage(1) or
setCurrentPage(1)/setPageIndex(1) depending on the existing state variable)
immediately after setSearchText, and make the identical change for the other
onChange instance referenced in the comment.
---
Nitpick comments:
In `@packages/sdk/src/modules/witnesses/queries/get-witnesses-query-options.ts`:
- Around line 125-138: The queryFn in get-witnesses-query-options.ts does not
forward React Query's AbortSignal, so cancelable requests aren't used; update
the async queryFn inside queryOptions to accept the context ({ signal }) or
destructure signal from its params and pass that signal into callREST (the
callREST invocation used to fetch "/witnesses/{witness-name}/voters") so
in-flight requests are aborted when queries are cancelled (keep existing
QueryKeys.witnesses.voters, page/pageSize/sort/direction usage).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f7ae812e-7437-4749-9156-c5346432bc20
⛔ Files ignored due to path filters (7)
packages/sdk/dist/browser/index.d.tsis excluded by!**/dist/**packages/sdk/dist/browser/index.jsis excluded by!**/dist/**packages/sdk/dist/browser/index.js.mapis excluded by!**/dist/**,!**/*.mappackages/sdk/dist/node/index.cjsis excluded by!**/dist/**packages/sdk/dist/node/index.cjs.mapis excluded by!**/dist/**,!**/*.mappackages/sdk/dist/node/index.mjsis excluded by!**/dist/**packages/sdk/dist/node/index.mjs.mapis excluded by!**/dist/**,!**/*.map
📒 Files selected for processing (3)
apps/web/src/app/witnesses/_components/witness-voters-dialog.tsxpackages/sdk/src/modules/core/query-keys.tspackages/sdk/src/modules/witnesses/queries/get-witnesses-query-options.ts
| onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
| setSearchText(e.target.value) | ||
| } |
There was a problem hiding this comment.
Reset to page 1 when search text changes.
With page-scoped data, searching on a later page can show a false empty state. Reset page on input change to reduce that mismatch.
Suggested fix
- onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
- setSearchText(e.target.value)
- }
+ onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
+ setSearchText(e.target.value);
+ setPage(1);
+ }}Also applies to: 87-88
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/app/witnesses/_components/witness-voters-dialog.tsx` around
lines 79 - 81, The onChange handlers in witness-voters-dialog.tsx only call
setSearchText, which can leave the UI on a later page and show an empty result;
update those handlers (the ones calling setSearchText) to also reset pagination
to page 1 by invoking your pagination setter (e.g., setPage(1) or
setCurrentPage(1)/setPageIndex(1) depending on the existing state variable)
immediately after setSearchText, and make the identical change for the other
onChange instance referenced in the comment.
Summary by CodeRabbit
New Features
Improvements
Style