fix: Handle KeyboardInterrupt in show_send_output_stream

This commit is contained in:
Paul Gauthier 2024-08-13 05:54:19 -07:00 committed by Paul Gauthier (aider)
parent c286135eeb
commit fb0066cbf0

View file

@ -1259,9 +1259,9 @@ class Coder:
yield from self.show_send_output_stream(completion) yield from self.show_send_output_stream(completion)
else: else:
self.show_send_output(completion) self.show_send_output(completion)
except KeyboardInterrupt: except KeyboardInterrupt as kbi:
self.keyboard_interrupt() self.keyboard_interrupt()
interrupted = True raise kbi
finally: finally:
self.io.log_llm_history( self.io.log_llm_history(
"LLM RESPONSE", "LLM RESPONSE",
@ -1276,10 +1276,7 @@ class Coder:
if args: if args:
self.io.ai_output(json.dumps(args, indent=4)) self.io.ai_output(json.dumps(args, indent=4))
if interrupted: self.calculate_and_show_tokens_and_cost(messages, completion)
raise KeyboardInterrupt
self.calculate_and_show_tokens_and_cost(messages, completion)
def show_send_output(self, completion): def show_send_output(self, completion):
if self.verbose: if self.verbose: