Skip to content

GTK Improvements#9

Merged
Redth merged 4 commits intomainfrom
feature/linux-gtk-support
Feb 13, 2026
Merged

GTK Improvements#9
Redth merged 4 commits intomainfrom
feature/linux-gtk-support

Conversation

@Redth
Copy link
Copy Markdown
Owner

@Redth Redth commented Feb 13, 2026

This pull request introduces several improvements and bug fixes to the MauiDevFlow Agent and Blazor GTK integration, focusing on more robust WebView discovery, safer numeric handling, improved logging, and better resource management. The most significant changes are grouped below:

Blazor WebView Discovery and Initialization:

  • Added a background discovery mechanism in GtkBlazorWebViewDebugService to automatically locate and capture the WebKit.WebView used by BlazorWebView, improving reliability of CDP (Chrome DevTools Protocol) integration on Linux. This includes visual tree traversal and type-safe extraction of the WebView.
  • The AddMauiBlazorDevFlowTools extension now automatically wires the Blazor CDP service to the agent and starts WebView discovery after app startup, reducing manual setup. [1] [2]

Robustness and Error Handling:

  • Improved numeric safety by validating window and element dimensions with double.IsFinite before reporting them in the agent's status and visual tree APIs, preventing NaN/Infinity issues. [1] [2] [3]
  • Enhanced error logging throughout the agent and Blazor GTK code, replacing silent failures and debug-only logs with Console.WriteLine for better visibility in production and development environments. [1] [2] [3]

WebView JavaScript Injection Improvements:

  • Refined the debug script injection logic to check for the presence of chobitsu and inject it from an embedded resource if missing, with improved verification and logging of the injection process.

Resource Management:

  • Ensured proper disposal of background discovery and draining cancellation tokens in GtkBlazorWebViewDebugService to avoid resource leaks.

- Guard window width/height, frame bounds, and opacity against
  Infinity/NaN values that crash System.Text.Json on GTK
- Log request errors with type and message instead of silently swallowing
- AddMauiBlazorDevFlowTools() now auto-wires CDP to Agent and starts
  WebView discovery — no manual WireBlazorCdpToAgent() call needed
- WebView discovery scans visual tree for BlazorWebView, extracts
  WebKit.WebView from handler's Gtk.Box platform view
- Inject chobitsu.js from embedded resource when not present in page
  (no manual script tag needed in wwwroot/index.html)
- Verified end-to-end: all MAUI and CDP commands work on Linux/GTK
- Agent.Gtk now registers with the broker daemon on startup
  (same pattern as standard Agent)
- Reads project/TFM from assembly metadata for agent identity
- Reports platform as 'Linux' for broker agent list
- Auto-reconnects to broker if started after the app
- Falls back to .mauidevflow/default port if broker unavailable
@Redth Redth changed the title Feature/linux gtk support GTK Improvements Feb 13, 2026
@Redth Redth merged commit fb1ae45 into main Feb 13, 2026
2 checks passed
@Redth Redth deleted the feature/linux-gtk-support branch February 13, 2026 16:41
@Redth Redth mentioned this pull request Mar 8, 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.

1 participant