diff --git a/core/ui/console.py b/core/ui/console.py index 0716fc797..077c9aa42 100644 --- a/core/ui/console.py +++ b/core/ui/console.py @@ -7,6 +7,15 @@ log = get_logger(__name__) +try: + from rubicon.objc import ObjCClass + NSUserNotification = ObjCClass("NSUserNotification") + NSUserNotificationCenter = ObjCClass("NSUserNotificationCenter") + NOTIFICATIONS_AVAILABLE = True +except ImportError: + log.warning("rubicon.objc not found, macOS notifications disabled") + NOTIFICATIONS_AVAILABLE = False + class PlainConsoleUI(UIBase): """ @@ -53,6 +62,13 @@ async def send_feature_finished( ): pass + async def send_notification(self, title: str, message: str): + if NOTIFICATIONS_AVAILABLE: + notification = NSUserNotification.alloc().init() + notification.title = title + notification.informativeText = message + NSUserNotificationCenter.defaultUserNotificationCenter.deliverNotification_(notification) + async def ask_question( self, question: str, @@ -65,6 +81,9 @@ async def ask_question( initial_text: Optional[str] = None, source: Optional[UISource] = None, ) -> UserInput: + # Send notification + await self.send_notification("GPT Pilot Input Required", question) + if source: print(f"[{source}] {question}") else: diff --git a/requirements.txt b/requirements.txt index 2ef591a07..ad748efdf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,3 +40,4 @@ tqdm==4.66.4 typing-extensions==4.12.1 urllib3==2.2.1 wcwidth==0.2.13 +rubicon-objc=0.4.9