mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
The MCP drawing tools ran the creating command (path.create, shape.*) and only then paint.setFill, paint.setStroke, stroke.set, object.setProps and effect.apply, each as a command of its own. check_draw_options checked dash, cap, join, opacity, name and effects up front, but not the paints: a fill or stroke the engine can't read (stroke: "currentColor"), or a swatch the document lacks, failed after the object was made, so the call returned an error and left the path, its undo step and its SVG node behind. Each styling command was also an undo step of its own. The tools now send the creating command and the styling commands as one command.batch (crates/mcp/src/tools.rs, draw): the engine rolls the whole batch back when a step fails, so a refused paint leaves no object, no undo step and nothing in the SVG, and a good call is one undo step named as the creating command names its own (Pen, Rectangle, …). The styling steps act on the new object, which the creating command selects, with item: null (its whole appearance), as the ids did before. The reply gives the failed step's own error, without the batch's prefix. docs/mcp.md says so. Test: tests_drawopts::a_bad_paint_draws_nothing (invalid fill, stroke, a missing swatch and a non-numeric strokeWidth on draw_path and draw_shape: error, node count, undo history and SVG export unchanged; a good call adds one undo step named Pen / Rectangle). It fails without the change (draw_path with stroke "currentColor" drew a path) and passes with it; the other draw option and command_batch tests still pass.