Skip to content

.NET: Reduce re-rendering in harness console#5953

Merged
westey-m merged 4 commits into
microsoft:mainfrom
westey-m:harness-console-reduce-rerender
May 19, 2026
Merged

.NET: Reduce re-rendering in harness console#5953
westey-m merged 4 commits into
microsoft:mainfrom
westey-m:harness-console-reduce-rerender

Conversation

@westey-m
Copy link
Copy Markdown
Contributor

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

  • Added positional properties to properties base class
  • Only re-render if props or status values actually changed, rather than object comparison

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings May 19, 2026 14:28
@moonbox3 moonbox3 added the .NET label May 19, 2026
@github-actions github-actions Bot changed the title Reduce re-rendering in harness console .NET: Reduce re-rendering in harness console May 19, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 93% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by westey-m's agents

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ConsoleReactiveComponent onto ConsoleReactiveProps and updated components to read layout from props.
  • Changed render short-circuiting to use .Equals(...) instead of ReferenceEquals(...) 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, scrollItems is recreated every render (ToList() / []). Since list equality is reference-based, this will cause TextScrollPanelProps to 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 switch Items to 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

  • CalculateHeight tolerates child.BaseProps == null by treating height as 0, but RenderCore will crash if any child has null BaseProps due 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.

Comment thread dotnet/samples/02-agents/Harness/Harness_Shared_Console/HarnessAppComponent.cs Outdated
@westey-m westey-m added this pull request to the merge queue May 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 19, 2026
@westey-m westey-m added this pull request to the merge queue May 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 19, 2026
@westey-m westey-m added this pull request to the merge queue May 19, 2026
Merged via the queue into microsoft:main with commit 61f636f May 19, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants