* Run the MCP sweep on GNOME Shell and fix its Linux failures
On a GNOME machine without KWin, orca_mcp.py launch --headless and the sweep now start a private GNOME Shell, so the tests run on the GPU instead of falling back to Xvfb. Picking an item far down a long ImGui list, such as a font near the end of the Text tool's list, no longer fails as out of view, and an item only half shown is scrolled into view before it is clicked. window_set restores a minimized window under GNOME Shell on X11, and the sweep's checks no longer depend on a desktop's top bar or on the fonts installed.
* Fix the window_set note unit test failing on every platform
The test slept 60 ms before starting the worker job and expected the call to have found the worker idle by then. On a loaded runner the call's thread could start later, so the job was already running, the call was refused as busy and its reply had no status. The test now waits until the call's change has run, and the call settles until the job starts, so the order holds on any machine.
#17871 made the slic3rutils tests start the production PythonInterpreter, which releases the GIL once Python is up, and gave the existing Python tests ensure_python_initialized() and py::gil_scoped_acquire. Four tests that #17819 added touch Python without the GIL and segfault on every platform. Give them the same two lines; the MCP tests hold the GIL only around the import, since python_api_reference() takes it itself.
# 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)
The Web media controller teardown test crashed because running a page script read the app's
settings before checking for a page. Running a script on a web view with no page now does
nothing on every platform.
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.
- Moonraker's `bind_detect` now builds the device ID from the entered address instead of the connected printer's cached identity, so binding a second printer by IP no longer reselects and reconnects the first one.
- The C11 model fallback for a device bound without a model now applies only to Bambu printers.
widget_list cut a widget's label at 120 bytes, so a long path or tooltip came back truncated, and a test that
read it back failed on a machine with a longer folder; labels now come back whole. Adding or renaming a command
or a sweep test no longer means updating hand-kept lists, copied test helpers or the same text in several docs,
and the runner's own test now fails when a sweep test has no entry in the index.
Thirty-four Design commands were bare verbs (extrude, fillet, measure), so an
agent could not tell from a name where a command acts or find a place's
commands together. Every Design command now starts with its place: design_,
sketch_, solid_, surface_, construct_, body_ or feature_. Replacing objects when
committing a design to the plate deletes them as Prepare's Delete does, and the
guide to making a feature reachable covers Design commands.
Happy Hare can write a lane_data entry for every gate with only the lane number set. Orca took that as the answer and showed every slot empty without asking Happy Hare's mmu object. When every lane is empty, sync now tries Happy Hare and then Creality CFS, and keeps the empty lane layout if neither reports filament. Lane data with filament in it keeps its priority.
The object list deletes an object's ModelObject before its row, and removes the
row's part rows one by one. On macOS each removal makes the outline reload the
object row at once, and GetChildren's import order read the freed ModelObject.
Deleting a multi-part object, or merging its parts with Mesh boolean, crashed
when that memory had been reused.
GetChildren now reads the row's object only while the model still holds it
(ObjectDataViewModel::live_model_object, a pointer comparison). The import order
read came in with #17050, so no release carries the crash.
A part, a modifier or a layer range can set its own outer wall, inner
wall, sparse infill, internal solid infill, top surface or bottom
surface filament. The slicer prints with them, but
PartPlate::get_extruders() and get_extruders_under_cli() read these
settings only from the print and object configs. A filament that only a
part's feature used was missing from the plate's filament list, so on a
dual-nozzle printer the custom grouping dialog left it out and Prepare
hid the prime tower.
Both walks now share a helper that also reads the feature filaments of
each part, modifier and layer range. A mixed filament still expands to
its components as it does for object settings.
A printer switch or a filament delete can leave filament ids past the
last slot. The plate now resolves them as the slicer does. An object's,
part's or layer range's id counts as filament 1, including a part's own
filament. A print-wide id follows PresetBundle::full_config() in the
GUI, which resets a feature or brim id to the default and caps a
support id at the last slot. From the CLI it follows the slicer, which
prints a feature or support id with filament 1.
Fixes#17728
Each place an agent finds commands under (Objects, Plates, View and windows and so on) now has one source file
under Mcp/Tools/, and the Design tab's commands have one file per Design heading, so a developer finds a command
where tool_list lists it and adds a new one beside its neighbours. A unit test fails when a command is added in
another place's file. No change to what agents or people see: the command catalog is byte-identical.
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.
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.
A square drawn on the axes through sketch_draw was locked level on x64 but could be
left free to rotate on arm64, so its constraints and degrees of freedom depended on
the CPU, and the test of them failed on macOS arm64 and Windows arm64. A polygon's
side that lies on an axis is now pinned Horizontal or Vertical on every platform, as
the Polygon tool pins it, so such a square has all four sides pinned.
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.
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.
The ten largest definitions in the tool list repeated much of what their parameters already say. They now
say it once, taking about 4.9 KB off the tool list an agent reads at the start of every session, with
nothing they described left out.
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.
Agents now read an object's position as 60.001 rather than 60.001007080078125, and a Design
command's zero as 0 rather than 4.4e-16, without the wrapper and ok flag that said nothing; a
client that computes with the numbers can still ask for them whole. object_list gives a short row
per object unless asked for detail, so a plate of a hundred objects fits a client's reply limit,
and app_log returns 50 lines by default.
A plugin schema can close an object through a keyword the manual keeps raw, such as allOf. The manual
then no longer says the object, or the call, takes other keys, and leaves the attached schema to say
what it accepts.
Every object in a manual now says whether it takes keys besides its properties, at any depth, as the top
level already did. A plugin schema whose properties can't be read now comes with the raw schema instead of
looking like one that takes no arguments.
An agent reading a manual now learns where a filament's purge mode, a calibration's shaper type, a
hole's point, printer_install's models and dialog_answer's dialog come from, and sees that a plugin
operation can reach outside the app. What a plugin's schema says that the manual can't show, such as a
required argument with no property, now comes with the raw schema, and a schema that takes any argument
says so instead of looking like one that takes none.
settings_get and preferences_get matched an agent's words, so a goal such as "add a brim" found the wrong
settings. Agents now list a settings tab's pages and groups with settings_list_pages, read a page's settings
and what each does with settings_list, and read named settings with settings_get and preferences by tab
with preferences_get.
script_search_api ranked the API by an agent's words, so a goal phrased in other words found the wrong entries.
Agents now list what a module or class holds with script_list_api and read one entry's whole documentation
with script_describe_api.
action_search ranked actions by matching an agent's words, so an action named differently from the request
was missed. action_list lists them by section and title for the agent to choose from, as tool_list does
for commands.
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.
An agent could read a command's arguments only as raw JSON Schema, with its conditional rules left to decode and
no word on where an object index or a face id comes from. tool_describe now gives any command's manual, listed or
not: every parameter at every depth with its allowed values, ranges and defaults, the schema's rules as sentences,
the Speed Dial items that run it with their arguments, its examples, and which tool lists a value the schema can't.
Agents listing the Design tab's commands, or any other group, got bare names and had to look each one up to
choose. tool_search {group} now gives each command's first sentence and, in Design, its heading, in the order
the description's index uses. action_search names the Speed Dial's sections section rather than group, so they
are no longer mistaken for tool_search's groups, and a wrong section is refused with the sections there are
instead of returning nothing.
Design commands were refused with numbers such as -32002 or with no code at all; they now say design_busy,
precondition, invalid_argument, rebuild_failed and the like, so an agent can tell a wrong argument from a design
that is not ready, on every route that takes arguments. Refusals worded for a person, such as an open gizmo or a
selected object, carry a hint naming the call that gets past them, and an index too large for the app or written
as 2.0 is no longer misread as another object, plate or instance.
tests/slic3rutils/test_part_plate.cpp includes slic3r/GUI/PartPlate.hpp,
which reaches wx/wxprec.h and so needs the Windows headers first. Without
them clang-cl stops in wx/msw/private.h on WNDPROC, RGB, VK_SHIFT and
GetWindowRect, and the Windows arm64 build fails.
The slicer target has a precompiled header that supplies those headers and
the test target does not, and MSVC accepts the file anyway, so only the
arm64 build breaks. Windows arm64 is skipped on a pull request that has no
build-windows-arm64 label, so the test merged in #17664 without that leg
ever compiling it.
tests/slic3rutils/test_scene_raycaster.cpp is the only other test in this
target that pulls in the GUI headers, and it opens with the same prelude.
The server-connected handler selects the agent's current machine again every time the cloud
server connects. For a LAN printer this makes the Bambu network plug-in unsubscribe the device,
which drops the LAN session that selecting the printer opened. A connect still in flight fails
with "called UnSubscribeDevice". One that already succeeded stays down with no connect result, so
the printer shows as connected while every command fails with -4 and Print fails with -4030.
Since #17086, OrcaSlicer connects the last LAN Bambu printer at startup, so a LAN user hits this
on most starts. A cloud reconnect later in a session drops the session the same way.
The selection is a cloud subscription, so a LAN printer does not need it. Move the re-select into
DeviceManager::reselect_cloud_machine(), which skips a LAN-mode printer and behaves as before for
any other machine.
Fixes#17766
A misspelt argument to most Design commands was ignored, so the command ran with
its default, such as a helix built with the default pitch. Every Design command now
refuses it and names the arguments it takes. Refusals of a missing object or part,
an unknown setting key, an invalid setting value or a preset that is not installed
now say the valid range, the similar keys, what the setting takes or the command
to use, and plate_add and object_add_handy_model say what they added.
Upload and Print picked the start command's folder from the model that /info reports, and every
unlisted model got /mnt/UDISK. A Nebula Pad reports the printer it is fitted to, such as
"Ender-3 V2 Neo", and keeps its G-code under /usr/data, so its firmware ignored the start.
Before the start, the host now asks the printer for its G-code file list (reqGcodeFile), as
Creality Print does, and starts the upload from the path listed for it. K1-family firmware answers
retGcodeFileInfo and K2-family firmware retGcodeFileInfo2. A list without the upload is asked for
again until files_reply passes. When the printer doesn't list the upload, the model table decides
as before, and it now includes "Ender-3 V2 Neo".
A multi-nozzle printer whose profile never sets physical_extruder_map, such as the Snapmaker U1, carries the single-entry default {0}. PartPlate::get_physical_extruder_by_filament_id indexed it by logical extruder, so Print plate read past its end for any plate that used filament 2 or later, and the Flatpak aborted there.
PartPlate's lookup, the printer sync in Plater and the three calibration setups in CalibUtils now read the map through effective_physical_extruder_map. It returns the profile's map when its length matches the nozzle count and the identity otherwise, so printers that ship a full map get the same values as before. The helper moves unchanged from IMEXHelpers to PrintConfig and PresetBundle, and its tests move to test_config.cpp. The G-code paths are unchanged.
calibration_generate_test always printed with filament slot 1, so an agent could not calibrate another filament of
the project or, on a multi-extruder printer, the nozzle that prints it. It now takes filament_slot, as the
Calibration dialogs' filament list offers, prints on the extruder the filament map gives that filament, and says in
its reply which extruder that is.
A dialog_auto_answer rule with a path cancelled every folder picker on Linux, such as the Preferences
download folder's Browse and the recording dialog's Change..., so a script couldn't pick a folder there and
the sweep's Preferences and Speed Dial tests failed. Folder pickers now take the path as on Windows and
macOS; file pickers still cancel on Linux.
A SPARKX i7 with a CFS Lite reports "cfsConnect": 0 and then answers the slot query. The query stopped at that status, so filament sync found no slots. It now keeps reading for a short no-CFS deadline and treats the printer as having no CFS only when no slots arrive.
* Trim Trailing Zeros at the Decimal Separator wxWidgets Wrote
double_to_string formats with wxNumberFormatter, which writes the UI locale's decimal separator, but trimmed after the C locale's separator. When the two differ, as reported on macOS in Czech and Russian, nothing was trimmed and fields showed 0.2000. Trim at wxNumberFormatter::GetDecimalSeparator() instead.
* Parse Point Fields Whichever Decimal Separator They Show
Point fields write X and Y with the UI locale's decimal separator but read them back with ToDouble, which uses the C locale's. When the two differ, any value with decimals fails with Invalid numeric and resets. Read them with string_to_double_any_separator, which converts the other separator to the C locale's before ToDouble, so every input ToDouble accepted before still parses.
Agents can now read the whole filament list with filament_list, change a mixed filament with filament_edit_mixed,
and set a gradient by driving the Add or Edit Mixed Filament dialog. The slot colours and the flushing settings move
from the project tools to filament_set_colour and filament_set_flushing, beside the rest of the filament list.
Deleting or merging a filament that a mix uses now behaves as it does in the sidebar, and the settings tools no
longer edit a physical filament's preset through a mixed slot.