Skip to content

fix(discussions): find closest discussion comment or reply by timestamp #2135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 17, 2025

Conversation

setchy
Copy link
Member

@setchy setchy commented Aug 13, 2025

Problem
Earlier today I noticed several discussion notifications which were showing an incorrect actor profile image, and upon notification interaction deep-linking to the wrong discussion item (latest comment instead of most recent reply on an older comment thread).

Solution
Updating our logic to find the latest discussion comment or reply to instead find the closest/nearest in timestamp.

In order to increase the accuracy, we have to fetch a wider selection of comments or replies before filtering down

Signed-off-by: Adam Setch <adam.setch@outlook.com>
@github-actions github-actions bot added the bug Something isn't working label Aug 13, 2025
@setchy
Copy link
Member Author

setchy commented Aug 13, 2025

still need to update unit tests, but raising a draft pr for feedback from @afonsojramos @bmulholland

@setchy setchy requested a review from Copilot August 16, 2025 11:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where discussion notifications were showing incorrect actor profile images and deep-linking to the wrong discussion item. The fix changes the logic from finding the latest discussion comment/reply to finding the closest one by timestamp to the notification's updated_at time.

  • Replaced simple "latest" selection logic with timestamp-based proximity matching
  • Increased the number of fetched comments and replies from 1 to 100 for better accuracy
  • Updated function names and signatures to reflect the new closest-match behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/renderer/utils/subject.ts Implements new closest-match algorithm using date-fns for timestamp comparison
src/renderer/utils/helpers.ts Updates function call to use new closest-match logic
src/renderer/utils/api/client.ts Increases fetched comment/reply limit from 1 to 100 for better matching accuracy

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

lastComments: 1,
lastReplies: 1,
lastComments: 100,
lastReplies: 100,
Copy link
Preview

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

Increasing from 1 to 100 comments significantly increases the API response size and processing time. Consider using a smaller number like 10-20 initially, or make this configurable based on the actual need.

Suggested change
lastReplies: 100,
lastComments: options?.lastComments ?? 20,
lastReplies: options?.lastReplies ?? 20,

Copilot uses AI. Check for mistakes.

lastComments: 1,
lastReplies: 1,
lastComments: 100,
lastReplies: 100,
Copy link
Preview

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

Increasing from 1 to 100 replies significantly increases the API response size and processing time. Consider using a smaller number like 10-20 initially, or make this configurable based on the actual need.

Suggested change
lastReplies: 100,
lastReplies,

Copilot uses AI. Check for mistakes.

setchy added 3 commits August 17, 2025 10:33
Signed-off-by: Adam Setch <adam.setch@outlook.com>
…s-nearest

Signed-off-by: Adam Setch <adam.setch@outlook.com>
…s-nearest

Signed-off-by: Adam Setch <adam.setch@outlook.com>
Copy link

@setchy setchy marked this pull request as ready for review August 17, 2025 18:41
@setchy setchy merged commit 3da45b9 into main Aug 17, 2025
16 checks passed
@setchy setchy deleted the fix/discussion-replies-nearest branch August 17, 2025 18:41
@github-actions github-actions bot added this to the Release 6.6.0 milestone Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant