Skip to content

fix(strategies): empty a folder before deleting it on the core - #550

Merged
guyverino merged 1 commit into
mainfrom
fix/strategies-folder-delete-populated
Sep 13, 2026
Merged

fix(strategies): empty a folder before deleting it on the core#550
guyverino merged 1 commit into
mainfrom
fix/strategies-folder-delete-populated

Conversation

@guyverino

Copy link
Copy Markdown
Collaborator

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 says Folder delete request … Demo (not empty or not found) and no reply event reaches moonproto, so the UI had nothing to show. Per moonproto docs/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_folder now queues a DeleteStrategy for every row under the folder (subfolders included; all confirmed disabled by the existing folder_delete_authorized 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 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

  • The populated case finishes with the legacy 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.
  • Another client adding a row between confirmation and the drain makes the core refuse the folder command — the folder stays, nothing else is lost. That is the accepted failure mode.
  • The "enabled strategies inside" rule is unchanged: a folder with any enabled strategy still refuses with the existing notice, and the confirmation is revalidated against the live snapshot on Yes.

Known limitations

  • The core still gives no reply event on a refused folder delete, so a refusal remains visible only in the core's own log.
  • Spotted, not touched (separate topic): strategies/tree/dnd.rs cut/paste cleans an emptied source folder with delete_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

cargo fmt --all -- --check
cargo build -p moon-ui-gpui --bin moonterminal --target x86_64-pc-windows-msvc --all-targets
cargo clippy -p moon-ui-gpui --bin moonterminal --target x86_64-pc-windows-msvc --all-targets -- -D warnings
cargo test -p moon-core --target x86_64-pc-windows-msvc
cargo test -p moon-ui-gpui --target x86_64-pc-windows-msvc

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 by delete folder <path>, the core log shows Strategy deleted ×N and no (not empty or not found).

🤖 Generated with Claude Code

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.
@guyverino
guyverino merged commit 0d9da43 into main Sep 13, 2026
6 checks passed
@guyverino
guyverino deleted the fix/strategies-folder-delete-populated branch September 13, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant