Commit Graph
13 Commits
Author SHA1 Message Date
SoftFever d42123d2f1 Fix hang when MCP clicks an open printer selector (#17913)
# Description

When an MCP client clicked the printer selector on the Device or
Calibration tab while its printer list was already open, OrcaSlicer
froze at full CPU on macOS and Linux and had to be force-quit. A
person's mouse can't trigger it, because the open list takes the click
and closes before the selector sees it, but an MCP click goes straight
to the selector. That click now closes the list, as a person's click
does, and Orca's popups no longer hang on macOS and Linux when they are
asked to open while already open. The hung call's reply was misleading
as well: it said the call had not run and was safe to retry, although
its click had run. A call that has already acted now says it may have
done some or all of what was asked, and to check with `app_state` before
calling it again.

**Included:**
- **GUI:** the Device and Calibration printer selectors close their open
list on a click; `PopupWindow` ignores a second open on macOS and Linux.
- **MCP:** "not run, safe to retry" is reported only while no step of
the call has run.
- **Tests:** an automation test for the MCP reply and a slic3rutils test
for the popup.
- **Docs:** the MCP server design doc and the orca-wxwidgets skill's
popup pages.

A person's clicks behave as before on every platform, and Windows popup
behaviour is unchanged.

# Screenshots/Recordings/Graphs

<!--
> UI changes need before and after screenshots, on each platform you
tested.
> See what each kind of PR needs:
https://github.com/OrcaSlicer/OrcaSlicer/blob/main/CONTRIBUTING.md#what-each-kind-of-pr-needs
> For other changes, please attach images that can help explain them.
-->

## Tests

- Reproduced the hang on macOS over MCP with two `widget_click
{target:{class:"SideToolsPanel"}}` calls on the Device tab. With the
fix, repeated clicks open and close the list, each reply comes back in
under 100 ms, and the app stays idle and answers `app_state` afterwards.
- New tests: "a call says it was not run only until a step of it has
run" (automation) and "a popup never links its event handlers to
themselves and a second click on its control closes it" (slic3rutils).
With the popup guard disabled, the popup test fails and still runs to
the end instead of hanging.
- On this branch, macOS arm64 Release: the build passes, the automation
suite passes (186 test cases) and the slic3rutils `[Mcp]` tests pass
(508 test cases).
- Windows and Linux were not built or run; their code paths were checked
against wxWidgets' source.

<!--
> A guide for users on how to download the artifacts from this PR.
-->

[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
2026-11-26 20:51:59 +08:00
SoftFever b3dcf0ac7d Ask before a plugin calls OrcaSlicer's tools
Any plugin could call OrcaSlicer's tools through orca.host.tools without a permission, so it could change your project, run post-processing scripts and answer permission prompts. It now needs the OrcaSlicer tools permission or full access, which it can declare as it loads or is asked for the first time it calls, like its other permissions. The Plugins dialog's Permissions tab has a switch for it, and turning it off ends what the plugin's calls left in force.
2026-11-26 02:56:29 +08:00
SoftFever 5eefef82fc Add the Agent Activity pane
A new pane, opened from View > Agent Activity or the Speed Dial, lists live what an AI agent and other
automation (Action Replay, Run Script, the command line, plugins) do in OrcaSlicer while it is open: each
call with its source, what it changed, failures with their reason, the steps of a run and the dialogs a
rule answered. Opening a call shows its request and response with passwords, keys and typed text masked,
so a person can watch and check what an agent is doing to their project.
2026-11-24 16:38:50 +08:00
SoftFever a0db07311b Fix two unit tests that failed at random on CI
The plugin-unload test of the automation suite and the in-flight tool call
test of the Python script runner each failed now and then on a busy runner,
macOS arm64 and Linux aarch64 in the last run, with nothing wrong in the app.
Both pass however the runner schedules their threads.
2026-11-23 21:38:37 +08:00
SoftFever 82d1f6adfa Fix the CI failures from the first build and test run of the MCP branch
The Flatpak build failed to compile the MCP bridge, clang-tidy flagged four missing
includes, and several new tests failed only on CI: plugin and script tests on Windows
runners with a non-UTF-8 code page, and two tests that raced on slower machines.
2026-11-23 19:10:16 +08:00
SoftFever e6250eca57 Let MCP commands name objects, parts and instances by id
An agent that read an object's id in object_list could only pass it as a guard beside the index, and the index moves
whenever objects are deleted, split or reordered; an id passed as an index was refused without saying what it was.
Every command that names an object, a part or an instance now takes its index or its id, both together still a
guard, and object_list gives each instance's id too. An id given as an index is refused with what that id names, and
recorded replays keep naming targets by index, so they still run in a new session.
2026-11-23 00:06:23 +08:00
SoftFever 3283fa0016 Mark names as code in the MCP tool descriptions
Agents can tell an argument or a reply field from an English word in every tool description. The
server instructions say what the Speed Dial is, a call held by a dialog says how to run it without
asking next time, and object_add_text and object_add_svg say what they reply.
2026-11-22 22:01:16 +08:00
SoftFever b85dbded55 List the commands tools/list leaves out with tool_list, in place of tool_search
tool_search matched words, so an agent that asked for a goal such as "add a brim" or "round the edges"
got unrelated commands. Agents now read tool_list, which lists the Design tab's commands, the menu items
that take no arguments and the plugins' operations with what each does, and a call refused for its
arguments names the tool_describe call that gives that command's parameters.
2026-11-22 17:56:09 +08:00
SoftFever 28203ae06d Keep MCP calls reliable on a busy machine
When the computer was busy, agents saw calls fail that work on a quiet one. A right click's context menu could open
on screen instead of reaching the call, a click could find a button still disabled, a call could report it was
blocked by a dialog an auto-answer rule had already answered, the first call through the stdio bridge could be
refused while the app it started was still loading, and a replay could fail waiting on a step that had finished.
Each of these now waits for the app to catch up instead.
2026-11-20 15:04:12 +08:00
SoftFever 6cd2ce1a2e Check every area of the MCP sweep with Python tests that read each step back
The sweep's objects, presets, filaments, settings, project files, slicing, gizmos and GUI tools are tested by Python
tests that compare the app's state after every step with the values their entries write out, in place of the
replays, and the existing tests' checks that could not fail now can. The calls these tests found wrong now behave
as described: moving one instance no longer sinks the others, a toolpath export writes the layers shown, an
auto-answered dialog no longer reports its call blocked, and a web dialog that has just opened takes requests.
2026-11-19 13:49:20 +08:00
SoftFever d64e10f4dd Regroup the slicer's MCP commands and let each run from its arguments
Outside the Design tab an agent had 175 commands, 50 of them in the tool
list. There are now 118, named by what they act on (`object_`, `plate_`,
`preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes
its target and values in the call, acts on the selection when it names no
target and says what it acted on; an old name is refused. Printers and
system filaments install and uninstall, preferences read and write, plugins
enable, reload, uninstall and refresh, and objects reorder, with no dialog
to drive.

The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the
rows these commands share with the menus are fixed. For a person: an object
row that cannot run says why instead of "Select an object first.", rows
that failed no longer claim success, Duplicate Plate can be undone, and
Refresh Plugins picked while a refresh runs now runs after it instead of
beside it.
2026-11-18 16:50:32 +08:00
SoftFever bf85189501 Cut the MCP test sweep's run time without losing coverage 2026-11-15 14:33:01 +08:00
SoftFever fece418ae0 Make the automation runtime its own subsystem, with MCP as one front end
Everything that drives OrcaSlicer by command (the dispatch of the command
catalog, jobs, the journal, replays, Python scripts, recordings) lived
inside the MCP server's service class. So Action Replay, the Run Script
panel, a plugin's tool call, a person's recording and a run from the
command line each had to start "the MCP service", with all of its GUI
hooks, although none of them needs a server or an agent.

The automation runtime is now a subsystem of its own. It starts the first
time a front end asks for it and knows none of them. The MCP endpoint
(HTTP, the protocol, the token, the discovery file, the takeover of a port
another window holds) is one front end beside the others, opened and
closed without stopping what the others run. The widget inspector, menu
capture and ImGui item recording are turned on only by a front end that
drives the GUI, so a person's recording or long command does not carry
them.

The part of the runtime that needs no GUI is the library
libslic3r_automation, built without wxWidgets and tested by its own suite,
automation_tests. A wx dependency in it fails to build, and its tests no
longer link the GUI library or the embedded Python.

The command line has one option set for this: --run FILE runs a replay or
a Python script once the GUI is ready, with --outputdir for its files, and
--unrestricted-scripts and --cad turn their settings on for one run
without saving them. --mcp-run, --mcp-run-out and --mcp-token are gone;
the scripts setting is python_scripts_unrestricted and a session's output
folder is <datadir>/automation/out. get_app_state reports ready and
version at the top level, and its mcp block describes the endpoint only.

No change to slicing output.
2026-11-14 23:41:01 +08:00