Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.

fix: board connection#105

Merged
xiduzo merged 5 commits into
mainfrom
fix/board-connection
Jan 8, 2026
Merged

fix: board connection#105
xiduzo merged 5 commits into
mainfrom
fix/board-connection

Conversation

@xiduzo

@xiduzo xiduzo commented Jan 8, 2026

Copy link
Copy Markdown
Owner

This pull request introduces significant improvements to the board connection and flashing logic in the Electron app, focusing on robustness, error handling, and preventing race conditions during critical operations. The main enhancements include the addition of a port operation lock mechanism, improved handling of board connection and flashing states, and refactoring of flow transmission to the runner process. These changes collectively make the connection process more reliable and easier to debug.

Board connection and flashing robustness:

  • Added a port operation lock mechanism in port-manager.ts to prevent port polling during critical operations like flashing and connecting, with lock acquisition and release functions to avoid race conditions. [1] [2]
  • Refactored connection and flashing logic in board-connection.ts to use the port operation lock, ensuring that port polling does not interfere with these processes. Improved cleanup and error handling throughout the connection lifecycle. [1] [2]
  • Enhanced flashing logic to handle cases where the port disconnects and reappears, including waiting for the port to come back after flashing and handling timeouts and errors more gracefully. [1] [2]

Flow transmission and connection state:

  • Introduced a shared sendFlowToRunner function and a getCurrentConnectionState function to centralize flow transmission and connection status queries, improving code maintainability and reliability. [1] [2] [3]
  • Updated IPC handlers in ipc.ts to use the new flow transmission and connection status functions, streamlining communication between the main and renderer processes. [1] [2]

Minor cleanup and import adjustments:

  • Cleaned up unused imports and improved import organization in app.tsx and related files for better code clarity. [1] [2]
  • Added missing imports for new functions related to connection state and flow transmission.

These changes should make board connection and flashing much more reliable, reduce intermittent errors, and simplify future maintenance and debugging.

Copilot AI review requested due to automatic review settings January 8, 2026 12:02
@vercel

vercel Bot commented Jan 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
microflow Skipped Skipped Jan 8, 2026 0:27am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances board connection and flashing reliability in the Electron app by introducing a port operation lock mechanism, improved error handling during critical operations, and centralizing flow transmission logic. Additionally, it refactors MQTT configuration to use a unified URL format with validation schema.

Key changes:

  • Added port operation locking to prevent race conditions during flashing and connection
  • Enhanced flashing logic to handle port disconnection/reconnection gracefully
  • Centralized flow transmission and connection state management with shared functions
  • Refactored MQTT configuration from separate host/port/protocol fields to a unified URL format with Zod validation

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/runtime/src/base.ts Added debug logging to postMessage method
packages/mqtt-provider/src/stores/mqtt.ts Replaced separate host/port/protocol fields with unified URL format including validation schema and parsing logic
packages/mqtt-provider/package.json Added zod dependency for URL validation
yarn.lock Updated dependencies to include zod
apps/figma-plugin/src/ui/pages/mqtt/index.tsx Updated MQTT form to use URL field instead of separate host/port fields with tooltip documentation
apps/electron-app/src/render/hooks/useSignalNodesAndEdges.ts Added commented debug log
apps/electron-app/src/render/hooks/useFlowSync.ts Added connection status request on mount and flowChanged to dependency array
apps/electron-app/src/render/components/forms/MqttSettingsForm.tsx Updated MQTT form to use URL field with validation
apps/electron-app/src/preload.ts Added ipc-get-connection-status channel
apps/electron-app/src/main/port-manager.ts Added port operation lock mechanism with acquire/release functions and startup board detection
apps/electron-app/src/main/ipc.ts Added getCurrentConnectionState handler and refactored flow sending to use shared function
apps/electron-app/src/main/board-connection.ts Major refactoring: added lock usage, enhanced error handling, added waitForPortToReappear function, improved cleanup logic
apps/electron-app/src/app.tsx Cleaned up unused imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/electron-app/src/render/hooks/useFlowSync.ts Outdated
Comment thread packages/mqtt-provider/src/stores/mqtt.ts
Comment thread packages/runtime/src/base.ts Outdated
Comment thread packages/mqtt-provider/src/stores/mqtt.ts Outdated
Comment thread packages/mqtt-provider/src/stores/mqtt.ts Outdated
Comment thread packages/mqtt-provider/src/stores/mqtt.ts Outdated
Comment thread apps/electron-app/src/main/board-connection.ts
Comment thread packages/mqtt-provider/src/stores/mqtt.ts Outdated
@xiduzo xiduzo merged commit 3acc12c into main Jan 8, 2026
8 of 9 checks passed
@xiduzo xiduzo deleted the fix/board-connection branch January 8, 2026 12:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants