Skip to content

fix: inconsistent loading of discussion thread response - #36

Open
naincy128 wants to merge 1 commit into
masterfrom
LP-529
Open

naincy128 wants to merge 1 commit into
masterfrom
LP-529

Conversation

@naincy128

@naincy128 naincy128 commented Jun 17, 2026 •

Copy link
Copy Markdown

Description

Fixes an issue where inline replies within discussion threads could load inconsistently, causing some replies to appear or disappear between page refreshes.

Root Cause

Response comments were not being retrieved using backend-level pagination. Combined with frontend request race conditions and stale state handling, this could result in inconsistent loading of inline replies, especially in threads with many responses.

As a result, users could see different combinations of replies on successive page refreshes, even though the underlying discussion data was unchanged.

Changes

Backend (edx-platform)

  • Updated response comment retrieval to use forum backend pagination APIs (get_comments and get_comments_count).
  • Moved response-comment pagination to the forum backend for more reliable and efficient loading.
  • Removed unused code related to the previous pagination approach.

Frontend (frontend-app-discussions)

  • Added request cancellation using AbortController to prevent stale requests from overwriting newer data.
  • Cleared stale child-comment state when reloading response comments.

Linked PR

edx-platform

Ticket

LP-529

@naincy128 naincy128 changed the title Fix inconsistent loading of discussion thread response fix: inconsistent loading of discussion thread response Jun 17, 2026
@naincy128
naincy128 marked this pull request as ready for review June 22, 2026 06:14
Copilot AI review requested due to automatic review settings June 23, 2026 10:45

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@santhosh-apphelix-2u santhosh-apphelix-2u 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.

This is a good improvement. Updating the backend to fetch child replies directly using the parent response ID is the right approach. It avoids loading the complete thread and searching through all responses for every child-reply request, so it should reduce processing time and backend load.

However, the frontend still makes one separate API call for every response that has replies. For example, if 10 responses have child replies, the page can still make 10 requests at almost the same time.

To avoid this, please update the same PR to support a limited batch request:

  • Collect the IDs of the visible responses that have child replies.
  • Send those parent response IDs together in one API request.
  • Fetch replies for all those parent IDs.
  • Return the replies grouped by parent ID.
  • Keep pagination information separately for each parent response.
  • Update the frontend to place each group of replies under the correct response.

This will keep your current parent-ID optimization while also reducing multiple frontend API calls. Since both changes are related to the same reply-loading issue, it would be better to complete them together in this PR rather than creating multiple follow-up changes.

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.

3 participants