aider icon indicating copy to clipboard operation
aider copied to clipboard

Uncaught KeyboardInterrupt during `io.confirm_ask`

Open felixscherz opened this issue 6 months ago • 0 comments

Issue

Hi, thanks for this tool! Sending keyboard interrupt with Ctrl+C during the confirmation prompt causes an uncaught KeyboardInterrupt to be raised. I noticed that the global exception handler set with report_uncaught_exceptions intentionally ignores KeyboardInterrupt. I would expect Ctrl+C to terminate the session without raising the exception so if desired I'd be happy to send a PR to implement this:)

$ aider --version
aider 0.82.2

$ aider
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
No git repo found, create one to track aider's changes (recommended)? (Y)es/(N)o [Yes]:
Traceback (most recent call last):
  File "/Users/felixscherz/.local/bin/aider", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/aider/main.py", line 729, in main
    git_root = setup_git(git_root, io)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/aider/main.py", line 121, in setup_git
    elif cwd and io.confirm_ask(
                 ^^^^^^^^^^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/aider/io.py", line 65, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/aider/io.py", line 866, in confirm_ask
    res = self.prompt_session.prompt(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
    return self.app.run(
           ^^^^^^^^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/prompt_toolkit/application/application.py", line 1002, in run
    return asyncio.run(coro)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 673, in run_until_complete
    self.run_forever()
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 640, in run_forever
    self._run_once()
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1992, in _run_once
    handle._run()
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/prompt_toolkit/application/application.py", line 886, in run_async
    return await _run_async(f)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/felixscherz/.dotfiles/bin/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/prompt_toolkit/application/application.py", line 746, in _run_async
    result = await f
             ^^^^^^^
KeyboardInterrupt

Version and model info

Version: 0.82.2

felixscherz avatar Apr 25 '25 20:04 felixscherz