diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js index 179758fd2a..392267c79d 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread.js @@ -156,18 +156,21 @@ }, /** - * Sets the initial state of the comment thread to have the last - * {UNRESOLVED_EXPAND_COUNT} comments expanded by default if the - * thread is unresolved. + * Sets the initial state of the comment thread. + * Expands the thread if one of the following is true: + * - last {UNRESOLVED_EXPAND_COUNT} comments expanded by default if the + * thread is unresolved, + * - it's a robot comment. */ _setInitialExpandedState() { - let comment; if (this._orderedComments) { for (let i = 0; i < this._orderedComments.length; i++) { - comment = this._orderedComments[i]; - comment.collapsed = - this._orderedComments.length - i - 1 >= UNRESOLVED_EXPAND_COUNT || - !this._unresolved; + const comment = this._orderedComments[i]; + const isRobotComment = !!comment.robot_id; + // False if it's an unresolved comment under UNRESOLVED_EXPAND_COUNT. + const resolvedThread = !this._unresolved || + this._orderedComments.length - i - 1 >= UNRESOLVED_EXPAND_COUNT; + comment.collapsed = !isRobotComment && resolvedThread; } } }, diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html index 5a5fc0694d..e1ab0a0a1e 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-comment-thread/gr-diff-comment-thread_test.html @@ -510,6 +510,13 @@ limitations under the License. for (let i = 0; i < element.comments.length; i++) { assert.isTrue(element.comments[i].collapsed); } + for (let i = 0; i < element.comments.length; i++) { + element.comments[i].robot_id = 123; + } + element._setInitialExpandedState(); + for (let i = 0; i < element.comments.length; i++) { + assert.isFalse(element.comments[i].collapsed); + } }); });