Skip to content

🏗️ Forge: VisualTreeHelper Parity Integration#298

Closed
tedd wants to merge 2 commits into
mainfrom
forge-visual-tree-helper-15292146790065390438
Closed

🏗️ Forge: VisualTreeHelper Parity Integration#298
tedd wants to merge 2 commits into
mainfrom
forge-visual-tree-helper-15292146790065390438

Conversation

@tedd

@tedd tedd commented Jul 9, 2026

Copy link
Copy Markdown
Owner

💡 Hypothesis: The TUI framework lacked the standard VisualTreeHelper utility class, requiring controls and logic to interface directly with UIElement's internal rendering hierarchy methods (VisualChildrenCount, GetVisualChild). This architectural deficit breaks WPF/XAML isomorphism, where visual tree traversal is distinctly decoupled via the VisualTreeHelper static API.

🎯 Execution: Engineered the VisualTreeHelper static class using .NET 10.0 idioms. Mapped the core GetChildrenCount, GetChild, and GetParent methods to the existing UIElement structural counterparts (VisualChildrenCount, GetVisualChild, and Parent).

📊 Functional Impact: The framework now supports standard XAML programmatic visual tree navigation, fulfilling a core foundational WPF parity requirement without allocating new traversal logic or modifying the underlying layout engine.

🔬 Verification Protocol:

  1. Instantiate standard layout panels and UI elements (e.g., StackPanel, Button, TextBlock).
  2. Utilize VisualTreeHelper.GetChildrenCount and verify it matches the expected visual rendering count.
  3. Utilize VisualTreeHelper.GetChild to ensure accurate retrieval of generated visual elements.
  4. Execute the new unit tests defined in VisualTreeHelperTests.

PR created automatically by Jules for task 15292146790065390438 started by @tedd

- Added `VisualTreeHelper.cs` to expose `GetChildrenCount`, `GetChild`, and `GetParent`.
- Delegated logic to existing `UIElement` methods `VisualChildrenCount`, `GetVisualChild`, and `Parent`.
- Added accompanying unit tests in `VisualTreeHelperTests`.

Co-authored-by: tedd <493224+tedd@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 03:40
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

… on Border

- Allowed nulls on `Border.Title` and `Border.StatusBar` to eliminate compiler warnings about missing `required` modifier.

Co-authored-by: tedd <493224+tedd@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a WPF-like VisualTreeHelper API to Tedd.TUI so controls and consumers can traverse the visual tree via a standard static helper rather than calling UIElement internals directly, supporting XAML/WPF parity goals.

Changes:

  • Introduces VisualTreeHelper with GetChildrenCount, GetChild, and GetParent delegating to existing UIElement visual hierarchy APIs.
  • Updates Border.Title and Border.StatusBar to nullable to reflect their optional nature.
  • Adds unit tests for VisualTreeHelper and includes small test cleanups/formatting tweaks plus a forge log entry.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Tedd.TUI/VisualTreeHelper.cs New WPF-parity helper for visual tree traversal.
src/Tedd.TUI/Border.cs Makes Title/StatusBar nullable (optional) without changing behavior.
src/Tedd.TUI.Tests/VisualTreeHelperTests.cs Adds coverage for the new helper methods and null-guard behavior.
src/Tedd.TUI.Tests/ValidatorLayoutMatrixTests.cs Formatting-only adjustment in a test lambda.
src/Tedd.TUI.Tests/ValidatorGroupBoxTests.cs Formatting-only adjustment in a test lambda.
src/Tedd.TUI.Tests/MarkdownViewTests.cs Uses Assert.Single for clearer row-count assertions.
src/Tedd.TUI.Tests/ItemsControlTests.cs Minor formatting in collection expressions.
.jules/forge.md Documents the parity integration work item.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
using System;
using System.Collections.Generic;
using Tedd.TUI;
Comment on lines +5 to +27
namespace Tedd.TUI
{
public static class VisualTreeHelper
{
public static int GetChildrenCount(UIElement reference)
{
if (reference == null) throw new ArgumentNullException(nameof(reference));
return reference.VisualChildrenCount;
}

public static UIElement GetChild(UIElement reference, int childIndex)
{
if (reference == null) throw new ArgumentNullException(nameof(reference));
return reference.GetVisualChild(childIndex);
}

public static UIElement? GetParent(UIElement reference)
{
if (reference == null) throw new ArgumentNullException(nameof(reference));
return reference.Parent; // TUI maps VisualParent to Parent mostly, or maybe we need a dedicated VisualParent in the future?
}
}
}
@tedd tedd closed this Jul 11, 2026
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.

2 participants