Skip to content

Refactor desktop startup/shutdown ownership paths and remove duplicated UI validation logic#58

Draft
Copilot wants to merge 4 commits into
masterfrom
copilot/refactor-codebase-for-quality
Draft

Refactor desktop startup/shutdown ownership paths and remove duplicated UI validation logic#58
Copilot wants to merge 4 commits into
masterfrom
copilot/refactor-codebase-for-quality

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 9, 2026

This change targets code quality debt in the desktop entrypoint by removing manual lifetime management and duplicated logic in high-traffic initialization/UI code. It keeps behavior intact while making resource handling and argument conversion safer and easier to reason about.

  • Ownership and lifetime cleanup (RAII)

    • Replaced raw-pointer ownership in src_desktop/main.cpp with std::unique_ptr for app-level objects:
      • SingleInstanceManager
      • WebsocketClient
    • Removed manual new/delete cleanup paths tied to app exit.
  • Windows argument conversion hardening

    • Reworked wWinMain UTF-16 → UTF-8 argv construction to use RAII containers (std::vector<std::string>, std::vector<char*>) instead of manual heap buffers.
    • Corrected conversion buffer sizing/resize flow to avoid null-terminator sizing pitfalls.
  • UI validation deduplication

    • Consolidated repeated “draw invalid field border” ImGui logic into a local helper used by hostname/port/FPS validation, reducing repeated rendering code.
  • Scope cleanup

    • Reverted an unrelated react-web/package.json version bump to keep this PR focused on the desktop refactor.
// Before: manual ownership
SingleInstanceManager* instanceManager = new SingleInstanceManager(...);
...
delete instanceManager;

// After: RAII ownership
std::unique_ptr<SingleInstanceManager> instanceManager =
    std::make_unique<SingleInstanceManager>(...);

Copilot AI and others added 3 commits May 9, 2026 17:39
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.

2 participants