# Gadget Code Drone Manager

Drone Manager is a view accessible from the Authenticated Home view as a cog icon link added to the Drones list in the right sidebar with a hover label of "Drone Manager".

The user selects the cog icon to navigate to the Drone Manager view.

The Drone Manager view presents the User's entire unfiltered list of drones as two separate lists:

- Online drones (Available or Busy)
- Offline drones

The Drone List should be a flex column that is split 50/50 vertically with the online drones on top and offline drones on the bottom. The lists scroll within their panel. The whole sidebar does not scroll. The user can select a drone in either list to load the drone's details in the content area of the view.

The user may only select one drone. They cannot have a selected item in both lists at the same time. So if they select an item in one list, clear the selection from the other list (and vice versa). Or, implement selectedDrone as a property on the view, which would be very useful throughout the whole view, and have both lists update their selected item based on this value.

The User cannot delete a DroneRegistration record. They are tied to data throughout the platform. And we are not yet ready to author the delete operation.

The User _can_ change the status of a drone to `DroneStatus.Offline` if it isn't offline. This lets the User either remove a failed drone from a list it shouldn't be in, or trigger the drone to terminate if it's still running.

## Drone Termination

The User changing a drone's status to Offline means they want the Drone to terminate. We will need to extend [Socket Protocol](../../docs/socket-protocol.md) to add the `requestTermination` message - which takes no parameters.

When a drone receives the `requestTermination` message, it does no state validation and doesn't worry about whether it's currently running an Agentic Workflow Loop, performing some other action(s), or idle. gadget-drone simply sends itself a SIGINT so that the handler in hookProcessSignals does it's job and shuts the drone down.

The drone _should_ update it's own status to Offline during this processing. We check for this to happen within 10 seconds. If it doesn't happen within 10 seconds, we set the registration to Offline and tell the user we timed out waiting for the drone to shut down, and have marked it Offline by force.

An online drone will display a Terminate button in the info panel for the User to select if they want to terminate the drone process. If the drone is known to be working on something, we confirm with, "Are you sure you want to terminate the drone? Any work or operations current in progress may be lost." If the drone is idle (no session lock) we send the `requestTerminate` message without confirmation.

## Drone Monitor

When a drone is selected and we populate the content area with information about the drone, the next row of the view is the Drone Monitor, which is backed by the [DroneMonitor](../src/models/drone-monitor.ts) model.

The monitor wants to be a high-tech-looking display of memory use history, and ai operations per minute.

The `logs` parameter is used for tracking memory use in the logging system and should be graphed to monitor log data production.

The monitor updates chart data once per minute. Live updates arriving on the dron's socket are monitored in the view in real-time.
