-
-
Notifications
You must be signed in to change notification settings - Fork 132
Enhancements to live comments #2269
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
Enhancements to live comments #2269
Conversation
…new comment; cleanup: resolvers, logs
…omments are there
…bility change, light cleanup
… comment injection
… use of constants, general cleanup
…he correct Item query
…fix leak on useEffect because of missing sort atomic apollo cache manipulations; manage top sort not being present in item query cache queue nested comments without a parent, retry on the next poll fix commit messages
… queue comments via state
… dropped comments; ui: show amount of new comments refactor: correct function positioning; cleanup: useless logs
…Comments readFragment fallback to received comment
…ss dedupe on ShowNewComments, count nested ncomments from fresh new comments
…how the floating button only if we're past the element, not only if it's not visible
…r traces of the injected field
…mit; cleanup: consistent naming
…oads - ncomments count logic shared with injection and counting - don't re-create and persist closures for every injection, rather temporarily on injection - access item hierarchy once, avoid creating new arrays - don't create and mutate payloads, rather know what to return fixes: - fix wrong parameters on traverseNewComments recursion
This is indeed weird, I'm trying to reproduce this but I can't, I'm now directly looking at how I use fragments.
I think I found the cause, for bottomed out status we check
I thought this too, let's see if I can find something actually better |
…ated has pending newComments, fixes CommentEdit consequences
lib/apollo.js
Outdated
nDirectComments: { | ||
merge (existing, incoming, { variables, readField }) { | ||
// if the item has new comments, don't merge the nDirectComments field | ||
// preventing new comments not yet injected from being counted, thus causing bottomedOut | ||
if (variables?.id && readField('newComments')?.length > 0) { | ||
return existing | ||
} | ||
|
||
return incoming | ||
} | ||
}, |
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.
on comment edits, upsertComment
updates the cache with new values, which includes an updated nDirectComments
but not comments, thus causing bottomedOut
(item.comments?.comments.length === 0 && item.nDirectComments > 0
) to trigger
So in the case of a comment with pending newComments
, I think it's ok and harmless to ignore nDirectComments
updates.
Screen.Recording.2025-07-23.at.18.36.17.mp4
edit: pushed a fix for incorrect usage of readField
, it was missing 'from'
where it should read this field... even though it was already reading it ... anyway, my tests shows that this works correctly.
…ctComments apollo merge
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.
Bug: Function Fails When Comments Array Missing
The prepareComments
function incorrectly assumes data.comments.comments
is always an array when data.comments
is present. If data.comments.comments
is undefined
, newComments.concat(data.comments.comments)
will add undefined
as an element to the array. The previous version safely handled this by falling back to an empty array.
components/show-new-comments.js#L55-L59
stacker.news/components/show-new-comments.js
Lines 55 to 59 in d3be789
newComments: [], | |
comments: { | |
...data.comments, | |
comments: newComments.concat(data.comments.comments) | |
} |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Description
Continues #2115 and #791
UI/UX and logic enhancements to the Live Comments system
Media
Blue live comments dot

Show all new comments of a thread
Screen.Recording.2025-07-23.at.12.40.32.mp4
Scroll to new top-level comments
Screen.Recording.2025-07-23.at.12.44.55.mp4
Outline newly injected comments
Screen.Recording.2025-07-23.at.12.46.35.mp4
Additional Context
This PR has been split from its proposed nice-to-have changes
fixes:
item.comments
)COMMENT_DEPTH_LIMIT
optimizations:
prepareComments
Checklist
Are your changes backward compatible? Please answer below:
For example, a change is not backward compatible if you removed a GraphQL field or dropped a database column.
Yes, these are completely new additions, no breakage or changes on the way comments and comment injection works.
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:
7, successful iterative QA for showing all new comments of a thread, floating button visibility and ux/ui enhancements
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
Yes, iterative QA
Did you introduce any new environment variables? If so, call them out explicitly here:
n/a