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)
|
||||
|
||||
@@ -146,14 +146,14 @@ export function createContextInjectorMessagesTransformHook(
|
||||
return
|
||||
}
|
||||
|
||||
// synthetic part 패턴 (minimal fields)
|
||||
// synthetic part pattern (minimal fields)
|
||||
const syntheticPart = {
|
||||
id: `synthetic_hook_${Date.now()}`,
|
||||
messageID: lastUserMessage.info.id,
|
||||
sessionID: (lastUserMessage.info as { sessionID?: string }).sessionID ?? "",
|
||||
type: "text" as const,
|
||||
text: pending.merged,
|
||||
synthetic: true, // UI에서 숨겨짐
|
||||
synthetic: true, // hidden in UI
|
||||
}
|
||||
|
||||
lastUserMessage.parts.splice(textPartIndex, 0, syntheticPart as Part)
|
||||
|
||||
Reference in New Issue
Block a user