Prevent TerminalLogger corruption during terminal resize#14370
Open
AlesProkop with Copilot wants to merge 3 commits into
Open
Prevent TerminalLogger corruption during terminal resize#14370AlesProkop with Copilot wants to merge 3 commits into
AlesProkop with Copilot wants to merge 3 commits into
Conversation
Contributor
|
Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
Co-authored-by: AlesProkop <276576870+AlesProkop@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix terminal logger display issue when resizing
Prevent TerminalLogger corruption during terminal resize
Jul 15, 2026
AlesProkop
marked this pull request as ready for review
July 17, 2026 12:25
Contributor
There was a problem hiding this comment.
Pull request overview
Improves TerminalLogger’s live node display rendering stability by making refreshes always consult the current terminal dimensions so a terminal resize triggers the existing erase-and-redraw path immediately, preventing corrupted/wrapped output during active builds.
Changes:
- Simplified the refresher thread loop to call a new
Refresh()method each frame. - Introduced
TerminalLogger.Refresh()to centralize refresh locking and ensure terminal size is checked per refresh. - Added a regression unit test that simulates shrinking the terminal width and asserts the logger emits the erase sequence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Build/Logging/TerminalLogger/TerminalLogger.cs | Refactors refresher loop to refresh each frame via Refresh(), ensuring terminal resize is detected promptly. |
| src/Build.UnitTests/TerminalLogger_Tests.cs | Adds a resizable terminal test double and a regression test for resize-triggered redraw behavior. |
Comment on lines
+1483
to
+1492
| /// <summary> | ||
| /// Refreshes the node display using the current terminal dimensions. | ||
| /// </summary> | ||
| internal void Refresh() | ||
| { | ||
| lock (_lock) | ||
| { | ||
| DisplayNodes(); | ||
| } | ||
| } |
| public void WriteLineFitToWidth(ReadOnlySpan<char> text) => _terminal.WriteLineFitToWidth(text); | ||
| public void WriteColor(TerminalColor color, string text) => _terminal.WriteColor(color, text); | ||
| public void WriteColorLine(TerminalColor color, string text) => _terminal.WriteColorLine(color, text); | ||
| public void Dispose() => _terminal.Dispose(); |
Comment on lines
+924
to
+939
| MockBuildEventSink eventSource = new(0); | ||
| TerminalLogger terminalLogger = new(terminal); | ||
| terminalLogger.Initialize(eventSource, _nodeCount); | ||
| eventSource.InvokeBuildStarted(MakeBuildStartedEventArgs()); | ||
| eventSource.InvokeStatusEventRaised(MakeProjectEvalFinishedArgs(_projectFile)); | ||
| eventSource.InvokeProjectStarted(MakeProjectStartedEventArgs(_projectFile)); | ||
| eventSource.InvokeTargetStarted(MakeTargetStartedEventArgs(_projectFile, "Build")); | ||
| eventSource.InvokeTaskStarted(MakeTaskStartedEventArgs(_projectFile, "Task")); | ||
|
|
||
| terminalLogger.Refresh(); | ||
| output.GetStringBuilder().Clear(); | ||
| terminal.Width = 40; | ||
| terminalLogger.Refresh(); | ||
|
|
||
| output.ToString().ShouldContain($"{AnsiCodes.CSI}{AnsiCodes.EraseInDisplay}"); | ||
| } |
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.
Work item (Internal use):
Summary
Customer Impact
Shrinking a terminal during a build no longer leaves wrapped duration fragments and corrupted status output.
Regression?
No. Unchanged dimensions retain the existing delta-rendering behavior.
Testing
Added regression coverage for shrinking an active terminal from 120 to 40 columns.
Risk
Low. The change adds inexpensive terminal dimension reads to the existing 30 Hz refresh loop.