feat: add exit event tracking for Control-C and /exit commands

This commit is contained in:
Paul Gauthier 2024-11-30 09:52:59 -08:00
parent c1c4193b1d
commit 295040c94c
2 changed files with 5 additions and 1 deletions

View file

@ -885,6 +885,7 @@ class Coder:
thresh = 2 # seconds
if self.last_keyboard_interrupt and now - self.last_keyboard_interrupt < thresh:
self.io.tool_warning("\n\n^C KeyboardInterrupt")
self.event("exit", reason="Control-C")
sys.exit()
self.io.tool_warning("\n\n^C again to exit")

View file

@ -909,6 +909,7 @@ class Commands:
def cmd_exit(self, args):
"Exit the application"
self.coder.event("exit", reason="/exit")
sys.exit()
def cmd_quit(self, args):
@ -1085,7 +1086,9 @@ class Commands:
self.io.tool_error("To use /voice you must provide an OpenAI API key.")
return
try:
self.voice = voice.Voice(audio_format=self.args.voice_format, device_name=self.args.voice_input_device)
self.voice = voice.Voice(
audio_format=self.args.voice_format, device_name=self.args.voice_input_device
)
except voice.SoundDeviceError:
self.io.tool_error(
"Unable to import `sounddevice` and/or `soundfile`, is portaudio installed?"