From e2d07826ede5c1df0f884ef8a59e0a89c95b7d08 Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期三, 12 八月 2026 20:43:29 +0800
Subject: [PATCH] 移除发布文件

---
 src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs |   41 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs b/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs
index 0b9f6e9..13f1d1d 100644
--- a/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs
+++ b/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs
@@ -2,6 +2,7 @@
 using Moli.Desktop.Diagnostics;
 using Moli.Desktop.Interop;
 using Moli.Desktop.Layout;
+using Moli.Desktop.Llm;
 using Moli.Desktop.Plugins;
 
 namespace Moli.Desktop.Runtime;
@@ -15,6 +16,8 @@
     private readonly IDiagnosticsService _diagnostics;
     private readonly IRuntimeEventBus _events;
     private readonly IRuntimeSurfaceController _surfaces;
+    private readonly DisplayChangeMonitor _displayMonitor;
+    private readonly ILlmGatewayService _llmGateway;
     private readonly SemaphoreSlim _lock = new(1, 1);
     private AppSettingsDocument _settings = new();
     private IReadOnlyList<PluginDescriptor> _pluginSnapshot = [];
@@ -30,7 +33,9 @@
         IWin32InteropService interop,
         IDiagnosticsService diagnostics,
         IRuntimeEventBus events,
-        IRuntimeSurfaceController surfaces)
+        IRuntimeSurfaceController surfaces,
+        DisplayChangeMonitor displayMonitor,
+        ILlmGatewayService llmGateway)
     {
         _configuration = configuration;
         _plugins = plugins;
@@ -39,6 +44,8 @@
         _diagnostics = diagnostics;
         _events = events;
         _surfaces = surfaces;
+        _displayMonitor = displayMonitor;
+        _llmGateway = llmGateway;
     }
 
     public async Task<OperationResult<AppRuntimeState>> StartAsync(CancellationToken cancellationToken = default)
@@ -61,6 +68,9 @@
             {
                 await _surfaces.ApplyWidgetLayoutAsync(ToSurfaceLayout(layout), cancellationToken).ConfigureAwait(false);
             }
+
+            _displayMonitor.DisplayChanged += () => OnDisplayTopologyChangedAsync();
+            _displayMonitor.Start();
 
             _diagnostics.Record(DiagnosticSeverity.Info, DiagnosticCodes.ApplicationStarted, "Desktop runtime started.");
             var state = BuildState();
@@ -234,6 +244,32 @@
         }
     }
 
+    public async Task OnDisplayTopologyChangedAsync(CancellationToken cancellationToken = default)
+    {
+        await _lock.WaitAsync(cancellationToken).ConfigureAwait(false);
+        try
+        {
+            ReconcileCurrentMonitors();
+            await _layout.SaveAsync(cancellationToken).ConfigureAwait(false);
+            await _surfaces.SyncAllLayoutsAsync(cancellationToken).ConfigureAwait(false);
+            await _surfaces.SyncWallpaperMonitorsAsync(cancellationToken).ConfigureAwait(false);
+            await _surfaces.ReattachDesktopLayersAsync(cancellationToken).ConfigureAwait(false);
+
+            var state = BuildState();
+            await _events.PublishAsync(new RuntimeEvent { Name = "display.topologyChanged", Payload = state }, cancellationToken).ConfigureAwait(false);
+            await PublishStatusAsync(state, cancellationToken).ConfigureAwait(false);
+        }
+        finally
+        {
+            _lock.Release();
+        }
+    }
+
+    public async Task CancelPluginRequestsAsync(PluginId pluginId, CancellationToken cancellationToken = default)
+    {
+        await _llmGateway.CancelPluginRequestsAsync(pluginId.Value, cancellationToken).ConfigureAwait(false);
+    }
+
     private async Task<OperationResult<AppRuntimeState>> UpdateRuntimeFlagAsync(
         string eventName,
         Action update,
@@ -327,7 +363,8 @@
         IsVisible = layout.IsVisible,
         IsLocked = _isGlobalLocked || layout.IsLocked,
         Opacity = layout.Opacity,
-        ClickThrough = _isEditMode || _isSafeInputMode ? false : layout.ClickThrough
+        ClickThrough = _isEditMode || _isSafeInputMode ? false : layout.ClickThrough,
+        DisplayLayer = layout.DisplayLayer
     };
 
     private WidgetLayout ToSurfaceLayout(WidgetLayout layout)

--
Gitblit v1.9.1