feat(background-agent): implement per-key queue processor

This commit is contained in:
justsisyphus
2026-01-18 14:36:06 +09:00
parent 481770e599
commit 54f448583c

View File

@@ -130,7 +130,36 @@ export class BackgroundManager {
}
private async processKey(key: string): Promise<void> {
// TODO: Implement in Task 4
if (this.processingKeys.has(key)) {
return
}
this.processingKeys.add(key)
try {
const queue = this.queuesByKey.get(key)
while (queue && queue.length > 0) {
const item = queue[0]
await this.concurrencyManager.acquire(key)
if (item.task.status === "cancelled") {
this.concurrencyManager.release(key)
queue.shift()
continue
}
try {
await this.startTask(item)
} catch (error) {
log("[background-agent] Error starting task:", error)
}
queue.shift()
}
} finally {
this.processingKeys.delete(key)
}
}
private async startTask(item: QueueItem): Promise<void> {