Files
OrcaSlicer/tools/mcp/tests/ops_open_project.json
T
SoftFever 0616068e26 Run commands, tools and the plugin API through one operations layer
A Speed Dial command, the MCP tool that does the same thing and the plugin
API's preset calls now run one shared operation, so every route accepts and
refuses the same states, with one wording and a code for each refusal. An
import by a command or a tool is one undo step, and import_file adds geometry
only.

The cases where two routes behaved differently now behave the same: a project
is not saved under a .gcode.3mf name, an empty project exports as .3mf but not
as STL, arrange runs from any view and with a gizmo open, a mixed-colour
filament slot is refused as one, a hidden preset is shown before it is
selected, and a layer is refused while the Preview has none.
2026-11-12 22:06:10 +08:00

147 lines
10 KiB
JSON

// Records what opening a project does through its two routes, the load_project command run with run_action and a
// path param, and the open_files tool given a .3mf (as auto): on a clean project, on one with unsaved changes
// (the tool with and without discard_changes) and with unsaved preset changes (top_shell_layers 7). The project
// it opens is saved here first: a cube with wall_loops 5. Each call that may ask runs with "await": false;
// get_app_state lists the question, which the replay answers, by its title, as a person who does not save: No to
// saving the project, Discard for the presets. After each it reads the objects, the project's name and file, the
// presets and their unsaved keys, the recent projects and the tab, and the undo snapshots taken since the last
// read (fixtures/ops_undo.py). Every call it records is optional. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_open_project.json --out <dir>
{
"orca_replay": 1,
"name": "ops open_project",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- The project to open: a cube with wall_loops 5 ----
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
{"tool": "set_settings", "args": {"values": {"wall_loops": 5}}},
{"tool": "save_project", "args": {"path": "${out_dir}/open_src.3mf", "overwrite": true}},
// ---- A clean project: the command ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "home"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:load_project:orca", "param": "${out_dir}/open_src.3mf"}, "await": false, "save_as": "clean_cmd", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.clean_cmd}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- the tool ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "home"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"]}, "await": false, "save_as": "clean_tool", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.clean_tool}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Unsaved project changes (a cylinder), presets clean: the command asks ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "param": "20 10"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:load_project:orca", "param": "${out_dir}/open_src.3mf"}, "await": false, "save_as": "dirty_cmd", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.dirty_cmd}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- the tool, without discard_changes, then with it ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "param": "20 10"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"]}, "optional": true},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"], "discard_changes": true}, "await": false, "save_as": "dirty_tool", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.dirty_tool}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Unsaved preset changes (top_shell_layers 7) on an empty project: the command ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_settings", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:load_project:orca", "param": "${out_dir}/open_src.3mf"}, "await": false, "save_as": "presets_cmd", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.presets_cmd}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "get_settings", "args": {"keys": ["wall_loops", "top_shell_layers"]}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- the tool, without discard_changes, then with it ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_settings", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"]}, "await": false, "save_as": "presets_tool", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.presets_tool}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "get_settings", "args": {"keys": ["wall_loops", "top_shell_layers"]}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_settings", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"], "discard_changes": true}, "await": false, "save_as": "presets_tool2", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.presets_tool2}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "get_settings", "args": {"keys": ["wall_loops", "top_shell_layers"]}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}}
]
}