From 8a146aa8c422450177fae069d9d59a0b96757444 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 7 Sep 2026 00:34:34 +0200 Subject: [PATCH] feat(vt): Profiles tab Delete action, bound through the markup contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Campaign VT slice 1 Part A round 2 step 5: the Profiles tab's action set (Create/Select/Save/Delete/name field/mine-only) was missing Delete entirely — every profile family only ever had Create/Copy/Clear. Adds MossTankProfileStore.Delete (removes the selected named profile's real .usd file and its side-car, falls back to "By char"; refuses for "By char" itself, which has nothing to delete — see ClearCurrent for that case) and wires it through MossTankPanel.DeleteProfile to a new "Delete" button in mosstank.xml, next to "Clear profile!". Create/Select/the name field/the mine-only toggle already bind to the directory-backed store from steps 1-4; this closes the one missing verb. Mutation shown to fail: Delete short-circuited to always refuse made DeleteProfileRemovesTheRealFileAndFallsBackToByCharacter fail (selection stayed on the named file instead of falling back); restored, it passes along with the By-char refusal companion test. The markup contract's interactive-control count was updated for the new button (190 -> 191). 595 MossTank tests passing (was 593). Co-Authored-By: Claude Fable 5.1 --- src/AcDream.Plugins.MossTank/MossTankPanel.cs | 12 +++++++ .../MossTankProfileStore.cs | 27 ++++++++++++++ src/AcDream.Plugins.MossTank/mosstank.xml | 3 ++ .../MossTankMarkupContractTests.cs | 2 +- .../MossTankPanelTests.cs | 36 +++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) diff --git a/src/AcDream.Plugins.MossTank/MossTankPanel.cs b/src/AcDream.Plugins.MossTank/MossTankPanel.cs index 787abb9c6..cb6983af8 100644 --- a/src/AcDream.Plugins.MossTank/MossTankPanel.cs +++ b/src/AcDream.Plugins.MossTank/MossTankPanel.cs @@ -850,6 +850,7 @@ internal sealed partial class MossTankPanel public Action CreateProfile => () => CreateProfileCore(copyCurrent: false); public Action CopyProfile => () => CreateProfileCore(copyCurrent: true); public Action ClearProfile => ClearProfileCore; + public Action DeleteProfile => DeleteProfileCore; public Action ToggleMineOnly => () => { string before = _profiles.Selected; @@ -3465,6 +3466,17 @@ internal sealed partial class MossTankPanel ResetProfileConsumers(); } + private void DeleteProfileCore() + { + if (!_profiles.Delete(out string notice)) + { + _profileLifecycleNotice = notice; + return; + } + LoadSelectedProfile(); + _profileLifecycleNotice = notice; + } + private void LoadSelectedProfile() { _profiles.LoadCurrent(_allSettings, _noBuffItemNames); diff --git a/src/AcDream.Plugins.MossTank/MossTankProfileStore.cs b/src/AcDream.Plugins.MossTank/MossTankProfileStore.cs index 003bfc4ce..40d0c03ae 100644 --- a/src/AcDream.Plugins.MossTank/MossTankProfileStore.cs +++ b/src/AcDream.Plugins.MossTank/MossTankProfileStore.cs @@ -217,6 +217,33 @@ internal sealed class MossTankProfileStore return true; } + /// + /// Deletes the currently selected named profile's .usd file and + /// its side-car, then falls back to . Refuses + /// for itself — there is no file to delete, + /// only a reset (see ). + /// + public bool Delete(out string notice) + { + if (_selected.Equals(ByCharacter, StringComparison.OrdinalIgnoreCase)) + { + notice = "'By char' is the built-in character profile and cannot be deleted."; + return false; + } + string fileName = _selected; + if (VtankStorage.IsAvailable) + VtankStorage.Delete(fileName); + if (_host.Storage.IsAvailable) + _host.Storage.Delete(SideCarKey(fileName)); + _selected = ByCharacter; + _pendingLegacyBareName = null; + _currentDatabase = null; + _currentDatabaseFileName = null; + WriteBinding(); + notice = $"Deleted profile {fileName}."; + return true; + } + public void LoadCurrent( VtankSettingsProfileSerializer.AllSettings settings, ISet noBuffItemNames) diff --git a/src/AcDream.Plugins.MossTank/mosstank.xml b/src/AcDream.Plugins.MossTank/mosstank.xml index 84dfdd7b4..f89fcff1a 100644 --- a/src/AcDream.Plugins.MossTank/mosstank.xml +++ b/src/AcDream.Plugins.MossTank/mosstank.xml @@ -136,6 +136,9 @@ onclick="{CreateProfile}" />