Skip to content

Refactor connection commands into callbacks#865

Merged
Turnlings merged 6 commits into
mainfrom
863-fix-commands-being-added-multiple-times
Nov 26, 2025
Merged

Refactor connection commands into callbacks#865
Turnlings merged 6 commits into
mainfrom
863-fix-commands-being-added-multiple-times

Conversation

@Turnlings

Copy link
Copy Markdown
Contributor

Apply the same technique as is used for rebooting to connection and disconnection. This should fix both previous issues of the command being added when it shouldn't, and also it not existing when it should.

Copilot AI review requested due to automatic review settings November 22, 2025 23:22
@Turnlings Turnlings linked an issue Nov 22, 2025 that may be closed by this pull request
@Turnlings Turnlings self-assigned this Nov 22, 2025

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 PR refactors connection and disconnection commands to use callback hooks, applying the same pattern already used for the reboot functionality. This addresses timing issues where commands were either added when they shouldn't be or missing when needed.

  • Renamed useRebootCallback.js to droneConnectionCallbacks.js and added two new hooks: useConnectToDroneFromButtonCallback and useDisconnectFromDroneCallback
  • Moved command registration from navbar.jsx to commandHandler.js where callbacks are obtained directly from the hooks
  • Updated all import statements across affected files to reference the renamed module

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
gcs/src/helpers/droneConnectionCallbacks.js Added new connection/disconnection callback hooks alongside the existing reboot callback
gcs/src/components/spotlight/commandHandler.js Imported and registered the new connection callbacks as commands
gcs/src/components/navbar.jsx Removed local command functions and useEffect, now uses callbacks from hooks
gcs/src/params.jsx Updated import path to reference renamed droneConnectionCallbacks module
gcs/src/components/dashboard/tabsSectionTabs/actionTabsSection.jsx Updated import path to reference renamed droneConnectionCallbacks module
Comments suppressed due to low confidence (2)

gcs/src/helpers/droneConnectionCallbacks.js:36

  • The new hook functions useConnectToDroneFromButtonCallback and useDisconnectFromDroneCallback are missing JSDoc documentation. For consistency with the existing useRebootCallback function (lines 16-20), these hooks should include documentation describing their purpose and return values.
    gcs/src/helpers/droneConnectionCallbacks.js:43
  • The new hook function useDisconnectFromDroneCallback is missing JSDoc documentation. For consistency with the existing useRebootCallback function (lines 16-20), this hook should include documentation describing its purpose and return value.

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

Comment thread gcs/src/components/navbar.jsx Outdated

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

gcs/src/helpers/droneConnectionCallbacks.js:43

  • Missing JSDoc documentation for the new hook functions. The existing useRebootCallback function has comprehensive documentation. Consider adding similar documentation for consistency:
/**
 * Hook that returns a callback to connect to a drone from a button click.
 * Fetches available COM ports and opens the connection modal.
 * @returns Callback to initiate drone connection
 */
export function useConnectToDroneFromButtonCallback() {
  // ...
}

/**
 * Hook that returns a callback to disconnect from a drone.
 * @returns Callback to disconnect from drone
 */
export function useDisconnectFromDroneCallback() {
  // ...
}

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

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


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

@Turnlings Turnlings requested a review from a team November 22, 2025 23:38
Comment thread gcs/src/helpers/droneConnectionCallbacks.js Outdated
Comment thread gcs/src/helpers/droneConnectionCallbacks.js
Comment thread gcs/src/helpers/droneConnectionCallbacks.js

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


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

@Turnlings Turnlings merged commit 0698d22 into main Nov 26, 2025
12 checks passed
@Turnlings Turnlings deleted the 863-fix-commands-being-added-multiple-times branch November 26, 2025 20:55
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.

Fix commands being added multiple times

3 participants