fix(strategies): empty a folder before deleting it on the core - #550
Merged
Conversation
Right-click -> Delete on a folder that still held (disabled) strategies
did nothing: the terminal sent only `TStratDelete(0, path)`, and the core
refuses that for a populated folder with a log line and no reply event
("Folder delete request ... (not empty or not found)"). The wire has no
command that removes a folder together with its contents, and omission
from the folder tree cannot remove a folder a retained strategy occupies.
`delete_folder` now queues a `DeleteStrategy` for every row under the
folder - all confirmed disabled by the guard - and then the folder
command, in the same per-core FIFO the feed drains in order, so the core
reads the folder delete once the folder is empty. Selection is cleared of
the deleted rows as for a plain strategy delete.
Three doc comments claimed the legacy command deletes the contents; they
now state what the core does. A source-grep test pins the ordering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Right-click → Delete on a strategies folder that still held (disabled) strategies did nothing: the confirmation closed, the folder stayed on the core. The terminal sent only
TStratDelete(0, path), and the core refuses that for a populated folder — its log saysFolder delete request … Demo (not empty or not found)and no reply event reaches moonproto, so the UI had nothing to show. Per moonprotodocs/strats.md, the legacy command deletes an empty folder only, and omission from the folder tree cannot remove a folder a retained strategy occupies: there is no wire command that removes a folder together with its contents.StrategiesView::delete_foldernow queues aDeleteStrategyfor every row under the folder (subfolders included; all confirmed disabled by the existingfolder_delete_authorizedguard) and then the folder command, in the same per-core FIFO the feed drains in order, so the core reads the folder delete once the folder is empty. Selection state is cleared of the deleted rows as for a plain strategy delete. Three doc comments that claimed the legacy command deletes the contents now state what the core does; a source-grep test pins the row-then-folder ordering.Notable decisions
delete(0, path)rather than a folder-tree omission even on cores with a versioned tree: at drain time the local snapshot still holds the rows (no echo yet), and the protocol keeps a folder a retained strategy occupies. The legacy command deletes an existing empty folder on either kind of core, and moonproto applies its echo to the versioned tree.Known limitations
strategies/tree/dnd.rscut/paste cleans an emptied source folder withdelete_empty_folder(…, Vec::new()); the feed guard compares the core's live placements with that empty list, so on any core holding a strategy the command is skipped.Issues
None of the 16 open issues is touched by this change.
How to verify
fmt check exit 0 · build exit 0 · clippy: no new finding (the 6 locations reported in the two touched moon-core files are the same 6 on a detached
origin/main, shifted by the inserted comment lines) · tests: moon-core 1961 + moon-ui-gpui 1816 + 333 passed, 0 failed · FireTest not run (no chart/render/window/input surface).Live: on a real core, Delete on a folder with disabled strategies → app log shows
delete strategy …×N followed bydelete folder <path>, the core log showsStrategy deleted×N and no(not empty or not found).🤖 Generated with Claude Code