Skip to content

Extract generic DevFlow WebView tooling with a clean context contract - #655

Open
mattleibow wants to merge 3 commits into
mainfrom
mattleibow-clean-webview-implementation
Open

mattleibow wants to merge 3 commits into
mainfrom
mattleibow-clean-webview-implementation

Conversation

@mattleibow

Copy link
Copy Markdown
Member

Summary

Implementation layer above schema-only #652, carved from the audited implementation in #651. This PR targets mattleibow-devflow-schema-corrections; it does not replace or rewrite the schema baseline. Native stack registration and superseding #651 are handled separately by the coordinator.

  • Add the shipping Microsoft.Maui.DevFlow.WebView package: one serialized embedded-JavaScript CDP engine with standard MAUI WebView and HybridWebView native adapters. Blazor references it and adds actual handler capture, rendered #app readiness and Blazor.navigateTo routing. AddMauiBlazorDevFlowTools remains a functional adapter registration including generic tools.
  • Preserve exact-once evaluation, unique internal wire IDs/caller-ID remapping, late-response isolation, no replay of timed-out mutations, UI-thread native operations, original host navigation/message/resource handlers, weak-owner correlation, duplicate AutomationId safety, guarded replacement-safe unregister, lifecycle cancellation, active-page selection and native-first screenshots.
  • Wire generic DOM/layout diagnostics, portable Client, CLI/MCP, Inspector, maintained standard/Hybrid/mixed samples and consumer/contributor/setup documentation. Browser fetch/XHR capture honestly returns 501; native .NET network capture is unchanged.
  • Include the new package in MauiLabs.slnx and the exact official DevFlow.slnf. The existing official publish glob already includes it. No new CI workflow or npm dependency/lockfile changes.

Breaking changes

Update the agent, CLI, Client, WebView and Blazor packages together, and rebuild older consumers. No WebView-facing compatibility is retained.

  • Context selection accepts only canonical webview-<index> IDs through contextId (CLI: --context-id). Remove the old webview query/CLI option and numeric, AutomationId and elementId resolver aliases. Explicit blank selectors are not normalized to the active host.
  • Contexts emit only ready, not isReady. hostKind describes the hosting context; it is not a native backend or behavior-dispatch switch.
  • Layout scope uses only includeWebViewElements; remove IncludeBlazorElements and its fallback. Layout capabilities use webview/webview-dom, without the former Blazor-only duplicates. DOM element metadata is generic WebView metadata.
  • Remove CdpCommandHandler/CdpReadyCheck, compatibility registration overloads and unguarded unregister, Microsoft.Maui.DevFlow.Blazor.ChobitsuDebugScript, the compatibility-only BlazorWebViewDebugServiceBase, base-service DI aliases, ConfigureHandler wrappers and first-bridge CDP convenience APIs (including the GTK singleton shim). Keep the actual shared engine and functional adapter APIs.
  • Real netstandard2.0 Client support, Driver namespaces/type forwards and native Driver responsibilities remain intact.

Fresh verification

Surface Result
Focused agent/bridge/registry/protocol/layout/capability tests 74 passed
Portable Client tests 65 passed; explicit netstandard2.0 build passed
CLI WebView contract tests 14 passed
Chromium Inspector context selection/source and explicit evaluation confirmation 2 passed
Managed GTK registration/disposal/API regressions 4 passed; no GTK native runtime exercised
Live Mac Catalyst WebView + native smoke regression 52 passed
Real stdio MCP and CLI against all three mixed-page hosts Source/evaluation/canonical selection verified; MCP native PNGs verified; removed option/IDs rejected
Schema validation 32 documents parsed; 25 retained baseline records; 50 payload/schema checks; 25 obsolete selector shapes rejected
Generic package net10.0, Android, iOS, Mac Catalyst and macOS built/packed; README verified; no ASP.NET/Razor/Blazor dependency graph
Blazor iOS build passed; live Mac Catalyst exercised

The initial expanded live selection passed 52/53: the untouched UiInspectionTests.HitTest_Response_MatchesDocumentedEnvelope AddButton-coordinate assertion failed and was reproduced alone. The focused rerun excludes that unrelated assertion. No full-suite-green claim: the original investigation also disclosed two unrelated broad CLI gesture failures (UiGesture_ReportsWhichTierHandledIt, UiGesture_Pinch_SendsScaleToGestureRoute), and the broad CLI suite was not rerun here. No Windows/GTK/WPF native-runtime or physical-device coverage claimed. Mac Catalyst used per-process Xcode 26.6, without global Xcode/lifecycle changes. All owned validation app/Inspector/MCP helpers have been stopped.

