Skip to content

Integrate Flutter CLI connection gateway - #985

Open
LuckZAE wants to merge 48 commits into
mainfrom
feature_dartCli
Open

LuckZAE wants to merge 48 commits into
mainfrom
feature_dartCli

Conversation

@LuckZAE

@LuckZAE LuckZAE commented Oct 10, 2026

Copy link
Copy Markdown

Description

  • Adds the connection-gateway runtime, process management, HTTP/WebSocket transport, JSON-RPC protocol, account adapter, and device adapter used by the Flutter CLI integration.
  • Routes device, account, and pre-print workflows through Snapmaker Connect while removing the obsolete direct SSWCP/login/dialog paths.
  • Adds platform packaging, bundle staging, installer cleanup, and gateway regression coverage.
  • Hardens service lifecycle, JSON-RPC parsing, error conversion, device URL encoding, and empty filament-slot rendering.

Screenshots/Recordings/Graphs

Not applicable; this is primarily a runtime/integration change without a new user-facing screen.

Tests

  • cmake --build build --target gateway_tests --config Release
  • ctest --test-dir build -C Release -R "^gateway:" --output-on-failure
  • Result: 49/49 gateway tests passed.
  • Windows installer generation was completed locally. Manual install, gateway launch, and uninstall validation is still pending in an interactive Windows session.

@LuckZAE
LuckZAE force-pushed the feature_dartCli branch 4 times, most recently from 12ea688 to 629765a Compare October 12, 2026 17:52
LuckZAE and others added 26 commits October 13, 2026 17:17
- New Utils/GatewayDevice: device-facing queries per the snapmaker_connection API contract (WS machine.system_info), no SSWCP/PrintHost dependency; home for future interface migrations
- GatewayService: add request_sync() synchronous JSON-RPC whose callback completes on the websocket thread, safe from any thread including the UI thread
- GUI_App: m_gateway_service now shared_ptr, gateway_service() accessor
- Plater: nozzle-sync and filament-sync entry points query machine info via the gateway and accept a gateway-connected device in their guards
- SSWCP untouched: the legacy connect flow keeps SSWCP::query_machine_info
Consume gateway machine snapshots for active-device state, filament and nozzle info, including building snapshots from device print-task config objects, with protocol/service/snapshot tests.

Remove the legacy device paths this replaces: AppConfig DeviceInfo storage, the MQTT-agent, machine-manage and cache WCP bridges, the WebSocket debug server, Bonjour machine find, and the runtime Flutter web resource updater/import flow.
- Resolve the CLI executable name per platform and architecture
- Report the configured executable name in process manager errors
- Ignore locally placed CLI binaries under resources/
The token-keepalive core of 0ffba32 (#809) was already replaced by the gateway account subscription; this drops its two now-unused zh_CN strings and the login-confirmation dark-mode color mapping. The unrelated flutter-web URL refactor and websocket cleanup from that commit stay.
@zhangzhend0ng

Copy link
Copy Markdown
Collaborator

VERDICT: APPROVE_WITH_COMMENTS

Findings

# Location Severity Issue & suggested fix Evidence
1 src/slic3r/GUI/GUI_App.cpp sync_gateway_region_after_wizard QUESTION set_region() performs a synchronous HTTP POST with a 5s total timeout on the GUI thread after the wizard. This can freeze the UI for seconds on a slow gateway. Move it to a worker thread (like refresh_gateway_account) and marshal back, or document why blocking is acceptable here. const auto result = m_gateway_service->set_region(region);
2 src/slic3r/GUI/GUI_App.hpp + refresh_gateway_account QUESTION m_gateway_account_refresh_workers accumulates std::thread objects until shutdown; completed workers are never joined/removed. Long-lived sessions with repeated account notifications leak OS thread resources. Join-and-remove completed workers, or use std::async/a thread pool. std::vector<std::thread> m_gateway_account_refresh_workers;
3 src/slic3r/Utils/GatewayService.cpp request_sync QUESTION Response can complete after wait_for returns timeout but before pending_requests_.erase(id); the future result is then discarded and the caller gets a false timeout. Re-check future readiness after acquiring pending_mutex_, or keep a shared state and only erase if still pending. if (future.wait_for(timeout) != std::future_status::ready) {\n std::lock_guard<std::mutex> lock(pending_mutex_);\n pending_requests_.erase(id);\n result.error = {GatewayErrorCode::TransportError, "request timed out"};\n return result;\n}\nreturn future.get();
4 src/slic3r/Utils/GatewayService.cpp constructor QUESTION Project convention (SnapmakerOrca standards) is error codes, no exceptions. This new constructor throws std::invalid_argument. If a build ever enables -fno-exceptions, this will not compile; more importantly it breaks the module’s established bool/int error-code style. Return an invalid object or fail creation through a factory. throw std::invalid_argument("GatewayService dependencies must not be null");
5 src/libslic3r/SSWCPProtocol.cpp MINOR Project coding standards prohibit structured bindings; this reformatted hunk retains one. Replace with explicit .first/.second access or a small struct. for (const auto& [number, text] : std::vector<std::pair<double, const char*>>{{0.2, "0.2"}, {0.4, "0.4"}, {0.6, "0.6"}, {0.8, "0.8"}}) {

Checklist coverage

  • Applied: projects/snapmaker-orca/coding-standards.md, cpp/memory/raii.md, cpp/memory/ownership.md, cpp/correctness/const-correctness.md, cpp/correctness/type-safety.md, cpp/correctness/undefined-behavior.md, cpp/correctness/integer-safety.md, cpp/concurrency/thread-safety.md, cpp/functions/parameter-validation.md, common/security/input-validation.md, cpp/build/cmake-include-hygiene.md, cpp/build/package-management.md, cpp/build/toolchain-and-compiler-flags.md, cpp/api/abi-compatibility.md, cpp/architecture/module-boundaries.md, cpp/architecture/layering-and-dependency-inversion.md, cpp/correctness/class-hierarchies.md, cpp/correctness/exception-safety.md, cpp/correctness/format-strings.md, cpp/error-handling/result-vs-exception.md, cpp/lifetime/dangling-references.md, python/correctness/type-hints-and-mypy.md, Module: gui, Module: print-engine, Module: slicing-algo, cpp/third-party/wxwidgets-3-1-5.md (UI portions), cpp/third-party/qt6-core.md/qt6-qml.md (N/A).
  • Partially applied: cpp/debugging/sanitizer-triage.md, cpp/testing/* (no sanitizer/TSan evidence in diff).
  • Coverage incomplete: src/slic3r/GUI/SSWCP.cpp hunk has no body in the supplied diff; new SSWCP::build_active_file_json / build_filament_mapping_json implementations could not be verified.

Action items

  • Move set_region off the GUI thread or document the blocking behavior with a timeout justification.
  • Add cleanup for completed m_gateway_account_refresh_workers threads.
  • Fix the request_sync timeout/response race by re-checking readiness under pending_mutex_.
  • Align GatewayService constructor failure handling with the no-exceptions/error-code convention.
  • Replace prohibited structured bindings in SSWCPProtocol.cpp (and audit new/modified files for other prohibited C++17 features).
  • Verify stage_connect_bundle.py asset naming against the actual GitHub release URLs (unverified in this diff).

Limitations: external release asset naming and snapmaker_control CLI behavior are not verifiable from this diff; SSWCP.cpp implementation body was not provided; no CI/sanitizer results were available.


AI 评审(advisory),由 dev-guidelines harness 流水线生成 · head d67d853a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants