feat: Add --notifications flag to control terminal bell

This commit is contained in:
Paul Gauthier (aider) 2025-03-06 11:55:32 -08:00
parent 665ffe3984
commit 2fe1b1e16e
2 changed files with 9 additions and 1 deletions

View file

@ -813,6 +813,12 @@ def get_parser(default_config_files, git_root):
default=False,
help="Enable/disable multi-line input mode with Meta-Enter to submit (default: False)",
)
group.add_argument(
"--notifications",
action=argparse.BooleanOptionalAction,
default=False,
help="Enable/disable terminal bell notifications when LLM responses are ready (default: False)",
)
group.add_argument(
"--detect-urls",
action=argparse.BooleanOptionalAction,

View file

@ -236,6 +236,7 @@ class InputOutput:
file_watcher=None,
multiline_mode=False,
root=".",
notifications=False,
):
self.placeholder = None
self.interrupted = False
@ -243,6 +244,7 @@ class InputOutput:
self.editingmode = editingmode
self.multiline_mode = multiline_mode
self.bell_on_next_input = False
self.notifications = notifications
no_color = os.environ.get("NO_COLOR")
if no_color is not None and no_color != "":
pretty = False
@ -951,7 +953,7 @@ class InputOutput:
def ring_bell(self):
"""Ring the terminal bell if needed and clear the flag"""
if self.bell_on_next_input:
if self.bell_on_next_input and self.notifications:
print("\a", end="", flush=True) # Ring the bell
self.bell_on_next_input = False # Clear the flag