You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add public IAlertManager and IAlertManagerSubscription interfaces (#34228)
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
## Description
Fixes#34104
Custom platform backends (e.g., Linux/GTK) currently have no supported
way to implement `DisplayAlert()`, `DisplayActionSheet()`, or
`DisplayPromptAsync()`. The entire alert pipeline (`AlertManager`,
`IAlertManagerSubscription`) is internal, forcing custom backends to use
`DispatchProxy` + heavy reflection to intercept dialog requests.
This PR introduces two public interfaces to enable custom platform
backends to implement alert dialogs without reflection:
### New Public APIs
**`IAlertManager`** — Public interface for the full alert management
lifecycle. Custom backends can implement this to completely replace the
default `AlertManager`:
```csharp
public interface IAlertManager
{
void Subscribe();
void Unsubscribe();
void RequestAlert(Page page, AlertArguments arguments);
void RequestActionSheet(Page page, ActionSheetArguments arguments);
void RequestPrompt(Page page, PromptArguments arguments);
}
```
**`IAlertManagerSubscription`** — Public interface for platform-specific
dialog implementations. The default `AlertManager` already resolves this
from DI, so custom backends can register their implementation directly:
```csharp
public interface IAlertManagerSubscription
{
void OnAlertRequested(Page sender, AlertArguments arguments);
void OnActionSheetRequested(Page sender, ActionSheetArguments arguments);
void OnPromptRequested(Page sender, PromptArguments arguments);
}
```
### Usage
Two levels of customization are now available:
```csharp
// Simple: Just provide custom dialog implementations
builder.Services.AddSingleton<IAlertManagerSubscription, GtkAlertSubscription>();
// Advanced: Replace the entire alert management system
builder.Services.AddSingleton<IAlertManager, CustomAlertManager>();
```
### Changes
- **New:** `IAlertManager` public interface in
`Microsoft.Maui.Controls.Platform`
- **New:** `IAlertManagerSubscription` public interface (moved from
internal nested interface)
- **Modified:** `AlertManager` now implements `IAlertManager`
- **Modified:** `Window.AlertManager` property typed as `IAlertManager`,
resolves custom implementation from DI
- **Modified:** Tests updated + 2 new tests for DI resolution
- **Updated:** All `PublicAPI.Unshipped.txt` files
### Related
- Related PR: #33267 (draft, creates internal `IAlertManager` for
#33266)
- Real-world use case: [Maui.Gtk
GtkAlertManager](https://github.com/redth/Maui.Gtk/blob/main/src/Platform.Maui.Linux.Gtk4/Platform/GtkAlertManager.cs)
— 370 lines of reflection that this PR eliminates
---------
**⚠️ Old pipeline names** (e.g., `MAUI-UITests-public`, `MAUI-public`) are **outdated** and should NOT be used. Always use the names above.
104
+
93
105
### Code Formatting
94
106
95
107
Always format code before committing:
@@ -126,26 +138,6 @@ When working with public API changes:
126
138
-**Use `dotnet format analyzers`** if having trouble
127
139
-**If files are incorrect**: Revert all changes, then add only the necessary new API entries
128
140
129
-
**🚨 CRITICAL: `#nullable enable` must be line 1**
130
-
131
-
Every `PublicAPI.Unshipped.txt` file starts with `#nullable enable` (often BOM-prefixed: `#nullable enable`) on the **first line**. If this line is moved or removed, the analyzer treats it as a declared API symbol and emits **RS0017** errors.
132
-
133
-
**Never sort these files with plain `sort`** — the BOM bytes (`0xEF 0xBB 0xBF`) sort after ASCII characters under `LC_ALL=C`, pushing `#nullable enable` to the bottom of the file.
134
-
135
-
When resolving merge conflicts or adding entries, use this safe pattern that preserves line 1:
-`.github/instructions/xaml-unittests.instructions.md` - XAML unit test guidelines
188
+
### Opening PRs
189
+
190
+
All PRs are required to have this at the top of the description:
191
+
192
+
```
193
+
<!-- Please let the below note in for people that find this PR -->
194
+
> [!NOTE]
195
+
> Are you waiting for the changes in this PR to be merged?
196
+
> It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you!
197
+
```
198
+
199
+
Always put that at the top, without the block quotes. Without it, users will NOT be able to try the PR and your work will have been in vain!
200
+
202
201
203
202
204
203
## Custom Agents and Skills
@@ -216,18 +215,24 @@ The repository includes specialized custom agents and reusable skills for specif
216
215
217
216
### Available Custom Agents
218
217
219
-
1.**write-tests-agent** - Agent for writing tests. Determines test type (UI vs XAML) and invokes the appropriate skill (`write-ui-tests`, `write-xaml-tests`)
218
+
1.**pr** - Sequential 4-phase workflow for reviewing and working on PRs
219
+
-**Use when**: A PR already exists and needs review or work, OR an issue needs a fix
220
+
-**Capabilities**: PR review, test verification, fix exploration, alternative comparison
-**Do NOT use for**: Just running tests manually → Use `sandbox-agent`
223
+
224
+
2.**write-tests-agent** - Agent for writing tests. Determines test type (UI vs XAML) and invokes the appropriate skill (`write-ui-tests`, `write-xaml-tests`)
220
225
-**Use when**: Creating new tests for issues or PRs
221
226
-**Capabilities**: Test type determination (UI and XAML), skill invocation, test verification
222
227
-**Trigger phrases**: "write tests for #XXXXX", "create tests", "add test coverage"
223
228
224
-
2.**sandbox-agent** - Specialized agent for working with the Sandbox app for testing, validation, and experimentation
229
+
3.**sandbox-agent** - Specialized agent for working with the Sandbox app for testing, validation, and experimentation
225
230
-**Use when**: User wants to manually test PR functionality or reproduce issues
-**Purpose**: Reviews PR code changes for correctness, safety, and consistency with MAUI conventions. Walks through a MAUI-specific checklist covering handler lifecycle, platform code, safe area, threading, public API, and test patterns.
268
+
-**Trigger phrases**: "review code for PR #XXXXX", "code review PR #XXXXX", "review this PR's code"
269
+
-**Note**: Standalone skill — uses independence-first assessment (reads code before PR description to avoid anchoring bias). Can be used by any agent or invoked directly.
270
+
-**🚨 CRITICAL**: NEVER use `--approve` or `--request-changes` — only post comments. Approval is a human decision.
-**Purpose**: Investigates CI failures for PRs — build errors, Helix test logs, and binlog analysis. Delegates to the `ci-analysis` skill from the dotnet/arcade-skills plugin.
296
-
-**Trigger phrases**: "check build for PR #XXXXX", "why did PR build fail", "get build status", "what's failing on PR", "Helix failures"
-**Behavior**: Reads prior attempts to learn from failures. Max 5 attempts per session.
317
311
-**Output**: Updates session markdown with attempt results and failure analysis
318
312
319
-
### Using Custom Agents and Skills
313
+
### Using Custom Agents
320
314
321
-
**Delegation Policy**: When user request matches skill/agent trigger phrases, **ALWAYS invoke the appropriate skill or delegate to the agent immediately**. Do not ask for permission or explain alternatives unless the request is ambiguous.
315
+
**Delegation Policy**: When user request matches agent trigger phrases, **ALWAYS delegate to the appropriate agent immediately**. Do not ask for permission or explain alternatives unless the request is ambiguous.
0 commit comments