mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
feat: Add desktop notification support with notify-py package
This commit is contained in:
parent
813de04596
commit
38e8d27416
2 changed files with 26 additions and 2 deletions
|
@ -795,6 +795,12 @@ def get_parser(default_config_files, git_root):
|
|||
default=default_env_file(git_root),
|
||||
help="Specify the .env file to load (default: .env in git root)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--notification",
|
||||
choices=["bell", "desktop", "both", "none"],
|
||||
default="bell",
|
||||
help="Notification method when LLM completes (default: bell)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--suggest-shell-commands",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
|
|
22
aider/io.py
22
aider/io.py
|
@ -8,6 +8,7 @@ from collections import defaultdict
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from io import StringIO
|
||||
from notifypy import Notify
|
||||
from pathlib import Path
|
||||
|
||||
from prompt_toolkit.completion import Completer, Completion, ThreadedCompleter
|
||||
|
@ -236,6 +237,7 @@ class InputOutput:
|
|||
file_watcher=None,
|
||||
multiline_mode=False,
|
||||
root=".",
|
||||
notification="bell",
|
||||
):
|
||||
self.placeholder = None
|
||||
self.interrupted = False
|
||||
|
@ -243,6 +245,7 @@ class InputOutput:
|
|||
self.editingmode = editingmode
|
||||
self.multiline_mode = multiline_mode
|
||||
self.bell_on_next_input = False
|
||||
self.notification_type = notification
|
||||
no_color = os.environ.get("NO_COLOR")
|
||||
if no_color is not None and no_color != "":
|
||||
pretty = False
|
||||
|
@ -949,10 +952,25 @@ class InputOutput:
|
|||
"""Clear the bell flag (optional, as we'll clear it after ringing)"""
|
||||
self.bell_on_next_input = False
|
||||
|
||||
def show_desktop_notification(self):
|
||||
"""Show a desktop notification that the LLM has completed"""
|
||||
notification = Notify()
|
||||
notification.title = "Aider"
|
||||
notification.message = "LLM processing complete"
|
||||
notification.send()
|
||||
|
||||
def ring_bell(self):
|
||||
"""Ring the terminal bell if needed and clear the flag"""
|
||||
"""Ring the terminal bell or show desktop notification if needed and clear the flag"""
|
||||
if self.bell_on_next_input:
|
||||
print("\a", end="", flush=True) # Ring the bell
|
||||
if self.notification_type in ("bell", "both"):
|
||||
print("\a", end="", flush=True) # Ring the bell
|
||||
|
||||
if self.notification_type in ("desktop", "both"):
|
||||
try:
|
||||
self.show_desktop_notification()
|
||||
except Exception as e:
|
||||
self.tool_warning(f"Desktop notification failed: {e}")
|
||||
|
||||
self.bell_on_next_input = False # Clear the flag
|
||||
|
||||
def toggle_multiline_mode(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue