-
Notifications
You must be signed in to change notification settings - Fork 275
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Adam Setch <[email protected]>
still need to update unit tests, but raising a draft pr for feedback from @afonsojramos @bmulholland |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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.
lastReplies: 100, | |
lastComments: options?.lastComments ?? 20, | |
lastReplies: options?.lastReplies ?? 20, |
Copilot uses AI. Check for mistakes.
lastComments: 1, | ||
lastReplies: 1, | ||
lastComments: 100, | ||
lastReplies: 100, |
There was a problem hiding this comment.
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.
lastReplies: 100, | |
lastReplies, |
Copilot uses AI. Check for mistakes.
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