Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TelemetryService } from "@roo-code/telemetry"

import { defaultModeSlug, getModeBySlug } from "../../shared/modes"
import type { ToolParamName, ToolResponse } from "../../shared/tools"
import { NotificationService, NotificationType } from "../../services/notification"

import { fetchInstructionsTool } from "../tools/fetchInstructionsTool"
import { listFilesTool } from "../tools/listFilesTool"
Expand Down Expand Up @@ -266,6 +267,47 @@ export async function presentAssistantMessage(cline: Task) {
progressStatus?: ToolProgressStatus,
isProtected?: boolean,
) => {
// Initialize notification service and send desktop notification for approval requests
const provider = cline.providerRef.deref()
if (provider) {
try {
const notificationService = new NotificationService(provider.context)

// Determine the tool name from the current block for better notification context
let toolName = block.name
let notificationMessage = partialMessage || `Approval required for ${toolName}`

// Customize notification message based on tool type
switch (toolName) {
case "execute_command":
notificationMessage = `Execute command: ${block.params.command}`
break
case "write_to_file":
notificationMessage = `Write to file: ${block.params.path}`
break
case "read_file":
// Handle both old and new read_file parameter formats
const filePath =
typeof block.params.args === "string"
? "multiple files"
: block.params.path || "unknown"
notificationMessage = `Read file: ${filePath}`
break
case "browser_action":
notificationMessage = `Browser action: ${block.params.action}`
break
default:
notificationMessage = `${toolName} - Approval required`
break
}

await notificationService.sendApprovalRequest(notificationMessage, toolName)
} catch (error) {
// Don't let notification errors break the approval flow
console.error("Failed to send desktop notification:", error)
}
}

const { response, text, images } = await cline.ask(
type,
partialMessage,
Expand Down Expand Up @@ -307,6 +349,18 @@ export async function presentAssistantMessage(cline: Task) {
const handleError = async (action: string, error: Error) => {
const errorString = `Error ${action}: ${JSON.stringify(serializeError(error))}`

// Send desktop notification for errors
const provider = cline.providerRef.deref()
if (provider) {
try {
const notificationService = new NotificationService(provider.context)
await notificationService.sendError(`Error ${action}`, error)
} catch (notificationError) {
// Don't let notification errors break the error handling flow
console.error("Failed to send error notification:", notificationError)
}
}

await cline.say(
"error",
`Error ${action}:\n${error.message ?? JSON.stringify(serializeError(error), null, 2)}`,
Expand Down
44 changes: 44 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,48 @@
"type": "string",
"default": "",
"description": "%settings.autoImportSettingsPath.description%"
},
"roo-cline.notifications.enabled": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.enabled.description%"
},
"roo-cline.notifications.showApprovalRequests": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.showApprovalRequests.description%"
},
"roo-cline.notifications.showErrors": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.showErrors.description%"
},
"roo-cline.notifications.showTaskCompletion": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.showTaskCompletion.description%"
},
"roo-cline.notifications.showUserInputRequired": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.showUserInputRequired.description%"
},
"roo-cline.notifications.showSessionTimeouts": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.showSessionTimeouts.description%"
},
"roo-cline.notifications.timeout": {
"type": "number",
"default": 10000,
"minimum": 0,
"maximum": 60000,
"description": "%settings.notifications.timeout.description%"
},
"roo-cline.notifications.sound": {
"type": "boolean",
"default": true,
"description": "%settings.notifications.sound.description%"
}
}
}
Expand Down Expand Up @@ -432,6 +474,7 @@
"monaco-vscode-textmate-theme-converter": "^0.1.7",
"node-cache": "^5.1.2",
"node-ipc": "^12.0.0",
"node-notifier": "^10.0.1",
"openai": "^5.0.0",
"os-name": "^6.0.0",
"p-limit": "^6.2.0",
Expand Down Expand Up @@ -476,6 +519,7 @@
"@types/mocha": "^10.0.10",
"@types/node": "20.x",
"@types/node-cache": "^4.1.3",
"@types/node-notifier": "^8.0.5",
"@types/node-ipc": "^9.2.3",
"@types/proper-lockfile": "^4.1.4",
"@types/ps-tree": "^1.1.6",
Expand Down
10 changes: 9 additions & 1 deletion src/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,13 @@
"settings.vsCodeLmModelSelector.family.description": "The family of the language model (e.g. gpt-4)",
"settings.customStoragePath.description": "Custom storage path. Leave empty to use the default location. Supports absolute paths (e.g. 'D:\\RooCodeStorage')",
"settings.enableCodeActions.description": "Enable Roo Code quick fixes",
"settings.autoImportSettingsPath.description": "Path to a RooCode configuration file to automatically import on extension startup. Supports absolute paths and paths relative to the home directory (e.g. '~/Documents/roo-code-settings.json'). Leave empty to disable auto-import."
"settings.autoImportSettingsPath.description": "Path to a RooCode configuration file to automatically import on extension startup. Supports absolute paths and paths relative to the home directory (e.g. '~/Documents/roo-code-settings.json'). Leave empty to disable auto-import.",
"settings.notifications.enabled.description": "Enable desktop notifications for Roo Code events",
"settings.notifications.showApprovalRequests.description": "Show desktop notifications when approval is required for tool operations",
"settings.notifications.showErrors.description": "Show desktop notifications for errors and failures",
"settings.notifications.showTaskCompletion.description": "Show desktop notifications when tasks are completed",
"settings.notifications.showUserInputRequired.description": "Show desktop notifications when user input is required",
"settings.notifications.showSessionTimeouts.description": "Show desktop notifications for session timeouts",
"settings.notifications.timeout.description": "Notification timeout in milliseconds (0 = no timeout, max 60 seconds)",
"settings.notifications.sound.description": "Play sound with desktop notifications"
}
Loading