-
Notifications
You must be signed in to change notification settings - Fork 407
Fetch and display readonly inline comments. #1856
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1856 +/- ##
==========================================
- Coverage 91.09% 91.01% -0.09%
==========================================
Files 185 189 +4
Lines 10719 10835 +116
Branches 1575 1592 +17
==========================================
+ Hits 9765 9861 +96
- Misses 954 974 +20
Continue to review full report at Codecov.
|
Co-Authored-By: Vanessa Yuen <[email protected]>
Co-Authored-By: Vanessa Yuen <[email protected]>
Co-Authored-By: Vanessa Yuen <[email protected]>
Co-Authored-By: Tilde Ann Thurium <[email protected]>
Co-Authored-By: Tilde Ann Thurium <[email protected]>
verify that this works on Windowsgithub/lib/models/patch/multi-file-patch.js Lines 343 to 348 in 3b89168
This comment was generated by todo based on a
|
hopefully this makes the tests easier to understand? IDK. YOLO.
we don't actually sort the comments by date. They come in in order and then we reverse them for some reason.
| this.handleComments(); | ||
| } | ||
|
|
||
| handleComments = error => { |
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.
hmm so actually, we are logging errors and stopping fetching if the errors exist, collecting the comments, and then attempting to load more comments. So logErrors doesn't cover it all either. Not sure what a better name would be but surely we can come up with something. 🤔 anyone have suggestions?
| } | ||
| } | ||
|
|
||
| handleError = error => { |
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.
same as other comment above re: need a better name for this method.
| state[comment.id] = [comment]; | ||
| } else { | ||
| // TODO: look at this more closely... | ||
| // When comment being replied to is outdated...?? Not 100% sure... |
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.
I tried replying to an outdated comment, and it did not show up in the pull request view. So yeah, I have no idea how we'd get into this state.
@kuychaco are there other ways you'd suggest we investigate this? I'm not sure what else to do.
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.
Maybe when replying to a deleted or hidden comment?
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.
okay, so I tried:
- replying to a deleted comment
- replying to a resolved comment
- replying to a hidden comment
None of these triggered that condition for line 132. However, I did notice we are not respecting hidden comments. That seems like a ship blocker to me since we should not be showing users comments that have been marked as abusive or spammy.
smashwilson
left a comment
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.
The only blocker I see is an unresolved TODO from and for myself 😅 I'll give that a shot tonight when I'm on the Windows box and dismiss this, then we should be clear to 🚢. Nice work everyone!
| commitCursor: null, | ||
| reviewCount: PAGE_SIZE, | ||
| reviewCursor: null, | ||
| commentCount: PAGE_SIZE, |
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.
Do we know how this effects our rate-limit overhead? The way that GraphQL queries are rate-limited is a bit unexpected:
Individual calls cannot request more than 500,000 total nodes.
I would guess that we could drop the review and review comment page sizes to drop our computed node total without impacting the vast majority of review scenarios.
Maybe @telliott27 has some idea of the distribution of number of reviews and number of comments within a review and could help us find a lower limit that would still capture ~70% or ~80% of requests in a single page... ?
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.
I pulled some distribution stats for number of reviews and number of review comments here: https://ghe.io/telliott27/reports/tree/master/Notebooks/PR%20Review%20Comments#pr-reviews-and-comments-percentiles
The TL;DR is that it is rare for a PR to have more than 10 reviews, and for reviews to have more than 10 comments.
| } | ||
|
|
||
| componentDidMount() { | ||
| this.handleComments(); |
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.
I see that we're only calling this from componentDidMount(). Is there any case in which we would want to re-collect comments again because props changed? We could make this a React.PureComponent and implement a componentDidUpdate() method as well.
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.
we are also calling this method in _loadMoreComments - it's the callback that gets passed to relay.loadMore. We do want to keep calling handleComments each time we receive new props, because the parent component needs to know when all the comments have been received, so it can group them by replyTo.id. Does the suggestion of making this a pure component still make sense under those conditions?
| this.handleComments(); | ||
| } | ||
|
|
||
| handleComments = error => { |
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.
How about accumulateComments or acceptComments?
| undoLastDiscard: PropTypes.func, | ||
| surface: PropTypes.func, | ||
|
|
||
| switchToIssueish: PropTypes.func, |
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.
Ah, we need this to support hyperlinks in rendered review comment bodies. 👌
| state[comment.id] = [comment]; | ||
| } else { | ||
| // TODO: look at this more closely... | ||
| // When comment being replied to is outdated...?? Not 100% sure... |
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.
Maybe when replying to a deleted or hidden comment?
lib/models/patch/multi-file-patch.js
Outdated
| } | ||
|
|
||
| getBufferRowForDiffPosition = (fileName, diffRow) => { | ||
| // TODO verify that this works on Windows |
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.
🚨 Oh right, I still need to do this. I think dotcom always gives us fileName with / separators, but we normalize them to \ before display.
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.
Spoiler alert: they were not handled correctly. It was the worst of both worlds: we were showing dotcom diffs with / separators, but also throwing an exception here when trying to load comments.
I've fixed the path normalization so that the "Files" tab will (a) display paths with native path separators and (b) correctly compute comment offsets with the normalized paths.
| const nativePath = toNativePathSep(rootComment.path); | ||
| const row = this.props.getBufferRowForDiffPosition(nativePath, rootComment.position); | ||
| const point = new Point(row, 0); | ||
| const range = new Range(point, point); |
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.
We could probably extract a helper for "make a one-point Range at position 0 of this row". 🤔
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.
Hmm, this is the only place we're doing that though. So not sure we need a helper.
lib/views/pr-review-comments-view.js
Outdated
| <img className="github-PrComment-avatar" src={author ? author.avatarUrl : ''} alt={login} /> | ||
| {login} commented{' '} | ||
| <a className="github-PrComment-timeAgo" href={this.props.comment.url}> | ||
| <Timeago time={this.props.comment.createdAt} /> |
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.
👍 for code re-use 😄
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.
yeah! I did not realize Timeago existed until this pull request. We should probably be using Timeago in the PullRequestCommitView and a few other places where we're rolling our own humanizing timestamp.
| wrapper.instance()._attemptToLoadMoreComments(); | ||
| assert.strictEqual(relayLoadMoreStub.callCount, 0); | ||
|
|
||
| clock.tick(PAGINATION_WAIT_TIME_MS); |
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.
Oh god setTimeout tests 🙈
| hasPreviousPage: o.reviewStartCursor !== 0, | ||
| }, | ||
| totalCount: o.reviewItemTotal, | ||
| }; |
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.
Note that we do have review and review comment builders for these 😄
it's cleaner, and the tests were stalling when run all together (the individual tests worked fine)
Co-Authored-By: Ash Wilson <[email protected]>
you can mark comments as spammy, or even abusive, so I'm really glad we caught this before shipping.
|
the last build never reported its status properly but it was green on azure pipelines I promise! |

Description of the Change
Another step in our quest to march ever onwards towards code review in the editor.
This pull request adds readonly comments to pull request pane, that are displayed inline with the diff.
See design here: https://github.com/atom/github/blob/master/docs/feature-requests/003-pull-request-review.md
TODO
implementation tracking project
Alternate Designs
Benefits
Possible Drawbacks
Applicable Issues
N/A
Metrics
Test Plan
Release Notes
The GitHub package now shows readonly inline comments in the pull request view.
User Experience Research (Optional)
We have a user experience research script for the GitHub pane and the pull request view, that will help us understand how the information we're displaying is or is not useful to our users. We intend to resume user research in January, after the holidays.