fix(background-cancel): skip notification when user explicitly cancels tasks
- Add skipNotification option to cancelTask method - Apply skipNotification to background_cancel tool - Prevents unwanted notifications when user cancels via tool
This commit is contained in:
@@ -832,7 +832,7 @@ export class BackgroundManager {
|
||||
|
||||
async cancelTask(
|
||||
taskId: string,
|
||||
options?: { source?: string; reason?: string; abortSession?: boolean }
|
||||
options?: { source?: string; reason?: string; abortSession?: boolean; skipNotification?: boolean }
|
||||
): Promise<boolean> {
|
||||
const task = this.tasks.get(taskId)
|
||||
if (!task || (task.status !== "running" && task.status !== "pending")) {
|
||||
@@ -878,7 +878,6 @@ export class BackgroundManager {
|
||||
}
|
||||
|
||||
this.cleanupPendingByParent(task)
|
||||
this.markForNotification(task)
|
||||
|
||||
if (abortSession && task.sessionID) {
|
||||
this.client.session.abort({
|
||||
@@ -886,6 +885,13 @@ export class BackgroundManager {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
if (options?.skipNotification) {
|
||||
log(`[background-agent] Task cancelled via ${source} (notification skipped):`, task.id)
|
||||
return true
|
||||
}
|
||||
|
||||
this.markForNotification(task)
|
||||
|
||||
try {
|
||||
await this.notifyParentSession(task)
|
||||
log(`[background-agent] Task cancelled via ${source}:`, task.id)
|
||||
|
||||
Reference in New Issue
Block a user