Spec boundaries

Exactly four feature-specific spec files change above #652: docs/DevFlow/spec/README.md, openapi.yaml, schemas/webview.json, and examples/webview-contexts-response.json. Preserve the parent's profiler PascalCase, sensor X/Y/Z, compact log keys, header arrays, HTTP/WS envelopes/events/filters and timestamp-free UI subscriptions. No broad agent-status/UI-tree/device/RFC7807 schema overhaul.

mattleibow and others added 2 commits October 9, 2026 17:05
Align WebView HTTP, streaming envelopes, and serialized DTOs with the recorded main baseline. Documentation and schemas only; no runtime or behavior changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8f1567da-8dcb-471a-a4e9-b5d96ead549c
Layer functional Blazor readiness and routing over the shared WebView/HybridWebView engine. Remove WebView compatibility aliases, singleton helpers and duplicated readiness/layout surfaces; migrate Client, CLI, MCP, Inspector, samples, tests and feature-specific specs together.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3577cd69-761e-4db5-b2d6-6640a1c3b783
@mattleibow mattleibow added the breaking-change This PR contains breaking changes label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Expert Code Review — PR #655

Methodology: 2 independent reviewers (1 failed — reduced coverage, no tiebreaker) with adversarial consensus. Because this PR changes 79 files, reviewers received disjoint batches; surviving batch-local findings were downgraded and marked low confidence.

Findings: 2 findings posted as inline comments (2 minor).

CI status: 17 checks passed, 1 failed (handler-tests), 3 remain in progress, and 1 was skipped at review time.

Test coverage: The PR includes substantial focused unit, integration, protocol, CLI, Inspector, lifecycle, registry, and WebView contract coverage for the changed surfaces. Native Windows/GTK/WPF runtime and physical-device coverage are not included, as disclosed in the PR description.

Generated by Expert Code Review · 2 independent reviewers with adversarial consensus

Generated by Expert Code Review (auto) for #655 · copilot · gpt56 · 193.7 AIC · ⌖ 12.6 AIC · ⊞ 37.6K · ◷

@github-actions github-actions Bot 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.

Expert Code Review: 2 low-confidence batch-split findings were posted inline. See the lean summary comment for methodology, CI status, and test coverage.

Generated by Expert Code Review (auto) for #655 · copilot · gpt56 · 193.7 AIC · ⌖ 12.6 AIC · ⊞ 37.6K

var autoId = wv.TryGetProperty("automationId", out var aid) ? aid.GetString() ?? "-" : "-";
var elemId = wv.TryGetProperty("elementId", out var eid) ? eid.GetString() ?? "-" : "-";
var ready = wv.TryGetProperty("isReady", out var rdy) && rdy.GetBoolean() ? "Yes" : "No";
var ready = wv.TryGetProperty("ready", out var rdy) && rdy.GetBoolean() ? "Yes" : "No";

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.

🟢 MINOR — low confidence, single reviewer (batch split)

The updated contract only accepts canonical IDs such as webview-2, but the non-JSON webview webviews table still displays only the numeric registry index. A user who copies the displayed 2 into --context-id gets a rejected selector.

Please expose the response id as a ContextId column (instead of, or alongside, Index) and cover the human-readable output in a CLI test.


var readyWebViews = webViews
.Where(webView => webView.IsReady)
.Where(webView => webView.IsReady && IsActiveCdpWebView(webView, activeWebViews) && blazorHosts.Any(host =>

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.

🟢 MINOR — low confidence, single reviewer (batch split)

readyWebViews is now restricted to active hosts mapped to captured nodes, but the later unavailable-host branch still compares against all registrations and iterates every unready registration. After navigation leaves an inactive registration behind, it can mark the active host opaque—especially when duplicate AutomationId values correlate the stale registration—so an otherwise complete layout scan is reported incomplete.

Apply the same active/captured-host filter to unavailable registrations, and only use AutomationId fallback when Owner is null, matching the ready-host mapping.

Include context IDs in human-readable CLI listings. Validate only the Inspector CDP source/evaluate target input, reject malformed or removed selectors without downstream dispatch, and preserve omitted/null active-host selection. Cover CLI output and proxy selection boundaries with focused regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3577cd69-761e-4db5-b2d6-6640a1c3b783
Base automatically changed from mattleibow-devflow-schema-corrections to main October 9, 2026 18:22
@jfversluis

Copy link
Copy Markdown
Member

Although it was a stack... This now still has conflicts 🤷 @mattleibow

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This PR contains breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants