From 040b797be5d0088744cba5c57dd83db11f3fb4d1 Mon Sep 17 00:00:00 2001 From: Tom Bohar Date: Sat, 26 Sep 2026 14:20:07 -0400 Subject: [PATCH] RynthCore as of 2026-09-26 (internal 5326694): panels re-bind plugin exports after RL; deploy checks launcher locks Co-Authored-By: Claude Opus 5.5 --- scripts/Deploy-RynthCore.ps1 | 19 +++++++++++++++++++ src/RynthCore.Engine/Plugins/PluginManager.cs | 12 ++++++++++++ src/RynthCore.Engine/UI/Panels/ItemsPanel.cs | 10 ++++++++++ src/RynthCore.Engine/UI/Panels/MetaPanel.cs | 8 ++++++++ .../UI/Panels/MonsterDamagePanel.cs | 16 ++++++++++++++++ .../UI/Panels/MonstersPanel.cs | 8 ++++++++ src/RynthCore.Engine/UI/Panels/NavPanel.cs | 8 ++++++++ src/RynthCore.Engine/UI/Panels/RadarPanel.cs | 7 +++++++ .../UI/Panels/RynthAiPanel.cs | 17 +++++++++++++++++ .../UI/Panels/RynthChatPanel.cs | 9 +++++++++ .../UI/Panels/RynthNavPanel.cs | 12 ++++++++++++ .../UI/Panels/RynthTrackerPanel.cs | 8 ++++++++ .../UI/Panels/RynthVisionPanel.cs | 9 +++++++++ .../UI/Panels/SettingsPanel.cs | 8 ++++++++ 14 files changed, 151 insertions(+) diff --git a/scripts/Deploy-RynthCore.ps1 b/scripts/Deploy-RynthCore.ps1 index 39f9cac..74caba6 100644 --- a/scripts/Deploy-RynthCore.ps1 +++ b/scripts/Deploy-RynthCore.ps1 @@ -199,6 +199,25 @@ $rootCleanup = @( ) if (-not $SkipLauncher) { + # Same pre-flight for the launcher payload: a running RynthCore.exe holds its + # Avalonia DLLs, and the copy failing on one of them used to abort the deploy + # AFTER Runtime\ below had been wiped (2026-09-26) — no engine until a redeploy. + $launcherLocked = @() + foreach ($f in Get-ChildItem -LiteralPath $launcherPublish -File) { + $target = Join-Path $Destination $f.Name + if ($f.Name -eq "RynthCore.App.Avalonia.exe") { $target = Join-Path $Destination "RynthCore.exe" } + if (-not (Test-Path -LiteralPath $target)) { continue } + try { + $s = [System.IO.File]::Open($target, 'Open', 'ReadWrite', 'None') + $s.Close() + } catch { + $launcherLocked += $target + } + } + if ($launcherLocked.Count -gt 0) { + throw ("Deploy aborted BEFORE touching anything - $($launcherLocked.Count) launcher file(s) are locked (close the RynthCore launcher, or pass -SkipLauncher):`n " + ($launcherLocked -join "`n ")) + } + foreach ($name in $rootCleanup) { $target = Join-Path $Destination $name if (Test-Path -LiteralPath $target) { diff --git a/src/RynthCore.Engine/Plugins/PluginManager.cs b/src/RynthCore.Engine/Plugins/PluginManager.cs index 8fada8d..10387ea 100644 --- a/src/RynthCore.Engine/Plugins/PluginManager.cs +++ b/src/RynthCore.Engine/Plugins/PluginManager.cs @@ -254,6 +254,15 @@ internal static class PluginManager private static string _shadowRootDir = ""; public static IReadOnlyList Plugins => _plugins; + + /// + /// Raised after every plugin has been shut down and removed (RL / rescan, engine + /// shutdown). Unload never FreeLibrary's a NativeAOT plugin, so an export bound + /// before a reload stays callable — into the shut-down copy. Panels that cache + /// plugin exports drop them here; their next poll re-binds to the fresh copy. + /// Raised on the pump thread. + /// + public static event Action? PluginsUnloaded; public static bool IsRescanQueued => _rescanRequested; public static string PluginDirectory => _pluginsDir; public static IReadOnlyList ExtraPluginPaths => EngineSettings.PluginPaths; @@ -2191,6 +2200,9 @@ internal static class PluginManager _plugins.Clear(); PublishPluginsRenderSnapshot(); + + try { PluginsUnloaded?.Invoke(); } + catch (Exception ex) { RynthLog.Plugin($"PluginManager: PluginsUnloaded handler threw: {ex.Message}"); } } private static void DispatchUIInitializedToLoadedPlugins() diff --git a/src/RynthCore.Engine/UI/Panels/ItemsPanel.cs b/src/RynthCore.Engine/UI/Panels/ItemsPanel.cs index 410dbcd..14d6fc6 100644 --- a/src/RynthCore.Engine/UI/Panels/ItemsPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/ItemsPanel.cs @@ -729,6 +729,16 @@ internal static class ItemsPanel } // ── Plugin binding ──────────────────────────────────────────────────────── + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static ItemsPanel() => PluginManager.PluginsUnloaded += () => + { + _getItemsJson = null; + _setItemsJson = null; + _addSelectedWeapon = null; + _addSelectedConsumable = null; + }; + private static void TryBind() { var plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/MetaPanel.cs b/src/RynthCore.Engine/UI/Panels/MetaPanel.cs index 24340dd..416ddf5 100644 --- a/src/RynthCore.Engine/UI/Panels/MetaPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/MetaPanel.cs @@ -1481,6 +1481,14 @@ internal static class MetaPanel // Plugin bridge // ========================================================================= + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static MetaPanel() => PluginManager.PluginsUnloaded += () => + { + _getMetaJson = null; + _sendMetaCommand = null; + }; + private static void TryBind() { var plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/MonsterDamagePanel.cs b/src/RynthCore.Engine/UI/Panels/MonsterDamagePanel.cs index a6704e8..71d6bf2 100644 --- a/src/RynthCore.Engine/UI/Panels/MonsterDamagePanel.cs +++ b/src/RynthCore.Engine/UI/Panels/MonsterDamagePanel.cs @@ -58,6 +58,22 @@ internal static class MonsterDamagePanel private static SetJsonFn? _setMonsters; // RynthPluginSetMonstersJson (write-back, whole rules array) private static VoidFn? _clearStats; // RynthPluginClearMonsterStats (master reset) + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static MonsterDamagePanel() => PluginManager.PluginsUnloaded += () => + { + _getJson = null; + _setHp = null; + _delRow = null; + _getWeapons = null; + _setWeapon = null; + _setOffhand = null; + _getMonsters = null; + _setMonsters = null; + _clearStats = null; + _setDefaultWeapon = null; + }; + private static void TryBind() { if (_getJson != null) return; diff --git a/src/RynthCore.Engine/UI/Panels/MonstersPanel.cs b/src/RynthCore.Engine/UI/Panels/MonstersPanel.cs index c6f72af..2735d9d 100644 --- a/src/RynthCore.Engine/UI/Panels/MonstersPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/MonstersPanel.cs @@ -955,6 +955,14 @@ internal static class MonstersPanel } // ── Plugin export binding ─────────────────────────────────────────────── + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static MonstersPanel() => PluginManager.PluginsUnloaded += () => + { + _getMonstersJson = null; + _setMonstersJson = null; + }; + private static void TryBind() { var plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/NavPanel.cs b/src/RynthCore.Engine/UI/Panels/NavPanel.cs index b1de941..521560f 100644 --- a/src/RynthCore.Engine/UI/Panels/NavPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/NavPanel.cs @@ -552,6 +552,14 @@ internal static class NavPanel // Plugin bridge // ========================================================================= + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static NavPanel() => PluginManager.PluginsUnloaded += () => + { + _getNavJson = null; + _sendNavCommand = null; + }; + private static void TryBind() { var plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/RadarPanel.cs b/src/RynthCore.Engine/UI/Panels/RadarPanel.cs index a6b276f..fa5d42a 100644 --- a/src/RynthCore.Engine/UI/Panels/RadarPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RadarPanel.cs @@ -1319,6 +1319,13 @@ internal static partial class RadarPanel } // ── Plugin export binding ─────────────────────────────────────────────── + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static RadarPanel() => PluginManager.PluginsUnloaded += () => + { + _getRadarSnapshot = null; + }; + private static void TryBind() { if (_getRadarSnapshot != null) return; diff --git a/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs index 11beb08..83dee99 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs @@ -1420,6 +1420,23 @@ internal static partial class RynthAiPanel } } + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static RynthAiPanel() => PluginManager.PluginsUnloaded += () => + { + _getSnapshotJson = null; + _toggleMacro = null; + _setSubsystemEnabled = null; + _selectProfile = null; + _forceRebuff = null; + _cancelForceRebuff = null; + _adjustOpacity = null; + _togglePanelLock = null; + _togglePanelMinimize = null; + _sendNavCommand = null; + _getPatrolInfoJson = null; + }; + private static void TryBind() { LoadedPlugin? plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs index 4f9a518..5252c35 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs @@ -1194,6 +1194,15 @@ internal static class RynthChatPanel internal static bool FloatingSelectionActive => _selDragging; + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static RynthChatPanel() => PluginManager.PluginsUnloaded += () => + { + _getScrollbackJson = null; + _sendLine = null; + _lastSeq = 0; // the fresh copy's scrollback numbers from 1 again + }; + private static void TryBind() { LoadedPlugin? plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/RynthNavPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthNavPanel.cs index ed07009..cc1b530 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthNavPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthNavPanel.cs @@ -200,6 +200,18 @@ internal static class RynthNavPanel } // ── Plugin binding ────────────────────────────────────────────────────────── + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static RynthNavPanel() => PluginManager.PluginsUnloaded += () => + { + _getStatus = null; + _loadTile = null; + _testQuery = null; + _preview = null; + _move = null; + _goto = null; + }; + private static void TryBind() { LoadedPlugin? plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/RynthTrackerPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthTrackerPanel.cs index 0f00ce8..d293269 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthTrackerPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthTrackerPanel.cs @@ -240,6 +240,14 @@ internal static class RynthTrackerPanel return neg ? "-" + sb : sb.ToString(); } + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static RynthTrackerPanel() => PluginManager.PluginsUnloaded += () => + { + _getSnapshotJson = null; + _reset = null; + }; + private static void TryBind() { LoadedPlugin? plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/RynthVisionPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthVisionPanel.cs index 5dc62c7..5fa87f5 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthVisionPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthVisionPanel.cs @@ -267,6 +267,15 @@ internal static class RynthVisionPanel // ── Plugin binding ──────────────────────────────────────────────────────── + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static RynthVisionPanel() => PluginManager.PluginsUnloaded += () => + { + _getSettings = null; + _setSettings = null; + _inspect = null; + }; + private static void TryBind() { LoadedPlugin? plugin = PluginManager.Plugins.FirstOrDefault( diff --git a/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs b/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs index 7c43eb0..bbcb3c3 100644 --- a/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs @@ -1296,6 +1296,14 @@ internal static class SettingsPanel // Plugin bridge // ========================================================================= + // RL loads fresh plugin copies without unloading the old ones: drop the + // exports bound below so the next poll re-binds to the live copy. + static SettingsPanel() => PluginManager.PluginsUnloaded += () => + { + _getSettingsJson = null; + _setSettingsJson = null; + }; + private static void TryBind() { var plugin = PluginManager.Plugins.FirstOrDefault(