mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
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
This commit is contained in:
parent
14b0d66e8a
commit
6deee8538e
3 changed files with 39 additions and 30 deletions
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
|
|
@ -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: {}
|
||||
|
|
|
|||
|
|
@ -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<void
|
|||
const { title = "Roo Code", subtitle = "", message } = options
|
||||
|
||||
try {
|
||||
// First try terminal-notifier (native macOS tool, no compilation needed)
|
||||
await execa("terminal-notifier", [
|
||||
"-title",
|
||||
title,
|
||||
"-subtitle",
|
||||
subtitle || "",
|
||||
"-message",
|
||||
message,
|
||||
"-sound",
|
||||
"default",
|
||||
"-group",
|
||||
"com.roocode.vscode",
|
||||
"-appIcon",
|
||||
path.join(__dirname, "..", "..", "assets", "icons", "icon.png"),
|
||||
])
|
||||
} catch (terminalNotifierError) {
|
||||
// If terminal-notifier is not available, fall back to osascript
|
||||
console.log("terminal-notifier not available, falling back to osascript")
|
||||
// Use node-mac-notifier for native macOS notifications
|
||||
const notification = new Notification(title, {
|
||||
body: message,
|
||||
subtitle: subtitle || undefined,
|
||||
sound: "default",
|
||||
icon: path.join(__dirname, "..", "..", "assets", "icons", "icon.png"),
|
||||
})
|
||||
|
||||
const escape = (str: string = "") => 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}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue