diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index a3840be49..6c885e96e 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -49,6 +49,11 @@ interface Todo { id: string } +interface QueueItem { + task: BackgroundTask + input: LaunchInput +} + export class BackgroundManager { private static cleanupManagers = new Set() private static cleanupRegistered = false @@ -65,6 +70,9 @@ export class BackgroundManager { private config?: BackgroundTaskConfig + private queuesByKey: Map = new Map() + private processingKeys: Set = new Set() + constructor(ctx: PluginInput, config?: BackgroundTaskConfig) { this.tasks = new Map() this.notifications = new Map() @@ -252,6 +260,13 @@ export class BackgroundManager { return undefined } + private getConcurrencyKeyFromInput(input: LaunchInput): string { + if (input.model) { + return `${input.model.providerID}/${input.model.modelID}` + } + return input.agent + } + /** * Track a task created elsewhere (e.g., from delegate_task) for notification tracking. * This allows tasks created by other tools to receive the same toast/prompt notifications. @@ -1129,6 +1144,8 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea this.tasks.clear() this.notifications.clear() this.pendingByParent.clear() + this.queuesByKey.clear() + this.processingKeys.clear() this.unregisterProcessCleanup() log("[background-agent] Shutdown complete")