Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Summary

This PR adds a new collapsePreexisting option to the githubPullRequests.commentExpandState setting that addresses the issue where newly created comments immediately collapse when using the collapseAll setting.

Users can now select collapsePreexisting to collapse all pre-existing comments while keeping newly added comments expanded, allowing them to review what was just added.

Changes Made

  1. Added new setting option: Added collapsePreexisting as a third option to githubPullRequests.commentExpandState setting in package.json and package.nls.json

  2. Updated comment collapse logic: Modified getCommentCollapsibleState() in src/github/utils.ts to:

    • Add constant for the new setting value
    • Check if the setting is collapsePreexisting and if the comment was newly added
    • Keep newly added comments expanded when this setting is active
  3. Enhanced threading functions: Updated updateThreadWithRange() and updateThread() to accept an isNewlyAdded parameter to detect when a comment thread is being added

  4. Updated controllers: Modified both pullRequestCommentController.ts and reviewCommentController.ts to:

    • Pass isNewlyAdded: true when updating newly added threads
    • Intentionally omit the flag for changed/refreshed threads (so the "newly added" logic only applies once)

How It Works

When a user selects the collapsePreexisting option:

  • Pre-existing comments from all users will collapse
  • Newly added comments (from any user) remain expanded
  • This allows users to review newly added comments before they collapse
  • Once the page is refreshed or the thread is updated, the comment will collapse following normal rules

Files Modified

  • package.json - Added new enum value collapsePreexisting to setting
  • package.nls.json - Added localized description for new setting
  • src/github/utils.ts - Updated logic to use isNewlyAdded flag
  • src/view/pullRequestCommentController.ts - Pass isNewlyAdded: true for newly added threads
  • src/view/reviewCommentController.ts - Pass isNewlyAdded: true for newly added threads

Testing

  • ✅ TypeScript compilation passes
  • ✅ Hygiene and lint checks pass
  • ✅ Logic follows existing patterns in the codebase
  • ✅ Detection works for any newly added comment regardless of author
Original prompt

This section details on the original issue you should resolve

<issue_title>Please do not automatically collapse the comment I just created when using collapseAll</issue_title>
<issue_description>This is a feature request to change the behaviour of the collapseAll mode so that comments you just created do not automatically collapse.

I my opinion, collapseAll should only apply to pre-existing comments. When I post a comment I find it quite annoying that it immediately disappears, as often I want to re-read what I wrote to check the markdown rendered properly and I didn't make any mistakes or was not as clear as I could be.

Perhaps there could be a new value for the setting, called collapsePreExisting?

vscode-pr-2.mp4

I have

"githubPullRequests.commentExpandState": "collapseAll",

but would not expect a comment I just made to automatically collapse

Originally posted by @MetRonnie in #3345. The current behaviour is considered correct according to #3345 (comment)


</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Actually, add a new options to githubPullRequests.commentExpandState for collapsePreexisting and use that value instead.

Copy link
Contributor Author

Copilot AI commented Dec 16, 2025

@copilot Actually, add a new options to githubPullRequests.commentExpandState for collapsePreexisting and use that value instead.

Done! I've added a new collapsePreexisting option to the githubPullRequests.commentExpandState setting. When this option is selected, newly created comments from the current user will remain expanded while all pre-existing comments collapse. Commit: 2392dfe

Copilot AI changed the title [WIP] Update collapseAll behavior for newly created comments Add collapsePreexisting setting to keep newly created comments expanded Dec 16, 2025
Copilot AI requested a review from alexr00 December 16, 2025 09:45
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot don't base it off of the current user, just base it off of a comment being added.

Copy link
Contributor Author

Copilot AI commented Dec 16, 2025

@copilot don't base it off of the current user, just base it off of a comment being added.

Updated! The logic now detects any newly added comment (regardless of author) and keeps it expanded when collapsePreexisting is selected. The implementation uses an isNewlyAdded boolean flag instead of checking the current user. Commit: 5bae2ea

Copilot AI changed the title Add collapsePreexisting setting to keep newly created comments expanded Add collapsePreexisting setting to keep newly added comments expanded Dec 16, 2025
Copilot AI requested a review from alexr00 December 16, 2025 11:04
@alexr00 alexr00 marked this pull request as ready for review December 16, 2025 11:56
@alexr00 alexr00 enabled auto-merge (squash) December 16, 2025 11:56
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 16, 2025
@alexr00 alexr00 merged commit b2fc320 into main Dec 16, 2025
6 checks passed
@alexr00 alexr00 deleted the copilot/change-collapse-behavior branch December 16, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please do not automatically collapse the comment I just created when using collapseAll

3 participants