gum-tool-delete-logic
Skill659 starsChanged 2 months agoMITView on GitHub
Gum delete architecture. Triggers: delete commands, IEditCommands delete methods, IDeleteLogic, DeleteLogic, DeleteOptionsWindow, HandleDeleteCommand, AskToDeleteState, AskToDeleteStateCategory, DeleteSelection.
In this repository69 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- debuggingSkill
- frb-build-verificationSkill
- frb-pixel-harnessSkill
- gum-architecture-layersSkill
- gum-bundleSkill
- gum-cliSkill
- gum-cross-platform-unificationSkill
- gum-docs-writingSkill
- gum-file-pathsSkill
- gum-forms-behaviorsSkill
- gum-forms-controlsSkill
- gum-forms-default-visualsSkill
- gum-forms-itemscontrolSkill
- gum-forms-theme-importSkill
- gum-iconsSkill
- gum-issue-creationSkill
- gum-kernsmith-integrationsSkill
- gum-layout-engineSkill
- gum-layoutSkill
- gum-localizationSkill
- gum-monogame-renderingSkill
- gum-monthly-releaseSkill
- gum-project-versioningSkill
- gum-property-assignmentSkill
- gum-raylib-renderingSkill
- gum-releaseSkill
- gum-runtime-animation-chainsSkill
- gum-runtime-bindingSkill
- gum-runtime-fontsSkill
- gum-runtime-hot-reloadSkill
- gum-runtime-syntax-versionSkill
- gum-runtime-systemmanagers-initSkill
- gum-runtime-topologySkill
- gum-runtime-variable-referencesSkill
- gum-samplesSkill
- gum-serviceSkill
- gum-source-linked-projectSkill
- gum-themingSkill
- gum-tool-animationsSkill
- gum-tool-codegenSkill
- gum-tool-copy-pasteSkill
- gum-tool-dialogsSkill
- gum-tool-errorsSkill
- gum-tool-file-watchSkill
- gum-tool-font-generationSkill
- gum-tool-import-from-gumxSkill
- gum-tool-loggingSkill
- gum-tool-outputSkill
- gum-tool-pluginsSkill
- gum-tool-save-classesSkill
- gum-tool-screenshotsSkill
- gum-tool-selectionSkill
- gum-tool-tree-viewSkill
- gum-tool-undoSkill
- gum-tool-variable-gridSkill
- gum-tool-variable-referencesSkill
- gum-tool-viewmodelsSkill
- gum-unit-testsSkill
- gum-variable-deep-diveSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 58
After removing instances, selection must fall back to a surviving sibling → parent instance → owning element, or the editor goes blank.
- Very specific: line 62
All delete actions funnel through IEditCommands:
- Very specific: line 70
Do not call IDeleteLogic methods directly from UI code — always go through IEditCommands.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gum Delete Logic Reference
Two Delete Patterns
There are two distinct delete flows depending on the object type being deleted.
Pattern 1 — AskTo* (states and categories)
Used for states and state categories. These types have blocking conditions that must be checked before any dialog is shown, so they have their own typed methods on IEditCommands.
Flow: IEditCommands.AskTo* → validate (behavior deps, plugin hooks, default-state check) → simple Yes/No dialog → undo lock → IDeleteLogic.Remove*
Entry points:
IEditCommands.AskToDeleteState(stateSave, stateContainer)IEditCommands.AskToDeleteStateCategory(category, container)
Why not DeleteOptionsWindow: States and categories are in-memory only — no XML files, no child hierarchy — so plugins have nothing to contribute to the delete dialog.
Pattern 2 — DeleteSelection (elements, behaviors, instances)
Used for screens, components, behaviors, and instances. All go through one shared entry point that dispatches based on what is currently selected.
Flow: IEditCommands.DeleteSelection → undo lock → IDeleteLogic.HandleDeleteCommand → DoDeletingLogic → ShowDeleteDialog (creates DeleteOptionsWindow) → IDeleteLogic.Remove*
Entry point: IEditCommands.DeleteSelection()
Why DeleteOptionsWindow: Plugins contribute runtime UI to this dialog (e.g. DeleteObjectPlugin adds "Delete XML file?" and "Delete children?" options via the DeleteOptionsWindowShow plugin event).
Responsibility Split
| Class | Responsibility |
IEditCommands / EditCommands | All user-triggered deletes. Shows dialogs, acquires undo locks, then delegates to IDeleteLogic. Only entry point callers should use. |
IDeleteLogic / DeleteLogic | Pure data mutation after confirmation. Remove* methods do not show dialogs. HandleDeleteCommand is the exception — it orchestrates the DeleteOptionsWindow flow and is only called from EditCommands.DeleteSelection. |
Contributing an option to DeleteOptionsWindow
DeleteOptionsWindowShow and DeleteConfirmed are declared on WpfPluginBase, not PluginBase — a
plugin contributing a delete option must derive from it.
Both fire once per batch with the full objectsToDelete array, while ElementDelete fires once
per element. Their relative order is not stable either: NotifyConfirmed runs before removal in
PerformConfirmedMixedTypeDelete and after it in DoDeletingLogic's elements-only branch. Keep both
handlers pure functions of the element rather than relying on ordering across them.
A checkbox cached in a plugin field leaks state across deletes: a cancelled delete never fires
DeleteConfirmed, and DeleteOptionsWindow.CloseWithResultFalse clears MainStackPanel.Children
without touching the plugin's field, so the next delete reads a stale checked value. Reset the field at
the top of DeleteOptionsWindowShow.
Post-delete selection
After removing instances, selection must fall back to a surviving sibling → parent instance → owning element, or the editor goes blank. Both the single-instance (PerformConfirmedSingleInstanceDelete) and multi-instance (PerformConfirmedMixedTypeDelete) paths funnel through one helper, SelectAfterInstanceRemoval.
Callers
All delete actions funnel through IEditCommands:
- Delete key →
HotkeyManager→IEditCommands.DeleteSelection - Element tree right-click Delete →
ElementTreeViewManager→IEditCommands.DeleteSelection - State tree right-click Delete state →
StateTreeViewRightClickService→IEditCommands.AskToDeleteState - State tree right-click Delete category →
StateTreeViewRightClickService→IEditCommands.AskToDeleteStateCategory - Menu strip Remove > Element →
MenuStripManager→IEditCommands.DeleteSelection - Menu strip Remove > State/Category →
MenuStripManager→IEditCommands.AskToDeleteState/AskToDeleteStateCategory
Do not call IDeleteLogic methods directly from UI code — always go through IEditCommands.
A key handler that deletes matches through IHotkeyManager.IsDeletePressed (or PlatformKeys.IsDelete in AvaloniaDataUi), never Delete.IsPressed or Key.Delete. A Mac keyboard's "delete" key arrives as Backspace, which only those helpers accept.
Testability
DeleteLogic (headless, Tools/Gum.Presentation/Managers/DeleteLogic.cs) delegates dialog display to the head-provided IDeleteDialogService: the WPF DeleteDialogService (Gum/Services/Dialogs/DeleteDialogService.cs) creates the DeleteOptionsWindow and calls ShowDialog(), and AvaloniaDeleteDialogService (Tool/Gum.Avalonia/Dialogs/) shows the neutral DeleteOptionsDialogViewModel through IDialogService — neither can be unit-tested directly. The internal BuildDeleteDialogMessage(Array, List<InstanceSave>?) method on DeleteLogic is the testable seam for asserting dialog message content (InternalsVisibleTo("GumToolUnitTests") is already configured).
Key Files
| File | Purpose |
Gum/Commands/IEditCommands.cs | Interface with architecture overview comment |
Gum/Commands/EditCommands.cs | Implementation; AskTo* dialog logic lives here |
Tools/Gum.Presentation/Managers/IDeleteLogic.cs | Interface for pure data-mutation operations |
Tools/Gum.Presentation/Managers/DeleteLogic.cs | Data mutation + delete-dialog orchestration via IDeleteDialogService |
Gum/Services/Dialogs/DeleteDialogService.cs | WPF shell (frozen): creates/shows DeleteOptionsWindow, calls the concrete PluginManager |
Tool/Gum.Avalonia/Dialogs/AvaloniaDeleteDialogService.cs | Avalonia head: shows DeleteOptionsDialogViewModel through IDialogService |
Tools/Gum.Presentation/Logic/ReferenceTypes.cs | ElementReferences class; GetDeleteImpactDetails() and ExcludeContainersBeingDeleted() used to build impact warnings in the delete dialog |
Tools/Gum.Presentation/Logic/ReferenceFinder.cs | GetReferencesToVariable() — enumerates every instance-level assignment of a variable project-wide, including through the inheritance chain; used by DeleteVariableService.GetIfCanDeleteVariable to block variable deletes today |
Gum/Plugins/InternalPlugins/Delete/DeleteObjectPlugin.cs | Contributes "Delete XML?" and "Delete children?" to DeleteOptionsWindow |
Gum/Plugins/InternalPlugins/StatePlugin/StateTreeViewRightClickService.cs | State/category right-click menu; calls AskTo* methods |
Gum/Plugins/InternalPlugins/TreeView/ElementTreeViewManager.RightClick.cs | Element tree right-click; calls DeleteSelection |
Gum/Managers/HotkeyManager.cs | Delete key handler; calls DeleteSelection |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

