[APIView] Fix excess whitespace in Copilot-generated comments (#15421)#15528
Open
[APIView] Fix excess whitespace in Copilot-generated comments (#15421)#15528
Conversation
…ments The conversion from AVC results to APIView CommentItemModel emitted three CRLFs (two blank lines) between the comment body and the Suggestion / Guidelines sections, and an extra blank line between each guideline link. In rendered markdown that produced large gaps inside the comment card. Use a single blank line as a paragraph separator and render guideline links as a markdown bullet list so they render compactly without blank lines between items.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines how APIView Copilot job results are converted into persisted CommentItemModel.CommentText markdown, reducing excess blank lines and rendering guideline links more compactly in the UI.
Changes:
- Removed extra paragraph separators when composing Copilot-generated comment text.
- Rendered guideline links as a Markdown bullet list to avoid blank lines between consecutive links.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
tjprescott
reviewed
May 6, 2026
Member
tjprescott
left a comment
There was a problem hiding this comment.
Please provide a screenshot of a new comment with multiple guidelines cited so we can see what it looks like.
PR #15251 set .rendered-comment-content to white-space: pre-line so user-typed single newlines inside a paragraph would be preserved. Side effect: newlines between block elements (e.g. </p>\n<p>, </p>\n<ul>) emitted by the markdown renderer are also significant under pre-line and render as visible blank lines, which is the bulk of the extra whitespace seen on Copilot-generated comments (#15421). Reset the container to white-space: normal and scope pre-line to inline-content blocks (p, li, td, th, blockquote). This collapses inter-block whitespace while still preserving user-typed line breaks inside paragraphs and list items.
Plain markdown blank lines between blocks now collapse under the new SCSS rules. Insert a raw <br/> so a visible gap is preserved between the body/suggestion and the Guidelines list, while the rest of the card stays compact.
A single <br/> only produces one line height. Replacing it with a paragraph gives a real empty <p> </p> with its own height and margin, producing a clearly visible gap before the Guidelines section.
| if (commentModel.GuidelineIds.Count > 0) | ||
| { | ||
| commentText.AppendLine(); | ||
| commentText.AppendLine(" "); |
Member
There was a problem hiding this comment.
do you need in here?? is AppendLine not enough?
I think commentText.AppendLine("<br>"); is a better alternative if AppenLind is not enough
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15421
Symptom
Copilot-generated APIView comment cards render with two blank lines between the body and the Guidelines heading and a blank line between every guideline link, making cards unnecessarily tall and sparse.
Root cause (two contributing issues)
1. Persisted markdown had extra paragraph separators
CopilotJobProcessorbuilt the persistedCommentItemModel.CommentTextmarkdown with three consecutiveAppendLinecalls between sections and an extraAppendLine()before each guideline URL:2. SPA CSS was promoting inter-block newlines into visible blank lines
PR #15251 set
.rendered-comment-content { white-space: pre-line; }on the whole comment body so user-typed single newlines inside a paragraph would be preserved. The unintended side effect: the markdown renderer emits literal\nbetween block elements (e.g.</p>\n<p>,</p>\n<ul>). Underpre-linethose newlines are significant and render as visible blank lines on top of the normal<p>margin — the bulk of the gap seen in the issue screenshot.Fix
Server-side (CopilotJobProcessor.cs)
AppendLine()) as the paragraph separator before theSuggestionand**Guidelines**sections.- https://…) so consecutive links are rendered compactly with no blank line between items.Client-side (comment-thread.component.scss)
.rendered-comment-contenttowhite-space: normalso newlines between block elements collapse instead of rendering as blank lines.white-space: pre-lineonly to inline-content blocks (p,li,td,th,blockquote) so user-typed single newlines inside a paragraph or list item are still preserved (the original intent of [APIView] Fix comments not retaining line break formatting #15251).After:
