Add Comet view support: gesture tap, scroll, and stable IDs#33
Merged
Redth merged 2 commits intoRedth:mainfrom Mar 11, 2026
Merged
Add Comet view support: gesture tap, scroll, and stable IDs#33Redth merged 2 commits intoRedth:mainfrom
Redth merged 2 commits intoRedth:mainfrom
Conversation
- CometViewResolver: Handle AmbiguousMatchException from generic handlers (ViewHandler<TView,TPlatform>) by walking inheritance chain with DeclaredOnly flag. Add outer try/catch to prevent unhandled exceptions from aborting tree walks. - VisualTreeWalker: Extract visibility, bounds, opacity, and text from IView/IText interfaces for non-VisualElement types (Comet). Use ??= for text extraction to preserve IText-resolved values. - DevFlowAgentService: Add interface-based tap handling (IButton, ISwitch, ICheckBox, IRadioButton) for Comet views that implement MAUI interfaces but not Controls classes. Add TryNativeTapOnHandler fallback using handler PlatformView reflection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Three changes to support Comet views in MauiDevFlow automation: 1. HandleTap: Add IGestureView support via reflection. Comet views use IGestureView.Gestures with TapGesture.Invoke() instead of MAUI TapGestureRecognizer. New TryInvokeCometGestureTap checks for the interface by name and invokes tap gestures without a Comet dependency. 2. HandleScroll: Add IView/IScrollView support. Comet ScrollView implements IScrollView but not Controls.ScrollView. Added TryNativeScrollOnHandler for element-targeted scroll, and FindDescendantIScrollView for page-level scroll. Platform override TryNativeScrollOnPlatformView delegates to native UIScrollView (iOS/macCatalyst), RecyclerView (Android), or ScrollViewer (Windows). 3. GenerateId: Extract platform view from IView.Handler for EnsurePlatformStableId. Comet auto-stamps AccessibilityIdentifier on native views, but GenerateId was passing the Comet.View to EnsurePlatformStableId which expected a UIView. Now falls through to handler.PlatformView, yielding stable platform-stamped IDs. Validated against CometControlsGallery on Mac Catalyst: - Sidebar tap (Text + OnTap gesture): WORKS - Button tap (IButton interface): WORKS - ScrollView scroll (element-targeted): WORKS - Page-level scroll (IScrollView discovery): WORKS - MAUI reference app: No regressions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
This PR adds first-class support for Comet MVU views in MauiDevFlow. Comet views implement MAUI interfaces (
IView,IButton,IScrollView,IGestureView) but do not subclassMicrosoft.Maui.Controlstypes, so they were previously invisible to the visual tree walker and unresponsive to agent tap/scroll commands.What's added
IGestureView tap support — Detects Comet's
IGestureView.Gesturescollection via reflection, findsTapGestureinstances, and invokes them. Falls back to MAUI interface-based tap (IButton.Clicked(), etc.) and finally to native platform tap viaHandler.PlatformView.IScrollView scroll support — Handles Comet
ScrollView(implementsIScrollViewbut notControls.ScrollView) by accessing the handler's platform view and performing native scroll (UIScrollView.SetContentOffseton iOS/macCatalyst,RecyclerView.ScrollByon Android,ScrollViewer.ChangeViewon Windows).Stable element IDs via Handler.PlatformView — For Comet views that lack
Element.Id, the walker now checksIView.AutomationIdfirst, then falls back to the platform view's accessibility identifier (e.g.,UIView.AccessibilityIdentifier) for stable IDs across visual tree snapshots.CometViewResolver — New reflection-based utility that resolves Comet view wrappers to their inner view types, extracts properties, and provides Comet-aware type names in the visual tree. Caches all reflection metadata and short-circuits immediately when Comet is not loaded.
Safety: all changes are additive
All changes are additive — existing MAUI app behavior is unchanged:
switchcases are placed after existingcase View v/case ScrollView svcases, so standard MAUI controls always match firstelse if (element is IView)branches only execute when the existingif (element is VisualElement)branch doesn't matchCometViewResolver.TryResolveCometView()returnsnullimmediately when Comet assembly is not loaded (cached boolean check)Testing
Known limitation
Comet view element IDs may change across MVU state rebuilds (the view tree is reconstructed on state changes). This is architectural to Comet's MVU model and not a regression introduced by this PR.