If input is in command/shell mode, exit to normal mode
If shell command is running, kill it
If approval menu is active, reject it
If ask-user menu is active, cancel it
If queued messages exist, pop the last one (LIFO)
If agent is running, interrupt it (restoring the interrupted prompt
to the chat input when it is empty and no user-visible model output
— text or a tool call — has appeared yet for the turn)
Otherwise, a second Esc clears the chat input draft (undoable)