fix: untrack new comments only on actual unmount or interaction#2930
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ee781e6. Configure here.
|
bot review claims to have found a regression: This looks like a regression from the new If the user dismisses the outline before that RAF runs, the pending insert can still add the comment back after it was untracked, and unmount cleanup may skip it because Suggested patch: make |
|
We don't even need the RAF for tracking new comments, I remember implementing it just to Fixed! Thank you!! |

Description
Fixes #2927
New comment outlining and tracking happens within a
useEffectthat depends onlastCommentAtandmeCommentsViewedAtof therootitem.Live comments would inject a new comment updating the very same fields the effect depends on, triggering the effect cleanup that untracks new comments. The same class of changes were likely happening with any other cache mod to
root, like a zap.Screenshots
dedicated-navigator-cleanup-before-after.mov
Additional Context
This didn't happen in React 18/Apollo Client 3. A theory can be that React 19 has different render scheduling/transitions.
Zap -> navigator clear cannot be reproduced in dev for some reason. Tracing
untrackNewCommentin Chrome DevTools showed that theuseEffectcleanup, that untracks new comments, runs also after a zap or live comment.Checklist
Are your changes backward compatible? Please answer below:
yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
5, could only verify the live comments bug, but it's in the same class/behavior of the zap->untrack bug.
Did you use AI for this? If so, how much did it assist you?
no
Note
Medium Risk
Adjusts React effect timing around new-comment tracking/untracking; mistakes could cause missed outlines, incorrect counts, or sticky navigator state on item pages.
Overview
Fixes premature removal of “new comment” tracking/outline by tracking each comment at most once and only untracking on real unmount.
Commentnow keeps adidTrackRefflag to avoid re-registering on re-renders/cache updates and moves theuntrackNewCommentcall into an unmount-only cleanup.use-comments-navigatormakestrackNewCommentsynchronous and returns whether insertion occurred, enabling immediate, reliable untracking on user interaction.Reviewed by Cursor Bugbot for commit 429d08b. Bugbot is set up for automated code reviews on this repo. Configure here.