From 207953159a6963dfa15ee0934907919ecc168b70 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 14 Jan 2026 23:29:10 -0800 Subject: [PATCH] Fix MainWindow to use shared ViewModel from DI and add console logging --- Flow.Launcher.Avalonia/MainWindow.axaml.cs | 5 ++--- Flow.Launcher.Infrastructure/Logger/Log.cs | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Avalonia/MainWindow.axaml.cs b/Flow.Launcher.Avalonia/MainWindow.axaml.cs index b2c0700d9..47372a4e9 100644 --- a/Flow.Launcher.Avalonia/MainWindow.axaml.cs +++ b/Flow.Launcher.Avalonia/MainWindow.axaml.cs @@ -19,9 +19,8 @@ public partial class MainWindow : Window { InitializeComponent(); - // Create and set the ViewModel - var settings = Ioc.Default.GetRequiredService(); - _viewModel = new MainViewModel(settings); + // Get the ViewModel from DI (same instance that App uses) + _viewModel = Ioc.Default.GetRequiredService(); _viewModel.HideRequested += () => Hide(); DataContext = _viewModel; diff --git a/Flow.Launcher.Infrastructure/Logger/Log.cs b/Flow.Launcher.Infrastructure/Logger/Log.cs index 09eb98f46..2fdba2dfe 100644 --- a/Flow.Launcher.Infrastructure/Logger/Log.cs +++ b/Flow.Launcher.Infrastructure/Logger/Log.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; @@ -149,6 +149,9 @@ namespace Flow.Launcher.Infrastructure.Logger var logger = LogManager.GetLogger(classNameWithMethod); logger.Log(level, message); + + // Also output to console for easy debugging + System.Console.WriteLine($"[{level}] {classNameWithMethod}: {message}"); } public static void Debug(string className, string message, [CallerMemberName] string methodName = "")