Skip to content

Commit 76a4560

Browse files
committed
feat: system notifications only trigger when vscode unfocus
1 parent cc8e3ef commit 76a4560

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/integrations/notifications/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { execa } from "execa"
22
import { platform } from "os"
3+
import * as vscode from "vscode"
34

45
interface NotificationOptions {
56
title?: string
67
subtitle?: string
78
message: string
9+
force?: boolean // Force notification even if the window is focused
810
}
911

1012
async function showMacOSNotification(options: NotificationOptions): Promise<void> {
@@ -65,6 +67,11 @@ async function showLinuxNotification(options: NotificationOptions): Promise<void
6567

6668
export async function showSystemNotification(options: NotificationOptions): Promise<void> {
6769
try {
70+
if (vscode.window.state.focused && !options.force) {
71+
// If the window is focused, do not show a notification
72+
return
73+
}
74+
6875
const { title = "Roo Code", message } = options
6976

7077
if (!message) {

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export interface WebviewMessage {
280280
title?: string
281281
subtitle?: string
282282
message: string
283+
force?: boolean // Force notification even if the window is focused
283284
}
284285
}
285286

webview-ui/src/components/settings/NotificationSettings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const NotificationSettings = ({
3939
notificationOptions: {
4040
title: t("settings.notifications.system.testTitle"),
4141
message: t("settings.notifications.system.testMessage"),
42+
force: true,
4243
},
4344
})
4445
}

0 commit comments

Comments
 (0)