.NET: Reduce re-rendering in harness console#5953
Merged
westey-m merged 4 commits intoMay 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR aims to reduce unnecessary console UI re-rendering in the Harness by moving from reference-based comparisons to value-based comparisons and by shifting layout fields (X/Y/Width/Height) into component props.
Changes:
- Moved layout (X, Y, Width, Height) from
ConsoleReactiveComponentontoConsoleReactivePropsand updated components to read layout fromprops. - Changed render short-circuiting to use
.Equals(...)instead ofReferenceEquals(...)for props/state. - Updated Harness layout math/padding and refactored child layout assignment to be props-based.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/samples/02-agents/Harness/Harness_Shared_Console/HarnessAppComponent.cs | Updates child layout assignment to use props and adjusts bottom padding/layout calculations. |
| dotnet/samples/02-agents/Harness/Harness_Shared_Console/Components/AgentStatus.cs | Switches positioning from component fields to props.Y. |
| dotnet/samples/02-agents/Harness/Harness_Shared_Console/Components/AgentModeAndHelp.cs | Uses props-based positioning and clears padded lines to match new height behavior. |
| dotnet/samples/02-agents/Harness/ConsoleReactiveFramework/ConsoleReactiveComponent.cs | Introduces BaseProps, moves layout to ConsoleReactiveProps, and changes re-render gating to value equality. |
| dotnet/samples/02-agents/Harness/ConsoleReactiveComponents/TopBottomRule.cs | Removes duplicated Width prop and updates child positioning via BaseProps. |
| dotnet/samples/02-agents/Harness/ConsoleReactiveComponents/TextScrollPanel.cs | Uses props for cursor movement/layout. |
| dotnet/samples/02-agents/Harness/ConsoleReactiveComponents/TextPanel.cs | Uses props for erasing/rendering and updates doc reference to props height. |
| dotnet/samples/02-agents/Harness/ConsoleReactiveComponents/TextInput.cs | Uses props for layout and text width. |
| dotnet/samples/02-agents/Harness/ConsoleReactiveComponents/ListSelection.cs | Uses props for layout when rendering title/options. |
Comments suppressed due to low confidence (2)
dotnet/samples/02-agents/Harness/Harness_Shared_Console/HarnessAppComponent.cs:1
- With the new value-based render gating,
scrollItemsis recreated every render (ToList()/[]). Since list equality is reference-based, this will causeTextScrollPanelPropsto compare as 'changed' even when the items are identical, undermining the goal of reducing re-renders. Prefer passing a stable list instance when content is unchanged (e.g., reuse an existing list/array from state) or switchItemsto an immutable/structurally comparable type (or implement structural equality for this props type).
// Copyright (c) Microsoft. All rights reserved.
dotnet/samples/02-agents/Harness/ConsoleReactiveComponents/TopBottomRule.cs:1
CalculateHeighttolerateschild.BaseProps == nullby treating height as 0, butRenderCorewill crash if any child has nullBasePropsdue to the null-forgiving operator (child.BaseProps! with ...). Either enforce non-null child props (e.g., validate and throw a clear exception before rendering) or define/assign default props for children so layout can always be applied safely.
// Copyright (c) Microsoft. All rights reserved.
SergeyMenshykh
approved these changes
May 19, 2026
peibekwe
approved these changes
May 19, 2026
SergeyMenshykh
approved these changes
May 19, 2026
SergeyMenshykh
approved these changes
May 19, 2026
This was referenced Jun 4, 2026
Open
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.
Motivation and Context
We are using object comparison to decide whether to re-render, but this means unnecessary re-renders, so switching to value based comparison.
Description
Contribution Checklist