# Gadget Code Abort Controller The User needs to be able to cancel/abort a work order in progress. ## gadget-code:frontend The view already knows if a work order/prompt is running. When a prompt is running, the prompt Send button becomes a Cancel button. When pressed, we send the `abortWorkOrder` message, wait for the callback, and respond accordingly. The User can also trigger an Abort by pressing Esc twice. On the first press, display a message: Press Esc again to abort. That message times out after 3 seconds. The flow for this: 1. User submits prompt, turn created, processing begins. 2. At any time while processing, the User presses Esc. 1. Display "Press Esc again to abort" and start 3-second timer 2. If User presses Esc again, abort the work order and close this message. 3. When 3 seconds pass, close this message 3. When a work order is aborted or finishes naturally, clean up the abort controller in both gadget-code:frontend and gadget-drone. ## gadget-code:backend `gadget-code:backend` plays no active role in abort procedures other than routing the messages between `gadget-code:frontend` and `gadget-drone`. These aborts don't alter session state in the backend. It is facilitating communication between the components and, in this context, that is it's only job. ## gadget-drone The drone should use a signalable abort. If the IDE sends an `abortWorkOrder` event, signal the AI API abort. The `abortWorkOrder` message should use a callback to indicate success/fail. When the drone receives an `abortWorkOrder` message, it signals the abort controller for the running AI API call. The abort controller aborts the request to the AI provider API, and lets that become an "Aborted" error. The system's error processing will deliver that to the IDE. The IDE looks for the Abort error (let's talk about how we're going to identify and define it!), marks the Turn's status as Aborted. I have added the Aborted status to ChatTurnStatus to be used as the turn's status if aborted. The UI should _not_ display this as an error with giant bright-red styling like some kind of emergency alert. The Abort message should just confirm and display to the User: "The turn was aborted by you."