Skip to content

Commit cf0d04d

Browse files
committed
Basic implementation of local macOS notifications Pythagora-io#1095
1 parent dcdb1b6 commit cf0d04d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

core/ui/console.py

+19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77

88
log = get_logger(__name__)
99

10+
try:
11+
from rubicon.objc import ObjCClass
12+
NSUserNotification = ObjCClass("NSUserNotification")
13+
NSUserNotificationCenter = ObjCClass("NSUserNotificationCenter")
14+
NOTIFICATIONS_AVAILABLE = True
15+
except ImportError:
16+
log.warning("rubicon.objc not found, macOS notifications disabled")
17+
NOTIFICATIONS_AVAILABLE = False
18+
1019

1120
class PlainConsoleUI(UIBase):
1221
"""
@@ -53,6 +62,13 @@ async def send_feature_finished(
5362
):
5463
pass
5564

65+
async def send_notification(self, title: str, message: str):
66+
if NOTIFICATIONS_AVAILABLE:
67+
notification = NSUserNotification.alloc().init()
68+
notification.title = title
69+
notification.informativeText = message
70+
NSUserNotificationCenter.defaultUserNotificationCenter.deliverNotification_(notification)
71+
5672
async def ask_question(
5773
self,
5874
question: str,
@@ -65,6 +81,9 @@ async def ask_question(
6581
initial_text: Optional[str] = None,
6682
source: Optional[UISource] = None,
6783
) -> UserInput:
84+
# Send notification
85+
await self.send_notification("GPT Pilot Input Required", question)
86+
6887
if source:
6988
print(f"[{source}] {question}")
7089
else:

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ tqdm==4.66.4
4040
typing-extensions==4.12.1
4141
urllib3==2.2.1
4242
wcwidth==0.2.13
43+
rubicon-objc==0.4.9

0 commit comments

Comments
 (0)