Skip to content

fix: add cursor-based pagination and fix refresh for feedback records#7935

Merged
pandeymangg merged 3 commits into
epic/v5from
dhruwang/eng-770-refresh-change-feedback-records-pagination
May 7, 2026
Merged

fix: add cursor-based pagination and fix refresh for feedback records#7935
pandeymangg merged 3 commits into
epic/v5from
dhruwang/eng-770-refresh-change-feedback-records-pagination

Conversation

@Dhruwang
Copy link
Copy Markdown
Member

@Dhruwang Dhruwang commented May 5, 2026

Summary

  • Adds cursor-based pagination to the feedback records table using the Hub API's next_cursor response
  • Tracks per-FRD cursors so "Load more" fetches the next page from each feedback directory
  • Refresh now properly resets pagination state and fetches a fresh first page, matching the initial server-side load behavior

Changes

  • page.tsx: Extracts next_cursor from each FRD's Hub response and passes initialCursors to the client
  • feedback-records-page-client.tsx: Passes initialCursors through to the table component
  • feedback-records-table.tsx:
    • Adds cursors state to track per-FRD pagination cursors
    • Adds handleLoadMore that fetches the next page using stored cursors and appends results
    • Refactors fetch logic into a shared fetchRecords helper used by both refresh and load-more
    • Adds a "Load more" button at the bottom of the table when more records are available
    • Refresh resets cursors and fetches fresh first-page data (same behavior as initial load)

Test plan

  • Load the feedback records page — verify initial records display correctly
  • If there are more than 50 records, verify "Load more" button appears
  • Click "Load more" — verify additional records are appended and sorted correctly
  • Click refresh — verify it resets to the first page (50 records) and "Load more" reappears if applicable
  • Create a new record via the drawer — verify the table refreshes to show the first page
  • Verify the table works correctly with multiple feedback directories

Resolves ENG-770

The feedback records table lacked pagination support — it always showed
only the first page with no way to load more. Additionally, refresh
re-fetched from scratch without tracking pagination state.

This adds:
- Per-FRD cursor tracking from the Hub API's next_cursor response
- A "Load more" button when more records are available
- Refresh now properly resets cursors and fetches a fresh first page

Resolves ENG-770
@Dhruwang Dhruwang requested a review from pandeymangg May 5, 2026 10:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Walkthrough

The changes implement cursor-based pagination for the feedback records feature. The server-side page now extracts next_cursor values from feedback record directory results and builds an initialCursors map. This map is passed through the component hierarchy from page.tsx to FeedbackRecordsPageClient to FeedbackRecordsTable. The table component uses these cursors to fetch subsequent pages of records per directory, manages cursor state, and conditionally displays a "Load more" button. The refresh action clears cursors and re-fetches the first page, while the load-more action appends records and updates stored cursors.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main changes: adding cursor-based pagination and fixing refresh behavior for feedback records.
Description check ✅ Passed The PR description covers what the PR does, detailed changes across three files, and a comprehensive test plan; it doesn't include screenshots but includes the issue resolution reference.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown
Contributor

@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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/web/app/`(app)/workspaces/[workspaceId]/unify/feedback-records/components/feedback-records-table.tsx:
- Around line 141-146: The toast error messages are hiding server-action
details; update both failure branches that handle the result from fetchRecords
(the one after const result = await fetchRecords("refresh") and the later branch
that currently calls toast.error(t(...))) to include the server error text by
calling toast.error(getFormattedErrorMessage(result), { id: toastId }) (or
toast.error(getFormattedErrorMessage(result)) if no id is used), ensuring you
import/consume the existing getFormattedErrorMessage helper and preserve the
localized fallback when result has no server message.
- Around line 159-176: handleRefresh and handleLoadMore can run concurrently and
the last finisher overwrites records/cursors; add a single mutual-exclusion
guard to prevent overlapping fetches by introducing and checking a shared lock
(e.g., isFetchingRef or fetchMutex) at the start of both handlers (handleRefresh
and handleLoadMore), bail out if already locked, then set the lock before
calling fetchRecords and clear it in a finally block; ensure you still set the
per-action UI flags (isLoadingMore/isRefreshing) but only update setRecords and
setCursors when the lock is held (or by the winning operation) so pagination
state cannot be clobbered.

In `@apps/web/app/`(app)/workspaces/[workspaceId]/unify/feedback-records/page.tsx:
- Around line 47-54: The bug: initialCursors is built from each FRD's full
first-page next_cursor but the rendered dataset is globally sliced to 50, so
some FRD first-page items may be omitted and later become unreachable. Fix by
computing initialCursors only for FRDs whose first-page items are included in
the initial displayed set (i.e., derive the map from the dataset after the
global slice), or by building the cursor map from the full per-FRD results
before slicing and then tracking which FRDs contributed items to the rendered 50
so you only advance cursors for those FRDs; update the logic around
initialCursors, frds and results (or the pre-slice result variable) to reflect
this consistent approach so load-more uses cursors only for FRDs that actually
contributed to the initial render.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b6fdc781-d14b-41bd-a8b4-7beb61304ab4

📥 Commits

Reviewing files that changed from the base of the PR and between 74dd778 and d302bfb.

📒 Files selected for processing (3)
  • apps/web/app/(app)/workspaces/[workspaceId]/unify/feedback-records/components/feedback-records-page-client.tsx
  • apps/web/app/(app)/workspaces/[workspaceId]/unify/feedback-records/components/feedback-records-table.tsx
  • apps/web/app/(app)/workspaces/[workspaceId]/unify/feedback-records/page.tsx

Comment thread apps/web/app/(app)/workspaces/[workspaceId]/unify/feedback-records/page.tsx Outdated
Dhruwang and others added 2 commits May 5, 2026 16:07
- Restore getFormattedErrorMessage for actionable error toasts
- Add mutual exclusion between refresh and load-more to prevent
  concurrent fetches from clobbering pagination state
- Remove global .slice() from initial load and refresh so no
  first-page FRD records become unreachable via cursors
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

@pandeymangg pandeymangg merged commit 6fb9cf2 into epic/v5 May 7, 2026
12 checks passed
@pandeymangg pandeymangg deleted the dhruwang/eng-770-refresh-change-feedback-records-pagination branch May 7, 2026 06:14
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.

2 participants