Skip to content

fix(android): register TriggerAliasEditorViewModel so the Rules page works#22

Closed
HarryCordewener wants to merge 1 commit into
masterfrom
fix/rules-di-registration
Closed

fix(android): register TriggerAliasEditorViewModel so the Rules page works#22
HarryCordewener wants to merge 1 commit into
masterfrom
fix/rules-di-registration

Conversation

@HarryCordewener

Copy link
Copy Markdown
Member

Problem

Tapping Rules on Android crashed with an "Unknown Error". The log shows:

Cannot provide a value for property 'Vm' on type 'SharpClient.UI.Pages.RulesPage'.
There is no registered service of type 'SharpClient.Core.Presentation.TriggerAliasEditorViewModel'.

RulesPage injects TriggerAliasEditorViewModel, which is registered on the Web host (Program.cs) but was never registered in the MAUI container (MauiProgram.cs). So DI failed to resolve it on Android and the render threw. (Web was unaffected — it had the registration.)

Fix

Register TriggerAliasEditorViewModel in MauiProgram, mirroring the Web registration (IWorldStore-backed, transient). After this, the set of view models injected by the UI exactly matches the set registered in the MAUI container — verified there are no other gaps.

Android head builds clean.

Note

This class of bug is host-DI drift between Program.cs (Web) and MauiProgram.cs (MAUI). A follow-up could extract a shared AddSharpClientViewModels(...) registration to prevent recurrence, but the scopes differ (Web uses Scoped per-circuit; MAUI uses Transient/Singleton), so it isn't a trivial merge — left out of this fix.

🤖 Generated with Claude Code

…works

Opening the Rules page on Android threw "Cannot provide a value for property 'Vm'
on type RulesPage. There is no registered service of type
TriggerAliasEditorViewModel." — the view model was registered on the Web host
(Program.cs) but never in the MAUI container (MauiProgram.cs), so DI failed when
RulesPage tried to inject it.

Register it in MauiProgram, mirroring the Web registration (IWorldStore-backed,
transient). With this, the set of injected view models exactly matches the set
registered in the MAUI container. Android head builds clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HHCRc5CJ6595iMzEgYYdQp
Copilot AI review requested due to automatic review settings July 1, 2026 14:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes an Android crash when navigating to the Rules page by aligning the MAUI DI container’s view model registrations with the Web host, ensuring TriggerAliasEditorViewModel can be resolved for RulesPage.

Changes:

  • Register TriggerAliasEditorViewModel in MauiProgram.cs as a transient service backed by IWorldStore.
  • Add in-code context explaining why the registration is needed (host DI drift between Web and MAUI).

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

@HarryCordewener

Copy link
Copy Markdown
Member Author

Superseded by #24, which moves all view-model registrations into a shared AddSharpClientViewModels extension called by both hosts — that registers TriggerAliasEditorViewModel for MAUI (this hot-fix) as part of the refactor, and prevents the Web/MAUI drift that caused it. Closing in favor of #24.

@HarryCordewener
HarryCordewener deleted the fix/rules-di-registration branch July 6, 2026 19:18
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