From b54cc7536226383aa20568f57326622b59767ade Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 3 Jun 2026 03:48:47 +0800 Subject: [PATCH] feat(automation): --automation-server CLI flag plumbed into GUI --- src/OrcaSlicer.cpp | 10 ++++++++++ src/libslic3r/PrintConfig.cpp | 13 +++++++++++++ src/slic3r/GUI/GUI_Init.hpp | 3 +++ 3 files changed, 26 insertions(+) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 2e445cadfd..278ca3dc99 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -1339,6 +1339,16 @@ int CLI::run(int argc, char **argv) //BBS: remove GCodeViewer as separate APP logic //params.start_as_gcodeviewer = start_as_gcodeviewer; + // UI automation server (opt-in). --automation-server enables it; + // --automation-server-port overrides the default 13619. + ConfigOptionBool* automation_server_option = m_config.option("automation_server"); + if (automation_server_option && automation_server_option->value) { + ConfigOptionInt* automation_port_option = m_config.option("automation_server_port"); + int port = (automation_port_option && automation_port_option->value > 0) ? automation_port_option->value : 13619; + params.automation_port = port; + BOOST_LOG_TRIVIAL(warning) << "UI automation server requested on port " << params.automation_port; + } + BOOST_LOG_TRIVIAL(info) << "begin to launch OrcaSlicer GUI soon"; return Slic3r::GUI::GUI_Run(params); #else // SLIC3R_GUI diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 8fdcede569..8c745789a0 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -10791,6 +10791,19 @@ CLIMiscConfigDef::CLIMiscConfigDef() def->tooltip = L("If enabled, this slicing will be considered using timelapse."); def->set_default_value(new ConfigOptionBool(false)); + def = this->add("automation_server", coBool); + def->label = L("Enable UI automation server"); + def->tooltip = L("Start a localhost JSON-RPC server that lets external scripts " + "drive and observe the GUI. For testing/automation only."); + def->set_default_value(new ConfigOptionBool(false)); + + def = this->add("automation_server_port", coInt); + def->label = L("UI automation server port"); + def->tooltip = L("TCP port for the UI automation server (bound to 127.0.0.1)."); + def->min = 1; + def->cli_params = "port"; + def->set_default_value(new ConfigOptionInt(13619)); + #if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(SLIC3R_GUI) /*def = this->add("sw_renderer", coBool); def->label = L("Render with a software renderer"); diff --git a/src/slic3r/GUI/GUI_Init.hpp b/src/slic3r/GUI/GUI_Init.hpp index 0d987fa014..f7c124e8bf 100644 --- a/src/slic3r/GUI/GUI_Init.hpp +++ b/src/slic3r/GUI/GUI_Init.hpp @@ -32,6 +32,9 @@ struct GUI_InitParams //BBS: remove start_as_gcodeviewer logic //bool start_as_gcodeviewer; bool input_gcode { false }; + + // UI automation: 0 = disabled, else the TCP port for the localhost JSON-RPC server. + int automation_port { 0 }; }; int GUI_Run(GUI_InitParams ¶ms);