feat(automation): --automation-server CLI flag plumbed into GUI

This commit is contained in:
SoftFever
2026-06-03 03:48:47 +08:00
parent 9d915c4e76
commit b54cc75362
3 changed files with 26 additions and 0 deletions

View File

@@ -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<ConfigOptionBool>("automation_server");
if (automation_server_option && automation_server_option->value) {
ConfigOptionInt* automation_port_option = m_config.option<ConfigOptionInt>("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

View File

@@ -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");

View File

@@ -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 &params);