feat: system notifications only trigger when vscode unfocus

This commit is contained in:
NaccOll 2025-08-12 15:00:47 +08:00
parent cc8e3ef511
commit 76a4560b56
3 changed files with 9 additions and 0 deletions

View file

@ -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<void> {
@ -65,6 +67,11 @@ async function showLinuxNotification(options: NotificationOptions): Promise<void
export async function showSystemNotification(options: NotificationOptions): Promise<void> {
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) {

View file

@ -280,6 +280,7 @@ export interface WebviewMessage {
title?: string
subtitle?: string
message: string
force?: boolean // Force notification even if the window is focused
}
}

View file

@ -39,6 +39,7 @@ export const NotificationSettings = ({
notificationOptions: {
title: t("settings.notifications.system.testTitle"),
message: t("settings.notifications.system.testMessage"),
force: true,
},
})
}