From 76a4560b56aabadcdc46490cd5ffa768a2ccc72e Mon Sep 17 00:00:00 2001 From: NaccOll Date: Tue, 12 Aug 2025 15:00:47 +0800 Subject: [PATCH] feat: system notifications only trigger when vscode unfocus --- src/integrations/notifications/index.ts | 7 +++++++ src/shared/WebviewMessage.ts | 1 + .../src/components/settings/NotificationSettings.tsx | 1 + 3 files changed, 9 insertions(+) diff --git a/src/integrations/notifications/index.ts b/src/integrations/notifications/index.ts index 8a26c1bf10..8d236b9142 100644 --- a/src/integrations/notifications/index.ts +++ b/src/integrations/notifications/index.ts @@ -1,10 +1,12 @@ import { execa } from "execa" import { platform } from "os" +import * as vscode from "vscode" interface NotificationOptions { title?: string subtitle?: string message: string + force?: boolean // Force notification even if the window is focused } async function showMacOSNotification(options: NotificationOptions): Promise { @@ -65,6 +67,11 @@ async function showLinuxNotification(options: NotificationOptions): Promise { try { + if (vscode.window.state.focused && !options.force) { + // If the window is focused, do not show a notification + return + } + const { title = "Roo Code", message } = options if (!message) { diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index eb6f4578f8..5723a042da 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -280,6 +280,7 @@ export interface WebviewMessage { title?: string subtitle?: string message: string + force?: boolean // Force notification even if the window is focused } } diff --git a/webview-ui/src/components/settings/NotificationSettings.tsx b/webview-ui/src/components/settings/NotificationSettings.tsx index 3fe1bad616..668775a788 100644 --- a/webview-ui/src/components/settings/NotificationSettings.tsx +++ b/webview-ui/src/components/settings/NotificationSettings.tsx @@ -39,6 +39,7 @@ export const NotificationSettings = ({ notificationOptions: { title: t("settings.notifications.system.testTitle"), message: t("settings.notifications.system.testMessage"), + force: true, }, }) }