From 6deee8538ea34328d77d714e848d1f936b7f0ade Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Tue, 26 Aug 2025 17:59:40 -0600 Subject: [PATCH] refactor: use node-mac-notifier for macOS notifications - Replace terminal-notifier and osascript fallback with node-mac-notifier - Provides native macOS notifications without opening Script Editor - Maintains same notification functionality with cleaner implementation --- pnpm-lock.yaml | 28 +++++++++++++++-- src/integrations/notifications/index.ts | 40 ++++++++----------------- src/package.json | 1 + 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bc223d8760..2835f7342f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -679,6 +679,9 @@ importers: node-ipc: specifier: ^12.0.0 version: 12.0.0 + node-mac-notifier: + specifier: ^1.2.0 + version: 1.2.0 node-notifier: specifier: ^10.0.1 version: 10.0.1 @@ -5803,6 +5806,9 @@ packages: event-stream@3.3.4: resolution: {integrity: sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==} + event-target-shim@1.1.1: + resolution: {integrity: sha512-9hnrQp9HNLexUaxXvgV83/DNrZET6Yjr5wFZowmv2sfbxYrpGT4YB4pmgvoJ6NmUUr/CDQbC1l99v9EaX3mO5w==} + event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} @@ -7756,6 +7762,9 @@ packages: resolution: {integrity: sha512-QHJ2gAJiqA3cM7cQiRjLsfCOBRB0TwQ6axYD4FSllQWipEbP6i7Se1dP8EzPKk5J1nCe27W69eqPmCoKyQ61Vg==} engines: {node: '>=14'} + node-mac-notifier@1.2.0: + resolution: {integrity: sha512-+9FZ01BbPMv3pQVRWgPlaIKbhQl35Pn3WmRg96zIrCJHb4XvClnAqc0+aPfHrWs8o1PYMAQFeYK5tF69ljkKQw==} + node-notifier@10.0.1: resolution: {integrity: sha512-YX7TSyDukOZ0g+gmzjB6abKu+hTGvO8+8+gIFDsRCU2t8fLV/P2unmt+LGFaIa4y64aX98Qksa97rgz4vMNeLQ==} @@ -9671,6 +9680,11 @@ packages: resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==} hasBin: true + uuid@3.4.0: + resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} + deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. + hasBin: true + uuid@8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true @@ -14232,7 +14246,6 @@ snapshots: bindings@1.5.0: dependencies: file-uri-to-path: 1.0.0 - optional: true bl@4.1.0: dependencies: @@ -15567,6 +15580,8 @@ snapshots: stream-combiner: 0.0.4 through: 2.3.8 + event-target-shim@1.1.1: {} + event-target-shim@5.0.1: {} eventemitter3@4.0.7: {} @@ -15805,8 +15820,7 @@ snapshots: dependencies: flat-cache: 4.0.1 - file-uri-to-path@1.0.0: - optional: true + file-uri-to-path@1.0.0: {} fill-range@7.1.1: dependencies: @@ -17930,6 +17944,12 @@ snapshots: js-queue: 2.0.2 strong-type: 1.1.0 + node-mac-notifier@1.2.0: + dependencies: + bindings: 1.5.0 + event-target-shim: 1.1.1 + uuid: 3.4.0 + node-notifier@10.0.1: dependencies: growly: 1.3.0 @@ -20141,6 +20161,8 @@ snapshots: uuid@11.1.0: {} + uuid@3.4.0: {} + uuid@8.3.2: {} uuid@9.0.1: {} diff --git a/src/integrations/notifications/index.ts b/src/integrations/notifications/index.ts index efe8dc720c..7ade049d73 100644 --- a/src/integrations/notifications/index.ts +++ b/src/integrations/notifications/index.ts @@ -2,6 +2,7 @@ import { execa } from "execa" import { platform } from "os" import * as vscode from "vscode" import * as path from "path" +import { Notification } from "node-mac-notifier" interface NotificationOptions { title?: string @@ -14,34 +15,19 @@ async function showMacOSNotification(options: NotificationOptions): Promise str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'") - const script = `display notification "${escape(message)}" with title "${escape(title)}" subtitle "${escape(subtitle)}" sound name "default"` - - try { - await execa("osascript", ["-e", script]) - } catch (osascriptError) { - console.error("Failed to show macOS notification:", osascriptError) - throw new Error(`Failed to show macOS notification: ${osascriptError}`) - } + // Show the notification immediately + notification.show() + } catch (error) { + console.error("Failed to show macOS notification:", error) + throw new Error(`Failed to show macOS notification: ${error}`) } } diff --git a/src/package.json b/src/package.json index bfc9ad7476..2fcc8c0c87 100644 --- a/src/package.json +++ b/src/package.json @@ -464,6 +464,7 @@ "monaco-vscode-textmate-theme-converter": "^0.1.7", "node-cache": "^5.1.2", "node-ipc": "^12.0.0", + "node-mac-notifier": "^1.2.0", "node-notifier": "^10.0.1", "ollama": "^0.5.17", "openai": "^5.0.0",