Compare commits

...

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
357b28c5fb Fix using directive ordering in DockViewModel.cs (SA1210)
Agent-Logs-Url: https://github.com/microsoft/PowerToys/sessions/bdf3fdfa-8c99-43e9-8d47-2e603180959b

Co-authored-by: michaeljolley <1228996+michaeljolley@users.noreply.github.com>
2026-04-16 17:49:22 +00:00
Niels Laute
e51e07e24b Fix CmdPal_DockConfiguration telemetry event never firing
DockViewModel.EmitDockConfiguration() fires a TelemetryDockConfigurationMessage
in its constructor, but TelemetryForwarder (which listens for that message) is
lazily constructed by DI and may not exist yet. WeakReferenceMessenger silently
drops messages with no registered recipient.

Fix: Add ITelemetryService as a constructor dependency of DockViewModel. This
forces DI to resolve TelemetryForwarder first, ensuring its message listeners
are registered before EmitDockConfiguration() fires.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 11:30:56 +02:00

View File

@@ -6,6 +6,7 @@ using System.Collections.Immutable;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon;
using Microsoft.CmdPal.Common.Services;
using Microsoft.CmdPal.UI.Messages;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.CmdPal.UI.ViewModels.Services;
@@ -34,11 +35,14 @@ public sealed partial class DockViewModel
public IReadOnlyList<TopLevelViewModel> AllItems => _topLevelCommandManager.GetDockBandsSnapshot();
// ITelemetryService dependency ensures TelemetryForwarder is constructed
// (and its message listeners registered) before this ViewModel fires events.
public DockViewModel(
TopLevelCommandManager tlcManager,
IContextMenuFactory contextMenuFactory,
TaskScheduler scheduler,
ISettingsService settingsService)
ISettingsService settingsService,
ITelemetryService telemetryService)
{
_topLevelCommandManager = tlcManager;
_contextMenuFactory = contextMenuFactory;