Repository navigation
feat(commands): command macros: Save As Command, saved commands and Manage Saved Commands (M6) - #338
Open
tanish2k09 wants to merge 8 commits into
Open
tanish2k09 wants to merge 8 commits into
tanish2k09 wants to merge 8 commits into
Conversation
…acro.* commands (M6) Every undo step keeps the commands it ran; Save As Command rewrites ids of this document to act on the selection or active layer, or names the step it can't keep. macro.run is one transactional undo step; macros call only what a plug-in may, and plug-ins can't call macro.*. anicraft-cli run reads saved command files. ADR 0097.
… menu, Manage Saved Commands (M6)
…al and sample names for the catalogs (M6)
… without copying them (M6) find_command rebuilt the whole registry (~360 specs) on every call, and macro.history cloned every recorded command's params to list a step. panic_hunt_every_command (which runs macro.history about 600 times per session over up to 10,000 steps): over 40 min before, 144 s after (debug, Windows, this machine). The CLI test's failing file now selects first.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait...
|
tanish2k09
force-pushed
the
m6/command-macros
branch
from
November 14, 2026 11:18
316f7a4 to
8bf4599
Compare
This branch has not been deployed
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 and why
Command macros (saved commands), the M6 roadmap task, built the way Animate does it: pick steps in the History panel, Save As Command, and they come back at the end of the Commands menu. They run on whatever is selected, as one undo step, and can have a keyboard shortcut. Design: ADR 0097.
(id, params)of the top-level commands that made it: one for a plain edit, all of them for a gesture or a marquee cut plus its edit. Undo and redo carry them along, and a live preview's revert drops what it reverted. A drag's moves add up into one (element.translateis coalesced). Each step is capped at 4096 commands / 1 MiB, and that memory counts against the undo budget.step 4 “Move Points” can't be kept: it works on particular objects of this document. Clipboard steps and plug-in runs are refused the same way.macro.runruns its steps nested. At the first failure it reports“Turn and Fade” stopped at step 3 of 3 (Taller row): … Nothing was changed.and the session restores the document, selection and playhead.plugin_may_call) and nevermacro.*. Plug-ins may not callmacro.*at all, so the two can't recurse into each other.Commands/<name>.jsonin the settings folder ({"format":"anicraft-command","version":1,"steps":[…]}), with the order kept in.order.json. They are small, shareable and read with bounds.anicraft-cli runscripts (bare arrays) are read too.macro.run,macro.list,macro.history,macro.save,macro.rename,macro.move,macro.delete,macro.import. All of them work headless, fromanicraft-cli run/exec, and through MCPanicraft_run. Replacing a file asks first; deleting always asks (ADR 0004).macro:<name>action under Commands, with the usual clash checks; renaming moves its keys and deleting drops them.execute_nested(benefits plug-ins too):executedoes (ADR 0073).Not in this slice
How it was tested
cargo test --workspace: green, 1633 tests after rebasing on main (Windows 10). New tests:macro_tests, 10):file.*,macro.*andplugin.*commands, control characters, every truncation and byte flip of a good file, and hostile params to everymacro.*command.runtakes a saved command file and names the failing step.panic_hunt_every_commandcovers themacro.*commands. It first took over 40 min because ofmacro.historyover 10,000 fuzz steps plusfind_commandrebuilding the registry on every call. After the fix (perf(engine)commit: registry indexed once, history listing checks without copying) it takes 144 s in debug on this machine.cargo clippy --all-targets -- -D warningsandcargo deny check licenses bans sourcesare clean. The pseudo-locale and narrow-dock tests pass, and the History footer wraps at 200 pt.Screenshots
--open savecommand: three edits on the sample picked in History, and Save As Command listing them (1 Rotate 90° CW, 2 Colour Effect, 3 Move), with a name field and Save/Cancel.--open managecommands: Manage Saved Commands with three commands. Each row has a step count, a shortcut (Ctrl+Alt+Ron Quarter Turn), Run, chevron reorder buttons (hidden at the ends), Shortcut…, Rename… and Delete…, followed by Add from File… and the folder.cargo run -- --screenshot shots/now.png: the default window is unchanged, except for the History panel's footer hint.Summary by CodeRabbit